https://mooseframework.inl.gov
nDRosenbrock.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
10 #include "nDRosenbrock.h"
11 #include "Sampler.h"
12 
13 registerMooseObject("StochasticToolsTestApp", nDRosenbrock);
14 
17 {
19  params.addRequiredParam<SamplerName>(
20  "sampler", "The Sampler object to use to perform g-function evaluations.");
21  params.addParam<bool>("classify", false, "Flag to turn return binary values.");
22  params.addParam<Real>("limiting_value", 0.0, "True if value exceeds limiting value.");
23  return params;
24 }
25 
27  : GeneralVectorPostprocessor(parameters),
28  _sampler(getSampler("sampler")),
29  _classify(getParam<bool>("classify")),
30  _limiting_value(getParam<Real>("limiting_value")),
31  _values(declareVector("g_values"))
32 {
33 }
34 
35 void
37 {
40  {
41  std::vector<Real> x = _sampler.getNextLocalRow();
42  Real y = 0.0;
43  for (std::size_t i = 0; i < x.size() - 1; ++i)
44  y += (100.0 * Utility::pow<2>(x[i + 1] - Utility::pow<2>(x[i])) + Utility::pow<2>(1 - x[i]));
45  if (!_classify)
46  _values.push_back(y);
47  else
48  {
49  if (std::exp(y) > _limiting_value)
50  _values.push_back(1.0);
51  else
52  _values.push_back(0.0);
53  }
54  }
55 }
56 
57 void
59 {
60  if (_parallel_type == "DISTRIBUTED")
62 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const MooseEnum & _parallel_type
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
std::vector< Real > getNextLocalRow()
const Real & _limiting_value
Definition: nDRosenbrock.h:26
dof_id_type getLocalRowBegin() const
const std::vector< double > y
const Parallel::Communicator & _communicator
dof_id_type getNumberOfLocalRows() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
Sampler & _sampler
Definition: nDRosenbrock.h:24
static InputParameters validParams()
const std::vector< double > x
const bool & _classify
Definition: nDRosenbrock.h:25
dof_id_type getLocalRowEnd() const
static InputParameters validParams()
Definition: nDRosenbrock.C:16
VectorPostprocessorValue & _values
Definition: nDRosenbrock.h:27
virtual void execute() override
Definition: nDRosenbrock.C:36
virtual void finalize() override
Definition: nDRosenbrock.C:58
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
registerMooseObject("StochasticToolsTestApp", nDRosenbrock)
nDRosenbrock(const InputParameters &parameters)
Definition: nDRosenbrock.C:26
uint8_t dof_id_type