13#include <range/v3/numeric/accumulate.hpp>
14#include <range/v3/view/transform.hpp>
24template <
typename Solutions,
typename Vector>
33 for (
auto const& bc : *known_solutions)
35 for (std::size_t i = 0; i < bc.ids.size(); ++i)
50 TimeDiscretizedODESystem(
const int process_id,
ODE& ode,
59 _ode.getMatrixSpecifications(process_id),
_b_id);
72 assemble(std::vector<GlobalVector*>
const& x_new_timestep,
73 std::vector<GlobalVector*>
const& x_prev,
77 auto const dt =
_time_disc.getCurrentTimeIncrement();
78 auto const& x_curr = *x_new_timestep[process_id];
84 _ode.preAssemble(t, dt, x_curr);
85 _ode.assembleWithJacobian(t, dt, x_new_timestep, x_prev, process_id,
118 int const process_id)
121 _ode.getKnownSolutions(
_time_disc.getCurrentTime(), x, process_id);
143 std::size_t
const size = ranges::accumulate(
145 {
return bc.ids.size(); }),
147 std::vector<IndexType> ids;
149 std::vector<double> values;
150 values.reserve(size);
154 for (std::size_t i = 0; i < bc.ids.size(); ++i)
156 auto const id = bc.ids[i];
160 values.push_back(x[
id] - bc.values[i]);
178 std::vector<IndexType> ids;
181 ids.insert(end(ids), begin(bc.ids), end(bc.ids));
185 std::vector<double> values(ids.size(), 0);
191 TimeDiscretizedODESystem(
const int process_id,
ODE& ode,
198 ode.getMatrixSpecifications(process_id),
_M_id);
200 ode.getMatrixSpecifications(process_id),
_K_id);
202 ode.getMatrixSpecifications(process_id),
_b_id);
216 assemble(std::vector<GlobalVector*>
const& x_new_timestep,
217 std::vector<GlobalVector*>
const& x_prev,
218 int const process_id)
223 auto const dt =
_time_disc.getCurrentTimeIncrement();
224 auto const& x_curr = *x_new_timestep[process_id];
230 _ode.preAssemble(t, dt, x_curr);
231 _ode.assemble(t, dt, x_new_timestep, x_prev, process_id, *
_M, *
_K, *
_b);
241 int const process_id)
244 _ode.getKnownSolutions(
_time_disc.getCurrentTime(), x, process_id);
266 std::vector<IndexType> ids;
267 std::vector<double> values;
270 ids.insert(end(ids), begin(bc.ids), end(bc.ids));
271 values.insert(end(values), begin(bc.values), end(bc.values));
MathLib::EigenMatrix GlobalMatrix
MathLib::EigenVector GlobalVector
static const ODESystemTag ODETag
A tag indicating the type of ODE.
GlobalMatrix * _Jac
the Jacobian of the residual
std::size_t _b_id
ID of the _b vector.
std::unique_ptr< MatTrans > _mat_trans
the object used to compute the matrix/vector for the nonlinear solver
void applyKnownSolutions(GlobalVector &x) const override
ODE & _ode
ode the ODE being wrapped
std::vector< NumLib::IndexValueVector< Index > > const * _known_solutions
stores precomputed values for known solutions
~TimeDiscretizedODESystem() override
TimeDiscretization TimeDisc
A shortcut for a general time discretization scheme.
TimeDisc & _time_disc
the time discretization to being used
GlobalVector * _b
Matrix .
std::size_t _Jac_id
ID of the _Jac matrix.
void getJacobian(GlobalMatrix &Jac) const override
void computeKnownSolutions(GlobalVector const &x, int const process_id) override
ODESystem< ODETag, NonlinearSolverTag::Newton > ODE
The type of ODE.
TimeDiscretization TimeDisc
A shortcut for a general time discretization scheme.
GlobalMatrix * _K
Matrix .
GlobalMatrix * _M
Matrix .
ODE & _ode
ode the ODE being wrapped
std::size_t _b_id
ID of the _b vector.
std::size_t _M_id
ID of the _M matrix.
ODESystem< ODETag, NonlinearSolverTag::Picard > ODE
The type of ODE.
void applyKnownSolutions(GlobalVector &x) const override
static const ODESystemTag ODETag
A tag indicating the type of ODE.
std::size_t _K_id
ID of the _K matrix.
GlobalVector * _b
Matrix .
~TimeDiscretizedODESystem() override
TimeDisc & _time_disc
the time discretization to being used
void computeKnownSolutions(GlobalVector const &x, int const process_id) override
std::vector< NumLib::IndexValueVector< Index > > const * _known_solutions
stores precomputed values for known solutions
std::unique_ptr< MatTrans > _mat_trans
the object used to compute the matrix/vector for the nonlinear solver
std::unique_ptr< MatrixTranslator< ODETag > > createMatrixTranslator(TimeDiscretization const &timeDisc)
@ FirstOrderImplicitQuasilinear
void finalizeAssembly(PETScMatrix &A)
void copy(PETScVector const &x, PETScVector &y)
void scale(PETScVector &x, PetscScalar const a)
void applyKnownSolution(EigenMatrix &A, EigenVector &b, EigenVector &, const std::vector< EigenMatrix::IndexType > &vec_knownX_id, const std::vector< double > &vec_knownX_x)
void setVector(PETScVector &v, std::initializer_list< double > values)
void applyKnownSolutions(std::vector< Solutions > const *const known_solutions, Vector &x)
Applies known solutions to the solution vector x.
static NUMLIB_EXPORT MatrixProvider & provider
static NUMLIB_EXPORT VectorProvider & provider