Skip to content

Commit

Permalink
Use ParallelObject instead of MooseObject
Browse files Browse the repository at this point in the history
  • Loading branch information
aeslaughter committed Feb 10, 2020
1 parent b73d6d9 commit 81d24f2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 26 deletions.
8 changes: 5 additions & 3 deletions framework/include/utils/BootstrapStatistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

#include "MooseTypes.h"
#include "MooseObject.h"
#include <vector>
Expand All @@ -30,7 +32,7 @@ MooseEnum makeBootstrapCalculatorEnum();
* objects.
*/
std::unique_ptr<const BootstrapCalculator> makeBootstrapCalculator(
const MooseEnum &, const MooseObject &, const std::vector<Real> &, unsigned int, unsigned int);
const MooseEnum &, const libMesh::ParallelObject &, const std::vector<Real> &, unsigned int, unsigned int);

/*
* Base class for computing bootstrap confidence level intervals. These classes follow the same
Expand All @@ -39,7 +41,7 @@ std::unique_ptr<const BootstrapCalculator> makeBootstrapCalculator(
class BootstrapCalculator : public libMesh::ParallelObject
{
public:
BootstrapCalculator(const MooseObject &);
BootstrapCalculator(const libMesh::ParallelObject &);
virtual ~BootstrapCalculator() = default;
void setSeed(unsigned int);
void setReplicates(unsigned int);
Expand All @@ -58,7 +60,7 @@ class BootstrapCalculator : public libMesh::ParallelObject
class Percentile : public BootstrapCalculator
{
public:
Percentile(const MooseObject &);
Percentile(const libMesh::ParallelObject &);
virtual std::vector<Real>
compute(const std::vector<Real> &, const Calculator &, const bool) const override;
};
Expand Down
22 changes: 12 additions & 10 deletions framework/include/utils/Statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

#include "MooseTypes.h"
#include "MooseObject.h"
#include <vector>
Expand All @@ -21,7 +23,7 @@ class Calculator;
* Free function for building a const Calculator object for use by StatisticsVectorPostprocessor.
*/
std::unique_ptr<const Calculator> makeCalculator(const MooseEnumItem & item,
const MooseObject & other);
const libMesh::ParallelObject & other);

/*
* Free function that returns the available statistics available to the
Expand All @@ -45,64 +47,64 @@ MultiMooseEnum makeCalculatorEnum();
class Calculator : public libMesh::ParallelObject
{
public:
Calculator(const MooseObject &);
Calculator(const libMesh::ParallelObject &);
virtual ~Calculator() = default;
virtual Real compute(const std::vector<Real> &, bool) const = 0;
};

class Mean : public Calculator
{
public:
Mean(const MooseObject &);
Mean(const libMesh::ParallelObject &);
virtual Real compute(const std::vector<Real> &, bool) const override;
};

class Min : public Calculator
{
public:
Min(const MooseObject &);
Min(const libMesh::ParallelObject &);
virtual Real compute(const std::vector<Real> &, bool) const override;
};

class Max : public Calculator
{
public:
Max(const MooseObject &);
Max(const libMesh::ParallelObject &);
virtual Real compute(const std::vector<Real> &, bool) const override;
};

class Sum : public Calculator
{
public:
Sum(const MooseObject &);
Sum(const libMesh::ParallelObject &);
virtual Real compute(const std::vector<Real> &, bool) const override;
};

class StdDev : public Calculator
{
public:
StdDev(const MooseObject &);
StdDev(const libMesh::ParallelObject &);
virtual Real compute(const std::vector<Real> &, bool) const override;
};

class StdErr : public StdDev
{
public:
StdErr(const MooseObject &);
StdErr(const libMesh::ParallelObject &);
virtual Real compute(const std::vector<Real> &, bool) const override;
};

class Ratio : public Calculator
{
public:
Ratio(const MooseObject &);
Ratio(const libMesh::ParallelObject &);
virtual Real compute(const std::vector<Real> &, bool) const override;
};

class L2Norm : public Calculator
{
public:
L2Norm(const MooseObject &);
L2Norm(const libMesh::ParallelObject &);
virtual Real compute(const std::vector<Real> &, bool) const override;
};

Expand Down
6 changes: 3 additions & 3 deletions framework/src/utils/BootstrapStatistics.C
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ makeBootstrapCalculatorEnum()

std::unique_ptr<const BootstrapCalculator>
makeBootstrapCalculator(const MooseEnum & item,
const MooseObject & other,
const libMesh::ParallelObject & other,
const std::vector<Real> & levels,
unsigned int replicates,
unsigned int seed)
Expand All @@ -51,7 +51,7 @@ makeBootstrapCalculator(const MooseEnum & item,
return std::unique_ptr<const BootstrapCalculator>(ptr);
}

BootstrapCalculator::BootstrapCalculator(const MooseObject & other) : libMesh::ParallelObject(other)
BootstrapCalculator::BootstrapCalculator(const libMesh::ParallelObject & other) : libMesh::ParallelObject(other)
{
}

Expand Down Expand Up @@ -158,7 +158,7 @@ BootstrapCalculator::shuffle(const std::vector<Real> & data,
}

// PERCENTILE //////////////////////////////////////////////////////////////////////////////////////
Percentile::Percentile(const MooseObject & other) : BootstrapCalculator(other) {}
Percentile::Percentile(const libMesh::ParallelObject & other) : BootstrapCalculator(other) {}

std::vector<Real>
Percentile::compute(const std::vector<Real> & data,
Expand Down
20 changes: 10 additions & 10 deletions framework/src/utils/Statistics.C
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ makeCalculatorEnum()
}

std::unique_ptr<const Calculator>
makeCalculator(const MooseEnumItem & item, const MooseObject & other)
makeCalculator(const MooseEnumItem & item, const libMesh::ParallelObject & other)
{
if (item == "min")
return libmesh_make_unique<const Min>(other);
Expand Down Expand Up @@ -57,10 +57,10 @@ makeCalculator(const MooseEnumItem & item, const MooseObject & other)
}

// CALCULATOR //////////////////////////////////////////////////////////////////////////////////////
Calculator::Calculator(const MooseObject & other) : libMesh::ParallelObject(other) {}
Calculator::Calculator(const libMesh::ParallelObject & other) : libMesh::ParallelObject(other) {}

// MEAN ////////////////////////////////////////////////////////////////////////////////////////////
Mean::Mean(const MooseObject & other) : Calculator(other) {}
Mean::Mean(const libMesh::ParallelObject & other) : Calculator(other) {}

Real
Mean::compute(const std::vector<Real> & data, bool is_distributed) const
Expand All @@ -79,7 +79,7 @@ Mean::compute(const std::vector<Real> & data, bool is_distributed) const
}

// MIN /////////////////////////////////////////////////////////////////////////////////////////////
Min::Min(const MooseObject & other) : Calculator(other) {}
Min::Min(const libMesh::ParallelObject & other) : Calculator(other) {}

Real
Min::compute(const std::vector<Real> & data, bool is_distributed) const
Expand All @@ -92,7 +92,7 @@ Min::compute(const std::vector<Real> & data, bool is_distributed) const
}

// MAX /////////////////////////////////////////////////////////////////////////////////////////////
Max::Max(const MooseObject & other) : Calculator(other) {}
Max::Max(const libMesh::ParallelObject & other) : Calculator(other) {}

Real
Max::compute(const std::vector<Real> & data, bool is_distributed) const
Expand All @@ -105,7 +105,7 @@ Max::compute(const std::vector<Real> & data, bool is_distributed) const
}

// SUM /////////////////////////////////////////////////////////////////////////////////////////////
Sum::Sum(const MooseObject & other) : Calculator(other) {}
Sum::Sum(const libMesh::ParallelObject & other) : Calculator(other) {}

Real
Sum::compute(const std::vector<Real> & data, bool is_distributed) const
Expand All @@ -118,7 +118,7 @@ Sum::compute(const std::vector<Real> & data, bool is_distributed) const
}

// STDDEV //////////////////////////////////////////////////////////////////////////////////////////
StdDev::StdDev(const MooseObject & other) : Calculator(other) {}
StdDev::StdDev(const libMesh::ParallelObject & other) : Calculator(other) {}

Real
StdDev::compute(const std::vector<Real> & data, bool is_distributed) const
Expand All @@ -144,7 +144,7 @@ StdDev::compute(const std::vector<Real> & data, bool is_distributed) const
}

// STDERR //////////////////////////////////////////////////////////////////////////////////////////
StdErr::StdErr(const MooseObject & other) : StdDev(other) {}
StdErr::StdErr(const libMesh::ParallelObject & other) : StdDev(other) {}

Real
StdErr::compute(const std::vector<Real> & data, bool is_distributed) const
Expand All @@ -156,7 +156,7 @@ StdErr::compute(const std::vector<Real> & data, bool is_distributed) const
}

// RATIO ///////////////////////////////////////////////////////////////////////////////////////////
Ratio::Ratio(const MooseObject & other) : Calculator(other) {}
Ratio::Ratio(const libMesh::ParallelObject & other) : Calculator(other) {}

Real
Ratio::compute(const std::vector<Real> & data, bool is_distributed) const
Expand All @@ -176,7 +176,7 @@ Ratio::compute(const std::vector<Real> & data, bool is_distributed) const
}

// L2NORM //////////////////////////////////////////////////////////////////////////////////////////
L2Norm::L2Norm(const MooseObject & other) : Calculator(other) {}
L2Norm::L2Norm(const libMesh::ParallelObject & other) : Calculator(other) {}

Real
L2Norm::compute(const std::vector<Real> & data, bool is_distributed) const
Expand Down

0 comments on commit 81d24f2

Please sign in to comment.