MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / main

Function main

applications/test/Distribution/Test-Distribution.C:54–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52using namespace Foam;
53
54int main(int argc, char *argv[])
55{
56 #include "setRootCase.H"
57
58 Random R(918273);
59
60 {
61 // scalar
62 label randomDistributionTestSize = 50000000;
63
64 Distribution<scalar> dS(scalar(5e-2));
65
66 Info<< nl << "Distribution<scalar>" << nl
67 << "Sampling "
68 << randomDistributionTestSize
69 << " times from GaussNormal distribution."
70 << endl;
71
72 for (label i = 0; i < randomDistributionTestSize; i++)
73 {
74 dS.add(2.5*R.GaussNormal() + 8.5);
75 }
76
77 Info<< "Mean " << dS.mean() << nl
78 << "Median " << dS.median()
79 << endl;
80
81 dS.write("Distribution_scalar_test_1");
82
83 Distribution<scalar> dS2(scalar(1e-2));
84
85 Info<< nl << "Distribution<scalar>" << nl
86 << "Sampling "
87 << randomDistributionTestSize
88 << " times from GaussNormal distribution."
89 << endl;
90
91 for (label i = 0; i < randomDistributionTestSize; i++)
92 {
93 dS2.add(1.5*R.GaussNormal() -6.0);
94 }
95
96 Info<< "Mean " << dS2.mean() << nl
97 << "Median " << dS2.median()
98 << endl;
99
100 dS2.write("Distribution_scalar_test_2");
101
102 Info<< nl << "Adding previous two Distribution<scalar>" << endl;
103
104 dS = dS + dS2;
105
106 dS.write("Distribution_scalar_test_1+2");
107 }
108
109 if (Pstream::parRun())
110 {
111 // scalar in parallel

Callers

nothing calls this directly

Calls 4

scalarFunction · 0.85
reduceFunction · 0.50
addMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected