Back to index

salome-med  6.5.0
Public Member Functions | Private Attributes
ICoCo::MEDField Class Reference

#include <ICoCoMEDField.hxx>

Inheritance diagram for ICoCo::MEDField:
Inheritance graph
[legend]
Collaboration diagram for ICoCo::MEDField:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MEDField ()
 MEDField (ParaMEDMEM::MEDCouplingUMesh *mesh, ParaMEDMEM::MEDCouplingFieldDouble *field)
 Constructor directly attaching a MEDCouplingUMesh and a MEDCouplingFieldDouble the object does not take the control the objects pointed by mesh and field.
 MEDField (TrioField &)
virtual ~MEDField ()
ParaMEDMEM::MEDCouplingFieldDoublegetField () const
ParaMEDMEM::MEDCouplingUMeshgetMesh () const
void setName (const std::string &name)
const std::string & getName () const
const char * getCharName () const

Private Attributes

ParaMEDMEM::MEDCouplingUMesh_mesh
ParaMEDMEM::MEDCouplingFieldDouble_field

Detailed Description

Definition at line 33 of file ICoCoMEDField.hxx.


Constructor & Destructor Documentation

Definition at line 36 of file ICoCoMEDField.hxx.

:_mesh(0),_field(0) { }

Constructor directly attaching a MEDCouplingUMesh and a MEDCouplingFieldDouble the object does not take the control the objects pointed by mesh and field.

Definition at line 35 of file ICoCoMEDField.cxx.

                                                                                             : 
    _mesh(mesh),
    _field(field)
  {
    if(_mesh)
      _mesh->incrRef();
    if(_field)
      _field->incrRef();
  }

Here is the call graph for this function:

Definition at line 45 of file ICoCoMEDField.cxx.

  {
    _mesh = ParaMEDMEM::MEDCouplingUMesh::New();
    _mesh->setMeshDimension(triofield._space_dim);
    ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
    myCoords->alloc(triofield._nbnodes,triofield._space_dim);
    _mesh->setCoords(myCoords);
    myCoords->decrRef();
    double *ptr=myCoords->getPointer();
    std::copy(triofield._coords,triofield._coords+triofield._space_dim*triofield._nbnodes,ptr);
    _mesh->allocateCells(triofield._nb_elems);
    INTERP_KERNEL::NormalizedCellType elemtype;
    switch (triofield._mesh_dim)
      {
      case 2:
        switch (triofield._nodes_per_elem)
          {
          case 3:
            elemtype=INTERP_KERNEL::NORM_TRI3;
            break;
          case 4 : 
            elemtype=INTERP_KERNEL::NORM_QUAD4;
            break;
          default:
            throw INTERP_KERNEL::Exception("incompatible Trio field - wrong nb of nodes per elem");
          }
        break;
      case 3:
        switch (triofield._nodes_per_elem)
          {
          case 4:
            elemtype=INTERP_KERNEL::NORM_TETRA4;
            break;
          case 8 : 
            elemtype=INTERP_KERNEL::NORM_HEXA8;
            break;
          default:
            throw INTERP_KERNEL::Exception("incompatible Trio field - wrong nb of nodes per elem");
          }
        break;
      default:
        throw INTERP_KERNEL::Exception("incompatible Trio field - wrong mesh dimension");
      }
    //creating a connectivity table that complies to MED (1 indexing)
    //and passing it to _mesh
    int* conn=new int[triofield._nodes_per_elem];
    _mesh->setMeshDimension(triofield._mesh_dim);
    for (int i=0; i<triofield._nb_elems;i++)
      {
        for(int j=0;j<triofield._nodes_per_elem;j++)
          {
            conn[j]=(triofield._connectivity)[i*triofield._nodes_per_elem+j];
          }
        _mesh->insertNextCell(elemtype,triofield._nodes_per_elem,conn);
      }
    delete[] conn;
    
    _mesh->finishInsertingCells();
    
    //field on the sending end
    int nb_case=triofield.nb_values();
    if (triofield._type==0)
      {
        _field =  ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
      }
    else
      {
        _field =  ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::ONE_TIME ); 
      }
    _field->setMesh(_mesh);
    _field->setNature(ParaMEDMEM::ConservativeVolumic);
    ParaMEDMEM::DataArrayDouble *fieldArr=ParaMEDMEM::DataArrayDouble::New();
    fieldArr->alloc(_field->getNumberOfTuples(),triofield._nb_field_components);
    _field->setName(triofield.getName().c_str());
    std::string meshName("SupportOf_"); meshName+=_field->getName();
    _mesh->setName(meshName.c_str());
    _field->setTime(triofield._time1,0,triofield._itnumber);
    if (triofield._field!=0)
      {
        for (int i =0; i<nb_case; i++)
          for (int j=0; j<triofield._nb_field_components; j++)
            {
              fieldArr->setIJ(i,j,triofield._field[i*triofield._nb_field_components+j]);
            }
      }
    //field on the receiving end
    else
      {
        // the trio field points to the pointer inside the MED field
        triofield._field=const_cast<double*> (fieldArr->getPointer());
        for (int i=0; i<triofield._nb_field_components*nb_case;i++)
          triofield._field[i]=0.0;
      }
    _field->setArray(fieldArr);
    fieldArr->decrRef();
  }

Here is the call graph for this function:

Definition at line 142 of file ICoCoMEDField.cxx.

  {
    if(_field)
      _field->decrRef();
    if(_mesh)
      _mesh->decrRef();
  }

Member Function Documentation

const char * Field::getCharName ( ) const [inherited]

Definition at line 46 of file ICoCoField.cxx.

                                     {
  return _name->c_str();
}

Definition at line 40 of file ICoCoMEDField.hxx.

{ return _field; }

Here is the caller graph for this function:

Definition at line 41 of file ICoCoMEDField.hxx.

{ return _mesh; }
const string & Field::getName ( ) const [inherited]

Definition at line 42 of file ICoCoField.cxx.

                                   {
  return *_name;
}

Here is the caller graph for this function:

void Field::setName ( const std::string &  name) [inherited]

Definition at line 38 of file ICoCoField.cxx.

                                      {
  *_name=name;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 44 of file ICoCoMEDField.hxx.

Definition at line 43 of file ICoCoMEDField.hxx.


The documentation for this class was generated from the following files: