From a6ac6a1b11a202f5ac5e743fed3b5e2cc393e970 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Mon, 31 Aug 2015 16:15:40 +0200 Subject: [PATCH] [PL] clang-format ProcessVariable. --- ProcessLib/ProcessVariable.cpp | 152 ++++++++++++++++----------------- ProcessLib/ProcessVariable.h | 82 +++++++++--------- 2 files changed, 116 insertions(+), 118 deletions(-) diff --git a/ProcessLib/ProcessVariable.cpp b/ProcessLib/ProcessVariable.cpp index a7e3e675d26..08862373000 100644 --- a/ProcessLib/ProcessVariable.cpp +++ b/ProcessLib/ProcessVariable.cpp @@ -18,81 +18,76 @@ #include "UniformDirichletBoundaryCondition.h" #include "InitialCondition.h" - namespace ProcessLib { - -ProcessVariable::ProcessVariable( - ConfigTree const& config, - MeshLib::Mesh const& mesh, - GeoLib::GEOObjects const& geometries) - : _name(config.get<std::string>("name")), - _mesh(mesh) +ProcessVariable::ProcessVariable(ConfigTree const& config, + MeshLib::Mesh const& mesh, + GeoLib::GEOObjects const& geometries) + : _name(config.get<std::string>("name")), _mesh(mesh) { - DBUG("Constructing process variable %s", this->_name.c_str()); - - // Initial condition - { - auto const& ic_config = config.find("initial_condition"); - if (ic_config == config.not_found()) - INFO("No initial condition found."); - - - std::string const type = - config.get<std::string>("initial_condition.type"); - if (type == "Uniform") - { - _initial_condition.reset(new UniformInitialCondition(ic_config->second)); - } - else - { - ERR("Unknown type of the initial condition."); - } - } - - // Boundary conditions - { - auto const& bcs_config = config.find("boundary_conditions"); - if (bcs_config == config.not_found()) - INFO("No boundary conditions found."); - - for (auto const& bc_iterator : bcs_config->second) - { - ConfigTree const& bc_config = bc_iterator.second; - - // Find corresponding GeoObject - std::string const geometrical_set_name = - bc_config.get<std::string>("geometrical_set"); - std::string const geometry_name = - bc_config.get<std::string>("geometry"); - - GeoLib::GeoObject const* const geometry = geometries.getGeoObject( - geometrical_set_name, geometry_name); - DBUG("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"); - - if (type == "UniformDirichlet") - { - _dirichlet_bcs.emplace_back( - new UniformDirichletBoundaryCondition( - geometry, bc_config)); - } - else if (type == "UniformNeumann") - { - _neumann_bc_configs.emplace_back( - new NeumannBcConfig(geometry, bc_config)); - } - else - { - ERR("Unknown type \'%s\' of the boundary condition.", - type.c_str()); - } - } - - } + DBUG("Constructing process variable %s", this->_name.c_str()); + + // Initial condition + { + auto const& ic_config = config.find("initial_condition"); + if (ic_config == config.not_found()) + INFO("No initial condition found."); + + std::string const type = + config.get<std::string>("initial_condition.type"); + if (type == "Uniform") + { + _initial_condition.reset( + new UniformInitialCondition(ic_config->second)); + } + else + { + ERR("Unknown type of the initial condition."); + } + } + + // Boundary conditions + { + auto const& bcs_config = config.find("boundary_conditions"); + if (bcs_config == config.not_found()) + INFO("No boundary conditions found."); + + for (auto const& bc_iterator : bcs_config->second) + { + ConfigTree const& bc_config = bc_iterator.second; + + // Find corresponding GeoObject + std::string const geometrical_set_name = + bc_config.get<std::string>("geometrical_set"); + std::string const geometry_name = + bc_config.get<std::string>("geometry"); + + GeoLib::GeoObject const* const geometry = + geometries.getGeoObject(geometrical_set_name, geometry_name); + DBUG( + "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"); + + if (type == "UniformDirichlet") + { + _dirichlet_bcs.emplace_back( + new UniformDirichletBoundaryCondition(geometry, bc_config)); + } + else if (type == "UniformNeumann") + { + _neumann_bc_configs.emplace_back( + new NeumannBcConfig(geometry, bc_config)); + } + else + { + ERR("Unknown type \'%s\' of the boundary condition.", + type.c_str()); + } + } + } } ProcessVariable::ProcessVariable(ProcessVariable&& other) @@ -101,24 +96,25 @@ ProcessVariable::ProcessVariable(ProcessVariable&& other) _initial_condition(std::move(other._initial_condition)), _dirichlet_bcs(std::move(other._dirichlet_bcs)), _neumann_bc_configs(std::move(other._neumann_bc_configs)) -{} +{ +} std::string const& ProcessVariable::getName() const { - return _name; + return _name; } MeshLib::Mesh const& ProcessVariable::getMesh() const { - return _mesh; + return _mesh; } void ProcessVariable::initializeDirichletBCs( MeshGeoToolsLib::MeshNodeSearcher& searcher, std::vector<std::size_t>& global_ids, std::vector<double>& values) { - for (auto& bc : _dirichlet_bcs) - bc->initialize(searcher, global_ids, values); + for (auto& bc : _dirichlet_bcs) + bc->initialize(searcher, global_ids, values); } -} // namespace ProcessLib +} // namespace ProcessLib diff --git a/ProcessLib/ProcessVariable.h b/ProcessLib/ProcessVariable.h index 3a1f236228a..e9b9ea13e7f 100644 --- a/ProcessLib/ProcessVariable.h +++ b/ProcessLib/ProcessVariable.h @@ -18,71 +18,73 @@ namespace MeshGeoToolsLib { - class MeshNodeSearcher; - class BoundaryElementsSearcher; +class MeshNodeSearcher; +class BoundaryElementsSearcher; } namespace MeshLib { - class Mesh; +class Mesh; } namespace GeoLib { - class GEOObjects; +class GEOObjects; } namespace ProcessLib { - class NeumannBcConfig; - class InitialCondition; - class UniformDirichletBoundaryCondition; +class NeumannBcConfig; +class InitialCondition; +class UniformDirichletBoundaryCondition; } namespace ProcessLib { - /// A named process variable. Its properties includes the mesh, and the initial /// and boundary conditions. class ProcessVariable { - using ConfigTree = boost::property_tree::ptree; + using ConfigTree = boost::property_tree::ptree; public: - ProcessVariable(ConfigTree const& config, MeshLib::Mesh const& mesh, - GeoLib::GEOObjects const& geometries); - - ProcessVariable(ProcessVariable&&); - - std::string const& getName() const; - - /// Returns a mesh on which the process variable is defined. - MeshLib::Mesh const& getMesh() const; - - void initializeDirichletBCs(MeshGeoToolsLib::MeshNodeSearcher& searcher, - std::vector<std::size_t>& global_ids, std::vector<double>& values); - - template <typename OutputIterator, typename GlobalSetup, typename ...Args> - void createNeumannBcs(OutputIterator bcs, - MeshGeoToolsLib::BoundaryElementsSearcher& searcher, - GlobalSetup const&, - Args&&... args) - { - for (auto& config : _neumann_bc_configs) - { - config->initialize(searcher); - bcs = new NeumannBc<GlobalSetup>(*config, std::forward<Args>(args)...); - } - } + ProcessVariable(ConfigTree const& config, MeshLib::Mesh const& mesh, + GeoLib::GEOObjects const& geometries); + + ProcessVariable(ProcessVariable&&); + + std::string const& getName() const; + + /// Returns a mesh on which the process variable is defined. + MeshLib::Mesh const& getMesh() const; + + void initializeDirichletBCs(MeshGeoToolsLib::MeshNodeSearcher& searcher, + std::vector<std::size_t>& global_ids, + std::vector<double>& values); + + template <typename OutputIterator, typename GlobalSetup, typename... Args> + void createNeumannBcs(OutputIterator bcs, + MeshGeoToolsLib::BoundaryElementsSearcher& searcher, + GlobalSetup const&, + Args&&... args) + { + for (auto& config : _neumann_bc_configs) + { + config->initialize(searcher); + bcs = new NeumannBc<GlobalSetup>(*config, + std::forward<Args>(args)...); + } + } private: - std::string const _name; - MeshLib::Mesh const& _mesh; - std::unique_ptr<InitialCondition> _initial_condition; - std::vector<std::unique_ptr<UniformDirichletBoundaryCondition> > _dirichlet_bcs; - std::vector<std::unique_ptr<NeumannBcConfig> > _neumann_bc_configs; + std::string const _name; + MeshLib::Mesh const& _mesh; + std::unique_ptr<InitialCondition> _initial_condition; + std::vector<std::unique_ptr<UniformDirichletBoundaryCondition>> + _dirichlet_bcs; + std::vector<std::unique_ptr<NeumannBcConfig>> _neumann_bc_configs; }; -} // namespace ProcessLib +} // namespace ProcessLib #endif // PROCESS_LIB_PROCESS_VARIABLE_H_ -- GitLab