ASPECT
interface.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2022 by the authors of the ASPECT code.
3 
4  This file is part of ASPECT.
5 
6  ASPECT is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2, or (at your option)
9  any later version.
10 
11  ASPECT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with ASPECT; see the file LICENSE. If not see
18  <http://www.gnu.org/licenses/>.
19 */
20 
21 
22 #ifndef _aspect_mesh_deformation_interface_h
23 #define _aspect_mesh_deformation_interface_h
24 
25 #include <aspect/plugins.h>
27 #include <aspect/global.h>
28 
29 #include <deal.II/fe/fe_system.h>
30 #include <deal.II/dofs/dof_handler.h>
31 #include <deal.II/lac/affine_constraints.h>
32 #include <deal.II/base/index_set.h>
33 #include <deal.II/base/mg_level_object.h>
34 #include <deal.II/lac/la_parallel_vector.h>
35 #include <deal.II/multigrid/mg_constrained_dofs.h>
36 #include <deal.II/multigrid/mg_transfer_matrix_free.h>
37 #include <deal.II/multigrid/mg_transfer_global_coarsening.templates.h>
39 
40 
41 namespace aspect
42 {
43  using namespace dealii;
44 
45  namespace Assemblers
46  {
53  template <int dim>
55  public SimulatorAccess<dim>
56  {
57  public:
58  ApplyStabilization(const double stabilization_theta);
59 
60  void
63 
64  private:
70  const double free_surface_theta;
71  };
72  }
73 
74  template <int dim> class Simulator;
75 
80  namespace MeshDeformation
81  {
89  template<int dim>
90  class Interface
91  {
92  public:
97  virtual ~Interface() = default;
98 
106  virtual void initialize ();
107 
116  virtual void update();
117 
118 
122  virtual bool needs_surface_stabilization() const;
123 
124 
132  virtual
133  Tensor<1,dim>
134  compute_initial_deformation_on_boundary(const types::boundary_id boundary_indicator,
135  const Point<dim> &position) const;
136 
144  virtual
145  void
146  compute_velocity_constraints_on_boundary(const DoFHandler<dim> &mesh_deformation_dof_handler,
147  AffineConstraints<double> &mesh_velocity_constraints,
148  const std::set<types::boundary_id> &boundary_id) const;
149 
156  static
157  void
158  declare_parameters (ParameterHandler &prm);
159 
166  virtual
167  void
168  parse_parameters (ParameterHandler &prm);
169  };
170 
171 
172 
178  template<int dim>
179  class MeshDeformationHandler: public SimulatorAccess<dim>
180  {
181  public:
189 
193  ~MeshDeformationHandler() override;
194 
200  void initialize();
201 
206  void set_assemblers(const SimulatorAccess<dim> &simulator_access,
207  aspect::Assemblers::Manager<dim> &assemblers) const;
208 
213  void update();
214 
222  void execute();
223 
228  void setup_dofs();
229 
233  static
234  void declare_parameters (ParameterHandler &prm);
235 
239  void parse_parameters (ParameterHandler &prm);
240 
258  static
259  void
260  register_mesh_deformation
261  (const std::string &name,
262  const std::string &description,
263  void (*declare_parameters_function) (ParameterHandler &),
264  std::unique_ptr<Interface<dim>> (*factory_function) ());
265 
270  const std::map<types::boundary_id, std::vector<std::string>> &
271  get_active_mesh_deformation_names () const;
272 
277  const std::map<types::boundary_id,std::vector<std::unique_ptr<Interface<dim>>>> &
278  get_active_mesh_deformation_models () const;
279 
284  const std::set<types::boundary_id> &
285  get_active_mesh_deformation_boundary_indicators () const;
286 
291  const std::set<types::boundary_id> &
292  get_boundary_indicators_requiring_stabilization () const;
293 
299  const std::set<types::boundary_id> &
300  get_free_surface_boundary_indicators () const;
301 
305  double get_free_surface_theta () const;
306 
321  const LinearAlgebra::Vector &
322  get_initial_topography () const;
323 
328  const LinearAlgebra::Vector &
329  get_mesh_displacements () const;
330 
334  const DoFHandler<dim> &
335  get_mesh_deformation_dof_handler () const;
336 
346  template <typename MeshDeformationType,
347  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,MeshDeformationType>::value>>
348  bool
349  has_matching_mesh_deformation_object () const;
350 
362  template <typename MeshDeformationType,
363  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,MeshDeformationType>::value>>
364  const MeshDeformationType &
365  get_matching_mesh_deformation_object () const;
366 
367 
373  const Mapping<dim> &
374  get_level_mapping(const unsigned int level) const;
375 
385  static
386  void
387  write_plugin_graph (std::ostream &output_stream);
388 
392  DeclException1 (ExcMeshDeformationNameNotFound,
393  std::string,
394  << "Could not find entry <"
395  << arg1
396  << "> among the names of registered mesh deformation objects.");
397 
398  private:
406  void make_initial_constraints ();
407 
420  void make_constraints ();
421 
426  void compute_mesh_displacements ();
427 
432  void compute_mesh_displacements_gmg ();
433 
449  void set_initial_topography ();
450 
454  void interpolate_mesh_velocity ();
455 
459  void update_multilevel_deformation ();
460 
466 
471  const FESystem<dim> mesh_deformation_fe;
472 
477 
484 
492 
497 
507 
517 
522 
527 
532  AffineConstraints<double> mesh_velocity_constraints;
533 
538  AffineConstraints<double> mesh_vertex_constraints;
539 
544  std::map<types::boundary_id,std::vector<std::unique_ptr<Interface<dim>>>> mesh_deformation_objects;
545 
550  std::map<types::boundary_id, std::vector<std::string>> mesh_deformation_object_names;
551 
558 
564 
571  std::set<types::boundary_id> zero_mesh_deformation_boundary_indicators;
572 
578  std::set<types::boundary_id> free_surface_boundary_indicators;
579 
584  std::set<types::boundary_id> boundary_indicators_requiring_stabilization;
585 
587 
594 
598  MGLevelObject<std::unique_ptr<Mapping<dim>>> level_mappings;
599 
603  MGLevelObject<::LinearAlgebra::distributed::Vector<double>> level_displacements;
604 
609 
613  MGConstrainedDoFs mg_constrained_dofs;
614 
615  friend class Simulator<dim>;
616  friend class SimulatorAccess<dim>;
617  };
618 
619 
620 
621  template <int dim>
622  template <typename MeshDeformationType, typename>
623  inline
624  bool
626  {
627  for (const auto &object_iterator : mesh_deformation_objects)
628  for (const auto &p : object_iterator.second)
629  if (Plugins::plugin_type_matches<MeshDeformationType>(*p))
630  return true;
631 
632  return false;
633  }
634 
635 
636 
637  template <int dim>
638  template <typename MeshDeformationType, typename>
639  inline
640  const MeshDeformationType &
642  {
643  AssertThrow(has_matching_mesh_deformation_object<MeshDeformationType> (),
644  ExcMessage("You asked MeshDeformation::MeshDeformationHandler::get_matching_mesh_deformation_object() for a "
645  "mesh deformation object of type <" + boost::core::demangle(typeid(MeshDeformationType).name()) + "> "
646  "that could not be found in the current model. Activate this "
647  "mesh deformation in the input file."));
648 
649  for (const auto &object_iterator : mesh_deformation_objects)
650  for (const auto &p : object_iterator.second)
651  if (Plugins::plugin_type_matches<MeshDeformationType>(*p))
652  return Plugins::get_plugin_as_type<MeshDeformationType>(*p);
653 
654  typename std::vector<std::unique_ptr<Interface<dim>>>::const_iterator mesh_def;
655  // We will never get here, because we had the Assert above. Just to avoid warnings.
656  return Plugins::get_plugin_as_type<MeshDeformationType>(*(*mesh_def));
657 
658  }
659 
660 
667  template <int dim>
668  std::string
670 
671 
672 
680 #define ASPECT_REGISTER_MESH_DEFORMATION_MODEL(classname,name,description) \
681  template class classname<2>; \
682  template class classname<3>; \
683  namespace ASPECT_REGISTER_MESH_DEFORMATION_MODEL_ ## classname \
684  { \
685  aspect::internal::Plugins::RegisterHelper<aspect::MeshDeformation::Interface<2>,classname<2>> \
686  dummy_ ## classname ## _2d (&aspect::MeshDeformation::MeshDeformationHandler<2>::register_mesh_deformation, \
687  name, description); \
688  aspect::internal::Plugins::RegisterHelper<aspect::MeshDeformation::Interface<3>,classname<3>> \
689  dummy_ ## classname ## _3d (&aspect::MeshDeformation::MeshDeformationHandler<3>::register_mesh_deformation, \
690  name, description); \
691  }
692  }
693 }
694 
695 #endif
::TrilinosWrappers::MPI::BlockVector BlockVector
Definition: global.h:239
std::set< types::boundary_id > prescribed_mesh_deformation_boundary_indicators
Definition: interface.h:557
MGLevelObject<::LinearAlgebra::distributed::Vector< double > > level_displacements
Definition: interface.h:603
void write_plugin_graph(std::ostream &output_stream)
std::set< types::boundary_id > boundary_indicators_requiring_stabilization
Definition: interface.h:584
::TrilinosWrappers::MPI::Vector Vector
Definition: global.h:233
AffineConstraints< double > mesh_velocity_constraints
Definition: interface.h:532
std::set< types::boundary_id > tangential_mesh_deformation_boundary_indicators
Definition: interface.h:563
AffineConstraints< double > mesh_vertex_constraints
Definition: interface.h:538
MGLevelObject< std::unique_ptr< Mapping< dim > > > level_mappings
Definition: interface.h:598
std::map< types::boundary_id, std::vector< std::string > > mesh_deformation_object_names
Definition: interface.h:550
LinearAlgebra::BlockVector mesh_velocity
Definition: interface.h:483
std::map< types::boundary_id, std::vector< std::unique_ptr< Interface< dim > > > > mesh_deformation_objects
Definition: interface.h:544
MGTransferMF< dim, double > mg_transfer
Definition: interface.h:608
MGTransferMatrixFree< dim, NumberType > MGTransferMF
Definition: compat.h:45
std::string get_valid_model_names_pattern()
void declare_parameters(ParameterHandler &prm)
Definition: compat.h:42
std::set< types::boundary_id > free_surface_boundary_indicators
Definition: interface.h:578
std::set< types::boundary_id > zero_mesh_deformation_boundary_indicators
Definition: interface.h:571
DeclException1(ProbabilityFunctionNegative, Point< dim >,<< "Your probability density function in the particle generator " "returned a negative probability density for the following position: "<< arg1<< ". Please check your function expression.")