MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
ex40p.cpp
Go to the documentation of this file.
1// MFEM Example 40 - Parallel Version
2//
3// Compile with: make ex40p
4//
5// Sample runs: mpirun -np 4 ex40p -step 10.0 -gr 2.0
6// mpirun -np 4 ex40p -step 10.0 -gr 2.0 -o 3 -r 1
7// mpirun -np 4 ex40p -step 10.0 -gr 2.0 -r 4 -m ../data/l-shape.mesh
8// mpirun -np 4 ex40p -step 10.0 -gr 2.0 -r 2 -m ../data/fichera.mesh
9//
10// Description: This example code demonstrates how to use MFEM to solve the
11// eikonal equation,
12//
13// |โˆ‡๐‘ข| = 1 in ฮฉ, ๐‘ข = 0 on โˆ‚ฮฉ.
14//
15// The viscosity solution of this problem coincides with the unique optimum
16// of the nonlinear program
17//
18// maximize โˆซ_ฮฉ ๐‘ข d๐‘ฅ subject to |โˆ‡๐‘ข| โ‰ค 1 in ฮฉ, ๐‘ข = 0 on โˆ‚ฮฉ, (โ‹†)
19//
20// which is the foundation for method implemented below.
21//
22// Following the proximal Galerkin methodology [1,2] (see also Example
23// 36), we construct a Legendre function for the closed unit ball
24// ๐ตโ‚ := {๐‘ฅ โˆˆ Rโฟ | |๐‘ฅ| โ‰ค 1}. Our choice is the Hellinger entropy,
25//
26// R(๐‘ฅ) = โˆ’( 1 โˆ’ |๐‘ฅ|ยฒ )^{1/2},
27//
28// although other choices are possible, each leading to a slightly
29// different algorithm. We then adaptively regularize the optimization
30// problem (โ‹†) with the Bregman divergence of the Hellinger entropy,
31//
32// maximize โˆซ_ฮฉ ๐‘ข d๐‘ฅ - ฮฑโ‚–โปยน D(โˆ‡๐‘ข,โˆ‡๐‘ขโ‚–โ‚‹โ‚) subject to ๐‘ข = 0 on ฮฉ.
33//
34// This results in a sequence of functions ( ๐œ“โ‚– , ๐‘ขโ‚– ),
35//
36// ๐‘ขโ‚– โ†’ ๐‘ข, ๐œ“โ‚–/|๐œ“โ‚–| โ†’ โˆ‡๐‘ข as k โ†’ โˆž,
37//
38// defined by the nonlinear saddle-point problems
39//
40// Find ๐œ“โ‚– โˆˆ H(div,ฮฉ) and ๐‘ขโ‚– โˆˆ Lยฒ(ฮฉ) such that
41// ( (โˆ‡R)โปยน(๐œ“โ‚–) , ฯ„ ) + ( ๐‘ขโ‚– , โˆ‡โ‹…ฯ„ ) = 0 โˆ€ ฯ„ โˆˆ H(div,ฮฉ)
42// ( โˆ‡โ‹…๐œ“โ‚– , v ) = ( โˆ‡โ‹…๐œ“โ‚–โ‚‹โ‚ - ฮฑโ‚– , v ) โˆ€ v โˆˆ Lยฒ(ฮฉ)
43//
44// where (โˆ‡R)โปยน(๐œ“) = ๐œ“ / ( 1 + |๐œ“|ยฒ )^{1/2} and ฮฑโ‚– = ฮฑโ‚€rแต, where r โ‰ฅ 1
45// is a prescribed growth rate. (r = 1 is the most stable.) The
46// saddle-point problems are solved using a damped quasi-Newton method
47// with a tunable regularization parameter 0 โ‰ค ฯต << 1. The solver is
48// also made more robust by additional safeguards described in the code.
49//
50// [1] Keith, B. and Surowiec, T. (2024) Proximal Galerkin: A structure-
51// preserving finite element method for pointwise bound constraints.
52// Foundations of Computational Mathematics, 1โ€“97.
53// [2] Dokken, J., Farrell, P., Keith, B., Papadopoulos, I., and
54// Surowiec, T. (2025) The latent variable proximal point algorithm
55// for variational problems with inequality constraints. (To appear.)
56
57#include "mfem.hpp"
58#include <fstream>
59#include <iostream>
60
61using namespace std;
62using namespace mfem;
63
64class IsomorphismCoefficient : public VectorCoefficient
65{
66protected:
67 ParGridFunction *psi;
68
69public:
70 IsomorphismCoefficient(int vdim, ParGridFunction &psi_)
71 : VectorCoefficient(vdim), psi(&psi_) { }
72
74
75 void Eval(Vector &V, ElementTransformation &T,
76 const IntegrationPoint &ip) override;
77};
78
79class DIsomorphismCoefficient : public MatrixCoefficient
80{
81protected:
82 ParGridFunction *psi;
83 real_t eps;
84
85public:
86 DIsomorphismCoefficient(int height, ParGridFunction &psi_, real_t eps_ = 0.0)
87 : MatrixCoefficient(height), psi(&psi_), eps(eps_) { }
88
89 void Eval(DenseMatrix &K, ElementTransformation &T,
90 const IntegrationPoint &ip) override;
91};
92
93int main(int argc, char *argv[])
94{
95 // 0. Initialize MPI and HYPRE.
96 Mpi::Init();
97 int num_procs = Mpi::WorldSize();
98 int myid = Mpi::WorldRank();
100
101 // 1. Parse command-line options.
102 const char *mesh_file = "../data/star.mesh";
103 int order = 1;
104 int max_it = 5;
105 int ref_levels = 3;
106 real_t alpha = 1.0;
107 real_t growth_rate = 1.0;
108 real_t newton_scaling = 0.8;
109 real_t eps = 1e-6;
110 real_t tol = 1e-4;
111 real_t max_alpha = 1e2;
112 real_t max_psi = 1e2;
113 real_t eps2 = 1e-1;
114 bool visualization = true;
115
116 OptionsParser args(argc, argv);
117 args.AddOption(&mesh_file, "-m", "--mesh",
118 "Mesh file to use.");
119 args.AddOption(&order, "-o", "--order",
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");
125 args.AddOption(&tol, "-tol", "--tol",
126 "Stopping criteria based on the difference between"
127 "successive solution updates");
128 args.AddOption(&alpha, "-step", "--step",
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.");
135 args.Parse();
136 if (!args.Good())
137 {
138 if (myid == 0)
139 {
140 args.PrintUsage(cout);
141 }
142 return 1;
143 }
144 if (myid == 0)
145 {
146 args.PrintOptions(cout);
147 }
148
149 // 2. Read the mesh from the mesh file.
150 Mesh mesh(mesh_file, 1, 1);
151 int dim = mesh.Dimension();
152 int sdim = mesh.SpaceDimension();
153
154 MFEM_ASSERT(mesh.bdr_attributes.Size(),
155 "This example does not support meshes"
156 " without boundary attributes."
157 )
158
159 // 3. Postprocess the mesh.
160 // 3A. Refine the mesh to increase the resolution.
161 for (int l = 0; l < ref_levels; l++)
162 {
163 mesh.UniformRefinement();
164 }
165
166 // 3B. Interpolate the geometry after refinement to control geometry error.
167 // NOTE: Minimum second-order interpolation is used to improve the accuracy.
168 int curvature_order = max(order,2);
169 mesh.SetCurvature(curvature_order);
170
171 // 3C. Compute the maximum mesh size.
172 real_t hmax = 0.0;
173 for (int i = 0; i < mesh.GetNE(); i++)
174 {
175 hmax = max(mesh.GetElementSize(i, 1), hmax);
176 }
177
178 ParMesh pmesh(MPI_COMM_WORLD, mesh);
179 mesh.Clear();
180
181 // 4. Define the necessary finite element spaces on the mesh.
182 RT_FECollection RTfec(order, dim);
183 ParFiniteElementSpace RTfes(&pmesh, &RTfec);
184
185 L2_FECollection L2fec(order, dim);
186 ParFiniteElementSpace L2fes(&pmesh, &L2fec);
187
188 int num_dofs_RT = RTfes.GlobalTrueVSize();
189 int num_dofs_L2 = L2fes.GlobalTrueVSize();
190 if (myid == 0)
191 {
192 cout << "Number of H(div) dofs: "
193 << num_dofs_RT << endl;
194 cout << "Number of Lยฒ dofs: "
195 << num_dofs_L2 << endl;
196 }
197
198 // 5. Define the offsets for the block matrices
199 Array<int> offsets(3);
200 offsets[0] = 0;
201 offsets[1] = RTfes.GetVSize();
202 offsets[2] = L2fes.GetVSize();
203 offsets.PartialSum();
204
205 Array<int> toffsets(3);
206 toffsets[0] = 0;
207 toffsets[1] = RTfes.GetTrueVSize();
208 toffsets[2] = L2fes.GetTrueVSize();
209 toffsets.PartialSum();
210
211 BlockVector x(offsets), rhs(offsets);
212 x = 0.0; rhs = 0.0;
213
214 BlockVector tx(toffsets), trhs(toffsets);
215 tx = 0.0; trhs = 0.0;
216
217 // 6. Define the solution vectors as a finite element grid functions
218 // corresponding to the fespaces.
219 ParGridFunction u_gf, delta_psi_gf;
220 delta_psi_gf.MakeRef(&RTfes,x,offsets[0]);
221 u_gf.MakeRef(&L2fes,x,offsets[1]);
222
223 ParGridFunction psi_old_gf(&RTfes);
224 ParGridFunction psi_gf(&RTfes);
225 ParGridFunction u_old_gf(&L2fes);
226
227 // 7. Define initial guesses for the solution variables.
228 delta_psi_gf = 0.0;
229 psi_gf = 0.0;
230 u_gf = 0.0;
231 psi_old_gf = psi_gf;
232 u_old_gf = u_gf;
233
234 // 8. Prepare for glvis output.
235 char vishost[] = "localhost";
236 int visport = 19916;
237 socketstream sol_sock;
238 if (visualization)
239 {
240 sol_sock.open(vishost,visport);
241 sol_sock.precision(8);
242 }
243
244 // 9. Coefficients to be used later.
245 ConstantCoefficient one_cf(1.0);
246 ConstantCoefficient zero_cf(0.0);
247 Vector zero_vec(sdim); zero_vec = 0.0;
248 VectorConstantCoefficient zero_vec_cf(zero_vec);
249 ConstantCoefficient neg_alpha_cf((real_t) -1.0*alpha);
250 IsomorphismCoefficient Z(sdim, psi_gf);
251 DIsomorphismCoefficient DZ(sdim, psi_gf, eps);
252 ScalarVectorProductCoefficient neg_Z(-1.0, Z);
253 DivergenceGridFunctionCoefficient div_psi_cf(&psi_gf);
254 DivergenceGridFunctionCoefficient div_psi_old_cf(&psi_old_gf);
255 SumCoefficient psi_old_minus_psi(div_psi_old_cf, div_psi_cf, 1.0, -1.0);
256
257 // 10. Assemble constant matrices/vectors to avoid reassembly in the loop.
258 ParLinearForm b0, b1;
259 b0.MakeRef(&RTfes,rhs.GetBlock(0),0);
260 b1.MakeRef(&L2fes,rhs.GetBlock(1),0);
261
263 b1.AddDomainIntegrator(new DomainLFIntegrator(neg_alpha_cf));
264 b1.AddDomainIntegrator(new DomainLFIntegrator(psi_old_minus_psi));
265
266 ParBilinearForm a00(&RTfes);
268
269 ParMixedBilinearForm a10(&RTfes,&L2fes);
271 a10.Assemble();
272 a10.Finalize();
273 HypreParMatrix *A10 = a10.ParallelAssemble();
274
275 HypreParMatrix *A01 = A10->Transpose();
276
277 ParLinearForm vol_form(&L2fes);
278 ParGridFunction one_gf(&L2fes);
279 one_gf = 1.0;
280 vol_form.AddDomainIntegrator(new DomainLFIntegrator(one_cf));
281 vol_form.Assemble();
282 real_t domain_volume = vol_form(one_gf);
283
284 // 11. Iterate.
285 int k;
286 int total_iterations = 0;
287 real_t increment_u = 0.1;
288 ParGridFunction u_tmp(&L2fes);
289 for (k = 0; k < max_it; k++)
290 {
291 u_tmp = u_old_gf;
292
293 if (myid == 0)
294 {
295 mfem::out << "\nOUTER ITERATION " << k+1 << endl;
296 }
297
298 int j;
299 for ( j = 0; j < 5; j++)
300 {
301 total_iterations++;
302
303 b0.Assemble();
304 b0.ParallelAssemble(trhs.GetBlock(0));
305
306 b1.Assemble();
307 b1.ParallelAssemble(trhs.GetBlock(1));
308
309 a00.Assemble(false);
310 a00.Finalize(false);
311 HypreParMatrix *A00 = a00.ParallelAssemble();
312
313 // Construct Schur-complement preconditioner
314 HypreParVector A00_diag(MPI_COMM_WORLD, A00->GetGlobalNumRows(),
315 A00->GetRowStarts());
316 A00->GetDiag(A00_diag);
317 HypreParMatrix S_tmp(*A01);
318 S_tmp.InvScaleRows(A00_diag);
319 HypreParMatrix *S = ParMult(A10, &S_tmp, true);
320
321 BlockDiagonalPreconditioner prec(toffsets);
322 HypreBoomerAMG P00(*A00);
323 P00.SetPrintLevel(0);
324 HypreBoomerAMG P11(*S);
325 P11.SetPrintLevel(0);
326 prec.SetDiagonalBlock(0,&P00);
327 prec.SetDiagonalBlock(1,&P11);
328
329 BlockOperator A(toffsets);
330 A.SetBlock(0,0,A00);
331 A.SetBlock(1,0,A10);
332 A.SetBlock(0,1,A01);
333
334 MINRESSolver minres(MPI_COMM_WORLD);
335 minres.SetPrintLevel(-1);
336 minres.SetRelTol(1e-12);
337 minres.SetMaxIter(10000);
338 minres.SetOperator(A);
339 minres.SetPreconditioner(prec);
340 minres.Mult(trhs,tx);
341 delete S;
342 delete A00;
343
344 delta_psi_gf.SetFromTrueDofs(tx.GetBlock(0));
345 u_gf.SetFromTrueDofs(tx.GetBlock(1));
346
347 u_tmp -= u_gf;
348 real_t Newton_update_size = u_tmp.ComputeL2Error(zero_cf);
349 u_tmp = u_gf;
350
351 // Damped Newton update
352 psi_gf.Add(newton_scaling, delta_psi_gf);
353 a00.Update();
354
355 if (visualization)
356 {
357 sol_sock << "parallel " << num_procs << " " << myid << "\n";
358 sol_sock << "solution\n" << pmesh << u_gf << "window_title 'Discrete solution'"
359 << flush;
360 }
361
362 if (myid == 0)
363 {
364 mfem::out << "Newton_update_size = " << Newton_update_size << endl;
365 }
366
367 if (newton_scaling*Newton_update_size < increment_u)
368 {
369 break;
370 }
371 }
372
373 u_tmp = u_gf;
374 u_tmp -= u_old_gf;
375 increment_u = u_tmp.ComputeL2Error(zero_cf);
376
377 if (myid == 0)
378 {
379 mfem::out << "Number of Newton iterations = " << j+1 << endl;
380 mfem::out << "Increment (|| uโ‚• - uโ‚•_prvs||) = " << increment_u << endl;
381 }
382
383 u_old_gf = u_gf;
384 psi_old_gf = psi_gf;
385 alpha *= max(growth_rate, 1_r);
386
387 // Safeguard 1: Stop alpha from growing too large
388 alpha = min(alpha, max_alpha);
389
390 // Safeguard 2: Stop |ฯˆ| from growing too large
391 real_t norm_psi = psi_old_gf.ComputeL1Error(zero_vec_cf)/domain_volume;
392 if (norm_psi > max_psi)
393 {
394 // Additional entropy regularization
395 neg_alpha_cf.constant = -alpha/(1.0 + eps2 * alpha * hmax);
396 psi_old_minus_psi.SetAlpha(1.0/(1.0 + eps2 * alpha * hmax));
397 }
398 else
399 {
400 neg_alpha_cf.constant = -alpha;
401 }
402
403 if (increment_u < tol || k == max_it-1)
404 {
405 break;
406 }
407
408 }
409
410 // 12. Print stats.
411 if (myid == 0)
412 {
413 mfem::out << "\n Outer iterations: " << k+1
414 << "\n Total iterations: " << total_iterations
415 << "\n Total dofs: " << RTfes.GetTrueVSize() + L2fes.GetTrueVSize()
416 << endl;
417 }
418
419 // 13. Free the used memory.
420 delete A01;
421 delete A10;
422 return 0;
423}
424
425void IsomorphismCoefficient::Eval(Vector &V, ElementTransformation &T,
426 const IntegrationPoint &ip)
427{
428 MFEM_ASSERT(psi != NULL, "grid function is not set");
429
430 Vector psi_vals(vdim);
431 psi->GetVectorValue(T, ip, psi_vals);
432 real_t norm = psi_vals.Norml2();
433 real_t phi = 1.0 / sqrt(1.0 + norm*norm);
434
435 V = psi_vals;
436 V *= phi;
437}
438
439void DIsomorphismCoefficient::Eval(DenseMatrix &K, ElementTransformation &T,
440 const IntegrationPoint &ip)
441{
442 MFEM_ASSERT(psi != NULL, "grid function is not set");
443 MFEM_ASSERT(eps >= 0, "eps is negative");
444
445 Vector psi_vals(height);
446 psi->GetVectorValue(T, ip, psi_vals);
447 real_t norm = psi_vals.Norml2();
448 real_t phi = 1.0 / sqrt(1.0 + norm*norm);
449
450 K = 0.0;
451 for (int i = 0; i < height; i++)
452 {
453 K(i,i) = phi + eps;
454 for (int j = 0; j < height; j++)
455 {
456 K(i,j) -= psi_vals(i) * psi_vals(j) * pow(phi, 3);
457 }
458 }
459}
int Size() const
Return the logical size of the array.
Definition array.hpp:147
void PartialSum()
Fill the entries of the array with the cumulative sum of the entries.
Definition array.cpp:103
void AddDomainIntegrator(BilinearFormIntegrator *bfi)
Adds new Domain Integrator. Assumes ownership of bfi.
void Finalize(int skip_zeros=1) override
Finalizes the matrix initialization if the AssemblyLevel is AssemblyLevel::LEGACY....
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.
Definition densemat.hpp:24
Scalar coefficient defined as the Divergence of a vector GridFunction.
Class for domain integration .
Definition lininteg.hpp:106
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Definition fespace.hpp:848
virtual void GetVectorValue(int i, const IntegrationPoint &ip, Vector &val) const
Definition gridfunc.cpp:473
The BoomerAMG solver in hypre.
Definition hypre.hpp:1717
void SetPrintLevel(int print_level)
Definition hypre.hpp:1797
Wrapper for hypre's ParCSR matrix class.
Definition hypre.hpp:408
void GetDiag(Vector &diag) const
Get the local diagonal of the matrix.
Definition hypre.cpp:1605
void InvScaleRows(const Vector &s)
Scale the local row i by 1./s(i)
Definition hypre.cpp:2181
HYPRE_BigInt * GetRowStarts() const
Return the parallel row partitioning array.
Definition hypre.hpp:709
HYPRE_BigInt GetGlobalNumRows() const
Return the global number of rows.
Definition hypre.hpp:699
HypreParMatrix * Transpose() const
Returns the transpose of *this.
Definition hypre.cpp:1730
Wrapper for hypre's parallel vector class.
Definition hypre.hpp:219
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
Definition hypre.cpp:33
Class for integration point with weight.
Definition intrules.hpp:35
void SetRelTol(real_t rtol)
Definition solvers.hpp:229
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
Definition solvers.cpp:72
void SetMaxIter(int max_it)
Definition solvers.hpp:231
Arbitrary order "L2-conforming" discontinuous finite elements.
Definition fe_coll.hpp:346
void AddDomainIntegrator(LinearFormIntegrator *lfi)
Adds new Domain Integrator. Assumes ownership of lfi.
MINRES method.
Definition solvers.hpp:653
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the MINRES method.
Definition solvers.cpp:1705
void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
Definition solvers.cpp:1680
void SetPreconditioner(Solver &pr) override
This should be called before SetOperator.
Definition solvers.hpp:665
Base class for Matrix Coefficients that optionally depend on time and space.
Mesh data type.
Definition mesh.hpp:64
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
Definition mesh.hpp:290
void Clear()
Clear the contents of the Mesh.
Definition mesh.hpp:761
int GetNE() const
Returns number of elements.
Definition mesh.hpp:1282
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1216
real_t GetElementSize(int i, int type=0)
Get the size of the i-th element relative to the perfect reference element.
Definition mesh.cpp:107
int SpaceDimension() const
Dimension of the physical space containing the mesh.
Definition mesh.hpp:1219
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.
Definition mesh.cpp:6484
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Definition mesh.cpp:11295
void Assemble(int skip_zeros=1)
void Finalize(int skip_zeros=1) override
Finalizes the matrix initialization if the AssemblyLevel is AssemblyLevel::LEGACY.
void AddDomainIntegrator(BilinearFormIntegrator *bfi)
Adds a domain integrator. Assumes ownership of bfi.
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...
Definition optparser.hpp:82
bool Good() const
Return true if the command line options were parsed successfully.
Class for parallel bilinear form.
HypreParMatrix * ParallelAssemble()
Returns the matrix assembled on the true dofs, i.e. P^t A P.
void Assemble(int skip_zeros=1)
Assemble the local matrix.
void Update(FiniteElementSpace *nfes=NULL) override
Update the FiniteElementSpace and delete all data associated with the old one.
Abstract parallel finite element space.
Definition pfespace.hpp:29
HYPRE_BigInt GlobalTrueVSize() const
Definition pfespace.hpp:346
int GetTrueVSize() const override
Return the number of local vector true dofs.
Definition pfespace.hpp:350
Class for parallel grid function.
Definition pgridfunc.hpp:50
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 linear form.
void ParallelAssemble(Vector &tv)
Assemble the vector on the true dofs, i.e. P^t v.
void Assemble()
Assembles the ParLinearForm i.e. sums over all domain/bdr integrators.
void MakeRef(FiniteElementSpace *f, Vector &v, int v_offset) override
Make the ParLinearForm reference external data on a new FiniteElementSpace.
Class for parallel meshes.
Definition pmesh.hpp:34
Class for parallel bilinear form using different test and trial FE spaces.
HypreParMatrix * ParallelAssemble()
Returns the matrix assembled on the true dofs, i.e. P_test^t A P_trial.
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
Definition fe_coll.hpp:403
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)
Definition lininteg.hpp:344
Vector data type.
Definition vector.hpp:82
Vector & Add(const real_t a, const Vector &Va)
(*this) += a * Va
Definition vector.cpp:322
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
const real_t alpha
Definition ex15.cpp:369
int dim
Definition ex24.cpp:53
int main()
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
Definition globals.hpp:66
HypreParMatrix * ParMult(const HypreParMatrix *A, const HypreParMatrix *B, bool own_matrix)
Definition hypre.cpp:3007
float real_t
Definition config.hpp:43
const char vishost[]