MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
pdiffusion.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11//
12// MFEM ultraweak DPG parallel example for diffusion
13//
14// Compile with: make pdiffusion
15//
16// Sample runs
17// mpirun -np 4 pdiffusion -m ../../data/inline-quad.mesh -o 3 -sref 1 -pref 2 -theta 0.0 -prob 0
18// mpirun -np 4 pdiffusion -m ../../data/inline-hex.mesh -o 2 -sref 0 -pref 1 -theta 0.0 -prob 0 -sc
19// mpirun -np 4 pdiffusion -m ../../data/beam-tet.mesh -o 3 -sref 0 -pref 2 -theta 0.0 -prob 0 -sc
20
21// L-shape runs
22// Note: uniform ref are expected to give sub-optimal rate for the L-shape problem (rate = 2/3)
23// mpirun -np 4 pdiffusion -o 2 -sref 1 -pref 5 -theta 0.0 -prob 1
24
25// L-shape AMR runs
26// mpirun -np 4 pdiffusion -o 1 -sref 1 -pref 10 -theta 0.8 -prob 1
27// mpirun -np 4 pdiffusion -o 2 -sref 1 -pref 8 -theta 0.75 -prob 1 -sc
28// mpirun -np 4 pdiffusion -o 3 -sref 1 -pref 6 -theta 0.75 -prob 1 -sc -do 2
29
30// Description:
31// This example code demonstrates the use of MFEM to define and solve
32// the "ultraweak" (UW) DPG formulation for the Poisson problem in parallel
33
34// - Δ u = f, in Ω
35// u = u₀, on ∂Ω
36//
37// It solves two kinds of problems
38// a) A manufactured solution problem where u_exact = sin(π * (x + y + z)).
39// This example computes and prints out convergence rates for the L2 error.
40// b) The L-shape benchmark problem with AMR. The AMR process is driven by the
41// DPG built-in residual indicator.
42
43// The DPG UW deals with the First Order System
44// ∇ u - σ = 0, in Ω
45// - ∇⋅σ = f, in Ω
46// u = u₀, in ∂Ω
47
48// Ultraweak-DPG is obtained by integration by parts of both equations and the
49// introduction of trace unknowns on the mesh skeleton
50
51// u ∈ L²(Ω), σ ∈ (L²(Ω))ᵈⁱᵐ
52// û ∈ H^1/2, σ̂ ∈ H^-1/2
53// -(u , ∇⋅τ) + < û, τ⋅n> - (σ , τ) = 0, ∀ τ ∈ H(div,Ω)
54// (σ , ∇ v) - < σ̂, v > = (f,v) ∀ v ∈ H¹(Ω)
55// û = u₀ on ∂Ω
56
57// Note:
58// û := u and σ̂ := -σ on the mesh skeleton
59
60// -------------------------------------------------------------
61// | | u | σ | û | σ̂ | RHS |
62// -------------------------------------------------------------
63// | τ | -(u,∇⋅τ) | -(σ,τ) | < û, τ⋅n> | | 0 |
64// | | | | | | |
65// | v | | (σ,∇ v) | | -<σ̂,v> | (f,v) |
66
67// where (τ,v) ∈ H(div,Ω) × H¹(Ω)
68
69// For more information see https://doi.org/10.1007/978-3-319-01818-8_6
70
71#include "mfem.hpp"
72#include "util/pweakform.hpp"
74#include <fstream>
75#include <iostream>
76
77using namespace std;
78using namespace mfem;
79using namespace mfem::common;
80
86
87static const char *enum_str[] =
88{
89 "manufactured",
90 "lshape"
91};
92
94
95real_t exact_u(const Vector & X);
96void exact_gradu(const Vector & X, Vector &gradu);
98void exact_sigma(const Vector & X, Vector & sigma);
99real_t exact_hatu(const Vector & X);
100void exact_hatsigma(const Vector & X, Vector & hatsigma);
101real_t f_exact(const Vector & X);
102
103int main(int argc, char *argv[])
104{
105 // 0. Initialize MPI and HYPRE.
106 Mpi::Init();
107 int myid = Mpi::WorldRank();
108 Hypre::Init();
109
110 // 1. Parse command-line options.
111 const char *mesh_file = "../../data/inline-quad.mesh";
112 int order = 1;
113 int delta_order = 1;
114 int sref = 0; // initial uniform mesh refinements
115 int pref = 0; // parallel mesh refinements for AMR
116 int iprob = 0;
117 bool static_cond = false;
118 real_t theta = 0.7;
119 bool visualization = true;
120 int visport = 19916;
121 bool paraview = false;
122
123 OptionsParser args(argc, argv);
124 args.AddOption(&mesh_file, "-m", "--mesh",
125 "Mesh file to use.");
126 args.AddOption(&order, "-o", "--order",
127 "Finite element order (polynomial degree).");
128 args.AddOption(&delta_order, "-do", "--delta_order",
129 "Order enrichment for DPG test space.");
130 args.AddOption(&sref, "-sref", "--num-serial-refinements",
131 "Number of initial serial uniform refinements");
132 args.AddOption(&pref, "-pref", "--num-parallel-refinements",
133 "Number of AMR refinements");
134 args.AddOption(&theta, "-theta", "--theta-factor",
135 "Refinement factor (0 indicates uniform refinements) ");
136 args.AddOption(&iprob, "-prob", "--problem", "Problem case"
137 " 0: manufactured, 1: L-shape");
138 args.AddOption(&static_cond, "-sc", "--static-condensation", "-no-sc",
139 "--no-static-condensation", "Enable static condensation.");
140 args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
141 "--no-visualization",
142 "Enable or disable GLVis visualization.");
143 args.AddOption(&paraview, "-paraview", "--paraview", "-no-paraview",
144 "--no-paraview",
145 "Enable or disable ParaView visualization.");
146 args.AddOption(&visport, "-p", "--send-port", "Socket for GLVis.");
147 args.Parse();
148 if (!args.Good())
149 {
150 if (myid == 0)
151 {
152 args.PrintUsage(cout);
153 }
154 return 1;
155 }
156
157 if (iprob > 1) { iprob = 1; }
158 prob = (prob_type)iprob;
159
160 if (prob == prob_type::lshape)
161 {
162 mesh_file = "../../data/l-shape.mesh";
163 }
164
165 if (myid == 0)
166 {
167 args.PrintOptions(cout);
168 }
169
170 Mesh mesh(mesh_file, 1, 1);
171 int dim = mesh.Dimension();
172 MFEM_VERIFY(dim > 1, "Dimension = 1 is not supported in this example");
173
174 if (prob == prob_type::lshape)
175 {
176 /** rotate mesh to be consistent with l-shape benchmark problem
177 See https://doi.org/10.1016/j.amc.2013.05.068 */
178 mesh.EnsureNodes();
179 GridFunction *nodes = mesh.GetNodes();
180 int size = nodes->Size()/2;
181 for (int i = 0; i<size; i++)
182 {
183 real_t x = (*nodes)[2*i];
184 (*nodes)[2*i] = 2*(*nodes)[2*i+1]-1;
185 (*nodes)[2*i+1] = -2*x+1;
186 }
187 }
188
189
190 for (int i = 0; i<sref; i++)
191 {
192 mesh.UniformRefinement();
193 }
194
195 mesh.EnsureNCMesh();
196
197 ParMesh pmesh(MPI_COMM_WORLD, mesh);
198 mesh.Clear();
199
200 // Define spaces
201 enum TrialSpace
202 {
203 u_space = 0,
204 sigma_space = 1,
205 hatu_space = 2,
206 hatsigma_space = 3
207 };
208 enum TestSpace
209 {
210 tau_space = 0,
211 v_space = 1
212 };
213 // L2 space for u
214 FiniteElementCollection *u_fec = new L2_FECollection(order-1,dim);
215 ParFiniteElementSpace *u_fes = new ParFiniteElementSpace(&pmesh,u_fec);
216
217 // Vector L2 space for σ
218 FiniteElementCollection *sigma_fec = new L2_FECollection(order-1,dim);
219 ParFiniteElementSpace *sigma_fes = new ParFiniteElementSpace(&pmesh,sigma_fec,
220 dim);
221
222 // H^1/2 space for û
223 FiniteElementCollection * hatu_fec = new H1_Trace_FECollection(order,dim);
224 ParFiniteElementSpace *hatu_fes = new ParFiniteElementSpace(&pmesh,hatu_fec);
225
226 // H^-1/2 space for σ̂
227 FiniteElementCollection * hatsigma_fec = new RT_Trace_FECollection(order-1,dim);
228 ParFiniteElementSpace *hatsigma_fes = new ParFiniteElementSpace(&pmesh,
229 hatsigma_fec);
230
231 // testspace fe collections
232 int test_order = order+delta_order;
233 FiniteElementCollection * tau_fec = new RT_FECollection(test_order-1, dim);
234 FiniteElementCollection * v_fec = new H1_FECollection(test_order, dim);
235
238
239 trial_fes.Append(u_fes);
240 trial_fes.Append(sigma_fes);
241 trial_fes.Append(hatu_fes);
242 trial_fes.Append(hatsigma_fes);
243 test_fec.Append(tau_fec);
244 test_fec.Append(v_fec);
245
246 // Required coefficients for the weak formulation
247 ConstantCoefficient one(1.0);
248 ConstantCoefficient negone(-1.0);
249 FunctionCoefficient f(f_exact); // rhs for the manufactured solution problem
250
251 // Required coefficients for the exact solutions
255
256 ParDPGWeakForm * a = new ParDPGWeakForm(trial_fes,test_fec);
257 a->StoreMatrices(true); // this is needed for estimation of residual
258
259 // -(u,∇⋅τ)
260 a->AddTrialIntegrator(new MixedScalarWeakGradientIntegrator(one),
261 TrialSpace::u_space,TestSpace::tau_space);
262
263 // -(σ,τ)
264 a->AddTrialIntegrator(new TransposeIntegrator(new VectorFEMassIntegrator(
265 negone)), TrialSpace::sigma_space, TestSpace::tau_space);
266
267 // (σ,∇ v)
268 a->AddTrialIntegrator(new TransposeIntegrator(new GradientIntegrator(one)),
269 TrialSpace::sigma_space,TestSpace::v_space);
270
271 // <û,τ⋅n>
272 a->AddTrialIntegrator(new NormalTraceIntegrator,
273 TrialSpace::hatu_space,TestSpace::tau_space);
274
275 // -<σ̂,v> (sign is included in σ̂)
276 a->AddTrialIntegrator(new TraceIntegrator,
277 TrialSpace::hatsigma_space, TestSpace::v_space);
278
279 // test integrators (space-induced norm for H(div) × H1)
280 // (∇⋅τ,∇⋅δτ)
281 a->AddTestIntegrator(new DivDivIntegrator(one),
282 TestSpace::tau_space, TestSpace::tau_space);
283 // (τ,δτ)
284 a->AddTestIntegrator(new VectorFEMassIntegrator(one),
285 TestSpace::tau_space, TestSpace::tau_space);
286 // (∇v,∇δv)
287 a->AddTestIntegrator(new DiffusionIntegrator(one),
288 TestSpace::v_space, TestSpace::v_space);
289 // (v,δv)
290 a->AddTestIntegrator(new MassIntegrator(one),
291 TestSpace::v_space, TestSpace::v_space);
292
293 // RHS
294 if (prob == prob_type::manufactured)
295 {
296 a->AddDomainLFIntegrator(new DomainLFIntegrator(f),TestSpace::v_space);
297 }
298
299 // GridFunction for Dirichlet bdr data
300 ParGridFunction hatu_gf;
301
302 // Visualization streams
303 socketstream u_out;
304 socketstream sigma_out;
305
306 if (myid == 0)
307 {
308 std::cout << "\n Ref |"
309 << " Dofs |"
310 << " L2 Error |"
311 << " Rate |"
312 << " Residual |"
313 << " Rate |"
314 << " PCG it |" << endl;
315 std::cout << std::string(72,'-') << endl;
316 }
317
318 Array<int> elements_to_refine; // for AMR
319 real_t err0 = 0.;
320 int dof0=0.;
321 real_t res0=0.0;
322
323 ParGridFunction u_gf(u_fes);
324 ParGridFunction sigma_gf(sigma_fes);
325 u_gf = 0.0;
326 sigma_gf = 0.0;
327
328 ParaViewDataCollection * paraview_dc = nullptr;
329
330 if (paraview)
331 {
332 paraview_dc = new ParaViewDataCollection(enum_str[prob], &pmesh);
333 paraview_dc->SetPrefixPath("ParaView/Diffusion");
334 paraview_dc->SetLevelsOfDetail(order);
335 paraview_dc->SetCycle(0);
336 paraview_dc->SetDataFormat(VTKFormat::BINARY);
337 paraview_dc->SetHighOrderOutput(true);
338 paraview_dc->SetTime(0.0); // set the time
339 paraview_dc->RegisterField("u",&u_gf);
340 paraview_dc->RegisterField("sigma",&sigma_gf);
341 }
342
343 if (static_cond) { a->EnableStaticCondensation(); }
344 for (int it = 0; it<=pref; it++)
345 {
346 a->Assemble();
347
348 Array<int> ess_tdof_list;
349 Array<int> ess_bdr;
350 if (pmesh.bdr_attributes.Size())
351 {
352 ess_bdr.SetSize(pmesh.bdr_attributes.Max());
353 ess_bdr = 1;
354 hatu_fes->GetEssentialTrueDofs(ess_bdr, ess_tdof_list);
355 }
356
357 // shift the ess_tdofs
358 for (int i = 0; i < ess_tdof_list.Size(); i++)
359 {
360 ess_tdof_list[i] += u_fes->GetTrueVSize() + sigma_fes->GetTrueVSize();
361 }
362
363 Array<int> offsets(5);
364 offsets[0] = 0;
365 offsets[1] = u_fes->GetVSize();
366 offsets[2] = sigma_fes->GetVSize();
367 offsets[3] = hatu_fes->GetVSize();
368 offsets[4] = hatsigma_fes->GetVSize();
369 offsets.PartialSum();
370 BlockVector x(offsets);
371 x = 0.0;
372 hatu_gf.MakeRef(hatu_fes,x.GetBlock(2),0);
373 hatu_gf.ProjectBdrCoefficient(uex,ess_bdr);
374
375 Vector X,B;
376 OperatorPtr Ah;
377 a->FormLinearSystem(ess_tdof_list,x,Ah,X,B);
378
379 BlockOperator * A = Ah.As<BlockOperator>();
380
382 M.owns_blocks = 1;
383 int skip = 0;
384 if (!static_cond)
385 {
386 HypreBoomerAMG * amg0 = new HypreBoomerAMG((HypreParMatrix &)A->GetBlock(0,0));
387 HypreBoomerAMG * amg1 = new HypreBoomerAMG((HypreParMatrix &)A->GetBlock(1,1));
388 amg0->SetPrintLevel(0);
389 amg1->SetPrintLevel(0);
390 M.SetDiagonalBlock(0,amg0);
391 M.SetDiagonalBlock(1,amg1);
392 skip=2;
393 }
395 skip));
396 amg2->SetPrintLevel(0);
397 M.SetDiagonalBlock(skip,amg2);
398 HypreSolver * prec;
399 if (dim == 2)
400 {
401 // AMS preconditioner for 2D H(div) (trace) space
402 prec = new HypreAMS((HypreParMatrix &)A->GetBlock(skip+1,skip+1), hatsigma_fes);
403 }
404 else
405 {
406 // ADS preconditioner for 3D H(div) (trace) space
407 prec = new HypreADS((HypreParMatrix &)A->GetBlock(skip+1,skip+1), hatsigma_fes);
408 }
409 M.SetDiagonalBlock(skip+1,prec);
410
411 CGSolver cg(MPI_COMM_WORLD);
412 cg.SetRelTol(1e-12);
413 cg.SetMaxIter(2000);
414 cg.SetPrintLevel(0);
415 cg.SetPreconditioner(M);
416 cg.SetOperator(*A);
417 cg.Mult(B, X);
418
419 a->RecoverFEMSolution(X,x);
420
421 Vector & residuals = a->ComputeResidual(x);
422
423 real_t residual = residuals.Norml2();
424
425 real_t maxresidual = residuals.Max();
426 real_t globalresidual = residual * residual;
427
428 MPI_Allreduce(MPI_IN_PLACE, &maxresidual, 1, MPITypeMap<real_t>::mpi_type,
429 MPI_MAX, MPI_COMM_WORLD);
430 MPI_Allreduce(MPI_IN_PLACE, &globalresidual, 1,
431 MPITypeMap<real_t>::mpi_type, MPI_SUM, MPI_COMM_WORLD);
432
433 globalresidual = sqrt(globalresidual);
434
435 u_gf.MakeRef(u_fes,x.GetBlock(0),0);
436 sigma_gf.MakeRef(sigma_fes,x.GetBlock(1),0);
437
438 int dofs = u_fes->GlobalTrueVSize() + sigma_fes->GlobalTrueVSize()
439 + hatu_fes->GlobalTrueVSize() + hatsigma_fes->GlobalTrueVSize();
440
441 real_t u_err = u_gf.ComputeL2Error(uex);
442 real_t sigma_err = sigma_gf.ComputeL2Error(sigmaex);
443 real_t L2Error = sqrt(u_err*u_err + sigma_err*sigma_err);
444 real_t rate_err = (it) ? dim*log(err0/L2Error)/log((real_t)dof0/dofs) : 0.0;
445 real_t rate_res = (it) ? dim*log(res0/globalresidual)/log((
446 real_t)dof0/dofs) : 0.0;
447 err0 = L2Error;
448 res0 = globalresidual;
449 dof0 = dofs;
450
451 if (myid == 0)
452 {
453 std::ios oldState(nullptr);
454 oldState.copyfmt(std::cout);
455 std::cout << std::right << std::setw(5) << it << " | "
456 << std::setw(10) << dof0 << " | "
457 << std::setprecision(3)
458 << std::setw(10) << std::scientific << err0 << " | "
459 << std::setprecision(2)
460 << std::setw(6) << std::fixed << rate_err << " | "
461 << std::setprecision(3)
462 << std::setw(10) << std::scientific << res0 << " | "
463 << std::setprecision(2)
464 << std::setw(6) << std::fixed << rate_res << " | "
465 << std::setw(6) << std::fixed << cg.GetNumIterations() << " | "
466 << std::endl;
467 std::cout.copyfmt(oldState);
468 }
469
470 if (visualization)
471 {
472 const char * keys = (it == 0 && dim == 2) ? "jRcm\n" : nullptr;
473 char vishost[] = "localhost";
474
475 VisualizeField(u_out,vishost,visport,u_gf,
476 "Numerical u", 0,0,500,500,keys);
477 VisualizeField(sigma_out,vishost,visport,sigma_gf,
478 "Numerical flux", 500,0,500,500,keys);
479 }
480
481 if (paraview)
482 {
483 paraview_dc->SetCycle(it);
484 paraview_dc->SetTime((real_t)it);
485 paraview_dc->Save();
486 }
487
488 if (it == pref) { break; }
489
490 elements_to_refine.SetSize(0);
491 for (int iel = 0; iel<pmesh.GetNE(); iel++)
492 {
493 if (residuals[iel] >= theta * maxresidual)
494 {
495 elements_to_refine.Append(iel);
496 }
497 }
498
499 pmesh.GeneralRefinement(elements_to_refine);
500
501 for (int i =0; i<trial_fes.Size(); i++)
502 {
503 trial_fes[i]->Update(false);
504 }
505 a->Update();
506 }
507
508 if (paraview)
509 {
510 delete paraview_dc;
511 }
512
513 delete a;
514 delete tau_fec;
515 delete v_fec;
516 delete hatsigma_fes;
517 delete hatsigma_fec;
518 delete hatu_fes;
519 delete hatu_fec;
520 delete sigma_fec;
521 delete sigma_fes;
522 delete u_fec;
523 delete u_fes;
524
525 return 0;
526}
527
529{
530 switch (prob)
531 {
533 {
534 real_t x = X[0];
535 real_t y = X[1];
536 real_t r = sqrt(x*x + y*y);
537 real_t alpha = 2./3.;
538 real_t phi = atan2(y,x);
539 if (phi < 0) { phi += 2*M_PI; }
540 return pow(r,alpha) * sin(alpha * phi);
541 }
542 break;
543 default:
544 {
545 real_t alpha = M_PI * (X.Sum());
546 return sin(alpha);
547 }
548 break;
549 }
550}
551
552void exact_gradu(const Vector & X, Vector & du)
553{
554 du.SetSize(X.Size());
555 switch (prob)
556 {
558 {
559 real_t x = X[0];
560 real_t y = X[1];
561 real_t r = sqrt(x*x + y*y);
562 real_t alpha = 2./3.;
563 real_t phi = atan2(y,x);
564 if (phi < 0) { phi += 2*M_PI; }
565
566 real_t r_x = x/r;
567 real_t r_y = y/r;
568 real_t phi_x = - y / (r*r);
569 real_t phi_y = x / (r*r);
570 real_t beta = alpha * pow(r,alpha - 1.);
571 du[0] = beta*(r_x * sin(alpha*phi) + r * phi_x * cos(alpha*phi));
572 du[1] = beta*(r_y * sin(alpha*phi) + r * phi_y * cos(alpha*phi));
573 }
574 break;
575 default:
576 {
577 real_t alpha = M_PI * (X.Sum());
578 du.SetSize(X.Size());
579 for (int i = 0; i<du.Size(); i++)
580 {
581 du[i] = M_PI * cos(alpha);
582 }
583 }
584 break;
585 }
586}
587
589{
590 switch (prob)
591 {
592 case prob_type::manufactured:
593 {
594 real_t alpha = M_PI * (X.Sum());
595 real_t u = sin(alpha);
596 return - M_PI*M_PI * u * X.Size();
597 }
598 break;
599 default:
600 MFEM_ABORT("Should be unreachable");
601 return 1;
602 break;
603 }
604}
605
606void exact_sigma(const Vector & X, Vector & sigma)
607{
608 // σ = ∇ u
610}
611
613{
614 return exact_u(X);
615}
616
617void exact_hatsigma(const Vector & X, Vector & hatsigma)
618{
619 exact_sigma(X,hatsigma);
620 hatsigma *= -1.;
621}
622
624{
625 MFEM_VERIFY(prob!=prob_type::lshape,
626 "f_exact should not be called for l-shape benchmark problem, i.e., f = 0")
627 return -exact_laplacian_u(X);
628}
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Definition array.cpp:68
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
Definition array.hpp:758
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
int Append(const T &el)
Append element 'el' to array, resize if necessary.
Definition array.hpp:830
A class to handle Block diagonal preconditioners in a matrix-free implementation.
A class to handle Block systems in a matrix-free implementation.
Array< int > & RowOffsets()
Return the row offsets for block starts.
Operator & GetBlock(int i, int j)
Return a reference to block i,j.
A class to handle Vectors in a block fashion.
Vector & GetBlock(int i)
Get the i-th vector in the block.
Conjugate gradient method.
Definition solvers.hpp:538
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the Conjugate Gradient method.
Definition solvers.cpp:751
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
Definition solvers.hpp:551
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)
void SetPrefixPath(const std::string &prefix)
Set the path where the DataCollection will be saved.
for Raviart-Thomas elements
Class for domain integration .
Definition lininteg.hpp:106
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Definition fe_coll.hpp:27
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Definition fespace.hpp:848
A general function coefficient.
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:31
Arbitrary order H1-conforming (continuous) finite elements.
Definition fe_coll.hpp:275
Arbitrary order "H^{1/2}-conforming" trace finite elements defined on the interface between mesh elem...
Definition fe_coll.hpp:338
The Auxiliary-space Divergence Solver in hypre.
Definition hypre.hpp:1948
The Auxiliary-space Maxwell Solver in hypre.
Definition hypre.hpp:1871
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
Abstract class for hypre's solvers and preconditioners.
Definition hypre.hpp:1188
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
Definition hypre.cpp:33
void SetRelTol(real_t rtol)
Definition solvers.hpp:229
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Definition solvers.cpp:174
int GetNumIterations() const
Returns the number of iterations taken during the last call to Mult()
Definition solvers.hpp:280
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
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 GeneralRefinement(const Array< Refinement > &refinements, int nonconforming=-1, int nc_limit=0)
Definition mesh.cpp:10883
void EnsureNodes()
Make sure that the mesh has valid nodes, i.e. its geometry is described by a vector finite element gr...
Definition mesh.cpp:6432
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
void GetNodes(Vector &node_coord) const
Definition mesh.cpp:9294
void EnsureNCMesh(bool simplices_nonconforming=false)
Definition mesh.cpp:10951
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Definition mesh.cpp:11295
static int WorldRank()
Return the MPI rank in 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).
Pointer to an Operator of a specified type.
Definition handle.hpp:34
OpType * As() const
Return the Operator pointer statically cast to a specified OpType. Similar to the method Get().
Definition handle.hpp:104
void FormLinearSystem(const Array< int > &ess_tdof_list, Vector &x, Vector &b, Operator *&A, Vector &X, Vector &B, int copy_interior=0)
Form a constrained linear system using a matrix-free approach.
Definition operator.cpp:114
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 representing the parallel weak formulation. (Convenient for DPG Equations)
Definition pweakform.hpp:26
Abstract parallel finite element space.
Definition pfespace.hpp:29
void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1) const override
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 ProjectBdrCoefficient(Coefficient *coeff[], VectorCoefficient *vcoeff, const Array< int > &attr)
void MakeRef(FiniteElementSpace *f, real_t *v) override
Make the ParGridFunction reference external data on a new FiniteElementSpace.
Class for parallel meshes.
Definition pmesh.hpp:34
Helper class for ParaView visualization data.
void SetHighOrderOutput(bool high_order_output_)
void SetLevelsOfDetail(int levels_of_detail_)
void SetDataFormat(VTKFormat fmt)
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
Definition fe_coll.hpp:403
Arbitrary order "H^{-1/2}-conforming" face finite elements defined on the interface between mesh elem...
Definition fe_coll.hpp:462
A general vector function coefficient.
Vector data type.
Definition vector.hpp:82
real_t Norml2() const
Returns the l2 norm of the vector.
Definition vector.cpp:931
real_t Max() const
Returns the maximal element of the vector.
Definition vector.cpp:1164
int Size() const
Returns the size of the vector.
Definition vector.hpp:226
real_t Sum() const
Return the sum of the vector entries.
Definition vector.cpp:1204
void SetSize(int s)
Resize the vector to size s.
Definition vector.hpp:558
Vector beta
real_t sigma(const Vector &x)
Definition maxwell.cpp:102
const real_t alpha
Definition ex15.cpp:369
int dim
Definition ex24.cpp:53
prob_type
Definition ex25.cpp:149
@ lshape
Definition ex25.cpp:152
int main()
real_t a
Definition lissajous.cpp:41
void VisualizeField(socketstream &sock, const char *vishost, int visport, GridFunction &gf, const char *title, int x, int y, int w, int h, const char *keys, bool vec)
real_t u(const Vector &xvec)
Definition lor_mms.hpp:22
float real_t
Definition config.hpp:43
std::function< real_t(const Vector &)> f(real_t mass_coeff)
Definition lor_mms.hpp:30
const char vishost[]
void exact_gradu(const Vector &X, Vector &gradu)
real_t exact_hatu(const Vector &X)
real_t exact_laplacian_u(const Vector &X)
real_t exact_u(const Vector &X)
void exact_sigma(const Vector &X, Vector &sigma)
void exact_hatsigma(const Vector &X, Vector &hatsigma)
prob_type prob
prob_type
@ manufactured
@ lshape
real_t f_exact(const Vector &X)
Helper struct to convert a C++ type to an MPI type.
std::array< int, NCMesh::MaxFaceNodes > nodes