Back to index

salome-med  6.5.0
ParaGRID.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "ParaGRID.hxx"
00021 #include "Topology.hxx"
00022 #include "BlockTopology.hxx"
00023 #include "MEDCouplingMemArray.hxx"
00024 #include "MEDCouplingCMesh.hxx"
00025 #include "InterpKernelUtilities.hxx"
00026 
00027 #include <iostream>
00028 
00029 using namespace std;
00030 
00031 namespace ParaMEDMEM
00032 {
00033   
00034   ParaGRID::ParaGRID(MEDCouplingCMesh* global_grid, Topology* topology) throw(INTERP_KERNEL::Exception)
00035   {
00036   
00037     _block_topology = dynamic_cast<BlockTopology*>(topology);
00038     if(_block_topology==0)
00039       throw INTERP_KERNEL::Exception(LOCALIZED("ParaGRID::ParaGRID topology must be block topology"));
00040     
00041     if (!_block_topology->getProcGroup()->containsMyRank())
00042       return;
00043     
00044     int dimension=_block_topology->getDimension() ;
00045     if (dimension != global_grid->getSpaceDimension())
00046       throw INTERP_KERNEL::Exception(LOCALIZED("ParaGrid::ParaGrid incompatible topology"));
00047     _grid=global_grid;
00048     _grid->incrRef();
00049     /*vector<vector<double> > xyz_array(dimension);
00050       vector<pair<int,int> > local_indices = _block_topology->getLocalArrayMinMax();
00051       vector <string> coordinates_names;
00052       vector <string> coordinates_units;
00053       for (int idim=0; idim<dimension ; idim++)
00054       {
00055       DataArrayDouble *array=global_grid->getCoordsAt(idim);
00056       double *arrayC=array->getPointer();
00057       cout << " Indices "<< local_indices[idim].first <<" "<<local_indices[idim].second<<endl;
00058       for (int i=(local_indices)[idim].first; i<(local_indices)[idim].second; i++)
00059       xyz_array[idim].push_back(arrayC[i]);
00060       coordinates_names.push_back(array->getName());
00061       coordinates_units.push_back(array->getInfoOnComponentAt(0));
00062       }
00063       _grid=MEDCouplingCMesh::New();
00064       _grid->set(xyz_array, coordinates_names,coordinates_units);
00065       _grid->setName(global_grid->getName());
00066       _grid->setDescription(global_grid->getDescription());*/
00067   }
00068 
00069   ParaGRID::~ParaGRID()
00070   {
00071     if(_grid)
00072       _grid->decrRef();
00073   }
00074 }