Back to index

salome-med  6.5.0
FIELDgeneral.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 using namespace std;
00024 #include "MEDMEM_Mesh.hxx"
00025 #include "MEDMEM_Field.hxx"
00026 
00027 using namespace MEDMEM;
00028 using namespace MED_EN ;
00029 
00030 int main (int argc, char ** argv) {
00031 
00032   const string MedFile = "pointe.med" ;
00033   const string MeshName = "maa1" ;
00034   const string FieldName = "fieldcelldoublevector" ;
00035 
00036   /* read MESH */
00037   MESH * myMesh = new MESH(MED_DRIVER,MedFile,MeshName) ;
00038   //  myMesh->read() ;
00039 
00040   /* read FIELD */
00041   // we need a support :
00042   const SUPPORT * mySupport = myMesh->getSupportOnAll(MED_CELL);
00043   FIELD<double> myField(mySupport,MED_DRIVER,MedFile,FieldName) ;
00044   //  myField.read() ;
00045 
00046   /* what in Field ? */
00047   // How many components
00048   int NumberOfCompoennts = myField.getNumberOfComponents() ;
00049 
00050   const string * ComponentsNames = myField.getComponentsNames();
00051   const string * ComponentsDescriptions = myField.getComponentsDescriptions();
00052   const string * ComponentsUnits = myField.getMEDComponentsUnits();
00053 
00054   for(int i=0;i<NumberOfCompoennts; i++) {
00055     cout << "Component " << i << " :" <<endl ;
00056     cout << "  - name        : " << ComponentsNames[i] << endl ;
00057     cout << "  - description : " << ComponentsDescriptions[i] << endl ;
00058     cout << "  - unit        : " << ComponentsUnits[i] << endl ;
00059   }
00060 
00061   // Which iteration :
00062   int IterationNumber = myField.getIterationNumber() ; // negative mean undefined
00063   int OrderNumber = myField.getOrderNumber() ;
00064   // internal iteration at this time iteration, negative mean undefined
00065   double Time = myField.getTime() ;
00066 
00067   cout << "Iteration " << IterationNumber << " at time " << Time <<
00068     " (and order number " << OrderNumber << ")" << endl ;
00069 
00070   // How many Value :
00071   int NumberOfValue = mySupport->getNumberOfElements(MED_ALL_ELEMENTS);
00072   // Value
00073   const double * Value = myField.getValue();
00074   for(int i=0; i<NumberOfValue; i++) {
00075     for(int j=0; j<NumberOfCompoennts; j++)
00076       cout << Value[i*NumberOfCompoennts+j] << " " ;
00077     cout << endl ;
00078   }
00079 
00080   myMesh->removeReference();
00081 
00082   return 0 ;
00083 }