MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
ex38.cpp
Go to the documentation of this file.
1// MFEM Example 38
2//
3// Compile with: make ex38
4//
5// Sample runs:
6// (since all sample runs require LAPACK or ALGOIM, the * symbol is used to
7// exclude them from the automatically generated internal MFEM tests).
8// * ex38
9// * ex38 -i volumetric1d
10// * ex38 -i surface2d
11// * ex38 -i surface2d -o 4 -r 5 -m 1
12// * ex38 -i volumetric2d
13// * ex38 -i volumetric2d -o 4 -r 5 -m 1
14// * ex38 -i surface3d
15// * ex38 -i surface3d -o 3 -r 4 -m 1
16// * ex38 -i volumetric3d
17// * ex38 -i volumetric3d -o 3 -r 4 -m 1
18//
19// Description: This example code demonstrates the use of MFEM to integrate
20// functions over implicit interfaces and subdomains bounded by
21// implicit interfaces.
22//
23// The quadrature rules are constructed by means of moment-fitting.
24// The interface is given by the zero isoline of a level-set
25// function ϕ and the subdomain is given as the domain where ϕ>0
26// holds. The algorithm for construction of the quadrature rules
27// was introduced by Mueller, Kummer and Oberlack [1].
28//
29// This example also showcases how to set up integrators using the
30// integration rules on implicit surfaces and subdomains.
31//
32// [1] Mueller, B., Kummer, F. and Oberlack, M. (2013) Highly accurate surface
33// and volume integration on implicit domains by means of moment-fitting.
34// Int. J. Numer. Meth. Engr. (96) 512-528. DOI:10.1002/nme.4569
35
36#include "mfem.hpp"
37#include <iostream>
38
39using namespace std;
40using namespace mfem;
41
42/// @brief Integration rule the example should demonstrate
47
48/// @brief Level-set function defining the implicit interface
50{
51 switch (itype)
52 {
54 return .55 - X(0);
56 return 1. - (pow(X(0), 2.) + pow(X(1), 2.));
58 return 1. - (pow(X(0) / 1.5, 2.) + pow(X(1) / .75, 2.));
60 return 1. - (pow(X(0), 2.) + pow(X(1), 2.) + pow(X(2), 2.));
62 return 1. - (pow(X(0) / 1.5, 2.) + pow(X(1) / .75, 2.) + pow(X(2) / .5, 2.));
63 default:
64 return 1.;
65 }
66}
67
68/// @brief Function that should be integrated
70{
71 switch (itype)
72 {
74 return pow(X(0), 2.);
76 return 3. * pow(X(0), 2.) - pow(X(1), 2.);
78 return 1.;
80 return 4. - 3. * pow(X(0), 2.) + 2. * pow(X(1), 2.) - pow(X(2), 2.);
82 return 1.;
83 default:
84 return 0.;
85 }
86}
87
88/// @brief Analytic surface integral
90{
91 switch (itype)
92 {
94 return .3025;
96 return 2. * M_PI;
98 return 7.26633616541076;
100 return 40. / 3. * M_PI;
102 return 9.90182151329315;
103 default:
104 return 0.;
105 }
106}
107
108/// @brief Analytic volume integral over subdomain with positive level-set
110{
111 switch (itype)
112 {
114 return pow(.55, 3.) / 3.;
116 return NAN;
118 return 9. / 8. * M_PI;
120 return NAN;
122 return 3. / 4. * M_PI;
123 default:
124 return 0.;
125 }
126}
127
128/**
129 @brief Class for surface IntegrationRule
130
131 This class demonstrates how IntegrationRules computed as CutIntegrationRules
132 can be saved to reduce the impact by computing them from scratch each time.
133 */
134class SIntegrationRule : public IntegrationRule
135{
136protected:
137 /// method 0 is moments-based, 1 is Algoim.
138 int method, ir_order, ls_order;
139 Coefficient &level_set;
140 /// Space Dimension of the IntegrationRule
141 int dim;
142 /// Column-wise matrix of the quadtrature weights
143 DenseMatrix Weights;
144 /// Column-wise matrix of the transformation weights of the normal
145 DenseMatrix SurfaceWeights;
146
147public:
148 /**
149 @brief Constructor of SIntegrationRule
150
151 The surface integrationRules are computed and saved in the constructor.
152
153 @param [in] Order Order of the IntegrationRule
154 @param [in] LvlSet Level-set defining the implicit interface
155 @param [in] lsOrder Polynomial degree for approx of level-set function
156 @param [in] mesh Pointer to the mesh that is used
157 */
158 SIntegrationRule(int method_, int Order,
159 Coefficient& LvlSet, int lsOrder, Mesh* mesh)
160 : method(method_), ir_order(Order), ls_order(lsOrder),
161 level_set(LvlSet), dim(mesh->Dimension())
162 {
163 // Nothing gets pre-computed for Algoim.
164 if (method == 1) { return; }
165
166#ifdef MFEM_USE_LAPACK
167 MomentFittingIntRules mf_ir(ir_order, level_set, ls_order);
168
170 mesh->GetElementTransformation(0, &Tr);
172 mf_ir.GetSurfaceIntegrationRule(Tr, ir);
173 if (dim >1)
174 {
175 Weights.SetSize(ir.GetNPoints(), mesh->GetNE());
176 }
177 else
178 {
179 Weights.SetSize(2, mesh->GetNE());
180 }
181 SurfaceWeights.SetSize(ir.GetNPoints(), mesh->GetNE());
182 Vector w;
183 mf_ir.GetSurfaceWeights(Tr, ir, w);
184 SurfaceWeights.SetCol(0, w);
185 SetSize(ir.GetNPoints());
186
187 for (int ip = 0; ip < GetNPoints(); ip++)
188 {
189 IntPoint(ip).index = ip;
190 IntegrationPoint &intp = IntPoint(ip);
191 intp.x = ir.IntPoint(ip).x;
192 intp.y = ir.IntPoint(ip).y;
193 intp.z = ir.IntPoint(ip).z;
194 if (dim > 1)
195 {
196 Weights(ip, 0) = ir.IntPoint(ip).weight;
197 }
198 else
199 {
200 Weights(0, 0) = ir.IntPoint(ip).x;
201 Weights(1, 0) = ir.IntPoint(ip).weight;
202 }
203 }
204
205
206 for (int elem = 1; elem < mesh->GetNE(); elem++)
207 {
208 mesh->GetElementTransformation(elem, &Tr);
209 mf_ir.GetSurfaceIntegrationRule(Tr, ir);
210 mf_ir.GetSurfaceWeights(Tr, ir, w);
211 SurfaceWeights.SetCol(elem, w);
212
213 for (int ip = 0; ip < GetNPoints(); ip++)
214 {
215 if (dim > 1)
216 {
217 Weights(ip, elem) = ir.IntPoint(ip).weight;
218 }
219 else
220 {
221 Weights(0, elem) = ir.IntPoint(ip).x;
222 Weights(1, elem) = ir.IntPoint(ip).weight;
223 }
224 }
225 }
226#else
227 MFEM_ABORT("Moment-fitting requires MFEM to be built with LAPACK!");
228#endif
229 }
230
231 /**
232 @brief Set the weights for the given element and multiply them with the
233 transformation of the interface
234 */
235 void SetElementAndSurfaceWeight(ElementTransformation &Tr)
236 {
237 if (method == 1)
238 {
239#ifdef MFEM_USE_ALGOIM
240 AlgoimIntegrationRules a_ir(ir_order, level_set, ls_order);
241 a_ir.GetSurfaceIntegrationRule(Tr, *this);
242 Vector w;
243 a_ir.GetSurfaceWeights(Tr, *this, w);
244 for (int ip = 0; ip < GetNPoints(); ip++)
245 {
246 IntPoint(ip).weight *= w(ip);
247 }
248 return;
249#else
250 MFEM_ABORT("MFEM is not built with Algoim support!");
251#endif
252 }
253
254 if (dim == 1)
255 {
256 IntPoint(0).x = Weights(0, Tr.ElementNo);
257 IntPoint(0).weight = Weights(1, Tr.ElementNo);
258 }
259 else
260 {
261 for (int ip = 0; ip < GetNPoints(); ip++)
262 {
263 IntPoint(ip).weight = Weights(ip, Tr.ElementNo) *
264 SurfaceWeights(ip, Tr.ElementNo);
265 }
266 }
267 }
268};
269
270/**
271 @brief Class for volume IntegrationRule
272
273 This class demonstrates how IntegrationRules computed as CutIntegrationRules
274 can be saved to reduce the impact by computing them from scratch each time.
275 */
276class CIntegrationRule : public IntegrationRule
277{
278protected:
279 /// method 0 is moments-based, 1 is Algoim.
280 int method, ir_order, ls_order;
281 Coefficient &level_set;
282 /// Space Dimension of the IntegrationRule
283 int dim;
284 /// Column-wise matrix of the quadtrature positions and weights.
285 DenseMatrix Weights;
286
287public:
288 /**
289 @brief Constructor of CIntegrationRule
290
291 The volume integrationRules are computed and saved in the constructor.
292
293 @param [in] Order Order of the IntegrationRule
294 @param [in] LvlSet Level-set defining the implicit interface
295 @param [in] lsOrder Polynomial degree for approx of level-set function
296 @param [in] mesh Pointer to the mesh that is used
297 */
298 CIntegrationRule(int method_, int Order,
299 Coefficient &LvlSet, int lsOrder, Mesh *mesh)
300 : method(method_), ir_order(Order), ls_order(lsOrder),
301 level_set(LvlSet), dim(mesh->Dimension())
302 {
303 // Nothing gets pre-computed for Algoim.
304 if (method == 1) { return; }
305
306#ifdef MFEM_USE_LAPACK
307 MomentFittingIntRules mf_ir(ir_order, level_set, ls_order);
308
310 mesh->GetElementTransformation(0, &Tr);
312 mf_ir.GetVolumeIntegrationRule(Tr, ir);
313 if (dim > 1)
314 {
315 Weights.SetSize(ir.GetNPoints(), mesh->GetNE());
316 }
317 else
318 {
319 Weights.SetSize(2 * ir.GetNPoints(), mesh->GetNE());
320 }
321
322 SetSize(ir.GetNPoints());
323 for (int ip = 0; ip < GetNPoints(); ip++)
324 {
325 IntPoint(ip).index = ip;
326 IntegrationPoint &intp = IntPoint(ip);
327 intp.x = ir.IntPoint(ip).x;
328 intp.y = ir.IntPoint(ip).y;
329 intp.z = ir.IntPoint(ip).z;
330 if (dim > 1)
331 {
332 Weights(ip, 0) = ir.IntPoint(ip).weight;
333 }
334 else
335 {
336 Weights(2 * ip, 0) = ir.IntPoint(ip).x;
337 Weights(2 * ip + 1, 0) = ir.IntPoint(ip).weight;
338 }
339 }
340
341 for (int elem = 1; elem < mesh->GetNE(); elem++)
342 {
343 mesh->GetElementTransformation(elem, &Tr);
344 mf_ir.GetVolumeIntegrationRule(Tr, ir);
345
346 for (int ip = 0; ip < ir.GetNPoints(); ip++)
347 {
348 if (dim > 1)
349 {
350 Weights(ip, elem) = ir.IntPoint(ip).weight;
351 }
352 else
353 {
354 Weights(2 * ip, elem) = ir.IntPoint(ip).x;
355 Weights(2 * ip + 1, elem) = ir.IntPoint(ip).weight;
356 }
357 }
358 }
359#else
360 MFEM_ABORT("Moment-fitting requires MFEM to be built with LAPACK!");
361#endif
362 }
363
364 /// @brief Set the weights for the given element
365 void SetElement(ElementTransformation &Tr)
366 {
367 if (method == 1)
368 {
369#ifdef MFEM_USE_ALGOIM
370 AlgoimIntegrationRules a_ir(ir_order, level_set, ls_order);
371 a_ir.GetVolumeIntegrationRule(Tr, *this);
372 return;
373#else
374 MFEM_ABORT("MFEM is not built with Algoim support!");
375#endif
376 }
377
378 for (int ip = 0; ip < GetNPoints(); ip++)
379 {
380 IntegrationPoint &intp = IntPoint(ip);
381 if (dim == 1)
382 {
383 intp.x = Weights(2 * ip, Tr.ElementNo);
384 intp.weight = Weights(2 * ip + 1, Tr.ElementNo);
385 }
386 else { intp.weight = Weights(ip, Tr.ElementNo); }
387 }
388 }
389};
390
391
392/**
393 @brief Class for surface linear form integrator
394
395 Integrator to demonstrate the use of the surface integration rule on an
396 implicit surface defined by a level-set.
397 */
398class SurfaceLFIntegrator : public LinearFormIntegrator
399{
400protected:
401 /// @brief vector to evaluate the basis functions
402 Vector shape;
403
404 /// @brief surface integration rule
405 SIntegrationRule* SIntRule;
406
407 /// @brief coefficient representing the level-set defining the interface
408 Coefficient &LevelSet;
409
410 /// @brief coefficient representing the integrand
411 Coefficient &Q;
412
413public:
414 /**
415 @brief Constructor for the surface linear form integrator
416
417 Constructor for the surface linear form integrator to demonstrate the use
418 of the surface integration rule by means of moment-fitting.
419
420 @param [in] q coefficient representing the inegrand
421 @param [in] levelset level-set defining the implicit interfac
422 @param [in] ir surface integrtion rule to be used
423 */
424 SurfaceLFIntegrator(Coefficient &q, Coefficient &levelset,
425 SIntegrationRule* ir)
426 : LinearFormIntegrator(), SIntRule(ir), LevelSet(levelset), Q(q) { }
427
428 /**
429 @brief Assembly of the element vector
430
431 Assemble the element vector of for the right hand side on the element given
432 by the FiniteElement and ElementTransformation.
433
434 @param [in] el finite Element the vector belongs to
435 @param [in] Tr transformation of finite element
436 @param [out] elvect vector containing the
437 */
438 void AssembleRHSElementVect(const FiniteElement &el,
440 Vector &elvect) override
441 {
442 int dof = el.GetDof();
443 shape.SetSize(dof);
444 elvect.SetSize(dof);
445 elvect = 0.;
446
447 // Update the surface integration rule for the current element
448 SIntRule->SetElementAndSurfaceWeight(Tr);
449
450 for (int ip = 0; ip < SIntRule->GetNPoints(); ip++)
451 {
452 Tr.SetIntPoint((&(SIntRule->IntPoint(ip))));
453 real_t val = Tr.Weight() * Q.Eval(Tr, SIntRule->IntPoint(ip));
454 el.CalcShape(SIntRule->IntPoint(ip), shape);
455 add(elvect, SIntRule->IntPoint(ip).weight * val, shape, elvect);
456 }
457 }
458
460};
461
462/**
463 @brief Class for subdomain linear form integrator
464
465 Integrator to demonstrate the use of the subdomain integration rule within
466 an area defined by an implicit surface defined by a level-set.
467 */
468class SubdomainLFIntegrator : public LinearFormIntegrator
469{
470protected:
471 /// @brief vector to evaluate the basis functions
472 Vector shape;
473
474 /// @brief surface integration rule
475 CIntegrationRule* CIntRule;
476
477 /// @brief coefficient representing the level-set defining the interface
478 Coefficient &LevelSet;
479
480 /// @brief coefficient representing the integrand
481 Coefficient &Q;
482
483public:
484 /**
485 @brief Constructor for the volumetric subdomain linear form integrator
486
487 Constructor for the subdomain linear form integrator to demonstrate the use
488 of the volumetric subdomain integration rule by means of moment-fitting.
489
490 @param [in] q coefficient representing the inegrand
491 @param [in] levelset level-set defining the implicit interfac
492 @param [in] ir subdomain integrtion rule to be used
493 */
494 SubdomainLFIntegrator(Coefficient &q, Coefficient &levelset,
495 CIntegrationRule* ir)
496 : LinearFormIntegrator(), CIntRule(ir), LevelSet(levelset), Q(q) { }
497
498 /**
499 @brief Assembly of the element vector
500
501 Assemble the element vector of for the right hand side on the element given
502 by the FiniteElement and ElementTransformation.
503
504 @param [in] el finite Element the vector belongs to
505 @param [in] Tr transformation of finite element
506 @param [out] elvect vector containing the
507 */
508 void AssembleRHSElementVect(const FiniteElement &el,
510 Vector &elvect) override
511 {
512 int dof = el.GetDof();
513 shape.SetSize(dof);
514 elvect.SetSize(dof);
515 elvect = 0.;
516
517 // Update the subdomain integration rule
518 CIntRule->SetElement(Tr);
519
520 for (int ip = 0; ip < CIntRule->GetNPoints(); ip++)
521 {
522 Tr.SetIntPoint((&(CIntRule->IntPoint(ip))));
523 real_t val = Tr.Weight()
524 * Q.Eval(Tr, CIntRule->IntPoint(ip));
525 el.CalcPhysShape(Tr, shape);
526 add(elvect, CIntRule->IntPoint(ip).weight * val, shape, elvect);
527 }
528 }
529
531};
532
533int main(int argc, char *argv[])
534{
535#if defined(MFEM_USE_LAPACK) || defined(MFEM_USE_ALGOIM)
536 // 1. Parse he command-line options.
537 int ref_levels = 3;
538 int order = 2;
539 int method = 0;
540 const char *inttype = "surface2d";
541 bool visualization = true;
543
544 OptionsParser args(argc, argv);
545 args.AddOption(&order, "-o", "--order", "Order of quadrature rule");
546 args.AddOption(&ref_levels, "-r", "--refine", "Number of meh refinements");
547 args.AddOption(&method, "-m", "--method",
548 "Cut integration method: 0 for moments-based, 1 for Algoim.");
549 args.AddOption(&inttype, "-i", "--integration-type",
550 "IntegrationType to demonstrate");
551 args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
552 "--no-visualization",
553 "Enable or disable GLVis visualization.");
554 args.ParseCheck();
555
556 if (strcmp(inttype, "volumetric1d") == 0
557 || strcmp(inttype, "Volumetric1D") == 0)
558 {
560 }
561 else if (strcmp(inttype, "surface2d") == 0
562 || strcmp(inttype, "Surface2D") == 0)
563 {
565 }
566 else if (strcmp(inttype, "volumetric2d") == 0
567 || strcmp(inttype, "Volumetric2D") == 0)
568 {
570 }
571 else if (strcmp(inttype, "surface3d") == 0
572 || strcmp(inttype, "Surface3d") == 0)
573 {
575 }
576 else if (strcmp(inttype, "volumetric3d") == 0
577 || strcmp(inttype, "Volumetric3d") == 0)
578 {
580 }
581
582 // 2. Construct and refine the mesh.
583 Mesh *mesh = nullptr;
585 {
586 mesh = new Mesh("../data/inline-segment.mesh");
587 }
590 {
591 mesh = new Mesh(2, 4, 1, 0, 2);
592 mesh->AddVertex(-1.6,-1.6);
593 mesh->AddVertex(1.6,-1.6);
594 mesh->AddVertex(1.6,1.6);
595 mesh->AddVertex(-1.6,1.6);
596 mesh->AddQuad(0,1,2,3);
597 mesh->FinalizeQuadMesh(1, 0, 1);
598 }
601 {
602 mesh = new Mesh(3, 8, 1, 0, 3);
603 mesh->AddVertex(-1.6,-1.6,-1.6);
604 mesh->AddVertex(1.6,-1.6,-1.6);
605 mesh->AddVertex(1.6,1.6,-1.6);
606 mesh->AddVertex(-1.6,1.6,-1.6);
607 mesh->AddVertex(-1.6,-1.6,1.6);
608 mesh->AddVertex(1.6,-1.6,1.6);
609 mesh->AddVertex(1.6,1.6,1.6);
610 mesh->AddVertex(-1.6,1.6,1.6);
611 mesh->AddHex(0,1,2,3,4,5,6,7);
612 mesh->FinalizeHexMesh(1, 0, 1);
613 }
614
615 for (int lev = 0; lev < ref_levels; lev++)
616 {
617 mesh->UniformRefinement();
618 }
619
620 // 3. Define the necessary finite element space on the mesh.
621 H1_FECollection fe_coll(1, mesh->Dimension());
622 FiniteElementSpace *fespace = new FiniteElementSpace(mesh, &fe_coll);
623
624 // 4. Construction Coefficients for the level set and the integrand.
625 FunctionCoefficient levelset(lvlset);
627
628 // 5. Define the necessary Integration rules on element 0.
630 mesh->GetElementTransformation(0, &Tr);
631 SIntegrationRule* sir = new SIntegrationRule(method, order,
632 levelset, 2, mesh);
633 CIntegrationRule* cir = NULL;
637 {
638 cir = new CIntegrationRule(method, order, levelset, 2, mesh);
639 }
640
641 // 6. Define and assemble the linear forms on the finite element space.
642 LinearForm surface(fespace);
643 LinearForm volume(fespace);
644
645 surface.AddDomainIntegrator(new SurfaceLFIntegrator(u, levelset, sir));
646 surface.Assemble();
647
651 {
652 volume.AddDomainIntegrator(new SubdomainLFIntegrator(u, levelset, cir));
653 volume.Assemble();
654 }
655
656 // 7. Print information, computed values and errors to the console.
657 int qorder = 0;
658 int nbasis = 2 * (order + 1) + (int)(order * (order + 1) / 2);
660 IntegrationRule ir = irs.Get(Geometry::SQUARE, qorder);
661 for (; ir.GetNPoints() <= nbasis; qorder++)
662 {
663 ir = irs.Get(Geometry::SQUARE, qorder);
664 }
665 cout << "============================================" << endl;
666 cout << "Mesh size dx: ";
668 {
669 cout << 3.2 / pow(2., (real_t)ref_levels) << endl;
670 }
671 else
672 {
673 cout << .25 / pow(2., (real_t)ref_levels) << endl;
674 }
677 {
678 cout << "Number of div free basis functions: " << nbasis << endl;
679 cout << "Number of quadrature points: " << ir.GetNPoints() << endl;
680 }
681 cout << scientific << setprecision(10);
682 cout << "============================================" << endl;
683 cout << "Computed value of surface integral: " << surface.Sum() << endl;
684 cout << "True value of surface integral: " << Surface() << endl;
685 cout << "Absolute Error (Surface): ";
686 cout << abs(surface.Sum() - Surface()) << endl;
687 cout << "Relative Error (Surface): ";
688 cout << abs(surface.Sum() - Surface()) / Surface() << endl;
692 {
693 cout << "--------------------------------------------" << endl;
694 cout << "Computed value of volume integral: " << volume.Sum() << endl;
695 cout << "True value of volume integral: " << Volume() << endl;
696 cout << "Absolute Error (Volume): ";
697 cout << abs(volume.Sum() - Volume()) << endl;
698 cout << "Relative Error (Volume): ";
699 cout << abs(volume.Sum() - Volume()) / Volume() << endl;
700 }
701 cout << "============================================" << endl;
702
703 // 8. Plot the level-set function on a high order finite element space.
704 if (visualization)
705 {
706 H1_FECollection fe_coll2(5, mesh->Dimension());
707 FiniteElementSpace fespace2(mesh, &fe_coll2);
708 FunctionCoefficient levelset_coeff(levelset);
709 GridFunction lgf(&fespace2);
710 lgf.ProjectCoefficient(levelset_coeff);
711 char vishost[] = "localhost";
712 int visport = 19916;
713 socketstream sol_sock(vishost, visport);
714 sol_sock.precision(8);
715 sol_sock << "solution\n" << *mesh << lgf << flush;
716 sol_sock << "keys pppppppppppppppppppppppppppcmmlRj\n";
717 sol_sock << "levellines " << 0. << " " << 0. << " " << 1 << "\n" << flush;
718 }
719
720 delete sir;
721 delete cir;
722 delete fespace;
723 delete mesh;
724 return EXIT_SUCCESS;
725#else
726 cout << "MFEM must be built with LAPACK or ALGOIM for this example." << endl;
727 return MFEM_SKIP_RETURN_VALUE;
728#endif // MFEM_USE_LAPACK
729}
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.
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:108
void SetCol(int c, const real_t *col)
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
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:244
Abstract class for all finite elements.
Definition fe_base.hpp:244
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:334
void CalcPhysShape(ElementTransformation &Trans, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in physical space at the point ...
Definition fe_base.cpp:182
A general function coefficient.
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:31
virtual void ProjectCoefficient(Coefficient &coeff)
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:275
Class for integration point with weight.
Definition intrules.hpp:35
Class for an integration rule - an Array of IntegrationPoint.
Definition intrules.hpp:100
int GetNPoints() const
Returns the number of the points in the integration rule.
Definition intrules.hpp:256
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
Definition intrules.hpp:259
Container class for integration rules.
Definition intrules.hpp:422
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
A standard isoparametric element transformation.
Definition eltrans.hpp:629
Abstract base class LinearFormIntegrator.
Definition lininteg.hpp:26
virtual void AssembleRHSElementVect(const FiniteElement &el, ElementTransformation &Tr, Vector &elvect)=0
Vector with associated FE space and LinearFormIntegrators.
void AddDomainIntegrator(LinearFormIntegrator *lfi)
Adds new Domain Integrator. Assumes ownership of lfi.
void Assemble()
Assembles the linear form i.e. sums over all domain/bdr integrators.
Mesh data type.
Definition mesh.hpp:64
int AddQuad(int v1, int v2, int v3, int v4, int attr=1)
Adds a quadrilateral to the mesh given by 4 vertices v1 through v4.
Definition mesh.cpp:1958
int AddVertex(real_t x, real_t y=0.0, real_t z=0.0)
Definition mesh.cpp:1873
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 FinalizeHexMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a hexahedral Mesh.
Definition mesh.cpp:3325
void GetElementTransformation(int i, IsoparametricTransformation *ElTr) const
Builds the transformation defining the i-th element in ElTr. ElTr must be allocated in advance and wi...
Definition mesh.cpp:357
void FinalizeQuadMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a quadrilateral Mesh.
Definition mesh.cpp:2404
int AddHex(int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8, int attr=1)
Adds a hexahedron to the mesh given by 8 vertices v1 through v8.
Definition mesh.cpp:2021
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
Definition mesh.cpp:11295
Class for subdomain IntegrationRules by means of moment-fitting.
void ParseCheck(std::ostream &out=mfem::out)
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
Vector data type.
Definition vector.hpp:82
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
int dim
Definition ex24.cpp:53
real_t Surface()
Analytic surface integral.
Definition ex38.cpp:89
IntegrationType itype
Definition ex38.cpp:46
real_t integrand(const Vector &X)
Function that should be integrated.
Definition ex38.cpp:69
real_t Volume()
Analytic volume integral over subdomain with positive level-set.
Definition ex38.cpp:109
real_t lvlset(const Vector &X)
Level-set function defining the implicit interface.
Definition ex38.cpp:49
IntegrationType
Integration rule the example should demonstrate.
Definition ex38.cpp:43
int main()
real_t u(const Vector &xvec)
Definition lor_mms.hpp:22
void add(const Vector &v1, const Vector &v2, Vector &v)
Definition vector.cpp:391
float real_t
Definition config.hpp:43
const char vishost[]