Skip to content
Snippets Groups Projects
Commit a6ac6a1b authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[PL] clang-format ProcessVariable.

parent e118b539
No related branches found
No related tags found
No related merge requests found
...@@ -18,81 +18,76 @@ ...@@ -18,81 +18,76 @@
#include "UniformDirichletBoundaryCondition.h" #include "UniformDirichletBoundaryCondition.h"
#include "InitialCondition.h" #include "InitialCondition.h"
namespace ProcessLib namespace ProcessLib
{ {
ProcessVariable::ProcessVariable(ConfigTree const& config,
ProcessVariable::ProcessVariable( MeshLib::Mesh const& mesh,
ConfigTree const& config, GeoLib::GEOObjects const& geometries)
MeshLib::Mesh const& mesh, : _name(config.get<std::string>("name")), _mesh(mesh)
GeoLib::GEOObjects const& geometries)
: _name(config.get<std::string>("name")),
_mesh(mesh)
{ {
DBUG("Constructing process variable %s", this->_name.c_str()); DBUG("Constructing process variable %s", this->_name.c_str());
// Initial condition // Initial condition
{ {
auto const& ic_config = config.find("initial_condition"); auto const& ic_config = config.find("initial_condition");
if (ic_config == config.not_found()) if (ic_config == config.not_found())
INFO("No initial condition found."); INFO("No initial condition found.");
std::string const type =
std::string const type = config.get<std::string>("initial_condition.type");
config.get<std::string>("initial_condition.type"); if (type == "Uniform")
if (type == "Uniform") {
{ _initial_condition.reset(
_initial_condition.reset(new UniformInitialCondition(ic_config->second)); new UniformInitialCondition(ic_config->second));
} }
else else
{ {
ERR("Unknown type of the initial condition."); ERR("Unknown type of the initial condition.");
} }
} }
// Boundary conditions // Boundary conditions
{ {
auto const& bcs_config = config.find("boundary_conditions"); auto const& bcs_config = config.find("boundary_conditions");
if (bcs_config == config.not_found()) if (bcs_config == config.not_found())
INFO("No boundary conditions found."); INFO("No boundary conditions found.");
for (auto const& bc_iterator : bcs_config->second) for (auto const& bc_iterator : bcs_config->second)
{ {
ConfigTree const& bc_config = bc_iterator.second; ConfigTree const& bc_config = bc_iterator.second;
// Find corresponding GeoObject // Find corresponding GeoObject
std::string const geometrical_set_name = std::string const geometrical_set_name =
bc_config.get<std::string>("geometrical_set"); bc_config.get<std::string>("geometrical_set");
std::string const geometry_name = std::string const geometry_name =
bc_config.get<std::string>("geometry"); bc_config.get<std::string>("geometry");
GeoLib::GeoObject const* const geometry = geometries.getGeoObject( GeoLib::GeoObject const* const geometry =
geometrical_set_name, geometry_name); geometries.getGeoObject(geometrical_set_name, geometry_name);
DBUG("Found geometry type \"%s\"", DBUG(
GeoLib::convertGeoTypeToString(geometry->getGeoType()).c_str()); "Found geometry type \"%s\"",
GeoLib::convertGeoTypeToString(geometry->getGeoType()).c_str());
// Construct type dependent boundary condition
std::string const type = bc_config.get<std::string>("type"); // Construct type dependent boundary condition
std::string const type = bc_config.get<std::string>("type");
if (type == "UniformDirichlet")
{ if (type == "UniformDirichlet")
_dirichlet_bcs.emplace_back( {
new UniformDirichletBoundaryCondition( _dirichlet_bcs.emplace_back(
geometry, bc_config)); new UniformDirichletBoundaryCondition(geometry, bc_config));
} }
else if (type == "UniformNeumann") else if (type == "UniformNeumann")
{ {
_neumann_bc_configs.emplace_back( _neumann_bc_configs.emplace_back(
new NeumannBcConfig(geometry, bc_config)); new NeumannBcConfig(geometry, bc_config));
} }
else else
{ {
ERR("Unknown type \'%s\' of the boundary condition.", ERR("Unknown type \'%s\' of the boundary condition.",
type.c_str()); type.c_str());
} }
} }
}
}
} }
ProcessVariable::ProcessVariable(ProcessVariable&& other) ProcessVariable::ProcessVariable(ProcessVariable&& other)
...@@ -101,24 +96,25 @@ ProcessVariable::ProcessVariable(ProcessVariable&& other) ...@@ -101,24 +96,25 @@ ProcessVariable::ProcessVariable(ProcessVariable&& other)
_initial_condition(std::move(other._initial_condition)), _initial_condition(std::move(other._initial_condition)),
_dirichlet_bcs(std::move(other._dirichlet_bcs)), _dirichlet_bcs(std::move(other._dirichlet_bcs)),
_neumann_bc_configs(std::move(other._neumann_bc_configs)) _neumann_bc_configs(std::move(other._neumann_bc_configs))
{} {
}
std::string const& ProcessVariable::getName() const std::string const& ProcessVariable::getName() const
{ {
return _name; return _name;
} }
MeshLib::Mesh const& ProcessVariable::getMesh() const MeshLib::Mesh const& ProcessVariable::getMesh() const
{ {
return _mesh; return _mesh;
} }
void ProcessVariable::initializeDirichletBCs( void ProcessVariable::initializeDirichletBCs(
MeshGeoToolsLib::MeshNodeSearcher& searcher, MeshGeoToolsLib::MeshNodeSearcher& searcher,
std::vector<std::size_t>& global_ids, std::vector<double>& values) std::vector<std::size_t>& global_ids, std::vector<double>& values)
{ {
for (auto& bc : _dirichlet_bcs) for (auto& bc : _dirichlet_bcs)
bc->initialize(searcher, global_ids, values); bc->initialize(searcher, global_ids, values);
} }
} // namespace ProcessLib } // namespace ProcessLib
...@@ -18,71 +18,73 @@ ...@@ -18,71 +18,73 @@
namespace MeshGeoToolsLib namespace MeshGeoToolsLib
{ {
class MeshNodeSearcher; class MeshNodeSearcher;
class BoundaryElementsSearcher; class BoundaryElementsSearcher;
} }
namespace MeshLib namespace MeshLib
{ {
class Mesh; class Mesh;
} }
namespace GeoLib namespace GeoLib
{ {
class GEOObjects; class GEOObjects;
} }
namespace ProcessLib namespace ProcessLib
{ {
class NeumannBcConfig; class NeumannBcConfig;
class InitialCondition; class InitialCondition;
class UniformDirichletBoundaryCondition; class UniformDirichletBoundaryCondition;
} }
namespace ProcessLib namespace ProcessLib
{ {
/// A named process variable. Its properties includes the mesh, and the initial /// A named process variable. Its properties includes the mesh, and the initial
/// and boundary conditions. /// and boundary conditions.
class ProcessVariable class ProcessVariable
{ {
using ConfigTree = boost::property_tree::ptree; using ConfigTree = boost::property_tree::ptree;
public: public:
ProcessVariable(ConfigTree const& config, MeshLib::Mesh const& mesh, ProcessVariable(ConfigTree const& config, MeshLib::Mesh const& mesh,
GeoLib::GEOObjects const& geometries); GeoLib::GEOObjects const& geometries);
ProcessVariable(ProcessVariable&&); ProcessVariable(ProcessVariable&&);
std::string const& getName() const; std::string const& getName() const;
/// Returns a mesh on which the process variable is defined. /// Returns a mesh on which the process variable is defined.
MeshLib::Mesh const& getMesh() const; MeshLib::Mesh const& getMesh() const;
void initializeDirichletBCs(MeshGeoToolsLib::MeshNodeSearcher& searcher, void initializeDirichletBCs(MeshGeoToolsLib::MeshNodeSearcher& searcher,
std::vector<std::size_t>& global_ids, std::vector<double>& values); std::vector<std::size_t>& global_ids,
std::vector<double>& values);
template <typename OutputIterator, typename GlobalSetup, typename ...Args>
void createNeumannBcs(OutputIterator bcs, template <typename OutputIterator, typename GlobalSetup, typename... Args>
MeshGeoToolsLib::BoundaryElementsSearcher& searcher, void createNeumannBcs(OutputIterator bcs,
GlobalSetup const&, MeshGeoToolsLib::BoundaryElementsSearcher& searcher,
Args&&... args) GlobalSetup const&,
{ Args&&... args)
for (auto& config : _neumann_bc_configs) {
{ for (auto& config : _neumann_bc_configs)
config->initialize(searcher); {
bcs = new NeumannBc<GlobalSetup>(*config, std::forward<Args>(args)...); config->initialize(searcher);
} bcs = new NeumannBc<GlobalSetup>(*config,
} std::forward<Args>(args)...);
}
}
private: private:
std::string const _name; std::string const _name;
MeshLib::Mesh const& _mesh; MeshLib::Mesh const& _mesh;
std::unique_ptr<InitialCondition> _initial_condition; std::unique_ptr<InitialCondition> _initial_condition;
std::vector<std::unique_ptr<UniformDirichletBoundaryCondition> > _dirichlet_bcs; std::vector<std::unique_ptr<UniformDirichletBoundaryCondition>>
std::vector<std::unique_ptr<NeumannBcConfig> > _neumann_bc_configs; _dirichlet_bcs;
std::vector<std::unique_ptr<NeumannBcConfig>> _neumann_bc_configs;
}; };
} // namespace ProcessLib } // namespace ProcessLib
#endif // PROCESS_LIB_PROCESS_VARIABLE_H_ #endif // PROCESS_LIB_PROCESS_VARIABLE_H_
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment