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