[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
mesh_error_estimate.h
1 #ifndef __MESHERRORESTIMATE_H__
2 #define __MESHERRORESTIMATE_H__
3 
4 #include <deal.II/distributed/grid_refinement.h>
5 #include <deal.II/distributed/shared_tria.h>
6 #include <deal.II/distributed/solution_transfer.h>
7 #include <deal.II/distributed/tria.h>
8 #include <deal.II/fe/fe_q.h>
9 #include <deal.II/fe/fe_values.h>
10 #include <deal.II/grid/grid_refinement.h>
11 #include <deal.II/grid/tria.h>
12 #include <deal.II/lac/la_parallel_vector.h>
13 
14 #include <iostream>
15 #include <vector>
16 
17 #include "dg/dg_base.hpp"
18 #include "functional/functional.h"
19 #include "parameters/all_parameters.h"
20 #include "physics/physics.h"
21 
22 namespace PHiLiP {
23 
24 #if PHILIP_DIM==1
25 template <int dim, typename real, typename MeshType = dealii::Triangulation<dim>>
26 #else
27 template <int dim, typename real, typename MeshType = dealii::parallel::distributed::Triangulation<dim>>
28 #endif
29 
32 {
33 
34 public:
35 
37  virtual dealii::Vector<real> compute_cellwise_errors () = 0;
38 
40  explicit MeshErrorEstimateBase(std::shared_ptr< DGBase<dim, real, MeshType> > dg_input);
41 
43  virtual ~MeshErrorEstimateBase() = default;
44 
46  std::shared_ptr<DGBase<dim,real,MeshType>> dg;
47 
48 };
49 
50 #if PHILIP_DIM==1
51 template <int dim, typename real, typename MeshType = dealii::Triangulation<dim>>
52 #else
53 template <int dim, typename real, typename MeshType = dealii::parallel::distributed::Triangulation<dim>>
54 #endif
55 class ResidualErrorEstimate : public MeshErrorEstimateBase <dim, real, MeshType>
57 {
58 
59 public:
61  dealii::Vector<real> compute_cellwise_errors () override;
62 
64  explicit ResidualErrorEstimate(std::shared_ptr<DGBase<dim,real,MeshType>> dg_input);
65 
66 };
67 
68 
70 
84 #if PHILIP_DIM==1 // dealii::parallel::distributed::Triangulation<dim> does not work for 1D
85 template <int dim, int nstate, typename real, typename MeshType = dealii::Triangulation<dim>>
86 #else
87 template <int dim, int nstate, typename real, typename MeshType = dealii::parallel::distributed::Triangulation<dim>>
88 #endif
89 class DualWeightedResidualError : public MeshErrorEstimateBase <dim, real, MeshType>
90 {
91 public:
92 
96  fine,
97  };
98 
100 
104  explicit DualWeightedResidualError(std::shared_ptr< DGBase<dim, real, MeshType> > dg_input);
105 
107 
110  void reinit();
111 
113 
116  void convert_dgsolution_to_coarse_or_fine(SolutionRefinementStateEnum refinement_state);
117 
119 
122  void coarse_to_fine();
123 
125 
128  void fine_to_coarse();
129 
131 
139  dealii::LinearAlgebra::distributed::Vector<real> fine_grid_adjoint();
140 
142 
149  dealii::LinearAlgebra::distributed::Vector<real> coarse_grid_adjoint();
150 
152 
160  dealii::Vector<real> dual_weighted_residual();
161 
163  dealii::Vector<real> compute_cellwise_errors () override;
164 
166  real total_dual_weighted_residual_error();
167 
169 
173  void output_results_vtk(const unsigned int cycle);
174 
176  dealii::LinearAlgebra::distributed::Vector<real> compute_adjoint(dealii::LinearAlgebra::distributed::Vector<real> &derivative_functional_wrt_solution,
177  dealii::LinearAlgebra::distributed::Vector<real> &adjoint_variable);
178 
180  std::shared_ptr< Functional<dim, nstate, real, MeshType> > functional;
181 
183  dealii::LinearAlgebra::distributed::Vector<real> solution_coarse;
185  dealii::LinearAlgebra::distributed::Vector<real> derivative_functional_wrt_solution_fine;
187  dealii::LinearAlgebra::distributed::Vector<real> derivative_functional_wrt_solution_coarse;
189  dealii::LinearAlgebra::distributed::Vector<real> adjoint_fine;
191  dealii::LinearAlgebra::distributed::Vector<real> adjoint_coarse;
193  dealii::Vector<real> dual_weighted_residual_fine;
194 
196  dealii::Vector<real> coarse_fe_index;
197 
199  SolutionRefinementStateEnum solution_refinement_state;
200 
201 protected:
202  MPI_Comm mpi_communicator;
203  dealii::ConditionalOStream pcout;
204 
205 }; // DualWeightedResidualError class
206 
207 } // namespace PHiLiP
208 
209 #endif
Abstract class to estimate error for mesh adaptation.
Files for the baseline physics.
Definition: ADTypes.hpp:10
MeshErrorEstimateBase(std::shared_ptr< DGBase< dim, real, MeshType > > dg_input)
Constructor.
std::shared_ptr< Functional< dim, nstate, real, MeshType > > functional
Functional class pointer.
MPI_Comm mpi_communicator
MPI communicator.
dealii::LinearAlgebra::distributed::Vector< real > derivative_functional_wrt_solution_coarse
functional derivative (on the coarse grid)
dealii::ConditionalOStream pcout
Parallel std::cout that only outputs on mpi_rank==0.
dealii::LinearAlgebra::distributed::Vector< real > adjoint_coarse
coarse grid adjoint ( )
virtual dealii::Vector< real > compute_cellwise_errors()=0
Computes the vector containing errors in each cell.
SolutionRefinementStateEnum
For storing the current refinement state of the solution.
virtual ~MeshErrorEstimateBase()=default
Virtual Destructor.
dealii::LinearAlgebra::distributed::Vector< real > solution_coarse
original solution
Class to compute residual based error.
std::shared_ptr< DGBase< dim, real, MeshType > > dg
Pointer to DGBase.
DualWeightedResidualError class.
DGBase is independent of the number of state variables.
Definition: dg_base.hpp:82
dealii::LinearAlgebra::distributed::Vector< real > derivative_functional_wrt_solution_fine
functional derivative (on the fine grid)
dealii::LinearAlgebra::distributed::Vector< real > adjoint_fine
fine grid adjoint ( )
dealii::Vector< real > dual_weighted_residual_fine
Dual weighted residual (.