ExaDG
Loading...
Searching...
No Matches
mapping_deformation_function.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef INCLUDE_GRID_MAPPING_DEFORMATION_FUNCTION_H_
23#define INCLUDE_GRID_MAPPING_DEFORMATION_FUNCTION_H_
24
25#include <exadg/grid/grid_data.h>
26#include <exadg/grid/mapping_deformation_base.h>
27
28namespace ExaDG
29{
36template<int dim, typename Number>
38{
39public:
40 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
41
45 DeformedMappingFunction(std::shared_ptr<dealii::Mapping<dim> const> mapping_undeformed,
46 unsigned int const mapping_degree_q_cache,
47 dealii::Triangulation<dim> const & triangulation,
48 std::shared_ptr<dealii::Function<dim>> const mesh_deformation_function,
49 double const start_time)
50 : DeformedMappingBase<dim, Number>(mapping_undeformed, mapping_degree_q_cache, triangulation),
51 mesh_deformation_function(mesh_deformation_function),
52 triangulation(triangulation)
53 {
54 update(start_time, false, dealii::numbers::invalid_unsigned_int);
55 }
56
60 void
61 update(double const time,
62 bool const print_solver_info,
63 types::time_step time_step_number) override
64 {
65 (void)print_solver_info;
66 (void)time_step_number;
67
68 mesh_deformation_function->set_time(time);
69
70 this->do_initialize(triangulation, mesh_deformation_function);
71 }
72
73private:
79 void
80 do_initialize(dealii::Triangulation<dim> const & triangulation,
81 std::shared_ptr<dealii::Function<dim>> displacement_function)
82 {
83 AssertThrow(dealii::MultithreadInfo::n_threads() == 1, dealii::ExcNotImplemented());
84
85 AssertThrow(get_element_type(triangulation) == ElementType::Hypercube,
86 dealii::ExcMessage("Only implemented for hypercube elements."));
87
88 // dummy FE for compatibility with interface of dealii::FEValues
89 dealii::FE_Nothing<dim> dummy_fe;
90 dealii::FEValues<dim> fe_values(*this->mapping_undeformed,
91 dummy_fe,
92 dealii::QGaussLobatto<dim>(this->mapping_q_cache->get_degree() +
93 1),
94 dealii::update_quadrature_points);
95
96 this->mapping_q_cache->initialize(
97 triangulation,
98 [&](typename dealii::Triangulation<dim>::cell_iterator const & cell)
99 -> std::vector<dealii::Point<dim>> {
100 fe_values.reinit(cell);
101
102 // compute displacement and add to original position
103 std::vector<dealii::Point<dim>> points_moved(fe_values.n_quadrature_points);
104 for(unsigned int i = 0; i < fe_values.n_quadrature_points; ++i)
105 {
106 // need to adjust for hierarchic numbering of dealii::MappingQCache
107 dealii::Point<dim> const point =
108 fe_values.quadrature_point(this->hierarchic_to_lexicographic_numbering[i]);
109 dealii::Point<dim> displacement;
110 for(unsigned int d = 0; d < dim; ++d)
111 displacement[d] = displacement_function->value(point, d);
112
113 points_moved[i] = point + displacement;
114 }
115
116 return points_moved;
117 });
118 }
119
120 std::shared_ptr<dealii::Function<dim>> mesh_deformation_function;
121
122 dealii::Triangulation<dim> const & triangulation;
123};
124
125} // namespace ExaDG
126
127#endif /*INCLUDE_GRID_MAPPING_DEFORMATION_FUNCTION_H_*/
Definition mapping_deformation_base.h:49
std::shared_ptr< dealii::Mapping< dim > const > mapping_undeformed
Definition mapping_deformation_base.h:106
Definition mapping_deformation_function.h:38
void update(double const time, bool const print_solver_info, types::time_step time_step_number) override
Definition mapping_deformation_function.h:61
DeformedMappingFunction(std::shared_ptr< dealii::Mapping< dim > const > mapping_undeformed, unsigned int const mapping_degree_q_cache, dealii::Triangulation< dim > const &triangulation, std::shared_ptr< dealii::Function< dim > > const mesh_deformation_function, double const start_time)
Definition mapping_deformation_function.h:45
Definition driver.cpp:33
ElementType get_element_type(dealii::Triangulation< dim > const &tria)
Definition grid_data.h:70