Loading [MathJax]/extensions/tex2jax.js
libMesh
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
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) {}
Number _integral
Definition: calculator.C:159
const System & _sys
Definition: calculator.C:155
std::unique_ptr< FEMFunctionBase< Number > > _f
Definition: calculator.C:157
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const =0

◆ 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) {}
Number _integral
Definition: calculator.C:159
const System & _sys
Definition: calculator.C:155
std::unique_ptr< FEMFunctionBase< Number > > _f
Definition: calculator.C:157

Member Function Documentation

◆ integral()

Number Integrate::integral ( ) const
inline

Definition at line 152 of file calculator.C.

152 { return _integral; }
Number _integral
Definition: calculator.C:159

◆ join()

void Integrate::join ( const Integrate other)
inline

Definition at line 147 of file calculator.C.

References _integral.

148  {
149  _integral += other._integral;
150  }
Number _integral
Definition: calculator.C:159

◆ operator()()

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

Definition at line 112 of file calculator.C.

References libMesh::FEMContext::elem_fe_reinit(), libMesh::FEMContext::get_element_fe(), libMesh::FEAbstract::get_JxW(), libMesh::FEAbstract::get_nothing(), libMesh::FEAbstract::get_xyz(), libMesh::index_range(), and libMesh::FEMContext::pre_fe_reinit().

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  }
const MeshBase & get_mesh() const
Definition: system.h:2345
virtual_for_inffe const std::vector< Real > & get_JxW() const
Definition: fe_abstract.h:303
This class provides all data required for a physics package (e.g.
Definition: fem_context.h:62
virtual_for_inffe const std::vector< Point > & get_xyz() const
Definition: fe_abstract.h:280
Number _integral
Definition: calculator.C:159
void get_nothing() const
Definition: fe_abstract.h:269
const System & _sys
Definition: calculator.C:155
unsigned int mesh_dimension() const
Definition: mesh_base.C:354
std::unique_ptr< FEMFunctionBase< Number > > _f
Definition: calculator.C:157
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:117
This class forms the foundation from which generic finite elements may be derived.

Member Data Documentation

◆ _f

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

Definition at line 157 of file calculator.C.

◆ _integral

Number Integrate::_integral
private

Definition at line 159 of file calculator.C.

Referenced by join().

◆ _sys

const System& Integrate::_sys
private

Definition at line 155 of file calculator.C.


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