Back to index

salome-med  6.5.0
Functions
MEDMEMTest_Field.cxx File Reference
#include "MEDMEMTest.hxx"
#include "MEDMEM_FieldConvert.hxx"
#include "MEDMEM_Field.hxx"
#include "MEDMEM_MedMeshDriver.hxx"
#include "MEDMEM_Grid.hxx"
#include "MEDMEM_Group.hxx"
#include "MEDMEM_Mesh.hxx"
#include "MEDMEM_Meshing.hxx"
#include "MEDMEM_Support.hxx"
#include "MEDMEM_VtkMeshDriver.hxx"
#include <cppunit/TestAssert.h>
#include <sstream>
#include <cmath>

Go to the source code of this file.

Functions

static void compareField_ (const FIELD_ *theField_1, const FIELD_ *theField_2, bool isFIELD, bool isValue)
 Check methods (48), defined in MEDMEM_Field.hxx: class FIELD_ { (+) FIELD_(); (+) FIELD_(const SUPPORT * Support, const int NumberOfComponents); (+) FIELD_(const FIELD_ &m); (+) virtual ~FIELD_(); (+) FIELD_& operator=(const FIELD_ &m);.
static void checkField_ (FIELD_ *theField_, const SUPPORT *theSupport, MED_EN::med_type_champ theValueType, MED_EN::medModeSwitch theInterlace)
template<class T , class INTERLACING_TAG >
void compareField (const FIELD< T, INTERLACING_TAG > *theField_1, const FIELD< T, INTERLACING_TAG > *theField_2, bool isValue)
template<class T , class INTERLACING_TAG >
void checkField (FIELD< T, INTERLACING_TAG > *theField, const SUPPORT *theSupport)
template<class T >
FIELD< T > * createFieldOnGroup (MESH *theMesh, const GROUP *theGroup, const string theName, const string theDescr)
double plus13 (double val)
static void proj2d (const double *temp, double *output)
static void testDrivers ()

Function Documentation

template<class T , class INTERLACING_TAG >
void checkField ( FIELD< T, INTERLACING_TAG > *  theField,
const SUPPORT *  theSupport 
)

Definition at line 432 of file MEDMEMTest_Field.cxx.

{
  // check FIELD_ part
  MED_EN::med_type_champ aValueType = SET_VALUE_TYPE<T>::_valueType;
  MED_EN::medModeSwitch  anInterlace = SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType;
  checkField_(theField, theSupport, aValueType, anInterlace);

  // check FIELD part

  // filling by support charackteristics (NOT IMPLEMENTED METHODS!!!):
  // value type must be MED_REEL64 (i.e. a FIELD<double>) for these methods,
  // nb. of components must be equal 1 (for Volume, Area, Length) or
  // space dimension (for Normal, Barycenter, )
  {
    const GMESH* aMesh = theSupport->getMesh();
    int spaceDim = 3;
    if (aMesh) spaceDim = aMesh->getSpaceDimension();
    theField->deallocValue();
    theField->allocValue(/*NumberOfComponents = */spaceDim + 1);

    theField->deallocValue();
    theField->allocValue(/*NumberOfComponents = */1);

    if (aMesh) 
      {
        theField->deallocValue();
        theField->allocValue(/*NumberOfComponents = */spaceDim);
      }

    if (aMesh)
      {
        theField->deallocValue();
        theField->allocValue(/*NumberOfComponents = */spaceDim);
        //  0020142: [CEA 315] Unused function in MEDMEM::FIELD
        // getVolume() etc. does nothing
        //       if (aValueType == MED_EN::MED_REEL64)
        {
          //         CPPUNIT_ASSERT_NO_THROW(theField->getNormal());
          //         CPPUNIT_ASSERT_NO_THROW(theField->getBarycenter());
          //
        }
        //       else
        {
          //         CPPUNIT_ASSERT_THROW(theField->getNormal(), MEDEXCEPTION);
          //         CPPUNIT_ASSERT_THROW(theField->getBarycenter(), MEDEXCEPTION);
          //
        }
      }
  }

  // values
  theField->deallocValue();
  theField->allocValue(/*NumberOfComponents = */2);
  int nbElemSupport = theSupport->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
  CPPUNIT_ASSERT_EQUAL(nbElemSupport, theField->getNumberOfValues());

  theField->deallocValue();
  CPPUNIT_ASSERT_THROW(theField->getGaussPresence(), MEDEXCEPTION);

  // copy constructor
  FIELD<T, INTERLACING_TAG> *aField_copy1= new FIELD<T, INTERLACING_TAG>(*theField);
  compareField(theField, aField_copy1, /*isValue = */false);
  aField_copy1->removeReference();

  // operator=
  FIELD<T, INTERLACING_TAG> *aField_copy2=new FIELD<T, INTERLACING_TAG>();
  *aField_copy2 = *theField;
  compareField(theField, aField_copy2, /*isValue = */false);
  aField_copy2->removeReference();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void checkField_ ( FIELD_ *  theField_,
const SUPPORT *  theSupport,
MED_EN::med_type_champ  theValueType,
MED_EN::medModeSwitch  theInterlace 
) [static]

Definition at line 289 of file MEDMEMTest_Field.cxx.

{
  // name
  const string aFieldName = "a_name_of_a_field";
  theField_->setName(aFieldName);
  CPPUNIT_ASSERT_EQUAL(aFieldName, theField_->getName());

  // description
  const string aFieldDescr = "a_description_of_a_field";
  theField_->setDescription(aFieldDescr);
  CPPUNIT_ASSERT_EQUAL(aFieldDescr, theField_->getDescription());

  // support
  theField_->setSupport(theSupport);
  CPPUNIT_ASSERT(theField_->getSupport() == theSupport);

  // components information
  int aNbComps = 3;

  string aCompsNames[3] =
    {
      "Vx", "Vy", "Vz"
    };
  string aCompsDescs[3] =
    {
      "vitesse selon x", "vitesse selon y", "vitesse selon z"
    };
  string aCompsUnits[3] =
    {
      "m.s-1", "m.s-1", "m.s-1"
    };

  theField_->setNumberOfComponents(aNbComps);
  CPPUNIT_ASSERT_EQUAL(aNbComps, theField_->getNumberOfComponents());

  theField_->setComponentsNames(aCompsNames);

  //#ifdef ENABLE_FAULTS
  try
    {
      theField_->setNumberOfComponents(7);
      // Segmentation fault here because array of components names is not resized
      for (int i = 1; i <= 7; i++)
        {
          theField_->setComponentName(i, "AnyComponent");
        }
    }
  catch (MEDEXCEPTION& ex)
    {
      // Ok, it is good to have MEDEXCEPTION here
    }
  catch (...)
    {
      CPPUNIT_FAIL("Unknown exception cought");
    }
  // restore components names
  theField_->setNumberOfComponents(aNbComps);
  theField_->setComponentsNames(aCompsNames);

  theField_->setComponentsDescriptions(aCompsDescs);
  theField_->setMEDComponentsUnits(aCompsUnits);

  const string * aCompsNamesBack = theField_->getComponentsNames();
  const string * aCompsDescsBack = theField_->getComponentsDescriptions();
  const string * aCompsUnitsBack = theField_->getMEDComponentsUnits();
  for (int i = 1; i <= aNbComps; i++)
    {
      CPPUNIT_ASSERT_EQUAL(aCompsNamesBack[i-1], theField_->getComponentName(i));
      CPPUNIT_ASSERT_EQUAL(aCompsNamesBack[i-1], aCompsNames[i-1]);

      CPPUNIT_ASSERT_EQUAL(aCompsDescsBack[i-1], theField_->getComponentDescription(i));
      CPPUNIT_ASSERT_EQUAL(aCompsDescsBack[i-1], aCompsDescs[i-1]);

      CPPUNIT_ASSERT_EQUAL(aCompsUnitsBack[i-1], theField_->getMEDComponentUnit(i));
      CPPUNIT_ASSERT_EQUAL(aCompsUnitsBack[i-1], aCompsUnits[i-1]);
    }

  const string aCompName2 ("Name of second component");
  const string aCompDesc2 ("Description of second component");
  const string aCompUnit2 ("Unit of second MED component");

  theField_->setComponentName(2, aCompName2);
  theField_->setComponentDescription(2, aCompDesc2);
  theField_->setMEDComponentUnit(2, aCompUnit2);

  const string * aCompsNamesBack2 = theField_->getComponentsNames();
  const string * aCompsDescsBack2 = theField_->getComponentsDescriptions();
  const string * aCompsUnitsBack2 = theField_->getMEDComponentsUnits();

  CPPUNIT_ASSERT_EQUAL(aCompsNamesBack2[1], theField_->getComponentName(2));
  CPPUNIT_ASSERT_EQUAL(aCompsNamesBack2[1], aCompName2);

  CPPUNIT_ASSERT_EQUAL(aCompsDescsBack2[1], theField_->getComponentDescription(2));
  CPPUNIT_ASSERT_EQUAL(aCompsDescsBack2[1], aCompDesc2);

  CPPUNIT_ASSERT_EQUAL(aCompsUnitsBack2[1], theField_->getMEDComponentUnit(2));
  CPPUNIT_ASSERT_EQUAL(aCompsUnitsBack2[1], aCompUnit2);

  CPPUNIT_ASSERT_THROW(theField_->setComponentName(0, "str"), MEDEXCEPTION);
  CPPUNIT_ASSERT_THROW(theField_->setComponentName(aNbComps + 1, "str"), MEDEXCEPTION);
  CPPUNIT_ASSERT_THROW(theField_->setComponentDescription(0, "str"), MEDEXCEPTION);
  CPPUNIT_ASSERT_THROW(theField_->setComponentDescription(aNbComps + 1, "str"), MEDEXCEPTION);
  CPPUNIT_ASSERT_THROW(theField_->setMEDComponentUnit(0, "str"), MEDEXCEPTION);
  CPPUNIT_ASSERT_THROW(theField_->setMEDComponentUnit(aNbComps + 1, "str"), MEDEXCEPTION);

  // iteration information
  int anIterNumber = 10; // set value to MED_NOPDT if undefined (default)
  theField_->setIterationNumber(anIterNumber);
  CPPUNIT_ASSERT_EQUAL(anIterNumber, theField_->getIterationNumber());

  int anOrderNumber = 1; // set value to MED_NONOR if undefined (default)
  theField_->setOrderNumber(anOrderNumber);
  CPPUNIT_ASSERT_EQUAL(anOrderNumber, theField_->getOrderNumber());

  double aTime = 3.435678; // in second
  theField_->setTime(aTime);
  CPPUNIT_ASSERT_DOUBLES_EQUAL(aTime, theField_->getTime(), 0.0000001);

  // Value
  int nbOfValues = 10;
  // dangerous method, because it does not reallocate values array
  theField_->setNumberOfValues(nbOfValues);
  CPPUNIT_ASSERT_EQUAL(nbOfValues, theField_->getNumberOfValues());

  // Value type and Interlacing type
  CPPUNIT_ASSERT_EQUAL(theValueType, theField_->getValueType());
  CPPUNIT_ASSERT_EQUAL(theInterlace, theField_->getInterlacingType());
}

Here is the caller graph for this function:

template<class T , class INTERLACING_TAG >
void compareField ( const FIELD< T, INTERLACING_TAG > *  theField_1,
const FIELD< T, INTERLACING_TAG > *  theField_2,
bool  isValue 
)

Definition at line 421 of file MEDMEMTest_Field.cxx.

{
  // compare FIELD_ part
  compareField_(theField_1, theField_2, /*isFIELD = */true, isValue);

  // compare FIELD part
  // TO DO
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void compareField_ ( const FIELD_ *  theField_1,
const FIELD_ *  theField_2,
bool  isFIELD,
bool  isValue 
) [static]

Check methods (48), defined in MEDMEM_Field.hxx: class FIELD_ { (+) FIELD_(); (+) FIELD_(const SUPPORT * Support, const int NumberOfComponents); (+) FIELD_(const FIELD_ &m); (+) virtual ~FIELD_(); (+) FIELD_& operator=(const FIELD_ &m);.

(-) virtual void rmDriver(int index=0); (-) virtual int addDriver(driverTypes driverType, const string & fileName="Default File Name.med", const string & driverFieldName="Default Field Nam", MED_EN::med_mode_acces access=MED_EN::MED_REMP); (-) virtual int addDriver(GENDRIVER & driver);

(-) virtual void read (const GENDRIVER &); (-) virtual void read(int index=0); (-) virtual void openAppend(void); (-) virtual void write(const GENDRIVER &); (-) virtual void write(int index=0, const string & driverName=""); (-) virtual void writeAppend(const GENDRIVER &); (-) virtual void writeAppend(int index=0, const string & driverName="");

(+) inline void setName(const string Name); (+) inline string getName() const; (+) inline void setDescription(const string Description); (+) inline string getDescription() const; (+) inline const SUPPORT * getSupport() const; (+) inline void setSupport(const SUPPORT * support); (+) inline void setNumberOfComponents(const int NumberOfComponents); (+) inline int getNumberOfComponents() const; (+) inline void setNumberOfValues(const int NumberOfValues); (+) inline int getNumberOfValues() const; (+) inline void setComponentsNames(const string * ComponentsNames); (+) inline void setComponentName(int i, const string ComponentName); (+) inline const string * getComponentsNames() const; (+) inline string getComponentName(int i) const; (+) inline void setComponentsDescriptions(const string * ComponentsDescriptions); (+) inline void setComponentDescription(int i, const string ComponentDescription); (+) inline const string * getComponentsDescriptions() const; (+) inline string getComponentDescription(int i) const; (+) inline void setComponentsUnits(const UNIT * ComponentsUnits); (+) inline const UNIT * getComponentsUnits() const; (+) inline const UNIT * getComponentUnit(int i) const; (+) inline void setMEDComponentsUnits(const string * MEDComponentsUnits); (+) inline void setMEDComponentUnit(int i, const string MEDComponentUnit); (+) inline const string * getMEDComponentsUnits() const; (+) inline string getMEDComponentUnit(int i) const;

(+) inline void setIterationNumber(int IterationNumber); (+) inline int getIterationNumber() const; (+) inline void setTime(double Time); (+) inline double getTime() const; (+) inline void setOrderNumber(int OrderNumber); (+) inline int getOrderNumber() const;

(+) inline MED_EN::med_type_champ getValueType () const; (+) inline MED_EN::medModeSwitch getInterlacingType() const; (-) virtual inline bool getGaussPresence() const throw (MEDEXCEPTION);

}

template <class T, class INTERLACING_TAG> class FIELD : public FIELD_ { (+) FIELD(); (+) FIELD(const FIELD &m); (+) FIELD(const SUPPORT * Support, const int NumberOfComponents) throw (MEDEXCEPTION); (+) FIELD(driverTypes driverType, const string & fileName, const string & fieldDriverName, const int iterationNumber=-1, const int orderNumber=-1) throw (MEDEXCEPTION); (+) FIELD(const SUPPORT * Support, driverTypes driverType, const string & fileName="", const string & fieldName="", const int iterationNumber = -1, const int orderNumber = -1) throw (MEDEXCEPTION); (+) ~FIELD(); (+) FIELD & operator=(const FIELD &m);

(+) const FIELD operator+(const FIELD& m) const; (+) const FIELD operator-(const FIELD& m) const; (+) const FIELD operator*(const FIELD& m) const; (+) const FIELD operator/(const FIELD& m) const; (+) const FIELD operator-() const; (+) FIELD& operator+=(const FIELD& m); (+) FIELD& operator-=(const FIELD& m); (+) FIELD& operator*=(const FIELD& m); (+) FIELD& operator/=(const FIELD& m);

(+) static FIELD* add(const FIELD& m, const FIELD& n); (+) static FIELD* addDeep(const FIELD& m, const FIELD& n); (+) static FIELD* sub(const FIELD& m, const FIELD& n); (+) static FIELD* subDeep(const FIELD& m, const FIELD& n); (+) static FIELD* mul(const FIELD& m, const FIELD& n); (+) static FIELD* mulDeep(const FIELD& m, const FIELD& n); (+) static FIELD* div(const FIELD& m, const FIELD& n); (+) static FIELD* divDeep(const FIELD& m, const FIELD& n);

(+) double normMax() const throw (MEDEXCEPTION); (+) double norm2() const throw (MEDEXCEPTION);

(+) void applyLin(T a, T b); (+) template <T T_function(T)> void applyFunc(); (+) void applyPow(T scalar);

(+) static FIELD* scalarProduct(const FIELD& m, const FIELD& n, bool deepCheck=false);

(+) double normL2(int component, const FIELD<double,FullInterlace> * p_field_volume=NULL) const; (+) double normL2(const FIELD<double,FullInterlace> * p_field_volume=NULL) const; (+) double normL1(int component, const FIELD<double,FullInterlace> * p_field_volume=NULL) const; (+) double normL1(const FIELD<double,FullInterlace> * p_field_volume=NULL) const;

(+) FIELD* extract(const SUPPORT *subSupport) const throw (MEDEXCEPTION);

(EMPTY COMMENT, EMPTY IMPLEMENTATION!!!) void init ();

(+) void rmDriver(int index=0); (+) int addDriver(driverTypes driverType, const string & fileName="Default File Name.med", const string & driverFieldName="Default Field Name", MED_EN::med_mode_acces access=MED_EN::MED_REMP); (+) int addDriver(GENDRIVER & driver);

(+) void allocValue(const int NumberOfComponents); (+) void allocValue(const int NumberOfComponents, const int LengthValue); (+) void deallocValue();

(+) inline void read(int index=0); (+) inline void read(const GENDRIVER & genDriver); (+) inline void read(driverTypes driverType, const std::string& filename); (+) inline void write(int index=0); (+) inline void write(const GENDRIVER &, MED_EN::med_mode_acces medMode=MED_EN::RDWR); (+) inline void write(driverTypes driverType, const std::string& filename, MED_EN::med_mode_acces medMode=MED_EN::RDWR); (+) inline void writeAppend(int index=0, const string & driverName = ""); (+) inline void writeAppend(const GENDRIVER &);

(+) inline MEDMEM_Array_ * getArray() const throw (MEDEXCEPTION); (+) inline ArrayGauss * getArrayGauss() const throw (MEDEXCEPTION); (+) inline ArrayNoGauss * getArrayNoGauss() const throw (MEDEXCEPTION); (+) inline bool getGaussPresence() const throw (MEDEXCEPTION);

(+) inline int getValueLength() const throw (MEDEXCEPTION); (+) inline const T* getValue() const throw (MEDEXCEPTION); (+) inline const T* getRow(int i) const throw (MEDEXCEPTION); (+) inline const T* getColumn(int j) const throw (MEDEXCEPTION); (+) inline T getValueIJ(int i,int j) const throw (MEDEXCEPTION); (+) inline T getValueIJK(int i,int j,int k) const throw (MEDEXCEPTION); (+) bool getValueOnElement(int eltIdInSup,T* retValues) const throw (MEDEXCEPTION);

(+) const int getNumberOfGeometricTypes() const throw (MEDEXCEPTION);

(+) const GAUSS_LOCALIZATION<INTERLACING_TAG> & getGaussLocalization (MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); (+) const GAUSS_LOCALIZATION<INTERLACING_TAG> * getGaussLocalizationPtr (MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); (+) void setGaussLocalization(MED_EN::medGeometryElement geomElement, const GAUSS_LOCALIZATION<INTERLACING_TAG> & gaussloc); (+) const int * getNumberOfGaussPoints() const throw (MEDEXCEPTION); (+) const int getNumberOfGaussPoints (MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); (+) const int getNbGaussI(int i) const throw (MEDEXCEPTION);

(+) const int * getNumberOfElements() const throw (MEDEXCEPTION); (+) const MED_EN::medGeometryElement * getGeometricTypes() const throw (MEDEXCEPTION); (+) bool isOnAllElements() const throw (MEDEXCEPTION);

(+) inline void setArray(MEDMEM_Array_ <em>value) throw (MEDEXCEPTION); (+) FIELD<double, FullInterlace> getGaussPointsCoordinates() const throw (MEDEXCEPTION); (+) inline void setValue(T* value) throw (MEDEXCEPTION); (+) inline void setRow(int i, T* value) throw (MEDEXCEPTION); (+) inline void setColumn(int i, T* value) throw (MEDEXCEPTION); (+) inline void setValueIJ(int i, int j, T value) throw (MEDEXCEPTION);

(NOT IMPLEMENTED!!!) void getVolume() const throw (MEDEXCEPTION); (NOT IMPLEMENTED!!!) void getArea() const throw (MEDEXCEPTION); (NOT IMPLEMENTED!!!) void getLength() const throw (MEDEXCEPTION); (NOT IMPLEMENTED!!!) void getNormal() const throw (MEDEXCEPTION); (NOT IMPLEMENTED!!!) void getBarycenter() const throw (MEDEXCEPTION);

(+) void fillFromAnalytic(myFuncType f) throw (MEDEXCEPTION);

}

Use code of test_operation_fieldint.cxx test_operation_fielddouble.cxx test_copie_field_.cxx test_copie_fieldT.cxx

Definition at line 238 of file MEDMEMTest_Field.cxx.

{
  // name, description, support
  CPPUNIT_ASSERT_EQUAL(theField_1->getName(), theField_2->getName());
  CPPUNIT_ASSERT_EQUAL(theField_1->getDescription(), theField_2->getDescription());
  CPPUNIT_ASSERT_EQUAL(theField_1->getSupport(), theField_2->getSupport());

  // components information
  int aNbComps = theField_1->getNumberOfComponents();
  CPPUNIT_ASSERT_EQUAL(aNbComps, theField_2->getNumberOfComponents());

  for (int i = 1; i <= aNbComps; i++)
    {
      CPPUNIT_ASSERT_EQUAL(theField_1->getComponentName(i), theField_2->getComponentName(i));
      CPPUNIT_ASSERT_EQUAL(theField_1->getComponentDescription(i), theField_2->getComponentDescription(i));
      CPPUNIT_ASSERT_EQUAL(theField_1->getMEDComponentUnit(i), theField_2->getMEDComponentUnit(i));
    }

  // iteration information
  CPPUNIT_ASSERT_EQUAL(theField_1->getIterationNumber(), theField_2->getIterationNumber());
  CPPUNIT_ASSERT_EQUAL(theField_1->getOrderNumber(), theField_2->getOrderNumber());
  CPPUNIT_ASSERT_DOUBLES_EQUAL(theField_1->getTime(), theField_2->getTime(), 0.0000001);

  // Value
  int nbOfValues = theField_1->getNumberOfValues();
  CPPUNIT_ASSERT_EQUAL(nbOfValues, theField_2->getNumberOfValues());

  if (isFIELD)
    {
      // Value type and Interlacing type
      CPPUNIT_ASSERT_EQUAL(theField_1->getValueType(), theField_2->getValueType());
      CPPUNIT_ASSERT_EQUAL(theField_1->getInterlacingType(), theField_2->getInterlacingType());

      // Gauss Presence
      if (isValue)
        {
          CPPUNIT_ASSERT_EQUAL(theField_1->getGaussPresence(), theField_2->getGaussPresence());
        }
      else
        {
          CPPUNIT_ASSERT_THROW(theField_1->getGaussPresence(), MEDEXCEPTION);
          CPPUNIT_ASSERT_THROW(theField_2->getGaussPresence(), MEDEXCEPTION);
        }
    }
  else
    {
      CPPUNIT_ASSERT_THROW(theField_1->getGaussPresence(), MEDEXCEPTION);
      CPPUNIT_ASSERT_THROW(theField_2->getGaussPresence(), MEDEXCEPTION);
    }
}

Here is the caller graph for this function:

template<class T >
FIELD<T>* createFieldOnGroup ( MESH *  theMesh,
const GROUP *  theGroup,
const string  theName,
const string  theDescr 
)

Definition at line 504 of file MEDMEMTest_Field.cxx.

{
  FIELD<T> * aFieldOnGroup = new FIELD<T>(theGroup, /*NumberOfComponents = */2);

  aFieldOnGroup->setName(theName);
  aFieldOnGroup->setDescription(theDescr);

  string aCompsNames[2] =
    {
      "Pos", "Neg"
    };
  string aCompsDescs[2] =
    {
      "+", "-"
    };
  string aCompsUnits[2] =
    {
      "unit1", "unit2"
    };

  aFieldOnGroup->setComponentsNames(aCompsNames);
  aFieldOnGroup->setComponentsDescriptions(aCompsDescs);
  aFieldOnGroup->setMEDComponentsUnits(aCompsUnits);

  return aFieldOnGroup;
}
double plus13 ( double  val)

Definition at line 533 of file MEDMEMTest_Field.cxx.

{
  return val + 13;
}

Here is the caller graph for this function:

static void proj2d ( const double *  temp,
double *  output 
) [static]

Definition at line 542 of file MEDMEMTest_Field.cxx.

{
  // dimetric projection with coefficients:
  // 1.0 along Oy and Oz, 0.5 along Ox
  //
  //    ^ z (y_)
  //    |
  //    |
  //    .----> y (x_)
  //   /
  //  L x
  //
  // x_ = y - x * sqrt(2.) / 4.
  // y_ = z - x * sqrt(2.) / 4.

  double dx = temp[0] * std::sqrt(2.) / 4.;
  output[0] = temp[1] - dx;
  output[1] = temp[2] - dx;
}
static void testDrivers ( ) [static]

Definition at line 562 of file MEDMEMTest_Field.cxx.

{
  string filename_rd                  = getResourceFile("pointe.med");
  string filename_wr                  = makeTmpFile("myMedFieldfile.med", filename_rd);
  string filename_support_wr          = makeTmpFile("myMedSupportFiledfile.med");
  string filename22_rd                = getResourceFile("pointe.med");
  string filenamevtk_wr               = makeTmpFile("myMedFieldfile22.vtk");

  string fieldname_celldouble_rd      = "fieldcelldoublescalar";
  string fieldname_celldouble_wr      = fieldname_celldouble_rd + "_cpy";
  string fieldname_nodeint_rd         = "fieldnodeint";
  string fieldname_nodeint_wr         = fieldname_nodeint_rd + "_cpy";
  string fieldname_nodeint_wr1        = fieldname_nodeint_rd + "_cpy1";
  string meshname                     = "maa1";

  // To remove tmp files from disk
  MEDMEMTest_TmpFilesRemover aRemover;
  aRemover.Register(filename_wr);
  aRemover.Register(filenamevtk_wr);
  aRemover.Register(filename_support_wr);

  FIELD<int> *aInvalidField=new FIELD<int>();
  //must throw becase only VTK_DRIVER or MED_DRIVER may be specified as driverType for FIELD
  CPPUNIT_ASSERT_THROW(*aInvalidField = *(new FIELD<int>(NO_DRIVER, filename_rd, fieldname_nodeint_rd)),
                       MEDEXCEPTION);
  CPPUNIT_ASSERT_THROW(*aInvalidField = *(new FIELD<int>(GIBI_DRIVER, filename_rd, fieldname_nodeint_rd)),
                       MEDEXCEPTION);
  CPPUNIT_ASSERT_THROW(*aInvalidField = *(new FIELD<int>(PORFLOW_DRIVER, filename_rd, fieldname_nodeint_rd)),
                       MEDEXCEPTION);
  CPPUNIT_ASSERT_THROW(*aInvalidField = *(new FIELD<int>(ASCII_DRIVER, filename_rd, fieldname_nodeint_rd)),
                       MEDEXCEPTION);
  aInvalidField->removeReference();
  //TestRead Part//
  FIELD<double> *aField_1 = NULL;
  CPPUNIT_ASSERT_NO_THROW(aField_1 = new FIELD<double>(MED_DRIVER, filename_rd,
                                                       fieldname_celldouble_rd));

  //Test read(int index) method
  int IdDriver_rd = aField_1->addDriver(MED_DRIVER,filename_rd,fieldname_celldouble_rd,MED_EN::RDONLY);
  // TODO: throw if read for the second time
  // (BUG) Cannot open file, but file exist
  // EAP: no more pb with opening the file for the second time with "weaker" mode,
  // but why to re-read the field?
  //CPPUNIT_ASSERT_THROW(aField_1->read(IdDriver_rd),MEDEXCEPTION);
  CPPUNIT_ASSERT_NO_THROW(aField_1->read(IdDriver_rd));

  //Test read(GENDRIVER & genDriver) method
  FIELD<int> *aField_2 = new FIELD<int>();
  aField_2->setName(fieldname_nodeint_rd);
  {
    MED_FIELD_RDONLY_DRIVER<int> aMedRdFieldDriver;
    aMedRdFieldDriver.setFileName(filename_rd);
    aField_2->read( aMedRdFieldDriver );
  }
  //Test read(driverTypes driverType, const std::string & fileName);
  FIELD<double> * aField_3 = new FIELD<double>();
  aField_3->setName(fieldname_celldouble_rd);
  aField_3->read( MED_DRIVER, filename_rd);

  //Test Write Part//
  //int IdDriver;
  MESH *aMesh = new MESH(MED_DRIVER,filename_rd,meshname);
  const SUPPORT *aSupport = aMesh->getSupportOnAll(MED_CELL);
  FIELD<int> *aFieldSupport;
  CPPUNIT_ASSERT_THROW(aFieldSupport = 
                       new FIELD<int>(aSupport, MED_DRIVER,filename_rd,
                                      fieldname_nodeint_rd), MEDMEM::MEDEXCEPTION);
  aSupport = aMesh->getSupportOnAll(MED_NODE);
  CPPUNIT_ASSERT_NO_THROW(aFieldSupport = 
                          new FIELD<int>(aSupport, MED_DRIVER, filename_rd,
                                         fieldname_nodeint_rd));
  aFieldSupport->removeReference();

  //Test write(int index) method
  // Add drivers to FIELDs
  int IdDriver1 = aField_3->addDriver(MED_DRIVER,filename_wr,fieldname_celldouble_wr);

  //Trying call write(int index) method with incorrect index
  CPPUNIT_ASSERT_THROW(aField_3->write(IdDriver1+1),MEDEXCEPTION);

  //Write field to file
  aField_3->write(IdDriver1);

  CPPUNIT_ASSERT_NO_THROW(aField_3->rmDriver(IdDriver1));

  //Test write(const GENDRIVER &, MED_EN::med_mode_acces medMode=MED_EN::RDWR);
  {
    MED_FIELD_WRONLY_DRIVER<int> aMedWrFieldDriver;
    aMedWrFieldDriver.setFileName(filename_wr);

    aField_3->setName(fieldname_nodeint_wr);
    aField_3->write(aMedWrFieldDriver);
    FIELD<double> aField_3_RD;
    aField_3_RD.setName(fieldname_nodeint_wr);
    aField_3_RD.read(MED_DRIVER,filename_wr);
  }

  // Test write(driverTypes driverType, const std::string& filename
  //            MED_EN::med_mode_acces medMode=MED_EN::RDWR)
  aField_3->setName(fieldname_nodeint_wr1);
  // wrong mode
  CPPUNIT_ASSERT_THROW(aField_3->write(MED_DRIVER,filename_wr,MED_EN::RDONLY), MEDEXCEPTION);
  aField_3->write(MED_DRIVER,filename_wr);
  {
    FIELD<double> aField_3_RD;
    aField_3_RD.setName(fieldname_nodeint_wr1);
    aField_3_RD.read(MED_DRIVER,filename_wr);
  }
  aField_3->setName("fieldname_nodeint_wr1");
  aField_3->write(MED_DRIVER,filename_wr, MED_EN::WRONLY);// overwrite filename_wr
  {
    FIELD<double> aField_3_RD;
    aField_3_RD.setName(fieldname_nodeint_wr1);
    CPPUNIT_ASSERT_THROW(aField_3_RD.read(MED_DRIVER,filename_wr),MEDEXCEPTION);
  }
  //Test writeAppend(int index) method
  //Create a vtk file
  MESH * aMesh_1 = new MESH(MED_DRIVER,filename22_rd, meshname);
  aMesh_1->write(VTK_DRIVER, filenamevtk_wr);
  //Create a field
  FIELD<int> * aField_4 =
    new FIELD<int>(MED_DRIVER,filename22_rd,fieldname_nodeint_rd,-1,-1,aMesh_1);
  //Add Driver to a field
  int IdDriver2 = aField_4->addDriver(VTK_DRIVER, filenamevtk_wr ,fieldname_nodeint_wr);
  //Trying call writeAppend() method with incorrect index
  CPPUNIT_ASSERT_THROW(aField_4->writeAppend(IdDriver2+1,fieldname_nodeint_wr),MEDEXCEPTION);

  CPPUNIT_ASSERT_NO_THROW(aField_4->writeAppend(IdDriver2, fieldname_nodeint_wr));

  //Test writeAppend(const GENDRIVER &) method
  aField_4->setName(fieldname_nodeint_wr1);
  {
    VTK_FIELD_DRIVER<int> aVtkFieldDriver(filenamevtk_wr, aField_4);
    CPPUNIT_ASSERT_NO_THROW(aField_4->writeAppend(aVtkFieldDriver));
  }

  //Delete objects
  aField_1->removeReference();
  aField_2->removeReference();
  aField_3->removeReference();
  aField_4->removeReference();
  aMesh->removeReference();
  aMesh_1->removeReference();
}

Here is the call graph for this function: