From fc36bb51ffe720897855710724d91e656908e346 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Tue, 24 Oct 2017 06:35:27 +0200 Subject: [PATCH] [PL/SourceTerms] Put SourceTerms in ProcessVars. --- ProcessLib/CMakeLists.txt | 1 + ProcessLib/ProcessVariable.cpp | 66 ++++++++++++++++++++++++++++++++-- ProcessLib/ProcessVariable.h | 8 +++++ 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/ProcessLib/CMakeLists.txt b/ProcessLib/CMakeLists.txt index 75ec2adcc56..6fd7c6b13dc 100644 --- a/ProcessLib/CMakeLists.txt +++ b/ProcessLib/CMakeLists.txt @@ -21,6 +21,7 @@ APPEND_SOURCE_FILES(SOURCES Parameter) APPEND_SOURCE_FILES(SOURCES PhaseField) APPEND_SOURCE_FILES(SOURCES RichardsFlow) APPEND_SOURCE_FILES(SOURCES SmallDeformation) +APPEND_SOURCE_FILES(SOURCES SourceTerms) APPEND_SOURCE_FILES(SOURCES TES) APPEND_SOURCE_FILES(SOURCES ThermoMechanics) APPEND_SOURCE_FILES(SOURCES TwoPhaseFlowWithPP) diff --git a/ProcessLib/ProcessVariable.cpp b/ProcessLib/ProcessVariable.cpp index 404c978e2df..987e6b0989f 100644 --- a/ProcessLib/ProcessVariable.cpp +++ b/ProcessLib/ProcessVariable.cpp @@ -33,7 +33,8 @@ ProcessVariable::ProcessVariable( //! \ogs_file_param{prj__process_variables__process_variable__initial_condition} config.getConfigParameter<std::string>("initial_condition"), parameters, _n_components)), - _bc_builder(std::make_unique<BoundaryConditionBuilder>()) + _bc_builder(std::make_unique<BoundaryConditionBuilder>()), + _source_term_builder(std::make_unique<SourceTermBuilder>()) { DBUG("Constructing process variable %s", _name.c_str()); @@ -82,6 +83,49 @@ ProcessVariable::ProcessVariable( } else { INFO("No boundary conditions found."); } + + // Source terms + //! \ogs_file_param{prj__process_variables__process_variable__source_terms} + if (auto sts_config = config.getConfigSubtreeOptional("source_terms")) + { + for (auto st_config : + //! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term} + sts_config->getConfigSubtreeList("source_term")) + { + auto const geometrical_set_name = + //! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__geometrical_set} + st_config.getConfigParameter<std::string>("geometrical_set"); + auto const geometry_name = + //! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__geometry} + st_config.getConfigParameter<std::string>("geometry"); + + GeoLib::GeoObject const* const geometry = + geometries.getGeoObject(geometrical_set_name, geometry_name); + + if (! geometry) + OGS_FATAL( + "No geometry with name `%s' has been found in the " + "geometrical set `%s'.", + geometry_name.c_str(), geometrical_set_name.c_str()); + + DBUG( + "Found geometry type \"%s\"", + GeoLib::convertGeoTypeToString(geometry->getGeoType()).c_str()); + + auto component_id = + //! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__component} + st_config.getConfigParameterOptional<int>("component"); + + if (!component_id && _n_components == 1) + // default value for single component vars. + component_id = 0; + + _source_term_configs.emplace_back(std::move(st_config), *geometry, + component_id); + } + } else { + INFO("No source terms found."); + } } ProcessVariable::ProcessVariable(ProcessVariable&& other) @@ -91,7 +135,9 @@ ProcessVariable::ProcessVariable(ProcessVariable&& other) _shapefunction_order(other._shapefunction_order), _initial_condition(std::move(other._initial_condition)), _bc_configs(std::move(other._bc_configs)), - _bc_builder(std::move(other._bc_builder)) + _bc_builder(std::move(other._bc_builder)), + _source_term_configs(std::move(other._source_term_configs)), + _source_term_builder(std::move(other._source_term_builder)) { } @@ -128,4 +174,20 @@ ProcessVariable::createBoundaryConditions( return bcs; } +std::vector<std::unique_ptr<NodalSourceTerm>> +ProcessVariable::createSourceTerms( + const NumLib::LocalToGlobalIndexMap& dof_table, + const int variable_id, + unsigned const integration_order) +{ + std::vector<std::unique_ptr<NodalSourceTerm>> source_terms; + + for (auto& config : _source_term_configs) + source_terms.emplace_back(_source_term_builder->createSourceTerm( + config, dof_table, _mesh, variable_id, integration_order, + _shapefunction_order)); + + return source_terms; +} + } // namespace ProcessLib diff --git a/ProcessLib/ProcessVariable.h b/ProcessLib/ProcessVariable.h index 56aa3c9e797..1fe809b6c45 100644 --- a/ProcessLib/ProcessVariable.h +++ b/ProcessLib/ProcessVariable.h @@ -12,6 +12,8 @@ #include "ProcessLib/BoundaryCondition/BoundaryCondition.h" #include "ProcessLib/BoundaryCondition/BoundaryConditionConfig.h" #include "ProcessLib/Parameter/Parameter.h" +#include "ProcessLib/SourceTerms/SourceTermConfig.h" +#include "ProcessLib/SourceTerms/SourceTermBuilder.h" namespace MeshLib { @@ -53,6 +55,10 @@ public: unsigned const integration_order, std::vector<std::unique_ptr<ParameterBase>> const& parameters); + std::vector<std::unique_ptr<NodalSourceTerm>> createSourceTerms( + const NumLib::LocalToGlobalIndexMap& dof_table, const int variable_id, + unsigned const integration_order); + Parameter<double> const& getInitialCondition() const { return _initial_condition; @@ -87,6 +93,8 @@ private: std::vector<BoundaryConditionConfig> _bc_configs; std::unique_ptr<BoundaryConditionBuilder> _bc_builder; + std::vector<SourceTermConfig> _source_term_configs; + std::unique_ptr<SourceTermBuilder> _source_term_builder; }; } // namespace ProcessLib -- GitLab