From 4493417e1b10af7f8cd8bce2811cc3af65b2586a Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Mon, 7 Oct 2019 18:59:09 +0200 Subject: [PATCH] Pass all solutions to assembleWithJacobian. --- NumLib/ODESolver/ODESystem.h | 2 +- NumLib/ODESolver/TimeDiscretizedODESystem.cpp | 4 ++-- ProcessLib/Process.cpp | 9 +++++---- ProcessLib/Process.h | 10 +++++----- ProcessLib/VectorMatrixAssembler.cpp | 6 +++--- ProcessLib/VectorMatrixAssembler.h | 2 +- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/NumLib/ODESolver/ODESystem.h b/NumLib/ODESolver/ODESystem.h index d3c3df20997..f5eed29c575 100644 --- a/NumLib/ODESolver/ODESystem.h +++ b/NumLib/ODESolver/ODESystem.h @@ -128,7 +128,7 @@ public: * \endparblock */ virtual void assembleWithJacobian(const double t, double const dt, - GlobalVector const& x, + std::vector<GlobalVector*> const& x, GlobalVector const& xdot, const double dxdot_dx, const double dx_dx, int const process_id, GlobalMatrix& M, diff --git a/NumLib/ODESolver/TimeDiscretizedODESystem.cpp b/NumLib/ODESolver/TimeDiscretizedODESystem.cpp index dd45a353b0b..3178aacc1f2 100644 --- a/NumLib/ODESolver/TimeDiscretizedODESystem.cpp +++ b/NumLib/ODESolver/TimeDiscretizedODESystem.cpp @@ -91,8 +91,8 @@ void TimeDiscretizedODESystem<ODESystemTag::FirstOrderImplicitQuasilinear, _Jac->setZero(); _ode.preAssemble(t, dt, x_curr); - _ode.assembleWithJacobian(t, dt, x_curr, xdot, dxdot_dx, dx_dx, process_id, - *_M, *_K, *_b, *_Jac); + _ode.assembleWithJacobian(t, dt, x_new_timestep, xdot, dxdot_dx, dx_dx, + process_id, *_M, *_K, *_b, *_Jac); LinAlg::finalizeAssembly(*_M); LinAlg::finalizeAssembly(*_K); diff --git a/ProcessLib/Process.cpp b/ProcessLib/Process.cpp index 17fd5c5feb1..6ae3af51892 100644 --- a/ProcessLib/Process.cpp +++ b/ProcessLib/Process.cpp @@ -211,24 +211,25 @@ void Process::assemble(const double t, double const dt, GlobalVector const& x, } void Process::assembleWithJacobian(const double t, double const dt, - GlobalVector const& x, + std::vector<GlobalVector*> const& x, GlobalVector const& xdot, const double dxdot_dx, const double dx_dx, int const process_id, GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b, GlobalMatrix& Jac) { - MathLib::LinAlg::setLocalAccessibleVector(x); + MathLib::LinAlg::setLocalAccessibleVector(*x[process_id]); MathLib::LinAlg::setLocalAccessibleVector(xdot); assembleWithJacobianConcreteProcess(t, dt, x, xdot, dxdot_dx, dx_dx, process_id, M, K, b, Jac); // TODO: apply BCs to Jacobian. - _boundary_conditions[process_id].applyNaturalBC(t, x, K, b, &Jac); + _boundary_conditions[process_id].applyNaturalBC(t, *x[process_id], K, b, + &Jac); // the last argument is for the jacobian, nullptr is for a unused jacobian - _source_term_collections[process_id].integrate(t, x, b, &Jac); + _source_term_collections[process_id].integrate(t, *x[process_id], b, &Jac); } void Process::constructDofTable() diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h index 2a08e5b3b4d..3d8fd55c5f8 100644 --- a/ProcessLib/Process.h +++ b/ProcessLib/Process.h @@ -107,10 +107,10 @@ public: GlobalVector& b) final; void assembleWithJacobian(const double t, double const dt, - GlobalVector const& x, GlobalVector const& xdot, - const double dxdot_dx, const double dx_dx, - int const process_id, GlobalMatrix& M, - GlobalMatrix& K, GlobalVector& b, + std::vector<GlobalVector*> const& x, + GlobalVector const& xdot, const double dxdot_dx, + const double dx_dx, int const process_id, + GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b, GlobalMatrix& Jac) final; std::vector<NumLib::IndexValueVector<GlobalIndexType>> const* @@ -201,7 +201,7 @@ private: GlobalMatrix& K, GlobalVector& b) = 0; virtual void assembleWithJacobianConcreteProcess( - const double t, double const dt, GlobalVector const& x, + const double t, double const dt, std::vector<GlobalVector*> const& x, GlobalVector const& xdot, const double dxdot_dx, const double dx_dx, int const process_id, GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b, GlobalMatrix& Jac) = 0; diff --git a/ProcessLib/VectorMatrixAssembler.cpp b/ProcessLib/VectorMatrixAssembler.cpp index 1a05594abcf..652f8211636 100644 --- a/ProcessLib/VectorMatrixAssembler.cpp +++ b/ProcessLib/VectorMatrixAssembler.cpp @@ -106,7 +106,7 @@ void VectorMatrixAssembler::assembleWithJacobian( std::size_t const mesh_item_id, LocalAssemblerInterface& local_assembler, std::vector<std::reference_wrapper<NumLib::LocalToGlobalIndexMap>> const& dof_tables, - const double t, double const dt, GlobalVector const& x, + const double t, double const dt, std::vector<GlobalVector*> const& x, GlobalVector const& xdot, const double dxdot_dx, const double dx_dx, int const process_id, GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b, GlobalMatrix& Jac, CoupledSolutionsForStaggeredScheme const* const cpl_xs) @@ -129,7 +129,7 @@ void VectorMatrixAssembler::assembleWithJacobian( if (cpl_xs == nullptr) { - auto const local_x = x.get(indices); + auto const local_x = x[process_id]->get(indices); _jacobian_assembler->assembleWithJacobian( local_assembler, t, dt, local_x, local_xdot, dxdot_dx, dx_dx, _local_M_data, _local_K_data, _local_b_data, _local_Jac_data); @@ -139,7 +139,7 @@ void VectorMatrixAssembler::assembleWithJacobian( auto local_coupled_xs0 = getCoupledLocalSolutions(cpl_xs->coupled_xs_t0, indices_of_processes); auto local_coupled_xs = - getCoupledLocalSolutions(cpl_xs->coupled_xs, indices_of_processes); + getCoupledLocalSolutions(x, indices_of_processes); ProcessLib::LocalCoupledSolutions local_coupled_solutions( std::move(local_coupled_xs0), std::move(local_coupled_xs)); diff --git a/ProcessLib/VectorMatrixAssembler.h b/ProcessLib/VectorMatrixAssembler.h index d0a450d7197..ce28f5c9522 100644 --- a/ProcessLib/VectorMatrixAssembler.h +++ b/ProcessLib/VectorMatrixAssembler.h @@ -60,7 +60,7 @@ public: std::vector< std::reference_wrapper<NumLib::LocalToGlobalIndexMap>> const& dof_tables, - const double t, double const dt, GlobalVector const& x, + const double t, double const dt, std::vector<GlobalVector*> const& x, GlobalVector const& xdot, const double dxdot_dx, const double dx_dx, int const process_id, GlobalMatrix& M, GlobalMatrix& K, GlobalVector& b, GlobalMatrix& Jac, -- GitLab