From a08b0e51491ac8ef0c4c81e8ac2cf747b1bda949 Mon Sep 17 00:00:00 2001 From: Wenqing Wang <wenqing.wang@ufz.de> Date: Thu, 21 Feb 2019 15:30:27 +0100 Subject: [PATCH] [HT] Enabled more flexible process order within the staggered coupling --- ProcessLib/HT/HTProcess.cpp | 45 +++++++++++++++++-------------------- ProcessLib/HT/HTProcess.h | 5 ++++- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/ProcessLib/HT/HTProcess.cpp b/ProcessLib/HT/HTProcess.cpp index 0de70fb4e80..d19f57f597b 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 1c1d06b1e6d..a955d35d4ae 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(); /** -- GitLab