ASPECT
interface.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2024 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  {
91  template <int dim>
93  {
94  public:
98  virtual bool needs_surface_stabilization() const;
99 
100 
108  virtual
109  Tensor<1,dim>
110  compute_initial_deformation_on_boundary(const types::boundary_id boundary_indicator,
111  const Point<dim> &position) const;
112 
120  virtual
121  void
122  compute_velocity_constraints_on_boundary(const DoFHandler<dim> &mesh_deformation_dof_handler,
123  AffineConstraints<double> &mesh_velocity_constraints,
124  const std::set<types::boundary_id> &boundary_id) const;
125  };
126 
127 
128 
134  template <int dim>
135  class MeshDeformationHandler: public SimulatorAccess<dim>
136  {
137  public:
145 
149  ~MeshDeformationHandler() override;
150 
156  void initialize();
157 
162  void set_assemblers(const SimulatorAccess<dim> &simulator_access,
163  aspect::Assemblers::Manager<dim> &assemblers) const;
164 
169  void update();
170 
178  void execute();
179 
184  void setup_dofs();
185 
189  static
190  void declare_parameters (ParameterHandler &prm);
191 
195  void parse_parameters (ParameterHandler &prm);
196 
214  static
215  void
216  register_mesh_deformation
217  (const std::string &name,
218  const std::string &description,
219  void (*declare_parameters_function) (ParameterHandler &),
220  std::unique_ptr<Interface<dim>> (*factory_function) ());
221 
226  const std::map<types::boundary_id, std::vector<std::string>> &
227  get_active_mesh_deformation_names () const;
228 
233  const std::map<types::boundary_id,std::vector<std::unique_ptr<Interface<dim>>>> &
234  get_active_mesh_deformation_models () const;
235 
240  const std::set<types::boundary_id> &
241  get_active_mesh_deformation_boundary_indicators () const;
242 
247  const std::set<types::boundary_id> &
248  get_boundary_indicators_requiring_stabilization () const;
249 
255  const std::set<types::boundary_id> &
256  get_free_surface_boundary_indicators () const;
257 
261  double get_free_surface_theta () const;
262 
277  const LinearAlgebra::Vector &
278  get_initial_topography () const;
279 
284  const LinearAlgebra::Vector &
285  get_mesh_displacements () const;
286 
290  const DoFHandler<dim> &
291  get_mesh_deformation_dof_handler () const;
292 
302  template <typename MeshDeformationType,
303  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,MeshDeformationType>::value>>
304  bool
305  has_matching_mesh_deformation_object () const;
306 
318  template <typename MeshDeformationType,
319  typename = typename std::enable_if_t<std::is_base_of<Interface<dim>,MeshDeformationType>::value>>
320  const MeshDeformationType &
321  get_matching_mesh_deformation_object () const;
322 
323 
329  const Mapping<dim> &
330  get_level_mapping(const unsigned int level) const;
331 
341  static
342  void
343  write_plugin_graph (std::ostream &output_stream);
344 
348  DeclException1 (ExcMeshDeformationNameNotFound,
349  std::string,
350  << "Could not find entry <"
351  << arg1
352  << "> among the names of registered mesh deformation objects.");
353 
354  private:
362  void make_initial_constraints ();
363 
376  void make_constraints ();
377 
382  void compute_mesh_displacements ();
383 
388  void compute_mesh_displacements_gmg ();
389 
405  void set_initial_topography ();
406 
410  void interpolate_mesh_velocity ();
411 
415  void update_multilevel_deformation ();
416 
422 
427  const FESystem<dim> mesh_deformation_fe;
428 
433 
440 
448 
453 
463 
473 
478 
483 
488  AffineConstraints<double> mesh_velocity_constraints;
489 
494  AffineConstraints<double> mesh_vertex_constraints;
495 
500  std::map<types::boundary_id,std::vector<std::unique_ptr<Interface<dim>>>> mesh_deformation_objects;
501 
506  std::map<types::boundary_id, std::vector<std::string>> mesh_deformation_object_names;
507 
514 
520 
527  std::set<types::boundary_id> zero_mesh_deformation_boundary_indicators;
528 
534  std::set<types::boundary_id> free_surface_boundary_indicators;
535 
540  std::set<types::boundary_id> boundary_indicators_requiring_stabilization;
541 
543 
550 
554  MGLevelObject<std::unique_ptr<Mapping<dim>>> level_mappings;
555 
559  MGLevelObject<::LinearAlgebra::distributed::Vector<double>> level_displacements;
560 
565 
569  MGConstrainedDoFs mg_constrained_dofs;
570 
571  friend class Simulator<dim>;
572  friend class SimulatorAccess<dim>;
573  };
574 
575 
576 
577  template <int dim>
578  template <typename MeshDeformationType, typename>
579  inline
580  bool
582  {
583  for (const auto &object_iterator : mesh_deformation_objects)
584  for (const auto &p : object_iterator.second)
585  if (Plugins::plugin_type_matches<MeshDeformationType>(*p))
586  return true;
587 
588  return false;
589  }
590 
591 
592 
593  template <int dim>
594  template <typename MeshDeformationType, typename>
595  inline
596  const MeshDeformationType &
598  {
599  AssertThrow(has_matching_mesh_deformation_object<MeshDeformationType> (),
600  ExcMessage("You asked MeshDeformation::MeshDeformationHandler::get_matching_mesh_deformation_object() for a "
601  "mesh deformation object of type <" + boost::core::demangle(typeid(MeshDeformationType).name()) + "> "
602  "that could not be found in the current model. Activate this "
603  "mesh deformation in the input file."));
604 
605  for (const auto &object_iterator : mesh_deformation_objects)
606  for (const auto &p : object_iterator.second)
607  if (Plugins::plugin_type_matches<MeshDeformationType>(*p))
608  return Plugins::get_plugin_as_type<MeshDeformationType>(*p);
609 
610  // We will never get here, because we had the Assert above. Just to avoid warnings.
611  typename std::vector<std::unique_ptr<Interface<dim>>>::const_iterator mesh_def;
612  return Plugins::get_plugin_as_type<MeshDeformationType>(*(*mesh_def));
613 
614  }
615 
616 
623  template <int dim>
624  std::string
626 
627 
628 
636 #define ASPECT_REGISTER_MESH_DEFORMATION_MODEL(classname,name,description) \
637  template class classname<2>; \
638  template class classname<3>; \
639  namespace ASPECT_REGISTER_MESH_DEFORMATION_MODEL_ ## classname \
640  { \
641  aspect::internal::Plugins::RegisterHelper<aspect::MeshDeformation::Interface<2>,classname<2>> \
642  dummy_ ## classname ## _2d (&aspect::MeshDeformation::MeshDeformationHandler<2>::register_mesh_deformation, \
643  name, description); \
644  aspect::internal::Plugins::RegisterHelper<aspect::MeshDeformation::Interface<3>,classname<3>> \
645  dummy_ ## classname ## _3d (&aspect::MeshDeformation::MeshDeformationHandler<3>::register_mesh_deformation, \
646  name, description); \
647  }
648  }
649 }
650 
651 #endif
::TrilinosWrappers::MPI::BlockVector BlockVector
Definition: global.h:261
std::set< types::boundary_id > prescribed_mesh_deformation_boundary_indicators
Definition: interface.h:513
MGLevelObject<::LinearAlgebra::distributed::Vector< double > > level_displacements
Definition: interface.h:559
void write_plugin_graph(std::ostream &output_stream)
std::set< types::boundary_id > boundary_indicators_requiring_stabilization
Definition: interface.h:540
::TrilinosWrappers::MPI::Vector Vector
Definition: global.h:255
AffineConstraints< double > mesh_velocity_constraints
Definition: interface.h:488
std::set< types::boundary_id > tangential_mesh_deformation_boundary_indicators
Definition: interface.h:519
AffineConstraints< double > mesh_vertex_constraints
Definition: interface.h:494
MGLevelObject< std::unique_ptr< Mapping< dim > > > level_mappings
Definition: interface.h:554
std::map< types::boundary_id, std::vector< std::string > > mesh_deformation_object_names
Definition: interface.h:506
LinearAlgebra::BlockVector mesh_velocity
Definition: interface.h:439
std::map< types::boundary_id, std::vector< std::unique_ptr< Interface< dim > > > > mesh_deformation_objects
Definition: interface.h:500
MGTransferMF< dim, double > mg_transfer
Definition: interface.h:564
MGTransferMatrixFree< dim, NumberType > MGTransferMF
Definition: compat.h:45
std::string get_valid_model_names_pattern()
Definition: compat.h:59
void declare_parameters(ParameterHandler &prm)
Definition: compat.h:42
std::set< types::boundary_id > free_surface_boundary_indicators
Definition: interface.h:534
std::set< types::boundary_id > zero_mesh_deformation_boundary_indicators
Definition: interface.h:527
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.")