libMesh
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Integrate Struct Reference

Public Member Functions

 Integrate (const System &sys, const FEMFunctionBase< Number > &f)
 
 Integrate (Integrate &other, Threads::split)
 
void operator() (const ConstElemRange &range)
 
void join (const Integrate &other)
 
Number integral () const
 

Private Attributes

const System_sys
 
std::unique_ptr< FEMFunctionBase< Number > > _f
 
Number _integral
 

Detailed Description

Definition at line 104 of file calculator.C.

Constructor & Destructor Documentation

◆ Integrate() [1/2]

Integrate::Integrate ( const System sys,
const FEMFunctionBase< Number > &  f 
)
inline

Definition at line 105 of file calculator.C.

106 :
107 _sys(sys), _f(f.clone()), _integral(0) {}
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const =0
std::unique_ptr< FEMFunctionBase< Number > > _f
Definition calculator.C:157
const System & _sys
Definition calculator.C:155
Number _integral
Definition calculator.C:159

◆ Integrate() [2/2]

Integrate::Integrate ( Integrate other,
Threads::split   
)
inline

Definition at line 109 of file calculator.C.

109 :
110 _sys(other._sys), _f(other._f->clone()), _integral(0) {}

Member Function Documentation

◆ integral()

Number Integrate::integral ( ) const
inline

Definition at line 152 of file calculator.C.

152{ return _integral; }

References _integral.

Referenced by main().

◆ join()

void Integrate::join ( const Integrate other)
inline

Definition at line 147 of file calculator.C.

148 {
149 _integral += other._integral;
150 }

References _integral.

◆ operator()()

void Integrate::operator() ( const ConstElemRange range)
inline

Definition at line 112 of file calculator.C.

112 {
113 FEMContext context(_sys);
114
115 FEBase * elem_fe = nullptr;
116 context.get_element_fe(0, elem_fe);
117
118 const std::vector<Real> & JxW = elem_fe->get_JxW();
119 const std::vector<Point> & xyz = elem_fe->get_xyz();
120
121 _f->init_context(context);
122
123 // If _f didn't need anything, that wasn't a fluke
124 elem_fe->get_nothing();
125
126 // We only integrate on the highest dimensional elements in the
127 // mesh, lest we be adding apples to oranges
128 const unsigned int mesh_dim = _sys.get_mesh().mesh_dimension();
129
130 for (const auto & elem : range)
131 {
132 if (elem->dim() < mesh_dim)
133 continue;
134
135 context.pre_fe_reinit(_sys, elem);
136 context.elem_fe_reinit();
137
138 for (auto qp : index_range(JxW))
139 {
140 const Number output = (*_f)(context, xyz[qp]);
141
142 _integral += output * JxW[qp];
143 }
144 }
145 }
void get_nothing() const
virtual_for_inffe const std::vector< Real > & get_JxW() const
virtual_for_inffe const std::vector< Point > & get_xyz() const
This class forms the foundation from which generic finite elements may be derived.
Definition fe_base.h:86
This class provides all data required for a physics package (e.g.
Definition fem_context.h:63
unsigned int mesh_dimension() const
Definition mesh_base.C:430
const MeshBase & get_mesh() const
Definition system.h:2401
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153

References _f, _integral, _sys, libMesh::FEMContext::elem_fe_reinit(), libMesh::FEMContext::get_element_fe(), libMesh::FEAbstract::get_JxW(), libMesh::System::get_mesh(), libMesh::FEAbstract::get_nothing(), libMesh::FEAbstract::get_xyz(), libMesh::index_range(), libMesh::MeshBase::mesh_dimension(), and libMesh::FEMContext::pre_fe_reinit().

Member Data Documentation

◆ _f

std::unique_ptr<FEMFunctionBase<Number> > Integrate::_f
private

Definition at line 157 of file calculator.C.

Referenced by operator()().

◆ _integral

Number Integrate::_integral
private

Definition at line 159 of file calculator.C.

Referenced by integral(), join(), and operator()().

◆ _sys

const System& Integrate::_sys
private

Definition at line 155 of file calculator.C.

Referenced by operator()().


The documentation for this struct was generated from the following file: