1 // Copyright (C) 2007-2013 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.
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 MEDCOUPLING_EXPORT MEDCouplingField : public RefCountObject, public TimeLabel
47 virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0;
48 virtual bool areCompatibleForMerge(const MEDCouplingField *other) const;
49 virtual bool areStrictlyCompatible(const MEDCouplingField *other) const;
50 virtual bool isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const throw(INTERP_KERNEL::Exception);
51 virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
52 virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
53 virtual void copyTinyStringsFrom(const MEDCouplingField *other) throw(INTERP_KERNEL::Exception);
54 void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
55 const ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _mesh; }
56 void setName(const char *name) { _name=name; }
57 const char *getDescription() const { return _desc.c_str(); }
58 void setDescription(const char *desc) { _desc=desc; }
59 const char *getName() const { return _name.c_str(); }
60 TypeOfField getTypeOfField() const;
61 NatureOfField getNature() const;
62 virtual void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
63 DataArrayDouble *getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception);
64 MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
65 MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const;
66 DataArrayInt *computeTupleIdsToSelectFromCellIds(const int *startCellIds, const int *endCellIds) const;
67 const MEDCouplingFieldDiscretization *getDiscretization() const { return _type; }
68 MEDCouplingFieldDiscretization *getDiscretization() { return _type; }
69 void setDiscretization(MEDCouplingFieldDiscretization *newDisc);
70 int getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception);
71 int getNumberOfMeshPlacesExpected() const throw(INTERP_KERNEL::Exception);
72 // Gauss point specific methods
73 void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
74 const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
75 void setGaussLocalizationOnCells(const int *begin, const int *end, const std::vector<double>& refCoo,
76 const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
77 void clearGaussLocalizations();
78 MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
79 int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
80 std::set<int> getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
81 int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
82 int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
83 void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
84 const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
85 void updateTime() const;
86 std::size_t getHeapMemorySize() const;
88 MEDCouplingField(TypeOfField type);
89 MEDCouplingField(const MEDCouplingField& other, bool deepCopy=true);
90 MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature=NoNature);
91 virtual ~MEDCouplingField();
95 NatureOfField _nature;
96 const MEDCouplingMesh *_mesh;
97 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDiscretization> _type;