Back to index

salome-med  6.5.0
dumpInterpolation.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 // File      : dumpInterpolation.cxx
00024 // Created   : Mon Jan 11 16:46:10 2010
00025 // Author    : Edward AGAPOV (eap)
00026 //
00027 #include <MEDMEM_MedFileBrowser.hxx>
00028 #include <MEDMEM_Remapper.hxx>
00029 
00030 using namespace MEDMEM;
00031 using namespace std;
00032 
00033 
00034 static string getMeshName(const char* file, int mesh_index)
00035 {
00036   MEDFILEBROWSER med(file);
00037   if ( mesh_index >= med.getNumberOfMeshes() )
00038     {
00039       cout << "Invalid index of mesh, it must be less than " << med.getNumberOfMeshes() << endl;
00040       return "Invalid mesh index";
00041     }
00042   vector<string> mesh_names = med.getMeshNames();
00043   return mesh_names[mesh_index];
00044 }
00045 
00046 //================================================================================
00051 //================================================================================
00052 
00053 int main(int argc, char** argv)
00054 {
00055   if( argc < 3 )
00056     {
00057       cout << "Dumps result of interpolation of two meshes" << endl
00058            << "For format of output, see comment to operator<<() in InterpKernelMatrix.hxx" <<endl;
00059       cout << "Usage: "<<argv[0]<<" med_file1 med_file2 [mesh_index1=0 mesh_index2=0]" << endl;
00060       return -1;
00061     }
00062   string mesh_name1 = getMeshName( argv[1], (argc > 3) ? atoi(argv[3]) : 0 );
00063   string mesh_name2 = getMeshName( argv[2], (argc > 4) ? atoi(argv[4]) : 0 );
00064 
00065   MESH *mesh1=new MESH(MED_DRIVER, argv[1], mesh_name1.data());
00066   MESH *mesh2=new MESH(MED_DRIVER, argv[2], mesh_name2.data());
00067 
00068   MEDMEM_REMAPPER aREMAPPER;
00069   aREMAPPER.prepare( *mesh1, *mesh2, "P0P0" );
00070   aREMAPPER.printMatrixInfo();
00071   mesh1->removeReference();
00072   mesh2->removeReference();
00073   return 0;
00074 }