MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
nurbs_ex5.cpp
Go to the documentation of this file.
1// MFEM Example 5 -- modified for NURBS FE
2//
3// Compile with: make nurbs_ex5
4//
5// Sample runs: nurbs_ex5 -m ../../data/square-nurbs.mesh -o 3
6// nurbs_ex5 -m ../../data/cube-nurbs.mesh -r 3
7// nurbs_ex5 -m ../../data/pipe-nurbs-2d.mesh
8// nurbs_ex5 -m ../../data/beam-tet.mesh
9// nurbs_ex5 -m ../../data/beam-hex.mesh
10// nurbs_ex5 -m ../../data/escher.mesh
11// nurbs_ex5 -m ../../data/fichera.mesh
12//
13// Device sample runs -- do not work for NURBS:
14// nurbs_ex5 -m ../../data/escher.mesh -pa -d cuda
15// nurbs_ex5 -m ../../data/escher.mesh -pa -d raja-cuda
16// nurbs_ex5 -m ../../data/escher.mesh -pa -d raja-omp
17//
18// Description: This example code solves a simple 2D/3D mixed Darcy problem
19// corresponding to the saddle point system
20//
21// k*u + grad p = f
22// - div u = g
23//
24// with natural boundary condition -p = <given pressure>.
25// Here, we use a given exact solution (u,p) and compute the
26// corresponding r.h.s. (f,g). We discretize with Raviart-Thomas
27// finite elements (velocity u) and piecewise discontinuous
28// polynomials (pressure p).
29//
30// NURBS-based H(div) spaces only implemented for meshes
31// consisting of a single patch.
32//
33// The example demonstrates the use of the BlockOperator class, as
34// well as the collective saving of several grid functions in
35// VisIt (visit.llnl.gov) and ParaView (paraview.org) formats.
36//
37// We recommend viewing examples 1-4 before viewing this example.
38
39// Sample runs: nurbs_ex3 -m ../../data/square-nurbs.mesh
40// nurbs_ex3 -m ../../data/square-nurbs.mesh -o 2
41// nurbs_ex3 -m ../../data/cube-nurbs.mesh
42
43
44#include "mfem.hpp"
45#include <fstream>
46#include <iostream>
47#include <algorithm>
48
49using namespace std;
50using namespace mfem;
51
52// Define the analytical solution and forcing terms / boundary conditions
53void uFun_ex(const Vector & x, Vector & u);
54real_t pFun_ex(const Vector & x);
55void fFun(const Vector & x, Vector & f);
56real_t gFun(const Vector & x);
57real_t f_natural(const Vector & x);
58
59int main(int argc, char *argv[])
60{
61 StopWatch chrono;
62
63 // 1. Parse command-line options.
64 const char *mesh_file = "../../data/square-nurbs.mesh";
65 int ref_levels = -1;
66 int order = 1;
67 bool pa = false;
68 const char *device_config = "cpu";
69 int visport = 19916;
70 bool visualization = 1;
71
72 OptionsParser args(argc, argv);
73 args.AddOption(&mesh_file, "-m", "--mesh",
74 "Mesh file to use.");
75 args.AddOption(&ref_levels, "-r", "--refine",
76 "Number of times to refine the mesh uniformly, -1 for auto.");
77 args.AddOption(&order, "-o", "--order",
78 "Finite element order (polynomial degree).");
79 args.AddOption(&pa, "-pa", "--partial-assembly", "-no-pa",
80 "--no-partial-assembly", "Enable Partial Assembly.");
81 args.AddOption(&device_config, "-d", "--device",
82 "Device configuration string, see Device::Configure().");
83 args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
84 "--no-visualization",
85 "Enable or disable GLVis visualization.");
86 args.AddOption(&visport, "-p", "--send-port", "Socket for GLVis.");
87 args.Parse();
88 if (!args.Good())
89 {
90 args.PrintUsage(cout);
91 return 1;
92 }
93 args.PrintOptions(cout);
94
95 // 2. Enable hardware devices such as GPUs, and programming models such as
96 // CUDA, OCCA, RAJA and OpenMP based on command line options.
97 Device device(device_config);
98 device.Print();
99
100 // 3. Read the mesh from the given mesh file. We can handle triangular,
101 // quadrilateral, tetrahedral, hexahedral, surface and volume meshes with
102 // the same code.
103 Mesh *mesh = new Mesh(mesh_file, 1, 1);
104 int dim = mesh->Dimension();
105
106 // 4. Refine the mesh to increase the resolution. In this example we do
107 // 'ref_levels' of uniform refinement. We choose 'ref_levels' to be the
108 // largest number that gives a final mesh with no more than 10,000
109 // elements.
110 {
111 if (ref_levels < 0)
112 {
113 ref_levels =
114 (int)floor(log(10000./mesh->GetNE())/log(2.)/dim);
115 }
116 for (int l = 0; l < ref_levels; l++)
117 {
118 mesh->UniformRefinement();
119 }
120 }
121
122 // 5. Define a finite element space on the mesh. Here we use the
123 // Raviart-Thomas finite elements of the specified order.
124 FiniteElementCollection *hdiv_coll = nullptr;
125 FiniteElementCollection *l2_coll = nullptr;
126 NURBSExtension *NURBSext = nullptr;
127
128 if (mesh->NURBSext && !pa)
129 {
130 hdiv_coll = new NURBS_HDivFECollection(order,dim);
131 l2_coll = new NURBSFECollection(order);
132 NURBSext = new NURBSExtension(mesh->NURBSext, order);
133 mfem::out<<"Create NURBS fec and ext"<<std::endl;
134 }
135 else
136 {
137 hdiv_coll = new RT_FECollection(order, dim);
138 l2_coll = new L2_FECollection(order, dim);
139 mfem::out<<"Create Normal fec"<<std::endl;
140 }
141 pa = false;
142 FiniteElementSpace *W_space = new FiniteElementSpace(mesh, NURBSext, l2_coll);
143 FiniteElementSpace *R_space = new FiniteElementSpace(mesh,
144 W_space->StealNURBSext(),
145 hdiv_coll);
146
147 // 6. Define the BlockStructure of the problem, i.e. define the array of
148 // offsets for each variable. The last component of the Array is the sum
149 // of the dimensions of each block.
150 Array<int> block_offsets(3); // number of variables + 1
151 block_offsets[0] = 0;
152 block_offsets[1] = R_space->GetVSize();
153 block_offsets[2] = W_space->GetVSize();
154 block_offsets.PartialSum();
155
156 std::cout << "***********************************************************\n";
157 std::cout << "dim(R) = " << block_offsets[1] - block_offsets[0] << "\n";
158 std::cout << "dim(W) = " << block_offsets[2] - block_offsets[1] << "\n";
159 std::cout << "dim(R+W) = " << block_offsets.Last() << "\n";
160 std::cout << "***********************************************************\n";
161 {
162 Array<int> ess_tdof_list;
163 if (mesh->bdr_attributes.Size())
164 {
165 Array<int> ess_bdr(mesh->bdr_attributes.Max());
166 ess_bdr = 1;
167 R_space->GetEssentialTrueDofs(ess_bdr, ess_tdof_list);
168 }
169 cout << "Number boundary dofs in H(div): "
170 << ess_tdof_list.Size() << endl;
171 }
172
173 {
174 Array<int> ess_tdof_list;
175 if (mesh->bdr_attributes.Size())
176 {
177 Array<int> ess_bdr(mesh->bdr_attributes.Max());
178 ess_bdr = 1;
179 W_space->GetEssentialTrueDofs(ess_bdr, ess_tdof_list);
180 }
181 cout << "Number boundary dofs in H1: "
182 << ess_tdof_list.Size() << endl;
183 }
184
185 // 7. Define the coefficients, analytical solution, and rhs of the PDE.
186 ConstantCoefficient k(1.0);
187
191
194
195 // 8. Allocate memory (x, rhs) for the analytical solution and the right hand
196 // side. Define the GridFunction u,p for the finite element solution and
197 // linear forms fform and gform for the right hand side. The data
198 // allocated by x and rhs are passed as a reference to the grid functions
199 // (u,p) and the linear forms (fform, gform).
200 MemoryType mt = device.GetMemoryType();
201 BlockVector x(block_offsets, mt), rhs(block_offsets, mt);
202
203 LinearForm *fform(new LinearForm);
204 fform->Update(R_space, rhs.GetBlock(0), 0);
207 fform->Assemble();
208 fform->SyncAliasMemory(rhs);
209
210 LinearForm *gform(new LinearForm);
211 gform->Update(W_space, rhs.GetBlock(1), 0);
212 gform->AddDomainIntegrator(new DomainLFIntegrator(gcoeff));
213 gform->Assemble();
214 gform->SyncAliasMemory(rhs);
215
216 // 9. Assemble the finite element matrices for the Darcy operator
217 //
218 // D = [ M B^T ]
219 // [ B 0 ]
220 // where:
221 //
222 // M = \int_\Omega k u_h \cdot v_h d\Omega u_h, v_h \in R_h
223 // B = -\int_\Omega \div u_h q_h d\Omega u_h \in R_h, q_h \in W_h
224 BilinearForm *mVarf(new BilinearForm(R_space));
225 MixedBilinearForm *bVarf(new MixedBilinearForm(R_space, W_space));
226
227 if (pa) { mVarf->SetAssemblyLevel(AssemblyLevel::PARTIAL); }
229 mVarf->Assemble();
230 if (!pa) { mVarf->Finalize(); }
231
232 if (pa) { bVarf->SetAssemblyLevel(AssemblyLevel::PARTIAL); }
234 bVarf->Assemble();
235 if (!pa) { bVarf->Finalize(); }
236
237 BlockOperator darcyOp(block_offsets);
238
239 TransposeOperator *Bt = NULL;
240
241 if (pa)
242 {
243 Bt = new TransposeOperator(bVarf);
244
245 darcyOp.SetBlock(0,0, mVarf);
246 darcyOp.SetBlock(0,1, Bt, -1.0);
247 darcyOp.SetBlock(1,0, bVarf, -1.0);
248 }
249 else
250 {
251 SparseMatrix &M(mVarf->SpMat());
252 SparseMatrix &B(bVarf->SpMat());
253 B *= -1.;
254 Bt = new TransposeOperator(&B);
255
256 darcyOp.SetBlock(0,0, &M);
257 darcyOp.SetBlock(0,1, Bt);
258 darcyOp.SetBlock(1,0, &B);
259 }
260
261 // 10. Construct the operators for preconditioner
262 //
263 // P = [ diag(M) 0 ]
264 // [ 0 B diag(M)^-1 B^T ]
265 //
266 // Here we use Symmetric Gauss-Seidel to approximate the inverse of the
267 // pressure Schur Complement
268 SparseMatrix *MinvBt = NULL;
269 Vector Md(mVarf->Height());
270
271 BlockDiagonalPreconditioner darcyPrec(block_offsets);
272 Solver *invM, *invS;
273 SparseMatrix *S = NULL;
274
275 if (pa)
276 {
277 mVarf->AssembleDiagonal(Md);
278 auto Md_host = Md.HostRead();
279 Vector invMd(mVarf->Height());
280 for (int i=0; i<mVarf->Height(); ++i)
281 {
282 invMd(i) = 1.0 / Md_host[i];
283 }
284
285 Vector BMBt_diag(bVarf->Height());
286 bVarf->AssembleDiagonal_ADAt(invMd, BMBt_diag);
287
288 Array<int> ess_tdof_list; // empty
289
290 invM = new OperatorJacobiSmoother(Md, ess_tdof_list);
291 invS = new OperatorJacobiSmoother(BMBt_diag, ess_tdof_list);
292 }
293 else
294 {
295 SparseMatrix &M(mVarf->SpMat());
296 M.GetDiag(Md);
297 Md.HostReadWrite();
298
299 SparseMatrix &B(bVarf->SpMat());
300 MinvBt = Transpose(B);
301
302 for (int i = 0; i < Md.Size(); i++)
303 {
304 MinvBt->ScaleRow(i, 1./Md(i));
305 }
306
307 S = Mult(B, *MinvBt);
308
309 invM = new DSmoother(M);
310
311#ifndef MFEM_USE_SUITESPARSE
312 invS = new GSSmoother(*S);
313#else
314 invS = new UMFPackSolver(*S);
315#endif
316 }
317
318 invM->iterative_mode = false;
319 invS->iterative_mode = false;
320
321 darcyPrec.SetDiagonalBlock(0, invM);
322 darcyPrec.SetDiagonalBlock(1, invS);
323
324 // 11. Solve the linear system with MINRES.
325 // Check the norm of the unpreconditioned residual.
326 int maxIter(10000);
327 real_t rtol(1.e-10);
328 real_t atol(1.e-10);
329
330 chrono.Clear();
331 chrono.Start();
332 MINRESSolver solver;
333 solver.SetAbsTol(atol);
334 solver.SetRelTol(rtol);
335 solver.SetMaxIter(maxIter);
336 solver.SetOperator(darcyOp);
337 solver.SetPreconditioner(darcyPrec);
338 solver.SetPrintLevel(1);
339 x = 0.0;
340 solver.Mult(rhs, x);
341 if (device.IsEnabled()) { x.HostRead(); }
342 chrono.Stop();
343
344 if (solver.GetConverged())
345 {
346 std::cout << "MINRES converged in " << solver.GetNumIterations()
347 << " iterations with a residual norm of "
348 << solver.GetFinalNorm() << ".\n";
349 }
350 else
351 {
352 std::cout << "MINRES did not converge in " << solver.GetNumIterations()
353 << " iterations. Residual norm is " << solver.GetFinalNorm()
354 << ".\n";
355 }
356 std::cout << "MINRES solver took " << chrono.RealTime() << "s.\n";
357
358 // 12. Create the grid functions u and p. Compute the L2 error norms.
360 u.MakeRef(R_space, x.GetBlock(0), 0);
361 p.MakeRef(W_space, x.GetBlock(1), 0);
362
363 int order_quad = max(2, 2*order+1);
365 for (int i=0; i < Geometry::NumGeom; ++i)
366 {
367 irs[i] = &(IntRules.Get(i, order_quad));
368 }
369
370 real_t err_u = u.ComputeL2Error(ucoeff, irs);
371 real_t norm_u = ComputeLpNorm(2., ucoeff, *mesh, irs);
372 real_t err_p = p.ComputeL2Error(pcoeff, irs);
373 real_t norm_p = ComputeLpNorm(2., pcoeff, *mesh, irs);
374
375 std::cout << "|| u_h - u_ex || / || u_ex || = " << err_u / norm_u << "\n";
376 std::cout << "|| p_h - p_ex || / || p_ex || = " << err_p / norm_p << "\n";
377
378 // 13. Save the mesh and the solution. This output can be viewed later using
379 // GLVis: "glvis -m ex5.mesh -g sol_u.gf" or "glvis -m ex5.mesh -g
380 // sol_p.gf".
381 {
382 ofstream mesh_ofs("ex5.mesh");
383 mesh_ofs.precision(8);
384 mesh->Print(mesh_ofs);
385
386 ofstream u_ofs("sol_u.gf");
387 u_ofs.precision(8);
388 u.Save(u_ofs);
389
390 ofstream p_ofs("sol_p.gf");
391 p_ofs.precision(8);
392 p.Save(p_ofs);
393 }
394
395 // 14. Save data in the VisIt format
396 VisItDataCollection visit_dc("Example5", mesh);
397 visit_dc.RegisterField("velocity", &u);
398 visit_dc.RegisterField("pressure", &p);
399 visit_dc.Save();
400
401 // 15. Save data in the ParaView format
402 ParaViewDataCollection paraview_dc("Example5", mesh);
403 paraview_dc.SetPrefixPath("ParaView");
404 paraview_dc.SetLevelsOfDetail(order);
405 paraview_dc.SetCycle(0);
406 paraview_dc.SetDataFormat(VTKFormat::BINARY);
407 paraview_dc.SetHighOrderOutput(true);
408 paraview_dc.SetTime(0.0); // set the time
409 paraview_dc.RegisterField("velocity",&u);
410 paraview_dc.RegisterField("pressure",&p);
411 paraview_dc.Save();
412
413 // 16. Send the solution by socket to a GLVis server.
414 if (visualization)
415 {
416 char vishost[] = "localhost";
417 socketstream u_sock(vishost, visport);
418 u_sock.precision(8);
419 u_sock << "solution\n" << *mesh << u << "window_title 'Velocity'" << endl;
420 socketstream p_sock(vishost, visport);
421 p_sock.precision(8);
422 p_sock << "solution\n" << *mesh << p << "window_title 'Pressure'" << endl;
423 }
424
425 // 17. Free the used memory.
426 delete fform;
427 delete gform;
428 delete invM;
429 delete invS;
430 delete S;
431 delete Bt;
432 delete MinvBt;
433 delete mVarf;
434 delete bVarf;
435 delete W_space;
436 delete R_space;
437 delete l2_coll;
438 delete hdiv_coll;
439 delete mesh;
440
441 return 0;
442}
443
444
445void uFun_ex(const Vector & x, Vector & u)
446{
447 real_t xi(x(0));
448 real_t yi(x(1));
449 real_t zi(0.0);
450 if (x.Size() == 3)
451 {
452 zi = x(2);
453 }
454
455 u(0) = - exp(xi)*sin(yi)*cos(zi);
456 u(1) = - exp(xi)*cos(yi)*cos(zi);
457
458 if (x.Size() == 3)
459 {
460 u(2) = exp(xi)*sin(yi)*sin(zi);
461 }
462}
463
464// Change if needed
466{
467 real_t xi(x(0));
468 real_t yi(x(1));
469 real_t zi(0.0);
470
471 if (x.Size() == 3)
472 {
473 zi = x(2);
474 }
475
476 return exp(xi)*sin(yi)*cos(zi);
477}
478
479void fFun(const Vector & x, Vector & f)
480{
481 f = 0.0;
482}
483
485{
486 if (x.Size() == 3)
487 {
488 return -pFun_ex(x);
489 }
490 else
491 {
492 return 0;
493 }
494}
495
497{
498 return (-pFun_ex(x));
499}
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Definition array.cpp:68
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
T & Last()
Return the last element in the array.
Definition array.hpp:863
A "square matrix" operator for the associated FE space and BLFIntegrators The sum of all the BLFInteg...
void AssembleDiagonal(Vector &diag) const override
Assemble the diagonal of the bilinear form into diag. Note that diag is a tdof Vector.
void SetAssemblyLevel(AssemblyLevel assembly_level)
Set the desired assembly level.
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....
void Assemble(int skip_zeros=1)
Assembles the form i.e. sums over all domain/bdr integrators.
const SparseMatrix & SpMat() const
Returns a const reference to the sparse matrix: .
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 for scaled Jacobi-type smoother of sparse matrix.
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.
The MFEM Device class abstracts hardware devices such as GPUs, as well as programming models such as ...
Definition device.hpp:123
static MemoryType GetMemoryType()
(DEPRECATED) Equivalent to GetDeviceMemoryType().
Definition device.hpp:278
void Print(std::ostream &out=mfem::out)
Print the configuration of the MFEM virtual device object.
Definition device.cpp:297
static bool IsEnabled()
Return true if any backend other than Backend::CPU is enabled.
Definition device.hpp:247
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
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:244
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1) const
Get a list of essential true dofs, ess_tdof_list, corresponding to the boundary attributes marked in ...
Definition fespace.cpp:658
NURBSExtension * StealNURBSext()
Definition fespace.cpp:2611
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Definition fespace.hpp:848
A general function coefficient.
Data type for Gauss-Seidel smoother of sparse matrix.
static const int NumGeom
Definition geom.hpp:46
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:31
virtual void MakeRef(FiniteElementSpace *f, real_t *v)
Make the GridFunction reference external data on a new FiniteElementSpace.
Definition gridfunc.cpp:233
Class for an integration rule - an Array of IntegrationPoint.
Definition intrules.hpp:100
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
real_t GetFinalNorm() const
Returns the final residual norm after termination of the solver during the last call to Mult().
Definition solvers.hpp:295
void SetRelTol(real_t rtol)
Definition solvers.hpp:229
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
bool GetConverged() const
Returns true if the last call to Mult() converged successfully.
Definition solvers.hpp:282
void SetAbsTol(real_t atol)
Definition solvers.hpp:230
Arbitrary order "L2-conforming" discontinuous finite elements.
Definition fe_coll.hpp:346
Vector with associated FE space and LinearFormIntegrators.
void AddDomainIntegrator(LinearFormIntegrator *lfi)
Adds new Domain Integrator. Assumes ownership of lfi.
void AddBoundaryIntegrator(LinearFormIntegrator *lfi)
Adds new Boundary Integrator. Assumes ownership of lfi.
void Update()
Update the object according to the associated FE space fes.
void Assemble()
Assembles the linear form i.e. sums over all domain/bdr integrators.
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
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
NURBSExtension * NURBSext
Optional NURBS mesh extension.
Definition mesh.hpp:298
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
Definition mesh.hpp:2433
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 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 SetAssemblyLevel(AssemblyLevel assembly_level)
Set the desired assembly level. The default is AssemblyLevel::LEGACY.
void AssembleDiagonal_ADAt(const Vector &D, Vector &diag) const
Assemble the diagonal of ADA^T into diag, where A is this mixed bilinear form and D is a diagonal.
const SparseMatrix & SpMat() const
Returns a const reference to the sparse matrix: .
void AddDomainIntegrator(BilinearFormIntegrator *bfi)
Adds a domain integrator. Assumes ownership of bfi.
NURBSExtension generally contains multiple NURBSPatch objects spanning an entire Mesh....
Definition nurbs.hpp:449
Arbitrary order non-uniform rational B-splines (NURBS) finite elements.
Definition fe_coll.hpp:699
Arbitrary order H(div) NURBS finite elements.
Definition fe_coll.hpp:758
Jacobi smoothing for a given bilinear form (no matrix necessary).
Definition solvers.hpp:333
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
Definition operator.hpp:66
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.
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
Base class for solvers.
Definition operator.hpp:780
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
Definition operator.hpp:783
Data type sparse matrix.
Definition sparsemat.hpp:51
void GetDiag(Vector &d) const
Returns the Diagonal of A.
void ScaleRow(const int row, const real_t scale)
Timing object.
Definition tic_toc.hpp:36
double RealTime()
Return the number of real seconds elapsed since the stopwatch was started.
Definition tic_toc.cpp:432
void Start()
Start the stopwatch. The elapsed time is not cleared.
Definition tic_toc.cpp:411
void Stop()
Stop the stopwatch.
Definition tic_toc.cpp:422
void Clear()
Clear the elapsed time on the stopwatch and restart it if it's running.
Definition tic_toc.cpp:406
The transpose of a given operator. Switches the roles of the methods Mult() and MultTranspose().
Definition operator.hpp:847
Direct sparse solver using UMFPACK.
Definition solvers.hpp:1121
for VectorFiniteElements (Nedelec, Raviart-Thomas)
Definition lininteg.hpp:344
A general vector function coefficient.
Vector data type.
Definition vector.hpp:82
virtual const real_t * HostRead() const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), false).
Definition vector.hpp:498
void SyncAliasMemory(const Vector &v) const
Update the alias memory location of the vector to match v.
Definition vector.hpp:267
int Size() const
Returns the size of the vector.
Definition vector.hpp:226
virtual real_t * HostReadWrite()
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), false).
Definition vector.hpp:514
Data collection with VisIt I/O routines.
void Save() override
Save the collection and a VisIt root file.
void RegisterField(const std::string &field_name, GridFunction *gf) override
Add a grid function to the collection and update the root file.
int dim
Definition ex24.cpp:53
int main()
real_t u(const Vector &xvec)
Definition lor_mms.hpp:22
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
Definition table.cpp:548
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
void Transpose(const Table &A, Table &At, int ncols_A_)
Transpose a Table.
Definition table.cpp:486
real_t ComputeLpNorm(real_t p, Coefficient &coeff, Mesh &mesh, const IntegrationRule *irs[])
Compute the Lp norm of a function f. .
float real_t
Definition config.hpp:43
MemoryType
Memory types supported by MFEM.
std::function< real_t(const Vector &)> f(real_t mass_coeff)
Definition lor_mms.hpp:30
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
Definition intrules.hpp:492
const char vishost[]
real_t p(const Vector &x, real_t t)
real_t pFun_ex(const Vector &x)
void uFun_ex(const Vector &x, Vector &u)
real_t gFun(const Vector &x)
real_t f_natural(const Vector &x)
void fFun(const Vector &x, Vector &f)