Hermes2D  3.0
essential_boundary_conditions.h
1 // This file is part of Hermes3D
2 //
3 // Copyright (c) 2009 hp-FEM group at the University of Nevada, Reno (UNR).
4 // Email: hpfem-group@unr.edu, home page: http://www.hpfem.org/.
5 //
6 // Hermes3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published
8 // by the Free Software Foundation; either version 2 of the License,
9 // or (at your option) any later version.
10 //
11 // Hermes3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Hermes3D; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20 #ifndef __HERMES_COMMON_BOUNDARYCONDITIONS_H
21 #define __HERMES_COMMON_BOUNDARYCONDITIONS_H
22 
23 #include "../global.h"
24 namespace Hermes
25 {
26  namespace Hermes2D
27  {
28  template<typename Scalar> class ExactSolutionScalar;
29  template<typename Scalar> class ExactSolutionVector;
30  template<typename Scalar> class EssentialBCs;
31 
34  {
35  BC_FUNCTION,
36  BC_CONST
37  };
38 
41  template<typename Scalar>
42  class HERMES_API EssentialBoundaryCondition : public Hermes::Mixins::Loggable
43  {
44  public:
47  EssentialBoundaryCondition(std::vector<std::string> markers);
49 
51  virtual ~EssentialBoundaryCondition();
52 
54  virtual EssentialBCValueType get_value_type() const = 0;
55 
64  virtual Scalar value(double x, double y) const = 0;
65 
67  void set_current_time(double time);
68 
70  double get_current_time() const;
71 
72  protected:
74  Scalar value_const;
75 
77  double current_time;
78 
80  std::vector<std::string> markers;
81 
82  template<typename T> friend class EssentialBCs;
83  template<typename T> friend class Space;
84  template<typename T> friend class H1Space;
85  template<typename T> friend class L2Space;
86  template<typename T> friend class HcurlSpace;
87  template<typename T> friend class HdivSpace;
88  };
89 
91  template<typename Scalar>
92  class HERMES_API DefaultEssentialBCConst : public EssentialBoundaryCondition < Scalar >
93  {
94  public:
96  DefaultEssentialBCConst(std::vector<std::string> markers, Scalar value_const);
97  DefaultEssentialBCConst(std::string marker, Scalar value_const);
98 
99  Scalar value(double x, double y) const;
100 
102  inline EssentialBCValueType get_value_type() const { return BC_CONST; }
103  };
104 
110  // Constructor with multiple markers, setting velocity at inlet(vel_inlet), domain height(H) and startup time(startup_time) - all parameters are of this example - DERIVED - class.
127  // Members of MyEssentialBCNonConst.
133 
134  template<typename Scalar>
135  class HERMES_API DefaultEssentialBCNonConst : public EssentialBoundaryCondition < Scalar >
136  {
137  public:
138  DefaultEssentialBCNonConst(std::vector<std::string> markers_,
139  MeshFunctionSharedPtr<Scalar> exact_solution);
140 
142 
144 
145  virtual Scalar value(double x, double y) const;
146 
148  inline EssentialBCValueType get_value_type() const { return BC_FUNCTION; }
149 
150  ExactSolutionScalar<Scalar>* exact_solution;
151  };
152 
156  template<typename Scalar>
157  class HERMES_API EssentialBCs {
158  public:
160  EssentialBCs();
161 
163  EssentialBCs(std::vector<EssentialBoundaryCondition<Scalar> *> essential_bcs);
164  EssentialBCs(EssentialBoundaryCondition<Scalar>* boundary_condition);
165 
167  ~EssentialBCs();
168 
170  void add_boundary_conditions(std::vector<EssentialBoundaryCondition<Scalar> *> essential_bcs);
171  void add_boundary_condition(EssentialBoundaryCondition<Scalar>* essential_bc);
172 
174  typename std::vector<EssentialBoundaryCondition<Scalar> *>::const_iterator iterator;
175  typename std::vector<EssentialBoundaryCondition<Scalar> *>::const_iterator begin() const;
176  typename std::vector<EssentialBoundaryCondition<Scalar> *>::const_iterator end() const;
177 
179  EssentialBoundaryCondition<Scalar>* get_boundary_condition(std::string marker);
180 
182  const std::vector<std::string>& get_markers() const;
183 
185  void set_current_time(double time);
186 
187  private:
189  std::vector<EssentialBoundaryCondition<Scalar> *> all;
190 
192  std::vector<std::string> markers;
194  std::vector<EssentialBoundaryCondition<Scalar> *> BCs;
195 
198 
200  void create_marker_cache();
201 
202  template<typename T> friend class EssentialBCs;
203  template<typename T> friend class Space;
204  template<typename T> friend class H1Space;
205  template<typename T> friend class L2Space;
206  template<typename T> friend class HcurlSpace;
207  template<typename T> friend class HdivSpace;
208  };
209  }
210 }
211 #endif
EssentialBCValueType
Types of description of boundary values, either a function (callback), or a constant.
Definition: adapt.h:24
Scalar value_const
Special case of a constant function.
::xsd::cxx::tree::time< char, simple_type > time
C++ type corresponding to the time XML Schema built-in type.
EssentialBCValueType get_value_type() const
Function giving info that u_Essential is a constant.
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.
EssentialBCValueType get_value_type() const
Function giving info that u_Essential is a non-constant function.
Represents a finite element space over a domain.
Definition: api2d.h:34
std::vector< EssentialBoundaryCondition< Scalar > * >::const_iterator iterator
Public iterators for the private data structures.
Class representing constant essential boundary condition.