MEDMEM fields are used to represent variables over a particular set of elements of the mesh. The region on which the variable is defined is determined through a support object (which can be retrieved by getSupport() method). Each field has a number of components, that could for instance be the different coordinates of a vector. All these components have a name, a description and a unit. Elements can also contain several Gauss points, in which case, values are defined on each Gauss point of the element.
The fields can contain integer values or floating point values. In C++, this is reflected by the fact that FIELD is a class template that can be either a FIELD<int>
or FIELD<double>
. In Python, two classes FIELDINT
and FIELDDOUBLE
exist. In the present section, the methods of the FIELD template will be described as methods of a class FIELD_
(from which the template classes actually inherit). The template parameter is T
.
In MEDMEM, a field is characterized by its name (getName
) and an optional description (getDescription
).
It is also characterized by its computation time :
By default, there are no iteration and order number defined (value MED_NOPDT and MED_NONOR).
As for the coordinates in the mesh definition, there are two ways to store fields : one consists in interlacing the different components, grouping the data elementwise (MED_FULL_INTERLACE mode), the other one consists in grouping the data componentwise (MED_NO_INTERLACE).
The situation is further complicated by the introduction of Gauss points. If the field is defined on several Gauss points, the MEDMEM convention is that the Gauss points are always grouped together. Let us denote the value of the field on the
-th element, for the
-th component on its
-th Gauss point. In {
MED_FULL_INTERLACE
, elements are nested in a order, while in
MED_NO_INTERLACE
elements are nested in order. \
For instance, MED_FULL_INTERLACE
will result in the following ordering (for four Gauss points and two components):
MED_NO_INTERLACE
will result in the following ordering :
In this document, only the methods enabling the retrieval of values on fields defined on several Gauss points are presented. For further information on defining the location of the Gauss points in a reference element, the reader should consult MED file Web Page : https://hammi.extra.cea.fr/static/MED/web_med/
The following sections describe the FIELD methods :
This program gives an example of creation of a file containing a mesh and fields. This program is a tool that reads a mesh in an input file, creates a field with the inverse of the cell volume, and creates an output file with the mesh and the field.
The reader should note that the mesh name passed as an argument to the addDriver()
method has to be coherent with the mesh name (as obtained by getName()
).
The following example reviews most of the notions seen in this section.
// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // using namespace std; #include "MEDMEM_Mesh.hxx" #include "MEDMEM_Field.hxx" using namespace MEDMEM; using namespace MED_EN ; int main (int argc, char ** argv) { const string MedFile = "pointe.med" ; const string MeshName = "maa1" ; const string FieldName = "fieldcelldoublevector" ; /* read MESH */ MESH * myMesh = new MESH(MED_DRIVER,MedFile,MeshName) ; // myMesh->read() ; /* read FIELD */ // we need a support : const SUPPORT * mySupport = myMesh->getSupportOnAll(MED_CELL); FIELD<double> myField(mySupport,MED_DRIVER,MedFile,FieldName) ; // myField.read() ; /* what in Field ? */ // How many components int NumberOfCompoennts = myField.getNumberOfComponents() ; const string * ComponentsNames = myField.getComponentsNames(); const string * ComponentsDescriptions = myField.getComponentsDescriptions(); const string * ComponentsUnits = myField.getMEDComponentsUnits(); for(int i=0;i<NumberOfCompoennts; i++) { cout << "Component " << i << " :" <<endl ; cout << " - name : " << ComponentsNames[i] << endl ; cout << " - description : " << ComponentsDescriptions[i] << endl ; cout << " - unit : " << ComponentsUnits[i] << endl ; } // Which iteration : int IterationNumber = myField.getIterationNumber() ; // negative mean undefined int OrderNumber = myField.getOrderNumber() ; // internal iteration at this time iteration, negative mean undefined double Time = myField.getTime() ; cout << "Iteration " << IterationNumber << " at time " << Time << " (and order number " << OrderNumber << ")" << endl ; // How many Value : int NumberOfValue = mySupport->getNumberOfElements(MED_ALL_ELEMENTS); // Value const double * Value = myField.getValue(); for(int i=0; i<NumberOfValue; i++) { for(int j=0; j<NumberOfCompoennts; j++) cout << Value[i*NumberOfCompoennts+j] << " " ; cout << endl ; } myMesh->removeReference(); return 0 ; }