Skip to content

Commit

Permalink
[Core] Adding GetModelPartNames to Model
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicente Mataix Ferrándiz committed Dec 17, 2018
1 parent 3f31180 commit e3c417b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.
14 changes: 14 additions & 0 deletions kratos/containers/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,20 @@ namespace Kratos
KRATOS_CATCH("")
}

std::vector<std::string> Model::GetModelPartNames()
{
std::vector<std::string> 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;
Expand Down
40 changes: 23 additions & 17 deletions kratos/containers/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -104,10 +109,7 @@ class KRATOS_API(KRATOS_CORE) Model

bool HasModelPart(const std::string& rFullModelPartName) const;

///@}
///@name Operations
///@{

std::vector<std::string> GetModelPartNames();

///@}
///@name Access
Expand Down Expand Up @@ -184,18 +186,8 @@ class KRATOS_API(KRATOS_CORE) Model
///@}
///@name Member Variables
///@{
std::map< std::string, std::unique_ptr<ModelPart> > mRootModelPartMap;

std::set< std::unique_ptr<VariablesList> >& GetListOfVariableLists() const
{
static std::set< std::unique_ptr<VariablesList> > mListOfVariablesLists;
return mListOfVariablesLists;
}
friend class Serializer;

void save(Serializer& rSerializer) const;
void load(Serializer& rSerializer);

std::map< std::string, std::unique_ptr<ModelPart> > mRootModelPartMap; /// The map containing the list of model parts

///@}
///@name Private Operators
Expand All @@ -210,6 +202,11 @@ class KRATOS_API(KRATOS_CORE) Model

std::vector<std::string> SplitSubModelPartHierarchy(const std::string& rFullModelPartName) const;

std::set< std::unique_ptr<VariablesList> >& GetListOfVariableLists() const
{
static std::set< std::unique_ptr<VariablesList> > mListOfVariablesLists;
return mListOfVariablesLists;
}

///@}
///@name Private Access
Expand All @@ -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
Expand Down

1 comment on commit e3c417b

@loumalouomega
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roigcarlo is this what you were looking for?

Please sign in to comment.