pi-DoMUS: Parallel Deal.II MUltiphysics Solver
heat_equation.h
Go to the documentation of this file.
1 
5 #ifndef _heat_equation_derived_interface_h_
6 #define _heat_equation_derived_interface_h_
7 
9 #include <deal2lkit/parsed_function.h>
10 
11 
12 #include <deal.II/fe/fe_values.h>
17 
21 
22 #include <deal.II/lac/solver_cg.h>
24 #include "data/assembly.h"
25 #include "lac/lac_type.h"
26 
27 
28 template <int dim, typename LAC=LADealII>
29 class HeatEquation : public ConservativeInterface<dim,dim,1, HeatEquation<dim,LAC>, LAC >
30 {
31  typedef FEValuesCache<dim,dim> Scratch;
32  typedef Assembly::CopyData::piDoMUSPreconditioner<dim,dim> CopyPreconditioner;
33  typedef Assembly::CopyData::piDoMUSSystem<dim,dim> CopySystem;
35 
36 public:
37 
38 
39  /* specific and useful functions for this very problem */
41  ConservativeInterface<dim,dim,1,HeatEquation<dim,LAC>, LAC >("Heat Equation",
42  "FESystem[FE_Q(2)]",
43  "u", "1", "0","1")
44  {};
45 
46 
48  {
49  return update_default;
50  };
51 
52 
53  template<typename Number>
55  Scratch &,
56  CopyPreconditioner &,
57  Number &) const
58  {
59  };
60 
61  template<typename Number>
63  Scratch &fe_cache,
64  CopySystem &data,
65  Number &energy) const
66  {
67  Number alpha = this->alpha;
68  this->reinit(alpha, cell, fe_cache);
69 
70  auto &JxW = fe_cache.get_JxW_values();
71 
72  const FEValuesExtractors::Scalar scalar(0);
73 
74  auto &us = fe_cache.get_values("solution", "u", scalar, alpha);
75  auto &us_dot = fe_cache.get_values("solution_dot", "u_dot", scalar, alpha);
76  auto &grad_us = fe_cache.get_gradients("solution", "gradu", scalar, alpha);
77 
78  energy = 0;
79  for (unsigned int q=0; q<us.size(); ++q)
80  {
81  const Number &u = us[q];
82  const Number &u_dot = us_dot[q];
83  const Tensor <1, dim, Number> &grad_u = grad_us[q];
84 
85  energy += (u_dot*u + 0.5*(grad_u*grad_u))*JxW[q];
86  }
87  };
88 };
89 
90 
91 #endif
92 
Definition: conservative.h:20
UpdateFlags get_preconditioner_flags() const
Definition: heat_equation.h:47
Definition: lac_type.h:33
void system_energy(const typename DoFHandler< dim >::active_cell_iterator &cell, Scratch &fe_cache, CopySystem &data, Number &energy) const
Definition: heat_equation.h:62
HeatEquation()
Definition: heat_equation.h:40
Definition: heat_equation.h:29
UpdateFlags
void reinit(const Number &alpha, const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, FEValuesCache< dim, spacedim > &fe_cache) const
Definition: old_interface.h:470
double alpha
Definition: old_interface.h:391
void preconditioner_energy(const typename DoFHandler< dim >::active_cell_iterator &, Scratch &, CopyPreconditioner &, Number &) const
Definition: heat_equation.h:54