Back to index

salome-med  6.5.0
Functions
Numerical operations on fields

This section groups together the different operators that enable the user to treat the FIELD objects as high-level numerical arrays, giving operators for numerical treatment (overloading of basic operators, algorithms, etc...) More...

Functions

FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::operator+ (const FIELD &m) const
 Overload addition operator.
FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::operator+= (const FIELD &m)
 Overloaded Operator += Operations are directly performed in the first field's array.
static FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::add (const FIELD &m, const FIELD &n)
 Addition of fields.
static FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::addDeep (const FIELD &m, const FIELD &n)
 Same as add method except that field check is deeper.
FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::operator- (const FIELD &m) const
 Overload substraction operator.
FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::operator- () const
FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::operator-= (const FIELD &m)
 Overloaded Operator -= Operations are directly performed in the first field's array.
void MEDMEM::FIELD< T, INTERLACING_TAG >::applyLin (T a, T b, int icomp)
 Apply to a given field component the linear function x -> ax+b.
static FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::sub (const FIELD &m, const FIELD &n)
 Substraction of fields.
static FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::subDeep (const FIELD &m, const FIELD &n)
 Same as sub method except that field check is deeper.
FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::operator* (const FIELD &m) const
 Overload multiplication operator.
FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::operator*= (const FIELD &m)
 Overloaded Operator *= Operations are directly performed in the first field's array.
static FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::mul (const FIELD &m, const FIELD &n)
 Multiplication of fields.
static FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::mulDeep (const FIELD &m, const FIELD &n)
 Same as mul method except that field check is deeper.
FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::operator/ (const FIELD &m) const
 Overload division operator.
FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::operator/= (const FIELD &m)
 Overloaded Operator /= Operations are directly performed in the first field's array.
static FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::div (const FIELD &m, const FIELD &n)
 Division of fields.
static FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::divDeep (const FIELD &m, const FIELD &n)
 Same as div method except that field check is deeper.
double MEDMEM::FIELD< T, INTERLACING_TAG >::normMax () const throw (MEDEXCEPTION)
 Return maximum of all absolute values contained in the array (all elements and all components are browsed).
double MEDMEM::FIELD< T, INTERLACING_TAG >::norm2 () const throw (MEDEXCEPTION)
 Return Euclidian norm for all elements of the array.
void MEDMEM::FIELD< T, INTERLACING_TAG >::getMinMax (T &vmin, T &vmax) throw (MEDEXCEPTION)
 Return Extrema of field.
vector< int > MEDMEM::FIELD< T, INTERLACING_TAG >::getHistogram (int &nbint) throw (MEDEXCEPTION)
 Return Histogram of field.
FIELD< double > * MEDMEM::FIELD< T, INTERLACING_TAG >::buildGradient () const throw (MEDEXCEPTION)
 Return vectorial gradient field.
FIELD< double > * MEDMEM::FIELD< T, INTERLACING_TAG >::buildNorm2Field () const throw (MEDEXCEPTION)
 Return scalar norm2 field.
template<T T_function>
void MEDMEM::FIELD< T, INTERLACING_TAG >::applyFunc ()
 Apply to each (scalar) field component the template parameter T_function, which is a pointer to function.
static T MEDMEM::FIELD< T, INTERLACING_TAG >::pow (T x)
void MEDMEM::FIELD< T, INTERLACING_TAG >::applyPow (T scalar)
 Apply to each (scalar) field component the math function pow.
void MEDMEM::FIELD< T, INTERLACING_TAG >::applyLin (T a, T b)
 Apply to each (scalar) field component the linear function x -> ax+b.
static FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::scalarProduct (const FIELD &m, const FIELD &n, bool deepCheck=false)
 Return a pointer to a new field that holds the scalar product.
double MEDMEM::FIELD< T, INTERLACING_TAG >::normL2 (int component, const FIELD< double, FullInterlace > *p_field_volume=NULL) const
 Return L2 Norm of the field's component.
double MEDMEM::FIELD< T, INTERLACING_TAG >::normL2 (const FIELD< double, FullInterlace > *p_field_volume=NULL) const
 Return L2 Norm of the field.
double MEDMEM::FIELD< T, INTERLACING_TAG >::normL1 (int component, const FIELD< double, FullInterlace > *p_field_volume=NULL) const
 Return L1 Norm of the field's component.
double MEDMEM::FIELD< T, INTERLACING_TAG >::normL1 (const FIELD< double, FullInterlace > *p_field_volume=NULL) const
 Return L1 Norm of the field.
double MEDMEM::FIELD< T, INTERLACING_TAG >::integral (const SUPPORT *subSupport=NULL) const throw (MEDEXCEPTION)
 Return integral of the field.
FIELDMEDMEM::FIELD< T, INTERLACING_TAG >::extract (const SUPPORT *subSupport) const throw (MEDEXCEPTION)
 Return a new field (to deallocate with delete) lying on subSupport that is included by this->_support with corresponding values extracting from this->_value.

Detailed Description

This section groups together the different operators that enable the user to treat the FIELD objects as high-level numerical arrays, giving operators for numerical treatment (overloading of basic operators, algorithms, etc...)


Function Documentation

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::add ( const FIELD< T, INTERLACING_TAG > &  m,
const FIELD< T, INTERLACING_TAG > &  n 
) [static]

Addition of fields.

Static member function. The function return a pointer to a new created field that holds the addition. Data members are checked for compatibility and initialized. The user is in charge of memory deallocation.

Definition at line 1331 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::add(const FIELD & m, const FIELD& n)";
  BEGIN_OF_MED(LOC);
    FIELD_::_checkFieldCompatibility(m, n); // may throw exception

    // Creation of a new field
    FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
                                                                      m.getNumberOfComponents());
    result->_operationInitialize(m,n,"+"); // perform Atribute's initialization
    result->_add_in_place(m,n); // perform addition

  END_OF_MED(LOC);
    return result;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::addDeep ( const FIELD< T, INTERLACING_TAG > &  m,
const FIELD< T, INTERLACING_TAG > &  n 
) [static]

Same as add method except that field check is deeper.

Definition at line 1350 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::addDeep(const FIELD & m, const FIELD& n)";
  BEGIN_OF_MED(LOC);
    FIELD_::_deepCheckFieldCompatibility(m, n); // may throw exception

    // Creation of a new field
    FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
                                                                      m.getNumberOfComponents());
    result->_operationInitialize(m,n,"+"); // perform Atribute's initialization
    result->_add_in_place(m,n); // perform addition

  END_OF_MED(LOC);
    return result;
}

Here is the call graph for this function:

template<class T , class INTERLACIN_TAG >
template<T T_function>
void MEDMEM::FIELD< T, INTERLACIN_TAG >::applyFunc ( )

Apply to each (scalar) field component the template parameter T_function, which is a pointer to function.

Since the pointer is known at compile time, the function is inlined into the inner loop! calculation is done "in place". Use examples :

 myField.applyFunc<std::sqrt>();  // apply sqare root function 
 myField.applyFunc<myFunction>(); // apply your own created function 

Definition at line 2247 of file MEDMEM_Field.hxx.

{
  // get a non const pointer to the inside array of values and perform operation
    T * value=const_cast<T *> (getValue());
    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array

    if (size>0) // for a negative size, there is nothing to do
    {
        const T* lastvalue=value+size; // pointer to the end of value
        for(;value!=lastvalue; ++value) // apply linear transformation
            *value = T_function(*value);
    }
}

Here is the caller graph for this function:

template<class T, class INTERLACIN_TAG >
void MEDMEM::FIELD< T, INTERLACIN_TAG >::applyLin ( a,
b,
int  icomp 
)

Apply to a given field component the linear function x -> ax+b.

calculation is done "in place".

Definition at line 1463 of file MEDMEM_Field.hxx.

{
    // get a non const pointer to the inside array of values and perform operation in place
    T * value=const_cast<T *> (getValue());
         
    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array

    if (size>0) // for a negative size, there is nothing to do
    {
                        value+=icomp-1;
                        const T* lastvalue=value+size; // pointer to the end of value
 
                        for(;value!=lastvalue; value+=getNumberOfComponents()) // apply linear transformation
                                *value = a*(*value)+b;
    }
}

Here is the caller graph for this function:

template<class T, class INTERLACIN_TAG >
void MEDMEM::FIELD< T, INTERLACIN_TAG >::applyLin ( a,
b 
)

Apply to each (scalar) field component the linear function x -> ax+b.

calculation is done "in place".

Definition at line 2282 of file MEDMEM_Field.hxx.

{
    // get a non const pointer to the inside array of values and perform operation in place
    T * value=const_cast<T *> (getValue());
    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array

    if (size>0) // for a negative size, there is nothing to do
    {
        const T* lastvalue=value+size; // pointer to the end of value
        for(;value!=lastvalue; ++value) // apply linear transformation
            *value = a*(*value)+b;
    }
}
template<class T, class INTERLACIN_TAG >
void MEDMEM::FIELD< T, INTERLACIN_TAG >::applyPow ( scalar)

Apply to each (scalar) field component the math function pow.

calculation is done "in place". Use examples :

 myField.applyFunc<std::sqrt>();  // apply sqare root function 
 myField.applyFunc<myFunction>(); // apply your own created function 

Definition at line 2273 of file MEDMEM_Field.hxx.

{
  FIELD<T, INTERLACIN_TAG>::_scalarForPow=scalar;
  applyFunc<FIELD<T, INTERLACIN_TAG>::pow>();
}

Here is the caller graph for this function:

template<class T , class INTERLACIN_TAG >
FIELD< double, FullInterlace > * MEDMEM::FIELD< T, INTERLACIN_TAG >::buildGradient ( ) const throw (MEDEXCEPTION)

Return vectorial gradient field.

Definition at line 2022 of file MEDMEM_Field.hxx.

{
  const char * LOC = "FIELD<T, INTERLACIN_TAG>::buildGradient() : ";
  BEGIN_OF_MED(LOC);

  // space dimension of input mesh
  int spaceDim = getSupport()->getMesh()->getSpaceDimension();
  double *x = new double[spaceDim];

  FIELD<double, FullInterlace>* Gradient =
    new FIELD<double, FullInterlace>(getSupport(),spaceDim);

  string name("gradient of ");
  name += getName();
  Gradient->setName(name);
  string descr("gradient of ");
  descr += getDescription();
  Gradient->setDescription(descr);

  if( _numberOfComponents > 1 ){
    delete Gradient;
    delete [] x;
    throw MEDEXCEPTION("gradient calculation only on scalar field");
  }

  for(int i=1;i<=spaceDim;i++){
    string nameC("gradient of ");
    nameC += getName();
    Gradient->setComponentName(i,nameC);
    Gradient->setComponentDescription(i,"gradient");
    string MEDComponentUnit = getMEDComponentUnit(1)+getSupport()->getMesh()->getCoordinatesUnits()[i-1];
    Gradient->setMEDComponentUnit(i,MEDComponentUnit);
  }

  Gradient->setIterationNumber(getIterationNumber());
  Gradient->setOrderNumber(getOrderNumber());
  Gradient->setTime(getTime());

  // typ of entity on what is field
  MED_EN::medEntityMesh typ = getSupport()->getEntity();

  const int *C;
  const int *iC;  
  const int *revC;
  const int *indC;
  const double *coord;
  int NumberOf;

  switch (typ) {
  case MED_CELL:
  case MED_FACE:
  case MED_EDGE:
    {
      // read connectivity array to have the list of nodes contained by an element
      C = getSupport()->getMesh()->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,typ,MED_ALL_ELEMENTS);
      iC = getSupport()->getMesh()->getConnectivityIndex(MED_NODAL,typ);
      // calculate reverse connectivity to have the list of elements which contains node i
      revC = getSupport()->getMesh()->getReverseConnectivity(MED_NODAL,typ);
      indC = getSupport()->getMesh()->getReverseConnectivityIndex(MED_NODAL,typ);
      // coordinates of each node
      coord = getSupport()->getMesh()->getCoordinates(MED_FULL_INTERLACE);
      // number of elements
      NumberOf = getSupport()->getNumberOfElements(MED_ALL_ELEMENTS);
      // barycenter field of elements
      FIELD<double, FullInterlace>* barycenter = getSupport()->getMesh()->getBarycenter(getSupport());

      // calculate gradient vector for each element i
      for (int i = 1; i < NumberOf + 1; i++) {

        // listElements contains elements which contains a node of element i
        set <int> listElements;
        set <int>::iterator elemIt;
        listElements.clear();

        // for each node j of element i
        for (int ij = iC[i-1]; ij < iC[i]; ij++) {
          int j = C[ij-1];
          for (int k = indC[j-1]; k < indC[j]; k++) {
            // c element contains node j
            int c = revC[k-1];
            // we put the elements in set
            if (c != i)
              listElements.insert(c);
          }
        }
        // coordinates of barycentre of element i in space of dimension spaceDim
        for (int j = 0; j < spaceDim; j++)
          x[j] = barycenter->getValueIJ(i,j+1);

        for (int j = 0; j < spaceDim; j++) {
          // value of field of element i
          double val = getValueIJ(i,1);
          double grad = 0.;
          // calculate gradient for each neighbor element
          for (elemIt = listElements.begin(); elemIt != listElements.end(); elemIt++) {
            int elem = *elemIt;
            double d2 = 0.;
            for (int l = 0; l < spaceDim; l++) {
              // coordinate of barycenter of element elem
              double xx = barycenter->getValueIJ(elem, l+1);
              d2 += (x[l]-xx) * (x[l]-xx);
            }
            grad += (barycenter->getValueIJ(elem,j+1)-x[j])*(getValueIJ(elem,1)-val)/sqrt(d2);
          }
          if (listElements.size() != 0) grad /= listElements.size();
          Gradient->setValueIJ(i,j+1,grad);
        }
      }
      delete barycenter;
    }
    break;
  case MED_NODE:
    // read connectivity array to have the list of nodes contained by an element
    C = getSupport()->getMesh()->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_CELL,MED_ALL_ELEMENTS);
    iC = getSupport()->getMesh()->getConnectivityIndex(MED_NODAL,MED_CELL);
    // calculate reverse connectivity to have the list of elements which contains node i
    revC=getSupport()->getMesh()->getReverseConnectivity(MED_NODAL,MED_CELL);
    indC=getSupport()->getMesh()->getReverseConnectivityIndex(MED_NODAL,MED_CELL);
    // coordinates of each node
    coord = getSupport()->getMesh()->getCoordinates(MED_FULL_INTERLACE);

    // calculate gradient for each node
    NumberOf = getSupport()->getNumberOfElements(MED_ALL_ELEMENTS);
    for (int i=1; i<NumberOf+1; i++){
      // listNodes contains nodes neigbor of node i 
      set <int> listNodes;
      set <int>::iterator nodeIt ;
      listNodes.clear();
      for(int j=indC[i-1];j<indC[i];j++){
        // c element contains node i
        int c=revC[j-1];
        // we put the nodes of c element in set
        for(int k=iC[c-1];k<iC[c];k++)
          if(C[k-1] != i)
            listNodes.insert(C[k-1]);
      }
      // coordinates of node i in space of dimension spaceDim
      for(int j=0;j<spaceDim;j++)
        x[j] = coord[(i-1)*spaceDim+j];
      
      for(int j=0;j<spaceDim;j++){
        // value of field
        double val = getValueIJ(i,1);
        double grad = 0.;
        // calculate gradient for each neighbor node
        for(nodeIt=listNodes.begin();nodeIt!=listNodes.end();nodeIt++){
          int node = *nodeIt;
          double d2 = 0.;
          for(int l=0;l<spaceDim;l++){
            double xx = coord[(node-1)*spaceDim+l];
            d2 += (x[l]-xx) * (x[l]-xx);
          }
          grad += (coord[(node-1)*spaceDim+j]-x[j])*(getValueIJ(node,1)-val)/sqrt(d2);
        }
        if(listNodes.size() != 0) grad /= listNodes.size();
        Gradient->setValueIJ(i,j+1,grad);
      }
    }
    break;
  case MED_ALL_ENTITIES:
    delete [] x;
    delete Gradient;
    throw MEDEXCEPTION("gradient calculation not yet implemented on all elements");
    break;
  }

  delete [] x;

  END_OF_MED(LOC);
  return Gradient;
}

Here is the call graph for this function:

template<class T , class INTERLACIN_TAG >
FIELD< double, FullInterlace > * MEDMEM::FIELD< T, INTERLACIN_TAG >::buildNorm2Field ( ) const throw (MEDEXCEPTION)

Return scalar norm2 field.

Definition at line 2197 of file MEDMEM_Field.hxx.

{
  const char * LOC = "FIELD<T, INTERLACIN_TAG>::buildNorm2Field() : ";
  BEGIN_OF_MED(LOC);

  FIELD<double, FullInterlace>* Norm2Field =
    new FIELD<double, FullInterlace>(getSupport(),1);

  string name("norm2 of ");
  name += getName();
  Norm2Field->setName(name);
  string descr("norm2 of ");
  descr += getDescription();
  Norm2Field->setDescription(descr);

  string nameC("norm2 of ");
  nameC += getName();
  Norm2Field->setComponentName(1,nameC);
  Norm2Field->setComponentDescription(1,"norm2");
  string MEDComponentUnit = getMEDComponentUnit(1);
  Norm2Field->setMEDComponentUnit(1,MEDComponentUnit);

  Norm2Field->setIterationNumber(getIterationNumber());
  Norm2Field->setOrderNumber(getOrderNumber());
  Norm2Field->setTime(getTime());

  // calculate nom2 for each element
  int NumberOf = getSupport()->getNumberOfElements(MED_ALL_ELEMENTS);
  for (int i=1; i<NumberOf+1; i++){
    double norm2 = 0.;
    for(int j=1;j<=getNumberOfComponents();j++)
      norm2 += getValueIJ(i,j)*getValueIJ(i,j);
    Norm2Field->setValueIJ(i,1,sqrt(norm2));
  }

  END_OF_MED(LOC);
  return Norm2Field;

}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::div ( const FIELD< T, INTERLACING_TAG > &  m,
const FIELD< T, INTERLACING_TAG > &  n 
) [static]

Division of fields.

Static member function. The function return a pointer to a new created field that holds the division. Data members are checked for compatibility and initialized. The user is in charge of memory deallocation.

Definition at line 1701 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::div(const FIELD & m, const FIELD& n)";
  BEGIN_OF_MED(LOC);
    FIELD_::_checkFieldCompatibility(m, n, false); // may throw exception

    // Creation of a new field
    FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
                                                                      m.getNumberOfComponents());
    try
      {
        result->_operationInitialize(m,n,"/"); // perform Atribute's initialization
        result->_div_in_place(m,n); // perform division
      }
    catch(MEDEXCEPTION& e)
      {
        result->removeReference();
        throw e;
      }
  END_OF_MED(LOC);
    return result;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::divDeep ( const FIELD< T, INTERLACING_TAG > &  m,
const FIELD< T, INTERLACING_TAG > &  n 
) [static]

Same as div method except that field check is deeper.

Definition at line 1727 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::divDeep(const FIELD & m, const FIELD& n)";
  BEGIN_OF_MED(LOC);
  FIELD_::_deepCheckFieldCompatibility(m, n, false); // may throw exception

  // Creation of a new field
  FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
                                                                    m.getNumberOfComponents());
  try
    {
      result->_operationInitialize(m,n,"/"); // perform Atribute's initialization
      result->_div_in_place(m,n); // perform division
    }
  catch(MEDEXCEPTION& e)
      {
        result->removeReference();
        throw e;
      }
  END_OF_MED(LOC);
  return result;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::extract ( const SUPPORT *  subSupport) const throw (MEDEXCEPTION)

Return a new field (to deallocate with delete) lying on subSupport that is included by this->_support with corresponding values extracting from this->_value.

Definition at line 2803 of file MEDMEM_Field.hxx.

{
  if(!subSupport->belongsTo(*_support))
    throw MEDEXCEPTION("FIELD<T>::extract : subSupport not included in this->_support !");
  if(_support->isOnAllElements() && subSupport->isOnAllElements())
    return new FIELD<T, INTERLACING_TAG>(*this);

  FIELD<T, INTERLACING_TAG> *ret = new FIELD<T, INTERLACING_TAG>(subSupport,
                                                                 _numberOfComponents);

  if(!ret->_value)
    throw MEDEXCEPTION("FIELD<T>::extract : invalid support detected !");

  T* valuesToSet=(T*)ret->getValue();

  int nbOfEltsSub=subSupport->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
  const int *eltsSub=subSupport->getNumber(MED_EN::MED_ALL_ELEMENTS);
  T* tempVals=new T[_numberOfComponents];
  for(int i=0;i<nbOfEltsSub;i++)
    {
      if(!getValueOnElement(eltsSub[i],tempVals))
        throw MEDEXCEPTION("Problem in belongsTo function !!!");
      for(int j=0;j<_numberOfComponents;j++)
        valuesToSet[i*_numberOfComponents+j]=tempVals[j];
    }
  delete [] tempVals;

  ret->copyGlobalInfo(*this);
  return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T , class INTERLACIN_TAG >
vector< int > MEDMEM::FIELD< T, INTERLACIN_TAG >::getHistogram ( int &  nbint) throw (MEDEXCEPTION)

Return Histogram of field.

Definition at line 1988 of file MEDMEM_Field.hxx.

{
  const T* value=getValue(); // get pointer to the values
  const int size=getNumberOfValues()*getNumberOfComponents();
  const T* lastvalue=value+size; // point just after last value

  if (size <= 0){ // Size of array has to be strictly positive

    string diagnosis;
    diagnosis="FIELD<T,INTERLACIN_TAG>::getHistogram() : cannot compute the histogram of "+getName()+
      " : it size is non positive!";
    throw MEDEXCEPTION(diagnosis.c_str());
  }

  vector<int> Histogram(nbint) ;
  T vmin,vmax;
  int j;

  for( j=0 ; j!=nbint ; j++) Histogram[j]=0 ;
    
  getMinMax(vmin,vmax);
  for( ; value!=lastvalue ; ++value){
    if(*value==vmax) j = nbint-1;
    else j = (int)(((double)nbint * (*value-vmin))/(vmax-vmin));
    Histogram[j]+=1 ;
  }

  return Histogram ;

}
template<class T, class INTERLACIN_TAG >
void MEDMEM::FIELD< T, INTERLACIN_TAG >::getMinMax ( T &  vmin,
T &  vmax 
) throw (MEDEXCEPTION)

Return Extrema of field.

Definition at line 1951 of file MEDMEM_Field.hxx.

{
  const T* value=getValue(); // get pointer to the values
  const int size=getNumberOfValues()*getNumberOfComponents();
  const T* lastvalue=value+size; // point just after last value
    
  if (size <= 0){ // Size of array has to be strictly positive
      
    string diagnosis;
    diagnosis="FIELD<T,INTERLACIN_TAG>::getMinMax() : cannot compute the extremums of "+getName()+
      " : its size is non positive!";
    throw MEDEXCEPTION(diagnosis.c_str());
  }
    
  if (!_isMinMax){
    vmax=MinMax<T>::getMin(); // init a max value
    vmin=MinMax<T>::getMax(); // init a min value
      
    for( ; value!=lastvalue ; ++value){
      if ( vmin > *value )
        vmin=*value;
      if ( vmax < *value )
        vmax=*value;
    }
    _isMinMax=true;
    _vmin=vmin;
    _vmax=vmax;
  }
  else{
    vmin = _vmin;
    vmax = _vmax;
  }

}
template<class T , class INTERLACING_TAG >
double MEDMEM::FIELD< T, INTERLACING_TAG >::integral ( const SUPPORT *  subSupport = NULL) const throw (MEDEXCEPTION)

Return integral of the field.

Parameters:
subSupport- optional part of a field to consider.
Return values:
double- value of integral

Definition at line 2653 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<>::integral(subSupport): ";

  double integrale = 0;

  if (!subSupport ) subSupport = _support;

  // check feasibility
  if ( getGaussPresence() )
    throw MEDEXCEPTION(STRING(LOC)<<"Gauss numbers greater than one are not yet implemented!");
  if ( subSupport->getEntity() != _support->getEntity())
    throw MEDEXCEPTION(STRING(LOC)<<"Different support entity of this field and subSupport");
  if ( subSupport->getEntity() == MED_EN::MED_NODE )
    throw MEDEXCEPTION(STRING(LOC)<<"Integral of nodal field not yet supported");

  // analyze support
  const int nbElems = subSupport->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
  const bool subOnAll = ( subSupport->isOnAllElements() );
  const bool  myOnAll = ( _support->isOnAllElements() );
  const int* subNums = !subOnAll ? subSupport->getNumber(MED_EN::MED_ALL_ELEMENTS) : 0;
  const int*   myNums = !myOnAll ? _support->getNumber(MED_EN::MED_ALL_ELEMENTS) : 0;
  if ( !subOnAll && !subNums )
    throw MEDEXCEPTION(STRING(LOC)<<"Invalid support: no element numbers");
  if ( !myOnAll && !myNums )
    throw MEDEXCEPTION(STRING(LOC)<<"Invalid field support: no element numbers");
  if ( subOnAll && !myOnAll )
    return integral(NULL);

  // get size of elements
  const FIELD<double, FullInterlace> * cellSize=_getFieldSize(subSupport);
  const double* size = cellSize->getValue();
  const double* lastSize = size + nbElems; // pointing just after the end of size

  const T* value = getValue();

  // calculate integrale
  if ( (subOnAll && _support->isOnAllElements()) || subSupport == _support )
    {
      const double* p_vol;
      if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE )
        {
          for (int j=1; j<=getNumberOfComponents(); ++j)
            for ( p_vol=size; p_vol != lastSize; ++value ,++p_vol)
              integrale += std::abs( *value * *p_vol );
        }
      else if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE )
        {
          typename ArrayNoByType::InterlacingPolicy* indexer =
            dynamic_cast< typename ArrayNoByType::InterlacingPolicy * > ( getArrayNoGauss() );
          for (int i, j=1; j<=getNumberOfComponents(); j++)
            for (i = 1, p_vol=size; p_vol!=lastSize; i++, ++p_vol )
              integrale += std::abs( value[indexer->getIndex(i,j)] * *p_vol );
        }
      else  // FULL_INTERLACE
        {
          for ( p_vol=size; p_vol != lastSize; ++p_vol)
            for (int j=0; j<getNumberOfComponents(); ++j, ++value)
              integrale += std::abs( *value * *p_vol );
        }
    }
  else
    {
      // find index for each element of subSupport
      PointerOf<int> index;
      if ( _support->isOnAllElements() )
        {
          index.set( subNums );
        }
      else // find common of two partial supports
        {
          // hope that numbers are in increasing order
          index.set( nbElems );
          for (int ii = 0; ii < nbElems; ii++)
            index[ii] = 0;
          bool allNumsFound = true;
          int i = 0, iSub = 0;
          for ( ; iSub < nbElems; ++iSub )
            {
              while ( i < getNumberOfValues() && subNums[iSub] > myNums[i] )
                ++i;
              if (i == getNumberOfValues() /*subNums[iSub] > myNums[i]*/) // no more myNums
                {
                  index[iSub] = 0; // no such number in myNums
                  break;
                }
              else if ( subNums[iSub] == myNums[i] ) // elem number found
                index[iSub] = ++i; // -- index counts from 1
              else // subNums[iSub] < myNums[i]
                allNumsFound = (index[iSub] = 0); // no such number in myNums
            }
          if ( iSub != nbElems || !allNumsFound )
            {
              // check if numbers are in increasing order
              bool increasingOrder = true;
              for ( iSub = 1; iSub < nbElems && increasingOrder; ++iSub )
                increasingOrder = ( subNums[iSub-1] < subNums[iSub] );
              for ( i = 1; i < getNumberOfValues() && increasingOrder; ++i )
                increasingOrder = ( myNums[i-1] < myNums[i] );

              if ( !increasingOrder )
                for ( iSub = 0; iSub < nbElems; ++iSub )
                  try
                    {
                      index[iSub] = _support->getValIndFromGlobalNumber( subNums[iSub] );
                    }
                  catch (MEDEXCEPTION)
                    {
                      index[iSub] = 0;
                    }
            }
        }

      // calculation
      if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE )
        {
          for (int j=0; j<getNumberOfComponents(); ++j)
            {
              value = getValue() + j * getNumberOfValues();
              for ( int i = 0; i < nbElems; ++i )
                if ( index[i] )
                  integrale += std::abs( value[ index[i]-1 ] * size[i] );
            }
        }
      else if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE )
        {
          typename ArrayNoByType::InterlacingPolicy* indexer =
            dynamic_cast< typename ArrayNoByType::InterlacingPolicy * > ( getArrayNoGauss() );
          for (int j=1; j<=getNumberOfComponents(); j++)
            for ( int i = 0; i < nbElems; ++i )
              if ( index[i] )
                integrale += std::abs( value[indexer->getIndex(index[i],j)] * size[i] );
        }
      else  // FULL_INTERLACE
        {
          const int dim = getNumberOfComponents();
          for ( int i = 0; i < nbElems; ++i )
            if ( index[i] )
              for (int j=0; j<dim; ++j)
                integrale += std::abs( value[ dim*(index[i]-1) + j] * size[i] );
        }
    }
  cellSize->removeReference();
  return integrale;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::mul ( const FIELD< T, INTERLACING_TAG > &  m,
const FIELD< T, INTERLACING_TAG > &  n 
) [static]

Multiplication of fields.

Static member function. The function return a pointer to a new created field that holds the multiplication. Data members are checked for compatibility and initialized. The user is in charge of memory deallocation.

Definition at line 1589 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::mul(const FIELD & m, const FIELD& n)";
  BEGIN_OF_MED(LOC);
    FIELD_::_checkFieldCompatibility(m, n, false); // may throw exception

    // Creation of a new field
    FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
                                                                      m.getNumberOfComponents());
    result->_operationInitialize(m,n,"*"); // perform Atribute's initialization
    result->_mul_in_place(m,n); // perform multiplication

  END_OF_MED(LOC);
    return result;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::mulDeep ( const FIELD< T, INTERLACING_TAG > &  m,
const FIELD< T, INTERLACING_TAG > &  n 
) [static]

Same as mul method except that field check is deeper.

Definition at line 1608 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::mulDeep(const FIELD & m, const FIELD& n)";
  BEGIN_OF_MED(LOC);
    FIELD_::_deepCheckFieldCompatibility(m, n, false); // may throw exception

    // Creation of a new field
    FIELD<T, INTERLACING_TAG>* result = new FIELD<T,INTERLACING_TAG>(m.getSupport(),
                                                                     m.getNumberOfComponents());
    result->_operationInitialize(m,n,"*"); // perform Atribute's initialization
    result->_mul_in_place(m,n); // perform multiplication

  END_OF_MED(LOC);
    return result;
}

Here is the call graph for this function:

template<class T , class INTERLACIN_TAG >
double MEDMEM::FIELD< T, INTERLACIN_TAG >::norm2 ( ) const throw (MEDEXCEPTION)

Return Euclidian norm for all elements of the array.

Definition at line 1926 of file MEDMEM_Field.hxx.

{
    const T* value=this->getValue(); // get const pointer to the values
    const int size=getNumberOfValues()*getNumberOfComponents(); // get size of array
    if (size <= 0) // Size of array has to be strictly positive
    {
        string diagnosis;
        diagnosis="FIELD<T,INTERLACIN_TAG>::norm2() : cannot compute the norm of "+getName()+
            " : it size is non positive!";
        throw MEDEXCEPTION(diagnosis.c_str());
    }
    const T* lastvalue=value+size; // point just after last value

    T result((T)0); // init
    for( ; value!=lastvalue ; ++value)
        result += (*value) * (*value);

    return std::sqrt(double(result));
}

Here is the caller graph for this function:

template<class T , class INTERLACING_TAG >
double MEDMEM::FIELD< T, INTERLACING_TAG >::normL1 ( int  component,
const FIELD< double, FullInterlace > *  p_field_volume = NULL 
) const

Return L1 Norm of the field's component.

If the optional p_field_volume argument is furnished, the volume is not re-calculated.

Definition at line 2543 of file MEDMEM_Field.hxx.

{
    _checkNormCompatibility(p_field_volume); // may throw exception
    if ( component<1 || component>getNumberOfComponents() )
        throw MEDEXCEPTION(STRING("FIELD<T,INTERLACING_TAG>::normL1() : The component argument should be between 1 and the number of components"));

    const FIELD<double,FullInterlace> * p_field_size=p_field_volume;
    if(!p_field_volume) // if the user don't supply the volume
      p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'impl√√҆mentation dans mesh]
    else
      p_field_size->addReference();
    // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size
    const double* vol = p_field_size->getValue();

    double integrale=0.0;
    double totVol=0.0;

    if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) {
      const T* value = getValue();
      const T* lastvalue = value + getNumberOfValues(); // pointing just after the end of column
      for (; value!=lastvalue ; ++value ,++vol) {
        integrale += std::abs( *value * *vol );
        totVol+=std::abs(*vol);
      }
    }
    else if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE ) {
      ArrayNoByType* anArray = dynamic_cast< ArrayNoByType * > ( getArrayNoGauss() );
      for (int i=1; i <= anArray->getNbElem() ; i++, ++vol ) {
        integrale += std::abs( anArray->getIJ(i,component) * (*vol));
        totVol+=std::abs(*vol);
      }
    }
    else { // FULL_INTERLACE
      ArrayFull* anArray = dynamic_cast< ArrayFull * > ( getArrayNoGauss() );
      for (int i=1; i <= anArray->getNbElem() ; i++, ++vol ) {
        integrale += std::abs( anArray->getIJ(i,component) * *vol);
        totVol+=std::abs(*vol);
      }
    }
    
    if(p_field_size)
      p_field_size->removeReference(); // delete temporary volume field
    if( totVol <= 0)
        throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!"));
    return integrale/totVol;
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T , class INTERLACING_TAG >
double MEDMEM::FIELD< T, INTERLACING_TAG >::normL1 ( const FIELD< double, FullInterlace > *  p_field_volume = NULL) const

Return L1 Norm of the field.

Cannot be applied to a field with a support on nodes. If the optional p_field_volume argument is furnished, the volume is not re-calculated.

Definition at line 2596 of file MEDMEM_Field.hxx.

{
  _checkNormCompatibility(p_field_volume); // may throw exception
  const FIELD<double, FullInterlace> * p_field_size=p_field_volume;
  if(!p_field_volume) // if the user don't supply the volume
    p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'impl√¬©mentation dans mesh]
  else
    p_field_size->addReference();
  // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size
  const double* vol = p_field_size->getValue();
  const double* lastvol = vol+getNumberOfValues(); // pointing just after the end of vol

  double integrale=0.0;
  double totVol=0.0;
  const double* p_vol=vol;
  for (p_vol=vol; p_vol!=lastvol ; ++p_vol) // calculate total volume
    totVol+=std::abs(*p_vol);

  if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) {
    const T* value = getValue();
    for (int i=1; i<=getNumberOfComponents(); ++i) { // compute integral on all components
      for (p_vol=vol; p_vol!=lastvol ; ++value ,++p_vol) {
        integrale += std::abs( *value * *p_vol );
      }
    }
  }
  else if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE ) {
    ArrayNoByType* anArray = dynamic_cast< ArrayNoByType * > ( getArrayNoGauss() );
    for (int j=1; j<=anArray->getDim(); j++) {
      int i = 1;
      for (p_vol=vol; i<=anArray->getNbElem() || p_vol!=lastvol; i++, ++p_vol ) {
        integrale += std::abs( anArray->getIJ(i,j) * *p_vol );
      }
    }
  }
  else { // FULL_INTERLACE
    ArrayFull* anArray = dynamic_cast< ArrayFull * > ( getArrayNoGauss() );
    for (int j=1; j<=anArray->getDim(); j++) {
      int i = 1;
      for (p_vol=vol; i<=anArray->getNbElem() || p_vol!=lastvol; i++, ++p_vol ) {
        integrale += std::abs( anArray->getIJ(i,j) * *p_vol );
      }
    }
  }
  if(p_field_size)
    p_field_size->removeReference();
  if( totVol <= 0)
    throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!"));
  return integrale/totVol;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
double MEDMEM::FIELD< T, INTERLACING_TAG >::normL2 ( int  component,
const FIELD< double, FullInterlace > *  p_field_volume = NULL 
) const

Return L2 Norm of the field's component.

Cannot be applied to a field with a support on nodes. If the optional p_field_volume argument is furnished, the volume is not re-calculated. For the nodal field, p_field_volume must be for all cells even if the field is partial.

Definition at line 2358 of file MEDMEM_Field.hxx.

{
    _checkNormCompatibility(p_field_volume, /*nodalAllowed=*/true); // may throw exception
    if ( component<1 || component>getNumberOfComponents() )
        throw MEDEXCEPTION(STRING("FIELD<T>::normL2() : The component argument should be between 1 and the number of components"));

    const FIELD<double, FullInterlace> * p_field_size=p_field_volume;
    if(!p_field_volume) // if the user don't supply the volume
      p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh]
    else
      p_field_size->addReference();
    // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size
    const double* vol=p_field_size->getValue();
    // Il n'est vraiment pas optimal de mixer des champs dans des modes d'entrelacement
    // different juste pour le calcul


    double integrale=0.0;
    double totVol=0.0;

    if ( getSupport()->getEntity() == MED_NODE ) // issue 20120: [CEA 206] normL2 on NODE field
    {
      //Most frequently the FIELD is on the whole mesh and
      // there is no need in optimizing iterations from supporting nodes-> back to cells,
      // so we iterate just on all cells
      const MESH * mesh = getSupport()->getMesh()->convertInMESH();
      const int nbCells = mesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
      const int *C = mesh->getConnectivity(MED_NODAL,MED_CELL,MED_ALL_ELEMENTS);
      const int *iC = mesh->getConnectivityIndex(MED_NODAL,MED_CELL);
      for (int i = 0; i < nbCells; ++i, ++vol) {
        // calculate integral on current element as average summ of values on all it's nodes
        double curCellValue = 0;
        try { // we expect exception with partial fields for nodes w/o values
          for (int ij = iC[i]; ij < iC[i+1]; ij++) {
            int node = C[ij-1];
            curCellValue += getValueIJ( node, component );
          }
        }
        catch ( MEDEXCEPTION ) {
          continue;
        }
        int nbNodes = iC[i+1]-iC[i];
        curCellValue /= nbNodes;
        integrale += (curCellValue * curCellValue) * std::abs(*vol);
        totVol+=std::abs(*vol);
      }
      mesh->removeReference();
    }
    else
    {
      if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) {
        const T* value = getValue();
        value = value + (component-1) * getNumberOfValues();
        const T* lastvalue = value + getNumberOfValues(); // pointing just after the end of column
        for (; value!=lastvalue ; ++value ,++vol) {
          integrale += double((*value) * (*value)) * std::abs(*vol);
          totVol+=std::abs(*vol);
        }
      }
      else if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE ) {
        ArrayNoByType* anArray = dynamic_cast< ArrayNoByType * > ( getArrayNoGauss() );
        for (int i=1; i <= anArray->getNbElem() ; i++, ++vol ) {
          integrale += anArray->getIJ(i,component) * anArray->getIJ(i,component) * std::abs(*vol);
          totVol+=std::abs(*vol);
        }
      }
      else { // FULL_INTERLACE
        ArrayFull* anArray = dynamic_cast< ArrayFull * > ( getArrayNoGauss() );
        for (int i=1; i <= anArray->getNbElem() ; i++, ++vol ) {
          integrale += anArray->getIJ(i,component) * anArray->getIJ(i,component) * std::abs(*vol);
          totVol+=std::abs(*vol);
        }
      }
    }

    if(p_field_size)
      p_field_size->removeReference(); // delete temporary volume field

    if( totVol <= 0)
        throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!"));
    return integrale/totVol;
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T , class INTERLACING_TAG >
double MEDMEM::FIELD< T, INTERLACING_TAG >::normL2 ( const FIELD< double, FullInterlace > *  p_field_volume = NULL) const

Return L2 Norm of the field.

If the optional p_field_volume argument is furnished, the volume is not re-calculated. For the nodal field, p_field_volume must be for all cells even if the field is partial.

Definition at line 2447 of file MEDMEM_Field.hxx.

{
    _checkNormCompatibility(p_field_volume, /*nodalAllowed=*/true); // may throw exception
    const FIELD<double, FullInterlace> * p_field_size=p_field_volume;
    if(!p_field_volume) // if the user don't supply the volume
      p_field_size=_getFieldSize(); // we calculate the volume
    else
      p_field_size->addReference();
    // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size
    const double* vol=p_field_size->getValue();
    const double* lastvol=vol+getNumberOfValues(); // pointing just after the end of vol


    double integrale=0.0;
    double totVol=0.0;

    if ( getSupport()->getEntity() == MED_NODE ) // issue 20120: [CEA 206] normL2 on NODE field
    {
      //Most frequently the FIELD is on the whole mesh and
      // there is no need in optimizing iterations from supporting nodes-> back to cells,
      // so we iterate just on all cells
      const MESH * mesh = getSupport()->getMesh()->convertInMESH();
      const int nbCells = mesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS);
      const int *C = mesh->getConnectivity(MED_NODAL,MED_CELL,MED_ALL_ELEMENTS);
      const int *iC = mesh->getConnectivityIndex(MED_NODAL,MED_CELL);
      int nbComp = getNumberOfComponents();
      for (int i = 0; i < nbCells; ++i, ++vol) {
        // calculate integral on current element as average summ of values on all it's nodes
        int nbNodes = iC[i+1]-iC[i];
        vector< double > curCellValue( nbComp, 0 );
        try { // we expect exception with partial fields for nodes w/o values
          for (int ij = iC[i]; ij < iC[i+1]; ij++) {
            int node = C[ij-1];
            for ( int j = 0; j < nbComp; ++j )
              curCellValue[ j ] += getValueIJ( node, j+1 ) / nbNodes;
          }
        }
        catch ( MEDEXCEPTION ) {
          continue;
        }

        for ( int j = 0; j < nbComp; ++j ) {
          integrale += (curCellValue[j] * curCellValue[j]) * std::abs(*vol);
        }
        totVol+=std::abs(*vol);
      }
      mesh->removeReference();
      if ( nbCells > 0 && totVol == 0.)
        throw MEDEXCEPTION("can't compute sobolev norm : "
                           "none of elements has values on all it's nodes");
    }
    else
    {
      const double* p_vol=vol;
      for (p_vol=vol; p_vol!=lastvol ; ++p_vol) // calculate total volume
        totVol+=std::abs(*p_vol);

      if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) {
        const T* value = getValue();
        for (int i=1; i<=getNumberOfComponents(); ++i) { // compute integral on all components
          for (p_vol=vol; p_vol!=lastvol ; ++value ,++p_vol) {
            integrale += (*value) * (*value) * std::abs(*p_vol);
          }
        }
      }
      else if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE_BY_TYPE ) {
        ArrayNoByType* anArray = dynamic_cast< ArrayNoByType * > ( getArrayNoGauss() );
        for (int j=1; j<=anArray->getDim(); j++) {
          int i = 1;
          for (p_vol=vol; i<=anArray->getNbElem() || p_vol!=lastvol; i++, ++p_vol ) {
            integrale += anArray->getIJ(i,j) * anArray->getIJ(i,j) * std::abs(*p_vol);
          }
        }
      }
      else { // FULL_INTERLACE
        ArrayFull* anArray = dynamic_cast< ArrayFull * > ( getArrayNoGauss() );
        for (int j=1; j<=anArray->getDim(); j++) {
          int i = 1;
          for (p_vol=vol; i<=anArray->getNbElem() || p_vol!=lastvol; i++, ++p_vol ) {
            integrale += anArray->getIJ(i,j) * anArray->getIJ(i,j) * std::abs(*p_vol);
          }
        }
      }
    }
    if(p_field_size)
        p_field_size->removeReference(); // delete temporary volume field

    if( totVol <= 0)
      throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!"));
    return integrale/totVol;
}

Here is the call graph for this function:

template<class T , class INTERLACIN_TAG >
double MEDMEM::FIELD< T, INTERLACIN_TAG >::normMax ( ) const throw (MEDEXCEPTION)

Return maximum of all absolute values contained in the array (all elements and all components are browsed).

Definition at line 1894 of file MEDMEM_Field.hxx.

{
    const T* value=getValue(); // get pointer to the values
    const int size=getNumberOfValues()*getNumberOfComponents();
    if (size <= 0) // Size of array has to be strictly positive
    {
        string diagnosis;
        diagnosis="FIELD<T,INTERLACIN_TAG>::normMax() : cannot compute the norm of "+getName()+
            " : it size is non positive!";
        throw MEDEXCEPTION(diagnosis.c_str());
    }
    const T* lastvalue=value+size; // get pointer just after last value
    const T* pMax=value; // pointer to the max value
    const T* pMin=value; // pointer to the min value

    // get pointers to the max & min value of array
    while ( ++value != lastvalue )
    {
        if ( *pMin > *value )
            pMin=value;
        if ( *pMax < *value )
            pMax=value;
    }

    T Max= *pMax>(T) 0 ? *pMax : -*pMax; // Max=abs(*pMax)
    T Min= *pMin>(T) 0 ? *pMin : -*pMin; // Min=abs(*pMin)

    return Max>Min ? double(Max) : double(Min);
}

Here is the caller graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::operator* ( const FIELD< T, INTERLACING_TAG > &  m) const

Overload multiplication operator.

This operation is authorized only for compatible fields that have the same support. The compatibility checking includes equality tests of the folowing data members:

  • _support
  • _numberOfComponents
  • _numberOfValues
  • _componentsTypes
  • _MEDComponentsUnits.

The data members of the returned field are initialized, based on the first field, except for the name, which is the combination of the two field's names and the operator. Advised Utilisation in C++ : FIELD<T> c = a * b;
In this case, the (recent) compilators perform optimisation and don't call the copy constructor. When using python, this operator calls the copy constructor in any case. The user has to be aware that when using operator * in associatives expressions like a = b * c * d *e;
no optimisation is performed : the evaluation of last expression requires the construction of 3 temporary fields.

Definition at line 1542 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::operator*(const FIELD & m)";
  BEGIN_OF_MED(LOC);
    FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception

    // Creation of the result - memory is allocated by FIELD constructor
    FIELD<T, INTERLACING_TAG> *result=new FIELD<T, INTERLACING_TAG>(this->getSupport(),this->getNumberOfComponents());
    result->_operationInitialize(*this,m,"*"); // perform Atribute's initialization
    result->_mul_in_place(*this,m); // perform multiplication

  END_OF_MED(LOC);
    return result;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > & MEDMEM::FIELD< T, INTERLACING_TAG >::operator*= ( const FIELD< T, INTERLACING_TAG > &  m)

Overloaded Operator *= Operations are directly performed in the first field's array.

This operation is authorized only for compatible fields that have the same support.

Definition at line 1562 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::operator*=(const FIELD & m)";
  BEGIN_OF_MED(LOC);
    FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception

    const T* value1=m.getValue();

    // get a non const pointer to the inside array of values and perform operation
    T * value=const_cast<T *> (getValue());
    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
    const T* endV=value+size; // pointer to the end of value

    for(;value!=endV; value1++,value++)
        *value *= *value1;

  END_OF_MED(LOC);
    return *this;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::operator+ ( const FIELD< T, INTERLACING_TAG > &  m) const

Overload addition operator.

This operation is authorized only for compatible fields that have the same support. The compatibility checking includes equality tests of the folowing data members:

  • _support
  • _numberOfComponents
  • _numberOfValues
  • _componentsTypes
  • _MEDComponentsUnits.

The data members of the returned field are initialized, based on the first field, except for the name, which is the combination of the two field's names and the operator. Advised Utilisation in C++ : FIELD<T> c = a + b;
In this case, the (recent) compilators perform optimisation and don't call the copy constructor. When using python, this operator calls the copy constructor in any case. The user has to be aware that when using operator + in associatives expressions like a = b + c + d +e;
no optimisation is performed : the evaluation of last expression requires the construction of 3 temporary fields.

Definition at line 1286 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::operator+(const FIELD & m)";
  BEGIN_OF_MED(LOC);
    FIELD_::_checkFieldCompatibility(*this, m); // may throw exception

    // Creation of the result - memory is allocated by FIELD constructor
    FIELD<T, INTERLACING_TAG> *result=new FIELD<T, INTERLACING_TAG>(this->getSupport(),this->getNumberOfComponents());
    result->_operationInitialize(*this,m,"+"); // perform Atribute's initialization
    result->_add_in_place(*this,m); // perform addition

  END_OF_MED(LOC);
    return result;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > & MEDMEM::FIELD< T, INTERLACING_TAG >::operator+= ( const FIELD< T, INTERLACING_TAG > &  m)

Overloaded Operator += Operations are directly performed in the first field's array.

This operation is authorized only for compatible fields that have the same support.

Definition at line 1306 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::operator+=(const FIELD & m)";
  BEGIN_OF_MED(LOC);
    FIELD_::_checkFieldCompatibility(*this, m); // may throw exception

    const T* value1=m.getValue(); // get pointers to the values we are adding

    // get a non const pointer to the inside array of values and perform operation
    T * value=const_cast<T *> (getValue());
    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
    const T* endV=value+size; // pointer to the end of value
    for(;value!=endV; value1++,value++)
        *value += *value1;
  END_OF_MED(LOC);
    return *this;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::operator- ( const FIELD< T, INTERLACING_TAG > &  m) const

Overload substraction operator.

This operation is authorized only for compatible fields that have the same support. The compatibility checking includes equality tests of the folowing data members:

  • _support
  • _numberOfComponents
  • _numberOfValues
  • _componentsTypes
  • _MEDComponentsUnits.

The data members of the returned field are initialized, based on the first field, except for the name, which is the combination of the two field's names and the operator. Advised Utilisation in C++ : FIELD<T> c = a - b;
In this case, the (recent) compilators perform optimisation and don't call the copy constructor. When using python, this operator calls the copy constructor in any case. The user has to be aware that when using operator - in associatives expressions like a = b - c - d -e;
no optimisation is performed : the evaluation of last expression requires the construction of 3 temporary fields.

Definition at line 1387 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::operator-(const FIELD & m)";
  BEGIN_OF_MED(LOC);
    FIELD_::_checkFieldCompatibility(*this, m); // may throw exception

    // Creation of the result - memory is allocated by FIELD constructor
    FIELD<T, INTERLACING_TAG> *result=new FIELD<T, INTERLACING_TAG>(this->getSupport(),this->getNumberOfComponents());
    result->_operationInitialize(*this,m,"-"); // perform Atribute's initialization
    result->_sub_in_place(*this,m); // perform substracion

  END_OF_MED(LOC);
    return result;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::operator- ( ) const

Definition at line 1403 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::operator-()";
  BEGIN_OF_MED(LOC);

    // Creation of the result - memory is allocated by FIELD constructor
  FIELD<T, INTERLACING_TAG> *result=new FIELD<T, INTERLACING_TAG>(this->getSupport(),this->getNumberOfComponents());
    // Atribute's initialization
    result->setName("- "+getName());
    result->setComponentsNames(getComponentsNames());
    // not yet implemented    setComponentType(getComponentType());
    result->setComponentsDescriptions(getComponentsDescriptions());
    result->setMEDComponentsUnits(getMEDComponentsUnits());
    result->setComponentsUnits(getComponentsUnits());
    result->setIterationNumber(getIterationNumber());
    result->setTime(getTime());
    result->setOrderNumber(getOrderNumber());

    const T* value1=getValue();
    // get a non const pointer to the inside array of values and perform operation
    T * value=const_cast<T *> (result->getValue());
    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
    const T* endV=value+size; // pointer to the end of value

    for(;value!=endV; value1++,value++)
        *value = -(*value1);
  END_OF_MED(LOC);
    return result;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > & MEDMEM::FIELD< T, INTERLACING_TAG >::operator-= ( const FIELD< T, INTERLACING_TAG > &  m)

Overloaded Operator -= Operations are directly performed in the first field's array.

This operation is authorized only for compatible fields that have the same support.

Definition at line 1438 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::operator-=(const FIELD & m)";
  BEGIN_OF_MED(LOC);
    FIELD_::_checkFieldCompatibility(*this, m); // may throw exception

    const T* value1=m.getValue();

    // get a non const pointer to the inside array of values and perform operation
    T * value=const_cast<T *> (getValue());
    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
    const T* endV=value+size; // pointer to the end of value

    for(;value!=endV; value1++,value++)
        *value -= *value1;

  END_OF_MED(LOC);
    return *this;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::operator/ ( const FIELD< T, INTERLACING_TAG > &  m) const

Overload division operator.

This operation is authorized only for compatible fields that have the same support. The compatibility checking includes equality tests of the folowing data members:

  • _support
  • _numberOfComponents
  • _numberOfValues
  • _componentsTypes
  • _MEDComponentsUnits.

The data members of the returned field are initialized, based on the first field, except for the name, which is the combination of the two field's names and the operator. Advised Utilisation in C++ : FIELD<T> c = a / b;
In this case, the (recent) compilators perform optimisation and don't call the copy constructor. When using python, this operator calls the copy constructor in any case. The user has to be aware that when using operator / in associatives expressions like a = b / c / d /e;
no optimisation is performed : the evaluation of last expression requires the construction of 3 temporary fields.

Definition at line 1645 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::operator/(const FIELD & m)";
  BEGIN_OF_MED(LOC);
    FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception

    // Creation of the result - memory is allocated by FIELD constructor
    FIELD<T, INTERLACING_TAG> *result=new FIELD<T, INTERLACING_TAG>(this->getSupport(),this->getNumberOfComponents());
    try
      {
        result->_operationInitialize(*this,m,"/"); // perform Atribute's initialization
        result->_div_in_place(*this,m); // perform division
      }
    catch(MEDEXCEPTION& e)
      {
        result->removeReference();
        throw e;
      }

  END_OF_MED(LOC);
    return result;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > & MEDMEM::FIELD< T, INTERLACING_TAG >::operator/= ( const FIELD< T, INTERLACING_TAG > &  m)

Overloaded Operator /= Operations are directly performed in the first field's array.

This operation is authorized only for compatible fields that have the same support.

Definition at line 1674 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::operator/=(const FIELD & m)";
  BEGIN_OF_MED(LOC);
    FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception

    const T* value1=m.getValue(); // get pointers to the values we are adding

    // get a non const pointer to the inside array of values and perform operation
    T * value=const_cast<T *> (getValue());
    const int size=getNumberOfValues()*getNumberOfComponents(); // size of array
    const T* endV=value+size; // pointer to the end of value

    for(;value!=endV; value1++,value++)
        *value /= *value1;

  END_OF_MED(LOC);
    return *this;
}

Here is the call graph for this function:

template<class T, class INTERLACIN_TAG >
T MEDMEM::FIELD< T, INTERLACIN_TAG >::pow ( x) [static, protected]

Definition at line 2261 of file MEDMEM_Field.hxx.

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::scalarProduct ( const FIELD< T, INTERLACING_TAG > &  m,
const FIELD< T, INTERLACING_TAG > &  n,
bool  deepCheck = false 
) [static]

Return a pointer to a new field that holds the scalar product.

Static member function. This operation is authorized only for compatible fields that have the same support. The compatibility checking includes equality tests of the folowing data members:

  • _support
  • _numberOfComponents
  • _numberOfValues
  • _componentsTypes
  • _MEDComponentsUnits. Data members are initialized. The new field point to the same support and has one component. Each value of it is the scalar product of the two argument's fields. The user is in charge of memory deallocation.

Definition at line 2313 of file MEDMEM_Field.hxx.

{
    if(!deepCheck)
      FIELD_::_checkFieldCompatibility( m, n, false); // may throw exception
    else
      FIELD_::_deepCheckFieldCompatibility(m, n, false);

    // we need a MED_FULL_INTERLACE representation of m & n to compute the scalar product
    // result type imply INTERLACING_TAG=FullInterlace for m & n

    const int numberOfElements=m.getNumberOfValues(); // strictly positive
    const int NumberOfComponents=m.getNumberOfComponents(); // strictly positive

    // Creation & init of a the result field on the same support, with one component
    // You have to be careful about the interlacing mode, because in the computation step,
    // it seems to assume the the interlacing mode is the FullInterlacing

    FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),1);
    result->setName( "scalarProduct ( " + m.getName() + " , " + n.getName() + " )" );
    result->setIterationNumber(m.getIterationNumber());
    result->setTime(m.getTime());
    result->setOrderNumber(m.getOrderNumber());

    const T* value1=m.getValue(); // get const pointer to the values
    const T* value2=n.getValue(); // get const pointer to the values
    // get a non const pointer to the inside array of values and perform operation
    T * value=const_cast<T *> (result->getValue());

    const T* lastvalue=value+numberOfElements; // pointing just after last value of result
    for ( ; value!=lastvalue ; ++value ) // loop on all elements
    {
        *value=(T)0; // initialize value
        const T* endofRow=value1+NumberOfComponents; // pointing just after end of row
        for ( ; value1 != endofRow; ++value1, ++value2) // computation of dot product
            *value += (*value1) * (*value2);
    }
    return result;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::sub ( const FIELD< T, INTERLACING_TAG > &  m,
const FIELD< T, INTERLACING_TAG > &  n 
) [static]

Substraction of fields.

Static member function. The function return a pointer to a new created field that holds the substraction. Data members are checked for compatibility and initialized. The user is in charge of memory deallocation.

Definition at line 1486 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::sub(const FIELD & m, const FIELD& n)";
  BEGIN_OF_MED(LOC);
    FIELD_::_checkFieldCompatibility(m, n); // may throw exception

    // Creation of a new field
    FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
                                                                      m.getNumberOfComponents());
    result->_operationInitialize(m,n,"-"); // perform Atribute's initialization
    result->_sub_in_place(m,n); // perform substraction

  END_OF_MED(LOC);
    return result;
}

Here is the call graph for this function:

template<class T , class INTERLACING_TAG >
FIELD< T, INTERLACING_TAG > * MEDMEM::FIELD< T, INTERLACING_TAG >::subDeep ( const FIELD< T, INTERLACING_TAG > &  m,
const FIELD< T, INTERLACING_TAG > &  n 
) [static]

Same as sub method except that field check is deeper.

Definition at line 1505 of file MEDMEM_Field.hxx.

{
  const char* LOC = "FIELD<T>::subDeep(const FIELD & m, const FIELD& n)";
  BEGIN_OF_MED(LOC);
    FIELD_::_deepCheckFieldCompatibility(m, n); // may throw exception

    // Creation of a new field
    FIELD<T, INTERLACING_TAG>* result = new FIELD<T, INTERLACING_TAG>(m.getSupport(),
                                                                      m.getNumberOfComponents());
    result->_operationInitialize(m,n,"-"); // perform Atribute's initialization
    result->_sub_in_place(m,n); // perform substraction

  END_OF_MED(LOC);
    return result;
}

Here is the call graph for this function: