ExaDG
Loading...
Searching...
No Matches
mass_operator.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 EXADG_STRUCTURE_SPATIAL_DISCRETIZATION_OPERATORS_MASS_OPERATOR_H_
23#define EXADG_STRUCTURE_SPATIAL_DISCRETIZATION_OPERATORS_MASS_OPERATOR_H_
24
25// deal.II
26#include <deal.II/numerics/vector_tools.h>
27
28// ExaDG
29#include <exadg/operators/mass_operator.h>
30
31namespace ExaDG
32{
33namespace Structure
34{
35template<int dim, typename Number>
36struct MassOperatorData : public ExaDG::MassOperatorData<dim, Number>
37{
38 std::shared_ptr<BoundaryDescriptor<dim> const> bc;
39};
40
41template<int dim, typename Number>
42class MassOperator : public ExaDG::MassOperator<dim, dim, Number>
43{
44public:
46
47 typedef typename Base::VectorType VectorType;
48
49 void
50 initialize(dealii::MatrixFree<dim, Number> const & matrix_free,
51 dealii::AffineConstraints<Number> const & affine_constraints,
53 {
54 operator_data = data;
55
56 ExaDG::MassOperator<dim, dim, Number>::initialize(matrix_free, affine_constraints, data);
57 }
58
59 void
60 set_inhomogeneous_constrained_values(VectorType & dst) const final
61 {
62 // periodicity and hanging node constraints are enforced strongly for continuous spaces
63 if(not this->is_dg)
64 {
65 unsigned int const dof_index_inhomogeneous = this->get_dof_index_inhomogeneous();
66 dealii::AffineConstraints<Number> const & constraints =
67 this->matrix_free->get_affine_constraints(dof_index_inhomogeneous);
68 constraints.distribute(dst);
69 }
70
71 // standard Dirichlet boundary conditions
72 std::map<dealii::types::global_dof_index, double> boundary_values;
73 for(auto dbc : operator_data.bc->dirichlet_bc_initial_acceleration)
74 {
75 dbc.second->set_time(this->get_time());
76 dealii::ComponentMask mask =
77 operator_data.bc->dirichlet_bc_component_mask.find(dbc.first)->second;
78
79 dealii::VectorTools::interpolate_boundary_values(
80 *this->matrix_free->get_mapping_info().mapping,
81 this->matrix_free->get_dof_handler(operator_data.dof_index),
82 dbc.first,
83 *dbc.second,
84 boundary_values,
85 mask);
86 }
87
88 // set Dirichlet values in solution vector
89 for(auto m : boundary_values)
90 if(dst.get_partitioner()->in_local_range(m.first))
91 dst[m.first] = m.second;
92
93 dst.update_ghost_values();
94 }
95
96private:
98};
99
100} // namespace Structure
101} // namespace ExaDG
102
103#endif /* EXADG_STRUCTURE_SPATIAL_DISCRETIZATION_OPERATORS_MASS_OPERATOR_H_ */
Definition mass_operator.h:53
Definition driver.cpp:33
Definition mass_operator.h:35
Definition mass_operator.h:37