KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
piecewise_linear_random_variable.h
Go to the documentation of this file.
1 //
2 // Authors:
3 // Guillermo Casas gcasas@cimne-upc.edu
4 //
5 
6 #ifndef PIECEWISE_LINEAR_RANDOM_VARIABLE_H
7 #define PIECEWISE_LINEAR_RANDOM_VARIABLE_H
8 
9 
10 // System includes
11 #include <string>
12 #include <iostream>
13 
14 // Project includes
15 #include "random_variable.h"
16 #include <random>
17 
18 namespace Kratos {
19 
20 class KRATOS_API(DEM_APPLICATION) PiecewiseLinearRandomVariable: public RandomVariable {
21 
22 public:
23 
25 
28  PiecewiseLinearRandomVariable(const Parameters rParameters);
29  PiecewiseLinearRandomVariable(const Parameters rParameters, const int seed);
30 
31  double Sample() override;
32  double ProbabilityDensity(const double x);
33  double GetMean() override;
34 
36  std::string Info() const override
37  {
38  std::stringstream buffer;
39  buffer << "PiecewiseLinearRandomVariable" ;
40  return buffer.str();
41 
42  }
43 
45  void PrintInfo(std::ostream& rOStream) const override
46  {
47  rOStream << "PiecewiseLinearRandomVariable";
48  }
49 
51 
52  void PrintData(std::ostream& rOStream) const override
53  {
54 
55  }
56 
57 protected:
58  void Check() override;
59 
60 
61 private:
62 
63  void CalculateTrapezoidProbabilitiesAndNormalize();
64  std::size_t SampleTrapezoidChoice();
65  double SampleWithinTrapezoid(const double H, const double B1, const double B2);
66  double SampleWithinStandardTrapezoid(const double b);
67  double SamplePositiveSlopingStandardTriangle();
68  double SampleNegativeSlopingStandardTriangle();
69 
72 
73  double mRelativeClosenessTolerance = 0.0;
74  std::vector<double> mPDFValues;
75  std::vector<double> mPDFBreakpoints;
76  std::mt19937 mRandomNumberGenerator;
77  std::discrete_distribution<int> mTrapezoidsDiscreteDistribution;
78 
79 }; // Class PiecewiseLinearRandomVariable
80 
81 } // namespace Kratos
82 
83 #endif // PIECEWISE_LINEAR_RANDOM_VARIABLE_H defined
84 
85 
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
Definition: piecewise_linear_random_variable.h:20
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: piecewise_linear_random_variable.h:52
KRATOS_CLASS_POINTER_DEFINITION(PiecewiseLinearRandomVariable)
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: piecewise_linear_random_variable.h:45
std::string Info() const override
Turn back information as a stemplate<class T, std::size_t dim> tring.
Definition: piecewise_linear_random_variable.h:36
Definition: random_variable.h:19
int seed
Definition: GenerateWind.py:138
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
H
Definition: generate_droplet_dynamics.py:257
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
x
Definition: sensitivityMatrix.py:49