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_group;
28
29public:
37
38 void
39 init(const std::list<DependencyMap> &all_dependeny_sets) override
40 {
42 unsigned int num_levels = solve_context->get_dof_manager().get_dof_handlers().size();
43 // Initialize rhs_operators
44 rhs_operators.reserve(num_levels);
45 for (unsigned int relative_level = 0; relative_level < num_levels; ++relative_level)
46 {
47 rhs_operators.emplace_back(solve_context->get_pde_operator(),
49 solve_context->get_field_attributes(),
50 solve_context->get_solution_indexer(),
51 relative_level,
53 solve_context->get_simulation_timer());
54 rhs_operators[relative_level].initialize(solutions);
55 rhs_operators[relative_level].set_scaling_diagonal(
56 true,
57 solve_context->get_invm_manager().get_invm(
58 solve_context->get_field_attributes(),
60 relative_level));
61 }
62 }
63
67 void
68 solve_level(unsigned int relative_level) override
69 {
70 // Zero out the ghosts
71 Timer::start_section("Zero ghosts");
72 solutions.zero_out_ghosts(relative_level);
73 Timer::end_section("Zero ghosts");
74
75 rhs_operators[relative_level].compute_operator(
76 solutions.get_solution_full_vector(relative_level));
77
78 // Apply constraints
79 solutions.apply_constraints(relative_level);
80
81 // Update the ghosts
82 Timer::start_section("Update ghosts");
83 solutions.update_ghosts(relative_level);
84 Timer::end_section("Update ghosts");
85 }
86
87private:
91 std::vector<MFOperator<dim, degree, number>> rhs_operators;
92};
93
This class handles the explicit solves of all explicit fields.
Definition explicit_solver.h:24
std::vector< MFOperator< dim, degree, number > > rhs_operators
Matrix free operators for each level.
Definition explicit_solver.h:91
void init(const std::list< DependencyMap > &all_dependeny_sets) override
Initialize the solver.
Definition explicit_solver.h:39
ExplicitSolver(SolveGroup _solve_group, const SolveContext< dim, degree, number > &_solve_context)
Constructor.
Definition explicit_solver.h:33
void solve_level(unsigned int relative_level) override
Solve for a single update step.
Definition explicit_solver.h:68
This class contains the user implementation of each PDE operator.
Definition pde_operator_base.h:24
This class provides context for a solver with ptrs to all the relevant dependencies.
Definition solve_context.h:36
Structure to hold the attributes of a solve-group.
Definition solve_group.h:59
std::set< Types::Index > field_indices
Indices of the fields to be solved in this group.
Definition solve_group.h:98
DependencyMap dependencies_rhs
Dependencies for the rhs equation(s)
Definition solve_group.h:103
Definition solver_base.h:32
SolveGroup solve_group
Information about the solve group this handler is responsible for.
Definition solver_base.h:259
virtual void init(const std::list< DependencyMap > &all_dependeny_sets)
Initialize the solver.
Definition solver_base.h:83
GroupSolutionHandler< dim, number > solutions
Solution vectors for fields handled by this solver.
Definition solver_base.h:269
const SolveContext< dim, degree, number > * solve_context
Solver context provides access to external information.
Definition solver_base.h:264
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
@ Value
Use value of the variable as a criterion for refinement.
Definition grid_refiner_criterion.h:31
Definition conditional_ostreams.cc:20