MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
nurbs_ex1.cpp
Go to the documentation of this file.
1// MFEM Example 1 - NURBS Version
2//
3// Compile with: make nurbs_ex1
4//
5// Sample runs: nurbs_ex1 -m ../../data/square-nurbs.mesh -o 2 -no-ibp
6// nurbs_ex1 -m ../../data/square-nurbs.mesh -o 2 --weak-bc
7// nurbs_ex1 -m ../../data/cube-nurbs.mesh -o 2 -no-ibp
8// nurbs_ex1 -m ../../data/pipe-nurbs-2d.mesh -o 2 -no-ibp
9// nurbs_ex1 -m ../../data/pipe-nurbs-2d.mesh -o 2 -r 2 --neu "3"
10// nurbs_ex1 -m ../../data/square-disc-nurbs.mesh -o -1
11// nurbs_ex1 -m ../../data/disc-nurbs.mesh -o -1
12// nurbs_ex1 -m ../../data/pipe-nurbs.mesh -o -1
13// nurbs_ex1 -m ../../data/beam-hex-nurbs.mesh -pm 1 -ps 2
14// nurbs_ex1 -m meshes/two-squares-nurbs.mesh -o 1 -rf meshes/two-squares.ref
15// nurbs_ex1 -m meshes/two-squares-nurbs-rot.mesh -o 1 -rf meshes/two-squares.ref
16// nurbs_ex1 -m meshes/two-squares-nurbs-autoedge.mesh -o 1 -rf meshes/two-squares.ref
17// nurbs_ex1 -m meshes/two-cubes-nurbs.mesh -o 1 -r 3 -rf meshes/two-cubes.ref
18// nurbs_ex1 -m meshes/two-cubes-nurbs-rot.mesh -o 1 -r 3 -rf meshes/two-cubes.ref
19// nurbs_ex1 -m meshes/two-cubes-nurbs-autoedge.mesh -o 1 -r 3 -rf meshes/two-cubes.ref
20// nurbs_ex1 -m ../../data/segment-nurbs.mesh -r 2 -o 2 -lod 3
21// nurbs_ex1 -m meshes/square-nurbs-deformed.mesh -o 2
22// nurbs_ex1 -m meshes/square-nurbs-deformed.mesh -o 2 -no-ibp
23// nurbs_ex1 -m meshes/cube-nurbs-deformed.mesh -o 2
24// nurbs_ex1 -m meshes/cube-nurbs-deformed.mesh -o 2 -no-ibp
25//
26// Description: This example code demonstrates the use of MFEM to define a
27// simple finite element discretization of the Poisson problem
28// -Delta u = 1 with homogeneous Dirichlet boundary conditions.
29// The boundary conditions can be enforced either strongly or weakly.
30// Specifically, we discretize using a FE space of the specified
31// order, or if order < 1 using an isoparametric/isogeometric
32// space (i.e. quadratic for quadratic curvilinear mesh, NURBS for
33// NURBS mesh, etc.)
34//
35// The example highlights the use of mesh refinement, finite
36// element grid functions, as well as linear and bilinear forms
37// corresponding to the left-hand side and right-hand side of the
38// discrete linear system. We also cover the explicit elimination
39// of essential boundary conditions, static condensation, and the
40// optional connection to the GLVis tool for visualization.
41
42#include "mfem.hpp"
43#include <fstream>
44#include <iostream>
45#include <list>
46
47using namespace std;
48using namespace mfem;
49
50class Data
51{
52public:
53 real_t x,val;
54 Data(real_t x_, real_t val_) {x=x_; val=val_;};
55};
56
57inline bool operator==(const Data& d1,const Data& d2) { return (d1.x == d2.x); }
58inline bool operator <(const Data& d1,const Data& d2) { return (d1.x < d2.x); }
59
60/** Class for integrating the bilinear form a(u,v) := (Q Laplace u, v) where Q
61 can be a scalar coefficient. */
62class Diffusion2Integrator: public BilinearFormIntegrator
63{
64private:
65#ifndef MFEM_THREAD_SAFE
66 Vector shape, laplace;
67#endif
68 Coefficient *Q;
69
70public:
71 /// Construct a diffusion integrator with coefficient Q = 1
72 Diffusion2Integrator() { Q = NULL; }
73
74 /// Construct a diffusion integrator with a scalar coefficient q
75 Diffusion2Integrator (Coefficient &q) : Q(&q) { }
76
77 /** Given a particular Finite Element
78 computes the element stiffness matrix elmat. */
79 void AssembleElementMatrix(const FiniteElement &el,
81 DenseMatrix &elmat) override
82 {
83 int nd = el.GetDof();
84 int dim = el.GetDim();
85 real_t w;
86
87#ifdef MFEM_THREAD_SAFE
88 Vector shape(nd);
89 Vector laplace(nd);
90#else
91 shape.SetSize(nd);
92 laplace.SetSize(nd);
93#endif
94 elmat.SetSize(nd);
95
96 const IntegrationRule *ir = IntRule;
97 if (ir == NULL)
98 {
99 int order;
100 if (el.Space() == FunctionSpace::Pk)
101 {
102 order = 2*el.GetOrder() - 2;
103 }
104 else
105 {
106 order = 2*el.GetOrder() + dim - 1;
107 }
108
109 if (el.Space() == FunctionSpace::rQk)
110 {
111 ir = &RefinedIntRules.Get(el.GetGeomType(),order);
112 }
113 else
114 {
115 ir = &IntRules.Get(el.GetGeomType(),order);
116 }
117 }
118
119 elmat = 0.0;
120 for (int i = 0; i < ir->GetNPoints(); i++)
121 {
122 const IntegrationPoint &ip = ir->IntPoint(i);
123 Trans.SetIntPoint(&ip);
124 w = -ip.weight * Trans.Weight();
125
126 el.CalcShape(ip, shape);
127 el.CalcPhysLaplacian(Trans, laplace);
128
129 if (Q)
130 {
131 w *= Q->Eval(Trans, ip);
132 }
133
134 for (int jj = 0; jj < nd; jj++)
135 {
136 for (int ii = 0; ii < nd; ii++)
137 {
138 elmat(ii, jj) += w*shape(ii)*laplace(jj);
139 }
140 }
141 }
142 }
143
144};
145
146real_t sol(const Vector & x)
147{
148 if (x.Size() >= 2)
149 {
150 if ((x[1] - x[0] - 0.5 < 0.0) &&
151 (x[0] + x[1] -0.99 < 0.0))
152 {
153 return 1.0;
154 }
155 }
156
157 return 0.0;
158}
159
160int main(int argc, char *argv[])
161{
162 // 1. Parse command-line options.
163 const char *mesh_file = "../../data/square-nurbs.mesh";
164 const char *per_file = "none";
165 const char *ref_file = "";
166 int ref_levels = -1;
167 Array<int> master(0);
168 Array<int> slave(0);
169 Array<int> neu(0);
170 bool static_cond = false;
171 bool visualization = 1;
172 int lod = 0;
173 bool ibp = 1;
174 bool strongBC = 1;
175 real_t kappa = -1;
176 Array<int> order(1);
177 int visport = 19916;
178 order[0] = 1;
179 bool homogenousBC = true;
180
181 OptionsParser args(argc, argv);
182 args.AddOption(&mesh_file, "-m", "--mesh",
183 "Mesh file to use.");
184 args.AddOption(&ref_levels, "-r", "--refine",
185 "Number of times to refine the mesh uniformly, -1 for auto.");
186 args.AddOption(&per_file, "-p", "--per",
187 "Periodic BCS file.");
188 args.AddOption(&ref_file, "-rf", "--ref-file",
189 "File with refinement data");
190 args.AddOption(&master, "-pm", "--master",
191 "Master boundaries for periodic BCs");
192 args.AddOption(&slave, "-ps", "--slave",
193 "Slave boundaries for periodic BCs");
194 args.AddOption(&neu, "-n", "--neu",
195 "Boundaries with Neumann BCs");
196 args.AddOption(&homogenousBC, "-h", "--hom",
197 "-nh", "--no-hom",
198 "Selection for using homogeneous Dirichelet boundary conditions.");
199 args.AddOption(&order, "-o", "--order",
200 "Finite element order (polynomial degree) or -1 for"
201 " isoparametric space.");
202 args.AddOption(&ibp, "-ibp", "--ibp",
203 "-no-ibp", "--no-ibp",
204 "Selects the standard weak form (IBP) or the nonstandard (NO-IBP).");
205 args.AddOption(&strongBC, "-sbc", "--strong-bc", "-wbc",
206 "--weak-bc",
207 "Selects strong or weak enforcement of Dirichlet BCs.");
208 args.AddOption(&kappa, "-k", "--kappa",
209 "Sets the SIPG penalty parameters, should be positive."
210 " Negative values are replaced with (order+1)^2.");
211 args.AddOption(&static_cond, "-sc", "--static-condensation", "-no-sc",
212 "--no-static-condensation", "Enable static condensation.");
213 args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
214 "--no-visualization",
215 "Enable or disable GLVis visualization.");
216 args.AddOption(&lod, "-lod", "--level-of-detail",
217 "Refinement level for 1D solution output (0 means no output).");
218 args.AddOption(&visport, "-p", "--send-port", "Socket for GLVis.");
219 args.Parse();
220 if (!args.Good())
221 {
222 args.PrintUsage(cout);
223 return 1;
224 }
225 if (!strongBC & (kappa < 0))
226 {
227 kappa = 4*(order.Max()+1)*(order.Max()+1);
228 }
229 args.PrintOptions(cout);
230
231 // 2. Read the mesh from the given mesh file. We can handle triangular,
232 // quadrilateral, tetrahedral, hexahedral, surface and volume meshes with
233 // the same code.
234 Mesh *mesh = new Mesh(mesh_file, 1, 1);
235 int dim = mesh->Dimension();
236
237 // 3. Refine the mesh to increase the resolution. In this example we do
238 // 'ref_levels' of uniform refinement and knot insertion of knots defined
239 // in a refinement file. We choose 'ref_levels' to be the largest number
240 // that gives a final mesh with no more than 50,000 elements.
241 {
242 // Mesh refinement as defined in refinement file
243 if (mesh->NURBSext && (strlen(ref_file) != 0))
244 {
245 mesh->RefineNURBSFromFile(ref_file);
246 }
247
248 if (ref_levels < 0)
249 {
250 ref_levels =
251 (int)floor(log(5000./mesh->GetNE())/log(2.)/dim);
252 }
253
254 for (int l = 0; l < ref_levels; l++)
255 {
256 mesh->UniformRefinement();
257 }
258 mesh->PrintInfo();
259 }
260
261 // 4. Define a finite element space on the mesh. Here we use continuous
262 // Lagrange finite elements of the specified order. If order < 1, we
263 // instead use an isoparametric/isogeometric space.
265 NURBSExtension *NURBSext = NULL;
266 int own_fec = 0;
267
268 if (mesh->NURBSext)
269 {
270 fec = new NURBSFECollection(order[0]);
271 own_fec = 1;
272
273 int nkv = mesh->NURBSext->GetNKV();
274 if (order.Size() == 1)
275 {
276 int tmp = order[0];
277 order.SetSize(nkv);
278 order = tmp;
279 }
280
281 if (order.Size() != nkv ) { mfem_error("Wrong number of orders set."); }
282 NURBSext = new NURBSExtension(mesh->NURBSext, order);
283
284 // Read periodic BCs from file
285 std::ifstream in;
286 in.open(per_file, std::ifstream::in);
287 if (in.is_open())
288 {
289 int psize;
290 in >> psize;
291 master.SetSize(psize);
292 slave.SetSize(psize);
293 master.Load(in, psize);
294 slave.Load(in, psize);
295 in.close();
296 }
297 NURBSext->ConnectBoundaries(master,slave);
298 }
299 else if (order[0] == -1) // Isoparametric
300 {
301 if (mesh->GetNodes())
302 {
303 fec = mesh->GetNodes()->OwnFEC();
304 own_fec = 0;
305 cout << "Using isoparametric FEs: " << fec->Name() << endl;
306 }
307 else
308 {
309 cout <<"Mesh does not have FEs --> Assume order 1.\n";
310 fec = new H1_FECollection(1, dim);
311 own_fec = 1;
312 }
313 }
314 else
315 {
316 if (order.Size() > 1) { cout <<"Wrong number of orders set, needs one.\n"; }
317 fec = new H1_FECollection(abs(order[0]), dim);
318 own_fec = 1;
319 }
320
321 FiniteElementSpace *fespace = new FiniteElementSpace(mesh, NURBSext, fec);
322 cout << "Number of finite element unknowns: "
323 << fespace->GetTrueVSize() << endl;
324
325 if (!ibp)
326 {
327 if (!mesh->NURBSext)
328 {
329 cout << "No integration by parts requires a NURBS mesh."<< endl;
330 return 2;
331 }
332 if (mesh->NURBSext->GetNP()>1)
333 {
334 cout << "No integration by parts requires a NURBS mesh, with only 1 patch."<<
335 endl;
336 cout << "A C_1 discretisation is required."<< endl;
337 cout << "Currently only C_0 multipatch coupling implemented."<< endl;
338 return 3;
339 }
340 if (order[0]<2)
341 {
342 cout << "No integration by parts requires at least quadratic NURBS."<< endl;
343 cout << "A C_1 discretisation is required."<< endl;
344 return 4;
345 }
346 }
347
348 // 5. Determine the list of true (i.e. conforming) essential boundary dofs.
349 // In this example, the boundary conditions are defined by marking all
350 // the boundary attributes from the mesh as essential (Dirichlet) and
351 // converting them to a list of true dofs.
352 Array<int> ess_bdr(0);
353 Array<int> neu_bdr(0);
354 Array<int> per_bdr(0);
355 if (mesh->bdr_attributes.Size())
356 {
357 ess_bdr.SetSize(mesh->bdr_attributes.Max());
358 neu_bdr.SetSize(mesh->bdr_attributes.Max());
359 per_bdr.SetSize(mesh->bdr_attributes.Max());
360
361 ess_bdr = 1;
362 neu_bdr = 0;
363 per_bdr = 0;
364
365 // Apply Neumann BCs
366 for (int i = 0; i < neu.Size(); i++)
367 {
368 if ( neu[i]-1 >= 0 &&
369 neu[i]-1 < mesh->bdr_attributes.Max())
370 {
371 ess_bdr[neu[i]-1] = 0;
372 neu_bdr[neu[i]-1] = 1;
373 }
374 else
375 {
376 cout <<"Neumann boundary "<<neu[i]<<" out of range -- discarded"<< endl;
377 }
378 }
379
380 // Correct for periodic BCs
381 for (int i = 0; i < master.Size(); i++)
382 {
383 if ( master[i]-1 >= 0 &&
384 master[i]-1 < mesh->bdr_attributes.Max())
385 {
386 ess_bdr[master[i]-1] = 0;
387 neu_bdr[master[i]-1] = 0;
388 per_bdr[master[i]-1] = 1;
389 }
390 else
391 {
392 cout <<"Master boundary "<<master[i]<<" out of range -- discarded"<< endl;
393 }
394 }
395 for (int i = 0; i < slave.Size(); i++)
396 {
397 if ( slave[i]-1 >= 0 &&
398 slave[i]-1 < mesh->bdr_attributes.Max())
399 {
400 ess_bdr[slave[i]-1] = 0;
401 neu_bdr[slave[i]-1] = 0;
402 per_bdr[slave[i]-1] = 1;
403 }
404 else
405 {
406 cout <<"Slave boundary "<<slave[i]<<" out of range -- discarded"<< endl;
407 }
408 }
409 }
410 cout <<"Boundary conditions:"<< endl;
411 cout <<" - Periodic : "; per_bdr.Print();
412 cout <<" - Essential : "; ess_bdr.Print();
413 cout <<" - Neumann : "; neu_bdr.Print();
414
415
416 // 6. Set up the linear form b(.) which corresponds to the right-hand side of
417 // the FEM linear system, which in this case is (1,phi_i) where phi_i are
418 // the basis functions in the finite element fespace.
419 ConstantCoefficient one(1.0);
420 ConstantCoefficient mone(-1.0);
421 ConstantCoefficient zero(0.0);
422
423 LinearForm *b = new LinearForm(fespace);
424 b->AddDomainIntegrator(new DomainLFIntegrator(one));
425 b->AddBoundaryIntegrator( new BoundaryLFIntegrator(one),neu_bdr);
426 if (!strongBC)
427 b->AddBdrFaceIntegrator(
428 new DGDirichletLFIntegrator(zero, one, -1.0, kappa), ess_bdr);
429
430 b->Assemble();
431
432 // 7. Define the solution vector x as a finite element grid function
433 // corresponding to fespace. Initialize x with initial guess that
434 // satisfies the boundary conditions. Force the use of the ELEMENT
435 // projection type, also in the case of a NURBS spaces. For a NURBS space
436 // this will give a projection without any over and undershoots.
437 GridFunction x(fespace);
438 if (homogenousBC)
439 {
440 x = 0.0;
441 }
442 else
443 {
444 FunctionCoefficient sol_cf(sol);
445 x.ProjectCoefficient(sol_cf, ProjectType::ELEMENT);
446 }
447
448 // 8. Set up the bilinear form a(.,.) on the finite element space
449 // corresponding to the Laplacian operator -Delta, by adding the Diffusion
450 // domain integrator.
451 BilinearForm *a = new BilinearForm(fespace);
452 if (ibp)
453 {
454 a->AddDomainIntegrator(new DiffusionIntegrator(one));
455 }
456 else
457 {
458 a->AddDomainIntegrator(new Diffusion2Integrator(one));
459 a->AddBdrFaceIntegrator(new DGDiffusionIntegrator(mone, 0.0, 0.0), neu_bdr);
460 }
461
462 if (!strongBC)
463 {
464 a->AddBdrFaceIntegrator(new DGDiffusionIntegrator(one, -1.0, kappa), ess_bdr);
465 }
466
467 // 9. Assemble the bilinear form and the corresponding linear system,
468 // applying any necessary transformations such as: eliminating boundary
469 // conditions, applying conforming constraints for non-conforming AMR,
470 // static condensation, etc.
471 if (static_cond) { a->EnableStaticCondensation(); }
472 a->Assemble();
473
474 SparseMatrix A;
475 Vector B, X;
477 if (strongBC)
478 {
479 fespace->GetEssentialTrueDofs(ess_bdr, ess_tdof_list);
480 }
481 a->FormLinearSystem(ess_tdof_list, x, *b, A, X, B);
482
483 cout << "Size of linear system: " << A.Height() << endl;
484
485#ifndef MFEM_USE_SUITESPARSE
486 // 10. Define a simple Jacobi preconditioner and use it to
487 // solve the system A X = B with PCG.
488 GSSmoother M(A);
489 PCG(A, M, B, X, 1, 200, 1e-12, 0.0);
490#else
491 // 10. If MFEM was compiled with SuiteSparse, use UMFPACK to solve the system.
492 UMFPackSolver umf_solver;
493 umf_solver.Control[UMFPACK_ORDERING] = UMFPACK_ORDERING_METIS;
494 umf_solver.SetOperator(A);
495 umf_solver.Mult(B, X);
496#endif
497
498 // 11. Recover the solution as a finite element grid function.
499 a->RecoverFEMSolution(X, *b, x);
500
501 // 12. Save the refined mesh and the solution. This output can be viewed later
502 // using GLVis: "glvis -m refined.mesh -g sol.gf".
503 {
504 ofstream mesh_ofs("refined.mesh");
505 mesh_ofs.precision(8);
506 mesh->Print(mesh_ofs);
507 ofstream sol_ofs("sol.gf");
508 sol_ofs.precision(8);
509 x.Save(sol_ofs);
510 sol_ofs.close();
511 }
512
513 // 13. Send the solution by socket to a GLVis server.
514 if (visualization)
515 {
516 char vishost[] = "localhost";
517 socketstream sol_sock(vishost, visport);
518 sol_sock.precision(8);
519 sol_sock << "solution\n" << *mesh << x << flush;
520 }
521
522 if (mesh->Dimension() == 1 && lod > 0)
523 {
524 std::list<Data> sol;
525
526 Vector vals,coords;
527 GridFunction *nodes = mesh->GetNodes();
528 if (!nodes)
529 {
530 nodes = new GridFunction(fespace);
531 mesh->GetNodes(*nodes);
532 }
533
534 for (int i = 0; i < mesh->GetNE(); i++)
535 {
536 int geom = mesh->GetElementBaseGeometry(i);
538 lod, 1);
539
540 x.GetValues(i, refined_geo->RefPts, vals);
541 nodes->GetValues(i, refined_geo->RefPts, coords);
542
543 for (int j = 0; j < vals.Size(); j++)
544 {
545 sol.push_back(Data(coords[j],vals[j]));
546 }
547 }
548 sol.sort();
549 sol.unique();
550 ofstream sol_ofs("solution.dat");
551 for (std::list<Data>::iterator d = sol.begin(); d != sol.end(); ++d)
552 {
553 sol_ofs<<d->x <<"\t"<<d->val<<endl;
554 }
555
556 sol_ofs.close();
557 }
558
559 // 14. Save data in the VisIt format
560 if (ibp)
561 {
562 VisItDataCollection visit_dc("Example1", mesh);
563 visit_dc.RegisterField("solution", &x);
564 visit_dc.Save();
565 }
566 else
567 {
568 VisItDataCollection visit_dc("Example1_nibp", mesh);
569 visit_dc.RegisterField("solution", &x);
570 visit_dc.Save();
571 }
572
573 // 15. Free the used memory.
574 delete a;
575 delete b;
576 delete fespace;
577 if (own_fec) { delete fec; }
578 delete mesh;
579
580 return 0;
581}
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Definition array.cpp:69
void Load(std::istream &in, int fmt=0)
Read an Array from the stream in using format fmt. The format fmt can be:
Definition array.cpp:54
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
Definition array.hpp:869
int Size() const
Return the logical size of the array.
Definition array.hpp:192
void Print(std::ostream &out=mfem::out, int width=4) const
Prints array to stream with width elements per row.
Definition array.cpp:24
Abstract base class BilinearFormIntegrator.
A "square matrix" operator for the associated FE space and BLFIntegrators The sum of all the BLFInteg...
Class for boundary integration .
Definition lininteg.hpp:193
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
A coefficient that is constant across space and time.
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
Definition densemat.hpp:125
Class for domain integration .
Definition lininteg.hpp:108
real_t Weight()
Return the weight of the Jacobian matrix of the transformation at the currently set IntegrationPoint....
Definition eltrans.hpp:144
void SetIntPoint(const IntegrationPoint *ip)
Set the integration point ip that weights and Jacobians will be evaluated at.
Definition eltrans.hpp:106
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Definition fe_coll.hpp:27
virtual const char * Name() const
Definition fe_coll.hpp:79
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:210
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
Definition fespace.hpp:827
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:624
Abstract class for all finite elements.
Definition fe_base.hpp:294
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
Definition fe_base.hpp:414
int GetDim() const
Returns the reference space dimension for the finite element.
Definition fe_base.hpp:381
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
Definition fe_base.hpp:407
int Space() const
Returns the type of FunctionSpace on the element.
Definition fe_base.hpp:424
void CalcPhysLaplacian(ElementTransformation &Trans, Vector &Laplacian) const
Evaluate the Laplacian of all shape functions of a scalar finite element in physical space at the giv...
Definition fe_base.cpp:213
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const =0
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
Definition fe_base.hpp:410
A general function coefficient.
@ Pk
Polynomials of order k.
Definition fe_base.hpp:280
@ rQk
Refined tensor products of polynomials of order k.
Definition fe_base.hpp:282
Gauss-Seidel smoother of a sparse matrix.
RefinedGeometry * Refine(Geometry::Type Geom, int Times, int ETimes=1)
Definition geom.cpp:1136
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:53
void GetValues(int i, const IntegrationRule &ir, Vector &vals, int vdim=1) const
Definition gridfunc.cpp:497
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
virtual void ProjectCoefficient(Coefficient &coeff, ProjectType type=ProjectType::DEFAULT)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
Arbitrary order H1-conforming (continuous) finite elements.
Definition fe_coll.hpp:291
Class for integration point with weight.
Definition intrules.hpp:35
Class for an integration rule - an Array of IntegrationPoint.
Definition intrules.hpp:96
int GetNPoints() const
Returns the number of the points in the integration rule.
Definition intrules.hpp:255
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
Definition intrules.hpp:258
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
const IntegrationRule * IntRule
Vector with associated FE space and LinearFormIntegrators.
Mesh data type.
Definition mesh.hpp:67
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
Definition mesh.hpp:309
NURBSExtension * NURBSext
Optional NURBS mesh extension.
Definition mesh.hpp:317
void RefineNURBSFromFile(std::string ref_file)
Definition mesh.cpp:6375
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:2610
int GetNE() const
Returns number of elements.
Definition mesh.hpp:1390
int Dimension() const
Dimension of the reference space used within the elements.
Definition mesh.hpp:1314
void GetNodes(Vector &node_coord) const
Definition mesh.cpp:10112
virtual void PrintInfo(std::ostream &os=mfem::out)
In serial, this method calls PrintCharacteristics(). In parallel, additional information about the pa...
Definition mesh.hpp:2699
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Definition mesh.cpp:12125
Geometry::Type GetElementBaseGeometry(int i) const
Definition mesh.hpp:1569
NURBSExtension generally contains multiple NURBSPatch objects spanning an entire Mesh....
Definition nurbs.hpp:575
int GetNP() const
Return the number of patches.
Definition nurbs.hpp:936
int GetNKV() const
Return the number of KnotVectors.
Definition nurbs.hpp:949
void ConnectBoundaries()
Set DOF maps for periodic BC.
Definition nurbs.cpp:3360
Arbitrary order non-uniform rational B-splines (NURBS) finite elements.
Definition fe_coll.hpp:749
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
Definition operator.hpp:68
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.
IntegrationRule RefPts
Definition geom.hpp:321
Data type sparse matrix.
Definition sparsemat.hpp:51
Direct sparse solver using UMFPACK.
Definition solvers.hpp:1210
real_t Control[UMFPACK_CONTROL]
Definition solvers.hpp:1220
void SetOperator(const Operator &op) override
Factorize the given Operator op which must be a SparseMatrix.
Definition solvers.cpp:3368
void Mult(const Vector &b, Vector &x) const override
Direct solution of the linear system using UMFPACK.
Definition solvers.cpp:3463
Vector data type.
Definition vector.hpp:82
int Size() const
Returns the size of the vector.
Definition vector.hpp:234
void SetSize(int s)
Resize the vector to size s.
Definition vector.hpp:633
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.
const int * ess_tdof_list
real_t kappa
Definition ex24.cpp:54
int dim
Definition ex24.cpp:53
int main()
real_t b
Definition lissajous.cpp:42
real_t a
Definition lissajous.cpp:41
void mfem_error(const char *msg)
Definition error.cpp:154
GeometryRefiner GlobGeometryRefiner
Definition geom.cpp:2014
void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, real_t RTOLERANCE, real_t ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)
Definition solvers.cpp:1067
bool operator==(const Array< T > &LHS, const Array< T > &RHS)
Definition array.hpp:435
float real_t
Definition config.hpp:46
IntegrationRules RefinedIntRules(1, Quadrature1D::GaussLegendre)
A global object with all refined integration rules.
Definition intrules.hpp:552
bool operator<(const Pair< A, B > &p, const Pair< A, B > &q)
Comparison operator for class Pair, based on the first element only.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
Definition intrules.hpp:549
const char vishost[]
STL namespace.
real_t sol(const Vector &x)
MFEM_HOST_DEVICE real_t abs(const Complex &z)
std::array< int, NCMesh::MaxFaceNodes > nodes