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 : Anthony Geay (CEA/DEN)
21 #include "MEDCouplingField.hxx"
22 #include "MEDCouplingMesh.hxx"
23 #include "MEDCouplingFieldDiscretization.hxx"
27 using namespace MEDCoupling;
29 void MEDCouplingField::checkConsistencyLight() const
32 throw INTERP_KERNEL::Exception("Field invalid because no mesh specified !");
34 throw INTERP_KERNEL::Exception("MEDCouplingField::checkConsistencyLight : no spatial discretization !");
37 bool MEDCouplingField::isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const
40 throw INTERP_KERNEL::Exception("MEDCouplingField::isEqualIfNotWhy : other instance is NULL !");
41 std::ostringstream oss; oss.precision(15);
42 if(_name!=other->_name)
44 oss << "Field names differ : this name = \"" << _name << "\" and other name = \"" << other->_name << "\" !";
48 if(_desc!=other->_desc)
50 oss << "Field descriptions differ : this description = \"" << _desc << "\" and other description = \"" << other->_desc << "\" !";
54 if(_nature!=other->_nature)
56 oss << "Field nature differ : this nature = \"" << MEDCouplingNatureOfField::GetRepr(_nature) << "\" and other nature = \"" << MEDCouplingNatureOfField::GetRepr(other->_nature) << "\" !";
60 if(!_type->isEqualIfNotWhy(other->_type,valsPrec,reason))
62 reason.insert(0,"Spatial discretizations differ :");
65 if(_mesh==0 && other->_mesh==0)
67 if(_mesh==0 || other->_mesh==0)
69 reason="Only one field between the two this and other has its underlying mesh defined !";
72 if(_mesh==other->_mesh)
74 bool ret=_mesh->isEqualIfNotWhy(other->_mesh,meshPrec,reason);
76 reason.insert(0,"Underlying meshes of fields differ for the following reason : ");
81 * Checks if \a this and another MEDCouplingField are fully equal.
82 * \param [in] other - the field to compare with \a this one.
83 * \param [in] meshPrec - precision used to compare node coordinates of the underlying mesh.
84 * \param [in] valsPrec - precision used to compare field values.
85 * \return bool - \c true if the two fields are equal, \c false else.
86 * \throw If \a other is NULL.
88 bool MEDCouplingField::isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const
91 return isEqualIfNotWhy(other,meshPrec,valsPrec,tmp);
95 * Checks if \a this and another MEDCouplingField are equal. The textual
96 * information like names etc. is not considered.
97 * \param [in] other - the field to compare with \a this one.
98 * \param [in] meshPrec - precision used to compare node coordinates of the underlying mesh.
99 * \param [in] valsPrec - precision used to compare field values.
100 * \return bool - \c true if the two fields are equal, \c false else.
101 * \throw If \a other is NULL.
102 * \throw If the spatial discretization of \a this field is NULL.
104 bool MEDCouplingField::isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const
107 throw INTERP_KERNEL::Exception("MEDCouplingField::isEqualWithoutConsideringStr : input field is NULL !");
109 throw INTERP_KERNEL::Exception("MEDCouplingField::isEqualWithoutConsideringStr : spatial discretization of this is NULL !");
110 if(!_type->isEqualWithoutConsideringStr(other->_type,valsPrec))
112 if(_nature!=other->_nature)
114 if(_mesh==0 && other->_mesh==0)
116 if(_mesh==0 || other->_mesh==0)
118 if(_mesh==other->_mesh)
120 return _mesh->isEqualWithoutConsideringStr(other->_mesh,meshPrec);
124 * This method states if 'this' and 'other' are compatibles each other before performing any treatment.
125 * This method is good for methods like : mergeFields.
126 * This method is not very demanding compared to areStrictlyCompatible that is better for operation on fields.
128 bool MEDCouplingField::areCompatibleForMerge(const MEDCouplingField *other) const
131 throw INTERP_KERNEL::Exception("MEDCouplingField::areCompatibleForMerge : input field is NULL !");
132 if(!_type->isEqual(other->_type,1.))
134 if(_nature!=other->_nature)
136 if(_mesh==other->_mesh)
138 return _mesh->areCompatibleForMerge(other->_mesh);
142 * This method is more strict than MEDCouplingField::areCompatibleForMerge method.
143 * This method is used for operation on fields to operate a first check before attempting operation.
145 bool MEDCouplingField::areStrictlyCompatible(const MEDCouplingField *other) const
148 throw INTERP_KERNEL::Exception("MEDCouplingField::areStrictlyCompatible : input field is NULL !");
149 if(!_type->isEqual(other->_type,1.e-12))
151 if(_nature!=other->_nature)
153 return _mesh==other->_mesh;
157 * This method is less strict than MEDCouplingField::areStrictlyCompatible method.
158 * The difference is that the nature is not checked.
159 * This method is used for multiplication and division on fields to operate a first check before attempting operation.
161 bool MEDCouplingField::areStrictlyCompatibleForMulDiv(const MEDCouplingField *other) const
164 throw INTERP_KERNEL::Exception("MEDCouplingField::areStrictlyCompatible : input field is NULL !");
165 if(!_type->isEqual(other->_type,1.e-12))
167 return _mesh==other->_mesh;
171 void MEDCouplingField::updateTime() const
174 updateTimeWith(*_mesh);
176 updateTimeWith(*_type);
179 std::size_t MEDCouplingField::getHeapMemorySizeWithoutChildren() const
182 ret+=_name.capacity();
183 ret+=_desc.capacity();
187 std::vector<const BigMemoryObject *> MEDCouplingField::getDirectChildrenWithNull() const
189 std::vector<const BigMemoryObject *> ret;
190 ret.push_back(_mesh);
191 ret.push_back((const MEDCouplingFieldDiscretization *)_type);
196 * Returns a type of \ref MEDCouplingSpatialDisc "spatial discretization" of \a this
197 * field in terms of enum MEDCoupling::TypeOfField.
198 * \return MEDCoupling::TypeOfField - the type of \a this field.
199 * \throw If the geometric type is empty.
201 TypeOfField MEDCouplingField::getTypeOfField() const
203 if(!((const MEDCouplingFieldDiscretization *)_type))
204 throw INTERP_KERNEL::Exception("MEDCouplingField::getTypeOfField : spatial discretization is null !");
205 return _type->getEnum();
209 * Returns the nature of \a this field. This information is very important during
210 * interpolation process using MEDCoupling::MEDCouplingRemapper or MEDCoupling::InterpKernelDEC.
211 * In other context than the two mentioned above, this attribute is unimportant. This
212 * attribute is not stored in the MED file.
213 * For more information of the semantics and the influence of this attribute to the
214 * result of interpolation, see
215 * - \ref NatureOfField
216 * - \ref TableNatureOfField "How interpolation coefficients depend on Field Nature"
218 NatureOfField MEDCouplingField::getNature() const
224 * Sets the nature of \a this field. This information is very important during
225 * interpolation process using MEDCoupling::MEDCouplingRemapper or MEDCoupling::InterpKernelDEC.
226 * In other context than the two mentioned above, this attribute is unimportant. This
227 * attribute is not stored in the MED file.
228 * For more information of the semantics and the influence of this attribute to the
229 * result of interpolation, see
230 * - \ref NatureOfField
231 * - \ref TableNatureOfField "How interpolation coefficients depend on Field Nature"
233 * \param [in] nat - the nature of \a this field.
234 * \throw If \a nat has an invalid value.
236 void MEDCouplingField::setNature(NatureOfField nat)
238 MEDCouplingNatureOfField::GetRepr(nat);//generate a throw if nat not recognized
243 * Returns coordinates of field location points that depend on
244 * \ref MEDCouplingSpatialDisc "spatial discretization" of \a this field.
245 * - For a field on nodes, returns coordinates of nodes.
246 * - For a field on cells, returns barycenters of cells.
247 * - For a field on gauss points, returns coordinates of gauss points.
249 * \return DataArrayDouble * - a new instance of DataArrayDouble. The caller is to
250 * delete this array using decrRef() as it is no more needed.
251 * \throw If the spatial discretization of \a this field is NULL.
252 * \throw If the mesh is not set.
254 DataArrayDouble *MEDCouplingField::getLocalizationOfDiscr() const
257 throw INTERP_KERNEL::Exception("MEDCouplingField::getLocalizationOfDiscr : No mesh set !");
258 if(!((const MEDCouplingFieldDiscretization *)_type))
259 throw INTERP_KERNEL::Exception("MEDCouplingField::getLocalizationOfDiscr : No spatial discretization set !");
260 return _type->getLocalizationOfDiscValues(_mesh);
264 * Returns a new MEDCouplingFieldDouble containing volumes of cells of a dual mesh whose
265 * cells are constructed around field location points (getLocalizationOfDiscr()) of \a this
266 * field. (In case of a field on cells, the dual mesh coincides with the underlying mesh).<br>
267 * For 1D cells, the returned field contains lengths.<br>
268 * For 2D cells, the returned field contains areas.<br>
269 * For 3D cells, the returned field contains volumes.
270 * \param [in] isAbs - if \c true, the computed cell volume does not reflect cell
271 * orientation, i.e. the volume is always positive.
272 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble.
273 * The caller is to delete this array using decrRef() as
274 * it is no more needed.
275 * \throw If the mesh is not set.
276 * \throw If the spatial discretization of \a this field is NULL.
277 * \throw If the spatial discretization of \a this field is not well defined.
280 MEDCouplingFieldDouble *MEDCouplingField::buildMeasureField(bool isAbs) const
283 throw INTERP_KERNEL::Exception("MEDCouplingField::buildMeasureField : no mesh defined !");
284 if(!((const MEDCouplingFieldDiscretization *)_type))
285 throw INTERP_KERNEL::Exception("MEDCouplingField::buildMeasureField : No spatial discretization set !");
286 return _type->getMeasureField(_mesh,isAbs);
290 * Sets the underlying mesh of \a this field.
291 * For examples of field construction, see \ref MEDCouplingFirstSteps3.
292 * \param [in] mesh - the new underlying mesh.
294 void MEDCouplingField::setMesh(const MEDCouplingMesh *mesh)
305 updateTimeWith(*_mesh);
311 * Sets localization of Gauss points for a given geometric type of cell.
312 * \param [in] type - the geometric type of cell for which the Gauss localization is set.
313 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
314 * must be \c nbOfNodesPerCell * \c dimOfType.
315 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
316 * must be _wg_.size() * \c dimOfType.
317 * \param [in] wg - the weights of Gauss points.
318 * \throw If \a this field is not on Gauss points.
319 * \throw If the spatial discretization of \a this field is NULL.
320 * \throw If the mesh is not set.
321 * \throw If size of any vector do not match the \a type.
323 void MEDCouplingField::setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
324 const std::vector<double>& gsCoo, const std::vector<double>& wg)
327 throw INTERP_KERNEL::Exception("Mesh has to be set before calling setGaussLocalizationOnType method !");
328 if(!((const MEDCouplingFieldDiscretization *)_type))
329 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call setGaussLocalizationOnType method !");
330 _type->setGaussLocalizationOnType(_mesh,type,refCoo,gsCoo,wg);
334 * Sets localization of Gauss points for given cells specified by their ids.
335 * \param [in] begin - an array of cell ids of interest.
336 * \param [in] end - the end of \a begin, i.e. a pointer to its (last+1)-th element.
337 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
338 * must be \c nbOfNodesPerCell * \c dimOfType.
339 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
340 * must be _wg_.size() * \c dimOfType.
341 * \param [in] wg - the weights of Gauss points.
342 * \throw If \a this field is not on Gauss points.
343 * \throw If the spatial discretization of \a this field is NULL.
344 * \throw If the mesh is not set.
345 * \throw If size of any vector do not match the type of cell # \a begin[0].
346 * \throw If type of any cell in \a begin differs from that of cell # \a begin[0].
347 * \throw If the range [_begin_,_end_) is empty.
349 void MEDCouplingField::setGaussLocalizationOnCells(const int *begin, const int *end, const std::vector<double>& refCoo,
350 const std::vector<double>& gsCoo, const std::vector<double>& wg)
353 throw INTERP_KERNEL::Exception("Mesh has to be set before calling setGaussLocalizationOnCells method !");
354 if(!((const MEDCouplingFieldDiscretization *)_type))
355 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call setGaussLocalizationOnCells method !");
356 _type->setGaussLocalizationOnCells(_mesh,begin,end,refCoo,gsCoo,wg);
360 * Clears data on Gauss points localization.
361 * \throw If \a this field is not on Gauss points.
362 * \throw If the spatial discretization of \a this field is NULL.
364 void MEDCouplingField::clearGaussLocalizations()
366 if(!((const MEDCouplingFieldDiscretization *)_type))
367 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call clearGaussLocalizations method !");
368 _type->clearGaussLocalizations();
372 * Returns a reference to the Gauss localization object by its id.
373 * \warning This method is not const, so the returned object can be modified without any
375 * \param [in] locId - the id of the Gauss localization object of interest.
376 * It must be in range <em> 0 <= locId < getNbOfGaussLocalization() </em>.
377 * \return \ref MEDCoupling::MEDCouplingGaussLocalization "MEDCouplingGaussLocalization" & - the
378 * Gauss localization object.
379 * \throw If \a this field is not on Gauss points.
380 * \throw If \a locId is not within the valid range.
381 * \throw If the spatial discretization of \a this field is NULL.
383 MEDCouplingGaussLocalization& MEDCouplingField::getGaussLocalization(int locId)
385 if(!((const MEDCouplingFieldDiscretization *)_type))
386 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getGaussLocalization method !");
387 return _type->getGaussLocalization(locId);
391 * Returns an id of the Gauss localization object corresponding to a given cell type.
392 * \param [in] type - the cell type of interest.
393 * \return int - the id of the Gauss localization object.
394 * \throw If \a this field is not on Gauss points.
395 * \throw If the spatial discretization of \a this field is NULL.
396 * \throw If no Gauss localization object found for the given cell \a type.
397 * \throw If more than one Gauss localization object found for the given cell \a type.
399 int MEDCouplingField::getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const
401 if(!((const MEDCouplingFieldDiscretization *)_type))
402 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getGaussLocalizationIdOfOneType method !");
403 return _type->getGaussLocalizationIdOfOneType(type);
407 * Returns ids of Gauss localization objects corresponding to a given cell type.
408 * \param [in] type - the cell type of interest.
409 * \return std::set<int> - ids of the Gauss localization object.
410 * \throw If \a this field is not on Gauss points.
411 * \throw If the spatial discretization of \a this field is NULL
413 std::set<int> MEDCouplingField::getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const
415 if(!((const MEDCouplingFieldDiscretization *)_type))
416 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getGaussLocalizationIdsOfOneType method !");
417 return _type->getGaussLocalizationIdsOfOneType(type);
421 * Returns number of Gauss localization objects available. Implicitly all ids in
422 * [0,getNbOfGaussLocalization()) are valid Gauss localization ids.
423 * \return int - the number of available Gauss localization objects.
424 * \throw If \a this field is not on Gauss points.
425 * \throw If the spatial discretization of \a this field is NULL.
427 int MEDCouplingField::getNbOfGaussLocalization() const
429 if(!((const MEDCouplingFieldDiscretization *)_type))
430 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getNbOfGaussLocalization method !");
431 return _type->getNbOfGaussLocalization();
435 * Returns an id of the Gauss localization object corresponding to a type of a given cell.
436 * \param [in] cellId - an id of the cell of interest.
437 * \return int - the id of the Gauss localization object.
438 * \throw If \a this field is not on Gauss points.
439 * \throw If the spatial discretization of \a this field is NULL.
440 * \throw If no Gauss localization object found for the given cell.
442 int MEDCouplingField::getGaussLocalizationIdOfOneCell(int cellId) const
444 if(!((const MEDCouplingFieldDiscretization *)_type))
445 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getGaussLocalizationIdOfOneCell method !");
446 return _type->getGaussLocalizationIdOfOneCell(cellId);
450 * Returns ids of cells that share the same Gauss localization given by its id.
451 * \param [in] locId - the id of the Gauss localization object of interest.
452 * It must be in range <em> 0 <= locId < getNbOfGaussLocalization() </em>.
453 * \param [in,out] cellIds - a vector returning ids of found cells. It is cleared before
454 * filling in. It remains empty if no cells found.
455 * \throw If \a this field is not on Gauss points.
456 * \throw If \a locId is not within the valid range.
457 * \throw If the spatial discretization of \a this field is NULL.
459 void MEDCouplingField::getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const
462 if(!((const MEDCouplingFieldDiscretization *)_type))
463 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getCellIdsHavingGaussLocalization method !");
464 _type->getCellIdsHavingGaussLocalization(locId,cellIds);
468 * Returns a reference to the Gauss localization object by its id.
469 * \warning This method is const, so the returned object is not apt for modification.
470 * \param [in] locId - the id of the Gauss localization object of interest.
471 * It must be in range <em> 0 <= locId < getNbOfGaussLocalization() </em>.
472 * \return const \ref MEDCouplingGaussLocalization & - the Gauss localization object.
473 * \throw If \a this field is not on Gauss points.
474 * \throw If \a locId is not within the valid range.
475 * \throw If the spatial discretization of \a this field is NULL.
477 const MEDCouplingGaussLocalization& MEDCouplingField::getGaussLocalization(int locId) const
479 if(!((const MEDCouplingFieldDiscretization *)_type))
480 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getGaussLocalization method !");
481 return _type->getGaussLocalization(locId);
484 MEDCouplingField::~MEDCouplingField()
490 MEDCouplingField::MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature):_nature(nature),_mesh(0),_type(type)
494 MEDCouplingField::MEDCouplingField(TypeOfField type):_nature(NoNature),_mesh(0),_type(MEDCouplingFieldDiscretization::New(type))
498 MEDCouplingField::MEDCouplingField(const MEDCouplingField& other, bool deepCopy):RefCountObject(other),_name(other._name),_desc(other._desc),_nature(other._nature),
507 _type=other._type->clone();
513 * Returns a new MEDCouplingMesh constituted by some cells of the underlying mesh of \a
514 * this field, and returns ids of entities (nodes, cells, Gauss points) lying on the
515 * specified cells. The cells to include to the result mesh are specified by an array of
516 * cell ids. The new mesh shares the coordinates array with the underlying mesh.
517 * \param [in] start - an array of cell ids to include to the result mesh.
518 * \param [in] end - specifies the end of the array \a start, so that
519 * the last value of \a start is \a end[ -1 ].
520 * \param [out] di - a new instance of DataArrayInt holding the ids of entities (nodes,
521 * cells, Gauss points). The caller is to delete this array using decrRef() as it
523 * \return MEDCouplingMesh * - a new instance of MEDCouplingMesh. The caller is to
524 * delete this mesh using decrRef() as it is no more needed.
525 * \throw If the spatial discretization of \a this field is NULL.
526 * \throw If the mesh is not set.
527 * \sa buildSubMeshDataRange()
529 MEDCouplingMesh *MEDCouplingField::buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const
531 if(!((const MEDCouplingFieldDiscretization *)_type))
532 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call buildSubMeshData method !");
533 return _type->buildSubMeshData(_mesh,start,end,di);
537 * This method returns a submesh of 'mesh' instance constituting cell ids defined by a range given by the 3 following inputs \a begin, \a end and \a step.
539 * \param [out] beginOut Valid only if \a di is NULL
540 * \param [out] endOut Valid only if \a di is NULL
541 * \param [out] stepOut Valid only if \a di is NULL
542 * \param [out] di is an array returned that specifies entity ids (nodes, cells, Gauss points... ) in array if no output range is foundable.
544 * \sa MEDCouplingField::buildSubMeshData
546 MEDCouplingMesh *MEDCouplingField::buildSubMeshDataRange(int begin, int end, int step, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const
548 if(!((const MEDCouplingFieldDiscretization *)_type))
549 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call buildSubMeshDataRange method !");
550 return _type->buildSubMeshDataRange(_mesh,begin,end,step,beginOut,endOut,stepOut,di);
554 * This method returns tuples ids implied by the mesh selection of the cell ids contained in array defined as an interval [start;end).
555 * \return a newly allocated DataArrayInt instance containing tuples ids.
557 DataArrayInt *MEDCouplingField::computeTupleIdsToSelectFromCellIds(const int *startCellIds, const int *endCellIds) const
559 if(!((const MEDCouplingFieldDiscretization *)_type))
560 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call computeTupleIdsToSelectFromCellIds method !");
561 return _type->computeTupleIdsToSelectFromCellIds(_mesh,startCellIds,endCellIds);
565 * Returns number of tuples expected regarding the spatial discretization of \a this
566 * field and number of entities in the underlying mesh. This method behaves exactly as MEDCouplingFieldDouble::getNumberOfTuples.
567 * \return int - the number of expected tuples.
568 * \throw If the spatial discretization of \a this field is NULL.
569 * \throw If the mesh is not set.
571 int MEDCouplingField::getNumberOfTuplesExpected() const
573 if(!((const MEDCouplingFieldDiscretization *)_type))
574 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getNumberOfTuplesExpected method !");
576 return _type->getNumberOfTuples(_mesh);
578 throw INTERP_KERNEL::Exception("MEDCouplingField::getNumberOfTuplesExpected : Empty mesh !");
581 void MEDCouplingField::setDiscretization(MEDCouplingFieldDiscretization *newDisc)
583 bool needUpdate=(const MEDCouplingFieldDiscretization *)_type!=newDisc;
592 * Returns number of mesh entities in the underlying mesh of \a this field regarding the
593 * spatial discretization.
594 * \return int - the number of mesh entities porting the field values.
595 * \throw If the spatial discretization of \a this field is NULL.
596 * \throw If the mesh is not set.
598 int MEDCouplingField::getNumberOfMeshPlacesExpected() const
600 if(!((const MEDCouplingFieldDiscretization *)_type))
601 throw INTERP_KERNEL::Exception("Spatial discretization not set ! Impossible to call getNumberOfMeshPlacesExpected method !");
603 return _type->getNumberOfMeshPlaces(_mesh);
605 throw INTERP_KERNEL::Exception("MEDCouplingField::getNumberOfMeshPlacesExpected : Empty mesh !");
609 * Copy tiny info (component names, name, description) but warning the underlying mesh is not renamed (for safety reason).
611 void MEDCouplingField::copyTinyStringsFrom(const MEDCouplingField *other)
615 setName(other->_name);
616 setDescription(other->_desc);
621 * This method computes the number of tuples a DataArrayDouble instance should have to build a correct MEDCouplingFieldDouble instance starting from a
622 * submesh of a virtual mesh on which a substraction per type had been applied regarding the spatial discretization in \a this.
624 * For spatial discretization \b not equal to ON_GAUSS_NE this method will make the hypothesis that any positive entity id in \a code \a idsPerType is valid.
625 * So in those cases attribute \a _mesh of \a this is ignored.
627 * For spatial discretization equal to ON_GAUSS_NE \a _mesh attribute will be taken into account.
629 * The input code is those implemented in MEDCouplingUMesh::splitProfilePerType.
631 * \param [in] code - a code with format described above.
632 * \param [in] idsPerType - a list of subparts
633 * \throw If \a this has no spatial discretization set.
634 * \throw If input code point to invalid zones in spatial discretization.
635 * \throw If spatial discretization in \a this requires a mesh and those mesh is invalid (null,...)
637 int MEDCouplingField::getNumberOfTuplesExpectedRegardingCode(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const
639 const MEDCouplingFieldDiscretization *t(_type);
641 throw INTERP_KERNEL::Exception("MEDCouplingField::getNumberOfTuplesExpectedRegardingCode : no spatial discretization set !");
642 return t->getNumberOfTuplesExpectedRegardingCode(code,idsPerType);