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 for (
int i = 0; i < size; i++)
98 const double vec_magn = std::sqrt(magn(i) + 1e-12);
99 for (
int d = 0; d <
dim; d++)
101 dist_v(i + d*size) *= fabs(dist_s(i)) / vec_magn;
111 "This function expects a vector ParGridFunction!");
126 MFEM_VERIFY(check_h1 && pfes.
GetVDim() == 1,
127 "This solver supports only scalar H1 spaces.");
134 source.ProjectCoefficient(zero_level_set);
141 for (
int i = 0; i <
source.Size(); i++)
143 const double x =
source(i);
144 source(i) = ((x < -1.0) || (x > 1.0)) ? 0.0 : (1.0 - x) * (1.0 + x);
148 int amg_print_level = 0;
177 if (pmesh.bdr_attributes.Size())
179 Array<int> ess_bdr(pmesh.bdr_attributes.Max());
212 for (
int ii = 0; ii < diffused_source.
Size(); ii++)
218 diffused_source(ii) = 0.5 * (u_neumann(ii) + u_dirichlet(ii));
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;
282 double NormalizationDistanceSolver::NormalizationCoeff::
287 u.GetGradient(T, u_grad);
288 const double u_value =
u.GetValue(T, ip);
290 return u_value / sqrt(u_value * u_value + u_grad * u_grad + 1e-12);
301 NormalizationCoeff rv_coeff(u_gf);
312 MFEM_VERIFY((check_h1 || check_l2) && fesd->
GetVDim() == 1,
313 "This solver supports only scalar H1 or L2 spaces.");
316 const int dim=mesh->Dimension();
318 MPI_Comm lcomm=fesd->
GetComm();
320 MPI_Comm_rank(lcomm,&myrank);
322 const int order = fesd->
GetOrder(0);
366 for (
int pp=3; pp<maxp; pp++)
370 std::cout <<
"pp = " << pp << std::endl;
413 trans.SetIntPoint(&ip);
425 for (
int jj=0; jj<ndim; jj++)
427 ngrad2 = ngrad2 + qval(jj)*qval(jj);
430 energy = energy + w * ngrad2 *
diffcoef * 0.5;
435 energy = energy + w * pval * pval * 0.5;
439 energy = energy - w*pval;
443 energy = energy + w*pval;
481 trans.SetIntPoint(&ip);
497 elvect.
Add(w * pval, shapef);
505 elvect.
Add( -w, shapef);
509 elvect.
Add( w, shapef);
538 trans.SetIntPoint(&ip);
580 trans.SetIntPoint(&ip);
596 for (
int jj=0; jj<ndim; jj++)
600 tmpv.
Add(vgrad[jj],shapef);
606 for (
int jj=0; jj<ndim; jj++)
608 ngrad2 = ngrad2 + qval(jj)*qval(jj);
611 energy = energy + w * std::pow(ngrad2+
ee*
ee,
pp/2.0)/
pp;
617 energy = energy - w * pval * tval;
621 energy = energy + w * pval * tval;
664 trans.SetIntPoint(&ip);
680 for (
int jj=0; jj<ndim; jj++)
684 tmpv.
Add(vgrad[jj],shapef);
691 for (
int jj=0; jj<ndim; jj++)
693 ngrad2 = ngrad2 + qval(jj)*qval(jj);
697 aa = std::pow(aa, (
pp - 2.0) / 2.0);
699 elvect.
Add(w * aa,lvec);
705 elvect.
Add( -w*fval, shapef);
709 elvect.
Add( w*fval, shapef);
747 trans.SetIntPoint(&ip);
762 for (
int jj=0; jj<ndim; jj++)
766 tmpv.
Add(vgrad[jj],shapef);
774 for (
int jj=0; jj<ndim; jj++)
776 ngrad2 = ngrad2 + qval(jj)*qval(jj);
779 aa = ngrad2 +
ee *
ee;
780 aa1 = std::pow(aa, (
pp - 2.0) / 2.0);
781 aa0 = (
pp-2.0) * std::pow(aa, (
pp - 4.0) / 2.0);
805 gmres->
Mult(rhs, *sv);
Abstract class for all finite elements.
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.
void trans(const Vector &u, Vector &x)
int GetNPoints() const
Returns the number of the points in the integration rule.
Class for an integration rule - an Array of IntegrationPoint.
void GetDerivative(int comp, int der_comp, ParGridFunction &der)
Parallel version of GridFunction::GetDerivative(); see its documentation.
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.
A coefficient that is constant across space and time.
Geometry::Type GetElementBaseGeometry(int i) const
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)
bool summary
A summary of the solver process will be reported after the last iteration to mfem::out.
Pointer to an Operator of a specified type.
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun, DenseMatrix &elmat) override
Assemble the local gradient matrix.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
int Size() const
Returns the size of the vector.
Coefficient defined by a GridFunction. This coefficient is mesh dependent.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
Data type dense matrix using column-major storage.
virtual void SetSolver(Solver &solver)
Set the linear solver for inverting the Jacobian.
virtual void ProjectDiscCoefficient(VectorCoefficient &coeff)
Project a discontinuous vector coefficient as a grid function on a continuous finite element space...
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.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Relax the linear system Ax=b.
void DeleteAll()
Delete the whole array.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
virtual void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
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.
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 SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
long long GetGlobalNE() const
Return the total (global) number of elements.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
virtual void SetFromTrueDofs(const Vector &tv)
Set the GridFunction from the given true-dof vector.
const FiniteElementCollection * FEColl() const
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
void SetPrintLevel(int print_level)
void SetInput(Coefficient &nfunc)
ParMesh * GetParMesh() const
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 GetColumn(int c, Vector &col) const
void Mult(const double *x, double *y) const
Matrix vector multiplication.
void DiffuseField(ParGridFunction &field, int smooth_steps)
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.
Wrapper for hypre's parallel vector class.
IterativeSolver::PrintLevel print_level
Mesh * GetMesh() const
Returns the mesh.
virtual void Mult(const Vector &b, Vector &x) const
Solve the nonlinear system with right-hand side b.
void SetAbsTol(double atol)
void SetRelTol(double rtol)
int GetDim() const
Returns the reference space dimension for the finite element.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
double Min() const
Returns the minimal element of the vector.
ParFiniteElementSpace * ParFESpace() const
int GetOrder(int i) const
Returns the polynomial degree of the i'th finite element.
virtual void ComputeVectorDistance(Coefficient &zero_level_set, ParGridFunction &distance)
int GetDof() const
Returns the number of degrees of freedom in the 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)
const Vector & GetTrueVector() const
Read only access to the (optional) internal true-dof Vector.
int GetNE() const
Returns number of elements.
Solver wrapper which orthogonalizes the input and output vector.
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 ...
Vector & Add(const double a, const Vector &Va)
(*this) += a * Va
Class for integration point with weight.
Ordering::Type GetOrdering() const
Return the ordering method.
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.
HypreParVector * GetTrueDofs() const
Returns the true dofs in a new HypreParVector.
void SetSolver(Solver &s)
Set the solver used by the OrthoSolver.
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Arbitrary order H1-conforming (continuous) finite elements.
bool iterations
Detailed information about each iteration will be reported to mfem::out.
double u(const Vector &xvec)
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.
void ComputeScalarDistance(Coefficient &u_coeff, ParGridFunction &dist)
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
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)
virtual void ComputeScalarDistance(Coefficient &zero_level_set, ParGridFunction &distance)=0