1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __PARAMEDMEM_MEDCOUPLINGIMESH_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGIMESH_HXX__
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingStructuredMesh.hxx"
29 class MEDCouplingCMesh;
31 class MEDCouplingIMesh : public MEDCouplingStructuredMesh
34 MEDCOUPLING_EXPORT static MEDCouplingIMesh *New();
35 MEDCOUPLING_EXPORT static MEDCouplingIMesh *New(const std::string& meshName, int spaceDim, const mcIdType *nodeStrctStart, const mcIdType *nodeStrctStop,
36 const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
37 MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingIMesh"); }
39 MEDCOUPLING_EXPORT void setSpaceDimension(int spaceDim);
40 MEDCOUPLING_EXPORT void setNodeStruct(const mcIdType *nodeStrctStart, const mcIdType *nodeStrctStop);
41 MEDCOUPLING_EXPORT std::vector<mcIdType> getNodeStruct() const;
42 MEDCOUPLING_EXPORT void setOrigin(const double *originStart, const double *originStop);
43 MEDCOUPLING_EXPORT std::vector<double> getOrigin() const;
44 MEDCOUPLING_EXPORT void setDXYZ(const double *dxyzStart, const double *dxyzStop);
45 MEDCOUPLING_EXPORT std::vector<double> getDXYZ() const;
46 MEDCOUPLING_EXPORT void setAxisUnit(const std::string& unitName);
47 MEDCOUPLING_EXPORT std::string getAxisUnit() const;
48 MEDCOUPLING_EXPORT double getMeasureOfAnyCell() const;
49 MEDCOUPLING_EXPORT MEDCouplingCMesh *convertToCartesian() const;
50 MEDCOUPLING_EXPORT void refineWithFactor(const std::vector<mcIdType>& factors);
51 MEDCOUPLING_EXPORT MEDCouplingIMesh *asSingleCell() const;
52 MEDCOUPLING_EXPORT static void CondenseFineToCoarse(const std::vector<mcIdType>& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts, DataArrayDouble *coarseDA);
53 MEDCOUPLING_EXPORT static void CondenseFineToCoarseGhost(const std::vector<mcIdType>& coarseSt, const DataArrayDouble *fineDA, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts, DataArrayDouble *coarseDA, mcIdType ghostSize);
54 MEDCOUPLING_EXPORT static void SpreadCoarseToFine(const DataArrayDouble *coarseDA, const std::vector<mcIdType>& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts);
55 MEDCOUPLING_EXPORT static void SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, const std::vector<mcIdType>& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts, mcIdType ghostSize);
56 MEDCOUPLING_EXPORT static void SpreadCoarseToFineGhostZone(const DataArrayDouble *coarseDA, const std::vector<mcIdType>& coarseSt, DataArrayDouble *fineDA, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts, mcIdType ghostSize);
58 MEDCOUPLING_EXPORT MEDCouplingIMesh *deepCopy() const;
59 MEDCOUPLING_EXPORT MEDCouplingIMesh *clone(bool recDeepCpy) const;
60 MEDCOUPLING_EXPORT const DataArrayDouble *getDirectAccessOfCoordsArrIfInStructure() const;
61 MEDCOUPLING_EXPORT MEDCouplingIMesh *buildWithGhost(mcIdType ghostLev) const;
62 MEDCOUPLING_EXPORT void updateTime() const;
63 MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
64 MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
65 MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return IMAGE_GRID; }
66 MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other);
67 MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const;
68 MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
69 MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
70 DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const;
71 MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
72 DataArrayIdType *&cellCor) const;
73 MEDCOUPLING_EXPORT void checkConsistencyLight() const;
74 MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const;
75 MEDCOUPLING_EXPORT int getSpaceDimension() const;
76 MEDCOUPLING_EXPORT void getCoordinatesOfNode(mcIdType nodeId, std::vector<double>& coo) const;
77 MEDCOUPLING_EXPORT std::string simpleRepr() const;
78 MEDCOUPLING_EXPORT std::string advancedRepr() const;
80 MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const;
81 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
82 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
83 MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const;
84 MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector<mcIdType>& elts) const;
85 MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle);
86 MEDCOUPLING_EXPORT void translate(const double *vector);
87 MEDCOUPLING_EXPORT void scale(const double *point, double factor);
88 MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
89 MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const;
90 MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const;
91 MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
92 MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true);
94 MEDCOUPLING_EXPORT void getNodeGridStructure(mcIdType *res) const;
95 MEDCOUPLING_EXPORT std::vector<mcIdType> getNodeGridStructure() const;
96 MEDCouplingStructuredMesh *buildStructuredSubPart(const std::vector< std::pair<mcIdType,mcIdType> >& cellPart) const;
97 //serialisation-unserialization
98 MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<mcIdType>& tinyInfo, std::vector<std::string>& littleStrings) const;
99 MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<mcIdType>& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
100 MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const;
101 MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<mcIdType>& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2,
102 const std::vector<std::string>& littleStrings);
103 MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
104 MEDCOUPLING_EXPORT std::string getVTKFileExtension() const;
107 MEDCouplingIMesh(const MEDCouplingIMesh& other, bool deepCopy);
109 void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const;
110 std::string getVTKDataSetType() const;
111 bool isEqualWithoutConsideringStrInternal(const MEDCouplingMesh *other, double prec, std::string& reason) const;
112 std::vector<std::string> buildInfoOnComponents() const;
113 void checkSpaceDimension() const;
114 static void CheckSpaceDimension(int spaceDim);
115 static int FindIntRoot(int val, int order);
116 static void SpreadCoarseToFineGhost2D(const double *inPtr, double *outPtr, std::size_t nbCompo, const std::vector<mcIdType>& coarseSt, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts, mcIdType ghostSize);
117 static void SpreadCoarseToFineGhostZone2D(const double *inPtr, double *outPtr, std::size_t nbCompo, const std::vector<mcIdType>& coarseSt, const std::vector< std::pair<mcIdType,mcIdType> >& fineLocInCoarse, const std::vector<mcIdType>& facts, mcIdType ghostSize);
122 mcIdType _structure[3];
123 std::string _axis_unit;