Hermes2D  2.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://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 
35  template<typename Scalar>
36  class HERMES_API EssentialBoundaryCondition : public Hermes::Mixins::Loggable
37  {
38  public:
40  EssentialBoundaryCondition(Hermes::vector<std::string> markers);
42 
44  virtual ~EssentialBoundaryCondition();
45 
48  BC_FUNCTION,
49  BC_CONST
50  };
51 
53  virtual EssentialBCValueType get_value_type() const = 0;
54 
63  virtual Scalar value(double x, double y, double n_x, double n_y, double t_x, double t_y) const = 0;
64 
66  void set_current_time(double time);
67 
69  double get_current_time() const;
70 
71  protected:
73  Scalar value_const;
74 
76  double current_time;
77 
79  Hermes::vector<std::string> markers;
80 
81  template<typename T> friend class EssentialBCs;
82  template<typename T> friend class Space;
83  template<typename T> friend class H1Space;
84  template<typename T> friend class L2Space;
85  template<typename T> friend class HcurlSpace;
86  template<typename T> friend class HdivSpace;
87  };
88 
90  template<typename Scalar>
91  class HERMES_API DefaultEssentialBCConst : public EssentialBoundaryCondition<Scalar> {
92  public:
94  DefaultEssentialBCConst(Hermes::vector<std::string> markers, Scalar value_const);
95  DefaultEssentialBCConst(std::string marker, Scalar value_const);
96 
97  Scalar value(double x, double y, double n_x, double n_y, double t_x, double t_y) const;
98 
101  };
102 
129 
130  template<typename Scalar>
131  class HERMES_API DefaultEssentialBCNonConst : public EssentialBoundaryCondition<Scalar>
132  {
133  public:
134  DefaultEssentialBCNonConst(Hermes::vector<std::string> markers_,
135  ExactSolutionScalar<Scalar>* exact_solution);
136 
138 
140 
141  virtual Scalar value(double x, double y, double n_x, double n_y, double t_x, double t_y) const;
142 
145 
146  ExactSolutionScalar<Scalar>* exact_solution;
147  };
148 
151  template<typename Scalar>
153  {
154  public:
155  // Tangential values given by a vector-valued solution.
156  DefaultEssentialBCNonConstHcurl(Hermes::vector<std::string> markers_,
157  ExactSolutionVector<Scalar>* exact_solution2);
159 
161 
162  virtual Scalar value(double x, double y, double n_x, double n_y, double t_x, double t_y) const;
163 
166 
167  ExactSolutionVector<Scalar>* exact_solution2;
168  };
169 
173  template<typename Scalar>
174  class HERMES_API EssentialBCs {
175  public:
177  EssentialBCs();
178 
180  EssentialBCs(Hermes::vector<EssentialBoundaryCondition<Scalar> *> essential_bcs);
181  EssentialBCs(EssentialBoundaryCondition<Scalar>* boundary_condition);
182 
184  ~EssentialBCs();
185 
187  void add_boundary_conditions(Hermes::vector<EssentialBoundaryCondition<Scalar> *> essential_bcs);
188  void add_boundary_condition(EssentialBoundaryCondition<Scalar>* essential_bc);
189 
191  typename Hermes::vector<EssentialBoundaryCondition<Scalar> *>::const_iterator iterator;
192  typename Hermes::vector<EssentialBoundaryCondition<Scalar> *>::const_iterator begin() const;
193  typename Hermes::vector<EssentialBoundaryCondition<Scalar> *>::const_iterator end() const;
194 
195  EssentialBoundaryCondition<Scalar>* get_boundary_condition(std::string marker);
196 
198  void set_current_time(double time);
199 
200  private:
202  Hermes::vector<EssentialBoundaryCondition<Scalar> *> all;
203 
205  Hermes::vector<std::string> markers;
207  Hermes::vector<EssentialBoundaryCondition<Scalar> *> BCs;
208 
211 
213  void create_marker_cache();
214 
215  template<typename T> friend class EssentialBCs;
216  template<typename T> friend class Space;
217  template<typename T> friend class H1Space;
218  template<typename T> friend class L2Space;
219  template<typename T> friend class HcurlSpace;
220  template<typename T> friend class HdivSpace;
221  };
222  }
223 }
224 #endif