diff --git a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.cpp b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.cpp index 68a5c72a3755888d275432349e62fd8c244cc388..d50fb4e08c6acaeaca331d956be82fff92f83660 100644 --- a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.cpp +++ b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.cpp @@ -104,13 +104,14 @@ void GroundwaterFlowProcess::assembleWithJacobianConcreteProcess( } -void GroundwaterFlowProcess::computeSecondaryVariableConcrete(const double t, - GlobalVector const& x) +void GroundwaterFlowProcess::computeSecondaryVariableConcrete( + const double t, GlobalVector const& x, + StaggeredCouplingTerm const& coupled_term) { DBUG("Compute the velocity for GroundwaterFlowProcess."); GlobalExecutor::executeMemberOnDereferenced( &GroundwaterFlowLocalAssemblerInterface::computeSecondaryVariable, - _local_assemblers, *_local_to_global_index_map, t, x); + _local_assemblers, *_local_to_global_index_map, t, x, coupled_term); } } // namespace GroundwaterFlow diff --git a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h index 694a84aa0fd046c79ba7eb0d22209fe13b620e4c..eadd1739792ce1aa9abfb4827f5ce130d743e213 100644 --- a/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h +++ b/ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h @@ -88,7 +88,9 @@ public: } void computeSecondaryVariableConcrete(double const t, - GlobalVector const& x) override; + GlobalVector const& x, + StaggeredCouplingTerm const& + coupled_term) override; private: void initializeConcreteProcess( diff --git a/ProcessLib/HeatConduction/HeatConductionFEM-impl.h b/ProcessLib/HeatConduction/HeatConductionFEM-impl.h index 598bc0d1d46a09f423304f021719fde6fc6757ba..2110040f4a262e826a5365f4b4ff10c480b283da 100644 --- a/ProcessLib/HeatConduction/HeatConductionFEM-impl.h +++ b/ProcessLib/HeatConduction/HeatConductionFEM-impl.h @@ -106,11 +106,11 @@ void LocalAssemblerData<ShapeFunction, IntegrationMethod, GlobalDim>:: template <typename ShapeFunction, typename IntegrationMethod, unsigned GlobalDim> void LocalAssemblerData<ShapeFunction, IntegrationMethod, GlobalDim>:: - coupling_assemble(double const t, std::vector<double> const& local_x, - std::vector<double>& local_M_data, - std::vector<double>& local_K_data, - std::vector<double>& /*local_b_data*/, - LocalCouplingTerm const& coupled_term) + assembleWithCoupledTerm(double const t, std::vector<double> const& local_x, + std::vector<double>& local_M_data, + std::vector<double>& local_K_data, + std::vector<double>& /*local_b_data*/, + LocalCouplingTerm const& coupled_term) { for (auto const& coupled_process_pair : coupled_term.coupled_processes) { diff --git a/ProcessLib/HeatConduction/HeatConductionFEM.h b/ProcessLib/HeatConduction/HeatConductionFEM.h index 3c65463b8542341e2286c16bb7a743f768876c62..1afceed27c72ee287af4bacb2ddacbbf39e9a267 100644 --- a/ProcessLib/HeatConduction/HeatConductionFEM.h +++ b/ProcessLib/HeatConduction/HeatConductionFEM.h @@ -122,11 +122,11 @@ public: } } - void coupling_assemble(double const t, std::vector<double> const& local_x, - std::vector<double>& local_M_data, - std::vector<double>& local_K_data, - std::vector<double>& /*local_b_data*/, - LocalCouplingTerm const& coupled_term) override; + void assembleWithCoupledTerm( + double const t, std::vector<double> const& local_x, + std::vector<double>& local_M_data, std::vector<double>& local_K_data, + std::vector<double>& /*local_b_data*/, + LocalCouplingTerm const& coupled_term) override; void computeSecondaryVariableConcrete( const double t, std::vector<double> const& local_x) override diff --git a/ProcessLib/HeatConduction/HeatConductionProcess.cpp b/ProcessLib/HeatConduction/HeatConductionProcess.cpp index c32b9ec8c1c1e43aee6a68ac87a0759177b66232..d341c30a4f9ab2476aa4209820f4b591b3e90821 100644 --- a/ProcessLib/HeatConduction/HeatConductionProcess.cpp +++ b/ProcessLib/HeatConduction/HeatConductionProcess.cpp @@ -115,13 +115,14 @@ void HeatConductionProcess::assembleWithJacobianConcreteProcess( dx_dx, M, K, b, Jac, coupling_term); } -void HeatConductionProcess::computeSecondaryVariableConcrete(const double t, - GlobalVector const& x) +void HeatConductionProcess::computeSecondaryVariableConcrete( + const double t, GlobalVector const& x, + StaggeredCouplingTerm const& coupled_term) { DBUG("Compute heat flux for HeatConductionProcess."); GlobalExecutor::executeMemberOnDereferenced( &HeatConductionLocalAssemblerInterface::computeSecondaryVariable, - _local_assemblers, *_local_to_global_index_map, t, x); + _local_assemblers, *_local_to_global_index_map, t, x, coupled_term); } } // namespace HeatConduction diff --git a/ProcessLib/HeatConduction/HeatConductionProcess.h b/ProcessLib/HeatConduction/HeatConductionProcess.h index 06f54405591188eba3e57320842261030b2906bc..ca7c77a8330ae39975bcc0c01cfa76fe1e80e5fb 100644 --- a/ProcessLib/HeatConduction/HeatConductionProcess.h +++ b/ProcessLib/HeatConduction/HeatConductionProcess.h @@ -38,8 +38,9 @@ public: bool isLinear() const override { return true; } - void computeSecondaryVariableConcrete(double const t, - GlobalVector const& x) override; + void computeSecondaryVariableConcrete( + double const t, GlobalVector const& x, + StaggeredCouplingTerm const& coupled_term) override; void preTimestepConcreteProcess(GlobalVector const& x, const double t, const double delta_t) override; diff --git a/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp index 209c6169aa8bf9d81133c782322ea87f2e55a298..9b6be35e0d9f86a0d55cf348eb04422d986968d0 100644 --- a/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp +++ b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.cpp @@ -349,12 +349,13 @@ void HydroMechanicsProcess<GlobalDim>::initializeConcreteProcess( template <unsigned GlobalDim> void HydroMechanicsProcess<GlobalDim>::computeSecondaryVariableConcrete( - const double t, GlobalVector const& x) + const double t, GlobalVector const& x, + StaggeredCouplingTerm const& coupled_term) { DBUG("Compute the secondary variables for HydroMechanicsProcess."); GlobalExecutor::executeMemberOnDereferenced( &HydroMechanicsLocalAssemblerInterface::computeSecondaryVariable, - _local_assemblers, *_local_to_global_index_map, t, x); + _local_assemblers, *_local_to_global_index_map, t, x, coupled_term); } // ------------------------------------------------------------------------------------ diff --git a/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.h b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.h index 92a2f3043b81b855c3011e2a9e237f7052b25090..a3ecb7442f5884b4bc46d7092b39d8c5015e789b 100644 --- a/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.h +++ b/ProcessLib/LIE/HydroMechanics/HydroMechanicsProcess.h @@ -53,7 +53,9 @@ public: //! @} void computeSecondaryVariableConcrete(double const t, - GlobalVector const& x) override; + GlobalVector const& x, + StaggeredCouplingTerm const& + coupled_term) override; private: using LocalAssemblerInterface = HydroMechanicsLocalAssemblerInterface; diff --git a/ProcessLib/LiquidFlow/CMakeLists.txt b/ProcessLib/LiquidFlow/CMakeLists.txt index 0cad455746411746646e36a9449853d699d6ab89..cb3d9dfc9df5fb0070f63b2cddb2070723144eda 100644 --- a/ProcessLib/LiquidFlow/CMakeLists.txt +++ b/ProcessLib/LiquidFlow/CMakeLists.txt @@ -86,10 +86,12 @@ AddTest( WRAPPER time TESTER vtkdiff REQUIREMENTS NOT OGS_USE_MPI - ABSTOL 1e-20 RELTOL 1e-10 + ABSTOL 1e-16 RELTOL 1e-10 DIFF_DATA mesh2D.vtu gravity_driven_pcs_1_ts_5_t_300.000000.vtu pressure_ref pressure mesh2D.vtu gravity_driven_pcs_1_ts_5_t_300.000000.vtu temperature_ref temperature + mesh2D.vtu gravity_driven_pcs_1_ts_5_t_300.000000.vtu v_x_ref v_x + mesh2D.vtu gravity_driven_pcs_1_ts_5_t_300.000000.vtu v_y_ref v_y ) # PETSc/MPI @@ -183,4 +185,8 @@ AddTest( DIFF_DATA mesh2D.vtu gravity_driven_pcs_1_ts_5_t_300_000000_0.vtu pressure_ref pressure mesh2D.vtu gravity_driven_pcs_1_ts_5_t_300_000000_0.vtu temperature_ref temperature +# To be activated when the output of velocity is correct under PETSc version. +# mesh2D.vtu gravity_driven_pcs_1_ts_5_t_300_000000_0.vtu v_x_ref v_x +# mesh2D.vtu gravity_driven_pcs_1_ts_5_t_300_000000_0.vtu v_y_ref v_y + ) diff --git a/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler-impl.h b/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler-impl.h index e460bd7075c5b91ed95526bfec9ba614a991d012..50f6db7ead667394686365403ef92bd4f2dd816d 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler-impl.h +++ b/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler-impl.h @@ -55,11 +55,11 @@ void LiquidFlowLocalAssembler<ShapeFunction, IntegrationMethod, GlobalDim>:: template <typename ShapeFunction, typename IntegrationMethod, unsigned GlobalDim> void LiquidFlowLocalAssembler<ShapeFunction, IntegrationMethod, GlobalDim>:: - coupling_assemble(double const t, std::vector<double> const& local_x, - std::vector<double>& local_M_data, - std::vector<double>& local_K_data, - std::vector<double>& local_b_data, - LocalCouplingTerm const& coupled_term) + assembleWithCoupledTerm(double const t, std::vector<double> const& local_x, + std::vector<double>& local_M_data, + std::vector<double>& local_K_data, + std::vector<double>& local_b_data, + LocalCouplingTerm const& coupled_term) { SpatialPosition pos; pos.setElementID(_element.getID()); @@ -306,6 +306,35 @@ void LiquidFlowLocalAssembler<ShapeFunction, IntegrationMethod, GlobalDim>:: } } +template <typename ShapeFunction, typename IntegrationMethod, + unsigned GlobalDim> +void LiquidFlowLocalAssembler<ShapeFunction, IntegrationMethod, GlobalDim>:: + computeSecondaryVariableWithCoupledProcessConcrete( + double const t, std::vector<double> const& local_x, + std::unordered_map<std::type_index, const std::vector<double>> const& + coupled_local_solutions) +{ + SpatialPosition pos; + pos.setElementID(_element.getID()); + const int material_id = _material_properties.getMaterialID(pos); + const Eigen::MatrixXd& perm = _material_properties.getPermeability( + material_id, t, pos, _element.getDimension()); + + const auto local_T = coupled_local_solutions.at(std::type_index( + typeid(ProcessLib::HeatConduction::HeatConductionProcess))); + + // Note: For Inclined 1D in 2D/3D or 2D element in 3D, the first item in + // the assert must be changed to perm.rows() == _element->getDimension() + assert(perm.rows() == GlobalDim || perm.rows() == 1); + + if (perm.size() == 1) // isotropic or 1D problem. + computeSecondaryVariableCoupledWithHeatTransportLocal< + IsotropicCalculator>(t, local_x, local_T, pos, perm); + else + computeSecondaryVariableCoupledWithHeatTransportLocal< + AnisotropicCalculator>(t, local_x, local_T, pos, perm); +} + template <typename ShapeFunction, typename IntegrationMethod, unsigned GlobalDim> template <typename LaplacianGravityVelocityCalculator> diff --git a/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler.h b/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler.h index 6b2bf9e5ce317f913c3925c48cde13ca0cd849cf..1785015995230d1104e9a17aed03faf855e58526 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler.h +++ b/ProcessLib/LiquidFlow/LiquidFlowLocalAssembler.h @@ -12,8 +12,10 @@ #pragma once +#include <map> +#include <unordered_map> #include <vector> -#include <memory> +#include <typeindex> #include "MathLib/LinAlg/Eigen/EigenMapTools.h" #include "NumLib/Extrapolation/ExtrapolatableElement.h" @@ -86,15 +88,20 @@ public: std::vector<double>& local_K_data, std::vector<double>& local_b_data) override; - void coupling_assemble(double const t, std::vector<double> const& local_x, - std::vector<double>& local_M_data, - std::vector<double>& local_K_data, - std::vector<double>& local_b_data, - LocalCouplingTerm const& coupled_term) override; + void assembleWithCoupledTerm( + double const t, std::vector<double> const& local_x, + std::vector<double>& local_M_data, std::vector<double>& local_K_data, + std::vector<double>& local_b_data, + LocalCouplingTerm const& coupled_term) override; void computeSecondaryVariableConcrete( double const /*t*/, std::vector<double> const& local_x) override; + void computeSecondaryVariableWithCoupledProcessConcrete( + double const t, std::vector<double> const& local_x, + std::unordered_map<std::type_index, const std::vector<double>> const& + coupled_local_solutions) override; + Eigen::Map<const Eigen::RowVectorXd> getShapeMatrix( const unsigned integration_point) const override { diff --git a/ProcessLib/LiquidFlow/LiquidFlowProcess.cpp b/ProcessLib/LiquidFlow/LiquidFlowProcess.cpp index 4ab25b277b45bdc5db966d547bea6618284552b3..74c9bde7697108bf35cf93c52e75edcf27439ada 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowProcess.cpp +++ b/ProcessLib/LiquidFlow/LiquidFlowProcess.cpp @@ -115,13 +115,15 @@ void LiquidFlowProcess::assembleWithJacobianConcreteProcess( dx_dx, M, K, b, Jac, coupling_term); } -void LiquidFlowProcess::computeSecondaryVariableConcrete(const double t, - GlobalVector const& x) +void LiquidFlowProcess::computeSecondaryVariableConcrete( + const double t, + GlobalVector const& x, + StaggeredCouplingTerm const& coupled_term) { DBUG("Compute the velocity for LiquidFlowProcess."); GlobalExecutor::executeMemberOnDereferenced( &LiquidFlowLocalAssemblerInterface::computeSecondaryVariable, - _local_assemblers, *_local_to_global_index_map, t, x); + _local_assemblers, *_local_to_global_index_map, t, x, coupled_term); } } // end of namespace diff --git a/ProcessLib/LiquidFlow/LiquidFlowProcess.h b/ProcessLib/LiquidFlow/LiquidFlowProcess.h index fdb2092e790d1c30a60b47e08b56bece3f2dcb36..dd5836da3ac2f6a722bd9a7003490c36be366863 100644 --- a/ProcessLib/LiquidFlow/LiquidFlowProcess.h +++ b/ProcessLib/LiquidFlow/LiquidFlowProcess.h @@ -72,8 +72,10 @@ public: double const gravitational_acceleration, BaseLib::ConfigTree const& config); - void computeSecondaryVariableConcrete(double const t, - GlobalVector const& x) override; + void computeSecondaryVariableConcrete( + double const t, + GlobalVector const& x, + StaggeredCouplingTerm const& coupled_term) override; bool isLinear() const override { return true; } int getGravitationalAxisID() const { return _gravitational_axis_id; } diff --git a/ProcessLib/LocalAssemblerInterface.cpp b/ProcessLib/LocalAssemblerInterface.cpp index 8eb8198e77bd250264e3fe65586125c4476298db..c626e7cb71cd2b915e6f5fad759817bc2318929a 100644 --- a/ProcessLib/LocalAssemblerInterface.cpp +++ b/ProcessLib/LocalAssemblerInterface.cpp @@ -14,7 +14,7 @@ namespace ProcessLib { -void LocalAssemblerInterface::coupling_assemble( +void LocalAssemblerInterface::assembleWithCoupledTerm( double const /*t*/, std::vector<double> const& /*local_x*/, std::vector<double>& /*local_M_data*/, std::vector<double>& /*local_K_data*/, @@ -22,7 +22,7 @@ void LocalAssemblerInterface::coupling_assemble( LocalCouplingTerm const& /*coupling_term*/) { OGS_FATAL( - "The coupling_assemble() function is not implemented in the local " + "The assembleWithCoupledTerm() function is not implemented in the local " "assembler."); } @@ -56,11 +56,24 @@ void LocalAssemblerInterface::assembleWithJacobianAndCouping( void LocalAssemblerInterface::computeSecondaryVariable( std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const& dof_table, - double const t, GlobalVector const& x) + double const t, GlobalVector const& x, + StaggeredCouplingTerm const& coupled_term) { auto const indices = NumLib::getIndices(mesh_item_id, dof_table); auto const local_x = x.get(indices); - computeSecondaryVariableConcrete(t, local_x); + + if (coupled_term.empty) + { + computeSecondaryVariableConcrete(t, local_x); + } + else + { + auto const local_coupled_xs + = getCurrentLocalSolutionsOfCoupledProcesses( + coupled_term.coupled_xs, indices); + computeSecondaryVariableWithCoupledProcessConcrete(t, local_x, + local_coupled_xs); + } } void LocalAssemblerInterface::preTimestep( diff --git a/ProcessLib/LocalAssemblerInterface.h b/ProcessLib/LocalAssemblerInterface.h index a70871b4b337a1b1f2520c1e958353fd11defbbb..040e6123f39f15b892bde0074900094143fdd00f 100644 --- a/ProcessLib/LocalAssemblerInterface.h +++ b/ProcessLib/LocalAssemblerInterface.h @@ -9,6 +9,10 @@ #pragma once + +#include <unordered_map> +#include <typeindex> + #include "NumLib/NumericsConfig.h" #include "MathLib/Point3d.h" #include "StaggeredCouplingTerm.h" @@ -36,7 +40,7 @@ public: std::vector<double>& local_M_data, std::vector<double>& local_K_data, std::vector<double>& local_b_data) = 0; - virtual void coupling_assemble(double const t, + virtual void assembleWithCoupledTerm(double const t, std::vector<double> const& local_x, std::vector<double>& local_M_data, std::vector<double>& local_K_data, @@ -64,7 +68,8 @@ public: virtual void computeSecondaryVariable(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const& dof_table, - const double t, GlobalVector const& x); + const double t, GlobalVector const& x, + StaggeredCouplingTerm const& coupled_term); virtual void preTimestep(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const& dof_table, @@ -94,6 +99,12 @@ private: virtual void computeSecondaryVariableConcrete (double const /*t*/, std::vector<double> const& /*local_x*/) {} + + virtual void computeSecondaryVariableWithCoupledProcessConcrete + (double const /*t*/, std::vector<double> const& /*local_x*/, + std::unordered_map<std::type_index, + const std::vector<double>> const& + /*coupled_local_solutions*/) {} }; } // namespace ProcessLib diff --git a/ProcessLib/Process.cpp b/ProcessLib/Process.cpp index addff2becea498ae7c4462e3a35fdd2db671c140..0fb1ca219366f8b317323026742b4c97d6404042 100644 --- a/ProcessLib/Process.cpp +++ b/ProcessLib/Process.cpp @@ -246,9 +246,11 @@ void Process::postTimestep(GlobalVector const& x) postTimestepConcreteProcess(x); } -void Process::computeSecondaryVariable( const double t, GlobalVector const& x) +void Process::computeSecondaryVariable(const double t, GlobalVector const& x, + StaggeredCouplingTerm const& + coupled_term) { - computeSecondaryVariableConcrete(t, x); + computeSecondaryVariableConcrete(t, x, coupled_term); } void Process::preIteration(const unsigned iter, const GlobalVector &x) diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h index 7bec88b578565d61859b8b79acb1fb12bbe956b8..674c898b132d1d6a4e56fbb8359e6c1192c6984e 100644 --- a/ProcessLib/Process.h +++ b/ProcessLib/Process.h @@ -60,7 +60,8 @@ public: GlobalVector const& x) override final; /// compute secondary variables for the coupled equations or for output. - void computeSecondaryVariable(const double t, GlobalVector const& x); + void computeSecondaryVariable(const double t, GlobalVector const& x, + StaggeredCouplingTerm const& coupled_term); NumLib::IterationResult postIteration(GlobalVector const& x) override final; @@ -165,7 +166,9 @@ private: GlobalVector const& /*x*/){} virtual void computeSecondaryVariableConcrete(const double /*t*/, - GlobalVector const& /*x*/) {} + GlobalVector const& /*x*/, + StaggeredCouplingTerm + const& /*coupled_term*/) {} virtual NumLib::IterationResult postIterationConcreteProcess( GlobalVector const& /*x*/) diff --git a/ProcessLib/StaggeredCouplingTerm.cpp b/ProcessLib/StaggeredCouplingTerm.cpp index a6468487e85ee94465d003347c91cd093ed460cc..a6c7b0da65dcde82471730a9aaa7159c9c0a0fa6 100644 --- a/ProcessLib/StaggeredCouplingTerm.cpp +++ b/ProcessLib/StaggeredCouplingTerm.cpp @@ -23,4 +23,25 @@ const StaggeredCouplingTerm createVoidStaggeredCouplingTerm() return StaggeredCouplingTerm(coupled_processes, coupled_xs, 0.0, empty); } +std::unordered_map<std::type_index, const std::vector<double>> +getCurrentLocalSolutionsOfCoupledProcesses( + const std::unordered_map<std::type_index, GlobalVector const&>& + global_coupled_xs, + const std::vector<GlobalIndexType>& indices) +{ + std::unordered_map<std::type_index, const std::vector<double>> + local_coupled_xs; + + // Get local nodal solutions of the coupled equations. + for (auto const& global_coupled_x_pair : global_coupled_xs) + { + auto const& coupled_x = global_coupled_x_pair.second; + auto const local_coupled_x = coupled_x.get(indices); + BaseLib::insertIfTypeIndexKeyUniqueElseError( + local_coupled_xs, global_coupled_x_pair.first, local_coupled_x, + "local_coupled_x"); + } + return local_coupled_xs; +} + } // end of ProcessLib diff --git a/ProcessLib/StaggeredCouplingTerm.h b/ProcessLib/StaggeredCouplingTerm.h index 8089d0a07e0103b14d0b562544f46815fbb6992a..8e362536a174a17e2f3df526815b912eda275757 100644 --- a/ProcessLib/StaggeredCouplingTerm.h +++ b/ProcessLib/StaggeredCouplingTerm.h @@ -104,4 +104,10 @@ struct LocalCouplingTerm */ const StaggeredCouplingTerm createVoidStaggeredCouplingTerm(); +std::unordered_map<std::type_index, const std::vector<double>> +getCurrentLocalSolutionsOfCoupledProcesses( + const std::unordered_map<std::type_index, GlobalVector const&>& + global_coupled_xs, + const std::vector<GlobalIndexType>& indices); + } // end of ProcessLib diff --git a/ProcessLib/UncoupledProcessesTimeLoop.cpp b/ProcessLib/UncoupledProcessesTimeLoop.cpp index c07fc0eedb9f9f70f5d870513c57d9076b60e9ad..c7666e8ae0c6815b0fdd1feed6a6ac98ae0676c0 100644 --- a/ProcessLib/UncoupledProcessesTimeLoop.cpp +++ b/ProcessLib/UncoupledProcessesTimeLoop.cpp @@ -659,11 +659,14 @@ bool UncoupledProcessesTimeLoop::solveUncoupledEquationSystems( auto& x = *_process_solutions[pcs_idx]; pcs.preTimestep(x, t, dt); - const auto nonlinear_solver_succeeded = solveOneTimeStepOneProcess( - x, timestep_id, t, dt, *spd, - ProcessLib::createVoidStaggeredCouplingTerm(), *_output); + const auto void_staggered_coupling_term = + ProcessLib::createVoidStaggeredCouplingTerm(); + + const auto nonlinear_solver_succeeded = + solveOneTimeStepOneProcess(x, timestep_id, t, dt, *spd, + void_staggered_coupling_term, *_output); pcs.postTimestep(x); - pcs.computeSecondaryVariable(t, x); + pcs.computeSecondaryVariable(t, x, void_staggered_coupling_term); INFO("[time] Solving process #%u took %g s in time step #%u ", pcs_idx, time_timestep_process.elapsed(), timestep_id); @@ -791,7 +794,11 @@ bool UncoupledProcessesTimeLoop::solveCoupledEquationSystemsByStaggeredScheme( auto& pcs = spd->process; auto& x = *_process_solutions[pcs_idx]; pcs.postTimestep(x); - pcs.computeSecondaryVariable(t, x); + + StaggeredCouplingTerm coupled_term( + spd->coupled_processes, _solutions_of_coupled_processes[pcs_idx], + 0.0); + pcs.computeSecondaryVariable(t, x, coupled_term); _output->doOutput(pcs, spd->process_output, timestep_id, t, x); ++pcs_idx; diff --git a/ProcessLib/VectorMatrixAssembler.cpp b/ProcessLib/VectorMatrixAssembler.cpp index a82bd7893396397cfea906f41a591b299fb88776..0420af82b719d319bcb3ab2e163b44d9836d59df 100644 --- a/ProcessLib/VectorMatrixAssembler.cpp +++ b/ProcessLib/VectorMatrixAssembler.cpp @@ -49,27 +49,6 @@ getPreviousLocalSolutionsOfCoupledProcesses( return local_coupled_xs0; } -static std::unordered_map<std::type_index, const std::vector<double>> -getCurrentLocalSolutionsOfCoupledProcesses( - const std::unordered_map<std::type_index, GlobalVector const&>& - global_coupled_xs, - const std::vector<GlobalIndexType>& indices) -{ - std::unordered_map<std::type_index, const std::vector<double>> - local_coupled_xs; - - // Get local nodal solutions of the coupled equations. - for (auto const& global_coupled_x_pair : global_coupled_xs) - { - auto const& coupled_x = global_coupled_x_pair.second; - auto const local_coupled_x = coupled_x.get(indices); - BaseLib::insertIfTypeIndexKeyUniqueElseError( - local_coupled_xs, global_coupled_x_pair.first, local_coupled_x, - "local_coupled_x"); - } - return local_coupled_xs; -} - VectorMatrixAssembler::VectorMatrixAssembler( std::unique_ptr<AbstractJacobianAssembler>&& jacobian_assembler) : _jacobian_assembler(std::move(jacobian_assembler)) @@ -104,7 +83,7 @@ void VectorMatrixAssembler::assemble( coupling_term.dt, coupling_term.coupled_processes, std::move(local_coupled_xs0), std::move(local_coupled_xs)); - local_assembler.coupling_assemble(t, local_x, _local_M_data, + local_assembler.assembleWithCoupledTerm(t, local_x, _local_M_data, _local_K_data, _local_b_data, local_coupling_term); } diff --git a/Tests/Data b/Tests/Data index 988bc7a963cff497aecb29e564b97c452a6e25f8..bfa231570633317349385f9776f23c02777fef9d 160000 --- a/Tests/Data +++ b/Tests/Data @@ -1 +1 @@ -Subproject commit 988bc7a963cff497aecb29e564b97c452a6e25f8 +Subproject commit bfa231570633317349385f9776f23c02777fef9d