Salome HOME
Ready to detach trio part.
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingGaussLocalization.cxx
index eae9beab48a823397d28176d7da4836808c06668..327013db9335f8aa8aa280a12969145b6e340612 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,6 +16,7 @@
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+// Author : Anthony Geay (CEA/DEN)
 
 #include "MEDCouplingGaussLocalization.hxx"
 #include "CellModel.hxx"
 #include <algorithm>
 
 ParaMEDMEM::MEDCouplingGaussLocalization::MEDCouplingGaussLocalization(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
-                                                                       const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
+                                                                       const std::vector<double>& gsCoo, const std::vector<double>& w)
 try:_type(type),_ref_coord(refCoo),_gauss_coord(gsCoo),_weight(w)
-  {
-    checkCoherency();
-  }
+{
+  checkCoherency();
+}
 catch(INTERP_KERNEL::Exception& e)
-  {
+{
     _type=INTERP_KERNEL::NORM_ERROR;
     _ref_coord.clear();
     _gauss_coord.clear();
     _weight.clear();
     throw e;
-  }
+}
+
+ParaMEDMEM::MEDCouplingGaussLocalization::MEDCouplingGaussLocalization(INTERP_KERNEL::NormalizedCellType typ)
+try:_type(typ)
+{
+  INTERP_KERNEL::CellModel::GetCellModel(_type);
+}
+catch(INTERP_KERNEL::Exception& e)
+{
+    _type=INTERP_KERNEL::NORM_ERROR;
+    throw e;
+}
 
-void ParaMEDMEM::MEDCouplingGaussLocalization::checkCoherency() const throw(INTERP_KERNEL::Exception)
+void ParaMEDMEM::MEDCouplingGaussLocalization::setType(INTERP_KERNEL::NormalizedCellType typ)
+{
+  INTERP_KERNEL::CellModel::GetCellModel(typ);//throws if not found. This is a check
+  _type=typ;
+}
+
+void ParaMEDMEM::MEDCouplingGaussLocalization::checkCoherency() const
 {
   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type);
   int nbNodes=cm.getNumberOfNodes();
@@ -56,8 +74,8 @@ void ParaMEDMEM::MEDCouplingGaussLocalization::checkCoherency() const throw(INTE
     }
   if(_gauss_coord.size()!=dim*_weight.size())
     {
-       std::ostringstream oss; oss << "Invalid gsCoo size and weight size : gsCoo.size() must be equal to _weight.size() * " << dim << " (dim) !";
-       throw INTERP_KERNEL::Exception(oss.str().c_str());
+      std::ostringstream oss; oss << "Invalid gsCoo size and weight size : gsCoo.size() must be equal to _weight.size() * " << dim << " (dim) !";
+      throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
 }
 
@@ -86,6 +104,15 @@ std::string ParaMEDMEM::MEDCouplingGaussLocalization::getStringRepr() const
   return oss.str();
 }
 
+std::size_t ParaMEDMEM::MEDCouplingGaussLocalization::getMemorySize() const
+{
+  std::size_t ret=0;
+  ret+=_ref_coord.capacity()*sizeof(double);
+  ret+=_gauss_coord.capacity()*sizeof(double);
+  ret+=_weight.capacity()*sizeof(double);
+  return ret;
+}
+
 bool ParaMEDMEM::MEDCouplingGaussLocalization::isEqual(const MEDCouplingGaussLocalization& other, double eps) const
 {
   if(_type!=other._type)
@@ -99,7 +126,7 @@ bool ParaMEDMEM::MEDCouplingGaussLocalization::isEqual(const MEDCouplingGaussLoc
   return true;
 }
 
-double ParaMEDMEM::MEDCouplingGaussLocalization::getRefCoord(int ptIdInCell, int comp) const throw(INTERP_KERNEL::Exception)
+double ParaMEDMEM::MEDCouplingGaussLocalization::getRefCoord(int ptIdInCell, int comp) const
 {
   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type);
   int nbNodes=cm.getNumberOfNodes();
@@ -111,13 +138,13 @@ double ParaMEDMEM::MEDCouplingGaussLocalization::getRefCoord(int ptIdInCell, int
   return _ref_coord[ptIdInCell*dim+comp];
 }
 
-double ParaMEDMEM::MEDCouplingGaussLocalization::getGaussCoord(int gaussPtIdInCell, int comp) const throw(INTERP_KERNEL::Exception)
+double ParaMEDMEM::MEDCouplingGaussLocalization::getGaussCoord(int gaussPtIdInCell, int comp) const
 {
   int dim=checkCoherencyOfRequest(gaussPtIdInCell,comp);
   return _gauss_coord[gaussPtIdInCell*dim+comp];
 }
 
-double ParaMEDMEM::MEDCouplingGaussLocalization::getWeight(int gaussPtIdInCell, double newVal) const throw(INTERP_KERNEL::Exception)
+double ParaMEDMEM::MEDCouplingGaussLocalization::getWeight(int gaussPtIdInCell, double newVal) const
 {
   checkCoherencyOfRequest(gaussPtIdInCell,0);
   return _weight[gaussPtIdInCell];
@@ -169,7 +196,7 @@ const double *ParaMEDMEM::MEDCouplingGaussLocalization::fillWithValues(const dou
  * This method sets the comp_th component of ptIdInCell_th point coordinate of reference element of type this->_type.
  * @throw if not 0<=ptIdInCell<nbOfNodePerCell or if not 0<=comp<dim
  */
-void ParaMEDMEM::MEDCouplingGaussLocalization::setRefCoord(int ptIdInCell, int comp, double newVal) throw(INTERP_KERNEL::Exception)
+void ParaMEDMEM::MEDCouplingGaussLocalization::setRefCoord(int ptIdInCell, int comp, double newVal)
 {
   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type);
   int nbNodes=cm.getNumberOfNodes();
@@ -181,18 +208,33 @@ void ParaMEDMEM::MEDCouplingGaussLocalization::setRefCoord(int ptIdInCell, int c
   _ref_coord[ptIdInCell*dim+comp]=newVal;
 }
 
-void ParaMEDMEM::MEDCouplingGaussLocalization::setGaussCoord(int gaussPtIdInCell, int comp, double newVal) throw(INTERP_KERNEL::Exception)
+void ParaMEDMEM::MEDCouplingGaussLocalization::setGaussCoord(int gaussPtIdInCell, int comp, double newVal)
 {
   int dim=checkCoherencyOfRequest(gaussPtIdInCell,comp);
   _gauss_coord[gaussPtIdInCell*dim+comp]=newVal;
 }
 
-void ParaMEDMEM::MEDCouplingGaussLocalization::setWeight(int gaussPtIdInCell, double newVal) throw(INTERP_KERNEL::Exception)
+void ParaMEDMEM::MEDCouplingGaussLocalization::setWeight(int gaussPtIdInCell, double newVal)
 {
   checkCoherencyOfRequest(gaussPtIdInCell,0);
   _weight[gaussPtIdInCell]=newVal;
 }
 
+void ParaMEDMEM::MEDCouplingGaussLocalization::setRefCoords(const std::vector<double>& refCoo)
+{
+  _ref_coord=refCoo;
+}
+
+void ParaMEDMEM::MEDCouplingGaussLocalization::setGaussCoords(const std::vector<double>& gsCoo)
+{
+  _gauss_coord=gsCoo;
+}
+
+void ParaMEDMEM::MEDCouplingGaussLocalization::setWeights(const std::vector<double>& w)
+{
+  _weight=w;
+}
+
 /*!
  * The format of 'tinyData' parameter is the same than pushed in method ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo.
  */
@@ -202,7 +244,7 @@ ParaMEDMEM::MEDCouplingGaussLocalization ParaMEDMEM::MEDCouplingGaussLocalizatio
   return ParaMEDMEM::MEDCouplingGaussLocalization((INTERP_KERNEL::NormalizedCellType)tinyData[0],v1,v2,v3);
 }
 
-int ParaMEDMEM::MEDCouplingGaussLocalization::checkCoherencyOfRequest(int gaussPtIdInCell, int comp) const throw(INTERP_KERNEL::Exception)
+int ParaMEDMEM::MEDCouplingGaussLocalization::checkCoherencyOfRequest(int gaussPtIdInCell, int comp) const
 {
   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type);
   int dim=cm.getDimension();