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_POISSON_USER_INTERFACE_BOUNDARY_DESCRIPTOR_H_
23#define INCLUDE_EXADG_POISSON_USER_INTERFACE_BOUNDARY_DESCRIPTOR_H_
24
25// deal.II
26#include <deal.II/base/function.h>
27#include <deal.II/base/types.h>
28
29// ExaDG
30#include <exadg/functions_and_boundary_conditions/container_interface_data.h>
31
32namespace ExaDG
33{
34namespace Poisson
35{
36enum class BoundaryType
37{
38 Undefined,
39 Dirichlet,
40 DirichletCached,
41 Neumann
42};
43
44template<int rank, int dim>
46{
47 // Dirichlet
48 std::map<dealii::types::boundary_id, std::shared_ptr<dealii::Function<dim>>> dirichlet_bc;
49
50 // ComponentMask (only used/relevant for continuous Galerkin, ignored for DG)
51 // If a certain boundary ID is not inserted into this map, it is assumed that all components are
52 // active, in analogy to the default constructor of dealii::ComponentMask.
53 std::map<dealii::types::boundary_id, dealii::ComponentMask> dirichlet_bc_component_mask;
54
55 // Another type of Dirichlet boundary condition where the Dirichlet values come
56 // from the solution on another domain that is in contact with the actual domain
57 // of interest at the given boundary (this type of Dirichlet boundary condition
58 // is required for the ALE mesh deformation problem in fluid-structure interaction).
59 // ComponentMask is not implemented/available for this type of boundary condition.
60 std::set<dealii::types::boundary_id> dirichlet_cached_bc;
61
62 // Neumann
63 std::map<dealii::types::boundary_id, std::shared_ptr<dealii::Function<dim>>> neumann_bc;
64
65 // returns the boundary type
66 inline DEAL_II_ALWAYS_INLINE //
67 BoundaryType
68 get_boundary_type(dealii::types::boundary_id const & boundary_id) const
69 {
70 if(this->dirichlet_bc.find(boundary_id) != this->dirichlet_bc.end())
71 return BoundaryType::Dirichlet;
72 else if(this->dirichlet_cached_bc.find(boundary_id) != this->dirichlet_cached_bc.end())
73 return BoundaryType::DirichletCached;
74 else if(this->neumann_bc.find(boundary_id) != this->neumann_bc.end())
75 return BoundaryType::Neumann;
76
77 AssertThrow(false, dealii::ExcMessage("Boundary type of face is invalid or not implemented."));
78
79 return BoundaryType::Undefined;
80 }
81
82 inline DEAL_II_ALWAYS_INLINE //
83 void
84 verify_boundary_conditions(
85 dealii::types::boundary_id const boundary_id,
86 std::set<dealii::types::boundary_id> const & periodic_boundary_ids) const
87 {
88 unsigned int counter = 0;
89 if(dirichlet_bc.find(boundary_id) != dirichlet_bc.end())
90 counter++;
91
92 if(dirichlet_cached_bc.find(boundary_id) != dirichlet_cached_bc.end())
93 counter++;
94
95 if(neumann_bc.find(boundary_id) != neumann_bc.end())
96 counter++;
97
98 if(periodic_boundary_ids.find(boundary_id) != periodic_boundary_ids.end())
99 counter++;
100
101 AssertThrow(counter == 1,
102 dealii::ExcMessage("Boundary face with non-unique boundary type found."));
103 }
104
105 void
106 set_dirichlet_cached_data(
107 std::shared_ptr<ContainerInterfaceData<rank, dim, double> const> interface_data) const
108 {
109 dirichlet_cached_data = interface_data;
110 }
111
112 std::shared_ptr<ContainerInterfaceData<rank, dim, double> const>
113 get_dirichlet_cached_data() const
114 {
115 AssertThrow(dirichlet_cached_data.get(),
116 dealii::ExcMessage("Pointer to ContainerInterfaceData has not been initialized."));
117
118 return dirichlet_cached_data;
119 }
120
121private:
122 mutable std::shared_ptr<ContainerInterfaceData<rank, dim, double> const> dirichlet_cached_data;
123};
124
125} // namespace Poisson
126} // namespace ExaDG
127
128
129#endif /* INCLUDE_EXADG_POISSON_USER_INTERFACE_BOUNDARY_DESCRIPTOR_H_ */
Definition container_interface_data.h:45
Definition driver.cpp:33
Definition boundary_descriptor.h:46