Theory and Practice of FEM -- a parametrized Poisson Solver
poisson.h
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------
2  *
3  * Copyright (C) 1999 - 2020 by the deal.II authors
4  *
5  * This file is part of the deal.II library.
6  *
7  * The deal.II library is free software; you can use it, redistribute
8  * it, and/or modify it under the terms of the GNU Lesser General
9  * Public License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  * The full text of the license can be found in the file LICENSE.md at
12  * the top level directory of deal.II.
13  *
14  * ---------------------------------------------------------------------
15  *
16  * Authors: Wolfgang Bangerth, 1999,
17  * Guido Kanschat, 2011
18  * Luca Heltai, 2021
19  */
20 
21 // Make sure we don't redefine things
22 #ifndef poisson_include_file
23 #define poisson_include_file
24 
25 #include <deal.II/base/function.h>
30 #include <deal.II/base/timer.h>
31 
33 #include <deal.II/dofs/dof_tools.h>
34 
35 #include <deal.II/fe/fe_q.h>
36 #include <deal.II/fe/fe_values.h>
38 
40 #include <deal.II/grid/tria.h>
41 
46 #include <deal.II/lac/solver_cg.h>
48 #include <deal.II/lac/vector.h>
49 
52 
56 
57 #include <fstream>
58 #include <iostream>
59 
60 // Forward declare the tester class
61 template <typename Integral>
62 class PoissonTester;
63 
64 using namespace dealii;
65 
71 template <int dim>
73 {
74 public:
79  Poisson();
80 
81  void
82  print_system_info();
83 
84  void
85  run();
86 
87  void
88  initialize(const std::string &filename);
89 
90  void
91  parse_string(const std::string &par);
92 
95 
96 protected:
97  void
98  assemble_system_one_cell(
99  const typename DoFHandler<dim>::active_cell_iterator &cell,
100  ScratchData & scratch,
101  CopyData & copy);
102 
103 
104  void
105  copy_one_cell(const CopyData &copy);
106 
107  void
108  make_grid();
109 
110  void
111  refine_grid();
112 
113  void
114  setup_system();
115 
116  void
117  assemble_system();
118 
119  void
120  assemble_system_on_range(
121  const typename DoFHandler<dim>::active_cell_iterator &begin,
122  const typename DoFHandler<dim>::active_cell_iterator &end);
123 
124  void
125  solve();
126  void
127  estimate();
128  void
129  mark();
130  void
131  output_results(const unsigned cycle) const;
132 
134 
136  std::unique_ptr<FE_Q<dim>> fe;
137  std::unique_ptr<MappingQGeneric<dim>> mapping;
144 
146  std::string estimator_type = "exact";
147  std::string marking_strategy = "global";
148  std::pair<double, double> coarsening_and_refinement_factors = {0.03, 0.3};
149 
150 
157 
158 
159  unsigned int fe_degree = 1;
160  unsigned int mapping_degree = 1;
161  unsigned int n_refinements = 4;
162  unsigned int n_refinement_cycles = 1;
163  std::string output_filename = "poisson";
164  int number_of_threads = -1;
165 
166  std::set<types::boundary_id> dirichlet_ids = {0};
167  std::set<types::boundary_id> neumann_ids;
168 
169  std::string forcing_term_expression = "1";
170  std::string coefficient_expression = "1";
171  std::string exact_solution_expression = "0";
172  std::string dirichlet_boundary_conditions_expression = "0";
173  std::string neumann_boundary_conditions_expression = "0";
174  std::string pre_refinement_expression = "0";
175  std::map<std::string, double> constants;
176 
177  std::string grid_generator_function = "hyper_cube";
178  std::string grid_generator_arguments = "0: 1: false";
179 
181 
182  bool use_direct_solver = true;
183 
185 
186  template <typename Integral>
187  friend class PoissonTester;
188 };
189 
190 #endif
std::set< types::boundary_id > neumann_ids
Definition: poisson.h:167
AffineConstraints< double > constraints
Definition: poisson.h:139
std::map< std::string, double > constants
Definition: poisson.h:175
SparseMatrix< double > system_matrix
Definition: poisson.h:141
Vector< double > system_rhs
Definition: poisson.h:143
FunctionParser< dim > coefficient
Definition: poisson.h:152
ParsedConvergenceTable error_table
Definition: poisson.h:180
ParameterAcceptorProxy< ReductionControl > solver_control
Definition: poisson.h:184
FunctionParser< dim > forcing_term
Definition: poisson.h:151
FunctionParser< dim > neumann_boundary_condition
Definition: poisson.h:155
SparsityPattern sparsity_pattern
Definition: poisson.h:140
FunctionParser< dim > dirichlet_boundary_condition
Definition: poisson.h:154
FunctionParser< dim > pre_refinement
Definition: poisson.h:156
TimerOutput timer
Definition: poisson.h:133
DoFHandler< dim > dof_handler
Definition: poisson.h:138
Triangulation< dim > triangulation
Definition: poisson.h:135
Vector< float > error_per_cell
Definition: poisson.h:145
Vector< double > solution
Definition: poisson.h:142
std::unique_ptr< MappingQGeneric< dim > > mapping
Definition: poisson.h:137
std::unique_ptr< FE_Q< dim > > fe
Definition: poisson.h:136
FunctionParser< dim > exact_solution
Definition: poisson.h:153
void run(const std::vector< std::vector< Iterator >> &colored_iterators, Worker worker, Copier copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, const unsigned int queue_length=2 *MultithreadInfo::n_threads(), const unsigned int chunk_size=8)