Back to index

salome-med  6.5.0
Defines | Functions
MEDMEM_EnsightFieldDriver.cxx File Reference
#include <fstream>
#include <sstream>
#include <iomanip>
#include <fenv.h>
#include "MEDMEM_Utilities.hxx"
#include "MEDMEM_Field.hxx"
#include "MEDMEM_EnsightUtils.hxx"

Go to the source code of this file.

Defines

#define TStrTool   _ASCIIFileReader

Functions

const char * getValuePointer (int i, const FIELD_ *field)
 Return pointer to the value of the i-th element.
template<typename T >
void write6ASCIIValues (const _SubPartValues &subPartValues, int nbValues, int nbComponents, int componentShift, ofstream &ensightDataFile)
 Write field values in EnSight6 ASCII format.
template<typename T >
void writeGoldASCIIValues (const _SubPartValues &subPartValues, int nbValues, int nbComponents, int componentShift, ofstream &ensightDataFile)
 Write field values in EnSight GOLD ASCII format.
template<typename T >
void write6BinaryValues (const _SubPartValues &subPartValues, int nbValues, int nbComponents, int componentShift, _BinaryFileWriter &ensightDataFile)
 Write field values in EnSight6 Binary format.
template<typename T >
void writeGoldBinaryValues (const _SubPartValues &subPartValues, int nbValues, int nbComponents, int componentShift, _BinaryFileWriter &ensightDataFile)
 Write field values in EnSight GOLD Binary format.

Define Documentation

#define TStrTool   _ASCIIFileReader

Definition at line 33 of file MEDMEM_EnsightFieldDriver.cxx.


Function Documentation

const char * getValuePointer ( int  i,
const FIELD_ field 
)

Return pointer to the value of the i-th element.

Definition at line 1198 of file MEDMEM_EnsightFieldDriver.cxx.

{
  switch ( field->getInterlacingType() ) {
  case MED_FULL_INTERLACE:
    if ( field->getValueType() == MED_REEL64 )
      return (const char*) & static_cast<const FIELD<double, FullInterlace>* >
        ( field )->getArrayNoGauss()->getIJ( i, 1 );
    else
      return (const char*) & static_cast<const FIELD<int, FullInterlace>* >
        ( field )->getArrayNoGauss()->getIJ( i, 1 );
  case MED_NO_INTERLACE:
    if ( field->getValueType() == MED_REEL64 )
      return (const char*) & static_cast<const FIELD<double, NoInterlace>* >
        ( field )->getArrayNoGauss()->getIJ( i, 1 );
    else
      return (const char*) & static_cast<const FIELD<int, NoInterlace>* >
        ( field )->getArrayNoGauss()->getIJ( i, 1 );
  case MED_NO_INTERLACE_BY_TYPE:
    if ( field->getValueType() == MED_REEL64 )
      return (const char*) & static_cast<const FIELD<double, NoInterlaceByType>* >
        ( field )->getArrayNoGauss()->getIJ( i, 1 );
    else
      return (const char*) & static_cast<const FIELD<int, NoInterlaceByType>* >
        ( field )->getArrayNoGauss()->getIJ( i, 1 );
  default:;
  }
  return 0;
}
template<typename T >
void write6ASCIIValues ( const _SubPartValues &  subPartValues,
int  nbValues,
int  nbComponents,
int  componentShift,
ofstream &  ensightDataFile 
)

Write field values in EnSight6 ASCII format.

Definition at line 1234 of file MEDMEM_EnsightFieldDriver.cxx.

{
  // add the 3-d component to a vector in 2D space
  const bool add3dComp = true;
  int mypoint=0;
  if ( subPartValues.myNumbers )
  {
    vector< _SelectedValueIterator<T> > compValIt =
      subPartValues.template getAllSelectedValues<T>( componentShift, nbComponents, add3dComp );
    nbComponents = compValIt.size();
    // in full interlace
    for (int i=0; i<nbValues; i++)
      for(int j=0; j<nbComponents; j++) {
        ensightDataFile << setw(12) << _toFloat( compValIt[j].next() );
        if (++mypoint == 6) {
          ensightDataFile << endl ;
          mypoint=0;
        }
      }
  }
  else {
    vector< _ValueIterator<T> > compValIt =
      subPartValues.template getAllValues<T>( componentShift, nbComponents, add3dComp );
    nbComponents = compValIt.size();
    // in full interlace
    for (int i=0; i<nbValues; i++)
      for(int j=0; j<nbComponents; j++) {
        ensightDataFile << setw(12) << _toFloat( compValIt[j].next() );
        if (++mypoint == 6) {
          ensightDataFile << endl ;
          mypoint=0;
        }
      }
  }
  if ( nbValues * nbComponents % 6 )
    ensightDataFile << endl;
}

Here is the call graph for this function:

template<typename T >
void write6BinaryValues ( const _SubPartValues &  subPartValues,
int  nbValues,
int  nbComponents,
int  componentShift,
_BinaryFileWriter ensightDataFile 
)

Write field values in EnSight6 Binary format.

Definition at line 1319 of file MEDMEM_EnsightFieldDriver.cxx.

{
  const bool add3dComp = true;
  if ( subPartValues.myNumbers )
  {
    vector< _SelectedValueIterator<T> > compValIt =
      subPartValues.template getAllSelectedValues<T>( componentShift, nbComponents, add3dComp );
    ensightDataFile.addReal( compValIt, nbValues, MED_FULL_INTERLACE );
  }
  else
  {
    vector< _ValueIterator<T> > compValIt =
      subPartValues.template getAllValues<T>( componentShift, nbComponents, add3dComp );
    ensightDataFile.addReal( compValIt, nbValues, MED_FULL_INTERLACE );
  }
}

Here is the call graph for this function:

template<typename T >
void writeGoldASCIIValues ( const _SubPartValues &  subPartValues,
int  nbValues,
int  nbComponents,
int  componentShift,
ofstream &  ensightDataFile 
)

Write field values in EnSight GOLD ASCII format.

Definition at line 1283 of file MEDMEM_EnsightFieldDriver.cxx.

{
  // in no-interlace
  for(int j=1; j<=nbComponents; j++) {
    if ( subPartValues.myNumbers )
    {
      _SelectedValueIterator<T> values
        = subPartValues.template getSelectedValues<T>( j, componentShift, nbComponents );
      for (int i=0; i<nbValues; i++)
        ensightDataFile << setw(12) << _toFloat( values.next() ) << endl;
    }
    else {
      _ValueIterator<T> values
        = subPartValues.template getValues<T>( j, componentShift, nbComponents );
      for (int i=0; i<nbValues; i++)
        ensightDataFile << setw(12) << _toFloat( values.next() )<< endl;
    }
  }
  // add the 3-d component to a vector in 2D space
  if ( nbComponents == 2 ) {
    for (int i=0; i<nbValues; i++)
      ensightDataFile << " 0.00000e+00" << endl;
  }
}

Here is the call graph for this function:

template<typename T >
void writeGoldBinaryValues ( const _SubPartValues &  subPartValues,
int  nbValues,
int  nbComponents,
int  componentShift,
_BinaryFileWriter ensightDataFile 
)

Write field values in EnSight GOLD Binary format.

Definition at line 1347 of file MEDMEM_EnsightFieldDriver.cxx.

{
  const bool add3dComp = false;
  if ( subPartValues.myNumbers )
  {
    vector< _SelectedValueIterator<T> > compValIt =
      subPartValues.template getAllSelectedValues<T>( componentShift, nbComponents, add3dComp );
    ensightDataFile.addReal( compValIt, nbValues, MED_NO_INTERLACE );
  }
  else
  {
    vector< _ValueIterator<T> > compValIt =
      subPartValues.template getAllValues<T>( componentShift, nbComponents, add3dComp );
    ensightDataFile.addReal( compValIt, nbValues, MED_NO_INTERLACE );
  }
  // add the 3-d component to a vector in 2D space
  if ( nbComponents == 2 ) {
    vector<float> values( nbValues, 0. );
    ensightDataFile.addReal( & values[0], nbValues );
  }
}

Here is the call graph for this function: