https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
13registerMooseObject("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
35void
37{
39 for (dof_id_type r = _sampler.getLocalRowBegin(); r < _sampler.getLocalRowEnd(); ++r)
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
57void
59{
60 if (_parallel_type == "DISTRIBUTED")
62}
const std::vector< double > y
const std::vector< double > x
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
std::vector< Real > getNextLocalRow()
dof_id_type getNumberOfLocalRows() const
dof_id_type getLocalRowEnd() const
dof_id_type getLocalRowBegin() const
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
const MooseEnum & _parallel_type
const Parallel::Communicator & _communicator
static InputParameters validParams()
virtual void execute() override
Sampler & _sampler
virtual void finalize() override
nDRosenbrock(const InputParameters &parameters)
const Real & _limiting_value
VectorPostprocessorValue & _values
const bool & _classify
registerMooseObject("StochasticToolsTestApp", nDRosenbrock)