Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
3093b327
Commit
3093b327
authored
Aug 11, 2017
by
Mark Olesen
Browse files
ENH: support pTotal as a derived field for surfMeshSamplers (issue
#567
)
parent
45881823
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/sampling/surfMeshSampler/surfMeshSamplers/surfMeshSamplers.C
View file @
3093b327
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016
-2017
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -58,10 +58,10 @@ void Foam::surfMeshSamplers::checkOutNames
{
objectRegistry
&
reg
=
const_cast
<
objectRegistry
&>
(
registry
);
for
All
(
n
ame
s
,
name
i
)
for
(
const
word
&
fldN
ame
:
name
s
)
{
objectRegistry
::
iterator
iter
=
reg
.
find
(
names
[
namei
]
);
if
(
iter
!=
reg
.
e
nd
())
objectRegistry
::
iterator
iter
=
reg
.
find
(
fldName
);
if
(
iter
.
fou
nd
())
{
registry
.
checkOut
(
*
iter
());
}
...
...
@@ -156,10 +156,8 @@ bool Foam::surfMeshSamplers::execute()
DynamicList
<
word
>
added
(
derivedNames_
.
size
());
DynamicList
<
word
>
cleanup
(
derivedNames_
.
size
());
for
All
(
derivedNames_
,
n
ame
i
)
for
(
const
word
&
derivedName
:
derivedN
ame
s_
)
{
const
word
&
derivedName
=
derivedNames_
[
namei
];
if
(
derivedName
==
"rhoU"
)
{
added
.
append
(
derivedName
);
...
...
@@ -190,20 +188,48 @@ bool Foam::surfMeshSamplers::execute()
{
cleanup
.
append
(
derivedName
);
db
.
store
(
new
volScalarField
const
volScalarField
&
p
=
mesh_
.
lookupObject
<
volScalarField
>
(
"p"
);
if
(
p
.
dimensions
()
==
dimPressure
)
{
db
.
store
(
derivedName
,
// pTotal = p + U^2 / 2
new
volScalarField
(
mesh_
.
lookupObject
<
volScalarField
>
(
"p"
)
+
0
.
5
*
mesh_
.
lookupObject
<
volScalarField
>
(
"rho"
)
*
magSqr
(
mesh_
.
lookupObject
<
volVectorField
>
(
"U"
))
derivedName
,
// pTotal = p + rho U^2 / 2
(
p
+
0
.
5
*
mesh_
.
lookupObject
<
volScalarField
>
(
"rho"
)
*
magSqr
(
mesh_
.
lookupObject
<
volVectorField
>
(
"U"
)
)
)
)
)
);
);
}
else
{
db
.
store
(
new
volScalarField
(
derivedName
,
// pTotal = p + U^2 / 2
(
p
+
0
.
5
*
magSqr
(
mesh_
.
lookupObject
<
volVectorField
>
(
"U"
)
)
)
)
);
}
}
}
else
...
...
@@ -226,10 +252,8 @@ bool Foam::surfMeshSamplers::execute()
const
wordList
fields
=
acceptable
.
sortedToc
();
if
(
!
fields
.
empty
())
{
for
All
(
*
this
,
surfI
)
for
(
surfMeshSampler
&
s
:
surfaces
()
)
{
surfMeshSampler
&
s
=
operator
[](
surfI
);
// Potentially monitor the update for writing geometry?
if
(
s
.
needsUpdate
())
{
...
...
@@ -258,21 +282,20 @@ bool Foam::surfMeshSamplers::write()
wordReList
select
(
fieldSelection_
.
size
()
+
derivedNames_
.
size
());
label
nElem
=
0
;
for
All
(
fieldSelection_
,
i
)
for
(
const
auto
&
item
:
fieldSelection_
)
{
select
[
nElem
++
]
=
fieldSelection_
[
i
]
;
select
[
nElem
++
]
=
item
;
}
for
All
(
derivedNames_
,
i
)
for
(
const
auto
&
derivedName
:
derivedNames_
)
{
select
[
nElem
++
]
=
derivedName
s_
[
i
]
;
select
[
nElem
++
]
=
derivedName
;
}
// avoid duplicate entries
select
=
wordRes
::
uniq
(
select
);
for
All
(
*
this
,
surfI
)
for
(
const
surfMeshSampler
&
s
:
surfaces
()
)
{
const
surfMeshSampler
&
s
=
operator
[](
surfI
);
s
.
write
(
select
);
}
...
...
@@ -317,10 +340,8 @@ bool Foam::surfMeshSamplers::read(const dictionary& dict)
if
(
this
->
size
())
{
Info
<<
"Reading surface description:"
<<
nl
;
for
All
(
*
this
,
surfI
)
for
(
surfMeshSampler
&
s
:
surfaces
()
)
{
surfMeshSampler
&
s
=
operator
[](
surfI
);
Info
<<
" "
<<
s
.
name
()
<<
nl
;
if
(
createOnRead
)
{
...
...
@@ -370,9 +391,9 @@ void Foam::surfMeshSamplers::readUpdate(const polyMesh::readUpdateState state)
bool
Foam
::
surfMeshSamplers
::
needsUpdate
()
const
{
for
All
(
*
this
,
surfI
)
for
(
const
surfMeshSampler
&
s
:
surfaces
()
)
{
if
(
operator
[](
surfI
)
.
needsUpdate
())
if
(
s
.
needsUpdate
())
{
return
true
;
}
...
...
@@ -386,9 +407,9 @@ bool Foam::surfMeshSamplers::expire()
{
bool
justExpired
=
false
;
for
All
(
*
this
,
surfI
)
for
(
surfMeshSampler
&
s
:
surfaces
()
)
{
if
(
operator
[](
surfI
)
.
expire
())
if
(
s
.
expire
())
{
justExpired
=
true
;
}
...
...
@@ -407,9 +428,9 @@ bool Foam::surfMeshSamplers::update()
}
bool
updated
=
false
;
for
All
(
*
this
,
surfI
)
for
(
surfMeshSampler
&
s
:
surfaces
()
)
{
if
(
operator
[](
surfI
)
.
update
())
if
(
s
.
update
())
{
updated
=
true
;
}
...
...
src/sampling/surfMeshSampler/surfMeshSamplers/surfMeshSamplers.H
View file @
3093b327
...
...
@@ -134,6 +134,18 @@ class surfMeshSamplers
const
UList
<
word
>&
names
);
//- Access the sampling surfaces
inline
const
PtrList
<
surfMeshSampler
>&
surfaces
()
const
{
return
static_cast
<
const
PtrList
<
surfMeshSampler
>&>
(
*
this
);
}
//- Access the sampling surfaces
inline
PtrList
<
surfMeshSampler
>&
surfaces
()
{
return
static_cast
<
PtrList
<
surfMeshSampler
>&>
(
*
this
);
}
//- Filter acceptable fields types
template
<
class
Type
>
...
...
Write
Preview
Markdown
is supported
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