Skip to content
GitLab
Menu
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
c537e4e8
Commit
c537e4e8
authored
Dec 19, 2016
by
Andrew Heather
Browse files
ENH: Updated output to use the writer class
parent
b7d09394
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/functionObjects/field/particleDistribution/particleDistribution.C
View file @
c537e4e8
...
...
@@ -47,28 +47,6 @@ namespace functionObjects
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void
Foam
::
functionObjects
::
particleDistribution
::
writeFileHeader
(
Ostream
&
os
)
const
{
writeHeader
(
os
,
"Particle distribution"
);
writeHeaderValue
(
os
,
"Cloud"
,
cloudName_
);
forAll
(
nameVsBinWidth_
,
i
)
{
writeHeaderValue
(
os
,
"Field:"
+
nameVsBinWidth_
[
i
].
first
(),
nameVsBinWidth_
[
i
].
second
()
);
}
os
<<
endl
;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam
::
functionObjects
::
particleDistribution
::
particleDistribution
...
...
@@ -79,14 +57,14 @@ Foam::functionObjects::particleDistribution::particleDistribution
)
:
fvMeshFunctionObject
(
name
,
runTime
,
dict
),
writeFile
(
runTime
,
name
,
typeName
,
dict
),
writeFile
(
runTime
,
name
),
cloudName_
(
"unknown-cloudName"
),
nameVsBinWidth_
(),
tagFieldName_
(
"none"
),
rndGen_
(
1234
,
-
1
)
rndGen_
(
1234
,
-
1
),
writerPtr_
(
nullptr
)
{
read
(
dict
);
writeFileHeader
(
file
());
}
...
...
@@ -105,6 +83,8 @@ bool Foam::functionObjects::particleDistribution::read(const dictionary& dict)
dict
.
lookup
(
"cloud"
)
>>
cloudName_
;
dict
.
lookup
(
"nameVsBinWidth"
)
>>
nameVsBinWidth_
;
dict
.
readIfPresent
(
"tagField"
,
tagFieldName_
);
word
format
(
dict
.
lookup
(
"setFormat"
));
writerPtr_
=
writer
<
scalar
>::
New
(
format
);
Info
<<
type
()
<<
" "
<<
name
()
<<
" output:"
<<
nl
<<
" Processing cloud : "
<<
cloudName_
<<
nl
...
...
@@ -177,7 +157,6 @@ bool Foam::functionObjects::particleDistribution::write()
}
}
file
()
<<
"# Time: "
<<
mesh_
.
time
().
timeName
()
<<
nl
;
bool
ok
=
false
;
forAll
(
nameVsBinWidth_
,
i
)
...
...
@@ -198,11 +177,6 @@ bool Foam::functionObjects::particleDistribution::write()
}
}
if
(
ok
)
{
file
()
<<
nl
;
}
return
true
;
}
...
...
@@ -220,11 +194,10 @@ void Foam::functionObjects::particleDistribution::generateDistribution
return
;
}
Ostream
&
os
=
file
();
word
fName
(
fieldName
);
if
(
tag
!=
-
1
)
{
os
<<
tag
<<
token
::
TAB
;
fName
=
fName
+
'_'
+
Foam
::
name
(
tag
)
;
}
distributionModels
::
general
distribution
...
...
@@ -234,7 +207,31 @@ void Foam::functionObjects::particleDistribution::generateDistribution
rndGen_
);
os
<<
fieldName
<<
distribution
.
writeDict
(
mesh_
.
time
().
timeName
());
const
Field
<
scalar
>
distX
(
distribution
.
x
());
const
Field
<
scalar
>
distY
(
distribution
.
y
());
pointField
xBin
(
distX
.
size
(),
Zero
);
xBin
.
replace
(
0
,
distX
);
const
coordSet
coords
(
fName
,
"x"
,
xBin
,
distX
);
const
wordList
fieldNames
(
1
,
fName
);
fileName
outputPath
(
baseTimeDir
());
mkDir
(
outputPath
);
OFstream
graphFile
(
outputPath
/
writerPtr_
->
getFileName
(
coords
,
fieldNames
));
Log
<<
" Writing distribution of "
<<
fieldName
<<
" to "
<<
graphFile
.
name
()
<<
endl
;
List
<
const
scalarField
*>
yPtrs
(
1
);
yPtrs
[
0
]
=
&
distY
;
writerPtr_
->
write
(
coords
,
fieldNames
,
yPtrs
,
graphFile
);
}
...
...
src/functionObjects/field/particleDistribution/particleDistribution.H
View file @
c537e4e8
...
...
@@ -28,7 +28,7 @@ Group
grpFieldFunctionObjects
Description
Generates a particle distrbution for lagrangian data at a given time.
Generates a particle distr
i
bution for lagrangian data at a given time.
Usage
\verbatim
...
...
@@ -43,6 +43,7 @@ Usage
(d 0.1)
(U 10)
);
setFormat raw;
}
\endverbatim
...
...
@@ -53,6 +54,7 @@ Usage
cloud | Name of cloud to process | Yes |
nameVsBinWidth | List of cloud field vs bin width | Yes |
tagField | Name of cloud field to use to group particles | no | none
setFormat | Output format | yes |
\endtable
See also
...
...
@@ -73,6 +75,7 @@ SourceFiles
#include
"scalarField.H"
#include
"cachedRandom.H"
#include
"Tuple2.H"
#include
"writer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -106,6 +109,9 @@ protected:
//- Random number generator - used by distribution models
cachedRandom
rndGen_
;
//- Writer
autoPtr
<
writer
<
scalar
>>
writerPtr_
;
// Protected Member Functions
...
...
@@ -133,9 +139,6 @@ protected:
//- Disallow default bitwise assignment
void
operator
=
(
const
particleDistribution
&
)
=
delete
;
//- Output file header information
virtual
void
writeFileHeader
(
Ostream
&
os
)
const
;
public:
...
...
src/lagrangian/distributionModels/general/general.C
View file @
c537e4e8
...
...
@@ -247,17 +247,8 @@ Foam::dictionary Foam::distributionModels::general::writeDict
{
// dictionary dict = distributionModel::writeDict(dictName);
dictionary
dict
(
dictName
);
List
<
scalar
>
data
(
xy_
.
size
());
forAll
(
data
,
i
)
{
data
[
i
]
=
xy_
[
i
][
0
];
}
dict
.
add
(
"x"
,
data
);
forAll
(
data
,
i
)
{
data
[
i
]
=
xy_
[
i
][
1
];
}
dict
.
add
(
"y"
,
data
);
dict
.
add
(
"x"
,
x
());
dict
.
add
(
"y"
,
y
());
return
dict
;
}
...
...
@@ -280,6 +271,34 @@ void Foam::distributionModels::general::readDict(const dictionary& dict)
}
Foam
::
tmp
<
Foam
::
Field
<
Foam
::
scalar
>>
Foam
::
distributionModels
::
general
::
x
()
const
{
tmp
<
Field
<
scalar
>>
tx
(
new
Field
<
scalar
>
(
xy_
.
size
()));
scalarField
&
xi
=
tx
.
ref
();
forAll
(
xy_
,
i
)
{
xi
[
i
]
=
xy_
[
i
][
0
];
}
return
tx
;
}
Foam
::
tmp
<
Foam
::
Field
<
Foam
::
scalar
>>
Foam
::
distributionModels
::
general
::
y
()
const
{
tmp
<
Field
<
scalar
>>
ty
(
new
Field
<
scalar
>
(
xy_
.
size
()));
scalarField
&
yi
=
ty
.
ref
();
forAll
(
xy_
,
i
)
{
yi
[
i
]
=
xy_
[
i
][
1
];
}
return
ty
;
}
Foam
::
Ostream
&
Foam
::
operator
<<
(
Ostream
&
os
,
...
...
src/lagrangian/distributionModels/general/general.H
View file @
c537e4e8
...
...
@@ -38,6 +38,7 @@ SourceFiles
#include
"distributionModel.H"
#include
"Vector.H"
#include
"VectorSpace.H"
#include
"Field.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -121,6 +122,12 @@ public:
// Member Functions
//- Bin boundaries
virtual
tmp
<
Field
<
scalar
>>
x
()
const
;
//- Probabilities
virtual
tmp
<
Field
<
scalar
>>
y
()
const
;
//- Sample the distributionModel
virtual
scalar
sample
()
const
;
...
...
tutorials/lagrangian/sprayFoam/aachenBomb/system/controlDict
View file @
c537e4e8
...
...
@@ -62,7 +62,7 @@ functions
(d 1e-5)
(U 10)
);
distributionBinWidth 1e-5
;
setFormat raw
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment