pi-DoMUS: Parallel Deal.II MUltiphysics Solver
base_interface.h
Go to the documentation of this file.
1 #ifndef _pidomus_base_interface_h_
2 #define _pidomus_base_interface_h_
3 
5 /* #include <deal.II/lac/linear_operator.h> */
6 /* #include <deal.II/lac/block_linear_operator.h> */
7 /* #include <deal.II/lac/packaged_operation.h> */
8 /* #include <deal.II/lac/solver_cg.h> */
10 
11 
12 #include <deal2lkit/parsed_finite_element.h>
13 #include <deal2lkit/parsed_function.h>
14 #include <deal2lkit/parsed_mapped_functions.h>
15 #include <deal2lkit/parsed_dirichlet_bcs.h>
16 
17 #include "copy_data.h"
18 #include "lac/lac_type.h"
19 
20 using namespace pidomus;
69 template <int dim,int spacedim=dim, typename LAC=LATrilinos>
70 class BaseInterface : public ParameterAcceptor
71 {
72 
73 public:
74 
78  virtual ~BaseInterface() {};
79 
87  BaseInterface(const std::string &name="",
88  const unsigned int &n_comp=0,
89  const unsigned int &n_matrices=0,
90  const std::string &default_fe="FE_Q(1)",
91  const std::string &default_component_names="u",
92  const std::string &default_differential_components="");
93 
94  void init ();
95 
96 
97  virtual void declare_parameters (ParameterHandler &prm);
98 
102  const std::vector<unsigned int> get_differential_blocks() const;
103 
107  virtual void postprocess_newly_created_triangulation(Triangulation<dim, spacedim> &tria) const;
108 
116  virtual void initialize_data(const typename LAC::VectorType &solution,
117  const typename LAC::VectorType &solution_dot,
118  const typename LAC::VectorType &explicit_solution,
119  const double t,
120  const double alpha) const;
121 
122 
128  virtual void assemble_energies_and_residuals(const typename DoFHandler<dim,spacedim>::active_cell_iterator &,
129  FEValuesCache<dim,spacedim> &,
130  std::vector<Sdouble> &energies,
131  std::vector<std::vector<double> > &local_residuals,
132  bool compute_only_system_terms) const;
133 
139  virtual void assemble_energies_and_residuals(const typename DoFHandler<dim,spacedim>::active_cell_iterator &,
140  FEValuesCache<dim,spacedim> &,
141  std::vector<SSdouble> &energies,
142  std::vector<std::vector<Sdouble> > &local_residuals,
143  bool compute_only_system_terms) const;
144 
151  virtual void assemble_local_matrices (const typename DoFHandler<dim,spacedim>::active_cell_iterator &cell,
152  FEValuesCache<dim,spacedim> &scratch,
153  CopyData &data) const;
154 
160  virtual void assemble_local_system_residual (const typename DoFHandler<dim,spacedim>::active_cell_iterator &cell,
161  FEValuesCache<dim,spacedim> &scratch,
162  CopyData &data) const;
163 
170  virtual void compute_system_operators(const DoFHandler<dim,spacedim> &,
171  const std::vector<shared_ptr<typename LATrilinos::BlockMatrix> >,
174 
179  void compute_system_operators(const DoFHandler<dim,spacedim> &,
180  const std::vector<shared_ptr<typename LADealII::BlockMatrix> >,
183  {};
184 
185 
186  virtual const Mapping<dim,spacedim> &get_mapping() const;
187 
188  virtual UpdateFlags get_face_update_flags() const;
189 
190  virtual UpdateFlags get_cell_update_flags() const;
191 
192  void fix_solution_dot_derivative(FEValuesCache<dim,spacedim> &, double) const;
193 
194  void fix_solution_dot_derivative(FEValuesCache<dim,spacedim> &fe_cache, Sdouble alpha) const;
195 
196 
197  void fix_solution_dot_derivative(FEValuesCache<dim,spacedim> &fe_cache, SSdouble alpha) const;
198 
199  template<typename Number>
200  void reinit(const Number &alpha,
202  FEValuesCache<dim,spacedim> &fe_cache) const;
203 
204 
205  template<typename Number>
206  void reinit(const Number &alpha,
208  const unsigned int face_no,
209  FEValuesCache<dim,spacedim> &fe_cache) const;
210 
211 
212 
213  const Table<2,DoFTools::Coupling> &get_matrix_coupling(const unsigned int &i) const;
214 
215  const unsigned int n_components;
216  const unsigned int n_matrices;
217 
218  ParsedFiniteElement<dim,spacedim> pfe;
219 
223  std::string get_component_names() const;
224 
225 
226 protected:
227 
228  void build_couplings();
229 
244  virtual void set_matrix_couplings(std::vector<std::string> &couplings) const;
245 
246  void convert_string_to_int(const std::string &str_coupling,
247  std::vector<std::vector<unsigned int> > &int_coupling) const;
248 
252  Table<2, DoFTools::Coupling> to_coupling(const std::vector<std::vector<unsigned int> > &table) const;
253 
254  std::string str_diff_comp;
255 
256  std::vector<unsigned int> _diff_comp;
257 
261  mutable const typename LAC::VectorType *solution;
262 
266  mutable const typename LAC::VectorType *explicit_solution;
267 
271  mutable const typename LAC::VectorType *solution_dot;
272 
276  mutable double t;
277  mutable double alpha;
278  unsigned int dofs_per_cell;
279  unsigned int n_q_points;
280  unsigned int n_face_q_points;
281 
282  std::vector<Table<2,DoFTools::Coupling> > matrix_couplings;
283 
284 
285 };
286 
287 template <int dim, int spacedim, typename LAC>
288 template<typename Number>
289 void
290 BaseInterface<dim,spacedim,LAC>::reinit(const Number &,
292  FEValuesCache<dim,spacedim> &fe_cache) const
293 {
294  double dummy=0;
295  Number alpha = this->alpha;
296  fe_cache.reinit(cell);
297  fe_cache.cache_local_solution_vector("explicit_solution", *this->explicit_solution, dummy);
298  fe_cache.cache_local_solution_vector("solution", *this->solution, alpha);
299  fe_cache.cache_local_solution_vector("solution_dot", *this->solution_dot, alpha);
300  this->fix_solution_dot_derivative(fe_cache, alpha);
301 }
302 
303 
304 template <int dim, int spacedim, typename LAC>
305 template<typename Number>
306 void
307 BaseInterface<dim,spacedim,LAC>::reinit(const Number &,
309  const unsigned int face_no,
310  FEValuesCache<dim,spacedim> &fe_cache) const
311 {
312  double dummy=0;
313  Number alpha = this->alpha;
314  fe_cache.reinit(cell, face_no);
315  fe_cache.cache_local_solution_vector("explicit_solution", *this->explicit_solution, dummy);
316  fe_cache.cache_local_solution_vector("solution", *this->solution, alpha);
317  fe_cache.cache_local_solution_vector("solution_dot", *this->solution_dot, alpha);
318  this->fix_solution_dot_derivative(fe_cache, alpha);
319 }
320 
321 #endif
ActiveSelector::active_cell_iterator active_cell_iterator
UpdateFlags
void reinit(const unsigned int n_blocks, const size_type block_size=0, const bool omit_zeroing_entries=false)
Definition: copy_data.h:18
Definition: copy_data.h:20