From f9918d2aabf5273d3a6f86b3d01d3f044e76273f Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Mon, 29 Jan 2018 09:07:17 +0100 Subject: [PATCH] [PL] SourceTerms: Forward and use the parameter. --- ProcessLib/SourceTerms/CreateNodalSourceTerm.cpp | 13 ++++++++----- ProcessLib/SourceTerms/CreateNodalSourceTerm.h | 3 ++- ProcessLib/SourceTerms/NodalSourceTerm.cpp | 12 ++++++++---- ProcessLib/SourceTerms/NodalSourceTerm.h | 5 +++-- ProcessLib/SourceTerms/SourceTermBuilder.cpp | 2 +- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ProcessLib/SourceTerms/CreateNodalSourceTerm.cpp b/ProcessLib/SourceTerms/CreateNodalSourceTerm.cpp index 9a561ed74b4..0253b79e888 100644 --- a/ProcessLib/SourceTerms/CreateNodalSourceTerm.cpp +++ b/ProcessLib/SourceTerms/CreateNodalSourceTerm.cpp @@ -18,18 +18,21 @@ namespace ProcessLib std::unique_ptr<NodalSourceTerm> createNodalSourceTerm( BaseLib::ConfigTree const& config, const NumLib::LocalToGlobalIndexMap& dof_table, std::size_t const mesh_id, - std::size_t const node_id, const int variable_id, const int component_id) + std::size_t const node_id, const int variable_id, const int component_id, + std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters) { DBUG("Constructing NodalSourceTerm from config."); //! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__type} config.checkConfigParameter("type", "Nodal"); - //! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__Nodal__value} - auto const nodal_value = config.getConfigParameter<double>("value"); - DBUG("Using value %f as nodal source term", nodal_value); + //! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__parameter} + auto const param_name = config.getConfigParameter<std::string>("parameter"); + DBUG("Using parameter %s as nodal source term.", param_name.c_str()); + + auto& param = findParameter<double>(param_name, parameters, 1); return std::make_unique<NodalSourceTerm>( - dof_table, mesh_id, node_id, variable_id, component_id, nodal_value); + dof_table, mesh_id, node_id, variable_id, component_id, param); } } // namespace ProcessLib diff --git a/ProcessLib/SourceTerms/CreateNodalSourceTerm.h b/ProcessLib/SourceTerms/CreateNodalSourceTerm.h index d779a933c30..7a8bfa7adc6 100644 --- a/ProcessLib/SourceTerms/CreateNodalSourceTerm.h +++ b/ProcessLib/SourceTerms/CreateNodalSourceTerm.h @@ -17,6 +17,7 @@ namespace ProcessLib std::unique_ptr<NodalSourceTerm> createNodalSourceTerm( BaseLib::ConfigTree const& config, const NumLib::LocalToGlobalIndexMap& dof_table, std::size_t mesh_id, - std::size_t const node_id, const int variable_id, const int component_id); + std::size_t const node_id, const int variable_id, const int component_id, + std::vector<std::unique_ptr<ProcessLib::ParameterBase>> const& parameters); } // namespace ProcessLib diff --git a/ProcessLib/SourceTerms/NodalSourceTerm.cpp b/ProcessLib/SourceTerms/NodalSourceTerm.cpp index aa358ac21b5..6811bf8c952 100644 --- a/ProcessLib/SourceTerms/NodalSourceTerm.cpp +++ b/ProcessLib/SourceTerms/NodalSourceTerm.cpp @@ -17,18 +17,18 @@ NodalSourceTerm::NodalSourceTerm(const NumLib::LocalToGlobalIndexMap& dof_table, std::size_t const mesh_id, std::size_t const node_id, const int variable_id, const int component_id, - double value) + Parameter<double> const& parameter) : _dof_table(dof_table), _mesh_id(mesh_id), _node_id(node_id), _variable_id(variable_id), _component_id(component_id), - _value(value) + _parameter(parameter) { DBUG("Create NodalSourceTerm."); } -void NodalSourceTerm::integrateNodalSourceTerm(const double /*t*/, +void NodalSourceTerm::integrateNodalSourceTerm(const double t, GlobalVector& b) const { DBUG("Assemble NodalSourceTerm."); @@ -36,7 +36,11 @@ void NodalSourceTerm::integrateNodalSourceTerm(const double /*t*/, MeshLib::Location const l{_mesh_id, MeshLib::MeshItemType::Node, _node_id}; auto const index = _dof_table.getGlobalIndex(l, _variable_id, _component_id); - b.add(index, _value); + + SpatialPosition pos; + pos.setNodeID(_node_id); + + b.add(index, _parameter(t, pos).front()); } } // namespace ProcessLib diff --git a/ProcessLib/SourceTerms/NodalSourceTerm.h b/ProcessLib/SourceTerms/NodalSourceTerm.h index 65b85a1c461..9ee08a61e01 100644 --- a/ProcessLib/SourceTerms/NodalSourceTerm.h +++ b/ProcessLib/SourceTerms/NodalSourceTerm.h @@ -10,6 +10,7 @@ #pragma once #include "NumLib/DOF/LocalToGlobalIndexMap.h" +#include "ProcessLib/Parameter/Parameter.h" namespace ProcessLib { @@ -19,7 +20,7 @@ public: NodalSourceTerm(const NumLib::LocalToGlobalIndexMap& dof_table, std::size_t const mesh_id, std::size_t const node_id, const int variable_id, const int component_id, - double value); + Parameter<double> const& parameter); void integrateNodalSourceTerm( const double t, @@ -31,7 +32,7 @@ private: std::size_t const _node_id; int const _variable_id; int const _component_id; - double const _value; + Parameter<double> const& _parameter; }; } // namespace ProcessLib diff --git a/ProcessLib/SourceTerms/SourceTermBuilder.cpp b/ProcessLib/SourceTerms/SourceTermBuilder.cpp index 740b1df6ae9..cbf4cbf3527 100644 --- a/ProcessLib/SourceTerms/SourceTermBuilder.cpp +++ b/ProcessLib/SourceTerms/SourceTermBuilder.cpp @@ -95,7 +95,7 @@ std::unique_ptr<NodalSourceTerm> SourceTermBuilder::createNodalSourceTerm( return ProcessLib::createNodalSourceTerm( config.config, dof_table, mesh.getID(), ids[0], variable_id, - *config.component_id); + *config.component_id, parameters); } } // ProcessLib -- GitLab