Fluid structure interaction suite
linear_problem.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2022 by Luca Heltai
4 //
5 // This file is part of the FSI-suite platform, based on the deal.II library.
6 //
7 // The FSI-suite platform is free software; you can use it, redistribute it,
8 // and/or modify it under the terms of the GNU Lesser General Public License as
9 // published by the Free Software Foundation; either version 3.0 of the License,
10 // or (at your option) any later version. The full text of the license can be
11 // found in the file LICENSE at the top level of the FSI-suite platform
12 // distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 // Make sure we don't redefine things
17 #ifndef pdes_linear_problem_h
18 #define pdes_linear_problem_h
19 
22 #include <deal.II/base/function.h>
26 #include <deal.II/base/timer.h>
27 
31 
33 #include <deal.II/dofs/dof_tools.h>
34 
35 #include <deal.II/fe/fe_q.h>
36 #include <deal.II/fe/fe_values.h>
39 
41 #include <deal.II/grid/tria.h>
42 
48 #include <deal.II/lac/solver_cg.h>
50 #include <deal.II/lac/vector.h>
51 
54 
58 
60 
61 #include <boost/signals2.hpp>
62 
63 #include <fstream>
64 #include <iostream>
65 
66 #include "lac.h"
67 #include "parsed_lac/amg.h"
70 #include "parsed_tools/constants.h"
72 #include "parsed_tools/data_out.h"
74 #include "parsed_tools/function.h"
77 
78 namespace PDEs
79 {
80  using namespace dealii;
81 
85  enum class EvolutionType
86  {
87  steady_state = 1 << 0, //< Steady state problem
88  quasi_static = 1 << 1, //< Quasi static problem
89  transient = 1 << 2, //< Transient problem
90  };
91 
95  template <int dim, int spacedim = dim, class LacType = LAC::LAdealii>
97  {
98  public:
102  LinearProblem(const std::string &component_names = "u",
103  const std::string &problem_name = "");
104 
108  virtual ~LinearProblem() = default;
109 
113  boost::signals2::signal<void()> check_consistency_call_back;
114 
121  virtual void
122  run();
123 
127  void
128  run_steady_state();
129 
133  void
134  run_quasi_static();
135 
139  void
140  run_transient();
141 
146 
150  virtual void
151  setup_transient(ARKode &arkode);
152 
156  static constexpr bool lac_is_dealii =
157  std::is_same<LAC::LAdealii, LacType>::value;
158 
162  static constexpr bool lac_is_petsc =
163  std::is_same<LAC::LAPETSc, LacType>::value;
164 
168  static constexpr bool lac_is_trilinos =
169  std::is_same<LAC::LATrilinos, LacType>::value;
170 
176  using Triangulation = typename std::conditional<
177  dim == 1,
178  dealii::parallel::shared::Triangulation<dim, spacedim>,
179  dealii::parallel::distributed::Triangulation<dim, spacedim>>::type;
180 
185 
190 
194  using BlockVectorType = typename LacType::BlockVector;
195 
199  using VectorType = typename BlockVectorType::BlockType;
200 
204  using BlockMatrixType = typename LacType::BlockSparseMatrix;
205 
216  virtual void
217  assemble_system_one_cell(
219  ScratchData &scratch,
220  CopyData &copy);
221 
228  virtual void
229  copy_one_cell(const CopyData &copy);
230 
234  virtual void
235  solve();
236 
241  virtual void
242  estimate(Vector<float> &error_per_cell) const;
243 
248  void
249  mark(const Vector<float> &error_per_cell);
250 
254  void
255  refine();
256 
261  virtual void
262  setup_system();
263 
269  virtual void
270  custom_estimator(dealii::Vector<float> &error_per_cell) const;
271 
275  boost::signals2::signal<void()> add_constraints_call_back;
276 
280  boost::signals2::signal<void()> setup_system_call_back;
281 
285  boost::signals2::signal<void()> output_results_call_back;
286 
290  virtual void
291  assemble_system();
292 
296  boost::signals2::signal<void()> assemble_system_call_back;
297 
304  virtual void
305  output_results(const unsigned cycle) const;
306 
310  virtual void
311  print_system_info() const;
312 
317  boost::signals2::signal<void(ParsedTools::DataOut<dim, spacedim> &)>
319 
323  boost::signals2::signal<void(const double &time,
324  const double &time_step,
325  const unsigned int &time_step_number)>
327 
328 
332  const std::string component_names;
333 
337  const unsigned int n_components;
338 
342  const std::string problem_name;
343 
347  const std::string section_name;
348 
353 
357  const unsigned int mpi_rank;
358 
362  const unsigned int mpi_size;
363 
367  int number_of_threads = 1;
368 
372  unsigned int verbosity_level = 4;
373 
377  dealii::ConditionalOStream pcout;
378 
383 
388 
410 
444 
449 
450 
471 
477  std::unique_ptr<Mapping<dim, spacedim>> mapping;
478 
483 
488 
489 
494 
499 
503  std::vector<types::global_dof_index> dofs_per_block;
504 
508  std::vector<IndexSet> locally_owned_dofs;
509 
513  std::vector<IndexSet> locally_relevant_dofs;
514 
518  typename LacType::BlockSparsityPattern sparsity;
519 
523  typename LacType::BlockSparseMatrix matrix;
524 
528  typename LacType::BlockSparseMatrix mass_matrix;
529 
534  typename LacType::BlockVector locally_relevant_solution;
535 
539  typename LacType::BlockVector solution;
540 
545  typename LacType::BlockVector rhs;
546 
554 
559 
563  typename LacType::AMG preconditioner;
564 
569 
573  typename LacType::AMG mass_preconditioner;
574 
595 
616 
621 
684 
685 
725 
751 
755  double start_time = 0.0;
756 
760  double end_time = 1.0;
761 
765  double desired_start_step_size = .0625;
766 
770  unsigned int output_frequency = 1;
771 
778 
783  boost::signals2::signal<void(ARKode &)> setup_arkode_call_back;
784  };
785 } // namespace PDEs
786 #endif
Construct a LinearProblem.
EvolutionType evolution_type
Describe the type of time evolution of the problem.
boost::signals2::signal< void()> check_consistency_call_back
Check consistency of the problem.
boost::signals2::signal< void()> add_constraints_call_back
A signal that is called at the end of setup_system()
boost::signals2::signal< void(const double &time, const double &time_step, const unsigned int &time_step_number)> advance_time_call_back
Connect to this signal to receive time information.
std::unique_ptr< Mapping< dim, spacedim > > mapping
The Mapping between reference and real elements.
Vector< float > error_per_cell
Storage for local error estimator.
ParsedTools::FiniteElement< dim, spacedim > finite_element
A wrapper around deal.II FiniteElement classes.
LacType::BlockVector solution
Solution vector.
ParsedLAC::InverseOperator inverse_operator
Inverse operator.
Triangulation triangulation
The problem triangulation.
LacType::BlockSparseMatrix mass_matrix
System matrix.
boost::signals2::signal< void()> assemble_system_call_back
A signal that is called at the end of assemble_system()
boost::signals2::signal< void(ParsedTools::DataOut< dim, spacedim > &)> add_data_vector
Connect to this signal to add data additional vectors to the output system.
boost::signals2::signal< void(ARKode &)> setup_arkode_call_back
Signal that is triggered after creating the arkode object.
ParsedTools::ConvergenceTable error_table
This is a wrapper around the ParsedConvergenceTable class, that allows you to specify what error to c...
const std::string component_names
Comma seperated names of components.
TimerOutput timer
Timing information.
ParsedTools::Function< spacedim > exact_solution
The actual function to use as a exact solution when computing the errors.
ParsedTools::GridGenerator< dim, spacedim > grid_generator
A wrapper around GridIn, GridOut, and GridGenerator namespace.
LacType::BlockSparseMatrix matrix
System matrix.
const std::string problem_name
Name of the problem to solve.
ConditionalOStream pcout
Output stream, only active on process 0.
ParsedTools::GridRefinement grid_refinement
Grid refinement and error estimation.
boost::signals2::signal< void()> setup_system_call_back
A signal that is called at the end of setup_system()
boost::signals2::signal< void()> output_results_call_back
A signal that is called at the end of output_results()
ParsedTools::Function< spacedim > initial_value
Only used for transient problems.
LacType::AMG mass_preconditioner
Preconditioner for the mass matrix.
const unsigned int n_components
Number of components.
ParsedLAC::InverseOperator mass_inverse_operator
Inverse operator for the mass matrix.
std::vector< IndexSet > locally_owned_dofs
All degrees of freedom owned by this MPI process.
const unsigned int mpi_rank
The mpi rank of this process.
typename BlockVectorType::BlockType VectorType
Vector type.
typename LacType::BlockVector BlockVectorType
Block vector type.
LacType::BlockSparsityPattern sparsity
System sparsity pattern.
ParsedTools::DataOut< dim, spacedim > data_out
Wrapper around the DataOut class.
ParsedTools::BoundaryConditions< spacedim > boundary_conditions
Boundary conditions used in this class.
virtual ~LinearProblem()=default
Virtual destructor.
std::vector< IndexSet > locally_relevant_dofs
All degrees of freedom needed for output and error estimation.
LacType::AMG preconditioner
Preconditioner.
LacType::BlockVector rhs
The system right hand side.
AffineConstraints< double > constraints
Hanging nodes and essential boundary conditions.
typename LacType::BlockSparseMatrix BlockMatrixType
Block matrix type.
Quadrature< dim > cell_quadrature
A quadrature used for cell integration.
const unsigned int mpi_size
The number of mpi processes.
std::vector< types::global_dof_index > dofs_per_block
Dofs per block.
MPI_Comm mpi_communicator
Global mpi communicator.
LacType::BlockVector locally_relevant_solution
A read only copy of the solution vector used for output and error estimation.
Quadrature< dim - 1 > face_quadrature
A quadrature used for face integration.
ParsedTools::Function< spacedim > forcing_term
The actual function to use as a forcing term.
typename SUNDIALS::ARKode< typename LacType::BlockVector > ARKode
SUNDIALS time integrator.
DoFHandler< dim, spacedim > dof_handler
Handler of degrees of freedom.
const std::string section_name
Name of the section to use within the parameter file.
ParsedTools::Proxy< typename SUNDIALS::ARKode< typename LacType::BlockVector >::AdditionalData > ark_ode_data
Configuration used to setup transient simulations.
A factory that can generate inverse operators according to parameter files.
A wrapper for boundary conditions.
Parsed FiniteElement.
A wrapper for the FunctionParser class.
Definition: function.h:30
GridGenerator class.
A wrapper for refinement strategies.
A proxy ParameterAcceptor wrapper for classes that have a member function add_parameters,...
Definition: proxy.h:33
We collect in this namespace all PDEs that are relevant to Fluid Structure Interaction Problems.
EvolutionType
Describe the dependencies of the linear problem w.r.t.
Type type(const std::string &component_name, const std::string &selected_component)
Return the component type for the given selected component.
Definition: components.cc:186
void run(char **argv, const std::string &input_parameter_file, const std::string &output_parameter_file)
Setup parameters from the command line, and call the Class::run() method.
Definition: runner.h:219