hyper.deal
Loading...
Searching...
No Matches
boundary_descriptor.h
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2020 by the hyper.deal authors
4//
5// This file is part of the hyper.deal library.
6//
7// The hyper.deal library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 3.0 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.MD at
12// the top level directory of hyper.deal.
13//
14// ---------------------------------------------------------------------
15
16#ifndef HYPERDEAL_USERINTERFACE_BOUNDARYDESCRIPTOR
17#define HYPERDEAL_USERINTERFACE_BOUNDARYDESCRIPTOR
18
19#include <hyper.deal/base/config.h>
20
21#include <deal.II/base/function.h>
22#include <deal.II/base/types.h>
23
24namespace hyperdeal
25{
26 namespace advection
27 {
31 enum class BoundaryType
32 {
33 Undefined,
34 DirichletInhomogenous,
35 DirichletHomogenous,
36 };
37
41 template <int dim, typename Number>
43 {
47 std::map<dealii::types::boundary_id,
48 std::shared_ptr<dealii::Function<dim, Number>>>
50
51 std::set<dealii::types::boundary_id> homogeneous_dirichlet_bc;
52
56 inline DEAL_II_ALWAYS_INLINE //
57 BoundaryType
58 get_boundary_type(dealii::types::boundary_id const &boundary_id) const
59 {
60 if (this->dirichlet_bc.find(boundary_id) != this->dirichlet_bc.end())
61 return BoundaryType::DirichletInhomogenous;
62
63 if (this->homogeneous_dirichlet_bc.find(boundary_id) !=
64 this->homogeneous_dirichlet_bc.end())
65 return BoundaryType::DirichletInhomogenous;
66
67 AssertThrow(false,
68 dealii::ExcMessage(
69 "Boundary type of face is invalid or not implemented."));
70
71 return BoundaryType::Undefined;
72 }
73
77 inline DEAL_II_ALWAYS_INLINE //
78 std::pair<BoundaryType, std::shared_ptr<dealii::Function<dim, Number>>>
79 get_boundary(dealii::types::boundary_id const &boundary_id) const
80 {
81 // process inhomogeneous Dirichlet BC
82 {
83 auto res = this->dirichlet_bc.find(boundary_id);
84 if (res != this->dirichlet_bc.end())
85 return {BoundaryType::DirichletInhomogenous, res->second};
86 }
87
88 // process homogeneous Dirichlet BC
89 {
90 auto res = this->homogeneous_dirichlet_bc.find(boundary_id);
91 if (res != this->homogeneous_dirichlet_bc.end())
92 return {BoundaryType::DirichletHomogenous,
93 std::shared_ptr<dealii::Function<dim, Number>>(
94 new dealii::Functions::ZeroFunction<dim, Number>())};
95 }
96
97 AssertThrow(false,
98 dealii::ExcMessage(
99 "Boundary type of face is invalid or not implemented."));
100
101 return {BoundaryType::Undefined,
102 std::shared_ptr<dealii::Function<dim>>(
103 new dealii::Functions::ZeroFunction<dim, Number>())};
104 }
105
109 void
110 set_time(const Number time)
111 {
112 for (auto &bc : dirichlet_bc)
113 bc.second->set_time(time);
114 }
115 };
116
117 } // namespace advection
118} // namespace hyperdeal
119
120#endif
Definition boundary_descriptor.h:43
std::map< dealii::types::boundary_id, std::shared_ptr< dealii::Function< dim, Number > > > dirichlet_bc
Definition boundary_descriptor.h:49
void set_time(const Number time)
Definition boundary_descriptor.h:110
DEAL_II_ALWAYS_INLINE std::pair< BoundaryType, std::shared_ptr< dealii::Function< dim, Number > > > get_boundary(dealii::types::boundary_id const &boundary_id) const
Definition boundary_descriptor.h:79
DEAL_II_ALWAYS_INLINE BoundaryType get_boundary_type(dealii::types::boundary_id const &boundary_id) const
Definition boundary_descriptor.h:58