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:

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

See vis_WriterFunBegin()

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

Parameters:
  • p – Pointer to WriterFun object.

  • state – Pointer to State object.

  • rprop – Pointer to RProp object.

void vis_WriterFunWriteRedMat(vis_WriterFun *p, vis_RedMat *redmat, vis_RProp *rprop)

write a Redmat to the ouput file

Parameters:
  • p – Pointer to WriterFun object.

  • redmat – Pointer to RedMat object.

  • rprop – Pointer to RProp object.

void vis_WriterFunWriteHistory(vis_WriterFun *p, vis_History *history, vis_RProp *rprop)

write a History to the ouput file

Parameters:
  • p – Pointer to WriterFun object.

  • history – Pointer to History object.

  • rprop – Pointer to RProp object.

void vis_WriterFunWriteModel(vis_WriterFun *p, vis_Model *model)

write a Model to the ouput file

Parameters:
  • p – Pointer to WriterFun object.

  • model – Pointer to Model object.

void vis_WriterFunGetFilePath(vis_WriterFun *p, Vchar *filePath)

get the path of the ouput file

Parameters:
  • p – Pointer to WriterFun object.

  • filePath – Specifies output file path.

void vis_WriterFunGetFileType(vis_WriterFun *p, Vint *fileType)

get the path of the ouput file

Parameters:
  • p – Pointer to WriterFun object.

  • fileType – Specifies output file type.

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:

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

See vdm_WriterBegin()

Vint vdm_WriterError(vdm_Writer *p)

return the current value of a writer object error flag

See vdm_WriterBegin()

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 default WRITER_RESTYPE is set to SYS_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

See vdm_WriterSetParami()

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 default WRITER_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

See vdm_WriterSetParamc()

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 if vdm_WriterOpen() fails.

Parameters:
  • p – Pointer to Writer object.

  • state – Pointer to State object.

  • rprop – Pointer to RProp object.

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 if vdm_WriterOpen() fails.

Parameters:
  • p – Pointer to Writer object.

  • redmat – Pointer to RedMat object.

  • rprop – Pointer to RProp object.

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 if vdm_WriterOpen() fails.

Parameters:
  • p – Pointer to Writer object.

  • history – Pointer to History object.

  • rprop – Pointer to RProp object.

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 if vdm_WriterOpen() fails.

Parameters:
  • p – Pointer to Writer object.

  • model – Pointer to Model object.

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.

void vdm_WriterClose(vdm_Writer *p)

close the Writer object

Close the Writer object if a file is still open. The output file associated is closed and can be used.

Parameters:

p – Pointer to Writer object.