47class NLSolverPLaplacian
55 real_t regularizationp=1e-7)
86 input_ownership=
false;
101 if (nlform!=
nullptr) {
delete nlform;}
102 if (nsolver!=
nullptr) {
delete nsolver;}
103 if (prec!=
nullptr) {
delete prec;}
104 if (lsolver!=
nullptr) {
delete lsolver;}
105 if (input_ownership) {
delete plap_input;}
120 void SetNRRTol(
real_t rtol)
126 void SetNRATol(
real_t atol)
132 void SetMaxNRIter(
int miter)
137 void SetLSRTol(
real_t rtol)
142 void SetLSATol(
real_t atol)
148 void SetMaxLSIter(
int miter)
154 void SetPrintLevel(
int plev)
161 void Solve(
Vector& statev)
168 nsolver->
Mult(
b, statev);
187 if (nlform!=
nullptr) {
delete nlform;}
188 if (nsolver!=
nullptr) {
delete nsolver;}
189 if (prec!=
nullptr) {
delete prec;}
190 if (lsolver!=
nullptr) {
delete lsolver;}
216 *plap_epsilon,*plap_input));
229 *plap_epsilon,*plap_input));
234#ifdef MFEM_USE_SUITESPARSE
288 bool input_ownership;
291int main(
int argc,
char *argv[])
294 const char *mesh_file =
"../../data/beam-tet.mesh";
295 int ser_ref_levels = 3;
297 bool visualization =
true;
298 real_t newton_rel_tol = 1e-4;
299 real_t newton_abs_tol = 1e-6;
300 int newton_iter = 10;
306 int int_integrator = integrator;
312 args.
AddOption(&mesh_file,
"-m",
"--mesh",
"Mesh file to use.");
316 "Number of times to refine the mesh uniformly in serial.");
320 "Order (degree) of the finite elements.");
325 "--no-visualization",
326 "Enable or disable GLVis visualization.");
329 "--relative-tolerance",
330 "Relative tolerance for the Newton solve.");
333 "--absolute-tolerance",
334 "Absolute tolerance for the Newton solve.");
337 "--newton-iterations",
338 "Maximum iterations for the Newton solve.");
342 "Power parameter (>=2.0) for the p-Laplacian.");
343 args.
AddOption((&print_level),
"-prt",
"--print-level",
"Print level.");
347 "Integrator 0: standard; 1: AD for Hessian; 2: AD for residual and Hessian");
358 Mesh *mesh =
new Mesh(mesh_file, 1, 1);
364 for (
int lev = 0; lev < ser_ref_levels; lev++)
377 std::cout <<
"Number of finite element unknowns: " << glob_size << std::endl;
393 NLSolverPLaplacian* nr;
396 nr=
new NLSolverPLaplacian(*mesh, fespace, 2.0, &load);
397 nr->SetIntegrator(integrator);
398 nr->SetMaxNRIter(newton_iter);
399 nr->SetNRATol(newton_abs_tol);
400 nr->SetNRRTol(newton_rel_tol);
405 std::cout <<
"[pp=2] The solution time is: " << timer->
RealTime()
408 real_t energy = nr->GetEnergy(sv);
409 std::cout <<
"[pp=2] The total energy of the system is E=" << energy
419 for (
int i = 3; i < pp; i++)
421 nr=
new NLSolverPLaplacian(*mesh, fespace, (
real_t)i, &load);
422 nr->SetIntegrator(integrator);
423 nr->SetMaxNRIter(newton_iter);
424 nr->SetNRATol(newton_abs_tol);
425 nr->SetNRRTol(newton_rel_tol);
430 std::cout <<
"[pp=" << i
431 <<
"] The solution time is: " << timer->
RealTime() << std::endl;
432 energy = nr->GetEnergy(sv);
433 std::cout <<
"[pp="<< i<<
"] The total energy of the system is E=" << energy
443 if (std::abs(pp - 2.0) > std::numeric_limits<real_t>::epsilon())
445 nr=
new NLSolverPLaplacian(*mesh, fespace, pp, &load);
446 nr->SetIntegrator(integrator);
447 nr->SetMaxNRIter(newton_iter);
448 nr->SetNRATol(newton_abs_tol);
449 nr->SetNRRTol(newton_rel_tol);
454 std::cout <<
"[pp=" << pp
455 <<
"] The solution time is: " << timer->
RealTime() << std::endl;
456 energy = nr->GetEnergy(sv);
457 std::cout <<
"[pp="<<pp<<
"] The total energy of the system is E=" << energy
464 dacol->
SetCycle(
static_cast<int>(std::floor(pp)));
468 dacol->
SetCycle(
static_cast<int>(std::ceil(pp)));
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Conjugate gradient method.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
A coefficient that is constant across space and time.
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection.
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
void SetTime(real_t t)
Set physical time (for time-dependent simulations)
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
Data type for Gauss-Seidel smoother of sparse matrix.
Class for grid function - Vector with associated FE space.
virtual void SetFromTrueDofs(const Vector &tv)
Set the GridFunction from the given true-dof vector.
Arbitrary order H1-conforming (continuous) finite elements.
void SetRelTol(real_t rtol)
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
void SetMaxIter(int max_it)
void SetAbsTol(real_t atol)
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
int Dimension() const
Dimension of the reference space used within the elements.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Newton's method for solving F(x)=b for a given operator F.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
virtual void SetSolver(Solver &solver)
Set the linear solver for inverting the Jacobian.
virtual void Mult(const Vector &b, Vector &x) const
Solve the nonlinear system with right-hand side b.
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.
Helper class for ParaView visualization data.
void SetLevelsOfDetail(int levels_of_detail_)
virtual void Save() override
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
double RealTime()
Return the number of real seconds elapsed since the stopwatch was started.
void Start()
Start the stopwatch. The elapsed time is not cleared.
void Stop()
Stop the stopwatch.
void Clear()
Clear the elapsed time on the stopwatch and restart it if it's running.
Direct sparse solver using UMFPACK.