Reading and writing files

Functions

virtual int MEDMEM::FIELD_::addDriver (driverTypes driverType, const string &fileName="Default File Name.med", const string &driverFieldName="Default Field Nam", MED_EN::med_mode_acces access=MED_EN::RDWR)
virtual int MEDMEM::FIELD_::addDriver (GENDRIVER &driver)
virtual void MEDMEM::FIELD_::read (const GENDRIVER &)
virtual void MEDMEM::FIELD_::read (int index=0)
virtual void MEDMEM::FIELD_::openAppend (void)
virtual void MEDMEM::FIELD_::write (const GENDRIVER &)
virtual void MEDMEM::FIELD_::write (int index=0, const string &driverName="")
 MEDMEM::FIELD::FIELD (const SUPPORT *Support, driverTypes driverType, const string &fileName="", const string &fieldName="", const int iterationNumber=-1, const int orderNumber=-1) throw (MEDEXCEPTION)
 MEDMEM::FIELD::FIELD (driverTypes driverType, const string &fileName, const string &fieldDriverName, const int iterationNumber=-1, const int orderNumber=-1, MESH *mesh=0) throw (MEDEXCEPTION)
int MEDMEM::FIELD::addDriver (driverTypes driverType, const string &fileName="Default File Name.med", const string &driverFieldName="Default Field Name", MED_EN::med_mode_acces access=MED_EN::RDWR)
void MEDMEM::FIELD::write (int index=0, const string &driverName="")

Detailed Description

Fields can be read or written to/from MED files.

Reading fields

For reading a field a typical use consists in :

As an example :

//reading mesh from file
MESH mesh(MED_DRIVER, "file.med", "my_Mesh");
//retrieving group in the mesh structure
GROUP* group= mesh->getGroup("myGroup");
//reading the field from the file
FIELD<double> field(group,MED_DRIVER,"file.med","my_Field",1,1);

If the field is defined on all elements, one could have :

//reading mesh from file
MESH mesh(MED_DRIVER, "file.med", "my_Mesh");
//creating a support on all faces
SUPPORT support (mesh,"mySupport",MED_FACE);
//reading the field from the file
FIELD<double> field(&support,MED_DRIVER,"file.med","my_FieldOnFaces",1,1);

It is also possible to read a field without specifying its support. In this case, the field constructor creates a support with no link to the initial mesh:

FIELD<double> field(MED_DRIVER, "file.med", "myField",1,1);
SUPPORT* support= field->getSupport();

See also FIELD<T> constructors

Writing fields

When it comes to write fields, it is necessary to use addDriver and then write. A typical use will be :

mesh.addDriver(MED_DRIVER, "myResultFile.med", "myMesh");
mesh.write();
field.addDriver(MED_DRIVER, "myResultFile.med, "myField");
field.write();

Function Documentation

int FIELD_::addDriver ( driverTypes  driverType,
const string &  fileName = "Default File Name.med",
const string &  driverFieldName = "Default Field Nam",
MED_EN::med_mode_acces  access = MED_EN::RDWR 
) [virtual, inherited]

Creates a driver for reading/writing fields in a file.

Parameters:
driverType specifies the file type (MED_DRIVER, VTK_DRIVER)
fileName name of the output file
driverFieldName name of the field
access specifies whether the file is opened for read, write or both.

Reimplemented in MEDMEM::FIELD< T, INTERLACING_TAG >.

int FIELD_::addDriver ( GENDRIVER &  driver  )  [virtual, inherited]
void FIELD_::read ( const GENDRIVER &   )  [virtual, inherited]
void FIELD_::read ( int  index = 0  )  [virtual, inherited]
void FIELD_::openAppend ( void   )  [virtual, inherited]
void FIELD_::write ( const GENDRIVER &   )  [virtual, inherited]
void FIELD_::write ( int  index = 0,
const string &  driverName = "" 
) [virtual, inherited]

Triggers the writing of the field with respect to the driver handle index given by addDriver(...) method.

Reimplemented in MEDMEM::FIELD< T, INTERLACING_TAG >.

template<class T , class INTERLACING_TAG >
MEDMEM::FIELD< T, INTERLACING_TAG >::FIELD ( const SUPPORT Support,
driverTypes  driverType,
const string &  fileName = "",
const string &  fieldDriverName = "",
const int  iterationNumber = -1,
const int  orderNumber = -1 
) throw (MEDEXCEPTION) [inherited]

Constructor with parameters; the object is set via a file and its associated driver. For the moment only the MED_DRIVER is considered and if the last two argument (iterationNumber and orderNumber) are not set; their default value is -1. If the field fieldDriverName with the iteration number iterationNumber and the order number orderNumber does not exist in the file fieldDriverName; the constructor raises an exception.

References MEDMEM::FIELD_::_interlacingType, and MEDMEM::FIELD_::_valueType.

template<class T , class INTERLACING_TAG >
MEDMEM::FIELD< T, INTERLACING_TAG >::FIELD ( driverTypes  driverType,
const string &  fileName,
const string &  fieldDriverName,
const int  iterationNumber = -1,
const int  orderNumber = -1,
MESH mesh = 0 
) throw (MEDEXCEPTION) [inherited]

If the mesh argument is not initialized or passed NULL, this constructor, at least, allows to create a FIELD without creating any SUPPORT then without having to load a MESH object, a support is created. It provides the meshName related mesh but doesn't not set a mesh in the created support. If the passed mesh contains corresponding support, this support will be used for the field. This support will be found in mesh by name of one of profiles, on which the FIELD lays in MED-file. This has sense for the case, then MED-file was created by MEDMEM, and so name of profile contains name of corresponding support.

References MEDMEM::FIELD_::_interlacingType, and MEDMEM::FIELD_::_valueType.

template<class T , class INTERLACING_TAG >
int MEDMEM::FIELD< T, INTERLACING_TAG >::addDriver ( driverTypes  driverType,
const string &  fileName = "Default File Name.med",
const string &  driverName = "Default Field Name",
MED_EN::med_mode_acces  access = MED_EN::RDWR 
) [virtual, inherited]

Creates the specified driver and return its index reference to path to read or write methods.

Parameters:
driverType specifies the file type (MED_DRIVER or VTK_DRIVER)
fileName name of the output file
driverName name of the field
access access type (read, write or both)

Reimplemented from MEDMEM::FIELD_.

References MEDMEM::FIELD_::_drivers.

template<class T , class INTERLACING_TAG >
void MEDMEM::FIELD< T, INTERLACING_TAG >::write ( int  index = 0,
const string &  driverName = "" 
) [virtual, inherited]

Writes FIELD in the file specified by the driver handle index.

Example :

//...
// Attaching the friver to file "output.med", meshname "Mesh"
int driver_handle = mesh.addDriver(MED_DRIVER, "output.med", "Mesh");
// Writing the content of mesh to the file 
mesh.write(driver_handle);

Reimplemented from MEDMEM::FIELD_.

References MEDMEM::FIELD_::_drivers.

Generated on Sat May 1 01:31:48 2010 for Med Memory Users' Guide by  doxygen 1.6.3