https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
NearestReporterCoordinatesFunction Class Referenceabstract

Function based on the nearest point to coordinates and values defined by a vector of values, interpolates linearly in time with transient data. More...

#include <NearestReporterCoordinatesFunction.h>

Inheritance diagram for NearestReporterCoordinatesFunction:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 
typedef FunctorBase< RealFunctorType
 
typedef Real ValueType
 
typedef typename FunctorReturnType< Real, FunctorEvaluationKind::Gradient >::type GradientType
 
typedef ValueType DotType
 

Public Member Functions

 NearestReporterCoordinatesFunction (const InputParameters &parameters)
 
virtual Real value (Real t, const Point &p) const override
 
virtual RealGradient gradient (Real t, const Point &p) const override
 
virtual Real timeDerivative (Real t, const Point &p) const override
 
virtual std::vector< RealparameterGradient (Real t, const Point &p) const override
 
virtual Real value (Real t, const Point &p) const
 
virtual ADReal value (const ADReal &t, const ADPoint &p) const
 
ChainedReal value (const ChainedReal &t) const
 
auto value (const U &t) const
 
auto value (const U &t, const U &x, const U &y=0, const U &z=0) const
 
ChainedReal value (const ChainedReal &t) const
 
auto value (const U &t) const
 
auto value (const U &t, const U &x, const U &y=0, const U &z=0) const
 
virtual ADReal value (const ADReal &t, const ADPoint &p) const
 
ChainedReal value (const ChainedReal &t) const
 
auto value (const U &t) const
 
auto value (const U &t, const U &x, const U &y=0, const U &z=0) const
 
virtual RealVectorValue vectorValue (Real t, const Point &p) const
 
virtual RealVectorValue curl (Real t, const Point &p) const
 
virtual Real div (Real t, const Point &p) const
 
GradientType gradient (const ElemArg &elem, const StateArg &state) const
 
GradientType gradient (const FaceArg &face, const StateArg &state) const
 
GradientType gradient (const ElemQpArg &qp, const StateArg &state) const
 
GradientType gradient (const ElemSideQpArg &qp, const StateArg &state) const
 
GradientType gradient (const ElemPointArg &elem_point, const StateArg &state) const
 
GradientType gradient (const NodeArg &node, const StateArg &state) const
 
GradientType gradient (const ElemArg &elem, const StateArg &state) const
 
GradientType gradient (const FaceArg &face, const StateArg &state) const
 
GradientType gradient (const ElemQpArg &qp, const StateArg &state) const
 
GradientType gradient (const ElemSideQpArg &qp, const StateArg &state) const
 
GradientType gradient (const ElemPointArg &elem_point, const StateArg &state) const
 
GradientType gradient (const NodeArg &node, const StateArg &state) const
 
auto timeDerivative (const U &t) const
 
auto timeDerivative (const U &t, const U &x, const U &y=0, const U &z=0) const
 
virtual Real integral () const
 
virtual Real average () const
 
virtual Real timeIntegral (Real t1, Real t2, const Point &p) const
 
void timestepSetup () override
 
void residualSetup () override final
 
void jacobianSetup () override final
 
void customSetup (const ExecFlagType &exec_type) override final
 
bool hasBlocks (SubdomainID) const override
 
bool supportsFaceArg () const override final
 
bool supportsElemSideQpArg () const override final
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
virtual void initialSetup ()
 
virtual void subdomainSetup ()
 
const ExecFlagEnumgetExecuteOnEnum () const
 
bool isImplicit ()
 
Moose::StateArg determineState () const
 
bool isDefaultPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessor (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessorByName (const PostprocessorName &name) const
 
std::size_t coupledPostprocessors (const std::string &param_name) const
 
const PostprocessorName & getPostprocessorName (const std::string &param_name, const unsigned int index=0) const
 
UserObjectName getUserObjectName (const std::string &param_name) const
 
const T & getUserObject (const std::string &param_name, bool is_dependency=true) const
 
const T & getUserObjectByName (const UserObjectName &object_name, bool is_dependency=true) const
 
const UserObjectgetUserObjectBase (const std::string &param_name, bool is_dependency=true) const
 
const UserObjectgetUserObjectBaseByName (const UserObjectName &object_name, bool is_dependency=true) const
 
virtual void meshChanged ()
 
const std::vector< MooseVariableScalar *> & getCoupledMooseScalarVars ()
 
const std::set< TagID > & getScalarVariableCoupleableVectorTags () const
 
const std::set< TagID > & getScalarVariableCoupleableMatrixTags () const
 
FunctorReturnType< Real, FET >::type genericEvaluate (const Space &r, const State &state) const
 
const MooseFunctorName & functorName () const
 
void setCacheClearanceSchedule (const std::set< ExecFlagType > &clearance_schedule)
 
virtual bool isExtrapolatedBoundaryFace (const FaceInfo &, const Elem *, const StateArg &) const
 
bool isInternalFace (const FaceInfo &) const
 
virtual bool isConstant () const
 
virtual bool hasFaceSide (const FaceInfo &fi, const bool fi_elem_side) const override
 
void checkFace (const Moose::FaceArg &face) const
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
ValueType operator() (const ElemArg &elem, const StateArg &state) const
 
ValueType operator() (const FaceArg &face, const StateArg &state) const
 
ValueType operator() (const ElemQpArg &qp, const StateArg &state) const
 
ValueType operator() (const ElemSideQpArg &qp, const StateArg &state) const
 
ValueType operator() (const ElemPointArg &elem_point, const StateArg &state) const
 
ValueType operator() (const NodeArg &node, const StateArg &state) const
 
ValueType operator() (const ElemArg &elem, const StateArg &state) const
 
ValueType operator() (const FaceArg &face, const StateArg &state) const
 
ValueType operator() (const ElemQpArg &qp, const StateArg &state) const
 
ValueType operator() (const ElemSideQpArg &qp, const StateArg &state) const
 
ValueType operator() (const ElemPointArg &elem_point, const StateArg &state) const
 
ValueType operator() (const NodeArg &node, const StateArg &state) const
 
ValueType operator() (const ElemArg &elem, const StateArg &state) const
 
ValueType operator() (const FaceArg &face, const StateArg &state) const
 
ValueType operator() (const ElemQpArg &qp, const StateArg &state) const
 
ValueType operator() (const ElemSideQpArg &qp, const StateArg &state) const
 
ValueType operator() (const ElemPointArg &elem_point, const StateArg &state) const
 
ValueType operator() (const NodeArg &node, const StateArg &state) const
 
DotType dot (const ElemArg &elem, const StateArg &state) const
 
DotType dot (const FaceArg &face, const StateArg &state) const
 
DotType dot (const ElemQpArg &qp, const StateArg &state) const
 
DotType dot (const ElemSideQpArg &qp, const StateArg &state) const
 
DotType dot (const ElemPointArg &elem_point, const StateArg &state) const
 
DotType dot (const NodeArg &node, const StateArg &state) const
 
DotType dot (const ElemArg &elem, const StateArg &state) const
 
DotType dot (const FaceArg &face, const StateArg &state) const
 
DotType dot (const ElemQpArg &qp, const StateArg &state) const
 
DotType dot (const ElemSideQpArg &qp, const StateArg &state) const
 
DotType dot (const ElemPointArg &elem_point, const StateArg &state) const
 
DotType dot (const NodeArg &node, const StateArg &state) const
 
DotType dot (const ElemArg &elem, const StateArg &state) const
 
DotType dot (const FaceArg &face, const StateArg &state) const
 
DotType dot (const ElemQpArg &qp, const StateArg &state) const
 
DotType dot (const ElemSideQpArg &qp, const StateArg &state) const
 
DotType dot (const ElemPointArg &elem_point, const StateArg &state) const
 
DotType dot (const NodeArg &node, const StateArg &state) const
 
GradientType gradDot (const ElemArg &elem, const StateArg &state) const
 
GradientType gradDot (const FaceArg &face, const StateArg &state) const
 
GradientType gradDot (const ElemQpArg &qp, const StateArg &state) const
 
GradientType gradDot (const ElemSideQpArg &qp, const StateArg &state) const
 
GradientType gradDot (const ElemPointArg &elem_point, const StateArg &state) const
 
GradientType gradDot (const NodeArg &node, const StateArg &state) const
 
GradientType gradDot (const ElemArg &elem, const StateArg &state) const
 
GradientType gradDot (const FaceArg &face, const StateArg &state) const
 
GradientType gradDot (const ElemQpArg &qp, const StateArg &state) const
 
GradientType gradDot (const ElemSideQpArg &qp, const StateArg &state) const
 
GradientType gradDot (const ElemPointArg &elem_point, const StateArg &state) const
 
GradientType gradDot (const NodeArg &node, const StateArg &state) const
 
GradientType gradDot (const ElemArg &elem, const StateArg &state) const
 
GradientType gradDot (const FaceArg &face, const StateArg &state) const
 
GradientType gradDot (const ElemQpArg &qp, const StateArg &state) const
 
GradientType gradDot (const ElemSideQpArg &qp, const StateArg &state) const
 
GradientType gradDot (const ElemPointArg &elem_point, const StateArg &state) const
 
GradientType gradDot (const NodeArg &node, const StateArg &state) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 

Public Attributes

const ConsoleStream _console
 

Protected Member Functions

void buildCoordinateMapping () const
 Builds _coord_mapping object with coordinates from input vectors. More...
 
std::array< std::pair< Real, std::size_t >, 2 > findNearestPoint (Real t, const Point &p) const
 With an input time and point, gets the closest point and two closest times in _coord_mapping. More...
 
virtual void addPostprocessorDependencyHelper (const PostprocessorName &) const
 
virtual void addUserObjectDependencyHelper (const UserObject &) const
 
T & declareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< T > declareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const T & getRestartableData (const std::string &data_name) const
 
T & declareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
T & declareRecoverableData (const std::string &data_name, Args &&... args)
 
T & declareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
T & declareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 
bool isCoupledScalar (const std::string &var_name, unsigned int i=0) const
 
unsigned int coupledScalarComponents (const std::string &var_name) const
 
unsigned int coupledScalar (const std::string &var_name, unsigned int comp=0) const
 
libMesh::Order coupledScalarOrder (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarValue (const std::string &var_name, unsigned int comp=0) const
 
const ADVariableValueadCoupledScalarValue (const std::string &var_name, unsigned int comp=0) const
 
const GenericVariableValue< is_ad > & coupledGenericScalarValue (const std::string &var_name, unsigned int comp=0) const
 
const GenericVariableValue< false > & coupledGenericScalarValue (const std::string &var_name, const unsigned int comp) const
 
const GenericVariableValue< true > & coupledGenericScalarValue (const std::string &var_name, const unsigned int comp) const
 
const VariableValuecoupledVectorTagScalarValue (const std::string &var_name, TagID tag, unsigned int comp=0) const
 
const VariableValuecoupledMatrixTagScalarValue (const std::string &var_name, TagID tag, unsigned int comp=0) const
 
const VariableValuecoupledScalarValueOld (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarValueOlder (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDot (const std::string &var_name, unsigned int comp=0) const
 
const ADVariableValueadCoupledScalarDot (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDot (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotOld (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDotOld (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDu (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDotDu (const std::string &var_name, unsigned int comp=0) const
 
const MooseVariableScalargetScalarVar (const std::string &var_name, unsigned int comp) const
 
virtual GradientType evaluateGradDot (const ElemArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const FaceArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemQpArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemSideQpArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemPointArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const NodeArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const FaceArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemQpArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemSideQpArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemPointArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const NodeArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const FaceArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemQpArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemSideQpArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const ElemPointArg &, const StateArg &) const
 
virtual GradientType evaluateGradDot (const NodeArg &, const StateArg &) const
 
virtual ValueType evaluate (const ElemArg &elem, const StateArg &state) const =0
 
virtual ValueType evaluate (const FaceArg &face, const StateArg &state) const =0
 
virtual ValueType evaluate (const ElemQpArg &qp, const StateArg &state) const =0
 
virtual ValueType evaluate (const ElemSideQpArg &side_qp, const StateArg &state) const =0
 
virtual ValueType evaluate (const ElemPointArg &elem_point, const StateArg &state) const =0
 
virtual ValueType evaluate (const NodeArg &node, const StateArg &state) const =0
 
virtual GradientType evaluateGradient (const ElemArg &, const StateArg &) const
 
virtual GradientType evaluateGradient (const FaceArg &, const StateArg &) const
 
virtual GradientType evaluateGradient (const ElemQpArg &, const StateArg &) const
 
virtual GradientType evaluateGradient (const ElemSideQpArg &, const StateArg &) const
 
virtual GradientType evaluateGradient (const ElemPointArg &, const StateArg &) const
 
virtual GradientType evaluateGradient (const NodeArg &, const StateArg &) const
 
virtual DotType evaluateDot (const ElemArg &, const StateArg &) const
 
virtual DotType evaluateDot (const FaceArg &, const StateArg &) const
 
virtual DotType evaluateDot (const ElemQpArg &, const StateArg &) const
 
virtual DotType evaluateDot (const ElemSideQpArg &, const StateArg &) const
 
virtual DotType evaluateDot (const ElemPointArg &, const StateArg &) const
 
virtual DotType evaluateDot (const NodeArg &, const StateArg &) const
 
const ReporterNamegetReporterName (const std::string &param_name) const
 
virtual void addReporterDependencyHelper (const ReporterName &)
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 

Protected Attributes

const std::vector< Real > & _coordx
 x-coordinates from reporter More...
 
const std::vector< Real > & _coordy
 y-coordinates from reporter More...
 
const std::vector< Real > & _coordz
 z-coordinates from reporter More...
 
const std::vector< Real > & _coordt
 time-coordinates from reporter More...
 
const std::vector< Real > & _values
 values from reporter More...
 
std::size_t _nval
 Number of values from coordinate vectors. More...
 
std::map< Point, std::vector< std::pair< Real, std::size_t > > > _coord_mapping
 Data structure for all current data. More...
 
const bool & _enabled
 
MooseApp_app
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
const ExecFlagEnum_execute_enum
 
const ExecFlagType_current_execute_flag
 
const InputParameters_ti_params
 
FEProblemBase_ti_feproblem
 
bool _is_implicit
 
Real_t
 
const Real_t_old
 
int_t_step
 
Real_dt
 
Real_dt_old
 
bool _is_transient
 
MooseApp_restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 
FEProblemBase_mci_feproblem
 
FEProblemBase_sc_fe_problem
 
const THREAD_ID _sc_tid
 
const Real_real_zero
 
const VariableValue_scalar_zero
 
const Point & _point_zero
 
const Parallel::Communicator & _communicator
 

Private Attributes

const std::vector< Real_empty_vec = {}
 

Detailed Description

Function based on the nearest point to coordinates and values defined by a vector of values, interpolates linearly in time with transient data.

Definition at line 18 of file NearestReporterCoordinatesFunction.h.

Constructor & Destructor Documentation

◆ NearestReporterCoordinatesFunction()

NearestReporterCoordinatesFunction::NearestReporterCoordinatesFunction ( const InputParameters parameters)

Definition at line 40 of file NearestReporterCoordinatesFunction.C.

43  ReporterInterface(this),
44  _coordx(isParamValid("x_coord_name") ? getReporterValue<std::vector<Real>>("x_coord_name")
45  : _empty_vec),
46  _coordy(isParamValid("y_coord_name") ? getReporterValue<std::vector<Real>>("y_coord_name")
47  : _empty_vec),
48  _coordz(isParamValid("z_coord_name") ? getReporterValue<std::vector<Real>>("z_coord_name")
49  : _empty_vec),
50  _coordt(isParamValid("time_name") ? getReporterValue<std::vector<Real>>("time_name")
51  : _empty_vec),
52  _values(getReporterValue<std::vector<Real>>("value_name"))
53 {
54 }
const std::vector< Real > & _coordy
y-coordinates from reporter
const std::vector< Real > & _coordt
time-coordinates from reporter
const std::vector< Real > & _coordx
x-coordinates from reporter
bool isParamValid(const std::string &name) const
const T & getReporterValue(const std::string &param_name, const std::size_t time_index=0)
const std::vector< Real > & _values
values from reporter
ReporterInterface(const MooseObject *moose_object)
OptimizationFunction(const InputParameters &parameters)
const std::vector< Real > & _coordz
z-coordinates from reporter
const InputParameters & parameters() const

Member Function Documentation

◆ buildCoordinateMapping()

void NearestReporterCoordinatesFunction::buildCoordinateMapping ( ) const
protected

Builds _coord_mapping object with coordinates from input vectors.

Definition at line 114 of file NearestReporterCoordinatesFunction.C.

Referenced by findNearestPoint().

115 {
116  // Do some size checks
117  _nval = std::max({_coordx.size(), _coordy.size(), _coordz.size(), _coordt.size()});
118  if (_nval == 0)
119  paramError("value", "At least one coordinate vector must not be empty.");
120  else if (!_coordx.empty() && _coordx.size() != _nval)
121  paramError("x_coord_name",
122  "Number of x coordinates (",
123  _coordx.size(),
124  ") does not match number of values (",
125  _nval,
126  ").");
127  else if (!_coordy.empty() && _coordy.size() != _nval)
128  paramError("y_coord_name",
129  "Number of y coordinates (",
130  _coordy.size(),
131  ") does not match number of values (",
132  _nval,
133  ").");
134  else if (!_coordz.empty() && _coordz.size() != _nval)
135  paramError("z_coord_name",
136  "Number of z coordinates (",
137  _coordz.size(),
138  ") does not match number of values (",
139  _nval,
140  ").");
141  else if (!_coordt.empty() && _coordt.size() != _nval)
142  paramError("time_name",
143  "Number of times (",
144  _coordt.size(),
145  ") does not match number of values (",
146  _nval,
147  ").");
148 
149  // Find times for each unique coordinate
150  _coord_mapping.clear();
151  for (const auto & i : make_range(_nval))
152  {
153  Point pt;
154  pt(0) = _coordx.empty() ? 0.0 : _coordx[i];
155  pt(1) = _coordy.empty() ? 0.0 : _coordy[i];
156  pt(2) = _coordz.empty() ? 0.0 : _coordz[i];
157  const Real time = _coordt.empty() ? 0.0 : _coordt[i];
158 
159  std::vector<std::pair<Real, std::size_t>> * vec = nullptr;
160  for (auto & it : _coord_mapping)
161  if (pt.absolute_fuzzy_equals(it.first))
162  {
163  vec = &it.second;
164  break;
165  }
166  if (!vec)
167  vec = &_coord_mapping[pt];
168 
169  vec->emplace_back(time, i);
170  std::sort(vec->begin(),
171  vec->end(),
172  [](const std::pair<Real, Real> & a, const std::pair<Real, Real> & b)
173  { return a.first < b.first; });
174  }
175 }
const std::vector< Real > & _coordy
y-coordinates from reporter
const std::vector< Real > & _coordt
time-coordinates from reporter
const std::vector< Real > & _coordx
x-coordinates from reporter
std::size_t _nval
Number of values from coordinate vectors.
void paramError(const std::string &param, Args... args) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::vector< Real > & _coordz
z-coordinates from reporter
IntRange< T > make_range(T beg, T end)
std::map< Point, std::vector< std::pair< Real, std::size_t > > > _coord_mapping
Data structure for all current data.

◆ findNearestPoint()

std::array< std::pair< Real, std::size_t >, 2 > NearestReporterCoordinatesFunction::findNearestPoint ( Real  t,
const Point &  p 
) const
protected

With an input time and point, gets the closest point and two closest times in _coord_mapping.

See value on how the return value is used.

Parameters
tRequested time to interpolate
pRequrested point to find the closest one in the supplied data
Returns
Two pairs indicating the two closest time points and the corresponding index in _values. The pairs will be equal if
Parameters
tis less than the smallest value or greater than the largest value in _coord_mapping for the found nearest point.

Definition at line 178 of file NearestReporterCoordinatesFunction.C.

Referenced by parameterGradient(), timeDerivative(), and value().

179 {
180  if (_coord_mapping.empty())
182 
183  // Make sure values is correct size
184  if (_values.size() != _nval)
185  paramError("value_name",
186  "Size of value vector (",
187  _values.size(),
188  ") does not match number of coordinates specified (",
189  _nval,
190  ").");
191 
192  const auto & tval =
193  std::min_element(_coord_mapping.begin(),
194  _coord_mapping.end(),
195  [&p](const std::pair<Point, std::vector<std::pair<Real, std::size_t>>> & p1,
196  const std::pair<Point, std::vector<std::pair<Real, std::size_t>>> & p2)
197  { return (p - p1.first).norm_sq() < (p - p2.first).norm_sq(); })
198  ->second;
199 
200  if (tval.size() == 1 || MooseUtils::absoluteFuzzyLessEqual(t, tval[0].first))
201  return {tval[0], tval[0]};
202  else if (MooseUtils::absoluteFuzzyGreaterEqual(t, tval.back().first))
203  return {tval.back(), tval.back()};
204  else
205  for (std::size_t ti = 1; ti < tval.size(); ++ti)
206  if (MooseUtils::absoluteFuzzyGreaterEqual(tval[ti].first, t))
207  return {tval[ti - 1], tval[ti]};
208 
209  mooseError("Internal error: unable to find nearest point.");
210  return std::array<std::pair<Real, std::size_t>, 2>();
211 }
void buildCoordinateMapping() const
Builds _coord_mapping object with coordinates from input vectors.
const std::vector< Real > & _values
values from reporter
std::size_t _nval
Number of values from coordinate vectors.
void paramError(const std::string &param, Args... args) const
auto norm_sq(const T &a) -> decltype(std::norm(a))
bool absoluteFuzzyLessEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
bool absoluteFuzzyGreaterEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
void mooseError(Args &&... args) const
std::map< Point, std::vector< std::pair< Real, std::size_t > > > _coord_mapping
Data structure for all current data.

◆ gradient()

RealGradient NearestReporterCoordinatesFunction::gradient ( Real  t,
const Point &  p 
) const
overridevirtual

Reimplemented from Function.

Definition at line 75 of file NearestReporterCoordinatesFunction.C.

76 {
77  return RealGradient(0, 0, 0);
78 }

◆ parameterGradient()

std::vector< Real > NearestReporterCoordinatesFunction::parameterGradient ( Real  t,
const Point &  p 
) const
overridevirtual

Implements OptimizationFunction.

Definition at line 96 of file NearestReporterCoordinatesFunction.C.

97 {
98  const std::array<std::pair<Real, std::size_t>, 2> tv = findNearestPoint(t, p);
99  std::vector<Real> param_grad(_nval, 0.0);
100 
101  if (tv[0].second == tv[1].second)
102  param_grad[tv[0].second] = 1;
103  else
104  {
105  const Real told = tv[0].first;
106  const Real tnew = tv[1].first;
107  param_grad[tv[0].second] = (tnew - t) / (tnew - told);
108  param_grad[tv[1].second] = (t - told) / (tnew - told);
109  }
110  return param_grad;
111 }
std::array< std::pair< Real, std::size_t >, 2 > findNearestPoint(Real t, const Point &p) const
With an input time and point, gets the closest point and two closest times in _coord_mapping.
std::size_t _nval
Number of values from coordinate vectors.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ timeDerivative()

Real NearestReporterCoordinatesFunction::timeDerivative ( Real  t,
const Point &  p 
) const
overridevirtual

Reimplemented from Function.

Definition at line 81 of file NearestReporterCoordinatesFunction.C.

82 {
83  const std::array<std::pair<Real, std::size_t>, 2> tv = findNearestPoint(t, p);
84 
85  if (tv[0].second == tv[1].second)
86  return 0.0;
87 
88  const Real told = tv[0].first;
89  const Real tnew = tv[1].first;
90  const Real vold = _values[tv[0].second];
91  const Real vnew = _values[tv[1].second];
92  return (vnew - vold) / (tnew - told);
93 }
std::array< std::pair< Real, std::size_t >, 2 > findNearestPoint(Real t, const Point &p) const
With an input time and point, gets the closest point and two closest times in _coord_mapping.
const std::vector< Real > & _values
values from reporter
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ validParams()

InputParameters NearestReporterCoordinatesFunction::validParams ( )
static

Definition at line 15 of file NearestReporterCoordinatesFunction.C.

16 {
18  params.addClassDescription(
19  "This Function finds the nearest point in the specified vectors of coordinates and returns "
20  "the values specified in the vector of values at the index of the nearest point. All the "
21  "vectors must be specified using either vector postprocessors or reporter vectors. This "
22  "function interpolates linearly in time with transient data.");
23  params.addParam<ReporterName>("x_coord_name",
24  "Name of vector-postprocessor or reporter vector containing "
25  "x-coordinate of points, default is assumed to be all 0s.");
26  params.addParam<ReporterName>("y_coord_name",
27  "Name of vector-postprocessor or reporter vector containing "
28  "y-coordinate of points, default is assumed to be all 0s.");
29  params.addParam<ReporterName>("z_coord_name",
30  "Name of vector-postprocessor or reporter vector containing "
31  "z-coordinate of points, default is assumed to be all 0s.");
32  params.addParam<ReporterName>("time_name",
33  "Name of vector-postprocessor or reporter vector containing time, "
34  "default is assumed to be all 0s.");
36  "value_name", "Name of vector-postprocessor or reporter vector containing value data.");
37  return params;
38 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()

◆ value() [1/9]

virtual Real Function::value

◆ value() [2/9]

auto Function::value

◆ value() [3/9]

virtual ADReal Function::value

◆ value() [4/9]

auto Function::value

◆ value() [5/9]

ChainedReal Function::value

◆ value() [6/9]

ChainedReal Function::value

◆ value() [7/9]

auto Function::value

◆ value() [8/9]

auto Function::value

◆ value() [9/9]

Real NearestReporterCoordinatesFunction::value ( Real  t,
const Point &  p 
) const
overridevirtual

Reimplemented from Function.

Definition at line 57 of file NearestReporterCoordinatesFunction.C.

58 {
59  const std::array<std::pair<Real, std::size_t>, 2> tv = findNearestPoint(t, p);
60 
61  // If the indices are equal then t is either less than the minimum time in the data
62  // or greater than the maximum time. In which case will extrapolate using a constant
63  // value.
64  if (tv[0].second == tv[1].second)
65  return _values[tv[0].second];
66 
67  const Real told = tv[0].first;
68  const Real tnew = tv[1].first;
69  const Real vold = _values[tv[0].second];
70  const Real vnew = _values[tv[1].second];
71  return vold + (vnew - vold) * (t - told) / (tnew - told);
72 }
std::array< std::pair< Real, std::size_t >, 2 > findNearestPoint(Real t, const Point &p) const
With an input time and point, gets the closest point and two closest times in _coord_mapping.
const std::vector< Real > & _values
values from reporter
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

Member Data Documentation

◆ _coord_mapping

std::map<Point, std::vector<std::pair<Real, std::size_t> > > NearestReporterCoordinatesFunction::_coord_mapping
mutableprotected

Data structure for all current data.

Definition at line 63 of file NearestReporterCoordinatesFunction.h.

Referenced by buildCoordinateMapping(), and findNearestPoint().

◆ _coordt

const std::vector<Real>& NearestReporterCoordinatesFunction::_coordt
protected

time-coordinates from reporter

Definition at line 56 of file NearestReporterCoordinatesFunction.h.

Referenced by buildCoordinateMapping().

◆ _coordx

const std::vector<Real>& NearestReporterCoordinatesFunction::_coordx
protected

x-coordinates from reporter

Definition at line 50 of file NearestReporterCoordinatesFunction.h.

Referenced by buildCoordinateMapping().

◆ _coordy

const std::vector<Real>& NearestReporterCoordinatesFunction::_coordy
protected

y-coordinates from reporter

Definition at line 52 of file NearestReporterCoordinatesFunction.h.

Referenced by buildCoordinateMapping().

◆ _coordz

const std::vector<Real>& NearestReporterCoordinatesFunction::_coordz
protected

z-coordinates from reporter

Definition at line 54 of file NearestReporterCoordinatesFunction.h.

Referenced by buildCoordinateMapping().

◆ _empty_vec

const std::vector<Real> NearestReporterCoordinatesFunction::_empty_vec = {}
private

Definition at line 66 of file NearestReporterCoordinatesFunction.h.

◆ _nval

std::size_t NearestReporterCoordinatesFunction::_nval
mutableprotected

Number of values from coordinate vectors.

Definition at line 61 of file NearestReporterCoordinatesFunction.h.

Referenced by buildCoordinateMapping(), findNearestPoint(), and parameterGradient().

◆ _values

const std::vector<Real>& NearestReporterCoordinatesFunction::_values
protected

values from reporter

Definition at line 58 of file NearestReporterCoordinatesFunction.h.

Referenced by findNearestPoint(), timeDerivative(), and value().


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