pi-DoMUS: Parallel Deal.II MUltiphysics Solver
poisson_problem.h
Go to the documentation of this file.
1 #ifndef _pidoums_poisson_h_
2 #define _pidoums_poisson_h_
3 
4 #include "pde_system_interface.h"
5 
10 
11 //typedef LATrilinos LAC;
12 
13 template <int dim, int spacedim, typename LAC=LATrilinos>
14 class PoissonProblem : public PDESystemInterface<dim,spacedim, PoissonProblem<dim,spacedim,LAC>, LAC>
15 {
16 
17 public:
19  PoissonProblem ();
20 
21  // interface with the PDESystemInterface :)
22 
23 
24  template <typename EnergyType, typename ResidualType>
26  FEValuesCache<dim,spacedim> &scratch,
27  std::vector<EnergyType> &energies,
28  std::vector<std::vector<ResidualType> > &local_residuals,
29  bool compute_only_system_terms) const;
30 
31 
33  const std::vector<shared_ptr<LATrilinos::BlockMatrix> >,
36 
37 private:
38  mutable shared_ptr<TrilinosWrappers::PreconditionJacobi> preconditioner;
39 
40 
41 };
42 
43 template <int dim, int spacedim, typename LAC>
46  PDESystemInterface<dim,spacedim,PoissonProblem<dim,spacedim,LAC>, LAC >("Poisson problem",
47  1,1,
48  "FESystem[FE_Q(1)]",
49  "u","1")
50 {}
51 
52 
53 
54 template <int dim, int spacedim, typename LAC>
55 template <typename EnergyType, typename ResidualType>
56 void
59  FEValuesCache<dim,spacedim> &fe_cache,
60  std::vector<EnergyType> &,
61  std::vector<std::vector<ResidualType> > &local_residuals,
62  bool compute_only_system_terms) const
63 {
64  const FEValuesExtractors::Scalar s(0);
65 
66  ResidualType rt = this->alpha; // dummy number to define the type of variables
67  this->reinit (rt, cell, fe_cache);
68  auto &uts = fe_cache.get_values("solution_dot", "u", s, rt);
69  auto &gradus = fe_cache.get_gradients("solution", "u", s, rt);
70 
71  const unsigned int n_q_points = uts.size();
72  auto &JxW = fe_cache.get_JxW_values();
73 
74  auto &fev = fe_cache.get_current_fe_values();
75 
76  for (unsigned int q=0; q<n_q_points; ++q)
77  {
78  auto &ut = uts[q];
79  auto &gradu = gradus[q];
80  for (unsigned int i=0; i<local_residuals[0].size(); ++i)
81  {
82  auto v = fev[s].value(i,q);
83  auto gradv = fev[s].gradient(i,q);
84  local_residuals[0][i] += (
85  ut*v
86  +
87  gradu*gradv
88  )*JxW[q];
89  }
90 
91  (void)compute_only_system_terms;
92 
93  }
94 
95 
96 }
97 
98 
99 template <int dim, int spacedim, typename LAC>
100 void
102  const std::vector<shared_ptr<LATrilinos::BlockMatrix> > matrices,
105 {
106 
107  preconditioner.reset (new TrilinosWrappers::PreconditionJacobi());
108  preconditioner->initialize(matrices[0]->block(0,0));
109 
110  auto A = linear_operator<LATrilinos::VectorType::BlockType>( matrices[0]->block(0,0) );
111 
113 
114  P_inv = linear_operator<LATrilinos::VectorType::BlockType>(matrices[0]->block(0,0), *preconditioner);
115 
116  auto P00 = P_inv;
117 
118  // ASSEMBLE THE PROBLEM:
119  system_op = block_operator<1, 1, LATrilinos::VectorType>({{
120  {{ A }}
121  }
122  });
123 
124  prec_op = block_operator<1, 1, LATrilinos::VectorType>({{
125  {{ P00}} ,
126  }
127  });
128 }
129 
130 #endif
PoissonProblem()
Definition: poisson_problem.h:45
Definition: lac_type.h:33
void energies_and_residuals(const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, FEValuesCache< dim, spacedim > &scratch, std::vector< EnergyType > &energies, std::vector< std::vector< ResidualType > > &local_residuals, bool compute_only_system_terms) const
Definition: poisson_problem.h:58
void compute_system_operators(const DoFHandler< dim, spacedim > &, const std::vector< shared_ptr< LATrilinos::BlockMatrix > >, LinearOperator< LATrilinos::VectorType > &, LinearOperator< LATrilinos::VectorType > &) const
Definition: poisson_problem.h:101
ActiveSelector::active_cell_iterator active_cell_iterator
This is the class that users should derive from.
Definition: pde_system_interface.h:46
~PoissonProblem()
Definition: poisson_problem.h:18
Definition: poisson_problem.h:14