ExaDG
Loading...
Searching...
No Matches
boundary_descriptor.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_EXADG_STRUCTURE_USER_INTERFACE_BOUNDARY_DESCRIPTOR_H_
23#define INCLUDE_EXADG_STRUCTURE_USER_INTERFACE_BOUNDARY_DESCRIPTOR_H_
24
25// deal.II
26#include <deal.II/base/function.h>
27#include <deal.II/base/types.h>
28#include <deal.II/fe/component_mask.h>
29
30// ExaDG
31#include <exadg/functions_and_boundary_conditions/container_interface_data.h>
32
33namespace ExaDG
34{
35namespace Structure
36{
37enum class BoundaryType
38{
39 Undefined,
40 Dirichlet,
41 DirichletCached,
42 Neumann,
43 NeumannCached
44};
45
46template<int dim>
48{
49 // Dirichlet
50 std::map<dealii::types::boundary_id, std::shared_ptr<dealii::Function<dim>>> dirichlet_bc;
51
52 // Initial acceleration prescribed on Dirichlet boundary:
53 // This data structure will only be used if the initial_acceleration is not set in FieldFunctions.
54 // Moreover, this data structure will only be used for unsteady problems.
55 std::map<dealii::types::boundary_id, std::shared_ptr<dealii::Function<dim>>>
56 dirichlet_bc_initial_acceleration;
57
58 // ComponentMask
59 // If a certain boundary ID is not inserted into this map, it is assumed that all components are
60 // active, in analogy to the default constructor of dealii::ComponentMask.
61 std::map<dealii::types::boundary_id, dealii::ComponentMask> dirichlet_bc_component_mask;
62
63 // Another type of Dirichlet boundary condition where the Dirichlet values come
64 // from the solution on another domain that is in contact with the actual domain
65 // of interest at the given boundary (this type of Dirichlet boundary condition
66 // is required for the ALE mesh deformation problem in fluid-structure interaction).
67 // ComponentMask is not implemented/available for this type of boundary condition.
68 std::set<dealii::types::boundary_id> dirichlet_cached_bc;
69
70 // Neumann
71 std::map<dealii::types::boundary_id, std::shared_ptr<dealii::Function<dim>>> neumann_bc;
72
73 // another type of Neumann boundary condition where the traction force comes
74 // from the solution on another domain that is in contact with the actual domain
75 // of interest at the given boundary (this type of Neumann boundary condition
76 // is required for fluid-structure interaction problems)
77 std::set<dealii::types::boundary_id> neumann_cached_bc;
78
79 inline DEAL_II_ALWAYS_INLINE //
80 BoundaryType
81 get_boundary_type(dealii::types::boundary_id const & boundary_id) const
82 {
83 if(this->dirichlet_bc.find(boundary_id) != this->dirichlet_bc.end())
84 return BoundaryType::Dirichlet;
85 else if(this->dirichlet_cached_bc.find(boundary_id) != this->dirichlet_cached_bc.end())
86 return BoundaryType::DirichletCached;
87 else if(this->neumann_bc.find(boundary_id) != this->neumann_bc.end())
88 return BoundaryType::Neumann;
89 else if(this->neumann_cached_bc.find(boundary_id) != this->neumann_cached_bc.end())
90 return BoundaryType::NeumannCached;
91
92 AssertThrow(false,
93 dealii::ExcMessage(
94 "Could not find a boundary type to the specified boundary_id = " +
95 std::to_string(boundary_id) +
96 ". A possible reason is that you "
97 "forgot to define a boundary condition for this boundary_id, or "
98 "that the boundary type associated to this boundary has not been "
99 "implemented."));
100
101 return BoundaryType::Undefined;
102 }
103
104 inline DEAL_II_ALWAYS_INLINE //
105 void
106 verify_boundary_conditions(
107 dealii::types::boundary_id const boundary_id,
108 std::set<dealii::types::boundary_id> const & periodic_boundary_ids) const
109 {
110 unsigned int counter = 0;
111 if(dirichlet_bc.find(boundary_id) != dirichlet_bc.end())
112 {
113 counter++;
114
115 AssertThrow(
116 dirichlet_bc_component_mask.find(boundary_id) != dirichlet_bc_component_mask.end(),
117 dealii::ExcMessage(
118 "dirichlet_bc_component_mask must contain the same boundary IDs as dirichlet_bc."));
119
120 AssertThrow(
121 dirichlet_bc_initial_acceleration.find(boundary_id) !=
122 dirichlet_bc_initial_acceleration.end(),
123 dealii::ExcMessage(
124 "dirichlet_bc_initial_acceleration must contain the same boundary IDs as dirichlet_bc."));
125 }
126
127 if(dirichlet_cached_bc.find(boundary_id) != dirichlet_cached_bc.end())
128 counter++;
129
130 if(neumann_bc.find(boundary_id) != neumann_bc.end())
131 counter++;
132
133 if(neumann_cached_bc.find(boundary_id) != neumann_cached_bc.end())
134 counter++;
135
136 if(periodic_boundary_ids.find(boundary_id) != periodic_boundary_ids.end())
137 counter++;
138
139 AssertThrow(counter == 1,
140 dealii::ExcMessage("Boundary face with non-unique boundary type found."));
141 }
142
143 void
144 set_dirichlet_cached_data(
145 std::shared_ptr<ContainerInterfaceData<1, dim, double> const> interface_data) const
146 {
147 dirichlet_cached_data = interface_data;
148 }
149
150 void
151 set_neumann_cached_data(
152 std::shared_ptr<ContainerInterfaceData<1, dim, double> const> interface_data) const
153 {
154 neumann_cached_data = interface_data;
155 }
156
157 std::shared_ptr<ContainerInterfaceData<1, dim, double> const>
158 get_dirichlet_cached_data() const
159 {
160 AssertThrow(dirichlet_cached_data.get(),
161 dealii::ExcMessage("Pointer to ContainerInterfaceData has not been initialized."));
162
163 return dirichlet_cached_data;
164 }
165
166 std::shared_ptr<ContainerInterfaceData<1, dim, double> const>
167 get_neumann_cached_data() const
168 {
169 AssertThrow(neumann_cached_data.get(),
170 dealii::ExcMessage("Pointer to ContainerInterfaceData has not been initialized."));
171
172 return neumann_cached_data;
173 }
174
175private:
176 mutable std::shared_ptr<ContainerInterfaceData<1, dim, double> const> dirichlet_cached_data;
177 mutable std::shared_ptr<ContainerInterfaceData<1, dim, double> const> neumann_cached_data;
178};
179
180} // namespace Structure
181} // namespace ExaDG
182
183#endif
Definition container_interface_data.h:45
Definition driver.cpp:33
Definition boundary_descriptor.h:48