MFEM v4.9.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#include "mfem.hpp"
40#include <fstream>
41#include <iostream>
42#include <algorithm>
43
44using namespace std;
45using namespace mfem;
46
47// Define the analytical solution and forcing terms / boundary conditions
48void uFun_ex(const Vector & x, Vector & u);
49real_t pFun_ex(const Vector & x);
50void fFun(const Vector & x, Vector & f);
51real_t gFun(const Vector & x);
52real_t f_natural(const Vector & x);
53
54int main(int argc, char *argv[])
55{
56 StopWatch chrono;
57
58 // 1. Parse command-line options.
59 const char *mesh_file = "../../data/square-nurbs.mesh";
60 int ref_levels = -1;
61 int order = 1;
62 bool pa = false;
63 const char *device_config = "cpu";
64 int visport = 19916;
65 bool visualization = 1;
66
67 OptionsParser args(argc, argv);
68 args.AddOption(&mesh_file, "-m", "--mesh",
69 "Mesh file to use.");
70 args.AddOption(&ref_levels, "-r", "--refine",
71 "Number of times to refine the mesh uniformly, -1 for auto.");
72 args.AddOption(&order, "-o", "--order",
73 "Finite element order (polynomial degree).");
74 args.AddOption(&pa, "-pa", "--partial-assembly", "-no-pa",
75 "--no-partial-assembly", "Enable Partial Assembly.");
76 args.AddOption(&device_config, "-d", "--device",
77 "Device configuration string, see Device::Configure().");
78 args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
79 "--no-visualization",
80 "Enable or disable GLVis visualization.");
81 args.AddOption(&visport, "-p", "--send-port", "Socket for GLVis.");
82 args.Parse();
83 if (!args.Good())
84 {
85 args.PrintUsage(cout);
86 return 1;
87 }
88 args.PrintOptions(cout);
89
90 // 2. Enable hardware devices such as GPUs, and programming models such as
91 // CUDA, OCCA, RAJA and OpenMP based on command line options.
92 Device device(device_config);
93 device.Print();
94
95 // 3. Read the mesh from the given mesh file. We can handle triangular,
96 // quadrilateral, tetrahedral, hexahedral, surface and volume meshes with
97 // the same code.
98 Mesh *mesh = new Mesh(mesh_file, 1, 1);
99 int dim = mesh->Dimension();
100
101 // 4. Refine the mesh to increase the resolution. In this example we do
102 // 'ref_levels' of uniform refinement. We choose 'ref_levels' to be the
103 // largest number that gives a final mesh with no more than 10,000
104 // elements.
105 {
106 if (ref_levels < 0)
107 {
108 ref_levels =
109 (int)floor(log(10000./mesh->GetNE())/log(2.)/dim);
110 }
111 for (int l = 0; l < ref_levels; l++)
112 {
113 mesh->UniformRefinement();
114 }
115 }
116
117 // 5. Define a finite element space on the mesh. Here we use the
118 // Raviart-Thomas finite elements of the specified order.
119 FiniteElementCollection *hdiv_coll = nullptr;
120 FiniteElementCollection *l2_coll = nullptr;
121 NURBSExtension *NURBSext = nullptr;
122
123 if (mesh->NURBSext && !pa)
124 {
125 hdiv_coll = new NURBS_HDivFECollection(order,dim);
126 l2_coll = new NURBSFECollection(order);
127 NURBSext = new NURBSExtension(mesh->NURBSext, order);
128 mfem::out<<"Create NURBS fec and ext"<<std::endl;
129 }
130 else
131 {
132 hdiv_coll = new RT_FECollection(order, dim);
133 l2_coll = new L2_FECollection(order, dim);
134 mfem::out<<"Create Normal fec"<<std::endl;
135 }
136 pa = false;
137 FiniteElementSpace *W_space = new FiniteElementSpace(mesh, NURBSext, l2_coll);
138 FiniteElementSpace *R_space = new FiniteElementSpace(mesh,
139 W_space->StealNURBSext(),
140 hdiv_coll);
141
142 // 6. Define the BlockStructure of the problem, i.e. define the array of
143 // offsets for each variable. The last component of the Array is the sum
144 // of the dimensions of each block.
145 Array<int> block_offsets(3); // number of variables + 1
146 block_offsets[0] = 0;
147 block_offsets[1] = R_space->GetVSize();
148 block_offsets[2] = W_space->GetVSize();
149 block_offsets.PartialSum();
150
151 std::cout << "***********************************************************\n";
152 std::cout << "dim(R) = " << block_offsets[1] - block_offsets[0] << "\n";
153 std::cout << "dim(W) = " << block_offsets[2] - block_offsets[1] << "\n";
154 std::cout << "dim(R+W) = " << block_offsets.Last() << "\n";
155 std::cout << "***********************************************************\n";
156 {
157 Array<int> ess_tdof_list;
158 if (mesh->bdr_attributes.Size())
159 {
160 Array<int> ess_bdr(mesh->bdr_attributes.Max());
161 ess_bdr = 1;
162 R_space->GetEssentialTrueDofs(ess_bdr, ess_tdof_list);
163 }
164 cout << "Number boundary dofs in H(div): "
165 << ess_tdof_list.Size() << endl;
166 }
167
168 {
169 Array<int> ess_tdof_list;
170 if (mesh->bdr_attributes.Size())
171 {
172 Array<int> ess_bdr(mesh->bdr_attributes.Max());
173 ess_bdr = 1;
174 W_space->GetEssentialTrueDofs(ess_bdr, ess_tdof_list);
175 }
176 cout << "Number boundary dofs in H1: "
177 << ess_tdof_list.Size() << endl;
178 }
179
180 // 7. Define the coefficients, analytical solution, and rhs of the PDE.
181 ConstantCoefficient k(1.0);
182
186
189
190 // 8. Allocate memory (x, rhs) for the analytical solution and the right hand
191 // side. Define the GridFunction u,p for the finite element solution and
192 // linear forms fform and gform for the right hand side. The data
193 // allocated by x and rhs are passed as a reference to the grid functions
194 // (u,p) and the linear forms (fform, gform).
195 MemoryType mt = device.GetMemoryType();
196 BlockVector x(block_offsets, mt), rhs(block_offsets, mt);
197
198 LinearForm *fform(new LinearForm);
199 fform->Update(R_space, rhs.GetBlock(0), 0);
202 fform->Assemble();
203 fform->SyncAliasMemory(rhs);
204
205 LinearForm *gform(new LinearForm);
206 gform->Update(W_space, rhs.GetBlock(1), 0);
207 gform->AddDomainIntegrator(new DomainLFIntegrator(gcoeff));
208 gform->Assemble();
209 gform->SyncAliasMemory(rhs);
210
211 // 9. Assemble the finite element matrices for the Darcy operator
212 //
213 // D = [ M B^T ]
214 // [ B 0 ]
215 // where:
216 //
217 // M = \int_\Omega k u_h \cdot v_h d\Omega u_h, v_h \in R_h
218 // B = -\int_\Omega \div u_h q_h d\Omega u_h \in R_h, q_h \in W_h
219 BilinearForm *mVarf(new BilinearForm(R_space));
220 MixedBilinearForm *bVarf(new MixedBilinearForm(R_space, W_space));
221
222 if (pa) { mVarf->SetAssemblyLevel(AssemblyLevel::PARTIAL); }
224 mVarf->Assemble();
225 if (!pa) { mVarf->Finalize(); }
226
227 if (pa) { bVarf->SetAssemblyLevel(AssemblyLevel::PARTIAL); }
229 bVarf->Assemble();
230 if (!pa) { bVarf->Finalize(); }
231
232 BlockOperator darcyOp(block_offsets);
233
234 TransposeOperator *Bt = NULL;
235
236 if (pa)
237 {
238 Bt = new TransposeOperator(bVarf);
239
240 darcyOp.SetBlock(0,0, mVarf);
241 darcyOp.SetBlock(0,1, Bt, -1.0);
242 darcyOp.SetBlock(1,0, bVarf, -1.0);
243 }
244 else
245 {
246 SparseMatrix &M(mVarf->SpMat());
247 SparseMatrix &B(bVarf->SpMat());
248 B *= -1.;
249 Bt = new TransposeOperator(&B);
250
251 darcyOp.SetBlock(0,0, &M);
252 darcyOp.SetBlock(0,1, Bt);
253 darcyOp.SetBlock(1,0, &B);
254 }
255
256 // 10. Construct the operators for preconditioner
257 //
258 // P = [ diag(M) 0 ]
259 // [ 0 B diag(M)^-1 B^T ]
260 //
261 // Here we use Symmetric Gauss-Seidel to approximate the inverse of the
262 // pressure Schur Complement
263 SparseMatrix *MinvBt = NULL;
264 Vector Md(mVarf->Height());
265
266 BlockDiagonalPreconditioner darcyPrec(block_offsets);
267 Solver *invM, *invS;
268 SparseMatrix *S = NULL;
269
270 if (pa)
271 {
272 mVarf->AssembleDiagonal(Md);
273 auto Md_host = Md.HostRead();
274 Vector invMd(mVarf->Height());
275 for (int i=0; i<mVarf->Height(); ++i)
276 {
277 invMd(i) = 1.0 / Md_host[i];
278 }
279
280 Vector BMBt_diag(bVarf->Height());
281 bVarf->AssembleDiagonal_ADAt(invMd, BMBt_diag);
282
283 Array<int> ess_tdof_list; // empty
284
285 invM = new OperatorJacobiSmoother(Md, ess_tdof_list);
286 invS = new OperatorJacobiSmoother(BMBt_diag, ess_tdof_list);
287 }
288 else
289 {
290 SparseMatrix &M(mVarf->SpMat());
291 M.GetDiag(Md);
292 Md.HostReadWrite();
293
294 SparseMatrix &B(bVarf->SpMat());
295 MinvBt = Transpose(B);
296
297 for (int i = 0; i < Md.Size(); i++)
298 {
299 MinvBt->ScaleRow(i, 1./Md(i));
300 }
301
302 S = Mult(B, *MinvBt);
303
304 invM = new DSmoother(M);
305
306#ifndef MFEM_USE_SUITESPARSE
307 invS = new GSSmoother(*S);
308#else
309 invS = new UMFPackSolver(*S);
310#endif
311 }
312
313 invM->iterative_mode = false;
314 invS->iterative_mode = false;
315
316 darcyPrec.SetDiagonalBlock(0, invM);
317 darcyPrec.SetDiagonalBlock(1, invS);
318
319 // 11. Solve the linear system with MINRES.
320 // Check the norm of the unpreconditioned residual.
321 int maxIter(10000);
322 real_t rtol(1.e-10);
323 real_t atol(1.e-10);
324
325 chrono.Clear();
326 chrono.Start();
327 MINRESSolver solver;
328 solver.SetAbsTol(atol);
329 solver.SetRelTol(rtol);
330 solver.SetMaxIter(maxIter);
331 solver.SetOperator(darcyOp);
332 solver.SetPreconditioner(darcyPrec);
333 solver.SetPrintLevel(1);
334 x = 0.0;
335 solver.Mult(rhs, x);
336 if (device.IsEnabled()) { x.HostRead(); }
337 chrono.Stop();
338
339 if (solver.GetConverged())
340 {
341 std::cout << "MINRES converged in " << solver.GetNumIterations()
342 << " iterations with a residual norm of "
343 << solver.GetFinalNorm() << ".\n";
344 }
345 else
346 {
347 std::cout << "MINRES did not converge in " << solver.GetNumIterations()
348 << " iterations. Residual norm is " << solver.GetFinalNorm()
349 << ".\n";
350 }
351 std::cout << "MINRES solver took " << chrono.RealTime() << "s.\n";
352
353 // 12. Create the grid functions u and p. Compute the L2 error norms.
355 u.MakeRef(R_space, x.GetBlock(0), 0);
356 p.MakeRef(W_space, x.GetBlock(1), 0);
357
358 int order_quad = max(2, 2*order+1);
360 for (int i=0; i < Geometry::NumGeom; ++i)
361 {
362 irs[i] = &(IntRules.Get(i, order_quad));
363 }
364
365 real_t err_u = u.ComputeL2Error(ucoeff, irs);
366 real_t norm_u = ComputeLpNorm(2., ucoeff, *mesh, irs);
367 real_t err_p = p.ComputeL2Error(pcoeff, irs);
368 real_t norm_p = ComputeLpNorm(2., pcoeff, *mesh, irs);
369
370 std::cout << "|| u_h - u_ex || / || u_ex || = " << err_u / norm_u << "\n";
371 std::cout << "|| p_h - p_ex || / || p_ex || = " << err_p / norm_p << "\n";
372
373 // 13. Save the mesh and the solution. This output can be viewed later using
374 // GLVis: "glvis -m ex5.mesh -g sol_u.gf" or "glvis -m ex5.mesh -g
375 // sol_p.gf".
376 {
377 ofstream mesh_ofs("ex5.mesh");
378 mesh_ofs.precision(8);
379 mesh->Print(mesh_ofs);
380
381 ofstream u_ofs("sol_u.gf");
382 u_ofs.precision(8);
383 u.Save(u_ofs);
384
385 ofstream p_ofs("sol_p.gf");
386 p_ofs.precision(8);
387 p.Save(p_ofs);
388 }
389
390 // 14. Save data in the VisIt format
391 VisItDataCollection visit_dc("Example5", mesh);
392 visit_dc.RegisterField("velocity", &u);
393 visit_dc.RegisterField("pressure", &p);
394 visit_dc.Save();
395
396 // 15. Save data in the ParaView format
397 ParaViewDataCollection paraview_dc("Example5", mesh);
398 paraview_dc.SetPrefixPath("ParaView");
399 paraview_dc.SetLevelsOfDetail(order);
400 paraview_dc.SetCycle(0);
401 paraview_dc.SetDataFormat(VTKFormat::BINARY);
402 paraview_dc.SetHighOrderOutput(true);
403 paraview_dc.SetTime(0.0); // set the time
404 paraview_dc.RegisterField("velocity",&u);
405 paraview_dc.RegisterField("pressure",&p);
406 paraview_dc.Save();
407
408 // 16. Send the solution by socket to a GLVis server.
409 if (visualization)
410 {
411 char vishost[] = "localhost";
412 socketstream u_sock(vishost, visport);
413 u_sock.precision(8);
414 u_sock << "solution\n" << *mesh << u << "window_title 'Velocity'" << endl;
415 socketstream p_sock(vishost, visport);
416 p_sock.precision(8);
417 p_sock << "solution\n" << *mesh << p << "window_title 'Pressure'" << endl;
418 }
419
420 // 17. Free the used memory.
421 delete fform;
422 delete gform;
423 delete invM;
424 delete invS;
425 delete S;
426 delete Bt;
427 delete MinvBt;
428 delete mVarf;
429 delete bVarf;
430 delete W_space;
431 delete R_space;
432 delete l2_coll;
433 delete hdiv_coll;
434 delete mesh;
435
436 return 0;
437}
438
439
440void uFun_ex(const Vector & x, Vector & u)
441{
442 real_t xi(x(0));
443 real_t yi(x(1));
444 real_t zi(0.0);
445 if (x.Size() == 3)
446 {
447 zi = x(2);
448 }
449
450 u(0) = - exp(xi)*sin(yi)*cos(zi);
451 u(1) = - exp(xi)*cos(yi)*cos(zi);
452
453 if (x.Size() == 3)
454 {
455 u(2) = exp(xi)*sin(yi)*sin(zi);
456 }
457}
458
459// Change if needed
461{
462 real_t xi(x(0));
463 real_t yi(x(1));
464 real_t zi(0.0);
465
466 if (x.Size() == 3)
467 {
468 zi = x(2);
469 }
470
471 return exp(xi)*sin(yi)*cos(zi);
472}
473
474void fFun(const Vector & x, Vector & f)
475{
476 f = 0.0;
477}
478
480{
481 if (x.Size() == 3)
482 {
483 return -pFun_ex(x);
484 }
485 else
486 {
487 return 0;
488 }
489}
490
492{
493 return (-pFun_ex(x));
494}
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Definition array.cpp:69
int Size() const
Return the logical size of the array.
Definition array.hpp:166
void PartialSum()
Fill the entries of the array with the cumulative sum of the entries.
Definition array.cpp:104
T & Last()
Return the last element in the array.
Definition array.hpp:945
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:124
static MemoryType GetMemoryType()
(DEPRECATED) Equivalent to GetDeviceMemoryType().
Definition device.hpp:281
void Print(std::ostream &os=mfem::out)
Print the configuration of the MFEM virtual device object.
Definition device.cpp:317
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:108
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:208
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:628
NURBSExtension * StealNURBSext()
Definition fespace.cpp:2598
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Definition fespace.hpp:826
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:32
virtual void MakeRef(FiniteElementSpace *f, real_t *v)
Make the GridFunction reference external data on a new FiniteElementSpace.
Definition gridfunc.cpp:234
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:304
void SetRelTol(real_t rtol)
Definition solvers.hpp:238
int GetNumIterations() const
Returns the number of iterations taken during the last call to Mult()
Definition solvers.hpp:289
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
Definition solvers.cpp:76
void SetMaxIter(int max_it)
Definition solvers.hpp:240
bool GetConverged() const
Returns true if the last call to Mult() converged successfully.
Definition solvers.hpp:291
void SetAbsTol(real_t atol)
Definition solvers.hpp:239
Arbitrary order "L2-conforming" discontinuous finite elements.
Definition fe_coll.hpp:350
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:742
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the MINRES method.
Definition solvers.cpp:1855
void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
Definition solvers.cpp:1830
void SetPreconditioner(Solver &pr) override
This should be called before SetOperator.
Definition solvers.hpp:754
Mesh data type.
Definition mesh.hpp:65
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
Definition mesh.hpp:304
NURBSExtension * NURBSext
Optional NURBS mesh extension.
Definition mesh.hpp:312
virtual void Print(std::ostream &os=mfem::out, const std::string &comments="") const
Print the mesh to the given stream using the default MFEM mesh format.
Definition mesh.hpp:2567
int GetNE() const
Returns number of elements.
Definition mesh.hpp:1377
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1306
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Definition mesh.cpp:11637
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:474
Arbitrary order non-uniform rational B-splines (NURBS) finite elements.
Definition fe_coll.hpp:717
Arbitrary order H(div) NURBS finite elements.
Definition fe_coll.hpp:776
Jacobi smoothing for a given bilinear form (no matrix necessary).
Definition solvers.hpp:422
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.
void SetLevelsOfDetail(int levels_of_detail_)
Set the refinement level.
void SetHighOrderOutput(bool high_order_output_)
Sets whether or not to output the data as high-order elements (false by default).
void SetDataFormat(VTKFormat fmt)
Set the data format for the ParaView output files.
Writer for ParaView visualization (PVD and VTU format)
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
Definition fe_coll.hpp:407
Base class for solvers.
Definition operator.hpp:792
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
Definition operator.hpp:795
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:859
Direct sparse solver using UMFPACK.
Definition solvers.hpp:1210
for VectorFiniteElements (Nedelec, Raviart-Thomas)
Definition lininteg.hpp:365
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:524
void SyncAliasMemory(const Vector &v) const
Update the alias memory location of the vector to match v.
Definition vector.hpp:275
int Size() const
Returns the size of the vector.
Definition vector.hpp:234
virtual real_t * HostReadWrite()
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), false).
Definition vector.hpp:540
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:505
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:443
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:46
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)
MFEM_HOST_DEVICE Complex exp(const Complex &q)