PRISMS-PF Manual
Loading...
Searching...
No Matches
group_solution_handler.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
6#include <deal.II/distributed/solution_transfer.h>
7#include <deal.II/lac/affine_constraints.h>
8#include <deal.II/lac/la_parallel_block_vector.h>
9#include <deal.II/lac/la_parallel_vector.h>
10#include <deal.II/matrix_free/matrix_free.h>
11
17#include <prismspf/core/types.h>
18
19#include <prismspf/config.h>
20
21#include <vector>
22
24
28template <typename number>
29using BlockVector = dealii::LinearAlgebra::distributed::BlockVector<number>;
30
34template <typename number>
36
40using dealii::MatrixFree;
41
59template <unsigned int dim, typename number>
61{
63 std::vector<BlockVector<number>> old_solutions;
64 MatrixFree<dim, number> matrix_free;
65};
66
70template <unsigned int dim, typename number>
72{
73public:
74#if DEAL_II_VERSION_MAJOR >= 9 && DEAL_II_VERSION_MINOR >= 7
75 using SolutionTransfer = dealii::SolutionTransfer<dim, SolutionVector<number>>;
76#else
78 dealii::parallel::distributed::SolutionTransfer<dim, SolutionVector<number>>;
79#endif
80
85 const std::vector<FieldAttributes> &_attributes_list);
86
92 get_solution_full_vector(unsigned int relative_level = 0);
93
99 get_solution_full_vector(unsigned int relative_level = 0) const;
100
105 get_solution_vector(unsigned int global_index, unsigned int relative_level = 0);
106
111 get_solution_vector(unsigned int global_index, unsigned int relative_level = 0) const;
112
117 get_old_solution_full_vector(unsigned int age, unsigned int relative_level = 0);
118
123 get_old_solution_full_vector(unsigned int age, unsigned int relative_level = 0) const;
124
129 get_old_solution_vector(unsigned int age,
130 unsigned int global_index,
131 unsigned int relative_level = 0);
132
137 get_old_solution_vector(unsigned int age,
138 unsigned int global_index,
139 unsigned int relative_level = 0) const;
140
145 get_solution_level(unsigned int relative_level = 0);
146
151 get_solution_level(unsigned int relative_level = 0) const;
152
156 [[nodiscard]] MatrixFree<dim, number> &
157 get_matrix_free(unsigned int relative_level = 0);
158
162 [[nodiscard]] const MatrixFree<dim, number> &
163 get_matrix_free(unsigned int relative_level = 0) const;
164
168 [[nodiscard]] unsigned int
169 get_block_index(unsigned int global_index) const;
170
174 [[nodiscard]] const SolveGroup &
175 get_solve_group() const;
176
180 [[nodiscard]] const std::vector<unsigned int> &
182
186 [[nodiscard]] const std::vector<unsigned int> &
188
192 template <unsigned int degree>
193 void
194 init(const DoFManager<dim, degree> &dof_manager,
195 const ConstraintManager<dim, degree, number> &constraint_manager,
196 unsigned int num_old_saved);
197
201 template <unsigned int degree>
202 void
203 reinit(const DoFManager<dim, degree> &dof_manager,
204 const ConstraintManager<dim, degree, number> &constraint_manager);
205
209 void
210 update_ghosts(unsigned int relative_level = 0) const;
211
215 void
216 zero_out_ghosts(unsigned int relative_level = 0) const;
217
221 void
222 apply_constraints(unsigned int relative_level = 0);
223
227 void
228 apply_constraints_to_all(unsigned int relative_level);
229
234 void
236
240 void
241 update(unsigned int relative_level = 0);
242
246 void
248
252 void
254
258 void
260
261private:
266
270 std::vector<unsigned int> block_to_global_index;
271
275 std::vector<unsigned int> global_to_block_index;
276
280 std::vector<SolutionLevel<dim, number>> solution_levels;
281
290 std::vector<SolutionTransfer> block_solution_transfer;
291};
292
The class handles the generation and application of boundary conditions based on the user-inputs.
Definition constraint_manager.h:50
Class that manages the deal.II DoFHandlers.
Definition dof_manager.h:27
Class that manages solution initialization and swapping with old solutions.
Definition group_solution_handler.h:72
void init(const DoFManager< dim, degree > &dof_manager, const ConstraintManager< dim, degree, number > &constraint_manager, unsigned int num_old_saved)
Initialize the solution set.
Definition group_solution_handler.cc:175
void apply_constraints_to_all(unsigned int relative_level)
Apply the given constraints to all the solution vectors, including old.
Definition group_solution_handler.cc:336
SolutionVector< number > & get_solution_vector(unsigned int global_index, unsigned int relative_level=0)
Get a solution vector of a given field index.
Definition group_solution_handler.cc:54
BlockVector< number > & get_old_solution_full_vector(unsigned int age, unsigned int relative_level=0)
Get the old solution vector set at a given age.
Definition group_solution_handler.cc:74
void update(unsigned int relative_level=0)
Update and propagate the old solutions.
Definition group_solution_handler.cc:387
std::vector< SolutionLevel< dim, number > > solution_levels
Solutions and matrix free of each level.
Definition group_solution_handler.h:280
std::vector< unsigned int > block_to_global_index
Mapping from block index to global field index.
Definition group_solution_handler.h:270
SolutionLevel< dim, number > & get_solution_level(unsigned int relative_level=0)
Get the solutions object at a level.
Definition group_solution_handler.cc:114
std::vector< unsigned int > global_to_block_index
Mapping from global field index to block index.
Definition group_solution_handler.h:275
void update_ghosts(unsigned int relative_level=0) const
Update the ghost values.
Definition group_solution_handler.cc:317
void prepare_for_solution_transfer()
Prepare for solution transfer.
Definition group_solution_handler.cc:274
const std::vector< unsigned int > & get_block_to_global_index() const
Get the global index from the block index.
Definition group_solution_handler.cc:165
void apply_initial_condition_for_old_fields()
Apply initial condition to the old fields. For now, this simply copies the values in the normal field...
Definition group_solution_handler.cc:371
BlockVector< number > & get_solution_full_vector(unsigned int relative_level=0)
Get the solution vector set. This contains all the normal fields and is typically used for output.
Definition group_solution_handler.cc:38
void zero_out_ghosts(unsigned int relative_level=0) const
Zero out the ghost values.
Definition group_solution_handler.cc:329
const SolveGroup & get_solve_group() const
Get the underlying solve group object.
Definition group_solution_handler.cc:151
void execute_solution_transfer()
Transfer solutions.
Definition group_solution_handler.cc:294
void apply_constraints(unsigned int relative_level=0)
Apply the given constraints to a solution vector of a given field index.
Definition group_solution_handler.cc:355
void init_solution_transfer()
Reinit the solution transfer objections.
Definition group_solution_handler.cc:260
dealii::parallel::distributed::SolutionTransfer< dim, SolutionVector< number > > SolutionTransfer
Definition group_solution_handler.h:78
SolutionVector< number > & get_old_solution_vector(unsigned int age, unsigned int global_index, unsigned int relative_level=0)
Get a solution vector of a given field index at a given age.
Definition group_solution_handler.cc:92
void reinit(const DoFManager< dim, degree > &dof_manager, const ConstraintManager< dim, degree, number > &constraint_manager)
Reinitialize the solution set.
Definition group_solution_handler.cc:207
MatrixFree< dim, number > & get_matrix_free(unsigned int relative_level=0)
Get the matrix_free object at a level.
Definition group_solution_handler.cc:128
std::vector< SolutionTransfer > block_solution_transfer
Utility for solution transfer to different mesh (for AMR). Can only work on one block at a time.
Definition group_solution_handler.h:290
SolveGroup solve_group
Information about the solve group this handler is responsible for.
Definition group_solution_handler.h:265
const std::vector< unsigned int > & get_global_to_block_index() const
Get the block index from the global index.
Definition group_solution_handler.cc:158
unsigned int get_block_index(unsigned int global_index) const
Get the block index from the global index.
Definition group_solution_handler.cc:144
Structure to hold the attributes of a solve-group.
Definition solve_group.h:59
@ Value
Use value of the variable as a criterion for refinement.
Definition grid_refiner_criterion.h:31
dealii::LinearAlgebra::distributed::BlockVector< number > BlockVector
Typedef for solution block vector.
Definition group_solution_handler.h:29
BlockVector< number >::BlockType SolutionVector
Typedef for solution vector.
Definition group_solution_handler.h:35
Definition conditional_ostreams.cc:20
The solution vectors and their corresponding matrix free object with respect to some multigrid level.
Definition group_solution_handler.h:61
MatrixFree< dim, number > matrix_free
Definition group_solution_handler.h:64
std::vector< BlockVector< number > > old_solutions
Definition group_solution_handler.h:63
BlockVector< number > solutions
Definition group_solution_handler.h:62