20 params.
addClassDescription(
"Optimization function with parameters represented by a mesh and " 21 "finite-element shape functions.");
23 params.
addRequiredParam<FileName>(
"exodus_mesh",
"File containing parameter mesh.");
26 "Family of FE shape functions for parameter.");
29 "Order of FE shape functions for parameter.");
32 "parameter_name",
"Reporter or VectorPostprocessor vector containing parameter values.");
34 "Name of vector-postprocessor or reporter vector containing time, " 35 "default assumes time independence.");
37 "project_points",
false,
"Whether to find the closest point on parameter mesh.");
41 "Number of nearest node candidates to consider when projecting points to parameter mesh.");
50 getParam<FileName>(
"exodus_mesh"),
52 getParam<bool>(
"project_points"),
53 getParam<unsigned int>(
"kdtree_candidates")),
54 _values(getReporterValue<std::vector<Real>>(
"parameter_name")),
55 _coordt(isParamValid(
"time_name") ? getReporterValue<std::vector<Real>>(
"time_name")
69 std::vector<dof_id_type> dof_indices;
70 std::vector<Real> weights;
76 val += (
_values[dof_indices[i] + offset0] * ti[0].second +
77 _values[dof_indices[i] + offset1] * ti[1].second) *
91 std::vector<dof_id_type> dof_indices;
92 std::vector<RealGradient> weights;
97 val += (
_values[dof_indices[i] + offset0] * ti[0].second +
98 _values[dof_indices[i] + offset1] * ti[1].second) *
109 if (ti[0].first == ti[1].first)
114 std::vector<dof_id_type> dof_indices;
115 std::vector<Real> weights;
120 val += (
_values[dof_indices[i] + offset0] * ti[0].second +
121 _values[dof_indices[i] + offset1] * ti[1].second) *
133 std::vector<dof_id_type> dof_indices;
134 std::vector<Real> weights;
140 std::vector<Real> pg(sz, 0.0);
143 pg[dof_indices[i] + offset0] += weights[i] * ti[0].second;
144 pg[dof_indices[i] + offset1] += weights[i] * ti[1].second;
149 std::array<std::pair<std::size_t, Real>, 2>
152 std::array<std::pair<std::size_t, Real>, 2> ti;
160 ti[0] = {
_coordt.size() - 1, 0.5};
161 ti[1] = {
_coordt.size() - 1, 0.5};
164 for (std::size_t i = 1; i <
_coordt.size(); ++i)
170 ti[0] = {i - 1, -1.0 / dt};
171 ti[1] = {i, 1.0 / dt};
175 ti[0] = {i - 1, (
_coordt[i] - t) / dt};
176 ti[1] = {i, (t -
_coordt[i - 1]) / dt};
192 "Size of parameter vector (",
194 ") does not match number of degrees of freedom in mesh (",
std::array< std::pair< std::size_t, Real >, 2 > interpolateTime(Real t, bool derivative=false) const
This function is used to compute the weights for time interpolation.
registerMooseObject("OptimizationApp", ParameterMeshFunction)
const std::vector< Real > & _values
values from reporter
ParameterMeshFunction(const InputParameters ¶meters)
const ParameterMesh _parameter_mesh
Parameter mesh.
virtual RealGradient gradient(Real t, const Point &p) const override
static MooseEnum getNonlinearVariableFamilies()
static MooseEnum getNonlinearVariableOrders()
virtual Real timeDerivative(Real t, const Point &p) const override
void checkSize() const
Used to make sure DoFs in '_parameter_mesh' matches number of values in '_values'.
void paramError(const std::string ¶m, Args... args) const
const std::vector< Real > & _coordt
Time coordinates from reporter.
virtual std::vector< Real > parameterGradient(Real t, const Point &p) const override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Base class for functions used in inverse optimization The parameterDerivative function is used in adj...
bool absoluteFuzzyLessEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
static InputParameters validParams()
bool absoluteFuzzyGreaterEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
static InputParameters validParams()
void getIndexAndWeight(const Point &pt, std::vector< dof_id_type > &dof_indices, std::vector< Real > &weights) const
Interpolate parameters onto the computational mesh getIndexAndWeight is only used by ParameterMeshFun...
auto index_range(const T &sizable)
virtual Real value(Real t, const Point &p) const override