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/ or email : webmaster.salome@opencascade.com
20 /* Programme de test du constructeur de copies de la classe FIELD_ de MEDMEM
28 #include "MEDMEM_Exception.hxx"
29 #include "MEDMEM_Mesh.hxx"
30 #include "MEDMEM_Family.hxx"
31 #include "MEDMEM_Group.hxx"
33 #include "MEDMEM_MedMeshDriver.hxx"
34 #include "MEDMEM_MedFieldDriver.hxx"
35 #include "MEDMEM_Support.hxx"
36 #include "MEDMEM_Field.hxx"
37 #include "MEDMEM_FieldConvert.hxx"
38 #include "MEDMEM_define.hxx"
41 using namespace MEDMEM;
42 using namespace MED_EN;
45 void affiche_field_(FIELD_ * myField, const SUPPORT * mySupport)
47 cout << "Field "<< myField->getName() << " : " <<myField->getDescription() << endl ;
48 int NumberOfComponents = myField->getNumberOfComponents() ;
49 cout << "- Nombre de composantes : "<< NumberOfComponents << endl ;
50 for (int i=1; i<NumberOfComponents+1; i++) {
51 cout << " - composante "<<i<<" :"<<endl ;
52 cout << " - nom : "<<myField->getComponentName(i)<< endl;
53 cout << " - description : "<<myField->getComponentDescription(i) << endl;
54 cout << " - units : "<<myField->getMEDComponentUnit(i) << endl;
56 cout << "- iteration :" << endl ;
57 cout << " - numero : " << myField->getIterationNumber()<< endl ;
58 cout << " - ordre : " << myField->getOrderNumber()<< endl ;
59 cout << " - temps : " << myField->getTime()<< endl ;
61 cout << "- Type : " << myField->getValueType()<< endl;
63 cout << "- Adresse support : " << mySupport << endl;
66 template <class INTERLACING_TAG>
67 void affiche_fieldT(FIELD<double, INTERLACING_TAG> * myField,
68 const SUPPORT * mySupport)
70 affiche_field_((FIELD_ *) myField, mySupport);
72 cout << "- Valeurs :"<<endl;
73 int NumberOf = mySupport->getNumberOfElements(MED_ALL_ELEMENTS);
74 int NumberOfComponents = myField->getNumberOfComponents() ;
76 if ( myField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) {
77 for (int i=1; i<NumberOf+1; i++) {
78 const double * value = myField->getRow(i) ;
79 for (int j=0; j<NumberOfComponents; j++)
80 cout << value[j]<< " ";
85 for (int j=1; j<NumberOfComponents+1; j++) {
86 const double * value = myField->getColumn(j) ;
87 for (int i=0; i<NumberOf; i++)
88 cout << value[i]<< " ";
94 int main (int argc, char ** argv) {
95 // int read; !! UNUSED VARIABLE !!
97 if ((argc !=3) && (argc != 4)) {
98 cerr << "Usage : " << argv[0]
99 << " filename meshname fieldname" << endl << endl;
103 string filename = argv[1] ;
104 string meshname = argv[2] ;
106 MESH * myMesh= new MESH() ;
107 myMesh->setName(meshname);
108 MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ;
109 myMeshDriver.setMeshName(meshname);
110 int current = myMesh->addDriver(myMeshDriver);
111 myMesh->read(current);
114 if (argc != 4) exit(0) ;
115 // else we have a field !
116 string fieldname = argv[3];
118 FIELD<double> * myField ;
119 // SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
120 SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_cell",MED_CELL);
122 myField = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
125 mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE);
127 myField = new FIELD<double>(mySupport,MED_DRIVER,filename,fieldname) ;
129 cout << "Field double " << fieldname << " not found !!!" << endl ;
134 affiche_fieldT(myField, mySupport);
135 FIELD<double> * myField2 = new FIELD<double>(* myField); // Contructeur par recopie, sauf SUPPORT
136 delete myField; // Ne détruit pas le Support
137 affiche_fieldT(myField2, myField2->getSupport());
138 FIELD<double,NoInterlace> * myField3 = FieldConvert( *myField2 );
141 affiche_fieldT(myField3, myField3->getSupport());
142 FIELD<double,FullInterlace> * myField4 = FieldConvert( *myField3 );
144 affiche_fieldT(myField4, myField4->getSupport());
147 FIELD<double,NoInterlace> * myField5 = new FIELD<double,NoInterlace>(mySupport,MED_DRIVER,filename,fieldname) ;
148 affiche_fieldT(myField5, myField5->getSupport());