6. Library Manager - LMan
The LMan module facilitates a number of common operations on a VdmTools library. Operations include printing a table of contents of a library, listing the contents of a dataset. The methods associated with a LMan object are the following.
Begin and end an instance of an object, return object error flag
vdm_LManBegin()
- create an instance of a LMan objectvdm_LManEnd()
- destroy an instance of a LMan objectvdm_LManError()
- return LMan object error flag
Definition and Query
vdm_LManExport()
- write ASCII representation of libraryvdm_LManGetObject()
- get pointer to attribute objectsvdm_LManImport()
- read ASCII representation of libraryvdm_LManList()
- print the contents of a datasetvdm_LManLoadModel()
- load a VisTools Model objectvdm_LManSaveModel()
- save a VisTools Model objectvdm_LManLoadState()
- load a VisTools State objectvdm_LManLoadIdTranState()
- load a VisTools State object subsetvdm_LManSaveState()
- save a VisTools State objectvdm_LManLoadHistory()
- load a VisTools History objectvdm_LManSaveHistory()
- lave a VisTools History objectvdm_LManLoadRedMat()
- load a VisTools RedMat objectvdm_LManSaveRedMat()
- save a VisTools RedMat objectvdm_LManSetObject()
- set pointers to attribute objectsvdm_LManSetParami()
- set integer parametersvdm_LManTOC()
- print a library table of contents
Instance a LMan object using vdm_LManBegin()
.
Once a LMan is instanced, set the DataFun
attribute object using vdm_LManSetObject()
.
The functions vdm_LManList()
and vdm_LManTOC()
may be used to print the contents of a dataset or print the table of
contents of a library respectively. Currently the printing is to
standard output.
An ASCII representation of the contents of a library may be exported
using vdm_LManExport()
.
This ASCII representation may then be imported using vdm_LManImport()
.
Any library may be exported, however only native libraries may be used
for import.
The LMan
module also supports loading and saving the contents of VisTools
objects. Two VisTools modules are supported,
Model and State.
The load function reads information from a library and enters it into
the VisTools object. The save function extracts information from a
VisTools object and writes it to a library. Use
vdm_LManLoadModel()
and vdm_LManSaveModel()
to load and store Model
objects. Use vdm_LManLoadState()
and vdm_LManSaveState()
to load and store State
objects. Use vdm_LManLoadIdTranState()
to load a
State
object with a subset of entities. The following file types are supported
for Model saving only.
The following file types are supported for Model and State saving.
Use vdm_LManLoadRedMat()
and vdm_LManSaveRedMat()
to load and store RedMat
objects. Currently, only SYS_NATIVE and SYS_NATIVE_HDF5 file
types are supported for RedMat
saving. Use vdm_LManLoadHistory()
and
vdm_LManSaveHistory()
to load and store
History objects.
The following code fragment illustrates the basic framework of using the LMan module to load model information into a Model object. It also illustrates a useful convention for using the file name extension to associate a file format. For example, .fil indicates an ABAQUS results file, .bdf indicates a NASTRAN input bulk data file, .op2 indicates a NASTRAN OUTPUT2 results file, etc.
/* file name and type */
Vchar file[256];
Vint filetype;
/* VdmTools objects */
/* Interface objects */
vdm_NASFil *nasfil;
vdm_NASLib *naslib;
vdm_ANSLib *anslib;
vdm_ABAFil *abafil;
vdm_ABALib *abalib;
vdm_SDRCLib *sdrclib;
vdm_STLFil *stlfil;
vdm_NatLib *natlib;
/* Abstract interface and Library Manager */
vdm_DataFun *datafun;
vdm_LMan *lman;
/* VisTools Model object */
vis_Model *model;
/* file name */
strcpy(file,"my_nastran_results.op2");
/* instance abstract DataFun interface object */
datafun = vdm_DataFunBegin ();
/* determine file type from file extension */
/* establish abstract DataFun interface */
if(strstr(file,".bdf") != NULL ||
strstr(file,".dat") != NULL) {
filetype = VDM_NASTRAN_BULKDATA;
nasfil = vdm_NASFilBegin();
vdm_NASFilDataFun (nasfil,datafun);
} else if(strstr(file,".op2") != NULL) {
filetype = VDM_NASTRAN_OUTPUT2;
naslib = vdm_NASLibBegin();
vdm_NASLibDataFun (naslib,datafun);
} else if(strstr(file,".rst") != NULL) {
filetype = VDM_ANSYS_RESULT;
anslib = vdm_ANSLibBegin();
vdm_ANSLibDataFun (anslib,datafun);
} else if(strstr(file,".inp") != NULL) {
filetype = VDM_ABAQUS_INPUT;
abafil = vdm_ABAFilBegin();
vdm_ABAFilDataFun (abafil,datafun);
} else if(strstr(file,".fil") != NULL) {
filetype = VDM_ABAQUS_FIL;
abalib = vdm_ABALibBegin();
vdm_ABALibDataFun (abalib,datafun);
} else if(strstr(file,".odb") != NULL) {
filetype = VDM_ABAQUS_ODB;
abalib = vdm_ABALibBegin();
vdm_ABALibDataFun (abalib,datafun);
} else if(strstr(file,".unv") != NULL ||
strstr(file,".bun") != NULL) {
filetype = VDM_SDRC_UNIVERSAL;
sdrclib = vdm_SDRCLibBegin();
vdm_SDRCLibDataFun (sdrclib,datafun);
} else if(strstr(file,".stl") != NULL) {
filetype = VDM_STL;
stlfil = vdm_STLFilBegin();
vdm_STLFilDataFun (stlfil,datafun);
} else if(strstr(file,".STL") != NULL) {
filetype = VDM_STLBIN;
stlfil = vdm_STLFilBegin();
vdm_STLFilDataFun (stlfil,datafun);
} else if(strstr(file,".vdm") != NULL) {
filetype = VDM_NATIVE;
natlib = vdm_NatLibBegin();
vdm_NatLibDataFun (natlib,datafun);
} else {
fprintf(stderr,"Error: Bad input file %s\n",file);
exit(0);
}
/* open file */
vdm_DataFunSetConvention (datafun,VDM_CONVENTION_DOUBLE);
vdm_DataFunOpen (datafun,"EXT",file,filetype);
if(vdm_DataFunError(datafun)) {
fprintf(stderr,"Error: Unable to open input data file\n");
exit(0);
}
/* create LMan object */
lman = vdm_LManBegin ();
vdm_LManSetObject (lman,VDM_DATAFUN,datafun);
/* load model */
model = vis_ModelBegin ();
vdm_LManLoadModel (lman,model);
if(vdm_LManError(lman)) {
fprintf(stderr,"Error: Unable to load model information\n");
exit(0);
}
/* close library device and delete interface */
vdm_DataFunClose (datafun);
vdm_DataFunEnd (datafun);
if(filetype == VDM_NASTRAN_BULKDATA) {
vdm_NASFilEnd (nasfil);
} else if(filetype == VDM_NASTRAN_OUTPUT2) {
vdm_NASLibEnd (naslib);
} else if(filetype == VDM_ANSYS_RESULT) {
vdm_ANSLibEnd (anslib);
} else if(filetype == VDM_ABAQUS_INPUT) {
vdm_ABAFilEnd (abafil);
} else if(filetype == VDM_ABAQUS_FIL) {
vdm_ABALibEnd (abalib);
} else if(filetype == VDM_ABAQUS_ODB) {
vdm_ABALibEnd (abalib);
} else if(filetype == VDM_SDRC_UNIVERSAL) {
vdm_SDRCLibEnd (sdrclib);
} else if(filetype == VDM_STL ||
filetype == VDM_STLBIN) {
vdm_STLFilEnd (stlfil);
} else if(filetype == VDM_NATIVE) {
vdm_NatLibEnd (natlib);
}
/* delete LMan object */
vdm_LManEnd (lman);
/* access Model object */
...
/* delete Model object contents */
vis_ModelDelete (model);
/* delete Model object */
vis_ModelEnd (model);
6.1. Function Descriptions
The currently available LMan functions are described in detail in this section.
-
vdm_LMan *vdm_LManBegin(void)
create an instance of a LMan object
Create an instance of a LMan object. Memory is allocated for the object private data and the pointer to the data is returned.
Destroy an instance of a LMan object using
void vdm_LManEnd (vdm_LMan *lman)
Return the current value of a LMan object error flag using
Vint vdm_LManError (vdm_LMan *lman)
- Returns:
The function returns a pointer to the newly created LMan object. If the object creation fails, NULL is returned.
-
void vdm_LManEnd(vdm_LMan *p)
destroy an instance of a LMan object
See
vdm_LManBegin()
-
Vint vdm_LManError(vdm_LMan *p)
destroy an instance of a LMan object
See
vdm_LManBegin()
-
void vdm_LManSetObject(vdm_LMan *p, Vint objecttype, Vobject *object)
set pointers to attribute objects
Set a pointer to an attribute object.
Get pointer to attribute objects
void vdm_LManGetObject (vdm_LMan *lman, Vint objecttype, Vobject **object)
- Errors
SYS_ERROR_OBJECTTYPE
is generated if an improper objecttype is specified.
- Parameters:
p – Pointer to LMan object.
objecttype – The name of the object type to be set.
x=VDM_DATAFUN DataFun object
object – Pointer to the object to be set.
-
void vdm_LManGetObject(vdm_LMan *p, Vint objecttype, Vobject **object)
get pointer to attribute objects
- Parameters:
p – Pointer to LMan object.
objecttype – The name of the object type to be retrieved.
x=VDM_DATAFUN DataFun object x=VDM_UNRECOGNIZEDDATA UnrecognizedData object
object – Pointer to the object to be retrieved.
-
void vdm_LManSetParami(vdm_LMan *p, Vint type, Vint iparam)
set integer parameters
Set integer parameters.
The table of contents listing will print out all dataset attributes if the
LMAN_VERBOSE
flag is enabled. By defaultLMAN_VERBOSE
is set toSYS_OFF
.Element connectivity input using FOCUS conventions will be assumed if the
LMAN_FOCUSCONN
flag is enabled. By defaultLMAN_FOCUSCONN
is set toSYS_OFF
.Flag undefined result data with the parameter
LMAN_NODATAVAL
. IfLMAN_NODATAVAL
is enabled the functionvdm_LManLoadState()
will identify undefined result data. The resulting State object will then be able to be queried for the defined status of result data. By defaultLMAN_NODATAVAL
is set toSYS_ON
.Use the parameters
LMAN_LOADMODEL_LOAD
,LMAN_LOADMODEL_REST
,LMAN_LOADMODEL_ELEMGEOM
andLMAN_LOADMODEL_SET
to control loading certain model data usingvdm_LManLoadModel
.LMAN_LOADMODEL_LOAD
refers to all loads.LMAN_LOADMODEL_REST
refers to all restraints and multipoint constraints.LMAN_LOADMODEL_SET
refers to all node, element and element entity sets.LMAN_LOADMODEL_ELEMGEOM
refers to shell and beam element geometry properties such as thickness, offset and fiber locations. By default all load model parameters are set toSYS_ON
.Use the parameter
LMAN_LOADSTATE_PRE
to specify the State precision used when loading data usingvdm_LManLoadState
. The proper data extent will be computed and set for quantized precisions. By defaultLMAN_LOADSTATE_PRE
is set toSYS_FLOAT
.Use the parameter
LMAN_RETAINCONNECT
to specify that the underlying Connect object used by the file reader object (eg. NASLib) is retained and is used as the Connect object component of the Model object when loading data usingvdm_LManLoadModel()
. This Connect object is then owned by the Model object but still retained and used by the underlying file reader object. It should not be destroyed before the underlying file reader is destroyed. The use of this option will avoid generating a copy of the Connect object. The Connect object returned from Model should be used for querying data only except for the functionvis_ConnectKernel()
. By defaultLMAN_RETAINCONNECT
is set toSYS_OFF
.- Errors
SYS_ERROR_ENUM
is generated if an improper type is specified.
- Parameters:
p – Pointer to LMan object.
type – Type of formulation parameter to set
=LMAN_VERBOSE Verbose TOC listing =LMAN_FOCUSCONN Convert FOCUS element connectivity =LMAN_NODATAVAL Flag undefined result data =LMAN_LOADMODEL_LOAD Load model loads =LMAN_LOADMODEL_REST Load model restraints =LMAN_LOADMODEL_SET Load model sets =LMAN_LOADMODEL_ELEMGEOM Load model element geometry =LMAN_LOADSTATE_PRE Precision option =LMAN_RETAINCONNECT Retain and reuse Connect
iparam – Integer parameter value.
=SYS_OFF Disable =SYS_ON Enable =SYS_DOUBLE Double precision =SYS_FLOAT Float precision
-
void vdm_LManExport(vdm_LMan *p, Vchar *name, Vchar *path)
write ASCII representation of library
Export an ASCII representation of datasets on a library to file path. All datasets names which match the input name are exported. To export all datasets set name = “*”.
- Errors
SYS_ERROR_OPERATION
is generated if the library contains no datasets.SYS_ERROR_FILE
is generated if path cannot be opened.
- Parameters:
p – Pointer to LMan object.
name – Dataset name to export
path – File path
-
void vdm_LManImport(vdm_LMan *p, Vchar *path)
read ASCII representation of library
Import an ASCII representation of datasets on file path. All datasets on file path are read and established on the library.
- Errors
SYS_ERROR_FILE
is generated if path cannot be opened.SYS_ERROR_FORMAT
is generated if the file contains data in an unrecognized
- Parameters:
p – Pointer to LMan object.
path – File path
-
void vdm_LManTOC(vdm_LMan *p, const Vchar *name)
print a library table of contents
Print a table of contents of a library to standard output. All datasets names which match the input name are included in the table.
- Parameters:
p – Pointer to LMan object.
name – Dataset names to include in table of contents
-
void vdm_LManList(vdm_LMan *p, Vchar *name)
print the contents of a dataset
Print the contents of datasets on a library to standard output. All datasets names which match the input name are listed. To list all datasets set name = “*”.
- Errors
SYS_ERROR_OPERATION
is generated if the library contains no datasets.
- Parameters:
p – Pointer to LMan object.
name – Dataset name to list
-
void vdm_LManLoadModel(vdm_LMan *p, vis_Model *model)
load a VisTools Model object
Read finite element model information from a library and enter it into a Model object. The input model object should not contain model information prior to calling this function.
- Errors
SYS_ERROR_OPERATION
is generated if the library contains no datasets or contains no finite elements or nodes.
-
void vdm_LManSaveModel(vdm_LMan *p, vis_Model *model)
save a VisTools Model object
Extract finite element model information from a Model object and write it to a library.
The following file types are supported for Model saving.
SYS_ABAQUS_INPUT SYS_ABAQUS_FIL SYS_ABAQUS_ODB SYS_ANSYS_INPUT SYS_CGNS SYS_ENSIGHT SYS_FLUENT_MESH SYS_MECHANICA_FNF SYS_NATIVE SYS_NATIVE_HDF5 SYS_NASTRAN_BULKDATA SYS_NASTRAN_OUTPUT2 SYS_OBJ SYS_PATRAN_NEUTRAL SYS_SDRC_UNIVERSAL SYS_STL SYS_STLBIN SYS_TECPLOT
- Errors
-
void vdm_LManLoadState(vdm_LMan *p, vis_State *state, vis_RProp *rprop)
load a VisTools State object
Read finite element state information from a library and enter it into a State object. The function
vis_RPropDef()
must have been called on the input RProp object and either the dataset index must have been established usingvis_RPropSetDatasetIndex()
or the dataset name must have been established usingvis_RPropSetDatasetName()
. Any data previously existing in the input State object is destroyed.If element node results data are to be loaded into State, a GridFun object must have been set using
vis_StateSetObject()
. The State object will have the proper number of entities, parent and child entity types and data type set. Usevis_StateInq()
to query this information. The State object will also have the proper local or global system type set. Usevis_StateGetSystem()
to query the system type. If the State object contains strain results interpreted as engineering strain then the strain type will be flagged. Usevis_StateGetEngineeringStrain()
to query the strain type.When loading data into State it is possible to specify the precision of the State object and the use of the “corner” node option for element node data. Set these options using
vdm_LManSetParami()
.- Errors
SYS_ERROR_NULLOBJECT
is generated if input state or rprop objects are NULL, if a DataFun object has not been registered, or if the State object does not contain a GridFun objectSYS_ERROR_VALUE
is generated if the dataset is not found.SYS_ERROR_OPERATION
is generated if the dataset is a history dataset or if the entity types of the input RProp object do mot match those of the dataset.
-
void vdm_LManLoadStateFromName(vdm_LMan *p, Vchar datasetname[], vis_State *state)
load a VisTools State object from a state name
Read finite element state information from a library and enter it into a State object. Any data previously existing in the input State object is destroyed.
If the State object does not contain a GridFun object, a GridFun object will be created (if needed) and set in the State object. The LMan is the owner of the GridFun object. In this case, the lifetime of the State is tied to the lifetime of the LMan object and the LMan object must be destroyed after the State object is used and destroyed.
The State object will also have the proper local or global system type set. Use
vis_StateGetSystem()
to query the system type. If the State object contains strain results interpreted as engineering strain then the strain type will be flagged. Usevis_StateGetEngineeringStrain()
to query the strain type.When loading data into State it is possible to specify the precision of the State object and the use of the “corner” node option for element node data. Set these options using
vdm_LManSetParami()
.- Errors
SYS_ERROR_NULLOBJECT
is generated if input state is NULL, or if a DataFun object has not been registeredSYS_ERROR_VALUE
is generated if the dataset is not found.SYS_ERROR_OPERATION
is generated if the dataset is a history dataset or if the entity types of the input RProp object do mot match those of the dataset.
-
void vdm_LManGetStateNames(vdm_LMan *p, vsy_List **stateNames)
Retrieve the names of states from a.
LMan object
This function retrieves the names of the result datasets from a LMan object.
-
void vdm_LManLoadIdTranState(vdm_LMan *p, vis_IdTran *idtran, vis_State *state, vis_RProp *rprop)
load a VisTools State object subset
Read a subset of a state information from a library and enter it into a State object. The input idtran object contains the indices of the entities to be read, otherwise the operation of the function is identical to
vdm_LManLoadState()
.- Errors
SYS_ERROR_NULLOBJECT
is generated if input idtran, state or rprop objects are NULL, if a DataFun object has not been registered, or if the State object does not contain a GridFun objectSYS_ERROR_VALUE
is generated if the dataset is not found.SYS_ERROR_OPERATION
is generated if the dataset is a history dataset or if the entity types of the input RProp object do mot match those of the dataset.SYS_ERROR_VALUE
is generated if a specified entity index is out of range.
-
void vdm_LManSaveState(vdm_LMan *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. The RProp object is used to construct a proper dataset name and assign attributes. At a minimum, the dataset result type, section and numeric identifiers must be set in the RProp object. If the result type is unknown,
SYS_RES_UNKNOWN
, then the result qualifiers should be specified usingvis_RPropSetQual()
.It is also suggested that the DataType and Contents attributes be defined using
vis_RPropSetValuec()
withRPROP_DATATYPE
andRPROP_CONTENTS
respectively.The State object should have the proper local or global system type set using
vis_StateSetSystem()
. If the State object contains strain results interpreted as engineering strain, then this should be flagged usingvis_StateSetEngineeringStrain()
.The following file types are supported for State saving.
SYS_ABAQUS_FIL SYS_ABAQUS_ODB SYS_CGNS SYS_ENSIGHT SYS_NATIVE SYS_NATIVE_HDF5 SYS_NASTRAN_OUTPUT2 SYS_SDRC_UNIVERSAL SYS_TECPLOT
- 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.
-
void vdm_LManLoadHistory(vdm_LMan *p, vis_History *history, vis_RProp *rprop)
load a VisTools History object
Read finite element history information from a library and enter it into a History object. The function
vis_RPropDef()
must have been called on the input RProp object and either the dataset index must have been established usingvis_RPropSetDatasetIndex()
or the dataset name must have been established usingvis_RPropSetDatasetName()
. Any data previously existing in the input History object is destroyed.The History object will have the proper local or global system type set. Use
vis_HistoryGetSystem()
to query the system type. If the History object contains strain results interpreted as engineering strain then the strain type will be flagged. Usevis_HistoryGetEngineeringStrain()
to query the strain type.- Errors
SYS_ERROR_NULLOBJECT
is generated if input state or rprop objects are NULL, if a DataFun object has not been registered, or if the State object does not contain a GridFun objectSYS_ERROR_VALUE
is generated if the dataset is not found.SYS_ERROR_OPERATION
is generated if the dataset is a history dataset or if the entity types of the input RProp object do mot match those of the dataset.
-
void vdm_LManSaveHistory(vdm_LMan *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. The RProp object is used to construct a proper dataset name and assign attributes. At a minimum, the dataset result type, section and numeric identifiers must be set in the RProp object. If the result type is unknown,
SYS_RES_UNKNOWN
, then the result qualifiers should be specified usingvis_RPropSetQual()
.It is also suggested that the DataType and Contents attributes be defined using
vis_RPropSetValuec()
withRPROP_DATATYPE
andRPROP_CONTENTS
respectively.The History object should have the proper local or global system type set using
vis_HistorySetSystem()
. If the History object contains strain results interpreted as engineering strain, then this should be flagged usingvis_HistorySetEngineeringStrain()
.The following file types are supported for History saving.
SYS_NATIVE SYS_NATIVE_HDF5
- 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.
-
void vdm_LManLoadRedMat(vdm_LMan *p, vis_RedMat *redmat, vis_RProp *rprop)
load a VisTools RedMat object
Read degree of freedom information from a library and enter it into a RedMat object. With respect to the input RProp object, either the dataset index must have been established using
vis_RPropSetDatasetIndex()
or the dataset name must have been established usingvis_RPropSetDatasetName()
. The quantities specified by the functionvis_RPropDef()
are ignored. Any data previously existing in the input RedMat object is destroyed.When loading data into RedMat it is possible to specify the precision of the RedMat object using
vis_RedMatPre()
.- Errors
SYS_ERROR_NULLOBJECT
is generated if input redmat or rprop objects are NULL, or if a DataFun object has not been registered.SYS_ERROR_OPERATION
is generated if the parent entity type is notSYS_DOF
.
-
void vdm_LManSaveRedMat(vdm_LMan *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. The RProp object is used to construct a proper dataset name and assign attributes. The RProp parent and child entity types should be
SYS_DOF
andSYS_NONE
. At a minimum, the dataset result type, and numeric identifiers must be set in the RProp object. If the result type is unknown,SYS_RES_UNKNOWN
, then the result qualifiers should be specified usingvis_RPropSetQual()
.It is also suggested that the DataType and Contents attributes be defined using
vis_RPropSetValuec()
withRPROP_DATATYPE
andRPROP_CONTENTS
respectively.The following file types are supported for RedMat saving.
SYS_NATIVE SYS_NATIVE_HDF5
- Errors
SYS_ERROR_OPERATION
is generated if the library is not writeable.