https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
35void
37{
38 const auto nval = _values.size();
39 if (nval == 0)
40 paramError("value_name", "Value vector must not be empty.");
41
42 // resize these incase the values reporters changed size
43 // this will only change data constructed to reference these
44 _ones_vec.resize(nval, 1.0);
45 _zeros_vec.resize(nval, 0.0);
46 _zeros_pts.resize(nval, Point());
47
48 errorCheck("x_coord_name", _coordx.size());
49 errorCheck("y_coord_name", _coordy.size());
50 errorCheck("z_coord_name", _coordz.size());
51 errorCheck("weight_name", _weight.size());
52 errorCheck("point_name", _point.size());
53 errorCheck("time_name", _coordt.size());
54
55 const Real at =
56 MooseUtils::absoluteFuzzyEqual(_reverse_time_end, 0.0) ? _t : _reverse_time_end - _t + _dt;
57 for (const auto & i : make_range(nval))
58 {
59 if (_coordt.empty() || MooseUtils::absoluteFuzzyEqual(at, _coordt[i]))
60 {
62 addPoint(_point[i], i, _values[i] * _weight[i]);
63 else
64 {
65 const Point point = Point(_coordx[i], _coordy[i], _coordz[i]);
66 addPoint(point, i, _values[i] * _weight[i]);
67 }
68 }
69 }
70}
registerMooseObject("OptimizationApp", ReporterTimePointSource)
void addPoint(const Elem *elem, Point p, unsigned id=libMesh::invalid_uint, Real value=1.0)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
const std::vector< Point > & _point
const std::vector< Real > & _coordx
static InputParameters validParams()
std::vector< Real > _ones_vec
const std::vector< Real > & _coordz
const std::vector< Real > & _values
void errorCheck(const std::string &input_name, std::size_t reporterSize)
const std::vector< Real > & _coordy
const bool _read_in_points
const std::vector< Real > & _weight
std::vector< Point > _zeros_pts
std::vector< Real > _zeros_vec
Apply a time dependent point load defined by Reporters.
static InputParameters validParams()
const std::vector< Real > & _coordt
time-coordinates from reporter
ReporterTimePointSource(const InputParameters &parameters)
const Real & _reverse_time_end
The final time when we want to reverse the time index in function evaluation.
virtual void addPoints() override