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.
random_variable.h
Go to the documentation of this file.
1 //
2 // Authors:
3 // Guillermo Casas gcasas@cimne-upc.edu
4 //
5 
6 #ifndef RANDOM_VARIABLE_H
7 #define RANDOM_VARIABLE_H
8 
9 
10 // System includes
11 #include <string>
12 #include <iostream>
13 
14 // Project includes
16 
17 namespace Kratos {
18 
19 class KRATOS_API(DEM_APPLICATION) RandomVariable {
20 
21 public:
22 
24 
27  RandomVariable(const Parameters rParameters);
28 
30  virtual ~RandomVariable(){};
31 
32  virtual double Sample(){KRATOS_ERROR << "You are calling the 'Sample' function of the abstract class 'RandomVariable'. Please instantiate a specific derived class instead."; return 0.0;};
33 
34  virtual double GetMean(){KRATOS_ERROR << "You are calling 'GetMean' function of the abstract class 'RandomVariable'. Please instantiate a specific derived class instead."; return 0.0;};
35 
36  const array_1d<double, 2>& GetSupport();
37 
39  virtual std::string Info() const;
40 
42  virtual void PrintInfo(std::ostream& rOStream) const;
43 
45  virtual void PrintData(std::ostream& rOStream) const;
46 
47 
48 protected:
49  virtual void Check(){};
50  double mMean = 0.0;
51  bool mMeanHasAlreadyBeenCalculated=false;
52 
53  template<typename T>
54  void CalculateFirstAndLastIndicesWithNonzeroValue(std::vector<T> values, size_t& low_index, size_t& high_index){
55  // finding first and last indices that correspond to nonzero probabilites
56 
57  auto it = std::find_if(values.begin(), values.end(), [](const double x) { return x != 0; });
58  auto reverse_it = std::find_if(values.rbegin(), values.rend(), [](const double x) { return x != 0; });
59  low_index = std::distance(values.begin(), it);
60  high_index = std::distance(begin(values), reverse_it.base()) - 1;
61  }
62 
63  void SetSupport(const double Min, const double Max);
64 
65 private:
66  array_1d<double, 2> mSupport;
67 
69  RandomVariable & operator=(RandomVariable const& rOther);
70 
71 }; // Class RandomVariable
72 
73 } // namespace Kratos
74 
75 #endif // RANDOM_VARIABLE_H defined
76 
77 
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
Definition: random_variable.h:19
KRATOS_CLASS_POINTER_DEFINITION(RandomVariable)
virtual double Sample()
Definition: random_variable.h:32
void CalculateFirstAndLastIndicesWithNonzeroValue(std::vector< T > values, size_t &low_index, size_t &high_index)
Definition: random_variable.h:54
virtual void Check()
Definition: random_variable.h:49
virtual ~RandomVariable()
Destructor.
Definition: random_variable.h:30
virtual double GetMean()
Definition: random_variable.h:34
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
list values
Definition: bombardelli_test.py:42
x
Definition: sensitivityMatrix.py:49