MFEM  v3.3
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
lininteg.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_LININTEG
13 #define MFEM_LININTEG
14 
15 #include "../config/config.hpp"
16 #include "coefficient.hpp"
17 
18 namespace mfem
19 {
20 
21 /// Abstract base class LinearFormIntegrator
23 {
24 protected:
26 
28  { IntRule = ir; }
29 
30 public:
31  /** Given a particular Finite Element and a transformation (Tr)
32  computes the element vector, elvect. */
33  virtual void AssembleRHSElementVect(const FiniteElement &el,
35  Vector &elvect) = 0;
36  virtual void AssembleRHSElementVect(const FiniteElement &el,
38  Vector &elvect);
39 
40  void SetIntRule(const IntegrationRule *ir) { IntRule = ir; }
41 
42  virtual ~LinearFormIntegrator() { }
43 };
44 
45 
46 /// Class for domain integration L(v) := (f, v)
48 {
49  Vector shape;
50  Coefficient &Q;
51  int oa, ob;
52 public:
53  /// Constructs a domain integrator with a given Coefficient
54  DomainLFIntegrator(Coefficient &QF, int a = 2, int b = 0)
55  // the old default was a = 1, b = 1
56  // for simple elliptic problems a = 2, b = -2 is ok
57  : Q(QF), oa(a), ob(b) { }
58 
59  /// Constructs a domain integrator with a given Coefficient
61  : LinearFormIntegrator(ir), Q(QF), oa(1), ob(1) { }
62 
63  /** Given a particular Finite Element and a transformation (Tr)
64  computes the element right hand side element vector, elvect. */
65  virtual void AssembleRHSElementVect(const FiniteElement &el,
67  Vector &elvect);
68 
70 };
71 
72 /// Class for boundary integration L(v) := (g, v)
74 {
75  Vector shape;
76  Coefficient &Q;
77  int oa, ob;
78 public:
79  /// Constructs a boundary integrator with a given Coefficient QG
80  BoundaryLFIntegrator(Coefficient &QG, int a = 1, int b = 1)
81  : Q(QG), oa(a), ob(b) { }
82 
83  /** Given a particular boundary Finite Element and a transformation (Tr)
84  computes the element boundary vector, elvect. */
85  virtual void AssembleRHSElementVect(const FiniteElement &el,
87  Vector &elvect);
88 
90 };
91 
92 /// Class for boundary integration \f$ L(v) = (g \cdot n, v) \f$
94 {
95  Vector shape;
97  int oa, ob;
98 public:
99  /// Constructs a boundary integrator with a given Coefficient QG
101  : Q(QG), oa(a), ob(b) { }
102 
103  virtual void AssembleRHSElementVect(const FiniteElement &el,
105  Vector &elvect);
106 
108 };
109 
110 /// Class for boundary integration \f$ L(v) = (g \cdot \tau, v) \f$ in 2D
112 {
113  Vector shape;
115  int oa, ob;
116 public:
117  /// Constructs a boundary integrator with a given Coefficient QG
119  : Q(QG), oa(a), ob(b) { }
120 
121  virtual void AssembleRHSElementVect(const FiniteElement &el,
123  Vector &elvect);
124 
126 };
127 
128 /** Class for domain integration of L(v) := (f, v), where
129  f=(f1,...,fn) and v=(v1,...,vn). */
131 {
132 private:
133  Vector shape, Qvec;
135 
136 public:
137  /// Constructs a domain integrator with a given VectorCoefficient
139 
140  /** Given a particular Finite Element and a transformation (Tr)
141  computes the element right hand side element vector, elvect. */
142  virtual void AssembleRHSElementVect(const FiniteElement &el,
144  Vector &elvect);
145 
147 };
148 
149 /** Class for boundary integration of L(v) := (g, v), where
150  f=(f1,...,fn) and v=(v1,...,vn). */
152 {
153 private:
154  Vector shape, vec;
156 
157 public:
158  /// Constructs a boundary integrator with a given VectorCoefficient QG
160 
161  /** Given a particular boundary Finite Element and a transformation (Tr)
162  computes the element boundary vector, elvect. */
163  virtual void AssembleRHSElementVect(const FiniteElement &el,
165  Vector &elvect);
166 
167  // For DG spaces
168  virtual void AssembleRHSElementVect(const FiniteElement &el,
170  Vector &elvect);
171 
173 };
174 
175 /// \f$ (f, v)_{\Omega} \f$ for VectorFiniteElements (Nedelec, Raviart-Thomas)
177 {
178 private:
179  VectorCoefficient &QF;
180  DenseMatrix vshape;
181  Vector vec;
182 
183 public:
185 
186  virtual void AssembleRHSElementVect(const FiniteElement &el,
188  Vector &elvect);
189 
191 };
192 
193 
194 /** \f$ (f, v \cdot n)_{\partial\Omega} \f$ for vector test function
195  v=(v1,...,vn) where all vi are in the same scalar FE space and f is a
196  scalar function. */
198 {
199 private:
200  double Sign;
201  Coefficient *F;
202  Vector shape, nor;
203 
204 public:
206  const IntegrationRule *ir = NULL)
207  : LinearFormIntegrator(ir), Sign(s), F(&f) { }
208 
209  virtual void AssembleRHSElementVect(const FiniteElement &el,
211  Vector &elvect);
212 
214 };
215 
216 /** Class for boundary integration of (f, v.n) for scalar coefficient f and
217  RT vector test function v. This integrator works with RT spaces defined
218  using the RT_FECollection class. */
220 {
221 private:
222  Coefficient &F;
223  Vector shape;
224 
225 public:
227 
228  virtual void AssembleRHSElementVect(const FiniteElement &el,
230  Vector &elvect);
231 
233 };
234 
235 /// Class for boundary integration \f$ L(v) = (n \times f, v) \f$
237 {
238 private:
240 
241 public:
243 
244  virtual void AssembleRHSElementVect(const FiniteElement &el,
246  Vector &elvect);
247 
249 };
250 
251 
252 /** Class for boundary integration of the linear form:
253  (alpha/2) < (u.n) f, w > - beta < |u.n| f, w >,
254  where f and u are given scalar and vector coefficients, respectively,
255  and w is the scalar test function. */
257 {
258 private:
259  Coefficient *f;
261  double alpha, beta;
262 
263  Vector shape;
264 
265 public:
267  double a, double b)
268  { f = &_f; u = &_u; alpha = a; beta = b; }
269 
270  virtual void AssembleRHSElementVect(const FiniteElement &el,
272  Vector &elvect);
273  virtual void AssembleRHSElementVect(const FiniteElement &el,
275  Vector &elvect);
276 };
277 
278 /** Boundary linear integrator for imposing non-zero Dirichlet boundary
279  conditions, to be used in conjunction with DGDiffusionIntegrator.
280  Specifically, given the Dirichlet data u_D, the linear form assembles the
281  following integrals on the boundary:
282 
283  sigma < u_D, (Q grad(v)).n > + kappa < {h^{-1} Q} u_D, v >,
284 
285  where Q is a scalar or matrix diffusion coefficient and v is the test
286  function. The parameters sigma and kappa should be the same as the ones
287  used in the DGDiffusionIntegrator. */
289 {
290 protected:
293  double sigma, kappa;
294 
295  // these are not thread-safe!
298 
299 public:
300  DGDirichletLFIntegrator(Coefficient &u, const double s, const double k)
301  : uD(&u), Q(NULL), MQ(NULL), sigma(s), kappa(k) { }
303  const double s, const double k)
304  : uD(&u), Q(&q), MQ(NULL), sigma(s), kappa(k) { }
306  const double s, const double k)
307  : uD(&u), Q(NULL), MQ(&q), sigma(s), kappa(k) { }
308 
309  virtual void AssembleRHSElementVect(const FiniteElement &el,
311  Vector &elvect);
312  virtual void AssembleRHSElementVect(const FiniteElement &el,
314  Vector &elvect);
315 };
316 
317 
318 /** Boundary linear form integrator for imposing non-zero Dirichlet boundary
319  conditions, in a DG elasticity formulation. Specifically, the linear form is
320  given by
321 
322  alpha < u_D, (lambda div(v) I + mu (grad(v) + grad(v)^T)) . n > +
323  + kappa < h^{-1} (lambda + 2 mu) u_D, v >,
324 
325  where u_D is the given Dirichlet data. The parameters alpha, kappa, lambda
326  and mu, should match the parameters with the same names used in the bilinear
327  form integrator, DGElasticityIntegrator. */
329 {
330 protected:
333  double alpha, kappa;
334 
335 #ifndef MFEM_THRAED_SAFE
344 #endif
345 
346 public:
348  Coefficient &lambda_, Coefficient &mu_,
349  double alpha_, double kappa_)
350  : uD(uD_), lambda(&lambda_), mu(&mu_), alpha(alpha_), kappa(kappa_) { }
351 
352  virtual void AssembleRHSElementVect(const FiniteElement &el,
354  Vector &elvect);
355  virtual void AssembleRHSElementVect(const FiniteElement &el,
357  Vector &elvect);
358 };
359 
360 }
361 
362 #endif
Abstract class for Finite Elements.
Definition: fe.hpp:46
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
Definition: lininteg.cpp:343
Class for domain integration L(v) := (f, v)
Definition: lininteg.hpp:47
Class for an integration rule - an Array of IntegrationPoint.
Definition: intrules.hpp:83
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
Definition: lininteg.cpp:408
VectorBoundaryLFIntegrator(VectorCoefficient &QG)
Constructs a boundary integrator with a given VectorCoefficient QG.
Definition: lininteg.hpp:159
BoundaryNormalLFIntegrator(VectorCoefficient &QG, int a=1, int b=1)
Constructs a boundary integrator with a given Coefficient QG.
Definition: lininteg.hpp:100
DGElasticityDirichletLFIntegrator(VectorCoefficient &uD_, Coefficient &lambda_, Coefficient &mu_, double alpha_, double kappa_)
Definition: lininteg.hpp:347
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
Definition: lininteg.cpp:560
virtual ~LinearFormIntegrator()
Definition: lininteg.hpp:42
Data type dense matrix using column-major storage.
Definition: densemat.hpp:22
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
Definition: lininteg.cpp:158
Class for boundary integration L(v) := (g, v)
Definition: lininteg.hpp:73
void SetIntRule(const IntegrationRule *ir)
Definition: lininteg.hpp:40
VectorFEBoundaryTangentLFIntegrator(VectorCoefficient &QG)
Definition: lininteg.hpp:242
const IntegrationRule * IntRule
Definition: lininteg.hpp:25
DGDirichletLFIntegrator(Coefficient &u, const double s, const double k)
Definition: lininteg.hpp:300
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
Definition: lininteg.cpp:57
Abstract base class LinearFormIntegrator.
Definition: lininteg.hpp:22
LinearFormIntegrator(const IntegrationRule *ir=NULL)
Definition: lininteg.hpp:27
VectorBoundaryFluxLFIntegrator(Coefficient &f, double s=1.0, const IntegrationRule *ir=NULL)
Definition: lininteg.hpp:205
Class for boundary integration .
Definition: lininteg.hpp:93
DomainLFIntegrator(Coefficient &QF, int a=2, int b=0)
Constructs a domain integrator with a given Coefficient.
Definition: lininteg.hpp:54
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
Definition: lininteg.cpp:200
VectorFEBoundaryFluxLFIntegrator(Coefficient &f)
Definition: lininteg.hpp:226
BoundaryLFIntegrator(Coefficient &QG, int a=1, int b=1)
Constructs a boundary integrator with a given Coefficient QG.
Definition: lininteg.hpp:80
MatrixCoefficient * MQ
Definition: lininteg.hpp:292
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
Definition: lininteg.cpp:118
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
Definition: lininteg.cpp:471
DomainLFIntegrator(Coefficient &QF, const IntegrationRule *ir)
Constructs a domain integrator with a given Coefficient.
Definition: lininteg.hpp:60
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)=0
Base class Coefficient that may optionally depend on time.
Definition: coefficient.hpp:31
VectorDomainLFIntegrator(VectorCoefficient &QF)
Constructs a domain integrator with a given VectorCoefficient.
Definition: lininteg.hpp:138
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
Definition: lininteg.cpp:310
VectorFEDomainLFIntegrator(VectorCoefficient &F)
Definition: lininteg.hpp:184
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
Definition: lininteg.cpp:373
BoundaryTangentialLFIntegrator(VectorCoefficient &QG, int a=1, int b=1)
Constructs a boundary integrator with a given Coefficient QG.
Definition: lininteg.hpp:118
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
Definition: lininteg.cpp:86
for VectorFiniteElements (Nedelec, Raviart-Thomas)
Definition: lininteg.hpp:176
Vector data type.
Definition: vector.hpp:36
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
Definition: lininteg.cpp:275
Class for boundary integration .
Definition: lininteg.hpp:236
DGDirichletLFIntegrator(Coefficient &u, MatrixCoefficient &q, const double s, const double k)
Definition: lininteg.hpp:305
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)
Definition: lininteg.cpp:26
Class for boundary integration in 2D.
Definition: lininteg.hpp:111
DGDirichletLFIntegrator(Coefficient &u, Coefficient &q, const double s, const double k)
Definition: lininteg.hpp:302
BoundaryFlowIntegrator(Coefficient &_f, VectorCoefficient &_u, double a, double b)
Definition: lininteg.hpp:266