From f8b343eb5809eaced02a9de0bb0f1f10afbf8839 Mon Sep 17 00:00:00 2001 From: Wenqing Wang <wenqing.wang@ufz.de> Date: Thu, 7 Dec 2017 16:10:58 +0100 Subject: [PATCH] [Coupling] Move a member of class Process to the derived class --- .../ComponentTransportProcess.cpp | 5 ---- ProcessLib/HT/HTProcess.cpp | 24 +++++++++++++++++++ ProcessLib/HT/HTProcess.h | 11 ++++----- .../HydroMechanicsProcess-impl.h | 1 - ProcessLib/Process.cpp | 23 ------------------ ProcessLib/Process.h | 12 ---------- 6 files changed, 28 insertions(+), 48 deletions(-) diff --git a/ProcessLib/ComponentTransport/ComponentTransportProcess.cpp b/ProcessLib/ComponentTransport/ComponentTransportProcess.cpp index 9e6a33c4552..45fcf30aaac 100644 --- a/ProcessLib/ComponentTransport/ComponentTransportProcess.cpp +++ b/ProcessLib/ComponentTransport/ComponentTransportProcess.cpp @@ -63,8 +63,6 @@ void ComponentTransportProcess::assembleConcreteProcess( GlobalVector& b) { DBUG("Assemble ComponentTransportProcess."); - if (!_use_monolithic_scheme) - setCoupledSolutionsOfPreviousTimeStep(); // Call global assembler for each local assembly item. GlobalExecutor::executeMemberDereferenced( @@ -79,9 +77,6 @@ void ComponentTransportProcess::assembleWithJacobianConcreteProcess( { DBUG("AssembleWithJacobian ComponentTransportProcess."); - if (!_use_monolithic_scheme) - setCoupledSolutionsOfPreviousTimeStep(); - // Call global assembler for each local assembly item. GlobalExecutor::executeMemberDereferenced( _global_assembler, &VectorMatrixAssembler::assembleWithJacobian, diff --git a/ProcessLib/HT/HTProcess.cpp b/ProcessLib/HT/HTProcess.cpp index 8689a67a9b9..1ef758b9f1c 100644 --- a/ProcessLib/HT/HTProcess.cpp +++ b/ProcessLib/HT/HTProcess.cpp @@ -189,5 +189,29 @@ NumLib::LocalToGlobalIndexMap* HTProcess::getDOFTableForExtrapolatorData( NumLib::ComponentOrder::BY_LOCATION); } +void HTProcess::setCoupledSolutionsOfPreviousTimeStep() +{ + const auto number_of_coupled_solutions = + _coupled_solutions->coupled_xs.size(); + _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].get(); + 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 overloading " + "Process::preTimestepConcreteProcess" + "(ref. HTProcess::preTimestepConcreteProcess) "); + } + + MathLib::LinAlg::setLocalAccessibleVector(*x_t0); + _coupled_solutions->coupled_xs_t0.emplace_back(x_t0); + } +} + } // namespace HT } // namespace ProcessLib diff --git a/ProcessLib/HT/HTProcess.h b/ProcessLib/HT/HTProcess.h index 55aba2df282..e0398f08e29 100644 --- a/ProcessLib/HT/HTProcess.h +++ b/ProcessLib/HT/HTProcess.h @@ -67,13 +67,6 @@ public: bool isLinear() const override { return false; } //! @} - // Get the solution of the previous time step. - GlobalVector* getPreviousTimeStepSolution( - const int process_id) const override - { - return _xs_previous_timestep[process_id].get(); - } - void setCoupledTermForTheStaggeredSchemeToLocalAssemblers() override; private: @@ -95,6 +88,10 @@ private: double const dt, const int process_id) override; + /// Set the solutions of the previous time step to the coupled term. + /// It only performs for the staggered scheme. + void setCoupledSolutionsOfPreviousTimeStep(); + NumLib::LocalToGlobalIndexMap* getDOFTableForExtrapolatorData( bool& manage_storage) const override; diff --git a/ProcessLib/HydroMechanics/HydroMechanicsProcess-impl.h b/ProcessLib/HydroMechanics/HydroMechanicsProcess-impl.h index d584ad7e5a7..bbb0eb26652 100644 --- a/ProcessLib/HydroMechanics/HydroMechanicsProcess-impl.h +++ b/ProcessLib/HydroMechanics/HydroMechanicsProcess-impl.h @@ -289,7 +289,6 @@ void HydroMechanicsProcess<DisplacementDim>:: } // For the staggered scheme - setCoupledSolutionsOfPreviousTimeStep(); // For the equations of displacement if (_coupled_solutions->process_id == 1) { diff --git a/ProcessLib/Process.cpp b/ProcessLib/Process.cpp index 5e7ec8894c6..b2ea3a4503a 100644 --- a/ProcessLib/Process.cpp +++ b/ProcessLib/Process.cpp @@ -375,27 +375,4 @@ NumLib::IterationResult Process::postIteration(const GlobalVector& x) return postIterationConcreteProcess(x); } -void Process::setCoupledSolutionsOfPreviousTimeStep() -{ - const auto number_of_coupled_solutions = - _coupled_solutions->coupled_xs.size(); - _coupled_solutions->coupled_xs_t0.reserve(number_of_coupled_solutions); - for (std::size_t i = 0; i < number_of_coupled_solutions; i++) - { - const auto x_t0 = getPreviousTimeStepSolution(i); - 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 overloading " - "Process::preTimestepConcreteProcess" - "(ref. HTProcess::preTimestepConcreteProcess) "); - } - - MathLib::LinAlg::setLocalAccessibleVector(*x_t0); - _coupled_solutions->coupled_xs_t0.emplace_back(x_t0); - } -} - } // namespace ProcessLib diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h index 971dcd95765..3ca1e200efd 100644 --- a/ProcessLib/Process.h +++ b/ProcessLib/Process.h @@ -118,14 +118,6 @@ public: return _secondary_variables; } - // Get the solution of the previous time step. - - virtual GlobalVector* getPreviousTimeStepSolution( - const int /*process_id*/) const - { - return nullptr; - } - // Used as a call back for CalculateSurfaceFlux process. virtual std::vector<double> getFlux(std::size_t /*element_id*/, @@ -238,10 +230,6 @@ protected: /// references to the solutions of the coupled processes. CoupledSolutionsForStaggeredScheme* _coupled_solutions; - /// Set the solutions of the previous time step to the coupled term. - /// It only performs for the staggered scheme. - void setCoupledSolutionsOfPreviousTimeStep(); - /// Order of the integration method for element-wise integration. /// The Gauss-Legendre integration method and available orders is /// implemented in MathLib::GaussLegendre. -- GitLab