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-plus
Commits
66b72c97
Commit
66b72c97
authored
Oct 12, 2017
by
Mark OLESEN
Browse files
ENH: make creation of streamline seeds demand-driven
parent
59bdc08c
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/functionObjects/field/streamLine/streamLine.C
View file @
66b72c97
...
...
@@ -52,7 +52,7 @@ void Foam::functionObjects::streamLine::track()
initialParticles
);
const
sampledSet
&
seedPoints
=
sampledSetP
tr_
();
const
sampledSet
&
seedPoints
=
sampledSetP
oints
();
forAll
(
seedPoints
,
i
)
{
...
...
src/functionObjects/field/streamLine/streamLineBase.C
View file @
66b72c97
...
...
@@ -47,6 +47,38 @@ namespace functionObjects
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const
Foam
::
word
&
Foam
::
functionObjects
::
streamLineBase
::
sampledSetAxis
()
const
{
if
(
sampledSetPtr_
.
empty
())
{
sampledSetPoints
();
}
return
sampledSetAxis_
;
}
const
Foam
::
sampledSet
&
Foam
::
functionObjects
::
streamLineBase
::
sampledSetPoints
()
const
{
if
(
sampledSetPtr_
.
empty
())
{
sampledSetPtr_
=
sampledSet
::
New
(
"seedSampleSet"
,
mesh_
,
meshSearchMeshObject
::
New
(
mesh_
),
dict_
.
subDict
(
"seedSampleSet"
)
);
sampledSetAxis_
=
sampledSetPtr_
->
axis
();
}
return
sampledSetPtr_
();
}
Foam
::
autoPtr
<
Foam
::
indirectPrimitivePatch
>
Foam
::
functionObjects
::
streamLineBase
::
wallPatch
()
const
{
...
...
@@ -54,12 +86,12 @@ Foam::functionObjects::streamLineBase::wallPatch() const
label
nFaces
=
0
;
for
All
(
patches
,
patch
i
)
for
(
const
polyPatch
&
pp
:
patch
es
)
{
//if (!polyPatch::constraintType(p
atches[patchi]
.type()))
if
(
isA
<
wallPolyPatch
>
(
p
atches
[
patchi
]
))
//if (!polyPatch::constraintType(p
p
.type()))
if
(
isA
<
wallPolyPatch
>
(
p
p
))
{
nFaces
+=
p
atches
[
patchi
]
.
size
();
nFaces
+=
p
p
.
size
();
}
}
...
...
@@ -67,13 +99,11 @@ Foam::functionObjects::streamLineBase::wallPatch() const
nFaces
=
0
;
for
All
(
patches
,
patch
i
)
for
(
const
polyPatch
&
pp
:
patch
es
)
{
//if (!polyPatch::constraintType(p
atches[patchi]
.type()))
if
(
isA
<
wallPolyPatch
>
(
p
atches
[
patchi
]
))
//if (!polyPatch::constraintType(p
p
.type()))
if
(
isA
<
wallPolyPatch
>
(
p
p
))
{
const
polyPatch
&
pp
=
patches
[
patchi
];
forAll
(
pp
,
i
)
{
addressing
[
nFaces
++
]
=
pp
.
start
()
+
i
;
...
...
@@ -110,24 +140,24 @@ void Foam::functionObjects::streamLineBase::initInterpolations
label
nScalar
=
0
;
label
nVector
=
0
;
for
All
(
fields_
,
i
)
for
(
const
word
&
fieldName
:
fields_
)
{
if
(
foundObject
<
volScalarField
>
(
field
s_
[
i
]
))
if
(
foundObject
<
volScalarField
>
(
field
Name
))
{
nScalar
++
;
}
else
if
(
foundObject
<
volVectorField
>
(
field
s_
[
i
]
))
else
if
(
foundObject
<
volVectorField
>
(
field
Name
))
{
nVector
++
;
}
else
{
FatalErrorInFunction
<<
"Cannot find field "
<<
field
s_
[
i
]
<<
nl
<<
"Cannot find field "
<<
field
Name
<<
nl
<<
"Valid scalar fields are:"
<<
mesh_
.
names
(
volScalarField
::
typeName
)
<<
nl
<<
flatOutput
(
mesh_
.
names
(
volScalarField
::
typeName
)
)
<<
nl
<<
"Valid vector fields are:"
<<
mesh_
.
names
(
volVectorField
::
typeName
)
<<
flatOutput
(
mesh_
.
names
(
volVectorField
::
typeName
)
)
<<
exit
(
FatalError
);
}
}
...
...
@@ -136,12 +166,11 @@ void Foam::functionObjects::streamLineBase::initInterpolations
vvInterp
.
setSize
(
nVector
);
nVector
=
0
;
for
All
(
fields_
,
i
)
for
(
const
word
&
fieldName
:
fields_
)
{
if
(
foundObject
<
volScalarField
>
(
field
s_
[
i
]
))
if
(
foundObject
<
volScalarField
>
(
field
Name
))
{
const
volScalarField
&
f
=
lookupObject
<
volScalarField
>
(
fields_
[
i
]);
const
volScalarField
&
f
=
lookupObject
<
volScalarField
>
(
fieldName
);
vsInterp
.
set
(
nScalar
++
,
...
...
@@ -152,10 +181,9 @@ void Foam::functionObjects::streamLineBase::initInterpolations
)
);
}
else
if
(
foundObject
<
volVectorField
>
(
field
s_
[
i
]
))
else
if
(
foundObject
<
volVectorField
>
(
field
Name
))
{
const
volVectorField
&
f
=
lookupObject
<
volVectorField
>
(
fields_
[
i
]);
const
volVectorField
&
f
=
lookupObject
<
volVectorField
>
(
fieldName
);
if
(
f
.
name
()
==
UName_
)
{
...
...
@@ -231,7 +259,7 @@ void Foam::functionObjects::streamLineBase::storePoint
DynamicList
<
vectorList
>&
newVectors
)
const
{
label
sz
=
newTrack
.
size
();
const
label
sz
=
newTrack
.
size
();
const
List
<
point
>&
track
=
allTracks_
[
tracki
];
...
...
@@ -274,6 +302,7 @@ void Foam::functionObjects::streamLineBase::trimToBox
)
const
{
const
List
<
point
>&
track
=
allTracks_
[
tracki
];
if
(
track
.
size
())
{
for
...
...
@@ -287,7 +316,7 @@ void Foam::functionObjects::streamLineBase::trimToBox
const
point
&
endPt
=
track
[
segmenti
];
const
vector
d
(
endPt
-
startPt
);
scalar
magD
=
mag
(
d
);
const
scalar
magD
=
mag
(
d
);
if
(
magD
>
ROOTVSMALL
)
{
if
(
bb
.
contains
(
startPt
))
...
...
@@ -507,6 +536,12 @@ Foam::functionObjects::streamLineBase::~streamLineBase()
bool
Foam
::
functionObjects
::
streamLineBase
::
read
(
const
dictionary
&
dict
)
{
if
(
&
dict_
!=
&
dict
)
{
// Update local copy of dictionary:
dict_
=
dict
;
}
fvMeshFunctionObject
::
read
(
dict
);
Info
<<
type
()
<<
" "
<<
name
()
<<
":"
<<
nl
;
...
...
@@ -536,10 +571,8 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
trackLength_
=
VGREAT
;
if
(
dict
.
found
(
"trackLength"
))
if
(
dict
.
readIfPresent
(
"trackLength"
,
trackLength_
))
{
dict
.
lookup
(
"trackLength"
)
>>
trackLength_
;
Info
<<
type
()
<<
" : fixed track length specified : "
<<
trackLength_
<<
nl
<<
endl
;
}
...
...
@@ -562,14 +595,8 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
cloudName_
=
dict
.
lookupOrDefault
<
word
>
(
"cloud"
,
type
());
sampledSetPtr_
=
sampledSet
::
New
(
"seedSampleSet"
,
mesh_
,
meshSearchMeshObject
::
New
(
mesh_
),
dict
.
subDict
(
"seedSampleSet"
)
);
sampledSetAxis_
=
sampledSetPtr_
->
axis
();
sampledSetPtr_
.
clear
();
sampledSetAxis_
.
clear
();
scalarFormatterPtr_
=
writer
<
scalar
>::
New
(
dict
.
lookup
(
"setFormat"
));
vectorFormatterPtr_
=
writer
<
vector
>::
New
(
dict
.
lookup
(
"setFormat"
));
...
...
@@ -756,7 +783,7 @@ bool Foam::functionObjects::streamLineBase::write()
new
coordSet
(
"track"
+
Foam
::
name
(
nTracks
),
sampledSetAxis
_
//"xyz"
sampledSetAxis
()
//
"xyz"
)
);
oldToNewTrack
[
tracki
]
=
nTracks
;
...
...
@@ -767,7 +794,7 @@ bool Foam::functionObjects::streamLineBase::write()
// Convert scalar values
if
(
allScalars_
.
size
()
>
0
&&
tracks
.
size
()
>
0
)
if
(
!
allScalars_
.
empty
()
&&
!
tracks
.
empty
()
)
{
List
<
List
<
scalarField
>>
scalarValues
(
allScalars_
.
size
());
...
...
@@ -781,7 +808,7 @@ bool Foam::functionObjects::streamLineBase::write()
scalarList
&
vals
=
allTrackVals
[
tracki
];
if
(
vals
.
size
())
{
label
newTracki
=
oldToNewTrack
[
tracki
];
const
label
newTracki
=
oldToNewTrack
[
tracki
];
scalarValues
[
scalari
][
newTracki
].
transfer
(
vals
);
}
}
...
...
@@ -811,7 +838,7 @@ bool Foam::functionObjects::streamLineBase::write()
// Convert vector values
if
(
allVectors_
.
size
()
>
0
&&
tracks
.
size
()
>
0
)
if
(
!
allVectors_
.
empty
()
&&
!
tracks
.
empty
()
)
{
List
<
List
<
vectorField
>>
vectorValues
(
allVectors_
.
size
());
...
...
@@ -825,7 +852,7 @@ bool Foam::functionObjects::streamLineBase::write()
vectorList
&
vals
=
allTrackVals
[
tracki
];
if
(
vals
.
size
())
{
label
newTracki
=
oldToNewTrack
[
tracki
];
const
label
newTracki
=
oldToNewTrack
[
tracki
];
vectorValues
[
vectori
][
newTracki
].
transfer
(
vals
);
}
}
...
...
@@ -854,20 +881,18 @@ bool Foam::functionObjects::streamLineBase::write()
// File names are generated on the master but setProperty needs to
// be across all procs
Pstream
::
scatter
(
scalarVtkFile
);
for
All
(
scalarNames_
,
namei
)
for
(
const
word
&
fieldName
:
scalarNames_
)
{
dictionary
propsDict
;
propsDict
.
add
(
"file"
,
scalarVtkFile
);
const
word
&
fieldName
=
scalarNames_
[
namei
];
setProperty
(
fieldName
,
propsDict
);
}
Pstream
::
scatter
(
vectorVtkFile
);
for
All
(
vectorNames_
,
namei
)
for
(
const
word
&
fieldName
:
vectorNames_
)
{
dictionary
propsDict
;
propsDict
.
add
(
"file"
,
vectorVtkFile
);
const
word
&
fieldName
=
vectorNames_
[
namei
];
setProperty
(
fieldName
,
propsDict
);
}
...
...
src/functionObjects/field/streamLine/streamLineBase.H
View file @
66b72c97
...
...
@@ -63,6 +63,14 @@ class streamLineBase
:
public
fvMeshFunctionObject
{
// Private data
//- Seed set engine
mutable
autoPtr
<
sampledSet
>
sampledSetPtr_
;
//- Axis of the sampled points to output
mutable
word
sampledSetAxis_
;
protected:
//- Input dictionary
...
...
@@ -102,35 +110,35 @@ protected:
wordList
vectorNames_
;
// Demand driven
// Demand driven
//- Mesh searching enigne
autoPtr
<
meshSearch
>
meshSearch
Ptr_
;
//- File writer for scalar data
autoPtr
<
writer
<
scalar
>>
scalarFormatter
Ptr_
;
//- Seed set engine
autoPtr
<
sampledSet
>
sampledSet
Ptr_
;
//- File writer for vector data
autoPtr
<
writer
<
vector
>>
vectorFormatter
Ptr_
;
//- Axis of the sampled points to output
word
sampledSetAxis_
;
//- File writer for scalar data
autoPtr
<
writer
<
scalar
>>
scalarFormatterPtr_
;
// Generated data
//- File writer for vector data
autoPtr
<
writer
<
vector
>>
vectorFormatterPtr
_
;
//- All tracks. Per track the points it passed through
DynamicList
<
List
<
point
>>
allTracks
_
;
//- Per scalarField, per track, the sampled values
List
<
DynamicList
<
scalarList
>>
allScalars_
;
// Generated data
//- Per vectorField, per track, the sampled values
List
<
DynamicList
<
vectorList
>>
allVectors_
;
//- All tracks. Per track the points it passed through
DynamicList
<
List
<
point
>>
allTracks_
;
//- Per scalarField, per track, the sampled values
List
<
DynamicList
<
scalarList
>>
allScalars_
;
// Protected Member Functions
//- Per vectorField, per track, the sampled values
List
<
DynamicList
<
vectorList
>>
allVectors_
;
//- The axis of the sampledSet. Creates sampledSet if required.
const
word
&
sampledSetAxis
()
const
;
//- Demand driven construction of the sampledSet.
// Also updates sampledSetAxis_
const
sampledSet
&
sampledSetPoints
()
const
;
//- Construct patch out of all wall patch faces
autoPtr
<
indirectPrimitivePatch
>
wallPatch
()
const
;
...
...
src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C
View file @
66b72c97
...
...
@@ -131,12 +131,11 @@ void Foam::functionObjects::wallBoundedStreamLine::track()
// Get the seed points
// ~~~~~~~~~~~~~~~~~~~
const
sampledSet
&
seedPoints
=
sampledSetPtr_
();
const
sampledSet
&
seedPoints
=
sampledSetPoints
();
forAll
(
seedPoints
,
i
)
{
label
celli
=
seedPoints
.
cells
()[
i
];
const
label
celli
=
seedPoints
.
cells
()[
i
];
if
(
celli
!=
-
1
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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