33 S->
Mult(tmp, fieldtrue);
45 double dx, loc_area = 0.0;
46 for (
int i = 0; i < pmesh.
GetNE(); i++)
51 MPI_Allreduce(&loc_area, &glob_area, 1, MPI_DOUBLE,
57 dx = glob_area / glob_zones;
break;
59 dx = sqrt(glob_area / glob_zones);
break;
61 dx = sqrt(2.0 * glob_area / glob_zones);
break;
63 dx = pow(glob_area / glob_zones, 1.0/3.0);
break;
65 dx = pow(6.0 * glob_area / glob_zones, 1.0/3.0);
break;
66 default: MFEM_ABORT(
"Unknown zone type!"); dx = 0.0;
77 "Only Ordering::byNODES is supported.");
80 const int size = dist_s.
Size();
85 for (
int d = 0; d <
dim; d++)
88 for (
int i = 0; i < size; i++)
90 magn(i) += der(i) * der(i);
92 dist_v(i + d*size) = (dist_s(i) > 0.0) ? -der(i) : der(i);
96 const double eps = 1e-16;
97 for (
int i = 0; i < size; i++)
99 const double vec_magn = std::sqrt(magn(i) + eps);
100 for (
int d = 0; d <
dim; d++)
102 dist_v(i + d*size) *= fabs(dist_s(i)) / vec_magn;
112 "This function expects a vector ParGridFunction!");
127 MFEM_VERIFY(check_h1 && pfes.
GetVDim() == 1,
128 "This solver supports only scalar H1 spaces.");
142 for (
int i = 0; i < source.
Size(); i++)
144 const double x =
source(i);
145 source(i) = ((x < -1.0) || (x > 1.0)) ? 0.0 : (1.0 - x) * (1.0 + x);
149 const int cg_print_lvl = (
print_level > 0) ? 1 : 0,
179 if (pmesh.bdr_attributes.Size())
181 Array<int> ess_bdr(pmesh.bdr_attributes.Max());
214 for (
int i = 0; i < diffused_source.
Size(); i++)
220 diffused_source(i) = 0.5 * (u_neumann(i) + u_dirichlet(i));
222 source = diffused_source;
253 double d_min_loc = distance.
Min();
255 MPI_Allreduce(&d_min_loc, &d_min_glob, 1, MPI_DOUBLE,
257 distance -= d_min_glob;
268 x.ProjectCoefficient(grad_u);
271 sol_sock_x <<
"parallel " << pfes.
GetNRanks() <<
" "
273 sol_sock_x.precision(8);
274 sol_sock_x <<
"solution\n" << pmesh << x;
275 sol_sock_x <<
"window_geometry " << 0 <<
" " << 0 <<
" "
276 << 500 <<
" " << 500 <<
"\n"
277 <<
"window_title '" <<
"Heat Directions" <<
"'\n"
278 <<
"keys evvRj*******A\n" << std::flush;
290 MFEM_VERIFY((check_h1 || check_l2) && fesd->
GetVDim() == 1,
291 "This solver supports only scalar H1 or L2 spaces.");
294 const int dim=mesh->Dimension();
296 MPI_Comm lcomm=fesd->
GetComm();
298 MPI_Comm_rank(lcomm,&myrank);
300 const int order = fesd->
GetOrder(0);
344 for (
int pp=3; pp<maxp; pp++)
346 if (myrank == 0 &&
print_level > 0) { std::cout<<
"pp="<<pp<<std::endl; }
406 for (
int jj=0; jj<ndim; jj++)
408 ngrad2 = ngrad2 + qval(jj)*qval(jj);
411 energy = energy + w * ngrad2 *
diffcoef * 0.5;
416 energy = energy + w * pval * pval * 0.5;
420 energy = energy - w*pval;
424 energy = energy + w*pval;
478 elvect.
Add(w * pval, shapef);
486 elvect.
Add( -w , shapef);
490 elvect.
Add( w , shapef);
577 for (
int jj=0; jj<ndim; jj++)
581 tmpv.
Add(vgrad[jj],shapef);
587 for (
int jj=0; jj<ndim; jj++)
589 ngrad2 = ngrad2 + qval(jj)*qval(jj);
592 energy = energy + w * std::pow(ngrad2+
ee*
ee,
pp/2.0)/
pp;
598 energy = energy - w * pval * tval;
602 energy = energy + w * pval * tval;
661 for (
int jj=0; jj<ndim; jj++)
665 tmpv.
Add(vgrad[jj],shapef);
672 for (
int jj=0; jj<ndim; jj++)
674 ngrad2 = ngrad2 + qval(jj)*qval(jj);
678 aa = std::pow(aa, (
pp - 2.0) / 2.0);
680 elvect.
Add(w * aa,lvec);
686 elvect.
Add( -w*fval , shapef);
690 elvect.
Add( w*fval , shapef);
743 for (
int jj=0; jj<ndim; jj++)
747 tmpv.
Add(vgrad[jj],shapef);
755 for (
int jj=0; jj<ndim; jj++)
757 ngrad2 = ngrad2 + qval(jj)*qval(jj);
760 aa = ngrad2 +
ee *
ee;
761 aa1 = std::pow(aa, (
pp - 2.0) / 2.0);
762 aa0 = (
pp-2.0) * std::pow(aa, (
pp - 4.0) / 2.0);
786 gmres->
Mult(rhs, *sv);
int GetNPoints() const
Returns the number of the points in the integration rule.
Abstract class for all finite elements.
Ordering::Type GetOrdering() const
Return the ordering method.
Class for domain integration L(v) := (f, v)
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
Conjugate gradient method.
int GetDim() const
Returns the reference space dimension for the finite element.
void trans(const Vector &u, Vector &x)
Class for an integration rule - an Array of IntegrationPoint.
void SetCol(int c, const double *col)
void ComputeScalarDistance(Coefficient &func, ParGridFunction &fdist)
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
ParMesh * GetParMesh() const
A coefficient that is constant across space and time.
long GetGlobalNE() const
Return the total (global) number of elements.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
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 ...
void SetSize(int s)
Resize the vector to size s.
Class for domain integrator L(v) := (f, grad v)
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
Pointer to an Operator of a specified type.
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun, DenseMatrix &elmat) override
Assemble the local gradient matrix.
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
Data type dense matrix using column-major storage.
int Size() const
Returns the size of the vector.
int GetNE() const
Returns number of elements.
virtual void SetSolver(Solver &solver)
Set the linear solver for inverting the Jacobian.
Abstract parallel finite element space.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
Geometry::Type GetElementBaseGeometry(int i) const
void DeleteAll()
Delete the whole array.
void ScalarDistToVector(ParGridFunction &dist_s, ParGridFunction &dist_v)
VectorCoefficient * fgrad
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun, Vector &elvect) override
Perform the local action of the NonlinearFormIntegrator.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Relax the linear system Ax=b.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
The BoomerAMG solver in hypre.
void source(const Vector &x, Vector &f)
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
void GetDerivative(int comp, int der_comp, GridFunction &der)
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
void SetPrintLevel(int print_lvl)
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
virtual void SetFromTrueDofs(const Vector &tv)
Set the GridFunction from the given true-dof vector.
Mesh * GetMesh() const
Returns the mesh.
void SetPrintLevel(int print_level)
void SetInput(Coefficient &nfunc)
void SetMaxIter(int max_it)
Vector coefficient defined as the Gradient of a scalar GridFunction.
virtual double GetElementEnergy(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun) override
Compute the local energy.
Newton's method for solving F(x)=b for a given operator F.
void AddMult_a_VVt(const double a, const Vector &v, DenseMatrix &VVt)
VVt += a * v v^t.
Parallel smoothers in hypre.
void CalcPhysDShape(ElementTransformation &Trans, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in physical space at the poi...
int GetVDim() const
Returns vector dimension.
void DiffuseField(ParGridFunction &field, int smooth_steps)
void GetColumn(int c, Vector &col) const
virtual void Mult(const Vector &b, Vector &x) const
Solve the nonlinear system with right-hand side b.
const Vector & GetTrueVector() const
Read only access to the (optional) internal true-dof Vector.
Wrapper for hypre's parallel vector class.
double Min() const
Returns the minimal element of the vector.
void SetAbsTol(double atol)
void SetRelTol(double rtol)
int GetDof() const
Returns the number of degrees of freedom in the finite element.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
void CalcPhysShape(ElementTransformation &Trans, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in physical space at the point ...
virtual void ComputeVectorDistance(Coefficient &zero_level_set, ParGridFunction &distance)
int GetOrder(int i) const
Returns the polynomial degree of the i'th finite element.
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun, Vector &elvect) override
Perform the local action of the NonlinearFormIntegrator.
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun, DenseMatrix &elmat) override
Assemble the local gradient matrix.
void ComputeScalarDistance(Coefficient &zero_level_set, ParGridFunction &distance)
Vector & Add(const double a, const Vector &Va)
(*this) += a * Va
Class for integration point with weight.
HypreParVector * GetTrueDofs() const
Returns the true dofs in a new HypreParVector.
virtual double GetElementEnergy(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun) override
Compute the local energy.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
const FiniteElementCollection * FEColl() const
void Mult(const double *x, double *y) const
Matrix vector multiplication.
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Arbitrary order H1-conforming (continuous) finite elements.
void SetPower(double pp_)
Class for parallel grid function.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
Wrapper for hypre's ParCSR matrix class.
Class for parallel meshes.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
void AddMult_a_AAt(double a, const DenseMatrix &A, DenseMatrix &AAt)
AAt += a * A * A^t.
double GetElementVolume(int i)
void Filter(ParGridFunction &func, ParGridFunction &ffield)
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
Arbitrary order "L2-conforming" discontinuous finite elements.
double AvgElementSize(ParMesh &pmesh)
void Neg()
(*this) = -(*this)
ParFiniteElementSpace * ParFESpace() const
virtual void ComputeScalarDistance(Coefficient &zero_level_set, ParGridFunction &distance)=0