diff --git a/ProcessLib/HT/HTProcess.cpp b/ProcessLib/HT/HTProcess.cpp index 0de70fb4e80a9f62a87a8a7f2fd0543d8f015429..d19f57f597b89dcecb5c982326f7f2fc589d7293 100644 --- a/ProcessLib/HT/HTProcess.cpp +++ b/ProcessLib/HT/HTProcess.cpp @@ -153,8 +153,8 @@ void HTProcess::assembleWithJacobianConcreteProcess( ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0]; GlobalExecutor::executeSelectedMemberDereferenced( _global_assembler, &VectorMatrixAssembler::assembleWithJacobian, - _local_assemblers, pv.getActiveElementIDs(), dof_tables, t, x, - xdot, dxdot_dx, dx_dx, M, K, b, Jac, _coupled_solutions); + _local_assemblers, pv.getActiveElementIDs(), dof_tables, t, x, xdot, + dxdot_dx, dx_dx, M, K, b, Jac, _coupled_solutions); } void HTProcess::preTimestepConcreteProcess(GlobalVector const& x, @@ -193,8 +193,7 @@ void HTProcess::setCoupledTermForTheStaggeredSchemeToLocalAssemblers() ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0]; GlobalExecutor::executeSelectedMemberOnDereferenced( &HTLocalAssemblerInterface::setStaggeredCoupledSolutions, - _local_assemblers, pv.getActiveElementIDs(), - _coupled_solutions); + _local_assemblers, pv.getActiveElementIDs(), _coupled_solutions); } std::tuple<NumLib::LocalToGlobalIndexMap*, bool> @@ -221,29 +220,27 @@ HTProcess::getDOFTableForExtrapolatorData() const manage_storage); } -void HTProcess::setCoupledSolutionsOfPreviousTimeStep() +void HTProcess::setCoupledSolutionsOfPreviousTimeStepPerProcess( + const int process_id) { - const auto number_of_coupled_solutions = - _coupled_solutions->coupled_xs.size(); - _coupled_solutions->coupled_xs_t0.clear(); - _coupled_solutions->coupled_xs_t0.reserve(number_of_coupled_solutions); - const int process_id = _coupled_solutions->process_id; - for (std::size_t i = 0; i < number_of_coupled_solutions; i++) + const auto& x_t0 = _xs_previous_timestep[process_id]; + if (x_t0 == nullptr) { - const auto& x_t0 = _xs_previous_timestep[process_id]; - if (x_t0 == nullptr) - { - OGS_FATAL( - "Memory is not allocated for the global vector " - "of the solution of the previous time step for the ." - "staggered scheme.\n It can be done by overriding " - "Process::preTimestepConcreteProcess" - "(ref. HTProcess::preTimestepConcreteProcess) "); - } - - MathLib::LinAlg::setLocalAccessibleVector(*x_t0); - _coupled_solutions->coupled_xs_t0.emplace_back(x_t0.get()); + OGS_FATAL( + "Memory is not allocated for the global vector of the solution of " + "the previous time step for the staggered scheme.\n It can be done " + "by overriding Process::preTimestepConcreteProcess (ref. " + "HTProcess::preTimestepConcreteProcess) "); } + + _coupled_solutions->coupled_xs_t0[process_id] = x_t0.get(); +} + +void HTProcess::setCoupledSolutionsOfPreviousTimeStep() +{ + _coupled_solutions->coupled_xs_t0.resize(2); + setCoupledSolutionsOfPreviousTimeStepPerProcess(_heat_transport_process_id); + setCoupledSolutionsOfPreviousTimeStepPerProcess(_hydraulic_process_id); } Eigen::Vector3d HTProcess::getFlux(std::size_t element_id, diff --git a/ProcessLib/HT/HTProcess.h b/ProcessLib/HT/HTProcess.h index 1c1d06b1e6d09200f372215e75f632a27445767c..a955d35d4ae8402d0a6075ac83cbd94249e6edbb 100644 --- a/ProcessLib/HT/HTProcess.h +++ b/ProcessLib/HT/HTProcess.h @@ -101,8 +101,11 @@ private: double const dt, const int process_id) override; + void setCoupledSolutionsOfPreviousTimeStepPerProcess(const int process_id); + /// Set the solutions of the previous time step to the coupled term. - /// It only performs for the staggered scheme. + /// It is only for the staggered scheme, and it must be called within + /// the coupling loop because that the coupling term is only created there. void setCoupledSolutionsOfPreviousTimeStep(); /**