Salome HOME
MEDMEM suppression
[modules/med.git] / src / MEDMEMBinTest / dumpInterpolation.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File      : dumpInterpolation.cxx
24 // Created   : Mon Jan 11 16:46:10 2010
25 // Author    : Edward AGAPOV (eap)
26 //
27 #include <MEDMEM_MedFileBrowser.hxx>
28 #include <MEDMEM_Remapper.hxx>
29
30 using namespace MEDMEM;
31 using namespace std;
32
33
34 static string getMeshName(const char* file, int mesh_index)
35 {
36   MEDFILEBROWSER med(file);
37   if ( mesh_index >= med.getNumberOfMeshes() )
38     {
39       cout << "Invalid index of mesh, it must be less than " << med.getNumberOfMeshes() << endl;
40       return "Invalid mesh index";
41     }
42   vector<string> mesh_names = med.getMeshNames();
43   return mesh_names[mesh_index];
44 }
45
46 //================================================================================
47 /*!
48  * \brief Perform interpolation of two meshes and dumps result. For format of output,
49  * see comment to operator<<() in InterpKernelMatrix.hxx
50  */
51 //================================================================================
52
53 int main(int argc, char** argv)
54 {
55   if( argc < 3 )
56     {
57       cout << "Dumps result of interpolation of two meshes" << endl
58            << "For format of output, see comment to operator<<() in InterpKernelMatrix.hxx" <<endl;
59       cout << "Usage: "<<argv[0]<<" med_file1 med_file2 [mesh_index1=0 mesh_index2=0]" << endl;
60       return -1;
61     }
62   string mesh_name1 = getMeshName( argv[1], (argc > 3) ? atoi(argv[3]) : 0 );
63   string mesh_name2 = getMeshName( argv[2], (argc > 4) ? atoi(argv[4]) : 0 );
64
65   MESH *mesh1=new MESH(MED_DRIVER, argv[1], mesh_name1.data());
66   MESH *mesh2=new MESH(MED_DRIVER, argv[2], mesh_name2.data());
67
68   MEDMEM_REMAPPER aREMAPPER;
69   aREMAPPER.prepare( *mesh1, *mesh2, "P0P0" );
70   aREMAPPER.printMatrixInfo();
71   mesh1->removeReference();
72   mesh2->removeReference();
73   return 0;
74 }