Back to index

salome-med  6.5.0
Classes | Typedefs | Functions | Variables
MEDMEM_ENSIGHT Namespace Reference

Classes

struct  TEnSightElemType
 EnSight element type name and an array to convert med connectivity to EnSight one. More...
class  _CaseFileDriver
 Reader/writer of EnSight Case file. More...
protocol  MEDMEM_EXPORT
 Base of all Ensight drivers. More...
struct  _SubPartDesc
 Descriptor of the sub-part: part number and elem type or "block" etc. More...
struct  _SubPart
 A type within EnSight part. More...
struct  _Support
 EnSight variable support composed of _SubPart's. More...
struct  _InterMed
 Structure to temporarily store data read from EnSight geom file. More...
struct  _ValueOwner
 Simple owner of C array. More...
class  _ValueIterator
 Iterator on values of a component. More...
class  _ASCIIFileReader
 Reader of ASCII files. More...
class  _BinaryFileReader
 Reader of binary files. More...
class  _BinaryFileWriter
 Writer of binary files. More...

Typedefs

typedef std::set< _SubPartDesc_SupportDesc
typedef _ValueOwner< char > TStrOwner
typedef _ValueOwner< int > TIntOwner
typedef _ValueOwner< double > TDblOwner
typedef _ValueOwner< float > TFltOwner

Functions

bool isToIgnore (const _CaseFileDriver_User *driver)
 Add a driver to the registry and return true if was already in.
void unregister (const _CaseFileDriver_User *driver)
 Remove a driver from the registry.
_InterMedgetMeshData (const string &key)
 Return mesh data needed by field driver.
STRING compatibilityPb (const string &exceptionText)
 Prepend "EnSight-MEDMEM compatibility problem" to the text of an exception.
bool toIgnoreIncompatibility ()
 To ignore incompatibility or not.
template<class TSet >
bool isValidIndex (const string &index, const map< int, TSet > &aMap)
 Return true if set index is empty or corresponds to an existing set.
const TEnSightElemTypegetEnSightType (medGeometryElement medType)
 Return EnSight type corresponding to med one.
const TEnSightElemTypegetEnSightType (const string &theTypeName)
 Return EnSight type having a given name.
bool contains (const char *what, const char *inString)
 Search substring in a string.
std::ostream & operator<< (std::ostream &os, const _SubPartDesc &desc)
 print _SubPartDesc
bool isGhostType (const string &typeName)
 Return true if typeName begins with "g_".
static float _toFloat (const double &value)
 Cast value to float and protect from overflow.
static float _toFloat (const int &value)
static float _toFloat (const long &value)

Variables

set< const _CaseFileDriver_User * > theCaseUsers
 Registry of drivers creating _CaseFileDriver.
map< string, _InterMed * > theInterMedMap
 Storage of data read by mesh driver to be used by field drivers.
const int MAX_LINE_LENGTH = 80
 Maximal EnSight line length.
const int MAX_FIELD_NAME_LENGTH = 19
 Maximal length of field name in EnSight.
const string ILLEGAL_FIELD_NAME_CHARACTERS = " !@#$^()[]*/+-"
 Maximal length of field name in EnSight.
const int INT_WIDTH_6 = 8
 Width of fields in ASCII file.
const int INT_WIDTH_GOLD = 10
const int FLT_WIDTH = 12
const int SPACE_DIM = 3
 EnSight space dimension.
static const char * TIME_STEP_BEG = "BEGIN TIME STEP"
 Time step data boundaries in single-file mode.
static const char * TIME_STEP_END = "END TIME STEP"
const size_t TIME_STEP_BEG_LEN = 15
const size_t TIME_STEP_END_LEN = 13

Class Documentation

struct MEDMEM_ENSIGHT::TEnSightElemType

EnSight element type name and an array to convert med connectivity to EnSight one.

Definition at line 118 of file MEDMEM_EnsightUtils.hxx.

Collaboration diagram for MEDMEM_ENSIGHT::TEnSightElemType:
Class Members
vector< int > _medIndex
medGeometryElement _medType
string _name

Typedef Documentation

Definition at line 89 of file MEDMEM_EnsightUtils.hxx.

Definition at line 563 of file MEDMEM_EnsightUtils.hxx.

Definition at line 564 of file MEDMEM_EnsightUtils.hxx.

Definition at line 562 of file MEDMEM_EnsightUtils.hxx.

Definition at line 561 of file MEDMEM_EnsightUtils.hxx.


Function Documentation

static float MEDMEM_ENSIGHT::_toFloat ( const double &  value) [inline, static]

Cast value to float and protect from overflow.

Definition at line 189 of file MEDMEM_EnsightUtils.hxx.

                                                      {
    if ( value >  FLT_MAX ) return  FLT_MAX;
    if ( value < -FLT_MAX ) return -FLT_MAX;
    if ( isnan( value ))    throw MEDEXCEPTION(compatibilityPb("NaN value not allowed"));
    return float( value );
  }

Here is the call graph for this function:

Here is the caller graph for this function:

static float MEDMEM_ENSIGHT::_toFloat ( const int &  value) [inline, static]

Definition at line 195 of file MEDMEM_EnsightUtils.hxx.

{ return float( value ); }
static float MEDMEM_ENSIGHT::_toFloat ( const long &  value) [inline, static]

Definition at line 196 of file MEDMEM_EnsightUtils.hxx.

{ return float( value ); }
STRING MEDMEM_ENSIGHT::compatibilityPb ( const string &  exceptionText)

Prepend "EnSight-MEDMEM compatibility problem" to the text of an exception.

Definition at line 210 of file MEDMEM_EnsightUtils.cxx.

  {
    return STRING("EnSight-MEDMEM compatibility problem:\n") << exceptionText;
  }

Here is the caller graph for this function:

bool MEDMEM_ENSIGHT::contains ( const char *  what,
const char *  inString 
)

Search substring in a string.

< search substring in a string

Definition at line 2232 of file MEDMEM_EnsightUtils.cxx.

{
  size_t whatLen = strlen( what );
  size_t inLen   = strlen( inString );
  return 
    ( search( inString, inString+inLen, what, what + whatLen) != inString+inLen );
}

Here is the caller graph for this function:

Return EnSight type corresponding to med one.

Definition at line 237 of file MEDMEM_EnsightUtils.cxx.

  {
    static TEnSightElemType theEnSightType;

    int nbNodes = medType % 100;
    theEnSightType._medType = medType;

    switch ( medType ) {
    case MED_NONE    :
    case MED_POINT1  : {
      theEnSightType._name = "point";
      theEnSightType._medIndex.resize(1,0);
      break ;
    }
    case MED_SEG2    : {
      theEnSightType._name = "bar2";
      int conn [2] = {0,1};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_SEG3    : {  
      theEnSightType._name = "bar3";
      int conn [3] = {0,2,1};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_TRIA3   : {
      theEnSightType._name = "tria3";
      int conn [3] = {0,2,1};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_QUAD4   : {
      theEnSightType._name = "quad4";
      int conn [4] = {0,3,2,1};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_TRIA6   : {
      theEnSightType._name = "tria6";
      int conn [6] = {0,2,1,5,4,3};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_QUAD8   : {
      theEnSightType._name = "quad8";
      int conn [8] = {0,3,2,1,7,6,5,4};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_TETRA4  : {
      theEnSightType._name = "tetra4";
      int conn [4] = {0,1,3,2};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_PYRA5   : {
      theEnSightType._name = "pyramid5";
      int conn [5] = {0,3,2,1,4};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_PENTA6  : {
      theEnSightType._name = "penta6";
      int conn [6] = {0,2,1,3,5,4};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_HEXA8   : {
      theEnSightType._name = "hexa8";
      int conn [8] = {0,3,2,1,4,7,6,5};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_TETRA10 : {
      theEnSightType._name = "tetra10";
      int conn [10] = {0,2,1,3,6,5,4,7,9,8};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_PYRA13  : {
      theEnSightType._name = "pyramid13";
      int conn [13] = {0,3,2,1,4,8,7,6,5,9,12,11,10};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_PENTA15 : {
      theEnSightType._name = "penta15";
      int conn [15] = {0,2,1,3,5,4,8,7,6,11,10,12,14,13};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_HEXA20  : {
      theEnSightType._name = "hexa20";
      int conn [20] = {0,3,2,1,4,7,6,5,11,10,9,8,15,14,13,12,16,19,18,17};
      theEnSightType._medIndex.assign( conn, conn+nbNodes );
      break ;
    }
    case MED_POLYGON : {
      theEnSightType._name = "nsided";
      theEnSightType._medIndex.clear();
      break ;
    }
    case MED_POLYHEDRA : {
      theEnSightType._name = "nfaced";
      theEnSightType._medIndex.clear();
      break ;
    }
    default: {
      theEnSightType._name = "";
      theEnSightType._medIndex.clear();
    }
    }
    return theEnSightType;
  }

Here is the caller graph for this function:

const TEnSightElemType & MEDMEM_ENSIGHT::getEnSightType ( const string &  theTypeName)

Return EnSight type having a given name.

Definition at line 357 of file MEDMEM_EnsightUtils.cxx.

  {
    string typeName = theTypeName;
    if ( isGhostType( typeName ))
      typeName = string( &typeName[2] ); // ghost type

    static map<string, TEnSightElemType> name2Type;

    map<string, TEnSightElemType>::iterator nameType = name2Type.find( typeName );
    if ( nameType != name2Type.end() )
      return nameType->second;

    const list<medGeometryElement> & allMedTypes = MED_EN::meshEntities[MED_CELL];
    list< medGeometryElement >::const_iterator medType = allMedTypes.begin();
    for ( ; medType != allMedTypes.end(); ++medType )
    {
      const TEnSightElemType& enSightType = getEnSightType( *medType );
      if ( enSightType._name == typeName )
        return name2Type[ typeName ] = enSightType;
    }
    return getEnSightType(MED_ALL_ELEMENTS);
  }

Here is the call graph for this function:

_InterMed * MEDMEM_ENSIGHT::getMeshData ( const string &  key)

Return mesh data needed by field driver.

Definition at line 184 of file MEDMEM_EnsightUtils.cxx.

  {
    // find existing data
    map< string, _InterMed* >::iterator kimed = theInterMedMap.find( key );
    if ( kimed != theInterMedMap.end() )
      return kimed->second;

    // create a new data
    MESH * mesh = new MESH;
    string caseFile, meshIndex;
    _ASCIIFileReader::split( key, caseFile, meshIndex, ':' );
    ENSIGHT_MESH_RDONLY_DRIVER meshDrv(caseFile, mesh, _ATOI( meshIndex ));
    meshDrv.read();
    kimed = theInterMedMap.find( key );
    if ( kimed == theInterMedMap.end() )
      return 0;
    _InterMed* imed     = kimed->second;
    imed->_medMesh      = mesh;
    imed->_isOwnMedMesh = true;
    return imed;
  }
bool MEDMEM_ENSIGHT::isGhostType ( const string &  typeName) [inline]

Return true if typeName begins with "g_".

Definition at line 140 of file MEDMEM_EnsightUtils.hxx.

  { return ( typeName[0] == 'g' && typeName[1] == '_'); }

Here is the caller graph for this function:

bool MEDMEM_ENSIGHT::isToIgnore ( const _CaseFileDriver_User *  driver)

Add a driver to the registry and return true if was already in.

Definition at line 156 of file MEDMEM_EnsightUtils.cxx.

  {
    return ! theCaseUsers.insert( driver ).second;
  }

Here is the caller graph for this function:

template<class TSet >
bool MEDMEM_ENSIGHT::isValidIndex ( const string &  index,
const map< int, TSet > &  aMap 
)

Return true if set index is empty or corresponds to an existing set.

Definition at line 227 of file MEDMEM_EnsightUtils.cxx.

  {
    if ( index.empty() ) return true;
    return ( aMap.find( _ATOI( index ) ) != aMap.end() );
  }

Here is the caller graph for this function:

std::ostream & MEDMEM_ENSIGHT::operator<< ( std::ostream &  os,
const _SubPartDesc &  desc 
)

print _SubPartDesc

Definition at line 2380 of file MEDMEM_EnsightUtils.cxx.

{
  if ( desc == _SubPartDesc::globalCoordDesc() )
    os << "'global coordinates'";
  else
    os << "<'part " << desc.partNumber() << "', '" << desc.typeName() << "'>";
  return os;
}

Here is the call graph for this function:

To ignore incompatibility or not.

Definition at line 218 of file MEDMEM_EnsightUtils.cxx.

Here is the caller graph for this function:

void MEDMEM_ENSIGHT::unregister ( const _CaseFileDriver_User *  driver)

Remove a driver from the registry.

Definition at line 166 of file MEDMEM_EnsightUtils.cxx.

  {
    theCaseUsers.erase( driver );
    if ( theCaseUsers.empty() )
    {
      for ( map< string, _InterMed* >::iterator str_imed = theInterMedMap.begin();
            str_imed != theInterMedMap.end();
            str_imed++ )
        delete str_imed->second;
      theInterMedMap.clear();
    }
  }

Here is the caller graph for this function:


Variable Documentation

const int MEDMEM_ENSIGHT::FLT_WIDTH = 12

Definition at line 167 of file MEDMEM_EnsightUtils.hxx.

const string MEDMEM_ENSIGHT::ILLEGAL_FIELD_NAME_CHARACTERS = " !@#$^()[]*/+-"

Maximal length of field name in EnSight.

Definition at line 159 of file MEDMEM_EnsightUtils.hxx.

Width of fields in ASCII file.

Definition at line 165 of file MEDMEM_EnsightUtils.hxx.

Definition at line 166 of file MEDMEM_EnsightUtils.hxx.

Maximal length of field name in EnSight.

Definition at line 153 of file MEDMEM_EnsightUtils.hxx.

Maximal EnSight line length.

Definition at line 147 of file MEDMEM_EnsightUtils.hxx.

EnSight space dimension.

Definition at line 173 of file MEDMEM_EnsightUtils.hxx.

set< const _CaseFileDriver_User* > MEDMEM_ENSIGHT::theCaseUsers

Registry of drivers creating _CaseFileDriver.

The problem is that if the mesh/field driver is created by the user, it is to write Case file, but if it is created by MED driver, it should not, in order not to overwrite the Case file written by MED driver. To assure this feature, we register all mesh/field drivers added to a case file by a MED driver and then ignore thier calls to _CaseFileDriver.

Definition at line 138 of file MEDMEM_EnsightUtils.cxx.

Storage of data read by mesh driver to be used by field drivers.

The field driver needs info read by the mesh driver (nb of elements by type in each part and what place the element gets in MEDMED support). So we store needed data unless it is no more needed (i.e. no driver is alive). The map key is "<case_file>:<mesh index>".

Definition at line 149 of file MEDMEM_EnsightUtils.cxx.

const char* MEDMEM_ENSIGHT::TIME_STEP_BEG = "BEGIN TIME STEP" [static]

Time step data boundaries in single-file mode.

Definition at line 179 of file MEDMEM_EnsightUtils.hxx.

Definition at line 181 of file MEDMEM_EnsightUtils.hxx.

const char* MEDMEM_ENSIGHT::TIME_STEP_END = "END TIME STEP" [static]

Definition at line 180 of file MEDMEM_EnsightUtils.hxx.

Definition at line 182 of file MEDMEM_EnsightUtils.hxx.