Salome HOME
3709cc6756938053c2f2bdfa02edd59e5cbaeb77
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingMappedExtrudedMesh.hxx
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __PARAMEDMEM_MEDCOUPLINGEXTRUDEDMESH_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGEXTRUDEDMESH_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingMesh.hxx"
26
27 #include <vector>
28
29 namespace MEDCoupling
30 {
31   class DataArrayIdType;
32   class DataArrayDouble;
33   class MEDCouplingUMesh;
34   class MEDCouplingCMesh;
35   class MEDCouplingFieldDouble;
36
37   class MEDCouplingMappedExtrudedMesh : public MEDCouplingMesh
38   {
39   public:
40     MEDCOUPLING_EXPORT static MEDCouplingMappedExtrudedMesh *New(const MEDCouplingUMesh *mesh3D, const MEDCouplingUMesh *mesh2D, mcIdType cell2DId);
41     MEDCOUPLING_EXPORT static MEDCouplingMappedExtrudedMesh *New(const MEDCouplingCMesh *mesh3D);
42     MEDCOUPLING_EXPORT static MEDCouplingMappedExtrudedMesh *New();
43     MEDCOUPLING_EXPORT std::string getClassName() const override { return std::string("MEDCouplingMappedExtrudedMesh"); }
44     MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const;
45     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
46     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
47     MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingMesh *other);
48     MEDCOUPLING_EXPORT mcIdType getNumberOfCells() const;
49     MEDCOUPLING_EXPORT mcIdType getNumberOfNodes() const;
50     MEDCOUPLING_EXPORT int getSpaceDimension() const;
51     MEDCOUPLING_EXPORT int getMeshDimension() const;
52     MEDCOUPLING_EXPORT MEDCouplingMappedExtrudedMesh *deepCopy() const;
53     MEDCOUPLING_EXPORT MEDCouplingMappedExtrudedMesh *clone(bool recDeepCpy) const;
54     MEDCOUPLING_EXPORT const DataArrayDouble *getDirectAccessOfCoordsArrIfInStructure() const;
55     MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const;
56     MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
57     MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
58                                                  DataArrayIdType *&cellCor, DataArrayIdType *&nodeCor) const;
59     MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
60                                                             DataArrayIdType *&cellCor) const;
61     MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(mcIdType cellId) const;
62     MEDCOUPLING_EXPORT std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
63     MEDCOUPLING_EXPORT DataArrayIdType *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
64     MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfNodesPerCell() const;
65     MEDCOUPLING_EXPORT DataArrayIdType *computeNbOfFacesPerCell() const;
66     MEDCOUPLING_EXPORT DataArrayIdType *computeEffectiveNbOfNodesPerCell() const;
67     MEDCOUPLING_EXPORT mcIdType getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
68     MEDCOUPLING_EXPORT void getNodeIdsOfCell(mcIdType cellId, std::vector<mcIdType>& conn) const;
69     MEDCOUPLING_EXPORT void getCoordinatesOfNode(mcIdType nodeId, std::vector<double>& coo) const;
70     MEDCOUPLING_EXPORT std::string simpleRepr() const;
71     MEDCOUPLING_EXPORT std::string advancedRepr() const;
72     MEDCOUPLING_EXPORT void checkConsistencyLight() const;
73     MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const;
74     MEDCOUPLING_EXPORT void getBoundingBox(double *bbox) const;
75     MEDCOUPLING_EXPORT void updateTime() const;
76     MEDCOUPLING_EXPORT void renumberCells(const mcIdType *old2NewBg, bool check=true);
77     MEDCOUPLING_EXPORT MEDCouplingUMesh *getMesh2D() const { return _mesh2D.iAmATrollConstCast(); }
78     MEDCOUPLING_EXPORT MEDCouplingUMesh *getMesh1D() const { return _mesh1D.iAmATrollConstCast(); }
79     MEDCOUPLING_EXPORT DataArrayIdType *getMesh3DIds() const { return _mesh3D_ids.iAmATrollConstCast(); }
80     MEDCOUPLING_EXPORT MEDCouplingUMesh *build3DUnstructuredMesh() const;
81     MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const;
82     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool) const;
83     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool) const;
84     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const;
85     MEDCOUPLING_EXPORT mcIdType getCellContainingPoint(const double *pos, double eps) const;
86     MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector<mcIdType>& elts) const;
87     MEDCOUPLING_EXPORT static mcIdType FindCorrespCellByNodalConn(const std::vector<mcIdType>& nodalConnec,
88                                                              const mcIdType *revNodalPtr, const mcIdType *revNodalIndxPtr);
89     MEDCOUPLING_EXPORT static void Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
90                                                    MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v);
91     MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle);
92     MEDCOUPLING_EXPORT void translate(const double *vector);
93     MEDCOUPLING_EXPORT void scale(const double *point, double factor);
94     MEDCOUPLING_EXPORT std::vector<mcIdType> getDistributionOfTypes() const;
95     MEDCOUPLING_EXPORT DataArrayIdType *checkTypeConsistencyAndContig(const std::vector<mcIdType>& code, const std::vector<const DataArrayIdType *>& idsPerType) const;
96     MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayIdType *profile, std::vector<mcIdType>& code, std::vector<DataArrayIdType *>& idsInPflPerType, std::vector<DataArrayIdType *>& idsPerType, bool smartPflKiller=true) const;
97     MEDCOUPLING_EXPORT MEDCouplingMesh *buildPart(const mcIdType *start, const mcIdType *end) const;
98     MEDCOUPLING_EXPORT MEDCouplingMesh *buildPartAndReduceNodes(const mcIdType *start, const mcIdType *end, DataArrayIdType*& arr) const;
99     MEDCOUPLING_EXPORT DataArrayIdType *simplexize(int policy);
100     MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
101     MEDCOUPLING_EXPORT DataArrayDouble *getCoordinatesAndOwner() const;
102     MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const;
103     MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const;
104     MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const;
105     //Serialization unserialisation
106     MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<mcIdType>& tinyInfo, std::vector<std::string>& littleStrings) const;
107     MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<mcIdType>& tinyInfo, DataArrayIdType *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
108     MEDCOUPLING_EXPORT void serialize(DataArrayIdType *&a1, DataArrayDouble *&a2) const;
109     MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<mcIdType>& tinyInfo, const DataArrayIdType *a1, DataArrayDouble *a2,
110                                             const std::vector<std::string>& littleStrings);
111     MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
112     MEDCOUPLING_EXPORT std::string getVTKFileExtension() const;
113     MEDCOUPLING_EXPORT mcIdType get2DCellIdForExtrusion() const { return _cell_2D_id; }
114   private:
115     MEDCouplingMappedExtrudedMesh(const MEDCouplingUMesh *mesh3D, const MEDCouplingUMesh *mesh2D, mcIdType cell2DId);
116     MEDCouplingMappedExtrudedMesh(const MEDCouplingCMesh *mesh3D);
117     MEDCouplingMappedExtrudedMesh(const MEDCouplingMappedExtrudedMesh& other, bool deepCpy);
118     MEDCouplingMappedExtrudedMesh();
119     void computeExtrusion(const MEDCouplingUMesh *mesh3D);
120     void computeExtrusionAlg(const MEDCouplingUMesh *mesh3D);
121     void build1DExtrusion(mcIdType idIn3DDesc, mcIdType newId, mcIdType nbOf1DLev, MEDCouplingUMesh *subMesh,
122                           const mcIdType *desc3D, const mcIdType *descIndx3D,
123                           const mcIdType *revDesc3D, const mcIdType *revDescIndx3D,
124                           bool computeMesh1D);
125     mcIdType findOppositeFaceOf(mcIdType current2DCell, mcIdType current3DCell, const std::vector<mcIdType>& connSorted,
126                            const mcIdType *desc3D, const mcIdType *descIndx3D,
127                            const mcIdType *conn2D, const mcIdType *conn2DIndx);
128     void computeBaryCenterOfFace(const std::vector<mcIdType>& nodalConnec, mcIdType lev1DId);
129     ~MEDCouplingMappedExtrudedMesh();
130     void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const;
131     std::string getVTKDataSetType() const;
132   private:
133     MCAuto<MEDCouplingUMesh> _mesh2D;
134     MCAuto<MEDCouplingUMesh> _mesh1D;
135     //! New to old 3D cell Ids Array
136     MCAuto<DataArrayIdType> _mesh3D_ids;
137     mcIdType _cell_2D_id;
138   };
139 }
140
141 #endif