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
13e28f7b
Commit
13e28f7b
authored
Nov 10, 2010
by
Mark Olesen
Browse files
Merge remote branch 'OpenCFD/master' into olesenm
parents
c1493b17
0db9fa57
Changes
27
Hide whitespace changes
Inline
Side-by-side
applications/utilities/postProcessing/sampling/sample/sampleDict
View file @
13e28f7b
...
...
@@ -27,6 +27,7 @@ setFormat raw;
// Surface output format. Choice of
// null : suppress output
// ensight : Ensight Gold format, one field per case file
// foamFile : separate points, faces and values file
// dx : DX scalar or vector format
// vtk : VTK ascii format
...
...
src/postProcessing/functionObjects/field/Make/files
View file @
13e28f7b
...
...
@@ -20,4 +20,7 @@ streamLine/streamLineParticle.C
streamLine/streamLineParticleCloud.C
streamLine/streamLineFunctionObject.C
surfaceInterpolateFields/surfaceInterpolateFields.C
surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects
src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C
View file @
13e28f7b
...
...
@@ -198,11 +198,10 @@ void Foam::fieldValues::cellSource::write()
if
(
active_
)
{
scalar
totalVolume
=
gSum
(
filterField
(
mesh
().
V
()));
if
(
Pstream
::
master
())
{
outputFilePtr_
()
<<
obr_
.
time
().
value
()
<<
tab
<<
sum
(
filterField
(
mesh
().
V
()));
outputFilePtr_
()
<<
obr_
.
time
().
value
()
<<
tab
<<
totalVolume
;
}
forAll
(
fields_
,
i
)
...
...
src/postProcessing/functionObjects/field/fieldValues/controlDict
View file @
13e28f7b
...
...
@@ -61,11 +61,25 @@ functions
// Output field values as well
valueOutput true;
//
Patch or
faceZone
to
sample
//
Type of source: patch/
faceZone
/
sample
dSurface
source patch;
// if patch or faceZone: name of patch or faceZone
sourceName movingWall;
// source faceZone;
// sourceName f0;
//// if sampledSurface: dictionary with a sampledSurface
//// Note: the sampledSurfaces will have cell-values, i.e.
//// non-interpolated. Also will not sample surface fields.
//sampledSurfaceDict
//{
// type cuttingPlane;
// planeType pointAndNormal;
// pointAndNormalDict
// {
// basePoint (0 0.099 0);
// normalVector (0 1 0);
// }
//}
// Operation: areaAverage/sum/weightedAverage ...
operation areaAverage;
...
...
@@ -73,7 +87,7 @@ functions
fields
(
p
phi
phi
// surface fields not supported for sampledSurface
U
);
}
...
...
src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C
View file @
13e28f7b
...
...
@@ -28,21 +28,20 @@ License
#include
"cyclicPolyPatch.H"
#include
"emptyPolyPatch.H"
#include
"coupledPolyPatch.H"
#include
"surfaceFields.H"
#include
"volFields.H"
#include
"sampledSurface.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug
(
Foam
::
fieldValues
::
faceSource
,
0
);
template
<>
const
char
*
Foam
::
NamedEnum
<
Foam
::
fieldValues
::
faceSource
::
sourceType
,
2
>::
const
char
*
Foam
::
NamedEnum
<
Foam
::
fieldValues
::
faceSource
::
sourceType
,
3
>::
names
[]
=
{
"faceZone"
,
"patch"
"faceZone"
,
"patch"
,
"sampledSurface"
};
const
Foam
::
NamedEnum
<
Foam
::
fieldValues
::
faceSource
::
sourceType
,
2
>
const
Foam
::
NamedEnum
<
Foam
::
fieldValues
::
faceSource
::
sourceType
,
3
>
Foam
::
fieldValues
::
faceSource
::
sourceTypeNames_
;
...
...
@@ -188,6 +187,19 @@ void Foam::fieldValues::faceSource::setPatchFaces()
}
void
Foam
::
fieldValues
::
faceSource
::
sampledSurfaceFaces
(
const
dictionary
&
dict
)
{
surfacePtr_
=
sampledSurface
::
New
(
name_
,
mesh
(),
dict
.
subDict
(
"sampledSurfaceDict"
)
);
surfacePtr_
().
update
();
nFaces_
=
returnReduce
(
surfacePtr_
().
faces
().
size
(),
sumOp
<
label
>
());
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void
Foam
::
fieldValues
::
faceSource
::
initialise
(
const
dictionary
&
dict
)
...
...
@@ -204,20 +216,37 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
setPatchFaces
();
break
;
}
case
stSampledSurface
:
{
sampledSurfaceFaces
(
dict
);
break
;
}
default:
{
FatalErrorIn
(
"faceSource::initialise()"
)
<<
type
()
<<
" "
<<
name_
<<
": "
<<
sourceTypeNames_
[
source_
]
<<
"("
<<
sourceName_
<<
"):"
<<
nl
<<
" Unknown source type. Valid source types are:"
<<
sourceTypeNames_
<<
nl
<<
exit
(
FatalError
);
<<
sourceTypeNames_
.
sortedToc
()
<<
nl
<<
exit
(
FatalError
);
}
}
scalar
totalArea
;
if
(
surfacePtr_
.
valid
())
{
surfacePtr_
().
update
();
totalArea
=
gSum
(
surfacePtr_
().
magSf
());
}
else
{
totalArea
=
gSum
(
filterField
(
mesh
().
magSf
(),
false
));
}
Info
<<
type
()
<<
" "
<<
name_
<<
":"
<<
nl
<<
" total faces = "
<<
nFaces_
<<
nl
<<
" total area = "
<<
gSum
(
filterField
(
mesh
().
magSf
(),
false
))
<<
" total area = "
<<
totalArea
<<
nl
;
if
(
operation_
==
opWeightedAverage
)
...
...
@@ -280,11 +309,11 @@ Foam::fieldValues::faceSource::faceSource
fieldValue
(
name
,
obr
,
dict
,
loadFromFiles
),
source_
(
sourceTypeNames_
.
read
(
dict
.
lookup
(
"source"
))),
operation_
(
operationTypeNames_
.
read
(
dict
.
lookup
(
"operation"
))),
weightFieldName_
(
"undefinedWeightedFieldName"
),
nFaces_
(
0
),
faceId_
(),
facePatchId_
(),
faceSign_
(),
weightFieldName_
(
"undefinedWeightedFieldName"
)
faceSign_
()
{
read
(
dict
);
}
...
...
@@ -315,11 +344,22 @@ void Foam::fieldValues::faceSource::write()
if
(
active_
)
{
scalar
totalArea
;
if
(
surfacePtr_
.
valid
())
{
surfacePtr_
().
update
();
totalArea
=
gSum
(
surfacePtr_
().
magSf
());
}
else
{
totalArea
=
gSum
(
filterField
(
mesh
().
magSf
(),
false
));
}
if
(
Pstream
::
master
())
{
outputFilePtr_
()
<<
obr_
.
time
().
value
()
<<
tab
<<
sum
(
filterField
(
mesh
().
magSf
(),
false
));
outputFilePtr_
()
<<
obr_
.
time
().
value
()
<<
tab
<<
totalArea
;
}
forAll
(
fields_
,
i
)
...
...
src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H
View file @
13e28f7b
...
...
@@ -36,8 +36,9 @@ Description
outputControl outputTime;
log true; // log to screen?
valueOutput true; // Write values at run-time output times?
source faceZone; // Type of face source: faceZone, patch
sourceName f0;
source faceZone; // Type of face source:
// faceZone,patch,sampledSurface
sourceName f0; // faceZone name, see below
operation sum;
fields
(
...
...
@@ -47,7 +48,13 @@ Description
);
}
where operation is one of:
source:
- faceZone : requires a 'sourceName' entry to specify the faceZone
- patch : "" patch
- sampledSurface : requires a 'sampledSurfaceDict' subdictionary. See e.g.
sampleDict.
operation is one of:
- none
- sum
- areaAverage
...
...
@@ -62,6 +69,11 @@ Description
faces.
- all fields get oriented according to the faceZone (so you might e.g. see
negative pressure)
- using sampledSurfaces:
- they do not do surface fields
- they use cell values - they do not do any interpolation.
- take care when using isoSurfaces - these might have duplicate
triangles so integration might be wrong
SourceFiles
faceSource.C
...
...
@@ -80,6 +92,9 @@ SourceFiles
namespace
Foam
{
class
sampledSurface
;
namespace
fieldValues
{
...
...
@@ -100,11 +115,12 @@ public:
enum
sourceType
{
stFaceZone
,
stPatch
stPatch
,
stSampledSurface
};
//- Source type names
static
const
NamedEnum
<
sourceType
,
2
>
sourceTypeNames_
;
static
const
NamedEnum
<
sourceType
,
3
>
sourceTypeNames_
;
//- Operation type enumeration
...
...
@@ -133,6 +149,9 @@ private:
//- Set faces to evaluate based on a patch
void
setPatchFaces
();
//- Set faces according to sampledSurface
void
sampledSurfaceFaces
(
const
dictionary
&
);
protected:
...
...
@@ -144,20 +163,30 @@ protected:
//- Operation to apply to values
operationType
operation_
;
//- Weight field name - only used for opWeightedAverage mode
word
weightFieldName_
;
//- Global number of faces
label
nFaces_
;
//- Local list of face IDs
labelList
faceId_
;
//- Local list of patch ID per face
labelList
facePatchId_
;
// If operating on mesh faces (faceZone,patch)
//- List of +1/-1 representing face flip map (1 use as is, -1 negate)
labelList
faceSign_
;
//- Local list of face IDs
labelList
faceId_
;
//- Local list of patch ID per face
labelList
facePatchId_
;
//- List of +1/-1 representing face flip map
// (1 use as is, -1 negate)
labelList
faceSign_
;
// If operating on sampledSurface
//- underlying sampledSurface
autoPtr
<
sampledSurface
>
surfacePtr_
;
//- Weight field name - only used for opWeightedAverage mode
word
weightFieldName_
;
// Protected Member Functions
...
...
@@ -171,7 +200,7 @@ protected:
//- Return field values by looking up field name
template
<
class
Type
>
tmp
<
Field
<
Type
>
>
s
etFieldValues
(
const
word
&
fieldName
)
const
;
tmp
<
Field
<
Type
>
>
g
etFieldValues
(
const
word
&
fieldName
)
const
;
//- Apply the 'operation' to the values
template
<
class
Type
>
...
...
src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C
View file @
13e28f7b
...
...
@@ -26,7 +26,7 @@ License
#include
"faceSource.H"
#include
"surfaceFields.H"
#include
"volFields.H"
#include
"
ListListOps
.H"
#include
"
sampledSurface
.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
...
...
@@ -36,7 +36,7 @@ bool Foam::fieldValues::faceSource::validField(const word& fieldName) const
typedef
GeometricField
<
Type
,
fvsPatchField
,
surfaceMesh
>
sf
;
typedef
GeometricField
<
Type
,
fvPatchField
,
volMesh
>
vf
;
if
(
obr_
.
foundObject
<
sf
>
(
fieldName
))
if
(
source_
!=
stSampledSurface
&&
obr_
.
foundObject
<
sf
>
(
fieldName
))
{
return
true
;
}
...
...
@@ -50,7 +50,7 @@ bool Foam::fieldValues::faceSource::validField(const word& fieldName) const
template
<
class
Type
>
Foam
::
tmp
<
Foam
::
Field
<
Type
>
>
Foam
::
fieldValues
::
faceSource
::
s
etFieldValues
Foam
::
tmp
<
Foam
::
Field
<
Type
>
>
Foam
::
fieldValues
::
faceSource
::
g
etFieldValues
(
const
word
&
fieldName
)
const
...
...
@@ -58,13 +58,20 @@ Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::setFieldValues
typedef
GeometricField
<
Type
,
fvsPatchField
,
surfaceMesh
>
sf
;
typedef
GeometricField
<
Type
,
fvPatchField
,
volMesh
>
vf
;
if
(
obr_
.
foundObject
<
sf
>
(
fieldName
))
if
(
source_
!=
stSampledSurface
&&
obr_
.
foundObject
<
sf
>
(
fieldName
))
{
return
filterField
(
obr_
.
lookupObject
<
sf
>
(
fieldName
),
true
);
}
else
if
(
obr_
.
foundObject
<
vf
>
(
fieldName
))
{
return
filterField
(
obr_
.
lookupObject
<
vf
>
(
fieldName
),
true
);
if
(
surfacePtr_
.
valid
())
{
return
surfacePtr_
().
sample
(
obr_
.
lookupObject
<
vf
>
(
fieldName
));
}
else
{
return
filterField
(
obr_
.
lookupObject
<
vf
>
(
fieldName
),
true
);
}
}
return
tmp
<
Field
<
Type
>
>
(
new
Field
<
Type
>
(
0
));
...
...
@@ -131,15 +138,26 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
if
(
ok
)
{
// Get (correctly oriented) field
Field
<
Type
>
values
=
combineFields
(
setFieldValues
<
Type
>
(
fieldName
));
Field
<
Type
>
values
=
getFieldValues
<
Type
>
(
fieldName
);
scalarField
weightField
=
getFieldValues
<
scalar
>
(
weightFieldName_
);
scalarField
magSf
;
if
(
surfacePtr_
.
valid
())
{
// Get unoriented magSf
magSf
=
surfacePtr_
().
magSf
();
}
else
{
// Get unoriented magSf
magSf
=
combineFields
(
filterField
(
mesh
().
magSf
(),
false
));
}
// Get unoriented magSf
scalarField
magSf
=
combineFields
(
filterField
(
mesh
().
magSf
(),
false
));
// Combine onto master
values
=
combineFields
(
values
);
magSf
=
combineFields
(
magSf
);
weightField
=
combineFields
(
weightField
);
// Get (correctly oriented) weighting field
scalarField
weightField
=
combineFields
(
setFieldValues
<
scalar
>
(
weightFieldName_
));
if
(
Pstream
::
master
())
{
...
...
src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.C
View file @
13e28f7b
...
...
@@ -130,7 +130,7 @@ Foam::fieldValue::fieldValue
obr_
(
obr
),
active_
(
true
),
log_
(
false
),
sourceName_
(
dict
.
lookup
(
"sourceNam
e"
)),
sourceName_
(
dict
.
lookup
OrDefault
<
word
>
(
"sourceName"
,
"sampledSurfac
e"
)),
fields_
(
dict
.
lookup
(
"fields"
)),
valueOutput_
(
dict
.
lookup
(
"valueOutput"
)),
outputFilePtr_
(
NULL
)
...
...
src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H
View file @
13e28f7b
...
...
@@ -164,12 +164,14 @@ public:
//- Execute the at the final time-loop, currently does nothing
virtual
void
end
();
//- Com
n
bine fields from all processor domains into single field
//- Combine fields from all processor domains into single field
template
<
class
Type
>
tmp
<
Field
<
Type
>
>
combineFields
(
const
tmp
<
Field
<
Type
>
>&
field
)
const
;
tmp
<
Field
<
Type
>
>
combineFields
(
const
Field
<
Type
>&
field
)
const
;
//- Combine fields from all processor domains into single field
template
<
class
Type
>
tmp
<
Field
<
Type
>
>
combineFields
(
const
tmp
<
Field
<
Type
>
>&
)
const
;
};
...
...
src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C
View file @
13e28f7b
...
...
@@ -32,12 +32,12 @@ License
template
<
class
Type
>
Foam
::
tmp
<
Foam
::
Field
<
Type
>
>
Foam
::
fieldValue
::
combineFields
(
const
tmp
<
Field
<
Type
>
>
&
field
const
Field
<
Type
>&
field
)
const
{
List
<
Field
<
Type
>
>
allValues
(
Pstream
::
nProcs
());
allValues
[
Pstream
::
myProcNo
()]
=
field
()
;
allValues
[
Pstream
::
myProcNo
()]
=
field
;
Pstream
::
gatherList
(
allValues
);
...
...
@@ -57,9 +57,19 @@ Foam::tmp<Foam::Field<Type> > Foam::fieldValue::combineFields
}
else
{
return
field
()
;
return
field
;
}
}
template
<
class
Type
>
Foam
::
tmp
<
Foam
::
Field
<
Type
>
>
Foam
::
fieldValue
::
combineFields
(
const
tmp
<
Field
<
Type
>
>&
field
)
const
{
return
combineFields
(
field
());
}
// ************************************************************************* //
src/sampling/Make/files
View file @
13e28f7b
...
...
@@ -46,6 +46,7 @@ surfWriters = sampledSurface/writers
$(surfWriters)/surfaceWriters.C
$(surfWriters)/dx/dxSurfaceWriterRunTime.C
$(surfWriters)/ensight/ensightSurfaceWriterRunTime.C
$(surfWriters)/foamFile/foamFileSurfaceWriterRunTime.C
$(surfWriters)/null/nullSurfaceWriterRunTime.C
$(surfWriters)/proxy/proxySurfaceWriterRunTime.C
...
...
src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C
View file @
13e28f7b
...
...
@@ -103,7 +103,8 @@ void Foam::sampledSurfaces::sampleAndWrite
mergeList_
[
surfI
].
points
,
mergeList_
[
surfI
].
faces
,
fieldName
,
allValues
allValues
,
s
.
interpolate
()
);
}
}
...
...
@@ -121,7 +122,8 @@ void Foam::sampledSurfaces::sampleAndWrite
s
.
points
(),
s
.
faces
(),
fieldName
,
values
values
,
s
.
interpolate
()
);
}
}
...
...
src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C
View file @
13e28f7b
...
...
@@ -250,6 +250,7 @@ void Foam::dxSurfaceWriter<Type>::write
const
faceList
&
faces
,
const
word
&
fieldName
,
const
Field
<
Type
>&
values
,
const
bool
isNodeValues
,
const
bool
verbose
)
const
{
...
...
@@ -272,7 +273,7 @@ void Foam::dxSurfaceWriter<Type>::write
writeData
(
os
,
values
);
if
(
values
.
size
()
==
points
.
size
()
)
if
(
isNodeValues
)
{
os
<<
nl
<<
"attribute
\"
dep
\"
string
\"
positions
\"
"
<<
nl
<<
nl
;
...
...
src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H
View file @
13e28f7b
...
...
@@ -88,6 +88,7 @@ public:
const
faceList
&
faces
,
const
word
&
fieldName
,
const
Field
<
Type
>&
values
,
const
bool
isNodeValues
,
const
bool
verbose
=
false
)
const
;
};
...
...
src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C
0 → 100644
View file @
13e28f7b
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include
"ensightSurfaceWriter.H"
#include
"OFstream.H"
#include
"OSspecific.H"
#include
"IOmanip.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
<
class
Type
>
void
Foam
::
ensightSurfaceWriter
<
Type
>::
binShapes
(
const
pointField
&
points
,
const
faceList
&
faces
,
DynamicList
<
label
>&
tris
,
DynamicList
<
label
>&
quads
,
DynamicList
<
label
>&
polys
)
{
tris
.
setCapacity
(
faces
.
size
());
quads
.
setCapacity
(
faces
.
size
());
polys
.
setCapacity
(
faces
.
size
());
forAll
(
faces
,
i
)
{
const
face
&
f
=
faces
[
i
];
if
(
f
.
size
()
==
3
)
{
tris
.
append
(
i
);
}
else
if
(
f
.
size
()
==
4
)
{
quads
.
append
(
i
);
}
else
{
polys
.
append
(
i
);
}
}
}
template
<
class
Type
>
void
Foam
::
ensightSurfaceWriter
<
Type
>::
writeGeometry
(
const
fileName
&
surfaceName
,
Ostream
&
os
,
const
pointField
&
points
,
const