Skip to content

Commit 6d101ca

Browse files
committed
merge with master and update changelog
2 parents e3d0907 + d14a314 commit 6d101ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+6952
-945
lines changed

CHANGELOG

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Meshing improvements
2323
Hessian for r-adaptivity using discrete fields, and allows use of skewness
2424
and orientation based metrics.
2525

26+
- Added support for r-adaptivity with more than one discrete field. This allows
27+
the user to specify different discrete functions for controlling the
28+
size, aspect-ratio, orientation, and skew of elements in the mesh.
29+
2630
Improved GPU capabilities
2731
-------------------------
2832
- Added support for Chebyshev accelerated polynomial smoother on GPU.
@@ -35,6 +39,15 @@ Discretization improvements
3539

3640
- Added support for simplices in GSLIB-FindPoints.
3741

42+
- Added support for H1 and L2 element matrix assembly in the mass, convection,
43+
diffusion, transpose, and the face DG trace integrators. This is compatible
44+
with GPU device execution and is illustrated in Example 9/9p, see the option
45+
'-ea'. When enabled, this level of assembly stores independent dense matrices
46+
for the elements, and independent dense matrices for the faces in the DG case.
47+
48+
- Added new partial assembly kernels for H(div) bilinear forms, as well as
49+
VectorFEDivergenceIntegrator.
50+
3851
Linear and nonlinear solvers
3952
----------------------------
4053
- Added power method to iteratively estimate the largest eigenvalue and the
@@ -43,6 +56,10 @@ Linear and nonlinear solvers
4356
- Added initial support for h- and p-multigrid solvers and preconditioners for
4457
matrix-based and matrix-free discretizations with basic GPU capability.
4558

59+
- Block arrays of parallel matrices can now be merged into a single parallel
60+
matrix with the function HypreParMatrixFromBlocks. This could be useful for
61+
solving block systems with parallel direct solvers such as STRUMPACK.
62+
4663
New and updated examples and miniapps
4764
-------------------------------------
4865
- Added a new example, Example 25/25p, to demonstrate the use of a Perfectly
@@ -65,6 +82,12 @@ New and updated examples and miniapps
6582
- Added a new meshing miniapp, Minimal Surface, which solves Plateau's problem:
6683
the Dirichlet problem for the minimal surface equation.
6784

85+
- Added partial assembly support to examples 4/4p and 5/5p, with diagonal
86+
preconditioning.
87+
88+
- Added a new test problem in example 24/24p, demonstrating a mixed bilinear
89+
form for H(div) and L_2, with partial assembly support.
90+
6891
Improved testing
6992
----------------
7093
- Added a GitLab pipeline that automates PR testing on supercomputing systems
@@ -83,6 +106,9 @@ Miscellaneous
83106
entire spatial and temporal data. In addition, ADIOS2 allows for setting a
84107
user-defined number of data substreams/subfiles. See examples 5, 9, 12, 16.
85108

109+
- Added a new IterativeSolverMonitor class that allows to monitor the residual
110+
and solution during the solving process of an IterativeSolver after every
111+
iteration.
86112

87113
Version 4.1, released on March 10, 2020
88114
=======================================

examples/ex14p.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,38 @@
3535
using namespace std;
3636
using namespace mfem;
3737

38+
class CustomSolverMonitor : public IterativeSolverMonitor
39+
{
40+
public:
41+
CustomSolverMonitor(const ParMesh *m,
42+
ParGridFunction *f) :
43+
pmesh(m),
44+
pgf(f) {}
45+
46+
void MonitorSolution(int i, double norm, const Vector &x, bool final)
47+
{
48+
char vishost[] = "localhost";
49+
int visport = 19916;
50+
int num_procs, myid;
51+
52+
MPI_Comm_size(pmesh->GetComm(),&num_procs);
53+
MPI_Comm_rank(pmesh->GetComm(),&myid);
54+
55+
pgf->SetFromTrueDofs(x);
56+
57+
socketstream sol_sock(vishost, visport);
58+
sol_sock << "parallel " << num_procs << " " << myid << "\n";
59+
sol_sock.precision(8);
60+
sol_sock << "solution\n" << *pmesh << *pgf
61+
<< "window_title 'Iteration no " << i << "'"
62+
<< "keys rRjlc\n" << flush;
63+
}
64+
65+
private:
66+
const ParMesh *pmesh;
67+
ParGridFunction *pgf;
68+
};
69+
3870
int main(int argc, char *argv[])
3971
{
4072
// 1. Initialize MPI.
@@ -188,6 +220,7 @@ int main(int argc, char *argv[])
188220
}
189221
else
190222
{
223+
CustomSolverMonitor monitor(pmesh, &x);
191224
GMRESSolver gmres(MPI_COMM_WORLD);
192225
gmres.SetAbsTol(0.0);
193226
gmres.SetRelTol(1e-12);
@@ -196,6 +229,7 @@ int main(int argc, char *argv[])
196229
gmres.SetPrintLevel(1);
197230
gmres.SetOperator(*A);
198231
gmres.SetPreconditioner(*amg);
232+
gmres.SetMonitor(monitor);
199233
gmres.Mult(*B, *X);
200234
}
201235
delete amg;

examples/ex19.cpp

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,42 @@
3838
using namespace std;
3939
using namespace mfem;
4040

41+
class GeneralResidualMonitor : public IterativeSolverMonitor
42+
{
43+
public:
44+
GeneralResidualMonitor(const std::string& prefix_, int print_lvl)
45+
: prefix(prefix_)
46+
{
47+
print_level = print_lvl;
48+
}
49+
50+
virtual void MonitorResidual(int it, double norm, const Vector &r, bool final);
51+
52+
private:
53+
const std::string prefix;
54+
int print_level;
55+
mutable double norm0;
56+
};
57+
58+
void GeneralResidualMonitor::MonitorResidual(int it, double norm,
59+
const Vector &r, bool final)
60+
{
61+
if (print_level == 1 || (print_level == 3 && (final || it == 0)))
62+
{
63+
mfem::out << prefix << " iteration " << setw(2) << it
64+
<< " : ||r|| = " << norm;
65+
if (it > 0)
66+
{
67+
mfem::out << ", ||r||/||r_0|| = " << norm/norm0;
68+
}
69+
else
70+
{
71+
norm0 = norm;
72+
}
73+
mfem::out << '\n';
74+
}
75+
}
76+
4177
// Custom block preconditioner for the Jacobian of the incompressible nonlinear
4278
// elasticity operator. It has the form
4379
//
@@ -103,9 +139,11 @@ class RubberOperator : public Operator
103139

104140
// Newton solver for the hyperelastic operator
105141
NewtonSolver newton_solver;
142+
GeneralResidualMonitor newton_monitor;
106143

107144
// Solver for the Jacobian solve in the Newton method
108145
Solver *j_solver;
146+
GeneralResidualMonitor j_monitor;
109147

110148
// Preconditioner for the Jacobian
111149
Solver *j_prec;
@@ -410,7 +448,8 @@ RubberOperator::RubberOperator(Array<FiniteElementSpace *> &fes,
410448
int iter,
411449
Coefficient &c_mu)
412450
: Operator(fes[0]->GetVSize() + fes[1]->GetVSize()),
413-
newton_solver(), mu(c_mu), block_offsets(offsets)
451+
newton_solver(), newton_monitor("Newton", 1),
452+
j_monitor(" GMRES", 3), mu(c_mu), block_offsets(offsets)
414453
{
415454
Array<Vector *> rhs(2);
416455
rhs = NULL; // Set all entries in the array
@@ -446,15 +485,17 @@ RubberOperator::RubberOperator(Array<FiniteElementSpace *> &fes,
446485
j_gmres->SetRelTol(1e-12);
447486
j_gmres->SetAbsTol(1e-12);
448487
j_gmres->SetMaxIter(300);
449-
j_gmres->SetPrintLevel(0);
488+
j_gmres->SetPrintLevel(-1);
489+
j_gmres->SetMonitor(j_monitor);
450490
j_gmres->SetPreconditioner(*j_prec);
451491
j_solver = j_gmres;
452492

453493
// Set the newton solve parameters
454494
newton_solver.iterative_mode = true;
455495
newton_solver.SetSolver(*j_solver);
456496
newton_solver.SetOperator(*this);
457-
newton_solver.SetPrintLevel(1);
497+
newton_solver.SetPrintLevel(-1);
498+
newton_solver.SetMonitor(newton_monitor);
458499
newton_solver.SetRelTol(rel_tol);
459500
newton_solver.SetAbsTol(abs_tol);
460501
newton_solver.SetMaxIter(iter);

examples/ex19p.cpp

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,56 @@
3838
using namespace std;
3939
using namespace mfem;
4040

41+
class GeneralResidualMonitor : public IterativeSolverMonitor
42+
{
43+
public:
44+
GeneralResidualMonitor(MPI_Comm comm, const std::string& prefix_,
45+
int print_lvl)
46+
: prefix(prefix_)
47+
{
48+
#ifndef MFEM_USE_MPI
49+
print_level = print_lvl;
50+
#else
51+
int rank;
52+
MPI_Comm_rank(comm, &rank);
53+
if (rank == 0)
54+
{
55+
print_level = print_lvl;
56+
}
57+
else
58+
{
59+
print_level = -1;
60+
}
61+
#endif
62+
}
63+
64+
virtual void MonitorResidual(int it, double norm, const Vector &r, bool final);
65+
66+
private:
67+
const std::string prefix;
68+
int print_level;
69+
mutable double norm0;
70+
};
71+
72+
void GeneralResidualMonitor::MonitorResidual(int it, double norm,
73+
const Vector &r, bool final)
74+
{
75+
if (print_level == 1 || (print_level == 3 && (final || it == 0)))
76+
{
77+
mfem::out << prefix << " iteration " << setw(2) << it
78+
<< " : ||r|| = " << norm;
79+
if (it > 0)
80+
{
81+
mfem::out << ", ||r||/||r_0|| = " << norm/norm0;
82+
}
83+
else
84+
{
85+
norm0 = norm;
86+
}
87+
mfem::out << '\n';
88+
}
89+
}
90+
4191
// Custom block preconditioner for the Jacobian of the incompressible nonlinear
4292
// elasticity operator. It has the form
4393
//
@@ -103,9 +153,11 @@ class RubberOperator : public Operator
103153

104154
// Newton solver for the hyperelastic operator
105155
NewtonSolver newton_solver;
156+
GeneralResidualMonitor newton_monitor;
106157

107158
// Solver for the Jacobian solve in the Newton method
108159
Solver *j_solver;
160+
GeneralResidualMonitor j_monitor;
109161

110162
// Preconditioner for the Jacobian
111163
Solver *j_prec;
@@ -459,7 +511,10 @@ RubberOperator::RubberOperator(Array<ParFiniteElementSpace *> &fes,
459511
int iter,
460512
Coefficient &c_mu)
461513
: Operator(fes[0]->TrueVSize() + fes[1]->TrueVSize()),
462-
newton_solver(fes[0]->GetComm()), mu(c_mu), block_trueOffsets(trueOffsets)
514+
newton_solver(fes[0]->GetComm()),
515+
newton_monitor(fes[0]->GetComm(), "Newton", 1),
516+
j_monitor(fes[0]->GetComm(), " GMRES", 3),
517+
mu(c_mu), block_trueOffsets(trueOffsets)
463518
{
464519
Array<Vector *> rhs(2);
465520
rhs = NULL; // Set all entries in the array
@@ -499,15 +554,17 @@ RubberOperator::RubberOperator(Array<ParFiniteElementSpace *> &fes,
499554
j_gmres->SetRelTol(1e-12);
500555
j_gmres->SetAbsTol(1e-12);
501556
j_gmres->SetMaxIter(300);
502-
j_gmres->SetPrintLevel(0);
557+
j_gmres->SetPrintLevel(-1);
558+
j_gmres->SetMonitor(j_monitor);
503559
j_gmres->SetPreconditioner(*j_prec);
504560
j_solver = j_gmres;
505561

506562
// Set the newton solve parameters
507563
newton_solver.iterative_mode = true;
508564
newton_solver.SetSolver(*j_solver);
509565
newton_solver.SetOperator(*this);
510-
newton_solver.SetPrintLevel(1);
566+
newton_solver.SetPrintLevel(-1);
567+
newton_solver.SetMonitor(newton_monitor);
511568
newton_solver.SetRelTol(rel_tol);
512569
newton_solver.SetAbsTol(abs_tol);
513570
newton_solver.SetMaxIter(iter);

0 commit comments

Comments
 (0)