93int main(
int argc,
char *argv[])
102 const char *mesh_file =
"../data/star.mesh";
108 real_t newton_scaling = 0.8;
114 bool visualization =
true;
117 args.
AddOption(&mesh_file,
"-m",
"--mesh",
118 "Mesh file to use.");
120 "Finite element order (polynomial degree).");
121 args.
AddOption(&ref_levels,
"-r",
"--refs",
122 "Number of h-refinements.");
123 args.
AddOption(&max_it,
"-mi",
"--max-it",
124 "Maximum number of iterations");
126 "Stopping criteria based on the difference between"
127 "successive solution updates");
129 "Initial size alpha");
130 args.
AddOption(&growth_rate,
"-gr",
"--growth-rate",
131 "Growth rate of the step size alpha");
132 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
133 "--no-visualization",
134 "Enable or disable GLVis visualization.");
150 Mesh mesh(mesh_file, 1, 1);
155 "This example does not support meshes"
156 " without boundary attributes."
161 for (
int l = 0; l < ref_levels; l++)
168 int curvature_order = max(order,2);
173 for (
int i = 0; i < mesh.
GetNE(); i++)
178 ParMesh pmesh(MPI_COMM_WORLD, mesh);
192 cout <<
"Number of H(div) dofs: "
193 << num_dofs_RT << endl;
194 cout <<
"Number of Lยฒ dofs: "
195 << num_dofs_L2 << endl;
215 tx = 0.0; trhs = 0.0;
220 delta_psi_gf.
MakeRef(&RTfes,x,offsets[0]);
221 u_gf.
MakeRef(&L2fes,x,offsets[1]);
241 sol_sock.precision(8);
247 Vector zero_vec(sdim); zero_vec = 0.0;
250 IsomorphismCoefficient Z(sdim, psi_gf);
251 DIsomorphismCoefficient DZ(sdim, psi_gf, eps);
255 SumCoefficient psi_old_minus_psi(div_psi_old_cf, div_psi_cf, 1.0, -1.0);
282 real_t domain_volume = vol_form(one_gf);
286 int total_iterations = 0;
289 for (k = 0; k < max_it; k++)
295 mfem::out <<
"\nOUTER ITERATION " << k+1 << endl;
299 for ( j = 0; j < 5; j++)
340 minres.
Mult(trhs,tx);
352 psi_gf.
Add(newton_scaling, delta_psi_gf);
357 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
358 sol_sock <<
"solution\n" << pmesh << u_gf <<
"window_title 'Discrete solution'"
364 mfem::out <<
"Newton_update_size = " << Newton_update_size << endl;
367 if (newton_scaling*Newton_update_size < increment_u)
379 mfem::out <<
"Number of Newton iterations = " << j+1 << endl;
380 mfem::out <<
"Increment (|| uโ - uโ_prvs||) = " << increment_u << endl;
385 alpha *= max(growth_rate, 1_r);
392 if (norm_psi > max_psi)
403 if (increment_u < tol || k == max_it-1)
413 mfem::out <<
"\n Outer iterations: " << k+1
414 <<
"\n Total iterations: " << total_iterations
428 MFEM_ASSERT(psi != NULL,
"grid function is not set");
432 real_t norm = psi_vals.Norml2();
433 real_t phi = 1.0 / sqrt(1.0 + norm*norm);
442 MFEM_ASSERT(psi != NULL,
"grid function is not set");
443 MFEM_ASSERT(eps >= 0,
"eps is negative");
447 real_t norm = psi_vals.Norml2();
448 real_t phi = 1.0 / sqrt(1.0 + norm*norm);
451 for (
int i = 0; i <
height; i++)
454 for (
int j = 0; j <
height; j++)
456 K(i,j) -= psi_vals(i) * psi_vals(j) * pow(phi, 3);
int Size() const
Return the logical size of the array.
void PartialSum()
Fill the entries of the array with the cumulative sum of the entries.
A class to handle Block diagonal preconditioners in a matrix-free implementation.
void SetDiagonalBlock(int iblock, Operator *op)
Add a square block op in the block-entry (iblock, iblock).
A class to handle Block systems in a matrix-free implementation.
void SetBlock(int iRow, int iCol, Operator *op, real_t c=1.0)
Add a block op in the block-entry (iblock, jblock).
A class to handle Vectors in a block fashion.
Vector & GetBlock(int i)
Get the i-th vector in the block.
A coefficient that is constant across space and time.
Data type dense matrix using column-major storage.
Scalar coefficient defined as the Divergence of a vector GridFunction.
Class for domain integration .
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
virtual void GetVectorValue(int i, const IntegrationPoint &ip, Vector &val) const
The BoomerAMG solver in hypre.
void SetPrintLevel(int print_level)
Wrapper for hypre's ParCSR matrix class.
void GetDiag(Vector &diag) const
Get the local diagonal of the matrix.
void InvScaleRows(const Vector &s)
Scale the local row i by 1./s(i)
HYPRE_BigInt * GetRowStarts() const
Return the parallel row partitioning array.
HYPRE_BigInt GetGlobalNumRows() const
Return the global number of rows.
HypreParMatrix * Transpose() const
Returns the transpose of *this.
Wrapper for hypre's parallel vector class.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
Class for integration point with weight.
void SetRelTol(real_t rtol)
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
void SetMaxIter(int max_it)
Arbitrary order "L2-conforming" discontinuous finite elements.
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the MINRES method.
void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
void SetPreconditioner(Solver &pr) override
This should be called before SetOperator.
Base class for Matrix Coefficients that optionally depend on time and space.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void Clear()
Clear the contents of the Mesh.
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
real_t GetElementSize(int i, int type=0)
Get the size of the i-th element relative to the perfect reference element.
int SpaceDimension() const
Dimension of the physical space containing the mesh.
virtual void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1)
Set the curvature of the mesh nodes using the given polynomial degree.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
static int WorldSize()
Return the size of MPI_COMM_WORLD.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
bool Good() const
Return true if the command line options were parsed successfully.
Abstract parallel finite element space.
HYPRE_BigInt GlobalTrueVSize() const
int GetTrueVSize() const override
Return the number of local vector true dofs.
Class for parallel grid function.
real_t ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL, const Array< int > *elems=NULL) const override
Returns ||u_ex - u_h||_L2 in parallel for H1 or L2 elements.
void SetFromTrueDofs(const Vector &tv) override
Set the GridFunction from the given true-dof vector.
MFEM_DEPRECATED real_t ComputeL1Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL) const override
Returns ||u_ex - u_h||_L1 in parallel for H1 or L2 elements.
void MakeRef(FiniteElementSpace *f, real_t *v) override
Make the ParGridFunction reference external data on a new FiniteElementSpace.
Class for parallel meshes.
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
Vector coefficient defined as a product of scalar and vector coefficients.
Scalar coefficient defined as the linear combination of two scalar coefficients or a scalar and a sca...
void SetAlpha(real_t alpha_)
Reset the factor in front of the first term in the linear combination.
Base class for vector Coefficients that optionally depend on time and space.
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 ...
Vector coefficient that is constant in space and time.
for VectorFiniteElements (Nedelec, Raviart-Thomas)
Vector & Add(const real_t a, const Vector &Va)
(*this) += a * Va
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
HypreParMatrix * ParMult(const HypreParMatrix *A, const HypreParMatrix *B, bool own_matrix)