1 // Copyright (C) 2007-2016 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 : Yann Pora (EDF R&D)
21 #include "MEDCouplingFieldInt.hxx"
22 #include "MEDCouplingFieldTemplate.hxx"
23 #include "MEDCouplingMesh.hxx"
25 using namespace MEDCoupling;
27 MEDCouplingFieldInt *MEDCouplingFieldInt::New(TypeOfField type, TypeOfTimeDiscretization td)
29 return new MEDCouplingFieldInt(type,td);
32 MEDCouplingFieldInt *MEDCouplingFieldInt::New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td)
34 return new MEDCouplingFieldInt(ft,td);
37 void MEDCouplingFieldInt::checkConsistencyLight() const
39 MEDCouplingField::checkConsistencyLight();
40 _time_discr->checkConsistencyLight();
41 _type->checkCoherencyBetween(_mesh,getArray());
44 std::string MEDCouplingFieldInt::simpleRepr() const
46 std::ostringstream ret;
47 ret << "FieldInt with name : \"" << getName() << "\"\n";
48 ret << "Description of field is : \"" << getDescription() << "\"\n";
50 { ret << "FieldInt space discretization is : " << _type->getStringRepr() << "\n"; }
52 { ret << "FieldInt has no spatial discretization !\n"; }
54 { ret << "FieldInt time discretization is : " << _time_discr->getStringRepr() << "\n"; }
56 { ret << "FieldInt has no time discretization !\n"; }
57 ret << "FieldInt nature of field is : \"" << MEDCouplingNatureOfField::GetReprNoThrow(_nature) << "\"\n";
60 if(getArray()->isAllocated())
62 int nbOfCompo=getArray()->getNumberOfComponents();
63 ret << "FieldInt default array has " << nbOfCompo << " components and " << getArray()->getNumberOfTuples() << " tuples.\n";
64 ret << "FieldInt default array has following info on components : ";
65 for(int i=0;i<nbOfCompo;i++)
66 ret << "\"" << getArray()->getInfoOnComponent(i) << "\" ";
71 ret << "Array set but not allocated !\n";
75 ret << "Mesh support information :\n__________________________\n" << _mesh->simpleRepr();
77 ret << "Mesh support information : No mesh set !\n";
81 void MEDCouplingFieldInt::reprQuickOverview(std::ostream& stream) const
85 void MEDCouplingFieldInt::setTimeUnit(const std::string& unit)
87 _time_discr->setTimeUnit(unit);
90 std::string MEDCouplingFieldInt::getTimeUnit() const
92 return _time_discr->getTimeUnit();
95 void MEDCouplingFieldInt::setTime(double val, int iteration, int order)
97 _time_discr->setTime(val,iteration,order);
100 double MEDCouplingFieldInt::getTime(int& iteration, int& order) const
102 return _time_discr->getTime(iteration,order);
105 void MEDCouplingFieldInt::setArray(DataArrayInt *array)
107 _time_discr->setArray(array,this);
110 const DataArrayInt *MEDCouplingFieldInt::getArray() const
112 return _time_discr->getArray();
115 DataArrayInt *MEDCouplingFieldInt::getArray()
117 return _time_discr->getArray();
120 MEDCouplingFieldInt::MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),_time_discr(MEDCouplingTimeDiscretizationInt::New(td))
124 MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldInt& other, bool deepCopy):MEDCouplingField(other,deepCopy),_time_discr(dynamic_cast<MEDCouplingTimeDiscretizationInt *>(other._time_discr->performCopyOrIncrRef(deepCopy)))
128 MEDCouplingFieldInt::MEDCouplingFieldInt(NatureOfField n, MEDCouplingTimeDiscretizationInt *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type,n),_time_discr(td)
132 MEDCouplingFieldInt::~MEDCouplingFieldInt()
138 * ** WARINING : This method do not deeply copy neither mesh nor spatial discretization. Only a shallow copy (reference) is done for mesh and spatial discretization ! **
140 MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td):MEDCouplingField(ft,false),_time_discr(MEDCouplingTimeDiscretizationInt::New(td))