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 {}
38
39 void
40 init(const std::list<SolveBlock> &all_solve_blocks) override
41 {
43 // Initialize rhs_operator
44 rhs_operator.init(solve_context->get_pde_operator(),
46 solve_context->get_field_attributes(),
47 solve_context->get_solution_indexer(),
48 solve_context->get_matrix_free_manager(),
49 solve_context->get_simulation_timer(),
51 solve_block.dependencies_rhs);
52 rhs_operator.set_scaling_diagonal(
53 true,
54 solve_context->get_invm_manager().get_invm(solve_context->get_field_attributes(),
55 solve_block.field_indices));
56 }
57
61 void
62 solve_impl() override
63 {
64 // Zero out the ghosts
65 Timer::start_section("Zero ghosts");
66 solutions.zero_out_ghosts();
67 Timer::end_section("Zero ghosts");
68
69 rhs_operator.compute_operator(solutions.get_solution_full_vector());
70
71 // Apply constraints
72 solutions.apply_constraints();
73
74 // Update the ghosts
75 Timer::start_section("Update ghosts");
76 solutions.update_ghosts();
77 Timer::end_section("Update ghosts");
78 }
79
80private:
85};
86
87PRISMS_PF_END_NAMESPACE
MFOperator< dim, degree, number > rhs_operator
Matrix free operator.
Definition explicit_solver.h:84
ExplicitSolver(SolveBlock _solve_block, const SolveContext< dim, degree, number > &_solve_context)
Constructor.
Definition explicit_solver.h:34
void solve_impl() override
Solve for a single update step.
Definition explicit_solver.h:62
void init(const std::list< SolveBlock > &all_solve_blocks) override
Initialize the solver.
Definition explicit_solver.h:40
This class exists to evaluate a single user-defined operator for the matrix-free implementation of so...
Definition mf_operator.h:54
virtual void compute_rhs(FieldContainer< dim, degree, number > &variable_list, const SimulationTimer &sim_timer, unsigned int solver_id) const
User-implemented class for the RHS of explicit equations.
Definition pde_operator_base.h:79
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
virtual void init(const std::list< SolveBlock > &all_solve_blocks)
Initialize the solver.
Definition solver_base.h:84
SolverBase(SolveBlock _solve_block, const SolveContext< dim, degree, number > &_solve_context)
Constructor.
Definition solver_base.h:36
GroupSolutionHandler< dim, number > solutions
Solution vectors for fields handled by this solver.
Definition solver_base.h:293
const SolveContext< dim, degree, number > * solve_context
Solver context provides access to external information.
Definition solver_base.h:288
SolveBlock solve_block
Information about the solve block this handler is responsible for.
Definition solver_base.h:283
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