9. Writer Components - Writer, WriterFun
9.1. Writer Functions - WriterFun
The writer function module, WriterFun, maintains function pointers to data writing functions which form a high-level data writing interface. The associated Writer module which is described in the following chapter, is designed to implement a specific variety of writing functions and to load the corresponding function pointers into a WriterFun object. Rather than accessing the functions of a particular Writer device object directly, the user accesses the functions through a WriterFun object. In this way data writing independence is achieved. When overloading a WriterFun object to create a custom object, it is the responsibility of the user to register all needed functions. The WriterFun module contains the following functions:
Begin and end an instance of an object
vis_WriterFunBegin()
- create an instance of a WriterFun objectvis_WriterFunEnd()
- destroy an instance of a WriterFun object
Set the object functions
vis_WriterFunSetWriteStateFunction()
- set the function to write a State objectvis_WriterFunSetWriteRedMatFunction()
- set the function to write a RedMat objectvis_WriterFunSetWriteHistoryFunction()
- set the function to write a History objectvis_WriterFunSetWriteModelFunction()
- set the function to write a Model objectvis_WriterFunSetGetFilePathFunction()
- set the function to get the ouput file path
Write data to a file
vis_WriterFunWriteState()
- write a State objectvis_WriterFunWriteRedMat()
- write a RedMat objectvis_WriterFunWriteHistory()
- write a History objectvis_WriterFunWriteModel()
- write a Model object
Operations
vis_WriterFunGetFilePath()
- get the ouput file path
9.1.1. Function Descriptions
The currently available WriterFun functions are described in detail in this section.
-
vis_WriterFun *vis_WriterFunBegin(void)
create an instance of a WriterFun object
Create an instance of a WriterFun object. Memory is allocated for the object private data and the pointer to the data is returned.
Destroy an instance of a WriterFun object using
void vis_WriterFunEnd (vis_WriterFun *writerFun)
- Returns:
The function returns a pointer to the newly created WriterFun object. If the object creation fails, NULL is returned.
-
void vis_WriterFunEnd(vis_WriterFun *p)
destroy an instance of a WriterFun object
-
void vis_WriterFunSetWriteStateFunction(vis_WriterFun *p, VFuncWriterWriteState *function)
set a function to write a State object
Specify the function to use to write State object. If no function is set,
vis_WriterFunWriteState()
calls will have no effect.- Parameters:
p – Pointer to WriterFun object.
function – Function to set.
-
void vis_WriterFunSetWriteRedMatFunction(vis_WriterFun *p, VFuncWriterWriteRedMat *function)
set a function to write a RedMat object
Specify the function to use to write RedMat object. If no function is set,
vis_WriterFunWriteRedMat()
calls will have no effect.- Parameters:
p – Pointer to WriterFun object.
function – Function to set.
-
void vis_WriterFunSetWriteHistoryFunction(vis_WriterFun *p, VFuncWriterWriteHistory *function)
set a function to write a History object
Specify the function to use to write History object. If no function is set,
vis_WriterFunWriteHistory()
calls will have no effect.- Parameters:
p – Pointer to WriterFun object.
function – Function to set.
-
void vis_WriterFunSetWriteModelFunction(vis_WriterFun *p, VFuncWriterWriteModel *function)
set a function to write a Model object
Specify the function to use to write Model object. If no function is set,
vis_WriterFunWriteModel()
calls will have no effect.- Parameters:
p – Pointer to WriterFun object.
function – Function to set.
-
void vis_WriterFunSetGetFilePathFunction(vis_WriterFun *p, VFuncWriterGetFilePath *function)
set a function to get the file path
Specify the function to get the file path. If no function is set,
vis_WriterFunGetFilePath()
calls will have no effect. This function is optional.- Parameters:
p – Pointer to WriterFun object.
function – Function to set.
-
void vis_WriterFunSetGetFileTypeFunction(vis_WriterFun *p, VFuncWriterGetFileType *function)
set a function to get the file type
Specify the function to get the file type. If no function is set,
vis_WriterFunGetFileType()
calls will have no effect. This function is optional.- Parameters:
p – Pointer to WriterFun object.
function – Function to set.
-
void vis_WriterFunWriteState(vis_WriterFun *p, vis_State *state, vis_RProp *rprop)
write a state to the ouput file
-
void vis_WriterFunWriteRedMat(vis_WriterFun *p, vis_RedMat *redmat, vis_RProp *rprop)
write a Redmat to the ouput file
-
void vis_WriterFunWriteHistory(vis_WriterFun *p, vis_History *history, vis_RProp *rprop)
write a History to the ouput file
-
void vis_WriterFunWriteModel(vis_WriterFun *p, vis_Model *model)
write a Model to the ouput file
9.2. Writer - Writer
The Writer module facilitates writing operations to a file. Operations include setting the type of the file to be written, its path and saving data. The following output types are supported:
SYS_NATIVE
SYS_NASTRAN_OUTPUT2
SYS_ABAQUS_FIL
SYS_ABAQUS_ODB
SYS_ENSIGHT
SYS_NATIVE_HDF5
The methods associated with a Writer object are the following:
Begin and end an instance of an object, return object error flag
vdm_WriterBegin()
- create an instance of a Writer objectvdm_WriterEnd()
- destroy an instance of a Writer objectvdm_WriterError()
- return Writer object error flag
Open a file
vdm_WriterOpen()
- open a new file
Close a file
vdm_WriterClose()
- close the file being written
Write data to a file
vdm_WriterWriteState()
- write a State objectvdm_WriterWriteRedMat()
- write a RedMat objectvdm_WriterWriteHistory()
- write a History objectvdm_WriterWriteModel()
- write a Model object
Operations
vdm_WriterSetParamc()
- set character parametersvdm_WriterGetParamc()
- get character parametersvdm_WriterSetParami()
- set integer parametersvdm_WriterGetParami()
- get integer parameters
9.2.1. Function Descriptions
The currently available Writer functions are described in detail in this section.
-
vdm_Writer *vdm_WriterBegin(void)
create an instance of a writer object
Create an instance of a Writer object. Memory is allocated for the object private data and the pointer to the data is returned.
Destroy an instance of a Writer object using
void vdm_WriterEnd (vdm_Writer *writer)
Return the current value of a Writer object error flag using
Vint vdm_WriterError (vdm_Writer *writer)
- Returns:
The function returns a pointer to the newly created Writer object. If the object creation fails, NULL is returned.
-
void vdm_WriterEnd(vdm_Writer *p)
destroy an instance of a writer object
-
Vint vdm_WriterError(vdm_Writer *p)
return the current value of a writer object error flag
-
void vdm_WriterDef(vdm_Writer *p, Vchar *filePath)
set output file path
Specify the pathname for the output file. The file type is detected based on the file name extension:
SYS_NATIVE for .vdm files
SYS_NASTRAN_OUTPUT2 for .op2, .OP2 and .rs2 files
SYS_ABAQUS_FIL for .fil files
SYS_ABAQUS_ODB for .odb files
SYS_ENSIGHT for .case, .CASE and .encas files
SYS_NATIVE_HDF5 for .vh5 files
- Errors
VIS_ERROR_ENUM
is generated if an improper ptype is specified.
- Parameters:
p – Pointer to Writer object.
filePath – Path of the output file
-
void vdm_WriterSetParami(vdm_Writer *p, Vint ptype, Vint iparam)
set integer parameters
Specify integer parameters to control solution.
The parameter
WRITER_RESTYPE
specifies the type of file to be generated. By defaultWRITER_RESTYPE
is set toSYS_NATIVE
.Get iparam as an output argument using
void vdm_WriterGetParami (vdm_Writer *writer, Vint ptype, Vint *iparam)
- Errors
VIS_ERROR_ENUM
is generated if an improper ptype is specified.
- Parameters:
p – Pointer to Writer object.
ptype – Type of solution parameter to set
x=WRITER_RESTYPE Type of file to produce
iparam – Specifies the integer value that ptype will be set to.
-
void vdm_WriterGetParami(vdm_Writer *p, Vint type, Vint *iparam)
get integer paramters
-
void vdm_WriterSetParamc(vdm_Writer *p, Vint ptype, Vchar *cparam)
set character parameters
Specify character parameters to control solution.
The parameter
WRITER_RESFILE
specifies the pathname for the file. By defaultWRITER_RESFILE
is vki.vdm.Get cparam as an output argument using
void vdm_WriterGetParamc (vdm_Writer *writer, Vint ptype, Vchar *cparam)
- Errors
VIS_ERROR_ENUM
is generated if an improper ptype is specified.
- Parameters:
p – Pointer to Writer object.
ptype – Type of solution parameter to set
x=WRITER_RESFILE Pathname of the file
cparam – Specifies the character value that ptype will be set to.
-
void vdm_WriterGetParamc(vdm_Writer *p, Vint type, Vchar *cparam)
get character parameters
-
void vdm_WriterWriteState(vdm_Writer *p, vis_State *state, vis_RProp *rprop)
save a VisTools State object
Extract finite element state information from a State object and write it to a library. This function can call
vdm_WriterOpen()
if needed.See
vdm_LManSaveState()
for more information.- Errors
SYS_ERROR_OPERATION
is generated if the library is not writeable.SYS_ERROR_ENUM
is generated if the RProp object has an improper type.SYS_ERROR_NULLOBJECT
is generated ifvdm_WriterOpen()
fails.
-
void vdm_WriterWriteRedMat(vdm_Writer *p, vis_RedMat *redmat, vis_RProp *rprop)
save a VisTools RedMat object
Extract degree of freedom information from a RedMat object and write it to a library. This function can call
vdm_WriterOpen()
if needed.See
vdm_LManSaveRedMat()
for more information.- Errors
SYS_ERROR_OPERATION
is generated if the library is not writeable.SYS_ERROR_NULLOBJECT
is generated ifvdm_WriterOpen()
fails.
-
void vdm_WriterWriteHistory(vdm_Writer *p, vis_History *history, vis_RProp *rprop)
save a VisTools History object
Extract finite element history information from a History object and write it to a library. This function can call
vdm_WriterOpen()
if needed.See
vdm_LManSaveHistory()
for more information.- Errors
SYS_ERROR_OPERATION
is generated if the library is not writeable.SYS_ERROR_ENUM
is generated if the RProp object has an improper type.SYS_ERROR_NULLOBJECT
is generated ifvdm_WriterOpen()
fails.
-
void vdm_WriterWriteModel(vdm_Writer *p, vis_Model *model)
save a VisTools Model object
Extract finite element model information from a Model object and write it to a library. This function can call
vdm_WriterOpen()
if needed.See
vdm_LManSaveModel()
for more information.- Errors
SYS_ERROR_OPERATION
is generated if the library is not writeable.SYS_ERROR_NULLOBJECT
is generated if the Model object does not contain a Connect object.SYS_ERROR_NULLOBJECT
is generated ifvdm_WriterOpen()
fails.
-
void vdm_WriterOpen(vdm_Writer *p)
open the Writer object
Open the Writer object by opening a file of the selected type. If the Writer object is already initialized,
vdm_WriterClose()
is called before initialization.- Parameters:
p – Pointer to Writer object.