Version: 6.5.0
Functions
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 (driverTypes driverType, const std::string &fileName)
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 &, MED_EN::med_mode_acces medMode=MED_EN::RDWR)
virtual void MEDMEM::FIELD_::write (driverTypes driverType, const std::string &fileName, MED_EN::med_mode_acces medMode=MED_EN::RDWR)
virtual void MEDMEM::FIELD_::write (int index=0)
 MEDMEM::FIELD< T, INTERLACING_TAG >::FIELD (const SUPPORT *Support, driverTypes driverType, const string &fileName="", const string &fieldName="", const int iterationNumber=-1, const int orderNumber=-1) throw (MEDEXCEPTION)
 MEDMEM::FIELD< T, INTERLACING_TAG >::FIELD (driverTypes driverType, const string &fileName, const string &fieldDriverName, const int iterationNumber=-1, const int orderNumber=-1, GMESH *mesh=0) throw (MEDEXCEPTION)
int MEDMEM::FIELD< T, INTERLACING_TAG >::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< T, INTERLACING_TAG >::read (int index=0)
void MEDMEM::FIELD< T, INTERLACING_TAG >::read (const GENDRIVER &genDriver)
void MEDMEM::FIELD< T, INTERLACING_TAG >::read (driverTypes driverType, const std::string &filename)
void MEDMEM::FIELD< T, INTERLACING_TAG >::write (int index=0)
void MEDMEM::FIELD< T, INTERLACING_TAG >::write (const GENDRIVER &, MED_EN::med_mode_acces medMode=MED_EN::RDWR)
void MEDMEM::FIELD< T, INTERLACING_TAG >::write (driverTypes driverType, const std::string &filename, MED_EN::med_mode_acces medMode=MED_EN::RDWR)

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");
//reading the field from the file
FIELD<double> field(group,MED_DRIVER,"file.med","my_Field",1,1,&mesh);

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 enough to call write() method. A typical use will be :

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

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

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

Parameters
driverTypespecifies the file type (MED_DRIVER, VTK_DRIVER)
fileNamename of the output file
driverFieldNamename of the field
accessspecifies whether the file is opened for read, write or both.

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

int FIELD_::addDriver ( GENDRIVER &  driver)
virtual
void FIELD_::read ( driverTypes  driverType,
const std::string &  fileName 
)
virtual
void FIELD_::read ( const GENDRIVER &  )
virtual
void FIELD_::read ( int  index = 0)
virtual
void FIELD_::openAppend ( void  )
virtual
void FIELD_::write ( const GENDRIVER &  ,
MED_EN::med_mode_acces  medMode = MED_EN::RDWR 
)
virtual
void FIELD_::write ( driverTypes  driverType,
const std::string &  fileName,
MED_EN::med_mode_acces  medMode = MED_EN::RDWR 
)
virtual
void FIELD_::write ( int  index = 0)
virtual

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)

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,
GMESH mesh = 0 
) throw (MEDEXCEPTION)

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

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

Parameters
driverTypespecifies the file type (MED_DRIVER or VTK_DRIVER)
fileNamename of the output file
driverNamename of the field
accessaccess type (read, write or both)

Reimplemented from MEDMEM::FIELD_.

template<class T , class INTERLACING_TAG >
void MEDMEM::FIELD< T, INTERLACING_TAG >::read ( int  index = 0)
virtual

Read FIELD in the file specified in the driver given by its index.

Reimplemented from MEDMEM::FIELD_.

template<class T , class INTERLACING_TAG >
void MEDMEM::FIELD< T, INTERLACING_TAG >::read ( const GENDRIVER &  driver)
virtual

Read FIELD with the driver. Additional information (name etc.) to select a field must be set to the field.

Reimplemented from MEDMEM::FIELD_.

template<class T , class INTERLACING_TAG >
void MEDMEM::FIELD< T, INTERLACING_TAG >::read ( driverTypes  driverType,
const std::string &  filename 
)
virtual

Read FIELD with driver of the given type. Additional information (name etc.) to select a field must be set to the field.

Reimplemented from MEDMEM::FIELD_.

template<class T , class INTERLACING_TAG >
void MEDMEM::FIELD< T, INTERLACING_TAG >::write ( int  index = 0)
virtual

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_.

template<class T , class INTERLACING_TAG >
void MEDMEM::FIELD< T, INTERLACING_TAG >::write ( const GENDRIVER &  driver,
MED_EN::med_mode_acces  medMode = MED_EN::RDWR 
)
virtual

Write FIELD with the given driver.

Reimplemented from MEDMEM::FIELD_.

template<class T , class INTERLACING_TAG >
void MEDMEM::FIELD< T, INTERLACING_TAG >::write ( driverTypes  driverType,
const std::string &  filename,
MED_EN::med_mode_acces  medMode = MED_EN::RDWR 
)
virtual

Write FIELD with driver of the given type.

Reimplemented from MEDMEM::FIELD_.

Copyright © 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS