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,
53 _time_disc(time_discretization),
57 _ode.getMatrixSpecifications(process_id), _Jac_id);
59 _ode.getMatrixSpecifications(process_id), _b_id);
72 assemble(std::vector<GlobalVector*>
const& x_new_timestep,
73 std::vector<GlobalVector*>
const& x_prev,
76 auto const t = _time_disc.getCurrentTime();
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,
112 _mat_trans->computeJacobian(*_Jac, Jac);
118 int const process_id)
121 _ode.getKnownSolutions(_time_disc.getCurrentTime(), x, process_id);
137 if (!_known_solutions)
143 std::size_t
const size = ranges::accumulate(
144 *_known_solutions | ranges::views::transform([](
auto const& bc)
145 {
return bc.ids.size(); }),
147 std::vector<IndexType> ids;
149 std::vector<double> values;
150 values.reserve(size);
152 for (
auto const& bc : *_known_solutions)
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]);
172 if (!_known_solutions)
178 std::vector<IndexType> ids;
179 for (
auto const& bc : *_known_solutions)
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,
194 _time_disc(time_discretization),
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)
222 auto const t = _time_disc.getCurrentTime();
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);
260 if (!_known_solutions)
266 std::vector<IndexType> ids;
267 std::vector<double> values;
268 for (
auto const& bc : *_known_solutions)
270 ids.insert(end(ids), begin(bc.ids), end(bc.ids));
271 values.insert(end(values), begin(bc.values), end(bc.values));
Global vector based on Eigen vector.
virtual void releaseMatrix(GlobalMatrix const &A)=0
virtual GlobalMatrix & getMatrix(std::size_t &id)=0
Get an uninitialized matrix with the given id.
virtual GlobalVector & getVector(std::size_t &id)=0
Get an uninitialized vector with the given id.
virtual void releaseVector(GlobalVector const &x)=0
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