Skip to content
Snippets Groups Projects
Commit 36d8f49b authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[NL] Out-of-balance forces. Picard.

parent f3541151
No related merge requests found
...@@ -27,6 +27,24 @@ void NonlinearSolver<NonlinearSolverTag::Picard>::assemble( ...@@ -27,6 +27,24 @@ void NonlinearSolver<NonlinearSolverTag::Picard>::assemble(
_equation_system->assemble(x, process_id); _equation_system->assemble(x, process_id);
} }
void NonlinearSolver<NonlinearSolverTag::Picard>::calculateOutOfBalanceForces(
std::vector<GlobalVector*> const& x, int const process_id)
{
if (!_compensate_initial_out_of_balance_forces)
return;
auto& A = NumLib::GlobalMatrixProvider::provider.getMatrix(_A_id);
auto& rhs = NumLib::GlobalVectorProvider::provider.getVector(_rhs_id);
_equation_system->assemble(x, process_id);
_equation_system->getA(A);
_equation_system->getRhs(rhs);
// F_oob = A * x - rhs
_f_oob = &NumLib::GlobalVectorProvider::provider.getVector();
MathLib::LinAlg::matMult(A, *x[process_id], *_f_oob);
MathLib::LinAlg::axpy(*_f_oob, -1.0, rhs); // res -= rhs
}
NonlinearSolverStatus NonlinearSolver<NonlinearSolverTag::Picard>::solve( NonlinearSolverStatus NonlinearSolver<NonlinearSolverTag::Picard>::solve(
std::vector<GlobalVector*>& x, std::vector<GlobalVector*>& x,
std::function<void(int, GlobalVector const&)> const& postIterationCallback, std::function<void(int, GlobalVector const&)> const& postIterationCallback,
...@@ -73,6 +91,11 @@ NonlinearSolverStatus NonlinearSolver<NonlinearSolverTag::Picard>::solve( ...@@ -73,6 +91,11 @@ NonlinearSolverStatus NonlinearSolver<NonlinearSolverTag::Picard>::solve(
sys.getRhs(rhs); sys.getRhs(rhs);
INFO("[time] Assembly took %g s.", time_assembly.elapsed()); INFO("[time] Assembly took %g s.", time_assembly.elapsed());
// Apply out-of-balance forces if set.
if (_f_oob != nullptr)
LinAlg::axpy(rhs, -1, *_f_oob);
timer_dirichlet.start(); timer_dirichlet.start();
sys.applyKnownSolutionsPicard(A, rhs, *x_new[process_id]); sys.applyKnownSolutionsPicard(A, rhs, *x_new[process_id]);
time_dirichlet += timer_dirichlet.elapsed(); time_dirichlet += timer_dirichlet.elapsed();
......
...@@ -193,13 +193,8 @@ public: ...@@ -193,13 +193,8 @@ public:
void assemble(std::vector<GlobalVector*> const& x, void assemble(std::vector<GlobalVector*> const& x,
int const process_id) const override; int const process_id) const override;
void calculateOutOfBalanceForces(GlobalVector const& /*x*/) override void calculateOutOfBalanceForces(std::vector<GlobalVector*> const& x,
{ int const process_id) override;
if (!_compensate_initial_out_of_balance_forces)
return;
OGS_FATAL("Calculation of out-of-balance forces is not implemented.");
}
NonlinearSolverStatus solve( NonlinearSolverStatus solve(
std::vector<GlobalVector*>& x, std::vector<GlobalVector*>& x,
...@@ -220,6 +215,7 @@ private: ...@@ -220,6 +215,7 @@ private:
ConvergenceCriterion* _convergence_criterion = nullptr; ConvergenceCriterion* _convergence_criterion = nullptr;
const int _maxiter; //!< maximum number of iterations const int _maxiter; //!< maximum number of iterations
GlobalVector* _f_oob = nullptr; //!< Out-of-balance forces vector.
std::size_t _A_id = 0u; //!< ID of the \f$ A \f$ matrix. std::size_t _A_id = 0u; //!< ID of the \f$ A \f$ matrix.
std::size_t _rhs_id = 0u; //!< ID of the right-hand side vector. std::size_t _rhs_id = 0u; //!< ID of the right-hand side vector.
std::size_t _x_new_id = 0u; //!< ID of the vector storing the solution of std::size_t _x_new_id = 0u; //!< ID of the vector storing the solution of
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment