Back to index

salome-med  6.5.0
Functions
FIELD<T> constructors

The different field constructors correspond to the two main ways a field is used : More...

Functions

 MEDMEM::FIELD< T, INTERLACING_TAG >::FIELD (const SUPPORT *Support, const int NumberOfComponents) throw (MEDEXCEPTION)
 Constructor that allocates the value array with the dimensions provided by NumberOfComponents and the dimension of Support.

Detailed Description

The different field constructors correspond to the two main ways a field is used :

     

Function Documentation

template<class T , class INTERLACING_TAG >
MEDMEM::FIELD< T, INTERLACING_TAG >::FIELD ( const SUPPORT *  Support,
const int  NumberOfComponents 
) throw (MEDEXCEPTION)

Constructor that allocates the value array with the dimensions provided by NumberOfComponents and the dimension of Support.

The value array is allocated but not initialized. This constructor does not allow the creation of fields with Gauss points.

Parameters:
Supportsupport on which the field lies
NumberOfComponentsnumber of components of the variable stored. For instance, it will be 3 for a (vx,vy,vz) vector.
FIELD<double> field (support, 3);
int nbelem = support->getNumberOfElements(MED_ALL_ELEMENTS);
for (int i=1; i<=nbelem; i++)
   for (j=1; j<=3;j++)
       field->setValueIJ(i,j,0.0);

Definition at line 1113 of file MEDMEM_Field.hxx.

                                                                                    :
  FIELD_(Support, NumberOfComponents),_value(NULL)
{
  const char* LOC = "FIELD<T>::FIELD(const SUPPORT * Support, const int NumberOfComponents)";
  BEGIN_OF_MED(LOC);
  SCRUTE_MED(this);

  //INITIALISATION DE _valueType DS LE CONSTRUCTEUR DE FIELD_
  ASSERT_MED(FIELD_::_valueType == MED_EN::MED_UNDEFINED_TYPE)
    FIELD_::_valueType=SET_VALUE_TYPE<T>::_valueType;

  //INITIALISATION DE _interlacingType DS LE CONSTRUCTEUR DE FIELD_
  ASSERT_MED(FIELD_::_interlacingType == MED_EN::MED_UNDEFINED_INTERLACE)
    FIELD_::_interlacingType=SET_INTERLACING_TYPE<INTERLACING_TAG>::_interlacingType;

  try
    {
      // becarefull about the numbre of gauss point
      _numberOfValues = Support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
    }
#if defined(_DEBUG_) || defined(_DEBUG)
  catch (MEDEXCEPTION &ex)
#else
  catch (MEDEXCEPTION )
#endif
    {
      MESSAGE_MED("No value defined ! ("<<ex.what()<<")");
    }
  MESSAGE_MED("FIELD : constructeur : "<< _numberOfValues <<" et "<< NumberOfComponents);
  if ( _numberOfValues > 0 )
    {
      if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE )
        {
          const int * nbelgeo = Support->getNumberOfElements();
          vector<int> nbelgeoc( Support->getNumberOfTypes() + 1 );
          nbelgeoc[0] = 0;
          for ( int t = 1; t < (int)nbelgeoc.size(); ++t )
            nbelgeoc[t] = nbelgeoc[t-1] + nbelgeo[t-1];
          _value = new ArrayNoByType (_numberOfComponents,_numberOfValues,
                                      Support->getNumberOfTypes(), &nbelgeoc[0]);
        }
      else
        {
          _value = new ArrayNoGauss (_numberOfComponents,_numberOfValues);
        }
      _isRead = true ;
    }
  _mesh  = ( MESH* ) NULL;

  END_OF_MED(LOC);
}