PRISMS-PF Manual
Loading...
Searching...
No Matches
explicit_solver.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2025 PRISMS Center at the University of Michigan
2// SPDX-License-Identifier: GNU Lesser General Public Version 2.1
3
4#pragma once
5
8
11
12#include <prismspf/config.h>
13
15
16template <unsigned int dim, unsigned int degree, typename number>
17class SolveContext;
18
22template <unsigned int dim, unsigned int degree, typename number>
23class ExplicitSolver : public SolverBase<dim, degree, number>
24{
25 using SolverBase<dim, degree, number>::solutions;
26 using SolverBase<dim, degree, number>::solve_context;
27 using SolverBase<dim, degree, number>::solve_block;
28
29public:
35 const SolveContext<dim, degree, number> &_solve_context)
36 : SolverBase<dim, degree, number>(_solve_block, _solve_context)
37 , rhs_operator(solve_context->get_pde_operator(),
38 &PDEOperatorBase<dim, degree, number>::compute_rhs,
39 solve_context->get_field_attributes(),
40 solve_context->get_solution_indexer(),
41 solve_context->get_matrix_free_manager(),
42 solve_block.dependencies_rhs,
43 solve_context->get_simulation_timer())
44 {}
45
46 void
47 init(const std::list<DependencyMap> &all_dependeny_sets) override
48 {
49 SolverBase<dim, degree, number>::init(all_dependeny_sets);
50 unsigned int num_levels =
51 solve_context->get_dof_manager().get_dof_handlers_levels().size();
52 // Initialize rhs_operators
53 rhs_operator.initialize(solutions);
54 rhs_operator.set_scaling_diagonal(
55 true,
56 solve_context->get_invm_manager().get_invm(solve_context->get_field_attributes(),
57 solve_block.field_indices,
58 0));
59 }
60
64 void
65 solve_impl() override
66 {
67 // Zero out the ghosts
68 Timer::start_section("Zero ghosts");
69 solutions.zero_out_ghosts(0);
70 Timer::end_section("Zero ghosts");
71
72 rhs_operator.compute_operator(solutions.get_solution_full_vector(0));
73
74 // Apply constraints
75 solutions.apply_constraints(0);
76
77 // Update the ghosts
78 Timer::start_section("Update ghosts");
79 solutions.update_ghosts(0);
80 Timer::end_section("Update ghosts");
81 }
82
83private:
88};
89
90PRISMS_PF_END_NAMESPACE
MFOperator< dim, degree, number > rhs_operator
Matrix free operator.
Definition explicit_solver.h:87
ExplicitSolver(SolveBlock _solve_block, const SolveContext< dim, degree, number > &_solve_context)
Constructor.
Definition explicit_solver.h:34
void init(const std::list< DependencyMap > &all_dependeny_sets) override
Initialize the solver.
Definition explicit_solver.h:47
void solve_impl() override
Solve for a single update step.
Definition explicit_solver.h:65
This class exists to evaluate a single user-defined operator for the matrix-free implementation of so...
Definition mf_operator.h:55
This class contains the user implementation of each PDE operator.
Definition pde_operator_base.h:27
Structure to hold the attributes of a solve-block.
Definition solve_block.h:59
This class provides context for a solver with ptrs to all the relevant dependencies.
Definition solve_context.h:34
SolverBase(SolveBlock _solve_block, const SolveContext< dim, degree, number > &_solve_context)
Constructor.
Definition solver_base.h:36
virtual void init(const std::list< DependencyMap > &all_dependeny_sets)
Initialize the solver.
Definition solver_base.h:84
GroupSolutionHandler< dim, number > solutions
Solution vectors for fields handled by this solver.
Definition solver_base.h:271
const SolveContext< dim, degree, number > * solve_context
Solver context provides access to external information.
Definition solver_base.h:266
SolveBlock solve_block
Information about the solve block this handler is responsible for.
Definition solver_base.h:261
static void start_section(const char *name)
Start a new timer section.
Definition timer.cc:116
static void end_section(const char *name)
End the timer section.
Definition timer.cc:127
Definition conditional_ostreams.cc:20