47 class NLSolverPLaplacian
55 double 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(
double rtol)
126 void SetNRATol(
double atol)
132 void SetMaxNRIter(
int miter)
137 void SetLSRTol(
double rtol)
142 void SetLSATol(
double atol)
148 void SetMaxLSIter(
int miter)
154 void SetPrintLevel(
int plev)
161 void Solve(
Vector& statev)
168 nsolver->Mult(
b, statev);
172 double GetEnergy(
Vector& statev)
179 return nlform->GetEnergy(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;}
193 Array<int> ess_bdr(mesh->bdr_attributes.Max());
201 nlform->AddDomainIntegrator(
new pLaplace(*plap_power,*plap_epsilon,
214 nlform->AddDomainIntegrator(
new 216 *plap_epsilon,*plap_input));
227 nlform->AddDomainIntegrator(
new 229 *plap_epsilon,*plap_input));
232 nlform->SetEssentialBC(ess_bdr);
234 #ifdef MFEM_USE_SUITESPARSE 242 lsolver->SetRelTol(linear_rtol);
243 lsolver->SetAbsTol(linear_atol);
244 lsolver->SetMaxIter(linear_iter);
245 lsolver->SetPrintLevel(print_level);
246 lsolver->SetPreconditioner(*prec);
250 nsolver->iterative_mode =
true;
251 nsolver->SetSolver(*lsolver);
252 nsolver->SetOperator(*nlform);
253 nsolver->SetPrintLevel(print_level);
254 nsolver->SetRelTol(newton_rtol);
255 nsolver->SetAbsTol(newton_atol);
256 nsolver->SetMaxIter(newton_iter);
288 bool input_ownership;
291 int 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 double newton_rel_tol = 1e-4;
299 double 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 double 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, (
double)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
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)));
Conjugate gradient method.
Class for grid function - Vector with associated FE space.
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
A coefficient that is constant across space and time.
void PrintOptions(std::ostream &out) const
Print the options.
int Dimension() const
Dimension of the reference space used within the elements.
Helper class for ParaView visualization data.
void PrintUsage(std::ostream &out) const
Print the usage message.
double RealTime()
Return the number of real seconds elapsed since the stopwatch was started.
bool Good() const
Return true if the command line options were parsed successfully.
Data type for Gauss-Seidel smoother of sparse matrix.
void Stop()
Stop the stopwatch.
Direct sparse solver using UMFPACK.
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Newton's method for solving F(x)=b for a given operator F.
void SetTime(double t)
Set physical time (for time-dependent simulations)
void Start()
Start the stopwatch. The elapsed time is not cleared.
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
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...
void SetLevelsOfDetail(int levels_of_detail_)
int main(int argc, char *argv[])
Arbitrary order H1-conforming (continuous) finite elements.
virtual void Save() override
virtual void SetFromTrueDofs(const Vector &tv)
Set the GridFunction from the given true-dof vector.
void Clear()
Clear the elapsed time on the stopwatch and restart it if it's running.