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>
38 
39 
40 namespace aspect
41 {
42  using namespace dealii;
43 
44  namespace Assemblers
45  {
52  template <int dim>
54  public SimulatorAccess<dim>
55  {
56  public:
57  ApplyStabilization(const double stabilization_theta);
58 
59  void
62 
63  private:
69  const double free_surface_theta;
70  };
71  }
72 
73  template <int dim> class Simulator;
74 
79  namespace MeshDeformation
80  {
88  template<int dim>
89  class Interface
90  {
91  public:
96  virtual ~Interface() = default;
97 
105  virtual void initialize ();
106 
115  virtual void update();
116 
117 
121  virtual bool needs_surface_stabilization() const;
122 
123 
131  virtual
132  Tensor<1,dim>
133  compute_initial_deformation_on_boundary(const types::boundary_id boundary_indicator,
134  const Point<dim> &position) const;
135 
143  virtual
144  void
145  compute_velocity_constraints_on_boundary(const DoFHandler<dim> &mesh_deformation_dof_handler,
146  AffineConstraints<double> &mesh_velocity_constraints,
147  const std::set<types::boundary_id> &boundary_id) const;
148 
155  static
156  void
157  declare_parameters (ParameterHandler &prm);
158 
165  virtual
166  void
167  parse_parameters (ParameterHandler &prm);
168  };
169 
170 
171 
177  template<int dim>
178  class MeshDeformationHandler: public SimulatorAccess<dim>
179  {
180  public:
188 
192  ~MeshDeformationHandler() override;
193 
199  void initialize();
200 
205  void set_assemblers(const SimulatorAccess<dim> &simulator_access,
206  aspect::Assemblers::Manager<dim> &assemblers) const;
207 
212  void update();
213 
221  void execute();
222 
227  void setup_dofs();
228 
232  static
233  void declare_parameters (ParameterHandler &prm);
234 
238  void parse_parameters (ParameterHandler &prm);
239 
257  static
258  void
259  register_mesh_deformation
260  (const std::string &name,
261  const std::string &description,
262  void (*declare_parameters_function) (ParameterHandler &),
263  std::unique_ptr<Interface<dim>> (*factory_function) ());
264 
269  const std::map<types::boundary_id, std::vector<std::string>> &
270  get_active_mesh_deformation_names () const;
271 
276  const std::map<types::boundary_id,std::vector<std::unique_ptr<Interface<dim>>>> &
277  get_active_mesh_deformation_models () const;
278 
283  const std::set<types::boundary_id> &
284  get_active_mesh_deformation_boundary_indicators () const;
285 
290  const std::set<types::boundary_id> &
291  get_boundary_indicators_requiring_stabilization () const;
292 
298  const std::set<types::boundary_id> &
299  get_free_surface_boundary_indicators () const;
300 
304  double get_free_surface_theta () const;
305 
320  const LinearAlgebra::Vector &
321  get_initial_topography () const;
322 
327  const LinearAlgebra::Vector &
328  get_mesh_displacements () const;
329 
336  template <typename MeshDeformationType>
337  bool
338  has_matching_mesh_deformation_object () const;
339 
348  template <typename MeshDeformationType>
349  const MeshDeformationType &
350  get_matching_mesh_deformation_object () const;
351 
352 
358  const Mapping<dim> &
359  get_level_mapping(const unsigned int level) const;
360 
370  static
371  void
372  write_plugin_graph (std::ostream &output_stream);
373 
377  DeclException1 (ExcMeshDeformationNameNotFound,
378  std::string,
379  << "Could not find entry <"
380  << arg1
381  << "> among the names of registered mesh deformation objects.");
382 
383  private:
391  void make_initial_constraints ();
392 
405  void make_constraints ();
406 
411  void compute_mesh_displacements ();
412 
417  void compute_mesh_displacements_gmg ();
418 
434  void set_initial_topography ();
435 
439  void interpolate_mesh_velocity ();
440 
444  void update_multilevel_deformation ();
445 
451 
456  const FESystem<dim> mesh_deformation_fe;
457 
462 
469 
477 
482 
492 
502 
507 
512 
517  AffineConstraints<double> mesh_velocity_constraints;
518 
523  AffineConstraints<double> mesh_vertex_constraints;
524 
529  std::map<types::boundary_id,std::vector<std::unique_ptr<Interface<dim>>>> mesh_deformation_objects;
530 
535  std::map<types::boundary_id, std::vector<std::string>> mesh_deformation_object_names;
536 
543 
549 
556  std::set<types::boundary_id> zero_mesh_deformation_boundary_indicators;
557 
563  std::set<types::boundary_id> free_surface_boundary_indicators;
564 
569  std::set<types::boundary_id> boundary_indicators_requiring_stabilization;
570 
572 
579 
583  MGLevelObject<std::unique_ptr<Mapping<dim>>> level_mappings;
584 
588  MGLevelObject<::LinearAlgebra::distributed::Vector<double>> level_displacements;
589 
593  MGTransferMatrixFree<dim, double> mg_transfer;
594 
595 
599  MGConstrainedDoFs mg_constrained_dofs;
600 
601  friend class Simulator<dim>;
602  friend class SimulatorAccess<dim>;
603  };
604 
605 
606 
607  template <int dim>
608  template <typename MeshDeformationType>
609  inline
610  bool
612  {
613  for (const auto &object_iterator : mesh_deformation_objects)
614  for (const auto &p : object_iterator.second)
615  if (Plugins::plugin_type_matches<MeshDeformationType>(*p))
616  return true;
617 
618  return false;
619  }
620 
621 
622 
623  template <int dim>
624  template <typename MeshDeformationType>
625  inline
626  const MeshDeformationType &
628  {
629  AssertThrow(has_matching_mesh_deformation_object<MeshDeformationType> (),
630  ExcMessage("You asked MeshDeformation::MeshDeformationHandler::get_matching_mesh_deformation_object() for a "
631  "mesh deformation object of type <" + boost::core::demangle(typeid(MeshDeformationType).name()) + "> "
632  "that could not be found in the current model. Activate this "
633  "mesh deformation in the input file."));
634 
635  for (const auto &object_iterator : mesh_deformation_objects)
636  for (const auto &p : object_iterator.second)
637  if (Plugins::plugin_type_matches<MeshDeformationType>(*p))
638  return Plugins::get_plugin_as_type<MeshDeformationType>(*p);
639 
640  typename std::vector<std::unique_ptr<Interface<dim>>>::const_iterator mesh_def;
641  // We will never get here, because we had the Assert above. Just to avoid warnings.
642  return Plugins::get_plugin_as_type<MeshDeformationType>(*(*mesh_def));
643 
644  }
645 
646 
653  template <int dim>
654  std::string
656 
657 
658 
666 #define ASPECT_REGISTER_MESH_DEFORMATION_MODEL(classname,name,description) \
667  template class classname<2>; \
668  template class classname<3>; \
669  namespace ASPECT_REGISTER_MESH_DEFORMATION_MODEL_ ## classname \
670  { \
671  aspect::internal::Plugins::RegisterHelper<aspect::MeshDeformation::Interface<2>,classname<2>> \
672  dummy_ ## classname ## _2d (&aspect::MeshDeformation::MeshDeformationHandler<2>::register_mesh_deformation, \
673  name, description); \
674  aspect::internal::Plugins::RegisterHelper<aspect::MeshDeformation::Interface<3>,classname<3>> \
675  dummy_ ## classname ## _3d (&aspect::MeshDeformation::MeshDeformationHandler<3>::register_mesh_deformation, \
676  name, description); \
677  }
678  }
679 }
680 
681 #endif
::TrilinosWrappers::MPI::BlockVector BlockVector
Definition: global.h:229
std::set< types::boundary_id > prescribed_mesh_deformation_boundary_indicators
Definition: interface.h:542
MGLevelObject<::LinearAlgebra::distributed::Vector< double > > level_displacements
Definition: interface.h:588
void write_plugin_graph(std::ostream &output_stream)
std::set< types::boundary_id > boundary_indicators_requiring_stabilization
Definition: interface.h:569
::TrilinosWrappers::MPI::Vector Vector
Definition: global.h:223
AffineConstraints< double > mesh_velocity_constraints
Definition: interface.h:517
std::set< types::boundary_id > tangential_mesh_deformation_boundary_indicators
Definition: interface.h:548
AffineConstraints< double > mesh_vertex_constraints
Definition: interface.h:523
MGLevelObject< std::unique_ptr< Mapping< dim > > > level_mappings
Definition: interface.h:583
MGTransferMatrixFree< dim, double > mg_transfer
Definition: interface.h:593
std::map< types::boundary_id, std::vector< std::string > > mesh_deformation_object_names
Definition: interface.h:535
LinearAlgebra::BlockVector mesh_velocity
Definition: interface.h:468
std::map< types::boundary_id, std::vector< std::unique_ptr< Interface< dim > > > > mesh_deformation_objects
Definition: interface.h:529
std::string get_valid_model_names_pattern()
void declare_parameters(ParameterHandler &prm)
std::set< types::boundary_id > free_surface_boundary_indicators
Definition: interface.h:563
std::set< types::boundary_id > zero_mesh_deformation_boundary_indicators
Definition: interface.h:556
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.")