OGS
DataHolderLib::Project Class Referencefinal

Detailed Description

The ProjectData Object contains all the data needed for a certain project, i.e. all geometric data (stored in a GEOObjects-object), all the meshes, processes, and process variables.

Definition at line 35 of file Project.h.

#include <Project.h>

Collaboration diagram for DataHolderLib::Project:
[legend]

Public Member Functions

 Project ()=default
 Constructor.
 
 Project (Project &)=delete
 
 ~Project ()=default
 
GeoLib::GEOObjectsgetGEOObjects ()
 Returns the GEOObjects containing all points, polylines and surfaces.
 
void addMesh (std::unique_ptr< MeshLib::Mesh > mesh)
 
const MeshLib::MeshgetMesh (const std::string &name) const
 
const std::vector< std::unique_ptr< MeshLib::Mesh > > & getMeshObjects () const
 Returns all the meshes with their respective names.
 
bool removeMesh (const std::string &name)
 
void addBoundaryCondition (std::unique_ptr< BoundaryCondition > bc)
 Adds a boundary condition to the project.
 
void addSourceTerm (std::unique_ptr< SourceTerm > st)
 Adds a source term to the project.
 
std::vector< std::unique_ptr< BoundaryCondition > > const & getBoundaryConditions () const
 Returns the vector of boundary conditions.
 
std::vector< std::unique_ptr< SourceTerm > > const & getSourceTerms () const
 Returns the vector of source terms.
 
void removePrimaryVariable (std::string const &primary_var_name)
 Removes a primary variable incl. all associated conditions.
 
void removeBoundaryCondition (std::string const &primary_var_name, std::string const &param_name)
 Removes one boundary condition.
 
void removeSourceTerm (std::string const &primary_var_name, std::string const &param_name)
 Remove one source term.
 

Private Member Functions

bool getUniqueName (std::string &name) const
 
std::vector< std::unique_ptr< MeshLib::Mesh > >::const_iterator findMeshByName (std::string const &name) const
 Returns an iterator to the first found mesh with the given name.
 
std::vector< std::unique_ptr< MeshLib::Mesh > >::iterator findMeshByName (std::string const &name)
 

Private Attributes

GeoLib::GEOObjects _geoObjects
 
std::vector< std::unique_ptr< MeshLib::Mesh > > _mesh_vec
 
std::vector< std::unique_ptr< BoundaryCondition > > _boundary_conditions
 
std::vector< std::unique_ptr< SourceTerm > > _source_terms
 

Constructor & Destructor Documentation

◆ Project() [1/2]

DataHolderLib::Project::Project ( )
default

Constructor.

◆ Project() [2/2]

DataHolderLib::Project::Project ( Project & )
delete

◆ ~Project()

DataHolderLib::Project::~Project ( )
default

Member Function Documentation

◆ addBoundaryCondition()

void DataHolderLib::Project::addBoundaryCondition ( std::unique_ptr< BoundaryCondition > bc)
inline

Adds a boundary condition to the project.

Definition at line 68 of file Project.h.

69 {
70 _boundary_conditions.push_back(std::move(bc));
71 }
std::vector< std::unique_ptr< BoundaryCondition > > _boundary_conditions
Definition Project.h:117

References _boundary_conditions.

Referenced by FileIO::XmlPrjInterface::readBoundaryConditions().

◆ addMesh()

void DataHolderLib::Project::addMesh ( std::unique_ptr< MeshLib::Mesh > mesh)

Adds a new mesh under a (possibly new) unique name.

Attention
This might change the given mesh's name.

Definition at line 21 of file Project.cpp.

22{
23 std::string name = mesh->getName();
24 getUniqueName(name);
25 mesh->setName(name);
26 _mesh_vec.push_back(std::move(mesh));
27}
bool getUniqueName(std::string &name) const
Definition Project.cpp:61
std::vector< std::unique_ptr< MeshLib::Mesh > > _mesh_vec
Definition Project.h:116

References _mesh_vec, and getUniqueName().

Referenced by MeshModel::addMesh(), MeshModel::addMesh(), and FileIO::XmlPrjInterface::readFile().

◆ addSourceTerm()

void DataHolderLib::Project::addSourceTerm ( std::unique_ptr< SourceTerm > st)
inline

Adds a source term to the project.

Definition at line 74 of file Project.h.

75 {
76 _source_terms.push_back(std::move(st));
77 }
std::vector< std::unique_ptr< SourceTerm > > _source_terms
Definition Project.h:118

References _source_terms.

Referenced by FileIO::XmlPrjInterface::readSourceTerms().

◆ findMeshByName() [1/2]

std::vector< std::unique_ptr< MeshLib::Mesh > >::iterator DataHolderLib::Project::findMeshByName ( std::string const & name)
private

Definition at line 35 of file Project.cpp.

37{
38 return std::find_if(_mesh_vec.begin(), _mesh_vec.end(),
39 [&name](std::unique_ptr<MeshLib::Mesh>& mesh)
40 { return mesh && (name == mesh->getName()); });
41}

References _mesh_vec.

◆ findMeshByName() [2/2]

std::vector< std::unique_ptr< MeshLib::Mesh > >::const_iterator DataHolderLib::Project::findMeshByName ( std::string const & name) const
private

Returns an iterator to the first found mesh with the given name.

Definition at line 30 of file Project.cpp.

31{
32 return const_cast<Project&>(*this).findMeshByName(name);
33}
Project()=default
Constructor.

References findMeshByName().

Referenced by findMeshByName(), getMesh(), and removeMesh().

◆ getBoundaryConditions()

std::vector< std::unique_ptr< BoundaryCondition > > const & DataHolderLib::Project::getBoundaryConditions ( ) const
inline

◆ getGEOObjects()

◆ getMesh()

const MeshLib::Mesh * DataHolderLib::Project::getMesh ( const std::string & name) const

Returns the mesh with the given name or a nullptr if the mesh was not found.

Definition at line 43 of file Project.cpp.

44{
45 auto it = findMeshByName(name);
46 return (it == _mesh_vec.end() ? nullptr : it->get());
47}
std::vector< std::unique_ptr< MeshLib::Mesh > >::const_iterator findMeshByName(std::string const &name) const
Returns an iterator to the first found mesh with the given name.
Definition Project.cpp:30
auto & get(Tuples &... ts)
Definition Get.h:59

References _mesh_vec, and findMeshByName().

Referenced by MeshElementRemovalDialog::accept(), MeshElementRemovalDialog::on_scalarArrayCheckBox_toggled(), and MeshElementRemovalDialog::on_scalarArrayComboBox_currentIndexChanged().

◆ getMeshObjects()

const std::vector< std::unique_ptr< MeshLib::Mesh > > & DataHolderLib::Project::getMeshObjects ( ) const
inline

◆ getSourceTerms()

std::vector< std::unique_ptr< SourceTerm > > const & DataHolderLib::Project::getSourceTerms ( ) const
inline

Returns the vector of source terms.

Definition at line 87 of file Project.h.

88 {
89 return _source_terms;
90 }

References _source_terms.

Referenced by FileIO::XmlPrjInterface::getPrimaryVariableVec(), ProcessModel::updateModel(), FileIO::XmlPrjInterface::write(), and FileIO::XmlPrjInterface::writeSourceTerms().

◆ getUniqueName()

bool DataHolderLib::Project::getUniqueName ( std::string & name) const
private

Checks if a mesh with the same name exists and provides a unique name in case of already existing mesh. Returns true if the mesh name is unique. Returns false and changes the provided name to a unique name otherwise.

Definition at line 61 of file Project.cpp.

62{
63 int count(0);
64 bool isUnique(false);
65 std::string cpName;
66
67 while (!isUnique)
68 {
69 isUnique = true;
70 cpName = name;
71
72 count++;
73 // If the original name already exists we start to add numbers to name
74 // for as long as it takes to make the name unique.
75 if (count > 1)
76 {
77 cpName = cpName + "-" + std::to_string(count);
78 }
79
80 for (auto const& mesh : _mesh_vec)
81 {
82 if (cpName == mesh->getName())
83 {
84 isUnique = false;
85 }
86 }
87 }
88
89 // At this point cpName is a unique name and isUnique is true.
90 // If cpName is not the original name, "name" is changed and isUnique is set
91 // to false, indicating that a vector with the original name already exists.
92 if (count > 1)
93 {
94 isUnique = false;
95 name = cpName;
96 }
97 return isUnique;
98}

References _mesh_vec.

Referenced by addMesh().

◆ removeBoundaryCondition()

void DataHolderLib::Project::removeBoundaryCondition ( std::string const & primary_var_name,
std::string const & param_name )

Removes one boundary condition.

Definition at line 123 of file Project.cpp.

125{
126 std::size_t const n_bc(_boundary_conditions.size());
127 for (std::size_t i = 0; i < n_bc; ++i)
128 {
129 if (_boundary_conditions[i]->getProcessVarName() == primary_var_name &&
130 _boundary_conditions[i]->getParamName() == param_name)
131 {
132 _boundary_conditions[i].reset();
134 return;
135 }
136 }
137}

References _boundary_conditions.

Referenced by ProcessModel::removeCondition(), and removePrimaryVariable().

◆ removeMesh()

bool DataHolderLib::Project::removeMesh ( const std::string & name)

Deletes all meshes with the given name and removes them from the list of saved meshes. If any mesh was found for removal, true is returned and false otherwise.

Definition at line 49 of file Project.cpp.

50{
51 auto it = findMeshByName(name);
52 if (it != _mesh_vec.end())
53 {
54 delete it->release();
55 _mesh_vec.erase(it);
56 return true;
57 }
58 return false;
59}

References _mesh_vec, and findMeshByName().

Referenced by MeshModel::removeMesh().

◆ removePrimaryVariable()

void DataHolderLib::Project::removePrimaryVariable ( std::string const & primary_var_name)

Removes a primary variable incl. all associated conditions.

Definition at line 100 of file Project.cpp.

101{
102 std::size_t const n_bc(_boundary_conditions.size());
103 for (int i = n_bc - 1; i >= 0; --i)
104 {
105 if (_boundary_conditions[i]->getProcessVarName() == primary_var_name)
106 {
107 removeBoundaryCondition(primary_var_name,
108 _boundary_conditions[i]->getParamName());
109 }
110 }
111
112 std::size_t const n_st(_source_terms.size());
113 for (int i = n_st - 1; i >= 0; --i)
114 {
115 if (_source_terms[i]->getProcessVarName() == primary_var_name)
116 {
117 removeSourceTerm(primary_var_name,
118 _source_terms[i]->getParamName());
119 }
120 }
121}
void removeSourceTerm(std::string const &primary_var_name, std::string const &param_name)
Remove one source term.
Definition Project.cpp:139
void removeBoundaryCondition(std::string const &primary_var_name, std::string const &param_name)
Removes one boundary condition.
Definition Project.cpp:123

References _boundary_conditions, _source_terms, removeBoundaryCondition(), and removeSourceTerm().

Referenced by ProcessModel::removeProcessVariable().

◆ removeSourceTerm()

void DataHolderLib::Project::removeSourceTerm ( std::string const & primary_var_name,
std::string const & param_name )

Remove one source term.

Definition at line 139 of file Project.cpp.

141{
142 std::size_t const n_st(_source_terms.size());
143 for (std::size_t i = 0; i < n_st; ++i)
144 {
145 if (_source_terms[i]->getProcessVarName() == primary_var_name &&
146 _source_terms[i]->getParamName() == param_name)
147 {
148 _source_terms[i].reset();
149 _source_terms.erase(_source_terms.begin() + i);
150 return;
151 }
152 }
153}

References _source_terms.

Referenced by ProcessModel::removeCondition(), and removePrimaryVariable().

Member Data Documentation

◆ _boundary_conditions

std::vector<std::unique_ptr<BoundaryCondition> > DataHolderLib::Project::_boundary_conditions
private

◆ _geoObjects

GeoLib::GEOObjects DataHolderLib::Project::_geoObjects
private

Definition at line 115 of file Project.h.

Referenced by getGEOObjects().

◆ _mesh_vec

std::vector<std::unique_ptr<MeshLib::Mesh> > DataHolderLib::Project::_mesh_vec
private

Definition at line 116 of file Project.h.

Referenced by addMesh(), findMeshByName(), getMesh(), getMeshObjects(), getUniqueName(), and removeMesh().

◆ _source_terms

std::vector<std::unique_ptr<SourceTerm> > DataHolderLib::Project::_source_terms
private

Definition at line 118 of file Project.h.

Referenced by addSourceTerm(), getSourceTerms(), removePrimaryVariable(), and removeSourceTerm().


The documentation for this class was generated from the following files: