Back to index

salome-med  6.5.0
Functions
test_copie_field_.cxx File Reference
#include "MEDMEM_Exception.hxx"
#include "MEDMEM_Mesh.hxx"
#include "MEDMEM_Family.hxx"
#include "MEDMEM_Group.hxx"
#include "MEDMEM_MedMeshDriver.hxx"
#include "MEDMEM_MedFieldDriver.hxx"
#include "MEDMEM_Support.hxx"
#include "MEDMEM_Field.hxx"
#include "MEDMEM_define.hxx"
#include <string>
#include <math.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

static void affiche_field (FIELD_ *myField, const SUPPORT *mySupport)
int main (int argc, char **argv)

Function Documentation

static void affiche_field ( FIELD_ myField,
const SUPPORT *  mySupport 
) [static]

Definition at line 46 of file test_copie_field_.cxx.

{
  cout << "Field "<< myField->getName() << " : " <<myField->getDescription() <<  endl ;
  int NumberOfComponents = myField->getNumberOfComponents() ;
  cout << "- Nombre de composantes : "<< NumberOfComponents << endl ;
  for (int i=1; i<NumberOfComponents+1; i++)
    {
      cout << "  - composante "<<i<<" :"<<endl ;
      cout << "      - nom         : "<<myField->getComponentName(i)<< endl;
      cout << "      - description : "<<myField->getComponentDescription(i) << endl;
      cout << "      - units       : "<<myField->getMEDComponentUnit(i) << endl;
    }
  cout << "- iteration :" << endl ;
  cout << "    - numero : " << myField->getIterationNumber()<< endl  ;
  cout << "    - ordre  : " << myField->getOrderNumber()<< endl  ;
  cout << "    - temps  : " << myField->getTime()<< endl  ;

  cout << "- Type : " << myField->getValueType()<< endl;
  /*
    cout << "- Valeurs :"<<endl;
    int NumberOf = mySupport->getNumberOfElements(MED_ALL_ELEMENTS);

    for (int i=1; i<NumberOf+1; i++) 
    {
    double * value = myField->getValueI(MED_FULL_INTERLACE,i) ;
    for (int j=0; j<NumberOfComponents; j++)
    cout << value[j]<< " ";
    cout<<endl;
    }
  */
  cout << "- Adresse support : " << mySupport << endl;
}

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 80 of file test_copie_field_.cxx.

{
  if ((argc !=3) && (argc != 4))
    {
      cerr << "Usage : " << argv[0] 
           << " filename meshname fieldname" << endl << endl;
      exit(-1);
    }

  string filename = argv[1] ;
  string meshname = argv[2] ;

  MESH * myMesh= new MESH(MED_DRIVER,filename,meshname) ;

  // read field :

  if (argc != 4) exit(0) ;
  // else we have a field !

  string fieldname = argv[3];


  const SUPPORT * mySupport = myMesh->getSupportOnAll(MED_EN::MED_CELL);
  FIELD<double> * myField = new FIELD<double>() ;

  myField->setName(fieldname);
  myField->setSupport(mySupport);
  MED_FIELD_RDONLY_DRIVER<double> myFieldDriver(filename,myField) ;
  myFieldDriver.setFieldName(fieldname);
  myFieldDriver.open() ;

  try
    {
      myFieldDriver.read() ;
    }
  catch (...)
    {
      myField->setSupport(0);
      mySupport = myMesh->getSupportOnAll(MED_EN::MED_NODE);
      myField->setSupport(mySupport);
      try
        {
          myFieldDriver.read() ;
        }
      catch (...)
        {
          cout << "Field " << fieldname << " not found !!!" << endl ;
          exit (-1) ;
        }
    }

  myFieldDriver.close() ;

  FIELD_ * pt_field_ = myField;
  affiche_field(pt_field_, mySupport);
  FIELD_ * pt_field_2 = new FIELD_(* pt_field_);
  myField->removeReference();
  affiche_field(pt_field_2, pt_field_2->getSupport());

  pt_field_2->removeReference();
  myMesh->removeReference() ;

  return 0;
}

Here is the call graph for this function: