SolvePoissonProblem.hpp
2 // See LICENSE.txt for details.
3
4 #pragma once
5
6 #include <cstddef>
7
8 #include "Domain/Creators/RegisterDerivedWithCharm.hpp"
9 #include "Domain/Tags.hpp"
10 #include "Elliptic/Actions/ComputeOperatorAction.hpp"
11 #include "Elliptic/DiscontinuousGalerkin/DgElementArray.hpp"
12 #include "Elliptic/DiscontinuousGalerkin/ImposeBoundaryConditions.hpp"
13 #include "Elliptic/Systems/Poisson/Actions/Observe.hpp"
14
16 #include "IO/Observer/Actions.hpp"
17 #include "IO/Observer/Helpers.hpp"
18 #include "IO/Observer/ObserverComponent.hpp"
19 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyFluxes.hpp"
20 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ComputeNonconservativeBoundaryFluxes.hpp"
22 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
23 #include "NumericalAlgorithms/LinearSolver/Actions/TerminateIfConverged.hpp"
24 #include "NumericalAlgorithms/LinearSolver/Gmres/Gmres.hpp"
25
27 #include "Options/Options.hpp"
29 #include "Parallel/InitializationFunctions.hpp"
30 #include "Parallel/Reduction.hpp"
32 #include "PointwiseFunctions/AnalyticSolutions/Poisson/ProductOfSinusoids.hpp"
33 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
34 #include "Utilities/Functional.hpp"
35 #include "Utilities/TMPL.hpp"
36
37 template <size_t Dim>
38 struct Metavariables {
39  static constexpr OptionString help{
40  "Find the solution to a Poisson problem in Dim spatial dimensions.\n"
41  "Analytic solution: ProductOfSinusoids\n"
42  "Linear solver: GMRES\n"
43  "Numerical flux: FirstOrderInternalPenaltyFlux"};
44
45  // The system provides all equations specific to the problem.
47
48  // The analytic solution and corresponding source to solve the Poisson
49  // equation for
50  using analytic_solution_tag =
52
53  // The linear solver algorithm. We must use GMRES since the operator is
54  // not positive-definite for the first-order system.
57
58  // Parse numerical flux parameters from the input file to store in the cache.
61
62  // Set up the domain creator from the input file.
64
65  // Collect all items to store in the cache.
66  using const_global_cache_tag_list = tmpl::list<analytic_solution_tag>;
67
68  using observed_reduction_data_tags = observers::collect_reduction_data_tags<
69  tmpl::list<Poisson::Actions::Observe, linear_solver>>;
70
71  // Specify all parallel components that will execute actions at some point.
72  using component_list = tmpl::append<
73  tmpl::list<Elliptic::DgElementArray<
75  tmpl::list<
84  Elliptic::dg::Actions::
85  ImposeHomogeneousDirichletBoundaryConditions<Metavariables>,
89  tmpl::list<observers::Observer<Metavariables>,
91
92  // Specify all global synchronization points.
93  enum class Phase { Initialization, RegisterWithObserver, Solve, Exit };
94
95  // Specify the transitions between phases.
96  static Phase determine_next_phase(
97  const Phase& current_phase,
98  const Parallel::CProxy_ConstGlobalCache<
99  Metavariables>& /*cache_proxy*/) noexcept {
100  switch (current_phase) {
101  case Phase::Initialization:
102  return Phase::RegisterWithObserver;
103  case Phase::RegisterWithObserver:
104  return Phase::Solve;
105  case Phase::Solve:
106  return Phase::Exit;
107  case Phase::Exit:
108  ERROR(
109  "Should never call determine_next_phase with the current phase "
110  "being 'Exit'");
111  default:
112  ERROR(
113  "Unknown type of phase. Did you static_cast<Phase> an integral "
114  "value?");
115  }
116  }
117 };
118
119 static const std::vector<void (*)()> charm_init_node_funcs{
120  &setup_error_handling, &domain::creators::register_derived_with_charm};
121 static const std::vector<void (*)()> charm_init_proc_funcs{
A GMRES solver for nonsymmetric linear systems of equations .
Definition: Gmres.hpp:66
Functions for serializing factory-created classes.
The set of directions to neighboring Elements.
Definition: Tags.hpp:145
The internal penalty flux for the first oder formulation of the Poisson equation. ...
Definition: Equations.hpp:117
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:35
Defines DataBox tags for the linear solver.
Items for initializing the DataBoxes of parallel components.
Definition: ConservativeSystem.hpp:21
The analytic solution, with the type of the analytic solution set as the template parameter...
Definition: Tags.hpp:22
Receive boundary data needed for fluxes from neighbors.
Definition: FluxCommunication.hpp:59
Defines classes and functions for making classes creatable from input files.
The set of directions which correspond to external boundaries. Used for representing data on the inte...
Definition: Tags.hpp:163
The nodegroup parallel component that is responsible for writing data to disk.
Definition: ObserverComponent.hpp:55
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:26
Holds an IterationId that identifies a step in the linear solver algorithm.
Definition: Tags.hpp:66
Action to observe volume and reduction data for the Poisson system.
Definition: Observe.hpp:64
void enable_floating_point_exceptions()
After a call to this function, the code will terminate with a floating point exception on overflow...
Definition: FloatingPointExceptions.cpp:27
Terminate the algorithm if the linear solver has converged.
Definition: TerminateIfConverged.hpp:32
Defines class Poisson::FirstOrderSystem.
The parallel component responsible for managing the DG elements that compose the computational domain...
Definition: DgElementArray.hpp:54
Send local boundary data needed for fluxes to neighbors.
Definition: FluxCommunication.hpp:204
Functions to enable/disable termination on floating point exceptions.
The global cache tag that retrieves the parameters for the numerical flux from the input file...
Definition: Tags.hpp:59
gmres_detail::PerformStep perform_step
Perform an iteration of the GMRES linear solver.
Definition: Gmres.hpp:152
The Poisson equation formulated as a set of coupled first-order PDEs.
Definition: FirstOrderSystem.hpp:55
Wraps the template metaprogramming library used (brigand)
Defines tags related to domain quantities.
Compute the bulk contribution to the linear operator applied to the variables.
Definition: ComputeOperatorAction.hpp:56
tmpl::list< gmres_detail::ResidualMonitor< Metavariables > > component_list
The parallel components used by the GMRES linear solver.
Definition: Gmres.hpp:75
Compute element boundary contributions to the temporal step of the variables.
Definition: ApplyFluxes.hpp:67
Definition: SolvePoissonProblem.hpp:38
Defines class template ConstGlobalCache.
The input file tag for the DomainCreator to use.
Definition: Tags.hpp:44
Compute on the boundaries for a non-conservative system.
Definition: ComputeNonconservativeBoundaryFluxes.hpp:45
Defines class IterationId.