1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 #include "MEDMEM_Mesh.hxx"
25 #include "MEDMEM_Field.hxx"
27 using namespace MEDMEM;
28 using namespace MED_EN ;
30 int main (int argc, char ** argv) {
32 const string MedFile = "pointe.med" ;
33 const string MeshName = "maa1" ;
36 MESH * myMesh = new MESH(MED_DRIVER,MedFile,MeshName) ;
38 // we need a support :
39 const SUPPORT * mySupport = myMesh->getSupportOnAll(MED_CELL);
41 /* create FIELD on mySupport, with 3 components */
42 int NumberOfCompoennts = 3 ;
43 FIELD<double> myField(mySupport,NumberOfCompoennts) ;
44 const string FieldName = "fieldcelldouble" ;
45 myField.setName(FieldName) ;
47 // Components information
48 string * ComponentsNames = new string[NumberOfCompoennts] ;
49 ComponentsNames[0] = "Vx" ;
50 ComponentsNames[1] = "Vy" ;
51 ComponentsNames[2] = "Vz" ;
52 myField.setComponentsNames(ComponentsNames) ;
54 string * ComponentsDescriptions = new string[NumberOfCompoennts] ;
55 ComponentsDescriptions[0] = "vitesse selon x" ;
56 ComponentsDescriptions[1] = "vitesse selon y" ;
57 ComponentsDescriptions[2] = "vitesse selon z" ;
58 myField.setComponentsDescriptions(ComponentsDescriptions) ;
60 string * ComponentsUnits = new string[NumberOfCompoennts] ;
61 ComponentsUnits[0] = "m.s-1" ;
62 ComponentsUnits[1] = "m.s-1" ;
63 ComponentsUnits[2] = "m.s-1" ;
64 myField.setMEDComponentsUnits(ComponentsUnits) ;
66 // Iteration information :
67 int IterationNumber = 10 ; // set value to MED_NOPDT if undefined (default)
68 myField.setIterationNumber(IterationNumber) ;
70 int OrderNumber = 1 ; // set value to MED_NONOR if undefined (default)
71 myField.setOrderNumber(OrderNumber) ;
73 double Time = 3.435678 ; // in second
74 myField.setTime(Time) ;
77 int NumberOfValue = mySupport->getNumberOfElements(MED_ALL_ELEMENTS);
78 for(int i=1; i<=NumberOfValue; i++) // i^th element
79 for (int j=1; j<=NumberOfCompoennts; j++) { // j^th component
80 double myValue = (i+j) * 0.1 ;
81 myField.setValueIJ(i,j,myValue);
84 // save this new field
85 myField.write(MED_DRIVER,filename) ;