1 // Copyright (C) 2007-2012 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 void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
54 const ParaMEDMEM::MEDCouplingMesh *getMesh() const { return _mesh; }
55 void setName(const char *name) { _name=name; }
56 const char *getDescription() const { return _desc.c_str(); }
57 void setDescription(const char *desc) { _desc=desc; }
58 const char *getName() const { return _name.c_str(); }
59 TypeOfField getTypeOfField() const;
60 NatureOfField getNature() const;
61 virtual void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
62 DataArrayDouble *getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception);
63 MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
64 MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const;
65 DataArrayInt *computeTupleIdsToSelectFromCellIds(const int *startCellIds, const int *endCellIds) const;
66 const MEDCouplingFieldDiscretization *getDiscretization() const { return _type; }
67 MEDCouplingFieldDiscretization *getDiscretization() { return _type; }
68 int getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception);
69 int getNumberOfMeshPlacesExpected() const throw(INTERP_KERNEL::Exception);
70 // Gauss point specific methods
71 void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
72 const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
73 void setGaussLocalizationOnCells(const int *begin, const int *end, const std::vector<double>& refCoo,
74 const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
75 void clearGaussLocalizations();
76 MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
77 int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
78 int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
79 int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
80 void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
81 const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
82 void updateTime() const;
84 MEDCouplingField(TypeOfField type);
85 MEDCouplingField(const MEDCouplingField& other);
86 MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature=NoNature);
87 virtual ~MEDCouplingField();
91 NatureOfField _nature;
92 const MEDCouplingMesh *_mesh;
93 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDiscretization> _type;