Back to index

salome-med  6.5.0
MEDCouplingFieldDiscretization.hxx
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 #ifndef __PARAMEDMEM_MEDCOUPLINGFIELDDISCRETIZATION_HXX__
00021 #define __PARAMEDMEM_MEDCOUPLINGFIELDDISCRETIZATION_HXX__
00022 
00023 #include "MEDCoupling.hxx"
00024 #include "MEDCouplingRefCountObject.hxx"
00025 #include "InterpKernelException.hxx"
00026 #include "MEDCouplingTimeLabel.hxx"
00027 #include "MEDCouplingNatureOfField.hxx"
00028 #include "MEDCouplingGaussLocalization.hxx"
00029 
00030 #include <vector>
00031 
00032 namespace ParaMEDMEM
00033 {
00034   class DataArrayInt;
00035   class MEDCouplingMesh;
00036   class DataArrayDouble;
00037   class MEDCouplingFieldDouble;
00038 
00039   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization : public TimeLabel
00040   {
00041   public:
00042     static MEDCouplingFieldDiscretization *New(TypeOfField type);
00043     double getPrecision() const { return _precision; }
00044     void setPrecision(double val) { _precision=val; }
00045     void updateTime() const;
00046     static TypeOfField getTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception);
00047     virtual TypeOfField getEnum() const = 0;
00048     virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const = 0;
00049     virtual bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
00050     virtual MEDCouplingFieldDiscretization *clone() const = 0;
00051     virtual std::string getStringRepr() const = 0;
00052     virtual const char *getRepr() const = 0;
00053     virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0;
00054     virtual int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const = 0;
00055     virtual DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const = 0;
00056     virtual void normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception);
00057     virtual void normL2(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception);
00058     virtual void integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception);
00059     virtual DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const = 0;
00060     virtual void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
00061                                                     DataArrayInt *&cellRest) = 0;
00062     virtual void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception) = 0;
00063     virtual void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
00064     virtual void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
00065                                        const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) = 0;
00066     virtual double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
00067     virtual void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) = 0;
00068     virtual MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const = 0;
00069     virtual void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const = 0;
00070     virtual void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const = 0;
00071     virtual DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const = 0;
00072     virtual MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const = 0;
00073     virtual void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const = 0;
00074     virtual void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const = 0;
00075     virtual void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const = 0;
00076     virtual void getSerializationIntArray(DataArrayInt *& arr) const;
00077     virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
00078     virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
00079     virtual void finishUnserialization(const std::vector<double>& tinyInfo);
00080     virtual void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr);
00081     virtual void setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
00082                                             const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
00083     virtual void setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector<double>& refCoo,
00084                                              const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
00085     virtual void clearGaussLocalizations() throw(INTERP_KERNEL::Exception);
00086     virtual MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
00087     virtual int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
00088     virtual int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
00089     virtual int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
00090     virtual void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
00091     virtual const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
00092     virtual ~MEDCouplingFieldDiscretization();
00093   protected:
00094     MEDCouplingFieldDiscretization();
00095     static void renumberEntitiesFromO2NArr(double epsOnVals, const int *old2NewPtr, DataArrayDouble *arr, const char *msg);
00096     static void renumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg);
00097   protected:
00098     double _precision;
00099     static const double DFLT_PRECISION;
00100   };
00101 
00102   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationP0 : public MEDCouplingFieldDiscretization
00103   {
00104   public:
00105     TypeOfField getEnum() const;
00106     MEDCouplingFieldDiscretization *clone() const;
00107     std::string getStringRepr() const;
00108     const char *getRepr() const;
00109     bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
00110     int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
00111     int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
00112     DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
00113     void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
00114                                const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
00115     DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
00116     void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
00117     void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
00118                                             DataArrayInt *&cellRest);
00119     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
00120     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
00121     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
00122     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
00123     DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
00124     void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
00125     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
00126     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
00127     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
00128   public:
00129     static const char REPR[];
00130     static const TypeOfField TYPE;
00131   };
00132 
00133   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationP1 : public MEDCouplingFieldDiscretization
00134   {
00135   public:
00136     TypeOfField getEnum() const;
00137     MEDCouplingFieldDiscretization *clone() const;
00138     std::string getStringRepr() const;
00139     const char *getRepr() const;
00140     bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
00141     int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
00142     int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
00143     DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
00144     void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
00145                                const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
00146     DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
00147     void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
00148                                             DataArrayInt *&cellRest);
00149     void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
00150     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
00151     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
00152     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
00153     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
00154     DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
00155     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
00156     void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
00157     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
00158     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
00159   protected:
00160     void getValueInCell(const MEDCouplingMesh *mesh, int cellId, const DataArrayDouble *arr, const double *loc, double *res) const;
00161   public:
00162     static const char REPR[];
00163     static const TypeOfField TYPE;
00164   };
00165 
00170   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationPerCell : public MEDCouplingFieldDiscretization
00171   {
00172   public:
00173     const DataArrayInt *getArrayOfDiscIds() const;
00174   protected:
00175     MEDCouplingFieldDiscretizationPerCell();
00176     MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other);
00177     ~MEDCouplingFieldDiscretizationPerCell();
00178     void updateTime() const;
00179     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
00180     bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
00181     bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
00182     void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
00183     void checkNoOrphanCells() const throw(INTERP_KERNEL::Exception);
00184   protected:
00185     void buildDiscrPerCellIfNecessary(const MEDCouplingMesh *m);
00186   protected:
00187     DataArrayInt *_discr_per_cell;
00188     static const int DFT_INVALID_LOCID_VALUE;
00189   };
00190 
00191   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGauss : public MEDCouplingFieldDiscretizationPerCell
00192   {
00193   public:
00194     MEDCouplingFieldDiscretizationGauss();
00195     TypeOfField getEnum() const;
00196     bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
00197     bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
00198     MEDCouplingFieldDiscretization *clone() const;
00199     std::string getStringRepr() const;
00200     const char *getRepr() const;
00201     int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
00202     int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
00203     DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
00204     void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
00205                                const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
00206     DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
00207     void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
00208                                             DataArrayInt *&cellRest);
00209     void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
00210     void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
00211     void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
00212     void finishUnserialization(const std::vector<double>& tinyInfo);
00213     void getSerializationIntArray(DataArrayInt *& arr) const;
00214     void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr);
00215     double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
00216     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
00217     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
00218     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
00219     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
00220     DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
00221     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
00222     void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
00223     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
00224     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
00225     void setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
00226                                     const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
00227     void setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector<double>& refCoo,
00228                                      const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
00229     void clearGaussLocalizations() throw(INTERP_KERNEL::Exception);
00230     MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
00231     int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
00232     int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
00233     int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
00234     void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
00235     const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
00236     std::vector<DataArrayInt *> splitIntoSingleGaussDicrPerCellType(std::vector< std::vector<int> >& locIds) const throw(INTERP_KERNEL::Exception);
00237     DataArrayInt *buildNbOfGaussPointPerCellField() const throw(INTERP_KERNEL::Exception);
00238   protected:
00239     MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other);
00240     void zipGaussLocalizations();
00241     int getOffsetOfCell(int cellId) const throw(INTERP_KERNEL::Exception);
00242     void checkLocalizationId(int locId) const throw(INTERP_KERNEL::Exception);
00243   public:
00244     static const char REPR[];
00245     static const TypeOfField TYPE;
00246   private:
00247     std::vector<MEDCouplingGaussLocalization> _loc;
00248   };
00249 
00253   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGaussNE : public MEDCouplingFieldDiscretization
00254   {
00255   public:
00256     MEDCouplingFieldDiscretizationGaussNE();
00257     TypeOfField getEnum() const;
00258     MEDCouplingFieldDiscretization *clone() const;
00259     std::string getStringRepr() const;
00260     const char *getRepr() const;
00261     bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
00262     int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
00263     int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
00264     DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
00265     void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
00266                                const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
00267     DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
00268     void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
00269                                             DataArrayInt *&cellRest);
00270     void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
00271     double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
00272     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
00273     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
00274     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
00275     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
00276     DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
00277     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
00278     void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
00279     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
00280     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
00281   protected:
00282     MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other);
00283   public:
00284     static const char REPR[];
00285     static const TypeOfField TYPE;
00286   };
00287 }
00288 
00289 #endif