diff --git a/ProcessLib/GroundwaterFlowProcess.h b/ProcessLib/GroundwaterFlowProcess.h index 2ab57aadc4ef998fd514334aa421ae364008566f..5eae3155390976389042080038bf8723509b6f92 100644 --- a/ProcessLib/GroundwaterFlowProcess.h +++ b/ProcessLib/GroundwaterFlowProcess.h @@ -37,7 +37,6 @@ #include "NeumannBc.h" #include "Parameter.h" #include "Process.h" -#include "ProcessVariable.h" namespace MeshLib { @@ -219,7 +218,7 @@ public: { DBUG("Initialize GroundwaterFlowProcess."); - setInitialConditions(*_hydraulic_head, 0); + Process<GlobalSetup>::setInitialConditions(*_hydraulic_head, 0); if (this->_mesh.getDimension()==1) createLocalAssemblers<1>(); @@ -231,23 +230,6 @@ public: assert(false); } - void setInitialConditions(ProcessVariable const& variable, - int const component_id) - { - std::size_t const n = this->_mesh.getNNodes(); - for (std::size_t i = 0; i < n; ++i) - { - MeshLib::Location const l(this->_mesh.getID(), - MeshLib::MeshItemType::Node, i); - auto const global_index = // 0 is the component id. - std::abs(this->_local_to_global_index_map->getGlobalIndex( - l, component_id)); - this->_x->set( - global_index, - variable.getInitialConditionValue(*this->_mesh.getNode(i))); - } - } - bool assemble(const double /*delta_t*/) override { DBUG("Assemble GroundwaterFlowProcess."); diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h index 5731d2125055feb64e6dca52e7bcfe79e6d6f7c2..afb68da27a8dcb560a770d377866d089778be085 100644 --- a/ProcessLib/Process.h +++ b/ProcessLib/Process.h @@ -23,6 +23,8 @@ #include "MathLib/LinAlg/PETSc/PETScMatrixOption.h" #endif +#include "ProcessVariable.h" + namespace MeshLib { class Mesh; @@ -128,6 +130,24 @@ protected: *_local_to_global_index_map, _mesh)); } + + /// Sets the initial condition values in the solution vector x for a given + /// process variable and component. + void setInitialConditions(ProcessVariable const& variable, + int const component_id) + { + std::size_t const n = _mesh.getNNodes(); + for (std::size_t i = 0; i < n; ++i) + { + MeshLib::Location const l(_mesh.getID(), + MeshLib::MeshItemType::Node, i); + auto const global_index = std::abs( + _local_to_global_index_map->getGlobalIndex(l, component_id)); + _x->set(global_index, + variable.getInitialConditionValue(*_mesh.getNode(i))); + } + } + protected: MeshLib::Mesh& _mesh; std::vector<MeshLib::MeshSubsets*> _all_mesh_subsets;