Hermes2D  3.0
weakforms_h1.h
1 // This file is part of Hermes2D.
2 //
3 // Hermes2D is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 2 of the License, or
6 // (at your option) any later version.
7 //
8 // Hermes2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Hermes2D. If not, see <http://www.gnu.org/licenses/>.
15 
16 #ifndef __H2D_H1_WEAK_FORMS_H
17 #define __H2D_H1_WEAK_FORMS_H
18 
19 #include "../weakform/weakform.h"
20 #include "../spline.h"
21 
22 namespace Hermes
23 {
24  namespace Hermes2D
25  {
26  namespace WeakFormsH1
27  {
28  /* Default volumetric matrix form \int_{area} const_coeff * function_coeff(x, y) * u * v \bfx
29  const_coeff... constant number
30  function_coeff... (generally nonconstant) function of x, y
31  */
32 
33  template<typename Scalar>
34  class HERMES_API DefaultMatrixFormVol : public MatrixFormVol < Scalar >
35  {
36  public:
37  DefaultMatrixFormVol(int i, int j, std::string area = HERMES_ANY,
38  Hermes2DFunction<Scalar>* coeff = nullptr,
39  SymFlag sym = HERMES_NONSYM, GeomType gt = HERMES_PLANAR);
40 
41  DefaultMatrixFormVol(int i, int j, std::vector<std::string> areas,
42  Hermes2DFunction<Scalar>* coeff = nullptr,
43  SymFlag sym = HERMES_NONSYM, GeomType gt = HERMES_PLANAR);
44 
45  virtual ~DefaultMatrixFormVol();
46 
47  virtual Scalar value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *u, Func<double> *v,
48  GeomVol<double> *e, Func<Scalar> **ext) const;
49 
50  virtual Hermes::Ord ord(int n, double *wt, Func<Hermes::Ord> *u_ext[], Func<Hermes::Ord> *u,
52 
53  virtual MatrixFormVol<Scalar>* clone() const;
54 
55  private:
56 
57  Hermes2DFunction<Scalar>* coeff;
58  bool own_coeff;
59  GeomType gt;
60  };
61 
62  /* Default volumetric matrix form \int_{area} const_coeff * spline_coeff'(u_ext[0]) u \nabla u_ext[0] \cdot \nabla v
63  + const_coeff * spline_coeff(u_ext[0]) * \nabla u \cdot \nabla v d\bfx
64  const_coeff... constant number
65  spline_coeff... nonconstant parameter given by cubic spline
66  */
67 
68  template<typename Scalar>
69  class HERMES_API DefaultJacobianDiffusion : public MatrixFormVol < Scalar >
70  {
71  public:
72  DefaultJacobianDiffusion(int i, int j, std::string area = HERMES_ANY, Hermes1DFunction<Scalar>* coeff = nullptr,
73  SymFlag sym = HERMES_NONSYM, GeomType gt = HERMES_PLANAR);
74 
75  DefaultJacobianDiffusion(int i, int j, std::vector<std::string> areas, Hermes1DFunction<Scalar>* coeff = nullptr,
76  SymFlag sym = HERMES_NONSYM, GeomType gt = HERMES_PLANAR);
77 
79 
80  virtual Scalar value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *u,
81  Func<double> *v, GeomVol<double> *e, Func<Scalar> **ext) const;
82 
83  virtual Hermes::Ord ord(int n, double *wt, Func<Hermes::Ord> *u_ext[], Func<Hermes::Ord> *u, Func<Hermes::Ord> *v,
84  GeomVol<Hermes::Ord> *e, Func<Ord> **ext) const;
85 
86  virtual MatrixFormVol<Scalar>* clone() const;
87 
88  private:
89  Hermes1DFunction<Scalar>* coeff;
90  bool own_coeff;
91  GeomType gt;
92  };
93 
94  template<typename Scalar>
95  class HERMES_API DefaultMatrixFormDiffusion : public MatrixFormVol < Scalar >
96  {
97  public:
98  DefaultMatrixFormDiffusion(int i, int j, std::string area = HERMES_ANY, Hermes1DFunction<Scalar>* coeff = nullptr,
99  SymFlag sym = HERMES_NONSYM, GeomType gt = HERMES_PLANAR);
100 
101  DefaultMatrixFormDiffusion(int i, int j, std::vector<std::string> areas, Hermes1DFunction<Scalar>* coeff = nullptr,
102  SymFlag sym = HERMES_NONSYM, GeomType gt = HERMES_PLANAR);
103 
105 
106  virtual Scalar value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *u,
107  Func<double> *v, GeomVol<double> *e, Func<Scalar> **ext) const;
108 
109  virtual Hermes::Ord ord(int n, double *wt, Func<Hermes::Ord> *u_ext[], Func<Hermes::Ord> *u, Func<Hermes::Ord> *v,
110  GeomVol<Hermes::Ord> *e, Func<Ord> **ext) const;
111 
112  virtual MatrixFormVol<Scalar>* clone() const;
113 
114  private:
115  Hermes1DFunction<Scalar>* coeff;
116  bool own_coeff;
117  GeomType gt;
118  };
119 
120  /* Default volumetric matrix form
121  \int_{area} spline_coeff1`(u_ext[0]) * u * u_ext[0]->dx * v
122  + spline_coeff1(u_ext[0]) * u->dx * v
123  + spline_coeff2`(u_ext[0]) * u * u_ext[0]->dy * v
124  + spline_coeff2(u_ext[0]) * u->dy * v d\bfx.
125  spline_coeff1, spline_coeff2... non-constant parameters given by cubic splines
126  */
127 
128  template<typename Scalar>
129  class HERMES_API DefaultJacobianAdvection : public MatrixFormVol < Scalar >
130  {
131  public:
132  DefaultJacobianAdvection(int i, int j, std::string area = HERMES_ANY,
133  Hermes1DFunction<Scalar>* coeff_1 = nullptr, Hermes1DFunction<Scalar>* coeff_2 = nullptr, GeomType gt = HERMES_PLANAR);
134 
135  DefaultJacobianAdvection(int i, int j, std::vector<std::string> areas,
136  Hermes1DFunction<Scalar>* coeff_1 = nullptr, Hermes1DFunction<Scalar>* coeff_2 = nullptr,
137  GeomType gt = HERMES_PLANAR);
138 
140 
141  virtual Scalar value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *u,
142  Func<double> *v, GeomVol<double> *e, Func<Scalar> **ext) const;
143 
144  virtual Hermes::Ord ord(int n, double *wt, Func<Hermes::Ord> *u_ext[], Func<Hermes::Ord> *u, Func<Hermes::Ord> *v,
145  GeomVol<Hermes::Ord> *e, Func<Ord> **ext) const;
146 
147  virtual MatrixFormVol<Scalar>* clone() const;
148 
149  private:
150  Hermes1DFunction<Scalar>* coeff1, *coeff2;
151  bool own_coeff1;
152  bool own_coeff2;
153  GeomType gt;
154  };
155 
156  /* Default volumetric vector form \int_{area} const_coeff * function_coeff(x, y) * v d\bfx
157  const_coeff... constant number
158  function_coeff... (generally nonconstant) function of x, y
159  */
160 
161  template<typename Scalar>
162  class HERMES_API DefaultVectorFormVol : public VectorFormVol < Scalar >
163  {
164  public:
165  DefaultVectorFormVol(int i, std::string area = HERMES_ANY, Hermes2DFunction<Scalar>* coeff = nullptr,
166  GeomType gt = HERMES_PLANAR);
167 
168  DefaultVectorFormVol(int i, std::vector<std::string> areas, Hermes2DFunction<Scalar>* coeff = nullptr,
169  GeomType gt = HERMES_PLANAR);
170 
172 
173  virtual Scalar value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *v,
174  GeomVol<double> *e, Func<Scalar> **ext) const;
175  virtual Hermes::Ord ord(int n, double *wt, Func<Hermes::Ord> *u_ext[], Func<Hermes::Ord> *v,
176  GeomVol<Hermes::Ord> *e, Func<Ord> **ext) const;
177 
178  virtual VectorFormVol<Scalar>* clone() const;
179 
180  private:
181 
182  Hermes2DFunction<Scalar>* coeff;
183  bool own_coeff;
184  GeomType gt;
185  };
186 
187  /* Default volumetric vector form \int_{area} const_coeff * function_coeff(x, y) * u_ext[0] * v d\bfx
188  const_coeff... constant number
189  function_coeff... (generally nonconstant) function of x, y
190  */
191 
192  template<typename Scalar>
193  class HERMES_API DefaultResidualVol : public VectorFormVol < Scalar >
194  {
195  public:
196  DefaultResidualVol(int i, std::string area = HERMES_ANY, Hermes2DFunction<Scalar>* coeff = nullptr,
197  GeomType gt = HERMES_PLANAR);
198  DefaultResidualVol(int i, std::vector<std::string> areas, Hermes2DFunction<Scalar>* coeff = nullptr,
199  GeomType gt = HERMES_PLANAR);
200 
202 
203  virtual Scalar value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *v,
204  GeomVol<double> *e, Func<Scalar> **ext) const;
205 
206  virtual Hermes::Ord ord(int n, double *wt, Func<Hermes::Ord> *u_ext[], Func<Hermes::Ord> *v,
207  GeomVol<Hermes::Ord> *e, Func<Ord> **ext) const;
208 
209  virtual VectorFormVol<Scalar>* clone() const;
210 
211  private:
212 
213  Hermes2DFunction<Scalar>* coeff;
214  bool own_coeff;
215  GeomType gt;
216  };
217 
218  /* Default volumetric vector form \int_{area} const_coeff * spline_coeff(u_ext[0]) *
219  \nabla u_ext[0] \cdot \nabla v d\bfx
220  const_coeff... constant number
221  spline_coeff... non-constant parameter given by a cubic spline
222  */
223 
224  template<typename Scalar>
225  class HERMES_API DefaultResidualDiffusion : public VectorFormVol < Scalar >
226  {
227  public:
228  DefaultResidualDiffusion(int i, std::string area = HERMES_ANY, Hermes1DFunction<Scalar>* coeff = nullptr,
229  GeomType gt = HERMES_PLANAR);
230 
231  DefaultResidualDiffusion(int i, std::vector<std::string> areas, Hermes1DFunction<Scalar>* coeff = nullptr,
232  GeomType gt = HERMES_PLANAR);
233 
235 
236  virtual Scalar value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *v,
237  GeomVol<double> *e, Func<Scalar> **ext) const;
238 
239  virtual Hermes::Ord ord(int n, double *wt, Func<Hermes::Ord> *u_ext[], Func<Hermes::Ord> *v,
240  GeomVol<Hermes::Ord> *e, Func<Ord> **ext) const;
241 
242  virtual VectorFormVol<Scalar>* clone() const;
243 
244  private:
245  Hermes1DFunction<Scalar>* coeff;
246  bool own_coeff;
247  GeomType gt;
248  };
249 
250  /* Default volumetric vector form \int_{area} spline_coeff1(u_ext[0]) * u->dx * v->val
251  + spline_coeff2(u_ext[0]) * u->dy * v->val d\bfx
252  spline_coeff1, spline_coeff2... non-constant parameters given by cubic splines
253  */
254 
255  template<typename Scalar>
256  class HERMES_API DefaultResidualAdvection : public VectorFormVol < Scalar >
257  {
258  public:
259  DefaultResidualAdvection(int i, std::string area = HERMES_ANY,
260  Hermes1DFunction<Scalar>* coeff_1 = nullptr, Hermes1DFunction<Scalar>* coeff_2 = nullptr,
261  GeomType gt = HERMES_PLANAR);
262  DefaultResidualAdvection(int i, std::vector<std::string> areas,
263  Hermes1DFunction<Scalar>* coeff_1 = nullptr, Hermes1DFunction<Scalar>* coeff_2 = nullptr, GeomType gt = HERMES_PLANAR);
264 
266 
267  virtual Scalar value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *v,
268  GeomVol<double> *e, Func<Scalar> **ext) const;
269 
270  virtual Hermes::Ord ord(int n, double *wt, Func<Hermes::Ord> *u_ext[], Func<Hermes::Ord> *v,
271  GeomVol<Hermes::Ord> *e, Func<Ord> **ext) const;
272 
273  virtual VectorFormVol<Scalar>* clone() const;
274 
275  private:
276  Hermes1DFunction<Scalar>* coeff1, *coeff2;
277  bool own_coeff1;
278  bool own_coeff2;
279  GeomType gt;
280  };
281 
282  /* Default surface matrix form \int_{area} const_coeff * function_coeff(x, y) * u * v dS
283  const_coeff... constant number
284  function_coeff... (generally nonconstant) function of x, y
285  */
286 
287  template<typename Scalar>
288  class HERMES_API DefaultMatrixFormSurf : public MatrixFormSurf < Scalar >
289  {
290  public:
291  DefaultMatrixFormSurf(int i, int j, std::string area = HERMES_ANY,
292  Hermes2DFunction<Scalar>* coeff = nullptr,
293  GeomType gt = HERMES_PLANAR);
294 
295  DefaultMatrixFormSurf(int i, int j, std::vector<std::string> areas,
296  Hermes2DFunction<Scalar>* coeff = nullptr,
297  GeomType gt = HERMES_PLANAR);
298 
300 
301  virtual Scalar value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *u, Func<double> *v,
302  GeomSurf<double> *e, Func<Scalar> **ext) const;
303 
304  virtual Hermes::Ord ord(int n, double *wt, Func<Hermes::Ord> *u_ext[], Func<Hermes::Ord> *u,
306 
307  virtual MatrixFormSurf<Scalar>* clone() const;
308 
309  private:
310 
311  Hermes2DFunction<Scalar>* coeff;
312  bool own_coeff;
313  GeomType gt;
314  };
315 
316  /* Default surface matrix form \int_{area} const_coeff * spline_coeff'(u_ext[0]) * u_ext[0] * u * v
317  + const_coeff * spline_coeff(u_ext[0]) * u * v dS
318  spline_coeff... non-constant parameter given by a spline
319  */
320 
321  template<typename Scalar>
322  class HERMES_API DefaultJacobianFormSurf : public MatrixFormSurf < Scalar >
323  {
324  public:
325  DefaultJacobianFormSurf(int i, int j, std::string area = HERMES_ANY, Hermes1DFunction<Scalar>* coeff = nullptr,
326  GeomType gt = HERMES_PLANAR);
327  DefaultJacobianFormSurf(int i, int j, std::vector<std::string> areas, Hermes1DFunction<Scalar>* coeff = nullptr,
328  GeomType gt = HERMES_PLANAR);
329 
331 
332  virtual Scalar value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *u, Func<double> *v,
333  GeomSurf<double> *e, Func<Scalar> **ext) const;
334 
335  virtual Hermes::Ord ord(int n, double *wt, Func<Hermes::Ord> *u_ext[], Func<Hermes::Ord> *u,
337 
338  virtual MatrixFormSurf<Scalar>* clone() const;
339 
340  private:
341  Hermes1DFunction<Scalar>* coeff;
342  bool own_coeff;
343  GeomType gt;
344  };
345 
346  /* Default surface vector form \int_{area} const_coeff * function_coeff(x, y) * v dS
347  const_coeff... constant number
348  function_coeff... (generally nonconstant) function of x, y
349  */
350 
351  template<typename Scalar>
352  class HERMES_API DefaultVectorFormSurf : public VectorFormSurf < Scalar >
353  {
354  public:
355  DefaultVectorFormSurf(int i, std::string area = HERMES_ANY, Hermes2DFunction<Scalar>* coeff = nullptr,
356  GeomType gt = HERMES_PLANAR);
357  DefaultVectorFormSurf(int i, std::vector<std::string> areas, Hermes2DFunction<Scalar>* coeff = nullptr,
358  GeomType gt = HERMES_PLANAR);
359 
361 
362  virtual Scalar value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *v,
363  GeomSurf<double> *e, Func<Scalar> **ext) const;
364 
365  virtual Hermes::Ord ord(int n, double *wt, Func<Hermes::Ord> *u_ext[], Func<Hermes::Ord> *v,
366  GeomSurf<Hermes::Ord> *e, Func<Ord> **ext) const;
367 
368  virtual VectorFormSurf<Scalar>* clone() const;
369 
370  private:
371 
372  Hermes2DFunction<Scalar>* coeff;
373  bool own_coeff;
374  GeomType gt;
375  };
376 
377  /* Default surface vector form \int_{area} const_coeff * function_coeff(x, y) * u_ext[0] v dS
378  const_coeff... constant number
379  function_coeff... (generally nonconstant) function of x, y
380  */
381 
382  template<typename Scalar>
383  class HERMES_API DefaultResidualSurf : public VectorFormSurf < Scalar >
384  {
385  public:
386  DefaultResidualSurf(int i, std::string area = HERMES_ANY, Hermes2DFunction<Scalar>* coeff = nullptr,
387  GeomType gt = HERMES_PLANAR);
388  DefaultResidualSurf(int i, std::vector<std::string> areas, Hermes2DFunction<Scalar>* coeff = nullptr,
389  GeomType gt = HERMES_PLANAR);
390 
392 
393  virtual Scalar value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *v,
394  GeomSurf<double> *e, Func<Scalar> **ext) const;
395 
396  virtual Hermes::Ord ord(int n, double *wt, Func<Hermes::Ord> *u_ext[], Func<Hermes::Ord> *v,
397  GeomSurf<Hermes::Ord> *e, Func<Ord> **ext) const;
398 
399  virtual VectorFormSurf<Scalar>* clone() const;
400 
401  private:
402  Hermes2DFunction<Scalar>* coeff;
403  bool own_coeff;
404  GeomType gt;
405  };
406 
407  /* Default weak form for the Laplace equation -div(const_coeff spline_coeff(u) grad u) = 0. */
408 
409  template<typename Scalar>
410  class HERMES_API DefaultWeakFormLaplace : public WeakForm < Scalar >
411  {
412  public:
413  DefaultWeakFormLaplace(std::string area = HERMES_ANY, Hermes1DFunction<Scalar>* coeff = nullptr,
414  GeomType gt = HERMES_PLANAR);
415  };
416 
417  template<typename Scalar>
418  class HERMES_API DefaultWeakFormLaplaceLinear : public WeakForm < Scalar >
419  {
420  public:
421  DefaultWeakFormLaplaceLinear(std::string area = HERMES_ANY, GeomType gt = HERMES_PLANAR);
422  };
423 
424  /* Default weak form for the Poisson equation -div(const_coeff spline_coeff(u) grad u) - rhs = 0. */
425 
426  template<typename Scalar>
427  class HERMES_API DefaultWeakFormPoisson : public WeakForm < Scalar >
428  {
429  public:
431  DefaultWeakFormPoisson(std::string area, Hermes1DFunction<Scalar>* coeff, Hermes2DFunction<Scalar>* f, GeomType gt = HERMES_PLANAR);
432  };
433 
434  template<typename Scalar>
435  class HERMES_API DefaultWeakFormPoissonLinear : public WeakForm < Scalar >
436  {
437  public:
438  DefaultWeakFormPoissonLinear(std::string area = HERMES_ANY, Hermes2DFunction<Scalar>* f = nullptr, GeomType gt = HERMES_PLANAR);
439  };
440  };
441  }
442 }
443 #endif
Geometry - volumetric - for order calculation.
Definition: forms.h:90
Definition: adapt.h:24
Abstract, base class for vector Surface form - i.e. VectorForm, where the integration is with respect...
Definition: weakform.h:48
Abstract, base class for matrix Surface form - i.e. MatrixForm, where the integration is with respect...
Definition: weakform.h:47
SymFlag
Bilinear form symmetry flag, see WeakForm::add_matrix_form.
Definition: global.h:156
Represents the weak formulation of a PDE problem.
Definition: global.h:86
Calculated function values (from the class Function) on an element for assembling.
Definition: forms.h:214
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.
Geometry - surface - for order calculation.
Definition: forms.h:111
Abstract, base class for matrix Volumetric form - i.e. MatrixForm, where the integration is with resp...
Definition: weakform.h:45
GeomType
Geometrical type of weak forms.
Definition: global.h:148
Abstract, base class for vector Volumetric form - i.e. VectorForm, where the integration is with resp...
Definition: weakform.h:46