66 mrModelPart(rModelPart)
97 static void CopySubModelPartStructure(
const ModelPart& rModelPartToCopyFromIt,
ModelPart& rModelPartToCopyIntoIt);
103 void RecursiveEnsureModelPartOwnsProperties(
const bool RemovePreviousProperties =
true);
109 void EnsureModelPartOwnsProperties(
const bool RemovePreviousProperties =
true);
120 void RemoveElementAndBelongings(
IndexType ElementId,
Flags IdentifierFlag = TO_ERASE,
IndexType ThisIndex = 0);
131 void RemoveElementAndBelongings(
Element& rThisElement,
const Flags IdentifierFlag = TO_ERASE,
IndexType ThisIndex = 0);
142 void RemoveElementAndBelongings(Element::Pointer pThisElement,
const Flags IdentifierFlag = TO_ERASE,
IndexType ThisIndex = 0);
153 void RemoveElementAndBelongingsFromAllLevels(
IndexType ElementId,
const Flags IdentifierFlag = TO_ERASE,
IndexType ThisIndex = 0);
164 void RemoveElementAndBelongingsFromAllLevels(
Element& rThisElement,
const Flags IdentifierFlag = TO_ERASE,
IndexType ThisIndex = 0);
175 void RemoveElementAndBelongingsFromAllLevels(Element::Pointer pThisElement,
const Flags IdentifierFlag = TO_ERASE,
IndexType ThisIndex = 0);
185 void RemoveElementsAndBelongings(
Flags IdentifierFlag = TO_ERASE);
195 void RemoveElementsAndBelongingsFromAllLevels(
const Flags IdentifierFlag = TO_ERASE);
206 void RemoveConditionAndBelongings(
IndexType ConditionId,
Flags IdentifierFlag = TO_ERASE,
IndexType ThisIndex = 0);
217 void RemoveConditionAndBelongings(
Condition& ThisCondition,
const Flags IdentifierFlag = TO_ERASE,
IndexType ThisIndex = 0);
226 void RemoveConditionAndBelongings(Condition::Pointer pThisCondition,
const Flags IdentifierFlag = TO_ERASE,
IndexType ThisIndex = 0);
237 void RemoveConditionAndBelongingsFromAllLevels(
IndexType ConditionId,
const Flags IdentifierFlag = TO_ERASE,
IndexType ThisIndex = 0);
248 void RemoveConditionAndBelongingsFromAllLevels(
Condition& rThisCondition,
const Flags IdentifierFlag = TO_ERASE,
IndexType ThisIndex = 0);
259 void RemoveConditionAndBelongingsFromAllLevels(Condition::Pointer pThisCondition,
const Flags IdentifierFlag = TO_ERASE,
IndexType ThisIndex = 0);
269 void RemoveConditionsAndBelongings(
Flags IdentifierFlag = TO_ERASE);
279 void RemoveConditionsAndBelongingsFromAllLevels(
const Flags IdentifierFlag = TO_ERASE);
284 void RemoveOrphanNodesFromSubModelParts();
287 template<
class TContainerType>
291 TContainerType&
data)
const
297 case (DataLocation::NodeHistorical):{
298 data.resize(mrModelPart.NumberOfNodes());
300 auto inodebegin = mrModelPart.NodesBegin();
303 auto inode = inodebegin +
Index;
305 data[
Index] = inode->FastGetSolutionStepValue(rVariable);
310 case (DataLocation::NodeNonHistorical):{
311 data.resize(mrModelPart.NumberOfNodes());
313 GetScalarDataFromContainer(mrModelPart.Nodes(), rVariable,
data);
316 case (DataLocation::Element):{
317 data.resize(mrModelPart.NumberOfElements());
319 GetScalarDataFromContainer(mrModelPart.Elements(), rVariable,
data);
322 case (DataLocation::Condition):{
323 data.resize(mrModelPart.NumberOfConditions());
325 GetScalarDataFromContainer(mrModelPart.Conditions(), rVariable,
data);
330 data[0] = mrModelPart[rVariable];
335 data[0] = mrModelPart.GetProcessInfo()[rVariable];
348 template<
class TContainerType,
class TVarType>
352 TContainerType&
data)
const
358 case (DataLocation::NodeHistorical):{
359 unsigned int TSize = mrModelPart.NumberOfNodes() > 0 ? mrModelPart.NodesBegin()->FastGetSolutionStepValue(rVariable).size() : 0;
361 TSize = mrModelPart.GetCommunicator().GetDataCommunicator().MaxAll(TSize);
362 data.resize(mrModelPart.NumberOfNodes()*TSize);
364 auto inodebegin = mrModelPart.NodesBegin();
367 auto inode = inodebegin +
Index;
369 const auto& r_val = inode->FastGetSolutionStepValue(rVariable);
370 for(std::size_t
dim = 0 ;
dim < TSize ;
dim++){
377 case (DataLocation::NodeNonHistorical):{
378 unsigned int TSize = mrModelPart.NumberOfNodes() > 0 ? mrModelPart.NodesBegin()->GetValue(rVariable).size() : 0;
380 TSize = mrModelPart.GetCommunicator().GetDataCommunicator().MaxAll(TSize);
382 data.resize(mrModelPart.NumberOfNodes()*TSize);
384 GetVectorDataFromContainer(mrModelPart.Nodes(), TSize, rVariable,
data);
387 case (DataLocation::Element):{
388 unsigned int TSize = mrModelPart.NumberOfElements() > 0 ? mrModelPart.ElementsBegin()->GetValue(rVariable).size() : 0;
390 TSize = mrModelPart.GetCommunicator().GetDataCommunicator().MaxAll(TSize);
392 data.resize(mrModelPart.NumberOfElements()*TSize);
394 GetVectorDataFromContainer(mrModelPart.Elements(), TSize, rVariable,
data);
397 case (DataLocation::Condition):{
398 unsigned int TSize = mrModelPart.NumberOfConditions() > 0 ? mrModelPart.ConditionsBegin()->GetValue(rVariable).size() : 0;
400 TSize = mrModelPart.GetCommunicator().GetDataCommunicator().MaxAll(TSize);
402 data.resize(mrModelPart.NumberOfConditions()*TSize);
404 GetVectorDataFromContainer(mrModelPart.Conditions(), TSize, rVariable,
data);
408 std::size_t TSize = mrModelPart[rVariable].size();
412 auto& r_val = mrModelPart[rVariable];
413 for(std::size_t
dim = 0 ;
dim < TSize ;
dim++){
419 const std::size_t TSize = mrModelPart.GetProcessInfo()[rVariable].size();
423 auto& r_val = mrModelPart.GetProcessInfo()[rVariable];
424 for(std::size_t
dim = 0 ;
dim < TSize ;
dim++){
439 template<
class TContainerType>
443 const TContainerType& rData)
449 case (DataLocation::NodeHistorical):{
450 auto inodebegin = mrModelPart.NodesBegin();
452 auto inode = inodebegin +
Index;
454 auto& r_val = inode->FastGetSolutionStepValue(rVariable);
455 r_val = rData[
Index];
460 case (DataLocation::NodeNonHistorical):{
461 SetScalarDataFromContainer(mrModelPart.Nodes(), rVariable, rData);
464 case (DataLocation::Element):{
465 SetScalarDataFromContainer(mrModelPart.Elements(), rVariable, rData);
468 case (DataLocation::Condition):{
469 SetScalarDataFromContainer(mrModelPart.Conditions(), rVariable, rData);
473 mrModelPart[rVariable]= rData[0];
477 mrModelPart.GetProcessInfo()[rVariable] = rData[0] ;
490 template<
class TContainerType,
class TVarType>
494 const TContainerType& rData)
500 case (DataLocation::NodeHistorical):{
501 unsigned int size = mrModelPart.NumberOfNodes() > 0 ? mrModelPart.NodesBegin()->FastGetSolutionStepValue(rVariable).size() : 0;
503 size = mrModelPart.GetCommunicator().GetDataCommunicator().MaxAll(size);
505 auto inodebegin = mrModelPart.NodesBegin();
507 auto inode = inodebegin +
Index;
508 auto& r_val = inode->FastGetSolutionStepValue(rVariable);
512 for(std::size_t
dim = 0 ;
dim < size ;
dim++){
519 case (DataLocation::NodeNonHistorical):{
520 unsigned int size = mrModelPart.NumberOfNodes() > 0 ? mrModelPart.NodesBegin()->GetValue(rVariable).size() : 0;
522 size = mrModelPart.GetCommunicator().GetDataCommunicator().MaxAll(size);
524 SetVectorDataFromContainer(mrModelPart.Nodes(), size, rVariable, rData);
527 case (DataLocation::Element):{
528 unsigned int size = mrModelPart.NumberOfElements() > 0 ? mrModelPart.ElementsBegin()->GetValue(rVariable).size() : 0;
530 size = mrModelPart.GetCommunicator().GetDataCommunicator().MaxAll(size);
532 SetVectorDataFromContainer(mrModelPart.Elements(), size, rVariable, rData);
535 case (DataLocation::Condition):{
536 unsigned int size = mrModelPart.NumberOfConditions() > 0 ? mrModelPart.ConditionsBegin()->GetValue(rVariable).size() : 0;
538 size = mrModelPart.GetCommunicator().GetDataCommunicator().MaxAll(size);
540 SetVectorDataFromContainer(mrModelPart.Conditions(), size, rVariable, rData);
544 const std::size_t size = mrModelPart[rVariable].size();
547 auto& r_val = mrModelPart[rVariable];
548 for(std::size_t
dim = 0 ;
dim < size ;
dim++){
554 const std::size_t size = mrModelPart.GetProcessInfo()[rVariable].size();
557 auto& r_val = mrModelPart.GetProcessInfo()[rVariable];
558 for(std::size_t
dim = 0 ;
dim < size ;
dim++){
582 const std::string& rNewModelPartName,
583 Model* pModel =
nullptr
596 template<
class TClassContainer,
class TReferenceClassContainer>
599 TClassContainer& rEntities,
600 TReferenceClassContainer& rReferenceEntities,
608 rEntities.SetSortedPartSize(rReferenceEntities.GetSortedPartSize());
609 const auto& r_reference_entities_container = rReferenceEntities.GetContainer();
610 auto& r_entities_container = rEntities.GetContainer();
611 const IndexType number_entities = r_reference_entities_container.size();
612 r_entities_container.resize(number_entities);
613 const auto it_ent_begin = r_reference_entities_container.begin();
615 auto it_ent = it_ent_begin +
i;
616 auto& p_old_ent = (*it_ent);
617 auto p_new_ent = p_old_ent->Create(p_old_ent->Id(), rGeometryPointerDatabase[p_old_ent->pGetGeometry()], r_properties(p_old_ent->pGetProperties()->Id()));
618 p_new_ent->SetData(p_old_ent->GetData());
619 p_new_ent->Set(
Flags(*p_old_ent));
620 r_entities_container[
i] = p_new_ent;
627 virtual std::string
Info()
const
629 return "AuxiliarModelPartUtilities";
635 rOStream <<
Info() << std::endl;
641 rOStream <<
Info() << std::endl;
661 template<
typename TDataType,
class TContainerType,
class TDataContainerType>
662 void GetScalarDataFromContainer(
663 const TContainerType& rContainer,
665 TDataContainerType&
data)
const
669 DataSizeCheck(rContainer.size(),
data.size());
672 const auto& r_entity = *(rContainer.begin() + index);
673 data[index] = r_entity.GetValue(rVariable);
679 template<
typename TDataType,
class TContainerType,
class TDataContainerType>
680 void GetVectorDataFromContainer(
681 const TContainerType& rContainer,
682 const std::size_t VectorSize,
683 const Variable<TDataType>& rVariable,
684 TDataContainerType&
data)
const
688 DataSizeCheck(rContainer.size()*VectorSize,
data.size());
690 IndexPartition<std::size_t>(rContainer.size()).for_each([&](std::size_t index){
691 const auto& r_entity = *(rContainer.begin() + index);
692 const auto& r_val = r_entity.GetValue(rVariable);
693 for(std::size_t
dim = 0 ;
dim < VectorSize ;
dim++){
701 template<
typename TDataType,
class TContainerType,
class TDataContainerType>
702 void SetScalarDataFromContainer(
703 TContainerType& rContainer,
704 const Variable<TDataType>& rVariable,
705 const TDataContainerType& rData)
const
709 DataSizeCheck(rContainer.size(), rData.size());
711 IndexPartition<std::size_t>(rContainer.size()).for_each([&](std::size_t index){
712 auto& r_entity = *(rContainer.begin() + index);
713 r_entity.SetValue(rVariable, rData[index]);
719 template<
typename TDataType,
class TContainerType,
class TDataContainerType>
720 void SetVectorDataFromContainer(
721 TContainerType& rContainer,
722 const std::size_t VectorSize,
723 const Variable<TDataType>& rVariable,
724 const TDataContainerType& rData)
const
728 DataSizeCheck(rContainer.size()*VectorSize, rData.size());
730 IndexPartition<std::size_t>(rContainer.size()).for_each([&](std::size_t index){
731 auto& r_entity = *(rContainer.begin() + index);
734 for(std::size_t
dim = 0 ;
dim < VectorSize ;
dim++){
735 aux[
dim] = rData[(VectorSize*index) +
dim];
737 r_entity.SetValue(rVariable, aux);
744 const std::size_t ContainerSize,
745 const std::size_t DataSize)
const
747 KRATOS_ERROR_IF(ContainerSize != DataSize) <<
"Mismatch in size! Container size: " << ContainerSize <<
" | Data size: " << DataSize << std::endl;
756 void DeepCopySubModelPart(
757 const ModelPart& rOldModelPart,
758 ModelPart& rNewModelPart
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
This utility includes auxiliar methods not included in the model part to avoid increase more than nec...
Definition: auxiliar_model_part_utilities.h:48
void DeepCopyEntities(ModelPart &rModelPart, TClassContainer &rEntities, TReferenceClassContainer &rReferenceEntities, std::unordered_map< Geometry< Node >::Pointer, Geometry< Node >::Pointer > &rGeometryPointerDatabase)
This method deep copies a entities.
Definition: auxiliar_model_part_utilities.h:597
void GetVectorData(const Variable< TVarType > &rVariable, const DataLocation DataLoc, TContainerType &data) const
To Export a Vector data (std::vector/array/..)
Definition: auxiliar_model_part_utilities.h:349
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: auxiliar_model_part_utilities.h:639
void SetScalarData(const Variable< typename TContainerType::value_type > &rVariable, const DataLocation DataLoc, const TContainerType &rData)
To Import a Scalar data (Double/int/...)
Definition: auxiliar_model_part_utilities.h:440
void SetVectorData(const Variable< TVarType > &rVariable, const DataLocation DataLoc, const TContainerType &rData)
To Import a Vector data (std::vector/array/..)
Definition: auxiliar_model_part_utilities.h:491
AuxiliarModelPartUtilities(ModelPart &rModelPart)
Definition: auxiliar_model_part_utilities.h:65
KRATOS_CLASS_POINTER_DEFINITION(AuxiliarModelPartUtilities)
Counted pointer of AuxiliarModelPartUtilities.
virtual ~AuxiliarModelPartUtilities()=default
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: auxiliar_model_part_utilities.h:633
void GetScalarData(const Variable< typename TContainerType::value_type > &rVariable, const DataLocation DataLoc, TContainerType &data) const
To Export a Scalar data (Double/int/...)
Definition: auxiliar_model_part_utilities.h:288
virtual std::string Info() const
Turn back information as a string.
Definition: auxiliar_model_part_utilities.h:627
Base class for all Conditions.
Definition: condition.h:59
Base class for all Elements.
Definition: element.h:60
Geometry base class.
Definition: geometry.h:71
This class is useful for index iteration over containers.
Definition: parallel_utilities.h:451
void for_each(TUnaryFunction &&f)
Definition: parallel_utilities.h:514
This class aims to manage different model parts across multi-physics simulations.
Definition: model.h:60
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
PropertiesContainerType & rProperties(IndexType ThisIndex=0)
Definition: model_part.h:1003
void SetMaxBufferSize(const size_type NewSize)
Set the maximum size of buffer used in the container.
Definition: pointer_vector_set.h:802
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
#define KRATOS_DEBUG_ERROR_IF(conditional)
Definition: exception.h:171
Kratos::ModelPart ModelPart
Definition: kratos_wrapper.h:31
DataLocation
Enum for location of data.
Definition: global_variables.h:48
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
ProcessInfo
Definition: edgebased_PureConvection.py:116
data
Definition: mesh_to_mdpa_converter.py:59
int counter
Definition: script_THERMAL_CORRECT.py:218
int dim
Definition: sensitivityMatrix.py:25
integer i
Definition: TensorModule.f:17