MFEM  v3.3.2
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
coefficient.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_COEFFICIENT
13 #define MFEM_COEFFICIENT
14 
15 #include "../config/config.hpp"
16 #include "../linalg/linalg.hpp"
17 #include "intrules.hpp"
18 #include "eltrans.hpp"
19 
20 namespace mfem
21 {
22 
23 class Mesh;
24 
25 #ifdef MFEM_USE_MPI
26 class ParMesh;
27 #endif
28 
29 
30 /// Base class Coefficient that may optionally depend on time.
32 {
33 protected:
34  double time;
35 
36 public:
37  Coefficient() { time = 0.; }
38 
39  void SetTime(double t) { time = t; }
40  double GetTime() { return time; }
41 
42  virtual double Eval(ElementTransformation &T,
43  const IntegrationPoint &ip) = 0;
44 
46  const IntegrationPoint &ip, double t)
47  {
48  SetTime(t);
49  return Eval(T, ip);
50  }
51 
52  virtual ~Coefficient() { }
53 };
54 
55 
56 /// Subclass constant coefficient.
58 {
59 public:
60  double constant;
61 
62  /// c is value of constant function
63  explicit ConstantCoefficient(double c = 1.0) { constant=c; }
64 
65  /// Evaluate the coefficient
66  virtual double Eval(ElementTransformation &T,
67  const IntegrationPoint &ip)
68  { return (constant); }
69 };
70 
71 /// class for piecewise constant coefficient
73 {
74 private:
75  Vector constants;
76 
77 public:
78 
79  /// Constructs a piecewise constant coefficient in NumOfSubD subdomains
80  explicit PWConstCoefficient(int NumOfSubD = 0) : constants(NumOfSubD)
81  { constants = 0.0; }
82 
83  /** c should be a vector defined by attributes, so for region with
84  attribute i c[i] is the coefficient in that region */
86  { constants.SetSize(c.Size()); constants=c; }
87 
88  /// Member function to access or modify the value of the i-th constant
89  double &operator()(int i) { return constants(i-1); }
90 
91  /// Set domain constants equal to the same constant c
92  void operator=(double c) { constants = c; }
93 
94  /// Returns the number of constants
95  int GetNConst() { return constants.Size(); }
96 
97  /// Evaluate the coefficient function
98  virtual double Eval(ElementTransformation &T,
99  const IntegrationPoint &ip);
100 };
101 
102 /// class for C-function coefficient
104 {
105 protected:
106  double (*Function)(const Vector &);
107  double (*TDFunction)(const Vector &, double);
108 
109 public:
110  /// Define a time-independent coefficient from a C-function
111  FunctionCoefficient(double (*f)(const Vector &))
112  {
113  Function = f;
114  TDFunction = NULL;
115  }
116 
117  /// Define a time-dependent coefficient from a C-function
118  FunctionCoefficient(double (*tdf)(const Vector &, double))
119  {
120  Function = NULL;
121  TDFunction = tdf;
122  }
123 
124  /// (DEPRECATED) Define a time-independent coefficient from a C-function
125  FunctionCoefficient(double (*f)(Vector &))
126  {
127  Function = reinterpret_cast<double(*)(const Vector&)>(f);
128  TDFunction = NULL;
129  }
130 
131  /// (DEPRECATED) Define a time-dependent coefficient from a C-function
132  FunctionCoefficient(double (*tdf)(Vector &, double))
133  {
134  Function = NULL;
135  TDFunction = reinterpret_cast<double(*)(const Vector&,double)>(tdf);
136  }
137 
138  /// Evaluate coefficient
139  virtual double Eval(ElementTransformation &T,
140  const IntegrationPoint &ip);
141 };
142 
143 class GridFunction;
144 
145 /// Coefficient defined by a GridFunction. This coefficient is mesh dependent.
147 {
148 private:
149  GridFunction *GridF;
150  int Component;
151 
152 public:
153  /** Construct GridFunctionCoefficient from a given GridFunction, and
154  optionally specify a component to use if it is a vector GridFunction. */
156  { GridF = gf; Component = comp; }
157 
158  void SetGridFunction(GridFunction *gf) { GridF = gf; }
159  GridFunction * GetGridFunction() const { return GridF; }
160 
161  virtual double Eval(ElementTransformation &T,
162  const IntegrationPoint &ip);
163 };
164 
166 {
167 private:
168  Coefficient * Q1;
169  Coefficient * Q2;
170  double (*Transform1)(double);
171  double (*Transform2)(double,double);
172 
173 public:
174  TransformedCoefficient (Coefficient * q,double (*F)(double))
175  : Q1(q), Transform1(F) { Q2 = 0; Transform2 = 0; }
177  double (*F)(double,double))
178  : Q1(q1), Q2(q2), Transform2(F) { Transform1 = 0; }
179 
180  virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
181 };
182 
183 /// Delta function coefficient
185 {
186 protected:
187  double center[3], scale, tol;
189  int sdim;
190  double (*tdf)(double);
191 
192 public:
194  {
195  center[0] = center[1] = center[2] = 0.; scale = 1.; tol = 1e-12;
196  weight = NULL; sdim = 0; tdf = NULL;
197  }
198  DeltaCoefficient(double x, double s)
199  {
200  center[0] = x; center[1] = 0.; center[2] = 0.; scale = s; tol = 1e-12;
201  weight = NULL; sdim = 1; tdf = NULL;
202  }
203  DeltaCoefficient(double x, double y, double s)
204  {
205  center[0] = x; center[1] = y; center[2] = 0.; scale = s; tol = 1e-12;
206  weight = NULL; sdim = 2; tdf = NULL;
207  }
208  DeltaCoefficient(double x, double y, double z, double s)
209  {
210  center[0] = x; center[1] = y; center[2] = z; scale = s; tol = 1e-12;
211  weight = NULL; sdim = 3; tdf = NULL;
212  }
213  void SetDeltaCenter(const Vector& center);
214  void SetScale(double _s) { scale = _s; }
215  /// Set a time-dependent function that multiplies the Scale().
216  void SetFunction(double (*f)(double)) { tdf = f; }
217  /** @brief Set the tolerance used during projection onto GridFunction to
218  identifying the Mesh vertex where the Center() of the delta function
219  lies. */
220  void SetTol(double _tol) { tol = _tol; }
221  /// Set a weight Coefficient that multiplies the DeltaCoefficient.
222  /** The weight Coefficient multiplies the value returned by EvalDelta() but
223  not the value returned by Scale().
224  The weight Coefficient is also used as the L2-weight function when
225  projecting the DeltaCoefficient onto a GridFunction, so that the weighted
226  integral of the projection is exactly equal to the Scale(). */
227  void SetWeight(Coefficient *w) { weight = w; }
228  const double *Center() { return center; }
229  /** @brief Return the scale set by SetScale() multiplied by the
230  time-dependent function specified by SetFunction(), if set. */
231  double Scale() { return tdf ? (*tdf)(GetTime())*scale : scale; }
232  /// See SetTol() for description of the tolerance parameter.
233  double Tol() { return tol; }
234  /// See SetWeight() for description of the weight Coefficient.
235  Coefficient *Weight() { return weight; }
237  /// Return the Scale() multiplied by the weight Coefficient, if any.
238  double EvalDelta(ElementTransformation &T, const IntegrationPoint &ip);
239  /** @brief A DeltaFunction cannot be evaluated. Calling this method will
240  cause an MFEM error, terminating the application. */
241  virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
242  { mfem_error("DeltaCoefficient::Eval"); return 0.; }
243  virtual ~DeltaCoefficient() { delete weight; }
244 };
245 
246 /// Coefficient defined on a subset of domain or boundary attributes
248 {
249 private:
250  Coefficient *c;
251  Array<int> active_attr;
252 
253 public:
255  { c = &_c; attr.Copy(active_attr); }
256 
257  virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
258  { return active_attr[T.Attribute-1] ? c->Eval(T, ip, GetTime()) : 0.0; }
259 };
260 
262 {
263 protected:
264  int vdim;
265  double time;
266 
267 public:
268  VectorCoefficient(int vd) { vdim = vd; time = 0.; }
269 
270  void SetTime(double t) { time = t; }
271  double GetTime() { return time; }
272 
273  /// Returns dimension of the vector.
274  int GetVDim() { return vdim; }
275 
276  virtual void Eval(Vector &V, ElementTransformation &T,
277  const IntegrationPoint &ip) = 0;
278 
279  // General implementation using the Eval method for one IntegrationPoint.
280  // Can be overloaded for more efficient implementation.
281  virtual void Eval(DenseMatrix &M, ElementTransformation &T,
282  const IntegrationRule &ir);
283 
284  virtual ~VectorCoefficient() { }
285 };
286 
288 {
289 private:
290  Vector vec;
291 public:
293  : VectorCoefficient(v.Size()), vec(v) { }
295  virtual void Eval(Vector &V, ElementTransformation &T,
296  const IntegrationPoint &ip) { V = vec; }
297 };
298 
300 {
301 private:
302  void (*Function)(const Vector &, Vector &);
303  void (*TDFunction)(const Vector &, double, Vector &);
304  Coefficient *Q;
305 
306 public:
307  /// Construct a time-independent vector coefficient from a C-function
308  VectorFunctionCoefficient(int dim, void (*F)(const Vector &, Vector &),
309  Coefficient *q = NULL)
310  : VectorCoefficient(dim), Q(q)
311  {
312  Function = F;
313  TDFunction = NULL;
314  }
315 
316  /// Construct a time-dependent vector coefficient from a C-function
318  void (*TDF)(const Vector &, double, Vector &),
319  Coefficient *q = NULL)
320  : VectorCoefficient(dim), Q(q)
321  {
322  Function = NULL;
323  TDFunction = TDF;
324  }
325 
327  virtual void Eval(Vector &V, ElementTransformation &T,
328  const IntegrationPoint &ip);
329 
331 };
332 
333 /// Vector coefficient defined by an array of scalar coefficients.
335 {
336 private:
337  Array<Coefficient*> Coeff;
338 
339 public:
340  /// Construct vector of dim coefficients.
341  explicit VectorArrayCoefficient(int dim);
342 
343  /// Returns i'th coefficient.
344  Coefficient* GetCoeff(int i) { return Coeff[i]; }
345 
346  Coefficient **GetCoeffs() { return Coeff; }
347 
348  /// Sets coefficient in the vector.
349  void Set(int i, Coefficient *c) { delete Coeff[i]; Coeff[i] = c; }
350 
351  /// Evaluates i'th component of the vector.
352  double Eval(int i, ElementTransformation &T, const IntegrationPoint &ip)
353  { return Coeff[i] ? Coeff[i]->Eval(T, ip, GetTime()) : 0.0; }
354 
356  virtual void Eval(Vector &V, ElementTransformation &T,
357  const IntegrationPoint &ip);
358 
359  /// Destroys vector coefficient.
360  virtual ~VectorArrayCoefficient();
361 };
362 
363 /// Vector coefficient defined by a vector GridFunction
365 {
366 private:
367  GridFunction *GridFunc;
368 
369 public:
371 
372  void SetGridFunction(GridFunction *gf) { GridFunc = gf; }
373  GridFunction * GetGridFunction() const { return GridFunc; }
374 
375  virtual void Eval(Vector &V, ElementTransformation &T,
376  const IntegrationPoint &ip);
377 
378  virtual void Eval(DenseMatrix &M, ElementTransformation &T,
379  const IntegrationRule &ir);
380 
382 };
383 
384 /// VectorDeltaCoefficient: DeltaCoefficient with a direction
386 {
387 protected:
390 
391 public:
393  : VectorCoefficient(_vdim), dir(_vdim), d() { }
395  : VectorCoefficient(_dir.Size()), dir(_dir), d() { }
396  VectorDeltaCoefficient(const Vector& _dir, double x, double s)
397  : VectorCoefficient(_dir.Size()), dir(_dir), d(x,s) { }
398  VectorDeltaCoefficient(const Vector& _dir, double x, double y, double s)
399  : VectorCoefficient(_dir.Size()), dir(_dir), d(x,y,s) { }
400  VectorDeltaCoefficient(const Vector& _dir, double x, double y, double z,
401  double s)
402  : VectorCoefficient(_dir.Size()), dir(_dir), d(x,y,z,s) { }
403 
404  /// Replace the associated DeltaCoeficient with a new DeltaCoeficient.
405  /** The new DeltaCoeficient cannot have a specified weight Coefficient, i.e.
406  DeltaCoeficient::Weight() should return NULL. */
407  void SetDeltaCoefficient(const DeltaCoefficient& _d) { d = _d; }
408  /// Return the associated scalar DeltaCoefficient.
410  void SetDirection(const Vector& _d);
411 
412  void GetDeltaCenter(Vector& center) { d.GetDeltaCenter(center); }
413  /** @brief Return the specified direction vector multiplied by the value
414  returned by DeltaCoefficient::EvalDelta() of the associated scalar
415  DeltaCoefficient. */
417  const IntegrationPoint &ip);
418  /** @brief A VectorDeltaFunction cannot be evaluated. Calling this method
419  will cause an MFEM error, terminating the application. */
420  virtual void Eval(Vector &V, ElementTransformation &T,
421  const IntegrationPoint &ip)
422  { mfem_error("VectorDeltaCoefficient::Eval"); }
424 };
425 
426 /// VectorCoefficient defined on a subset of domain or boundary attributes
428 {
429 private:
431  Array<int> active_attr;
432 
433 public:
435  : VectorCoefficient(vc.GetVDim())
436  { c = &vc; attr.Copy(active_attr); }
437 
438  virtual void Eval(Vector &V, ElementTransformation &T,
439  const IntegrationPoint &ip);
440 
441  virtual void Eval(DenseMatrix &M, ElementTransformation &T,
442  const IntegrationRule &ir);
443 };
444 
445 
447 {
448 protected:
449  int height, width;
450  double time;
451 
452 public:
453  explicit MatrixCoefficient(int dim) { height = width = dim; time = 0.; }
454 
455  MatrixCoefficient(int h, int w) : height(h), width(w), time(0.) { }
456 
457  void SetTime(double t) { time = t; }
458  double GetTime() { return time; }
459 
460  int GetHeight() const { return height; }
461  int GetWidth() const { return width; }
462  // For backward compatibility
463  int GetVDim() const { return width; }
464 
465  virtual void Eval(DenseMatrix &K, ElementTransformation &T,
466  const IntegrationPoint &ip) = 0;
467 
468  virtual ~MatrixCoefficient() { }
469 };
470 
472 {
473 private:
474  DenseMatrix mat;
475 public:
477  : MatrixCoefficient(m.Height(), m.Width()), mat(m) { }
480  const IntegrationPoint &ip) { M = mat; }
481 };
482 
484 {
485 private:
486  void (*Function)(const Vector &, DenseMatrix &);
487  void (*TDFunction)(const Vector &, double, DenseMatrix &);
488  Coefficient *Q;
489  DenseMatrix mat;
490 
491 public:
492  /// Construct a time-independent square matrix coefficient from a C-function
493  MatrixFunctionCoefficient(int dim, void (*F)(const Vector &, DenseMatrix &),
494  Coefficient *q = NULL)
495  : MatrixCoefficient(dim), Q(q)
496  {
497  Function = F;
498  TDFunction = NULL;
499  mat.SetSize(0);
500  }
501 
502  /// Construct a constant matrix coefficient times a scalar Coefficient
504  : MatrixCoefficient(m.Height(), m.Width()), Q(&q)
505  {
506  Function = NULL;
507  TDFunction = NULL;
508  mat = m;
509  }
510 
511  /// Construct a time-dependent square matrix coefficient from a C-function
513  void (*TDF)(const Vector &, double, DenseMatrix &),
514  Coefficient *q = NULL)
515  : MatrixCoefficient(dim), Q(q)
516  {
517  Function = NULL;
518  TDFunction = TDF;
519  mat.SetSize(0);
520  }
521 
522  virtual void Eval(DenseMatrix &K, ElementTransformation &T,
523  const IntegrationPoint &ip);
524 
526 };
527 
529 {
530 private:
531  Array<Coefficient *> Coeff;
532 
533 public:
534 
535  explicit MatrixArrayCoefficient (int dim);
536 
537  Coefficient* GetCoeff (int i, int j) { return Coeff[i*width+j]; }
538 
539  void Set(int i, int j, Coefficient * c) { delete Coeff[i*width+j]; Coeff[i*width+j] = c; }
540 
541  double Eval(int i, int j, ElementTransformation &T, const IntegrationPoint &ip)
542  { return Coeff[i*width+j] ? Coeff[i*width+j] -> Eval(T, ip, GetTime()) : 0.0; }
543 
544  virtual void Eval(DenseMatrix &K, ElementTransformation &T,
545  const IntegrationPoint &ip);
546 
547  virtual ~MatrixArrayCoefficient();
548 };
549 
550 /// MatrixCoefficient defined on a subset of domain or boundary attributes
552 {
553 private:
555  Array<int> active_attr;
556 
557 public:
559  : MatrixCoefficient(mc.GetHeight(), mc.GetWidth())
560  { c = &mc; attr.Copy(active_attr); }
561 
562  virtual void Eval(DenseMatrix &K, ElementTransformation &T,
563  const IntegrationPoint &ip);
564 };
565 
566 /** Compute the Lp norm of a function f.
567  \f$ \| f \|_{Lp} = ( \int_\Omega | f |^p d\Omega)^{1/p} \f$ */
568 double ComputeLpNorm(double p, Coefficient &coeff, Mesh &mesh,
569  const IntegrationRule *irs[]);
570 
571 /** Compute the Lp norm of a vector function f = {f_i}_i=1...N.
572  \f$ \| f \|_{Lp} = ( \sum_i \| f_i \|_{Lp}^p )^{1/p} \f$ */
573 double ComputeLpNorm(double p, VectorCoefficient &coeff, Mesh &mesh,
574  const IntegrationRule *irs[]);
575 
576 #ifdef MFEM_USE_MPI
577 /** Compute the global Lp norm of a function f.
578  \f$ \| f \|_{Lp} = ( \int_\Omega | f |^p d\Omega)^{1/p} \f$ */
579 double ComputeGlobalLpNorm(double p, Coefficient &coeff, ParMesh &pmesh,
580  const IntegrationRule *irs[]);
581 
582 /** Compute the global Lp norm of a vector function f = {f_i}_i=1...N.
583  \f$ \| f \|_{Lp} = ( \sum_i \| f_i \|_{Lp}^p )^{1/p} \f$ */
584 double ComputeGlobalLpNorm(double p, VectorCoefficient &coeff, ParMesh &pmesh,
585  const IntegrationRule *irs[]);
586 #endif
587 
588 }
589 
590 #endif
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
double Eval(ElementTransformation &T, const IntegrationPoint &ip, double t)
Definition: coefficient.hpp:45
void GetDeltaCenter(Vector &center)
void SetTol(double _tol)
Set the tolerance used during projection onto GridFunction to identifying the Mesh vertex where the C...
Class for an integration rule - an Array of IntegrationPoint.
Definition: intrules.hpp:83
Vector coefficient defined by an array of scalar coefficients.
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:27
GridFunction * GetGridFunction() const
void SetWeight(Coefficient *w)
Set a weight Coefficient that multiplies the DeltaCoefficient.
Subclass constant coefficient.
Definition: coefficient.hpp:57
VectorGridFunctionCoefficient(GridFunction *gf)
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)=0
double(* tdf)(double)
FunctionCoefficient(double(*tdf)(const Vector &, double))
Define a time-dependent coefficient from a C-function.
void SetSize(int s)
Resize the vector to size s.
Definition: vector.hpp:320
double Eval(int i, ElementTransformation &T, const IntegrationPoint &ip)
Evaluates i&#39;th component of the vector.
void SetDeltaCenter(const Vector &center)
Definition: coefficient.cpp:69
double Scale()
Return the scale set by SetScale() multiplied by the time-dependent function specified by SetFunction...
FunctionCoefficient(double(*f)(Vector &))
(DEPRECATED) Define a time-independent coefficient from a C-function
virtual void Eval(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip)=0
void Copy(Array &copy) const
Create a copy of the current array.
Definition: array.hpp:161
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
double & operator()(int i)
Member function to access or modify the value of the i-th constant.
Definition: coefficient.hpp:89
Data type dense matrix using column-major storage.
Definition: densemat.hpp:23
Delta function coefficient.
int Size() const
Returns the size of the vector.
Definition: vector.hpp:113
void SetFunction(double(*f)(double))
Set a time-dependent function that multiplies the Scale().
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
double Tol()
See SetTol() for description of the tolerance parameter.
GridFunction * GetGridFunction() const
void Set(int i, int j, Coefficient *c)
VectorFunctionCoefficient(int dim, void(*TDF)(const Vector &, double, Vector &), Coefficient *q=NULL)
Construct a time-dependent vector coefficient from a C-function.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Definition: coefficient.cpp:55
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
A DeltaFunction cannot be evaluated. Calling this method will cause an MFEM error, terminating the application.
void SetTime(double t)
VectorDeltaCoefficient(const Vector &_dir, double x, double y, double s)
DeltaCoefficient(double x, double y, double z, double s)
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate coefficient.
Definition: coefficient.cpp:31
DeltaCoefficient & GetDeltaCoefficient()
Return the associated scalar DeltaCoefficient.
DeltaCoefficient(double x, double s)
double(* Function)(const Vector &)
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
A VectorDeltaFunction cannot be evaluated. Calling this method will cause an MFEM error...
virtual void Eval(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip)
Coefficient * GetCoeff(int i, int j)
double Eval(int i, int j, ElementTransformation &T, const IntegrationPoint &ip)
VectorCoefficient defined on a subset of domain or boundary attributes.
MatrixFunctionCoefficient(int dim, void(*F)(const Vector &, DenseMatrix &), Coefficient *q=NULL)
Construct a time-independent square matrix coefficient from a C-function.
int dim
Definition: ex3.cpp:47
double ComputeLpNorm(double p, Coefficient &coeff, Mesh &mesh, const IntegrationRule *irs[])
VectorConstantCoefficient(const Vector &v)
ConstantCoefficient(double c=1.0)
c is value of constant function
Definition: coefficient.hpp:63
const double * Center()
Coefficient defined on a subset of domain or boundary attributes.
Coefficient * Weight()
See SetWeight() for description of the weight Coefficient.
VectorDeltaCoefficient(const Vector &_dir)
MatrixRestrictedCoefficient(MatrixCoefficient &mc, Array< int > &attr)
void SetDirection(const Vector &_d)
VectorDeltaCoefficient(const Vector &_dir, double x, double y, double z, double s)
MatrixFunctionCoefficient(int dim, void(*TDF)(const Vector &, double, DenseMatrix &), Coefficient *q=NULL)
Construct a time-dependent square matrix coefficient from a C-function.
void SetDeltaCoefficient(const DeltaCoefficient &_d)
Replace the associated DeltaCoeficient with a new DeltaCoeficient.
virtual ~VectorArrayCoefficient()
Destroys vector coefficient.
virtual void Eval(DenseMatrix &M, ElementTransformation &T, const IntegrationPoint &ip)
int GetVDim()
Returns dimension of the vector.
void SetTime(double t)
Definition: coefficient.hpp:39
void operator=(double c)
Set domain constants equal to the same constant c.
Definition: coefficient.hpp:92
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient.
Definition: coefficient.hpp:66
void GetDeltaCenter(Vector &center)
Definition: coefficient.cpp:77
MatrixFunctionCoefficient(const DenseMatrix &m, Coefficient &q)
Construct a constant matrix coefficient times a scalar Coefficient.
Base class Coefficient that may optionally depend on time.
Definition: coefficient.hpp:31
virtual ~Coefficient()
Definition: coefficient.hpp:52
void mfem_error(const char *msg)
Definition: error.cpp:107
FunctionCoefficient(double(*f)(const Vector &))
Define a time-independent coefficient from a C-function.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient function.
Definition: coefficient.cpp:24
Coefficient * GetCoeff(int i)
Returns i&#39;th coefficient.
void SetTime(double t)
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
void EvalDelta(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Return the specified direction vector multiplied by the value returned by DeltaCoefficient::EvalDelta...
double ComputeGlobalLpNorm(double p, Coefficient &coeff, ParMesh &pmesh, const IntegrationRule *irs[])
void SetGridFunction(GridFunction *gf)
PWConstCoefficient(int NumOfSubD=0)
Constructs a piecewise constant coefficient in NumOfSubD subdomains.
Definition: coefficient.hpp:80
double EvalDelta(ElementTransformation &T, const IntegrationPoint &ip)
Return the Scale() multiplied by the weight Coefficient, if any.
Definition: coefficient.cpp:83
MatrixCoefficient defined on a subset of domain or boundary attributes.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Definition: coefficient.cpp:49
void SetGridFunction(GridFunction *gf)
VectorDeltaCoefficient: DeltaCoefficient with a direction.
class for piecewise constant coefficient
Definition: coefficient.hpp:72
void SetScale(double _s)
Class for integration point with weight.
Definition: intrules.hpp:25
FunctionCoefficient(double(*tdf)(Vector &, double))
(DEPRECATED) Define a time-dependent coefficient from a C-function
TransformedCoefficient(Coefficient *q, double(*F)(double))
int GetNConst()
Returns the number of constants.
Definition: coefficient.hpp:95
VectorDeltaCoefficient(const Vector &_dir, double x, double s)
DeltaCoefficient(double x, double y, double s)
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
VectorArrayCoefficient(int dim)
Construct vector of dim coefficients.
VectorFunctionCoefficient(int dim, void(*F)(const Vector &, Vector &), Coefficient *q=NULL)
Construct a time-independent vector coefficient from a C-function.
class for C-function coefficient
Vector data type.
Definition: vector.hpp:41
TransformedCoefficient(Coefficient *q1, Coefficient *q2, double(*F)(double, double))
Vector coefficient defined by a vector GridFunction.
VectorRestrictedCoefficient(VectorCoefficient &vc, Array< int > &attr)
MatrixConstantCoefficient(const DenseMatrix &m)
virtual void Eval(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip)
GridFunctionCoefficient(GridFunction *gf, int comp=1)
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
Definition: densemat.hpp:86
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
double(* TDFunction)(const Vector &, double)
MatrixCoefficient(int h, int w)
void Set(int i, Coefficient *c)
Sets coefficient in the vector.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
RestrictedCoefficient(Coefficient &_c, Array< int > &attr)