22 #include "solver/linear_solver.h"
23 #include "solvers/matrix_solver.h"
31 template<
typename Scalar>
32 LinearSolver<Scalar>::LinearSolver(
bool force_use_direct_solver) : Solver<Scalar>(false),
Hermes::Solvers::MatrixSolver<Scalar>(force_use_direct_solver)
34 this->dp =
new DiscreteProblem<Scalar>(
true);
38 template<
typename Scalar>
39 LinearSolver<Scalar>::LinearSolver(DiscreteProblem<Scalar>* dp,
bool force_use_direct_solver) : Solver<Scalar>(dp),
Hermes::Solvers::MatrixSolver<Scalar>(force_use_direct_solver)
43 template<
typename Scalar>
44 LinearSolver<Scalar>::LinearSolver(WeakFormSharedPtr<Scalar> wf, SpaceSharedPtr<Scalar> space,
bool force_use_direct_solver) : Solver<Scalar>(false),
Hermes::Solvers::MatrixSolver<Scalar>(force_use_direct_solver)
46 this->dp =
new DiscreteProblem<Scalar>(wf, space,
true);
50 template<
typename Scalar>
51 LinearSolver<Scalar>::LinearSolver(WeakFormSharedPtr<Scalar> wf, std::vector<SpaceSharedPtr<Scalar> > spaces,
bool force_use_direct_solver) : Solver<Scalar>(false),
Hermes::Solvers::MatrixSolver<Scalar>(force_use_direct_solver)
53 this->dp =
new DiscreteProblem<Scalar>(wf, spaces,
true);
57 template<
typename Scalar>
58 LinearSolver<Scalar>::~LinearSolver()
62 template<
typename Scalar>
65 return this->sln_vector;
68 template<
typename Scalar>
74 template<
typename Scalar>
78 this->jacobian_reusable =
false;
81 template<
typename Scalar>
85 this->jacobian_reusable =
false;
88 template<
typename Scalar>
91 Hermes::Solvers::MatrixSolver<Scalar>::set_verbose_output(to_set);
92 this->dp->set_verbose_output(to_set);
95 template<
typename Scalar>
100 this->on_initialization();
108 if (this->jacobian_reusable && this->constant_jacobian)
110 this->info(
"\tLinearSolver: assembling... [reusing matrix, assembling rhs].");
111 this->dp->assemble(coeff_vec, this->get_residual());
112 this->linear_matrix_solver->set_reuse_scheme(Hermes::Solvers::HERMES_REUSE_MATRIX_STRUCTURE_COMPLETELY);
116 if (this->jacobian_reusable)
117 this->info(
"\tLinearSolver: assembling... [re-assembling with a reusable matrix structure].");
119 this->info(
"\tLinearSolver: assembling... [assembling the matrix and rhs anew].");
120 this->dp->assemble(coeff_vec, this->get_jacobian(), this->get_residual());
121 this->linear_matrix_solver->set_reuse_scheme(Hermes::Solvers::HERMES_CREATE_STRUCTURE_FROM_SCRATCH);
124 this->process_matrix_output(this->get_jacobian(), 1);
125 this->process_vector_output(this->get_residual(), 1);
128 this->info(
"\tLinearSolver: assembling done in %s. Solving...", this->last_str().c_str());
132 this->linear_matrix_solver->solve(coeff_vec);
134 this->sln_vector = this->linear_matrix_solver->get_sln_vector();
139 this->info(
"\tLinearSolver: solving done in %s.", this->last_str().c_str());
Used to pass the instances of Space around.
Represents a finite element space over a domain.