From e3c417b2114b640343a1924f96cc64687f3cb9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Mataix=20Ferr=C3=A1ndiz?= Date: Mon, 17 Dec 2018 13:24:11 +0100 Subject: [PATCH] [Core] Adding GetModelPartNames to Model --- kratos/containers/model.cpp | 14 +++++++++++++ kratos/containers/model.h | 40 +++++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/kratos/containers/model.cpp b/kratos/containers/model.cpp index f1c29410bea8..f4ed0f0983ab 100644 --- a/kratos/containers/model.cpp +++ b/kratos/containers/model.cpp @@ -168,6 +168,20 @@ namespace Kratos KRATOS_CATCH("") } + std::vector Model::GetModelPartNames() + { + std::vector model_parts_names(mRootModelPartMap.size()); + + // We fill the vector + std::size_t index = 0; + for (auto& mps : mRootModelPartMap) { + model_parts_names[index] = mps.first; + ++index; + } + + return model_parts_names; + } + std::string Model::Info() const { std::stringstream ss; diff --git a/kratos/containers/model.h b/kratos/containers/model.h index caab4bed9671..c4b68bf6eb49 100644 --- a/kratos/containers/model.h +++ b/kratos/containers/model.h @@ -85,13 +85,18 @@ class KRATOS_API(KRATOS_CORE) Model //mListOfVariablesLists.clear(); //this has to be done AFTER clearing the RootModelParts } - Model & operator=(const Model&) = delete; Model(const Model&) = delete; - ///@} ///@name Operators ///@{ + + Model & operator=(const Model&) = delete; + + ///@} + ///@name Operations + ///@{ + void Reset(); ModelPart& CreateModelPart( const std::string ModelPartName, IndexType NewBufferSize=1 ); @@ -104,10 +109,7 @@ class KRATOS_API(KRATOS_CORE) Model bool HasModelPart(const std::string& rFullModelPartName) const; - ///@} - ///@name Operations - ///@{ - + std::vector GetModelPartNames(); ///@} ///@name Access @@ -184,18 +186,8 @@ class KRATOS_API(KRATOS_CORE) Model ///@} ///@name Member Variables ///@{ - std::map< std::string, std::unique_ptr > mRootModelPartMap; - - std::set< std::unique_ptr >& GetListOfVariableLists() const - { - static std::set< std::unique_ptr > mListOfVariablesLists; - return mListOfVariablesLists; - } - friend class Serializer; - - void save(Serializer& rSerializer) const; - void load(Serializer& rSerializer); + std::map< std::string, std::unique_ptr > mRootModelPartMap; /// The map containing the list of model parts ///@} ///@name Private Operators @@ -210,6 +202,11 @@ class KRATOS_API(KRATOS_CORE) Model std::vector SplitSubModelPartHierarchy(const std::string& rFullModelPartName) const; + std::set< std::unique_ptr >& GetListOfVariableLists() const + { + static std::set< std::unique_ptr > mListOfVariablesLists; + return mListOfVariablesLists; + } ///@} ///@name Private Access @@ -232,6 +229,15 @@ class KRATOS_API(KRATOS_CORE) Model // Model(Model const& rOther); + ///@} + ///@name Serialization + ///@{ + + friend class Serializer; + + void save(Serializer& rSerializer) const; + void load(Serializer& rSerializer); + ///@} }; // Class Model