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);
388 if (ownCoeff[i*
width+j]) {
delete Coeff[i*
width+j]; }
389 Coeff[i*
width+j] = c;
390 ownCoeff[i*
width+j] = own;
397 if (ownCoeff[i]) {
delete Coeff[i]; }
404 for (
int i = 0; i <
height; i++)
406 for (
int j = 0; j <
width; j++)
408 K(i,j) = this->
Eval(i, j, T, ip);
433 "InnerProductCoefficient: "
434 "Arguments have incompatible dimensions.");
447 :
a(&A),
b(&B), va(A.GetVDim()), vb(B.GetVDim())
450 "VectorRotProductCoefficient: "
451 "Arguments must have dimension equal to two.");
459 return va[0] * vb[1] - va[1] * vb[0];
463 :
a(&A), ma(A.GetHeight(), A.GetWidth())
466 "DeterminantCoefficient: "
467 "Argument must be a square matrix.");
479 ACoef(NULL), BCoef(NULL),
481 alphaCoef(NULL), betaCoef(NULL),
482 alpha(1.0), beta(1.0)
489 double _alpha,
double _beta)
491 ACoef(&_A), BCoef(&_B),
492 A(_A.GetVDim()), B(_A.GetVDim()),
493 alphaCoef(NULL), betaCoef(NULL),
494 alpha(_alpha), beta(_beta)
497 "VectorSumCoefficient: "
498 "Arguments must have the same dimension.");
506 ACoef(&_A), BCoef(&_B),
511 alpha(0.0), beta(0.0)
514 "VectorSumCoefficient: "
515 "Arguments must have the same dimension.");
522 if ( ACoef) { ACoef->
Eval(A, T, ip); }
523 if ( BCoef) { BCoef->
Eval(B, T, ip); }
524 if (alphaCoef) { alpha = alphaCoef->
Eval(T, ip); }
525 if ( betaCoef) { beta = betaCoef->
Eval(T, ip); }
526 add(alpha, A, beta, B, V);
544 double sa = (a == NULL) ? aConst : a->
Eval(T, ip);
559 V *= (nv > tol) ? (1.0/nv) : 0.0;
568 "VectorCrossProductCoefficient: "
569 "Arguments must have dimension equal to three.");
578 V[0] = va[1] * vb[2] - va[2] * vb[1];
579 V[1] = va[2] * vb[0] - va[0] * vb[2];
580 V[2] = va[0] * vb[1] - va[1] * vb[0];
586 ma(A.GetHeight(), A.GetWidth()), vb(B.GetVDim())
589 "MatrixVectorProductCoefficient: "
590 "Arguments have incompatible dimensions.");
606 for (
int d=0; d<dim; d++) { M(d,d) = 1.0; }
611 double _alpha,
double _beta)
613 a(&A),
b(&B),
alpha(_alpha), beta(_beta),
614 ma(A.GetHeight(), A.GetWidth())
617 "MatrixSumCoefficient: "
618 "Arguments must have the same dimensions.");
625 if ( beta != 1.0 ) { M *= beta; }
646 double sa = (a == NULL) ? aConst : a->
Eval(T, ip);
667 "InverseMatrixCoefficient: "
668 "Argument must be a square matrix.");
682 va(A.GetVDim()), vb(B.GetVDim())
691 for (
int i=0; i<va.
Size(); i++)
693 for (
int j=0; j<vb.
Size(); j++)
695 M(i, j) = va[i] * vb[j];
713 for (
int i=0; i<vk.Size(); i++)
716 for (
int j=0; j<vk.Size(); j++)
718 M(i, j) -= vk[i] * vk[j];
721 M *= ((a == NULL ) ? aConst : a->
Eval(T, ip) );
730 for (
int i = 0; i < mesh.
GetNE(); i++)
738 double val = fabs(coeff.
Eval(*tr, ip));
764 for (
int i = 0; i < mesh.
GetNE(); i++)
772 coeff.
Eval(vval, *tr, ip);
775 for (
int idim(0); idim < vdim; ++idim)
777 norm += ip.
weight * tr->
Weight() * pow(fabs( vval(idim) ), p);
782 for (
int idim(0); idim < vdim; ++idim)
784 val = fabs(vval(idim));
800 double norm =
LpNormLoop(p, coeff, mesh, irs);
807 norm = -pow(-norm, 1.0/p);
811 norm = pow(norm, 1.0/p);
821 double norm =
LpNormLoop(p, coeff, mesh, irs);
828 norm = -pow(-norm, 1.0/p);
832 norm = pow(norm, 1.0/p);
843 double loc_norm =
LpNormLoop(p, coeff, pmesh, irs);
844 double glob_norm = 0;
846 MPI_Comm comm = pmesh.
GetComm();
850 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_SUM, comm);
855 glob_norm = -pow(-glob_norm, 1.0/p);
859 glob_norm = pow(glob_norm, 1.0/p);
864 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_MAX, comm);
873 double loc_norm =
LpNormLoop(p, coeff, pmesh, irs);
874 double glob_norm = 0;
876 MPI_Comm comm = pmesh.
GetComm();
880 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_SUM, comm);
885 glob_norm = -pow(-glob_norm, 1.0/p);
889 glob_norm = pow(glob_norm, 1.0/p);
894 MPI_Allreduce(&loc_norm, &glob_norm, 1, MPI_DOUBLE, MPI_MAX, comm);
907 MFEM_VERIFY(_index >= 0,
"Index must be >= 0");
908 MFEM_VERIFY(_index < QuadF.
GetVDim(),
909 "Index must be < QuadratureFunction length");
912 MFEM_VERIFY(_length > 0,
"Length must be > 0");
913 MFEM_VERIFY(_length <= QuadF.
GetVDim() - index,
914 "Length must be <= (QuadratureFunction length - index)");
934 for (
int i = 0; i <
vdim; i++)
936 V(i) = temp(index + i);
946 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)
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)
void SetComponent(int _index, int _length)
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)
const double * HostRead() const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), false).
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.
void SetDirection(const Vector &_d)
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 double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the determinant coefficient at ip.
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.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
MatrixSumCoefficient(MatrixCoefficient &A, MatrixCoefficient &B, double _alpha=1.0, double _beta=1.0)
Construct with the two coefficients. Result is _alpha * A + _beta * B.
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 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()
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()...
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)
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...