libMesh
Public Member Functions | Protected Attributes | Private Attributes | List of all members
libMesh::AutoAreaFunction Class Reference

#include <triangulator_interface.h>

Inheritance diagram for libMesh::AutoAreaFunction:
[legend]

Public Member Functions

 AutoAreaFunction (const Parallel::Communicator &comm, const unsigned int num_nearest_pts, const unsigned int power, const Real background_value, const Real background_eff_dist)
 
 AutoAreaFunction (const AutoAreaFunction &)
 
AutoAreaFunctionoperator= (const AutoAreaFunction &)
 
 AutoAreaFunction (AutoAreaFunction &&)=delete
 
AutoAreaFunctionoperator= (AutoAreaFunction &&)=delete
 
virtual ~AutoAreaFunction ()
 
void init_mfi (const std::vector< Point > &input_pts, const std::vector< Real > &input_vals)
 
virtual Real operator() (const Point &p, const Real) override
 
virtual void operator() (const Point &p, const Real time, DenseVector< Real > &output) override
 Evaluation function for time-dependent vector-valued functions. More...
 
virtual std::unique_ptr< FunctionBase< Real > > clone () const override
 
virtual void init ()
 The actual initialization process. More...
 
virtual void clear ()
 Clears the function. More...
 
void operator() (const Point &p, DenseVector< Real > &output)
 Evaluation function for time-independent vector-valued functions. More...
 
virtual Real component (unsigned int i, const Point &p, Real time=0.)
 
bool initialized () const
 
void set_is_time_dependent (bool is_time_dependent)
 Function to set whether this is a time-dependent function or not. More...
 
bool is_time_dependent () const
 

Protected Attributes

const FunctionBase_master
 Const pointer to our master, initialized to nullptr. More...
 
bool _initialized
 When init() was called so that everything is ready for calls to operator() (...), then this bool is true. More...
 
bool _is_time_dependent
 Cache whether or not this function is actually time-dependent. More...
 

Private Attributes

const Parallel::Communicator_comm
 
const unsigned int _num_nearest_pts
 
const unsigned int _power
 
const Real _background_value
 
const Real _background_eff_dist
 
std::unique_ptr< InverseDistanceInterpolation< 3 > > _auto_area_mfi
 

Detailed Description

Definition at line 45 of file triangulator_interface.h.

Constructor & Destructor Documentation

◆ AutoAreaFunction() [1/3]

libMesh::AutoAreaFunction::AutoAreaFunction ( const Parallel::Communicator comm,
const unsigned int  num_nearest_pts,
const unsigned int  power,
const Real  background_value,
const Real  background_eff_dist 
)

Definition at line 49 of file triangulator_interface.C.

References libMesh::FunctionBase< Real >::_initialized, and libMesh::FunctionBase< Real >::_is_time_dependent.

53  :
54  _comm(comm),
55  _num_nearest_pts(num_nearest_pts),
56  _power(power),
57  _background_value(background_value),
58  _background_eff_dist(background_eff_dist),
60 {
61  this->_initialized = false;
62  this->_is_time_dependent = false;
63 }
const Parallel::Communicator & _comm
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
std::unique_ptr< InverseDistanceInterpolation< 3 > > _auto_area_mfi
bool _is_time_dependent
Cache whether or not this function is actually time-dependent.
const unsigned int _num_nearest_pts
template class LIBMESH_EXPORT InverseDistanceInterpolation< 3 >

◆ AutoAreaFunction() [2/3]

libMesh::AutoAreaFunction::AutoAreaFunction ( const AutoAreaFunction )

◆ AutoAreaFunction() [3/3]

libMesh::AutoAreaFunction::AutoAreaFunction ( AutoAreaFunction &&  )
delete

◆ ~AutoAreaFunction()

libMesh::AutoAreaFunction::~AutoAreaFunction ( )
virtualdefault

Member Function Documentation

◆ clear()

virtual void libMesh::FunctionBase< Real >::clear ( )
inlinevirtualinherited

Clears the function.

Definition at line 92 of file function_base.h.

92 {}

◆ clone()

virtual std::unique_ptr<FunctionBase<Real> > libMesh::AutoAreaFunction::clone ( ) const
inlineoverridevirtual
Returns
A new copy of the function.

The new copy should be as "deep" as necessary to allow independent destruction and simultaneous evaluations of the copies in different threads.

Implements libMesh::FunctionBase< Real >.

Definition at line 76 of file triangulator_interface.h.

References _background_eff_dist, _background_value, _comm, _num_nearest_pts, and _power.

77  {
78  return std::make_unique<AutoAreaFunction>(_comm, _num_nearest_pts, _power, _background_value, _background_eff_dist);
79  }
const Parallel::Communicator & _comm
const unsigned int _num_nearest_pts

◆ component()

Real libMesh::FunctionBase< Real >::component ( unsigned int  i,
const Point p,
Real  time = 0. 
)
inlinevirtualinherited
Returns
The vector component i at coordinate p and time time.
Note
Subclasses aren't required to override this, since the default implementation is based on the full vector evaluation, which is often correct.
Subclasses are recommended to override this, since the default implementation is based on a vector evaluation, which is usually unnecessarily inefficient.
The default implementation calls operator() with a DenseVector of size i+1 which will result in unexpected behaviour if operator() makes any access beyond that limit.

Definition at line 232 of file function_base.h.

235 {
236  DenseVector<Output> outvec(i+1);
237  (*this)(p, time, outvec);
238  return outvec(i);
239 }

◆ init()

virtual void libMesh::FunctionBase< Real >::init ( )
inlinevirtualinherited

The actual initialization process.

Definition at line 87 of file function_base.h.

87 {}

◆ init_mfi()

void libMesh::AutoAreaFunction::init_mfi ( const std::vector< Point > &  input_pts,
const std::vector< Real > &  input_vals 
)

Definition at line 68 of file triangulator_interface.C.

References _auto_area_mfi, and libMesh::FunctionBase< Real >::_initialized.

70 {
71  std::vector<std::string> field_vars{"f"};
72  _auto_area_mfi->set_field_variables(field_vars);
73  _auto_area_mfi->get_source_points() = input_pts;
74 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
75  std::vector<Number> input_complex_vals;
76  for (const auto & input_val : input_vals)
77  input_complex_vals.push_back(Complex (input_val, 0.0));
78  _auto_area_mfi->get_source_vals() = input_complex_vals;
79 #else
80  _auto_area_mfi->get_source_vals() = input_vals;
81 #endif
82  _auto_area_mfi->prepare_for_use();
83  this->_initialized = true;
84 }
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
std::unique_ptr< InverseDistanceInterpolation< 3 > > _auto_area_mfi
std::complex< Real > Complex

◆ initialized()

bool libMesh::FunctionBase< Real >::initialized ( ) const
inlineinherited
Returns
true when this object is properly initialized and ready for use, false otherwise.

Definition at line 210 of file function_base.h.

211 {
212  return (this->_initialized);
213 }
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...

◆ is_time_dependent()

bool libMesh::FunctionBase< Real >::is_time_dependent ( ) const
inlineinherited
Returns
true when the function this object represents is actually time-dependent, false otherwise.

Definition at line 224 of file function_base.h.

225 {
226  return (this->_is_time_dependent);
227 }
bool _is_time_dependent
Cache whether or not this function is actually time-dependent.

◆ operator()() [1/3]

Real libMesh::AutoAreaFunction::operator() ( const Point p,
const Real  time 
)
overridevirtual
Returns
The scalar function value at coordinate p and time time, which defaults to zero.

Pure virtual, so you have to override it.

Implements libMesh::FunctionBase< Real >.

Definition at line 86 of file triangulator_interface.C.

References _auto_area_mfi, libMesh::FunctionBase< Real >::_initialized, libMesh::libmesh_assert(), and libMesh::libmesh_real().

88 {
90 
91  std::vector<Point> target_pts;
92  std::vector<Number> target_vals;
93 
94  target_pts.push_back(p);
95  target_vals.resize(1);
96 
97  _auto_area_mfi->interpolate_field_data(_auto_area_mfi->field_variables(), target_pts, target_vals);
98 
99  return libmesh_real(target_vals.front());
100 }
T libmesh_real(T a)
bool _initialized
When init() was called so that everything is ready for calls to operator() (...), then this bool is t...
libmesh_assert(ctx)
std::unique_ptr< InverseDistanceInterpolation< 3 > > _auto_area_mfi

◆ operator()() [2/3]

virtual void libMesh::AutoAreaFunction::operator() ( const Point p,
const Real  time,
DenseVector< Real > &  output 
)
inlineoverridevirtual

Evaluation function for time-dependent vector-valued functions.

Sets output values in the passed-in output DenseVector.

Pure virtual, so you have to override it.

Implements libMesh::FunctionBase< Real >.

Definition at line 67 of file triangulator_interface.h.

References libMesh::DenseVector< T >::resize().

70  {
71  output.resize(1);
72  output(0) = (*this)(p,time);
73  return;
74  }

◆ operator()() [3/3]

void libMesh::FunctionBase< Real >::operator() ( const Point p,
DenseVector< Real > &  output 
)
inlineinherited

Evaluation function for time-independent vector-valued functions.

Sets output values in the passed-in output DenseVector.

Definition at line 245 of file function_base.h.

247 {
248  // Call the time-dependent function with t=0.
249  this->operator()(p, 0., output);
250 }
virtual Real operator()(const Point &p, const Real time=0.)=0

◆ operator=() [1/2]

AutoAreaFunction& libMesh::AutoAreaFunction::operator= ( const AutoAreaFunction )

◆ operator=() [2/2]

AutoAreaFunction& libMesh::AutoAreaFunction::operator= ( AutoAreaFunction &&  )
delete

◆ set_is_time_dependent()

void libMesh::FunctionBase< Real >::set_is_time_dependent ( bool  is_time_dependent)
inlineinherited

Function to set whether this is a time-dependent function or not.

This is intended to be only used by subclasses who cannot natively determine time-dependence. In such a case, this function should be used immediately following construction.

Definition at line 217 of file function_base.h.

218 {
220 }
bool _is_time_dependent
Cache whether or not this function is actually time-dependent.

Member Data Documentation

◆ _auto_area_mfi

std::unique_ptr<InverseDistanceInterpolation<3> > libMesh::AutoAreaFunction::_auto_area_mfi
private

Definition at line 87 of file triangulator_interface.h.

Referenced by init_mfi(), and operator()().

◆ _background_eff_dist

const Real libMesh::AutoAreaFunction::_background_eff_dist
private

Definition at line 86 of file triangulator_interface.h.

Referenced by clone().

◆ _background_value

const Real libMesh::AutoAreaFunction::_background_value
private

Definition at line 85 of file triangulator_interface.h.

Referenced by clone().

◆ _comm

const Parallel::Communicator& libMesh::AutoAreaFunction::_comm
private

Definition at line 82 of file triangulator_interface.h.

Referenced by clone().

◆ _initialized

bool libMesh::FunctionBase< Real >::_initialized
protectedinherited

When init() was called so that everything is ready for calls to operator() (...), then this bool is true.

Definition at line 184 of file function_base.h.

Referenced by AutoAreaFunction(), init_mfi(), and operator()().

◆ _is_time_dependent

bool libMesh::FunctionBase< Real >::_is_time_dependent
protectedinherited

Cache whether or not this function is actually time-dependent.

Definition at line 189 of file function_base.h.

Referenced by AutoAreaFunction().

◆ _master

const FunctionBase* libMesh::FunctionBase< Real >::_master
protectedinherited

Const pointer to our master, initialized to nullptr.

There may be cases where multiple functions are required, but to save memory, one master handles some centralized data.

Definition at line 178 of file function_base.h.

◆ _num_nearest_pts

const unsigned int libMesh::AutoAreaFunction::_num_nearest_pts
private

Definition at line 83 of file triangulator_interface.h.

Referenced by clone().

◆ _power

const unsigned int libMesh::AutoAreaFunction::_power
private

Definition at line 84 of file triangulator_interface.h.

Referenced by clone().


The documentation for this class was generated from the following files: