27 #ifndef LAPLACE_DG_HPP_
28 #define LAPLACE_DG_HPP_
33 #include "../source/DUBValues.hpp"
34 #include "../source/DUB_FEM_handler.hpp"
35 #include "../source/assemble_DG.hpp"
36 #include "../source/face_handler_DG.hpp"
37 #include "../source/model_DG.hpp"
38 #include "../source/volume_handler_DG.hpp"
39 #include "source/core_model.hpp"
40 #include "source/geometry/mesh_handler.hpp"
41 #include "source/init.hpp"
42 #include "source/io/data_writer.hpp"
43 #include "source/numerics/bc_handler.hpp"
44 #include "source/numerics/linear_solver_handler.hpp"
45 #include "source/numerics/preconditioner_handler.hpp"
46 #include "source/numerics/tools.hpp"
60 : lifex::utils::FunctionDirichlet()
65 value(
const dealii::Point<lifex::dim> &p,
66 const unsigned int = 0)
const override
69 return std::exp(p[0] + p[1]);
71 return std::exp(p[0] + p[1] + p[2]);
83 : Function<lifex::dim>()
88 value(
const dealii::Point<lifex::dim> &p,
89 const unsigned int = 0)
const override
92 return -2 * std::exp(p[0] + p[1]);
94 return -3 * std::exp(p[0] + p[1] + p[2]);
106 : Function<lifex::dim>()
111 value(
const dealii::Point<lifex::dim> &p,
112 const unsigned int component = 0)
const override
117 return std::exp(p[0] + p[1]);
119 return std::exp(p[0] + p[1]);
124 return std::exp(p[0] + p[1] + p[2]);
126 return std::exp(p[0] + p[1] + p[2]);
128 return std::exp(p[0] + p[1] + p[2]);
160 template <
class basis>
168 this->
u_ex = std::make_shared<laplace_DG::ExactSolution>();
169 this->
grad_u_ex = std::make_shared<laplace_DG::GradExactSolution>();
170 this->
f_ex = std::make_shared<laplace_DG::RightHandSide>();
179 template <
class basis>
193 dealii::FullMatrix<double> V(this->dofs_per_cell, this->dofs_per_cell);
195 dealii::FullMatrix<double> SC(this->dofs_per_cell, this->dofs_per_cell);
197 dealii::FullMatrix<double> IC(this->dofs_per_cell, this->dofs_per_cell);
199 dealii::FullMatrix<double> IC_t(this->dofs_per_cell, this->dofs_per_cell);
201 dealii::FullMatrix<double> IB(this->dofs_per_cell, this->dofs_per_cell);
203 dealii::FullMatrix<double> IB_t(this->dofs_per_cell, this->dofs_per_cell);
205 dealii::FullMatrix<double> IN(this->dofs_per_cell, this->dofs_per_cell);
207 dealii::FullMatrix<double> IN_t(this->dofs_per_cell, this->dofs_per_cell);
209 dealii::FullMatrix<double> SN(this->dofs_per_cell, this->dofs_per_cell);
212 dealii::Vector<double> cell_rhs(this->dofs_per_cell);
214 dealii::Vector<double> cell_rhs_edge(this->dofs_per_cell);
216 std::vector<lifex::types::global_dof_index> dof_indices(
217 this->dofs_per_cell);
219 for (
const auto &cell : this->dof_handler.active_cell_iterators())
221 if (cell->is_locally_owned())
223 this->assemble->reinit(cell);
224 dof_indices = this->dof_handler.get_dof_indices(cell);
226 V = this->assemble->local_V();
227 cell_rhs = this->assemble->local_rhs(this->f_ex);
229 this->matrix.add(dof_indices, V);
230 this->rhs.add(dof_indices, cell_rhs);
232 for (
const auto &edge : cell->face_indices())
234 this->assemble->reinit(cell, edge);
235 std::vector<lifex::types::global_dof_index> dof_indices_neigh(
236 this->dofs_per_cell);
238 SC = this->assemble->local_SC(this->prm_stability_coeff);
239 this->matrix.add(dof_indices, SC);
241 if (!cell->at_boundary(edge))
244 this->assemble->local_IC(this->prm_penalty_coeff);
245 this->matrix.add(dof_indices, IC);
246 this->matrix.add(dof_indices, IC_t);
248 const auto neighcell = cell->neighbor(edge);
250 this->dof_handler.get_dof_indices(neighcell);
253 this->assemble->local_IN(this->prm_penalty_coeff);
254 SN = this->assemble->local_SN(this->prm_stability_coeff);
256 this->matrix.add(dof_indices, dof_indices_neigh, IN);
257 this->matrix.add(dof_indices_neigh, dof_indices, IN_t);
258 this->matrix.add(dof_indices, dof_indices_neigh, SN);
263 this->assemble->local_IB(this->prm_penalty_coeff);
264 cell_rhs_edge = this->assemble->local_rhs_edge_dirichlet(
265 this->prm_stability_coeff,
266 this->prm_penalty_coeff,
268 this->matrix.add(dof_indices, IB);
269 this->matrix.add(dof_indices, IB_t);
270 this->rhs.add(dof_indices, cell_rhs_edge);
276 this->matrix.compress(dealii::VectorOperation::add);
277 this->rhs.compress(dealii::VectorOperation::add);
Class to solve the Laplace equation using the Discontinuous Galerkin method.
void assemble_system() override
Assembly of the linear system.
ExactSolution()
Constructor.
virtual double value(const dealii::Point< lifex::dim > &p, const unsigned int=0) const override
Evaluate the exact solution in a point.
Gradient of the exact solution.
virtual double value(const dealii::Point< lifex::dim > &p, const unsigned int component=0) const override
Evaluate the gradient of the exact solution in a point.
GradExactSolution()
Constructor.
virtual double value(const dealii::Point< lifex::dim > &p, const unsigned int=0) const override
Evaluate the source term in a point.
RightHandSide()
Constructor.
Class representing the resolution of problems using discontinuous Galerkin methods.
std::shared_ptr< dealii::Function< lifex::dim > > f_ex
Known forcing term.
std::shared_ptr< dealii::Function< lifex::dim > > grad_u_ex
Pointer to exact gradient solution Function.
std::shared_ptr< lifex::utils::FunctionDirichlet > u_ex
Pointer to exact solution function.