1 // Copyright (C) 2007-2014 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_MEDCOUPLINGFIELD_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGFIELD_HXX__
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingTimeLabel.hxx"
26 #include "MEDCouplingNatureOfField.hxx"
27 #include "MEDCouplingRefCountObject.hxx"
28 #include "NormalizedUnstructuredMesh.hxx"
29 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
31 #include "InterpKernelException.hxx"
39 class DataArrayDouble;
40 class MEDCouplingMesh;
41 class MEDCouplingFieldDouble;
42 class MEDCouplingGaussLocalization;
44 class MEDCouplingField : public RefCountObject, public TimeLabel
47 MEDCOUPLING_EXPORT virtual void checkCoherency() const = 0;
48 MEDCOUPLING_EXPORT virtual bool areCompatibleForMerge(const MEDCouplingField *other) const;
49 MEDCOUPLING_EXPORT virtual bool areStrictlyCompatible(const MEDCouplingField *other) const;
50 MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const;
51 MEDCOUPLING_EXPORT virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
52 MEDCOUPLING_EXPORT virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
53 MEDCOUPLING_EXPORT virtual void copyTinyStringsFrom(const MEDCouplingField *other);
54 MEDCOUPLING_EXPORT void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
55 MEDCOUPLING_EXPORT const ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _mesh; }
56 MEDCOUPLING_EXPORT ParaMEDMEM::MEDCouplingMesh *getMesh() { return const_cast<ParaMEDMEM::MEDCouplingMesh *>(_mesh); }
57 MEDCOUPLING_EXPORT void setName(const std::string& name) { _name=name; }
58 MEDCOUPLING_EXPORT std::string getDescription() const { return _desc; }
59 MEDCOUPLING_EXPORT void setDescription(const std::string& desc) { _desc=desc; }
60 MEDCOUPLING_EXPORT std::string getName() const { return _name; }
61 MEDCOUPLING_EXPORT TypeOfField getTypeOfField() const;
62 MEDCOUPLING_EXPORT NatureOfField getNature() const;
63 MEDCOUPLING_EXPORT virtual void setNature(NatureOfField nat);
64 MEDCOUPLING_EXPORT DataArrayDouble *getLocalizationOfDiscr() const;
65 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const;
66 MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const;
67 MEDCOUPLING_EXPORT MEDCouplingMesh *buildSubMeshDataRange(int begin, int end, int step, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const;
68 MEDCOUPLING_EXPORT DataArrayInt *computeTupleIdsToSelectFromCellIds(const int *startCellIds, const int *endCellIds) const;
69 MEDCOUPLING_EXPORT const MEDCouplingFieldDiscretization *getDiscretization() const { return _type; }
70 MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization *getDiscretization() { return _type; }
71 MEDCOUPLING_EXPORT void setDiscretization(MEDCouplingFieldDiscretization *newDisc);
72 MEDCOUPLING_EXPORT int getNumberOfTuplesExpected() const;
73 MEDCOUPLING_EXPORT int getNumberOfMeshPlacesExpected() const;
74 // Gauss point specific methods
75 MEDCOUPLING_EXPORT void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
76 const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
77 MEDCOUPLING_EXPORT void setGaussLocalizationOnCells(const int *begin, const int *end, const std::vector<double>& refCoo,
78 const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
79 MEDCOUPLING_EXPORT void clearGaussLocalizations();
80 MEDCOUPLING_EXPORT MEDCouplingGaussLocalization& getGaussLocalization(int locId);
81 MEDCOUPLING_EXPORT int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const;
82 MEDCOUPLING_EXPORT std::set<int> getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const;
83 MEDCOUPLING_EXPORT int getNbOfGaussLocalization() const;
84 MEDCOUPLING_EXPORT int getGaussLocalizationIdOfOneCell(int cellId) const;
85 MEDCOUPLING_EXPORT void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const;
86 MEDCOUPLING_EXPORT const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const;
87 MEDCOUPLING_EXPORT void updateTime() const;
88 MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
89 MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
91 MEDCOUPLING_EXPORT int getNumberOfTuplesExpectedRegardingCode(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const;
92 MEDCOUPLING_EXPORT virtual void reprQuickOverview(std::ostream& stream) const = 0;
94 MEDCOUPLING_EXPORT MEDCouplingField(TypeOfField type);
95 MEDCOUPLING_EXPORT MEDCouplingField(const MEDCouplingField& other, bool deepCopy=true);
96 MEDCOUPLING_EXPORT MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature=NoNature);
97 MEDCOUPLING_EXPORT virtual ~MEDCouplingField();
101 NatureOfField _nature;
102 const MEDCouplingMesh *_mesh;
103 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDiscretization> _type;