Version: 6.3.1

src/MEDCoupling/MEDCouplingFieldDiscretization.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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 const char *getStringRepr() const = 0;
00052     virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0;
00053     virtual int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const = 0;
00054     virtual DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const = 0;
00055     virtual void normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception);
00056     virtual void normL2(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const throw(INTERP_KERNEL::Exception);
00057     virtual void integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs, double *res) const throw(INTERP_KERNEL::Exception);
00058     virtual DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const = 0;
00059     virtual void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
00060                                                     DataArrayInt *&cellRest) = 0;
00061     virtual void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception) = 0;
00062     virtual void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
00063     virtual void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
00064                                        const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) = 0;
00065     virtual double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
00066     virtual void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) = 0;
00067     virtual MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const = 0;
00068     virtual void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const = 0;
00069     virtual void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const = 0;
00070     virtual DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const = 0;
00071     virtual MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const = 0;
00072     virtual void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const = 0;
00073     virtual void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const = 0;
00074     virtual void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const = 0;
00075     virtual void getSerializationIntArray(DataArrayInt *& arr) const;
00076     virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
00077     virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
00078     virtual void finishUnserialization(const std::vector<double>& tinyInfo);
00079     virtual void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr);
00080     virtual void setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
00081                                             const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
00082     virtual void setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector<double>& refCoo,
00083                                              const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
00084     virtual void clearGaussLocalizations() throw(INTERP_KERNEL::Exception);
00085     virtual MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
00086     virtual int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
00087     virtual int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
00088     virtual int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
00089     virtual void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
00090     virtual const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
00091     virtual ~MEDCouplingFieldDiscretization();
00092   protected:
00093     MEDCouplingFieldDiscretization();
00094     static void renumberEntitiesFromO2NArr(double epsOnVals, const int *old2NewPtr, DataArrayDouble *arr, const char *msg);
00095     static void renumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg);
00096   protected:
00097     double _precision;
00098     static const double DFLT_PRECISION;
00099   };
00100 
00101   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationP0 : public MEDCouplingFieldDiscretization
00102   {
00103   public:
00104     TypeOfField getEnum() const;
00105     MEDCouplingFieldDiscretization *clone() const;
00106     const char *getStringRepr() const;
00107     bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
00108     int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
00109     int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
00110     DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
00111     void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
00112                                const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
00113     DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
00114     void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
00115     void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
00116                                             DataArrayInt *&cellRest);
00117     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
00118     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
00119     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
00120     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
00121     DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
00122     void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
00123     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
00124     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
00125     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
00126   public:
00127     static const char REPR[];
00128     static const TypeOfField TYPE;
00129   };
00130 
00131   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationP1 : public MEDCouplingFieldDiscretization
00132   {
00133   public:
00134     TypeOfField getEnum() const;
00135     MEDCouplingFieldDiscretization *clone() const;
00136     const char *getStringRepr() const;
00137     bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
00138     int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
00139     int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
00140     DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
00141     void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
00142                                const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
00143     DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
00144     void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
00145                                             DataArrayInt *&cellRest);
00146     void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
00147     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
00148     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
00149     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
00150     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
00151     DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
00152     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
00153     void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
00154     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
00155     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
00156   protected:
00157     void getValueInCell(const MEDCouplingMesh *mesh, int cellId, const DataArrayDouble *arr, const double *loc, double *res) const;
00158   public:
00159     static const char REPR[];
00160     static const TypeOfField TYPE;
00161   };
00162 
00167   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationPerCell : public MEDCouplingFieldDiscretization
00168   {
00169   public:
00170     const DataArrayInt *getArrayOfDiscIds() const;
00171   protected:
00172     MEDCouplingFieldDiscretizationPerCell();
00173     MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other);
00174     ~MEDCouplingFieldDiscretizationPerCell();
00175     void updateTime() const;
00176     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
00177     bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
00178     bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
00179     void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
00180     void checkNoOrphanCells() const throw(INTERP_KERNEL::Exception);
00181   protected:
00182     void buildDiscrPerCellIfNecessary(const MEDCouplingMesh *m);
00183   protected:
00184     DataArrayInt *_discr_per_cell;
00185     static const int DFT_INVALID_LOCID_VALUE;
00186   };
00187 
00188   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGauss : public MEDCouplingFieldDiscretizationPerCell
00189   {
00190   public:
00191     MEDCouplingFieldDiscretizationGauss();
00192     TypeOfField getEnum() const;
00193     bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
00194     bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
00195     MEDCouplingFieldDiscretization *clone() const;
00196     const char *getStringRepr() const;
00197     int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
00198     int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
00199     DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
00200     void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
00201                                const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
00202     DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
00203     void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
00204                                             DataArrayInt *&cellRest);
00205     void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
00206     void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
00207     void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
00208     void finishUnserialization(const std::vector<double>& tinyInfo);
00209     void getSerializationIntArray(DataArrayInt *& arr) const;
00210     void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr);
00211     double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
00212     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
00213     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
00214     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
00215     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
00216     DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
00217     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
00218     void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
00219     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
00220     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
00221     void setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
00222                                     const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
00223     void setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector<double>& refCoo,
00224                                      const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
00225     void clearGaussLocalizations() throw(INTERP_KERNEL::Exception);
00226     MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
00227     int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
00228     int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
00229     int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
00230     void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
00231     const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
00232     std::vector<DataArrayInt *> splitIntoSingleGaussDicrPerCellType(std::vector< std::vector<int> >& locIds) const throw(INTERP_KERNEL::Exception);
00233     DataArrayInt *buildNbOfGaussPointPerCellField() const throw(INTERP_KERNEL::Exception);
00234   protected:
00235     MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other);
00236     void zipGaussLocalizations();
00237     int getOffsetOfCell(int cellId) const throw(INTERP_KERNEL::Exception);
00238     void checkLocalizationId(int locId) const throw(INTERP_KERNEL::Exception);
00239   public:
00240     static const char REPR[];
00241     static const TypeOfField TYPE;
00242   private:
00243     std::vector<MEDCouplingGaussLocalization> _loc;
00244   };
00245 
00249   class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGaussNE : public MEDCouplingFieldDiscretization
00250   {
00251   public:
00252     MEDCouplingFieldDiscretizationGaussNE();
00253     TypeOfField getEnum() const;
00254     MEDCouplingFieldDiscretization *clone() const;
00255     const char *getStringRepr() const;
00256     bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
00257     int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
00258     int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const;
00259     DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const;
00260     void renumberArraysForCell(const MEDCouplingMesh *mesh, const std::vector<DataArrayDouble *>& arrays,
00261                                const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
00262     DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const;
00263     void computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
00264                                             DataArrayInt *&cellRest);
00265     void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
00266     double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
00267     void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
00268     MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
00269     void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
00270     void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
00271     DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
00272     MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
00273     void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
00274     void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
00275     void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
00276   protected:
00277     MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other);
00278   public:
00279     static const char REPR[];
00280     static const TypeOfField TYPE;
00281   };
00282 }
00283 
00284 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS