ASPECT
interface.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2019 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 
28 #include <aspect/global.h>
29 
30 #include <deal.II/fe/fe_system.h>
32 
33 #if DEAL_II_VERSION_GTE(9,1,0)
35 #else
37 #endif
38 
39 #include <deal.II/base/index_set.h>
40 
41 
42 namespace aspect
43 {
44  using namespace dealii;
45 
46  template <int dim> class Simulator;
47 
52  namespace MeshDeformation
53  {
61  template<int dim>
62  class Interface
63  {
64  public:
69  virtual ~Interface() = default;
70 
78  virtual void initialize ();
79 
88  virtual void update();
89 
97  virtual
99  compute_initial_deformation_on_boundary(const types::boundary_id boundary_indicator,
100  const Point<dim> &position) const;
101 
109  virtual
110  void
111  compute_velocity_constraints_on_boundary(const DoFHandler<dim> &mesh_deformation_dof_handler,
112  AffineConstraints<double> &mesh_velocity_constraints,
113  const std::set<types::boundary_id> &boundary_id) const;
114 
121  static
122  void
124 
131  virtual
132  void
133  parse_parameters (ParameterHandler &prm);
134  };
135 
136 
137 
143  template<int dim>
144  class MeshDeformationHandler: public SimulatorAccess<dim>
145  {
146  public:
154 
158  ~MeshDeformationHandler() override;
159 
165  void initialize();
166 
171  void update();
172 
180  void execute();
181 
186  void setup_dofs();
187 
191  static
193 
197  void parse_parameters (ParameterHandler &prm);
198 
216  static
217  void
218  register_mesh_deformation
219  (const std::string &name,
220  const std::string &description,
221  void (*declare_parameters_function) (ParameterHandler &),
222  Interface<dim> *(*factory_function) ());
223 
228  const std::map<types::boundary_id, std::vector<std::string> > &
229  get_active_mesh_deformation_names () const;
230 
235  const std::map<types::boundary_id,std::vector<std::unique_ptr<Interface<dim> > > > &
236  get_active_mesh_deformation_models () const;
237 
242  const std::set<types::boundary_id> &
243  get_active_mesh_deformation_boundary_indicators () const;
244 
250  const std::set<types::boundary_id> &
251  get_free_surface_boundary_indicators () const;
252 
267  const LinearAlgebra::Vector &
268  get_initial_topography () const;
269 
274  const LinearAlgebra::Vector &
275  get_mesh_displacements () const;
276 
283  template <typename MeshDeformationType>
284  bool
285  has_matching_mesh_deformation_object () const;
286 
295  template <typename MeshDeformationType>
296  const MeshDeformationType &
297  get_matching_mesh_deformation_object () const;
298 
308  static
309  void
310  write_plugin_graph (std::ostream &output_stream);
311 
315  DeclException1 (ExcMeshDeformationNameNotFound,
316  std::string,
317  << "Could not find entry <"
318  << arg1
319  << "> among the names of registered mesh deformation objects.");
320 
321  private:
330  AffineConstraints<double> make_initial_constraints ();
331 
339  void deform_initial_mesh ();
340 
353  void make_constraints ();
354 
358  void compute_mesh_displacements ();
359 
375  void set_initial_topography ();
376 
380  void interpolate_mesh_velocity ();
381 
387 
393 
398 
405 
413 
418 
428 
438 
443 
448 
454 
460 
465  std::map<types::boundary_id,std::vector<std::unique_ptr<Interface<dim> > > > mesh_deformation_objects;
466 
471  std::map<types::boundary_id, std::vector<std::string> > mesh_deformation_object_names;
472 
479 
485 
492  std::set<types::boundary_id> zero_mesh_deformation_boundary_indicators;
493 
499  std::set<types::boundary_id> free_surface_boundary_indicators;
500 
502 
503  friend class Simulator<dim>;
504  friend class SimulatorAccess<dim>;
505  };
506 
507 
508 
509  template <int dim>
510  template <typename MeshDeformationType>
511  inline
512  bool
514  {
515  for (typename std::map<types::boundary_id, std::vector<std::unique_ptr<Interface<dim> > > >::iterator boundary_id
516  = mesh_deformation_objects.begin();
517  boundary_id != mesh_deformation_objects.end(); ++boundary_id)
518  for (const auto &p : boundary_id->second)
519  if (Plugins::plugin_type_matches<MeshDeformationType>(*p))
520  return true;
521 
522  return false;
523  }
524 
525 
526 
527  template <int dim>
528  template <typename MeshDeformationType>
529  inline
530  const MeshDeformationType &
532  {
533  AssertThrow(has_matching_mesh_deformation_object<MeshDeformationType> (),
534  ExcMessage("You asked MeshDeformation::MeshDeformationHandler::get_matching_mesh_deformation_object() for a "
535  "mesh deformation object of type <" + boost::core::demangle(typeid(MeshDeformationType).name()) + "> "
536  "that could not be found in the current model. Activate this "
537  "mesh deformation in the input file."));
538 
539  for (typename std::map<types::boundary_id, std::vector<std::unique_ptr<Interface<dim> > > >::iterator boundary_id
540  = mesh_deformation_objects.begin();
541  boundary_id != mesh_deformation_objects.end(); ++boundary_id)
542  {
543  typename std::vector<std::unique_ptr<Interface<dim> > >::const_iterator mesh_def;
544  for (const auto &p : boundary_id->second)
545  {
546  if (Plugins::plugin_type_matches<MeshDeformationType>(*p))
547  return Plugins::get_plugin_as_type<MeshDeformationType>(*p);
548  else
549  // We will never get here, because we had the Assert above. Just to avoid warnings.
550  return Plugins::get_plugin_as_type<MeshDeformationType>(*(*mesh_def));
551  }
552  }
553  }
554 
555 
562  template <int dim>
563  std::string
565 
566 
567 
575 #define ASPECT_REGISTER_MESH_DEFORMATION_MODEL(classname,name,description) \
576  template class classname<2>; \
577  template class classname<3>; \
578  namespace ASPECT_REGISTER_MESH_DEFORMATION_MODEL_ ## classname \
579  { \
580  aspect::internal::Plugins::RegisterHelper<aspect::MeshDeformation::Interface<2>,classname<2> > \
581  dummy_ ## classname ## _2d (&aspect::MeshDeformation::MeshDeformationHandler<2>::register_mesh_deformation, \
582  name, description); \
583  aspect::internal::Plugins::RegisterHelper<aspect::MeshDeformation::Interface<3>,classname<3> > \
584  dummy_ ## classname ## _3d (&aspect::MeshDeformation::MeshDeformationHandler<3>::register_mesh_deformation, \
585  name, description); \
586  }
587  }
588 }
589 
590 #endif
std::set< types::boundary_id > prescribed_mesh_deformation_boundary_indicators
Definition: interface.h:478
#define AssertThrow(cond, exc)
void write_plugin_graph(std::ostream &output_stream)
AffineConstraints< double > mesh_velocity_constraints
Definition: interface.h:453
std::set< types::boundary_id > tangential_mesh_deformation_boundary_indicators
Definition: interface.h:484
AffineConstraints< double > mesh_vertex_constraints
Definition: interface.h:459
static ::ExceptionBase & ExcMessage(std::string arg1)
std::map< types::boundary_id, std::vector< std::string > > mesh_deformation_object_names
Definition: interface.h:471
LinearAlgebra::BlockVector mesh_velocity
Definition: interface.h:404
std::map< types::boundary_id, std::vector< std::unique_ptr< Interface< dim > > > > mesh_deformation_objects
Definition: interface.h:465
std::string get_valid_model_names_pattern()
void declare_parameters(ParameterHandler &prm)
DeclException1(ExcARKodeError, int,<< "One of the SUNDIALS ARKode internal functions "<< " returned a negative error code: "<< arg1<< ". Please consult SUNDIALS manual.")
std::set< types::boundary_id > free_surface_boundary_indicators
Definition: interface.h:499
std::set< types::boundary_id > zero_mesh_deformation_boundary_indicators
Definition: interface.h:492
unsigned int boundary_id