28 return (constants(att-1));
41 return Function(transip);
45 return TDFunction(transip, GetTime());
52 return GridF -> GetValue (T, ip, Component);
60 return (*Transform2)(Q1->Eval(T, ip, GetTime()),
61 Q2->Eval(T, ip, GetTime()));
65 return (*Transform1)(Q1->Eval(T, ip, GetTime()));
71 MFEM_VERIFY(vcenter.
Size() <= 3,
72 "SetDeltaCenter::Maximum number of dim supported is 3")
73 for (
int i = 0; i < vcenter.
Size(); i++) { center[i] = vcenter[i]; }
74 sdim = vcenter.
Size();
87 return weight ? weight->Eval(T, ip, GetTime())*w : w;
115 Function(transip, V);
119 TDFunction(transip, GetTime(), V);
123 V *= Q->Eval(T, ip, GetTime());
130 for (
int i = 0; i <
dim; i++)
139 if (ownCoeff[i]) {
delete Coeff[i]; }
146 for (
int i = 0; i <
vdim; i++)
148 if (ownCoeff[i]) {
delete Coeff[i]; }
156 for (
int i = 0; i <
vdim; i++)
158 V(i) = this->
Eval(i, T, ip);
189 gf -> FESpace() ->
GetMesh() -> SpaceDimension() : 0)
197 gf -> FESpace() ->
GetMesh() -> SpaceDimension() : 0;
223 int sdim = gf -> FESpace() ->
GetMesh() -> SpaceDimension();
224 MFEM_VERIFY(sdim == 2 || sdim == 3,
225 "CurlGridFunctionCoefficient "
226 "only defind for spaces of dimension 2 or 3.");
229 vdim = (gf) ? (2 * gf -> FESpace() ->
GetMesh() -> SpaceDimension() - 3) : 0;
307 "MatrixFunctionCoefficient is not symmetric");
311 SymmFunction(transip, Ksym);
315 for (
int i=0; i<
height; ++i)
317 for (
int j=i; j<
width; ++j)
319 const double Kij = Ksym[j - i + os];
321 if (j != i) { K(j,i) = Kij; }
331 Function(transip, K);
335 TDFunction(transip,
GetTime(), K);
354 "MatrixFunctionCoefficient is not symmetric");
365 SymmFunction(transip, K);
387 Function(transip, K);
391 TDFunction(transip,
GetTime(), K);
418 if (ownCoeff[i*
width+j]) {
delete Coeff[i*
width+j]; }
419 Coeff[i*
width+j] = c;
420 ownCoeff[i*
width+j] = own;
427 if (ownCoeff[i]) {
delete Coeff[i]; }
434 for (
int i = 0; i <
height; i++)
436 for (
int j = 0; j <
width; j++)
438 K(i,j) = this->
Eval(i, j, T, ip);
463 "InnerProductCoefficient: "
464 "Arguments have incompatible dimensions.");
477 :
a(&A),
b(&B), va(A.GetVDim()), vb(B.GetVDim())
480 "VectorRotProductCoefficient: "
481 "Arguments must have dimension equal to two.");
489 return va[0] * vb[1] - va[1] * vb[0];
493 :
a(&A), ma(A.GetHeight(), A.GetWidth())
496 "DeterminantCoefficient: "
497 "Argument must be a square matrix.");
509 ACoef(NULL), BCoef(NULL),
511 alphaCoef(NULL), betaCoef(NULL),
512 alpha(1.0), beta(1.0)
519 double alpha_,
double beta_)
521 ACoef(&A_), BCoef(&B_),
522 A(A_.GetVDim()), B(A_.GetVDim()),
523 alphaCoef(NULL), betaCoef(NULL),
524 alpha(alpha_), beta(beta_)
527 "VectorSumCoefficient: "
528 "Arguments must have the same dimension.");
536 ACoef(&A_), BCoef(&B_),
541 alpha(0.0), beta(0.0)
544 "VectorSumCoefficient: "
545 "Arguments must have the same dimension.");
552 if ( ACoef) { ACoef->
Eval(A, T, ip); }
553 if ( BCoef) { BCoef->
Eval(B, T, ip); }
554 if (alphaCoef) { alpha = alphaCoef->
Eval(T, ip); }
555 if ( betaCoef) { beta = betaCoef->
Eval(T, ip); }
556 add(alpha, A, beta, B, V);
574 double sa = (a == NULL) ? aConst : a->
Eval(T, ip);
589 V *= (nv > tol) ? (1.0/nv) : 0.0;
598 "VectorCrossProductCoefficient: "
599 "Arguments must have dimension equal to three.");
608 V[0] = va[1] * vb[2] - va[2] * vb[1];
609 V[1] = va[2] * vb[0] - va[0] * vb[2];
610 V[2] = va[0] * vb[1] - va[1] * vb[0];
616 ma(A.GetHeight(), A.GetWidth()), vb(B.GetVDim())
619 "MatrixVectorProductCoefficient: "
620 "Arguments have incompatible dimensions.");
637 for (
int d=0; d<dim; d++) { M(d,d) = 1.0; }
642 double alpha_,
double beta_)
644 a(&A),
b(&B),
alpha(alpha_), beta(beta_),
645 ma(A.GetHeight(), A.GetWidth())
648 "MatrixSumCoefficient: "
649 "Arguments must have the same dimensions.");
656 if ( beta != 1.0 ) { M *= beta; }
677 double sa = (a == NULL) ? aConst : a->
Eval(T, ip);
698 "InverseMatrixCoefficient: "
699 "Argument must be a square matrix.");
713 va(A.GetVDim()), vb(B.GetVDim())
722 for (
int i=0; i<va.
Size(); i++)
724 for (
int j=0; j<vb.
Size(); j++)
726 M(i, j) = va[i] * vb[j];
749 for (
int i=0; i<vk.Size(); i++)
752 for (
int j=0; j<vk.Size(); j++)
754 M(i, j) -= vk[i] * vk[j];
757 M *= ((a == NULL ) ? aConst : a->
Eval(T, ip) );
766 for (
int i = 0; i < mesh.
GetNE(); i++)
774 double val = fabs(coeff.
Eval(*tr, ip));
800 for (
int i = 0; i < mesh.
GetNE(); i++)
808 coeff.
Eval(vval, *tr, ip);
811 for (
int idim(0); idim < vdim; ++idim)
813 norm += ip.
weight * tr->
Weight() * pow(fabs( vval(idim) ), p);
818 for (
int idim(0); idim < vdim; ++idim)
820 val = fabs(vval(idim));
836 double norm =
LpNormLoop(p, coeff, mesh, irs);
843 norm = -pow(-norm, 1.0/p);
847 norm = pow(norm, 1.0/p);
857 double norm =
LpNormLoop(p, coeff, mesh, irs);
864 norm = -pow(-norm, 1.0/p);
868 norm = pow(norm, 1.0/p);
879 double loc_norm =
LpNormLoop(p, coeff, pmesh, irs);
880 double glob_norm = 0;
882 MPI_Comm comm = pmesh.
GetComm();
886 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_SUM, comm);
891 glob_norm = -pow(-glob_norm, 1.0/p);
895 glob_norm = pow(glob_norm, 1.0/p);
900 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_MAX, comm);
909 double loc_norm =
LpNormLoop(p, coeff, pmesh, irs);
910 double glob_norm = 0;
912 MPI_Comm comm = pmesh.
GetComm();
916 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_SUM, comm);
921 glob_norm = -pow(-glob_norm, 1.0/p);
925 glob_norm = pow(glob_norm, 1.0/p);
930 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_MAX, comm);
943 MFEM_VERIFY(index_ >= 0,
"Index must be >= 0");
944 MFEM_VERIFY(index_ < QuadF.
GetVDim(),
945 "Index must be < QuadratureFunction length");
948 MFEM_VERIFY(length_ > 0,
"Length must be > 0");
949 MFEM_VERIFY(length_ <= QuadF.
GetVDim() - index,
950 "Length must be <= (QuadratureFunction length - index)");
970 for (
int i = 0; i <
vdim; i++)
972 V(i) = temp(index + i);
982 MFEM_VERIFY(qf.
GetVDim() == 1,
"QuadratureFunction's vdim must be 1");
int GetNPoints() const
Returns the number of the points in the integration rule.
int GetVDim() const
Get the vector dimension.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the vector coefficient at ip.
Class for an integration rule - an Array of IntegrationPoint.
void GetVectorValues(int i, const IntegrationRule &ir, DenseMatrix &vals, DenseMatrix &tr) const
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the vector coefficient at ip.
Class for grid function - Vector with associated FE space.
const GridFunction * GridFunc
void Set(int i, int j, Coefficient *c, bool own=true)
Set the coefficient located at (i,j) in the matrix. By default by default this will take ownership of...
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient at ip.
const GridFunction * GridFunc
Base class for vector Coefficients that optionally depend on time and space.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the vector curl coefficient at ip.
TransposeMatrixCoefficient(MatrixCoefficient &A)
Construct with the matrix coefficient. Result is .
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the vector coefficient in the element described by T at the point ip, storing the result in ...
VectorCrossProductCoefficient(VectorCoefficient &A, VectorCoefficient &B)
Construct with the two coefficients. Result is A x B.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient at ip.
virtual void GetVectorValue(int i, const IntegrationPoint &ip, Vector &val) const
NormalizedVectorCoefficient(VectorCoefficient &A, double tol=1e-6)
Return a vector normalized to a length of one.
void SetSize(int s)
Change the size of the DenseSymmetricMatrix to s x s.
void SetSize(int s)
Resize the vector to size s.
MatrixVectorProductCoefficient(MatrixCoefficient &A, VectorCoefficient &B)
Constructor with two coefficients. Result is A*B.
double Eval(int i, ElementTransformation &T, const IntegrationPoint &ip)
void SetDeltaCenter(const Vector ¢er)
Set the center location of the delta function.
double GetTime()
Get the time for time dependent coefficients.
Element::Type GetElementType(int i) const
Returns the type of element i.
double Norml2() const
Returns the l2 norm of the vector.
virtual void Eval(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the matrix coefficient in the element described by T at the point ip, storing the result in ...
Data type dense matrix using column-major storage.
int Size() const
Returns the size of the vector.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the vector coefficient at ip.
CurlGridFunctionCoefficient(const GridFunction *gf)
Construct the coefficient with a vector grid function gf. The grid function is not owned by the coeff...
int GetNE() const
Returns number of elements.
GradientGridFunctionCoefficient(const GridFunction *gf)
Construct the coefficient with a scalar grid function gf. The grid function is not owned by the coeff...
CrossCrossCoefficient(double A, VectorCoefficient &K)
virtual void Eval(DenseMatrix &M, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the matrix coefficient at ip.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient at ip.
virtual ~MatrixArrayCoefficient()
void SetTime(double t)
Set the time for time dependent coefficients.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient at ip.
void add(const Vector &v1, const Vector &v2, Vector &v)
DeterminantCoefficient(MatrixCoefficient &A)
Construct with the matrix.
ScalarMatrixProductCoefficient(double A, MatrixCoefficient &B)
Constructor with one coefficient. Result is A*B.
virtual void Eval(DenseMatrix &M, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the matrix coefficient at ip.
virtual void Eval(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the matrix coefficient at ip.
int GetHeight() const
Get the height of the matrix.
double Eval(int i, int j, ElementTransformation &T, const IntegrationPoint &ip)
InnerProductCoefficient(VectorCoefficient &A, VectorCoefficient &B)
Construct with the two vector coefficients. Result is .
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
double ComputeLpNorm(double p, Coefficient &coeff, Mesh &mesh, const IntegrationRule *irs[])
Compute the Lp norm of a function f. .
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient in the element described by T at the point ip.
double GetTime()
Get the time for time dependent coefficients.
double LpNormLoop(double p, Coefficient &coeff, Mesh &mesh, const IntegrationRule *irs[])
QuadratureFunctionCoefficient(QuadratureFunction &qf)
Constructor with a quadrature function as input.
void Add(const double c, const DenseMatrix &A)
Adds the matrix A multiplied by the number c to the matrix.
OuterProductCoefficient(VectorCoefficient &A, VectorCoefficient &B)
Construct with two vector coefficients. Result is .
void SetGridFunction(const GridFunction *gf)
Set the vector grid function.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient at ip.
void Invert()
Replaces the current matrix with its inverse.
void Set(int i, Coefficient *c, bool own=true)
Sets coefficient in the vector.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient at ip.
virtual ~VectorArrayCoefficient()
Destroys vector coefficient.
int GetVDim()
Returns dimension of the vector.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient at ip.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the vector coefficient in the element described by T at the point ip, storing the result in ...
const GridFunction * GridFunc
virtual const double * HostRead() const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), false).
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the determinant coefficient at ip.
void SetComponent(int index_, int length_)
void SetTime(double t)
Set the time for time dependent coefficients.
void GetDeltaCenter(Vector ¢er)
Write the center of the delta function into center.
virtual void Eval(DenseMatrix &M, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the matrix coefficient at ip.
double p(const Vector &x, double t)
void SetGridFunction(const GridFunction *gf)
Set the scalar grid function.
void Transpose()
(*this) = (*this)^t
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
VectorQuadratureFunctionCoefficient(QuadratureFunction &qf)
Constructor with a quadrature function as input.
virtual void Eval(DenseMatrix &M, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the matrix coefficient at ip.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
Base class for Matrix Coefficients that optionally depend on time and space.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient.
void GetColumnReference(int c, Vector &col)
void SetTime(double t)
Set the time for time dependent coefficients.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the vector coefficient at ip.
virtual void EvalDelta(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Return the specified direction vector multiplied by the value returned by DeltaCoefficient::EvalDelta...
const GridFunction * GridFunc
double ComputeGlobalLpNorm(double p, Coefficient &coeff, ParMesh &pmesh, const IntegrationRule *irs[])
Compute the global Lp norm of a function f. .
double GetDivergence(ElementTransformation &tr) const
virtual double EvalDelta(ElementTransformation &T, const IntegrationPoint &ip)
The value of the function assuming we are evaluating at the delta center.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient at ip.
MatrixArrayCoefficient(int dim)
Construct a coefficient matrix of dimensions dim * dim. The actual coefficients still need to be adde...
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the gradient vector coefficient at ip.
Class for integration point with weight.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the scalar divergence coefficient at ip.
double GetTime()
Get the time for time dependent coefficients.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
DivergenceGridFunctionCoefficient(const GridFunction *gf)
Construct the coefficient with a vector grid function gf. The grid function is not owned by the coeff...
virtual void Eval(DenseMatrix &M, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the matrix coefficient at ip.
void SetDirection(const Vector &d_)
void GetElementValues(int idx, Vector &values)
Return all values associated with mesh element idx in a Vector.
VectorSumCoefficient(int dim)
void SetGridFunction(const GridFunction *gf)
Set the grid function for this coefficient. Also sets the Vector dimension to match that of the gf...
int index(int i, int j, int nx, int ny)
void GetGradients(ElementTransformation &tr, const IntegrationRule &ir, DenseMatrix &grad) const
virtual void Eval(DenseMatrix &M, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the matrix coefficient at ip.
double infinity()
Define a shortcut for std::numeric_limits<double>::infinity()
MatrixSumCoefficient(MatrixCoefficient &A, MatrixCoefficient &B, double alpha_=1.0, double beta_=1.0)
Construct with the two coefficients. Result is alpha_ * A + beta_ * B.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
VectorArrayCoefficient(int dim)
Construct vector of dim coefficients. The actual coefficients still need to be added with Set()...
virtual void Eval(DenseSymmetricMatrix &K, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the matrix coefficient at ip.
void GetCurl(ElementTransformation &tr, Vector &curl) const
void Mult(const double *x, double *y) const
Matrix vector multiplication.
int GetWidth() const
Get the width of the matrix.
VectorRotProductCoefficient(VectorCoefficient &A, VectorCoefficient &B)
Constructor with two vector coefficients. Result is .
virtual void Eval(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the matrix coefficient at ip.
virtual void Eval(DenseMatrix &M, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the matrix coefficient at ip.
virtual void EvalSymmetric(Vector &K, ElementTransformation &T, const IntegrationPoint &ip)
(DEPRECATED) Evaluate the symmetric matrix coefficient at ip.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
Class for parallel meshes.
InverseMatrixCoefficient(MatrixCoefficient &A)
Construct with the matrix coefficient. Result is .
Class representing a function through its values (scalar or vector) at quadrature points...
void GetGradient(ElementTransformation &tr, Vector &grad) const
ScalarVectorProductCoefficient(double A, VectorCoefficient &B)
Constructor with constant and vector coefficient. Result is A * B.
VectorGridFunctionCoefficient()
Construct an empty coefficient. Calling Eval() before the grid function is set will cause a segfault...