https://mooseframework.inl.gov
ReporterTimePointSource.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include "MooseUtils.h"
12 
14 
17 {
19  params.addClassDescription("Apply a time dependent point load defined by Reporters.");
20  params.addParam<ReporterName>("time_name",
21  "Name of vector-postprocessor or reporter vector containing time, "
22  "default is assumed to be all 0s.");
23  params.addParam<Real>("reverse_time_end", 0.0, "End time used for reversing the time values.");
24  return params;
25 }
26 
28  : ReporterPointSource(parameters),
29  _coordt(isParamValid("time_name") ? getReporterValue<std::vector<Real>>("time_name")
30  : _zeros_vec),
31  _reverse_time_end(getParam<Real>("reverse_time_end"))
32 {
33 }
34 
35 void
37 {
38  // Do some size checks
39  const auto nval = _values.size();
40  if (nval == 0)
41  paramError("value_name", "Value vector must not be empty.");
42 
43  // resize these incase the values reporters changed size
44  // this will only change data constructed to reference these
45  _ones_vec.resize(nval, 1.0);
46  _zeros_vec.resize(nval, 0.0);
47  _zeros_pts.resize(nval, Point());
48 
49  errorCheck("x_coord_name", _coordx.size());
50  errorCheck("y_coord_name", _coordy.size());
51  errorCheck("z_coord_name", _coordz.size());
52  errorCheck("weight_name", _weight.size());
53  errorCheck("point_name", _point.size());
54  errorCheck("time_name", _coordt.size());
55 
57  const Real at =
59  for (const auto & i : make_range(nval))
60  {
61  if (_coordt.empty() || MooseUtils::absoluteFuzzyEqual(at, _coordt[i]))
62  {
63  if (_read_in_points)
64  {
65  fillPoint(_point[i], i);
66  }
67  else
68  {
69  const Point point = Point(_coordx[i], _coordy[i], _coordz[i]);
70  fillPoint(point, i);
71  }
72  }
73  }
74 }
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
virtual void addPoints() override
const std::vector< Point > & _point
std::unordered_map< Point, Real > _point_to_weightedValue
const Real & _reverse_time_end
The final time when we want to reverse the time index in function evaluation.
const std::vector< Real > & _coordx
std::vector< Real > _ones_vec
std::vector< Point > _zeros_pts
void paramError(const std::string &param, Args... args) const
std::vector< Real > _zeros_vec
void errorCheck(const std::string &input_name, std::size_t reporterSize)
Apply a time dependent point load defined by Reporters.
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::vector< Real > & _coordy
IntRange< T > make_range(T beg, T end)
const bool _read_in_points
const std::vector< Real > & _values
void addClassDescription(const std::string &doc_string)
const std::vector< Real > & _coordt
time-coordinates from reporter
void fillPoint(const Point &point, const dof_id_type id)
ReporterTimePointSource(const InputParameters &parameters)
const std::vector< Real > & _weight
registerMooseObject("OptimizationApp", ReporterTimePointSource)
const std::vector< Real > & _coordz