Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
1ce132fb
Commit
1ce132fb
authored
Jul 23, 2009
by
Andrew Heather
Browse files
code clean-up
parent
85b9b3e3
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/thermophysicalModels/pdfs/RosinRammler/RosinRammler.C
View file @
1ce132fb
...
...
@@ -24,33 +24,21 @@ License
\*---------------------------------------------------------------------------*/
#include
"RosinRammler.H"
#include
"addToRunTimeSelectionTable.H"
namespace
Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug
(
RosinRammler
,
0
);
namespace
Foam
{
defineTypeNameAndDebug
(
RosinRammler
,
0
);
addToRunTimeSelectionTable
(
pdf
,
RosinRammler
,
dictionary
);
addToRunTimeSelectionTable
(
pdf
,
RosinRammler
,
dictionary
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
RosinRammler
::
RosinRammler
(
const
dictionary
&
dict
,
Random
&
rndGen
)
Foam
::
RosinRammler
::
RosinRammler
(
const
dictionary
&
dict
,
Random
&
rndGen
)
:
pdf
(
dict
,
rndGen
),
pdfDict_
(
dict
.
subDict
(
typeName
+
"PDF"
)),
...
...
@@ -80,10 +68,10 @@ RosinRammler::RosinRammler
// find max value so that it can be normalized to 1.0
scalar
sMax
=
0
;
label
n
=
d_
.
size
();
for
(
label
i
=
0
;
i
<
n
;
i
++
)
for
(
label
i
=
0
;
i
<
n
;
i
++
)
{
scalar
s
=
exp
(
-
1
.
0
);
for
(
label
j
=
0
;
j
<
n
;
j
++
)
for
(
label
j
=
0
;
j
<
n
;
j
++
)
{
if
(
i
!=
j
)
{
...
...
@@ -96,11 +84,10 @@ RosinRammler::RosinRammler
sMax
=
max
(
sMax
,
s
);
}
for
(
label
i
=
0
;
i
<
n
;
i
++
)
for
(
label
i
=
0
;
i
<
n
;
i
++
)
{
ls_
[
i
]
/=
sMax
;
}
}
...
...
@@ -112,20 +99,20 @@ Foam::RosinRammler::~RosinRammler()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
scalar
RosinRammler
::
sample
()
const
Foam
::
scalar
Foam
::
RosinRammler
::
sample
()
const
{
scalar
y
=
0
;
scalar
x
=
0
;
label
n
=
d_
.
size
();
bool
success
=
false
;
while
(
!
success
)
while
(
!
success
)
{
x
=
minValue_
+
range_
*
rndGen_
.
scalar01
();
y
=
rndGen_
.
scalar01
();
scalar
p
=
0
.
0
;
for
(
label
i
=
0
;
i
<
n
;
i
++
)
for
(
label
i
=
0
;
i
<
n
;
i
++
)
{
scalar
xx
=
pow
(
x
/
d_
[
i
],
n_
[
i
]);
p
+=
ls_
[
i
]
*
xx
*
exp
(
-
xx
);
...
...
@@ -140,16 +127,17 @@ scalar RosinRammler::sample() const
return
x
;
}
scalar
RosinRammler
::
minValue
()
const
Foam
::
scalar
Foam
::
RosinRammler
::
minValue
()
const
{
return
minValue_
;
}
scalar
RosinRammler
::
maxValue
()
const
Foam
::
scalar
Foam
::
RosinRammler
::
maxValue
()
const
{
return
maxValue_
;
}
// ************************************************************************* //
}
// ************************************************************************* //
src/thermophysicalModels/pdfs/RosinRammler/RosinRammler.H
View file @
1ce132fb
...
...
@@ -72,10 +72,11 @@ class RosinRammler
scalar
range_
;
public:
//- Runtime type information
TypeName
(
"RosinRammler"
);
TypeName
(
"RosinRammler"
);
// Constructors
...
...
@@ -88,18 +89,20 @@ public:
);
// Destructor
~
RosinRammler
();
//- Destructor
virtual
~
RosinRammler
();
// Member Functions
scalar
sample
()
const
;
//- Sample the pdf
virtual
scalar
sample
()
const
;
scalar
minValue
()
const
;
scalar
m
ax
Value
()
const
;
//- Return the minimum value
virtual
scalar
m
in
Value
()
const
;
//- Return the maximum value
virtual
scalar
maxValue
()
const
;
};
...
...
src/thermophysicalModels/pdfs/exponential/exponential.C
View file @
1ce132fb
...
...
@@ -28,29 +28,17 @@ License
#include
"exponential.H"
#include
"addToRunTimeSelectionTable.H"
namespace
Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug
(
exponential
,
0
);
addToRunTimeSelectionTable
(
pdf
,
exponential
,
dictionary
);
namespace
Foam
{
defineTypeNameAndDebug
(
exponential
,
0
);
addToRunTimeSelectionTable
(
pdf
,
exponential
,
dictionary
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
exponential
::
exponential
(
const
dictionary
&
dict
,
Random
&
rndGen
)
Foam
::
exponential
::
exponential
(
const
dictionary
&
dict
,
Random
&
rndGen
)
:
pdf
(
dict
,
rndGen
),
pdfDict_
(
dict
.
subDict
(
typeName
+
"PDF"
)),
...
...
@@ -70,10 +58,10 @@ exponential::exponential
scalar
sMax
=
0
;
label
n
=
lambda_
.
size
();
for
(
label
i
=
0
;
i
<
n
;
i
++
)
for
(
label
i
=
0
;
i
<
n
;
i
++
)
{
scalar
s
=
lambda_
[
i
]
*
exp
(
-
lambda_
[
i
]
*
minValue_
);
for
(
label
j
=
0
;
j
<
n
;
j
++
)
for
(
label
j
=
0
;
j
<
n
;
j
++
)
{
if
(
i
!=
j
)
{
...
...
@@ -89,7 +77,6 @@ exponential::exponential
{
ls_
[
i
]
/=
sMax
;
}
}
...
...
@@ -101,14 +88,14 @@ Foam::exponential::~exponential()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
scalar
exponential
::
sample
()
const
Foam
::
scalar
Foam
::
exponential
::
sample
()
const
{
scalar
y
=
0
;
scalar
x
=
0
;
label
n
=
lambda_
.
size
();
bool
success
=
false
;
while
(
!
success
)
while
(
!
success
)
{
x
=
minValue_
+
range_
*
rndGen_
.
scalar01
();
y
=
rndGen_
.
scalar01
();
...
...
@@ -119,25 +106,26 @@ scalar exponential::sample() const
p
+=
ls_
[
i
]
*
exp
(
-
lambda_
[
i
]
*
x
);
}
if
(
y
<
p
)
if
(
y
<
p
)
{
success
=
true
;
}
}
return
x
;
}
scalar
exponential
::
minValue
()
const
Foam
::
scalar
Foam
::
exponential
::
minValue
()
const
{
return
minValue_
;
}
scalar
exponential
::
maxValue
()
const
Foam
::
scalar
Foam
::
exponential
::
maxValue
()
const
{
return
maxValue_
;
}
// ************************************************************************* //
}
// ************************************************************************* //
src/thermophysicalModels/pdfs/exponential/exponential.H
View file @
1ce132fb
...
...
@@ -46,7 +46,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class exponential Declaration
Class exponential Declaration
\*---------------------------------------------------------------------------*/
class
exponential
...
...
@@ -69,7 +69,7 @@ class exponential
public:
//- Runtime type information
TypeName
(
"exponential"
);
TypeName
(
"exponential"
);
// Constructors
...
...
@@ -82,18 +82,20 @@ public:
);
// Destructor
~
exponential
();
//- Destructor
virtual
~
exponential
();
// Member Functions
scalar
sample
()
const
;
//- Sample the pdf
virtual
scalar
sample
()
const
;
scalar
minValue
()
const
;
scalar
m
ax
Value
()
const
;
//- Return the minimum value
virtual
scalar
m
in
Value
()
const
;
//- Return the maximum value
virtual
scalar
maxValue
()
const
;
};
...
...
src/thermophysicalModels/pdfs/general/general.C
View file @
1ce132fb
...
...
@@ -24,33 +24,20 @@ License
\*---------------------------------------------------------------------------*/
#include
"general.H"
#include
"addToRunTimeSelectionTable.H"
namespace
Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug
(
general
,
0
);
addToRunTimeSelectionTable
(
pdf
,
general
,
dictionary
);
namespace
Foam
{
defineTypeNameAndDebug
(
general
,
0
);
addToRunTimeSelectionTable
(
pdf
,
general
,
dictionary
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
general
::
general
(
const
dictionary
&
dict
,
Random
&
rndGen
)
Foam
::
general
::
general
(
const
dictionary
&
dict
,
Random
&
rndGen
)
:
pdf
(
dict
,
rndGen
),
pdfDict_
(
dict
.
subDict
(
typeName
+
"PDF"
)),
...
...
@@ -63,16 +50,15 @@ general::general
// normalize the pdf
scalar
yMax
=
0
;
for
(
label
i
=
0
;
i
<
nEntries_
;
i
++
)
for
(
label
i
=
0
;
i
<
nEntries_
;
i
++
)
{
yMax
=
max
(
yMax
,
xy_
[
i
][
1
]);
}
for
(
label
i
=
0
;
i
<
nEntries_
;
i
++
)
for
(
label
i
=
0
;
i
<
nEntries_
;
i
++
)
{
xy_
[
i
][
1
]
/=
yMax
;
}
}
...
...
@@ -84,21 +70,21 @@ Foam::general::~general()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
scalar
general
::
sample
()
const
Foam
::
scalar
Foam
::
general
::
sample
()
const
{
scalar
y
=
0
;
scalar
x
=
0
;
bool
success
=
false
;
while
(
!
success
)
while
(
!
success
)
{
x
=
minValue_
+
range_
*
rndGen_
.
scalar01
();
y
=
rndGen_
.
scalar01
();
bool
intervalFound
=
false
;
label
i
=
-
1
;
while
(
!
intervalFound
)
while
(
!
intervalFound
)
{
i
++
;
if
(
(
x
>
xy_
[
i
][
0
])
&&
(
x
<
xy_
[
i
+
1
][
0
])
)
...
...
@@ -106,27 +92,33 @@ scalar general::sample() const
intervalFound
=
true
;
}
}
scalar
p
=
xy_
[
i
][
1
]
+
(
x
-
xy_
[
i
][
0
])
*
(
xy_
[
i
+
1
][
1
]
-
xy_
[
i
][
1
])
/
(
xy_
[
i
+
1
][
0
]
-
xy_
[
i
][
0
]);
if
(
y
<
p
)
scalar
p
=
xy_
[
i
][
1
]
+
(
x
-
xy_
[
i
][
0
])
*
(
xy_
[
i
+
1
][
1
]
-
xy_
[
i
][
1
])
/
(
xy_
[
i
+
1
][
0
]
-
xy_
[
i
][
0
]);
if
(
y
<
p
)
{
success
=
true
;
}
}
return
x
;
}
scalar
general
::
minValue
()
const
Foam
::
scalar
Foam
::
general
::
minValue
()
const
{
return
minValue_
;
}
scalar
general
::
maxValue
()
const
Foam
::
scalar
Foam
::
general
::
maxValue
()
const
{
return
maxValue_
;
}
// ************************************************************************* //
}
// ************************************************************************* //
src/thermophysicalModels/pdfs/general/general.H
View file @
1ce132fb
...
...
@@ -62,16 +62,18 @@ class general
List
<
pair
>
xy_
;
label
nEntries_
;
//- min and max values of the distribution
scalar
minValue_
;
scalar
maxValue_
;
scalar
range_
;
public:
//- Runtime type information
TypeName
(
"general"
);
TypeName
(
"general"
);
// Constructors
...
...
@@ -85,17 +87,19 @@ public:
// Destructor
~
general
();
virtual
~
general
();
// Member Functions
scalar
sample
()
const
;
//- Sample the pdf
virtual
scalar
sample
()
const
;
scalar
minValue
()
const
;
scalar
m
ax
Value
()
const
;
//- Return the minimum value
virtual
scalar
m
in
Value
()
const
;
//- Return the maximum value
virtual
scalar
maxValue
()
const
;
};
...
...
@@ -105,10 +109,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//#include "generalI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
src/thermophysicalModels/pdfs/normal/normal.C
View file @
1ce132fb
...
...
@@ -24,33 +24,20 @@ License
\*---------------------------------------------------------------------------*/
#include
"normal.H"
#include
"addToRunTimeSelectionTable.H"
namespace
Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug
(
normal
,
0
);
addToRunTimeSelectionTable
(
pdf
,
normal
,
dictionary
);
namespace
Foam
{
defineTypeNameAndDebug
(
normal
,
0
);
addToRunTimeSelectionTable
(
pdf
,
normal
,
dictionary
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
normal
::
normal
(
const
dictionary
&
dict
,
Random
&
rndGen
)
Foam
::
normal
::
normal
(
const
dictionary
&
dict
,
Random
&
rndGen
)
:
pdf
(
dict
,
rndGen
),
pdfDict_
(
dict
.
subDict
(
typeName
+
"PDF"
)),
...
...
@@ -63,11 +50,11 @@ normal::normal
{
scalar
sMax
=
0
;
label
n
=
strength_
.
size
();
for
(
label
i
=
0
;
i
<
n
;
i
++
)
for
(
label
i
=
0
;
i
<
n
;
i
++
)
{
scalar
x
=
expectation_
[
i
];
scalar
s
=
strength_
[
i
];
for
(
label
j
=
0
;
j
<
n
;
j
++
)
for
(
label
j
=
0
;
j
<
n
;
j
++
)
{
if
(
i
!=
j
)
{
...
...
@@ -80,11 +67,10 @@ normal::normal
sMax
=
max
(
sMax
,
s
);
}
for
(
label
i
=
0
;
i
<
n
;
i
++
)
for
(
label
i
=
0
;
i
<
n
;
i
++
)
{
strength_
[
i
]
/=
sMax
;
}
}
...
...
@@ -96,20 +82,20 @@ Foam::normal::~normal()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
scalar
normal
::
sample
()
const
Foam
::
scalar
Foam
::
normal
::
sample
()
const
{
scalar
y
=
0
;
scalar
x
=
0
;
label
n
=
expectation_
.
size
();
bool
success
=
false
;
while
(
!
success
)
while
(
!
success
)
{
x
=
minValue_
+
range_
*
rndGen_
.
scalar01
();
y
=
rndGen_
.
scalar01
();
scalar
p
=
0
.
0
;
for
(
label
i
=
0
;
i
<
n
;
i
++
)
for
(
label
i
=
0
;
i
<
n
;
i
++
)
{
scalar
nu
=
expectation_
[
i
];
scalar
sigma
=
variance_
[
i
];
...
...
@@ -118,25 +104,26 @@ scalar normal::sample() const
p
+=
s
*
exp
(
-
0
.
5
*
v
*
v
);
}
if
(
y
<
p
)
if
(
y
<
p
)
{
success
=
true
;
}
}
return
x
;
}
scalar
normal
::
minValue
()
const
Foam
::
scalar
Foam
::
normal
::
minValue
()
const
{
return
minValue_
;
}
scalar
normal
::
maxValue
()
const
Foam
::
scalar
Foam
::
normal
::
maxValue
()
const
{
return
maxValue_
;
}
// ************************************************************************* //
}
// ************************************************************************* //
src/thermophysicalModels/pdfs/normal/normal.H
View file @
1ce132fb
...
...
@@ -73,10 +73,11 @@ class normal
scalar
range_
;
public:
//- Runtime type information
TypeName
(
"normal"
);
TypeName
(
"normal"
);
// Constructors
...
...
@@ -89,18 +90,20 @@ public:
);