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
21 #include "MEDCouplingAMRAttribute.hxx"
22 #include "MEDCouplingMemArray.hxx"
24 using namespace ParaMEDMEM;
26 DataArrayDoubleCollection *DataArrayDoubleCollection::New(const std::vector< std::pair<std::string,int> >& fieldNames)
28 return new DataArrayDoubleCollection(fieldNames);
31 void DataArrayDoubleCollection::allocTuples(int nbOfTuples)
33 std::size_t sz(_arrs.size());
34 for(std::size_t i=0;i<sz;i++)
35 _arrs[i]->reAlloc(nbOfTuples);
38 void DataArrayDoubleCollection::dellocTuples()
40 std::size_t sz(_arrs.size());
41 for(std::size_t i=0;i<sz;i++)
45 DataArrayDoubleCollection::DataArrayDoubleCollection(const std::vector< std::pair<std::string,int> >& fieldNames):_arrs(fieldNames.size())
47 std::size_t sz(fieldNames.size());
48 std::vector<std::string> names(sz);
49 for(std::size_t i=0;i<sz;i++)
51 const std::pair<std::string,int>& info(fieldNames[i]);
52 _arrs[i]=DataArrayDouble::New();
53 _arrs[i]->alloc(0,info.second);
54 _arrs[i]->setName(info.first);
57 CheckDiscriminantNames(names);
60 std::size_t DataArrayDoubleCollection::getHeapMemorySizeWithoutChildren() const
62 std::size_t ret(sizeof(DataArrayDoubleCollection));
63 ret+=_arrs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>);
67 std::vector<const BigMemoryObject *> DataArrayDoubleCollection::getDirectChildren() const
69 std::vector<const BigMemoryObject *> ret;
70 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> >::const_iterator it=_arrs.begin();it!=_arrs.end();it++)
72 const DataArrayDouble *pt(*it);
79 void DataArrayDoubleCollection::CheckDiscriminantNames(const std::vector<std::string>& names)
81 std::set<std::string> s(names.begin(),names.end());
82 if(s.size()!=names.size())
83 throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::CheckDiscriminantNames : The names of fields must be different each other ! It is not the case !");
86 std::size_t MEDCouplingGridCollection::getHeapMemorySizeWithoutChildren() const
88 std::size_t ret(sizeof(MEDCouplingGridCollection));
89 ret+=_map_of_dadc.capacity()*sizeof(std::pair<MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> >);
93 std::vector<const BigMemoryObject *> MEDCouplingGridCollection::getDirectChildren() const
95 std::vector<const BigMemoryObject *> ret;
96 for(std::vector< std::pair<MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++)
98 const DataArrayDoubleCollection *col((*it).second);
105 MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames)
107 return new MEDCouplingAMRAttribute(gf,fieldNames);
110 void MEDCouplingAMRAttribute::alloc()
115 void MEDCouplingAMRAttribute::dealloc()
119 bool MEDCouplingAMRAttribute::changeGodFather(MEDCouplingCartesianAMRMesh *gf)
121 bool ret(MEDCouplingDataForGodFather::changeGodFather(gf));
125 std::size_t MEDCouplingAMRAttribute::getHeapMemorySizeWithoutChildren() const
127 std::size_t ret(sizeof(MEDCouplingAMRAttribute));
131 std::vector<const BigMemoryObject *> MEDCouplingAMRAttribute::getDirectChildren() const
133 return std::vector<const BigMemoryObject *>();
136 void MEDCouplingAMRAttribute::updateTime() const
140 MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames):MEDCouplingDataForGodFather(gf)