MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
integ_algoim.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
11
12#include "integ_algoim.hpp"
13
14#ifdef MFEM_USE_ALGOIM
15
16namespace mfem
17{
18
21 const Vector &lsfun)
22{
23 int_order=o;
24 vir=nullptr;
25 sir=nullptr;
26
28 {
30 }
31 else if (el.GetGeomType()==Geometry::Type::CUBE)
32 {
34 }
35 else
36 {
37 MFEM_ABORT("Currently MFEM + Algoim supports only quads and hexes.");
38 }
39
40 // change the basis of the level-set function
41 // from Lagrangian to Bernstein (positive)
42 lsvec.SetSize(pe->GetDof());
43 DenseMatrix T(pe->GetDof());
44 pe->Project(el,trans,T);
45 T.Mult(lsfun,lsvec);
46}
47
49{
50 if (vir!=nullptr) {return vir;}
51
52 const int dim=pe->GetDim();
53 int np1d=int_order/2+1;
54 if (dim==2)
55 {
56 LevelSet2D ls(pe,lsvec);
57 auto q = Algoim::quadGen<2>(ls,Algoim::BoundingBox<real_t,2>(0.0,1.0),
58 -1, -1, np1d);
59
60 vir=new IntegrationRule(q.nodes.size());
61 vir->SetOrder(int_order);
62 for (size_t i=0; i<q.nodes.size(); i++)
63 {
64 IntegrationPoint& ip=vir->IntPoint(i);
65 ip.Set2w(q.nodes[i].x(0),q.nodes[i].x(1),q.nodes[i].w);
66 }
67 }
68 else
69 {
70 LevelSet3D ls(pe,lsvec);
71 auto q = Algoim::quadGen<3>(ls,Algoim::BoundingBox<real_t,3>(0.0,1.0),
72 -1, -1, np1d);
73
74 vir=new IntegrationRule(q.nodes.size());
75 vir->SetOrder(int_order);
76 for (size_t i=0; i<q.nodes.size(); i++)
77 {
78 IntegrationPoint& ip=vir->IntPoint(i);
79 ip.Set(q.nodes[i].x(0),q.nodes[i].x(1),q.nodes[i].x(2),q.nodes[i].w);
80 }
81 }
82
83 return vir;
84}
85
87{
88 if (sir!=nullptr) {return sir;}
89
90 int np1d=int_order/2+1;
91 const int dim=pe->GetDim();
92 if (dim==2)
93 {
94 LevelSet2D ls(pe,lsvec);
95 auto q = Algoim::quadGen<2>(ls,Algoim::BoundingBox<real_t,2>(0.0,1.0),
96 2, -1, np1d);
97
98 sir=new IntegrationRule(q.nodes.size());
99 sir->SetOrder(int_order);
100 for (size_t i=0; i<q.nodes.size(); i++)
101 {
102 IntegrationPoint& ip=sir->IntPoint(i);
103 ip.Set2w(q.nodes[i].x(0),q.nodes[i].x(1),q.nodes[i].w);
104 }
105 }
106 else
107 {
108 LevelSet3D ls(pe,lsvec);
109 auto q = Algoim::quadGen<3>(ls,Algoim::BoundingBox<real_t,3>(0.0,1.0),
110 3, -1, np1d);
111
112 sir=new IntegrationRule(q.nodes.size());
113 sir->SetOrder(int_order);
114 for (size_t i=0; i<q.nodes.size(); i++)
115 {
116 IntegrationPoint& ip=sir->IntPoint(i);
117 ip.Set(q.nodes[i].x(0),q.nodes[i].x(1),q.nodes[i].x(2),q.nodes[i].w);
118 }
119 }
120
121 return sir;
122}
123
124}
125
126#endif
127
128
const IntegrationRule * GetVolumeIntegrationRule()
AlgoimIntegrationRule(int o, const FiniteElement &el, ElementTransformation &trans, const Vector &lsfun)
const IntegrationRule * GetSurfaceIntegrationRule()
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
void Mult(const real_t *x, real_t *y) const
Matrix vector multiplication.
Definition densemat.cpp:220
Abstract class for all finite elements.
Definition fe_base.hpp:239
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
Definition fe_base.hpp:333
int GetDim() const
Returns the reference space dimension for the finite element.
Definition fe_base.hpp:316
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
Definition fe_base.hpp:326
int GetDof() const
Returns the number of degrees of freedom in the finite element.
Definition fe_base.hpp:329
Arbitrary order H1 elements in 3D utilizing the Bernstein basis on a cube.
Definition fe_pos.hpp:162
Arbitrary order H1 elements in 2D utilizing the Bernstein basis on a square.
Definition fe_pos.hpp:143
Class for integration point with weight.
Definition intrules.hpp:35
void Set(const real_t *p, const int dim)
Definition intrules.hpp:46
void Set2w(const real_t x1, const real_t x2, const real_t w)
Definition intrules.hpp:84
Class for an integration rule - an Array of IntegrationPoint.
Definition intrules.hpp:100
void SetOrder(const int order)
Sets the order of the integration rule. This is only for keeping order information,...
Definition intrules.hpp:253
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
Definition intrules.hpp:259
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
Definition fe_pos.cpp:25
Vector data type.
Definition vector.hpp:80
void SetSize(int s)
Resize the vector to size s.
Definition vector.hpp:538
int dim
Definition ex24.cpp:53
void trans(const Vector &u, Vector &x)
Definition ex27.cpp:412