functionObjects::surfaceRegion: Write the surface geometry for formats in which the data is in separate files

This commit is contained in:
Henry Weller
2016-06-30 10:33:55 +01:00
parent 6a5923f966
commit 2e419c58f8
4 changed files with 86 additions and 43 deletions

View File

@ -371,7 +371,7 @@ void Foam::functionObjects::fieldValues::surfaceRegion::combineSurfaceGeometry
if (Pstream::parRun()) if (Pstream::parRun())
{ {
// dimension as fraction of mesh bounding box // Dimension as fraction of mesh bounding box
scalar mergeDim = 1e-10*mesh().bounds().mag(); scalar mergeDim = 1e-10*mesh().bounds().mag();
labelList pointsMap; labelList pointsMap;
@ -538,27 +538,30 @@ void Foam::functionObjects::fieldValues::surfaceRegion::writeFileHeader
const label i const label i
) )
{ {
writeCommented(file(), "Region type : "); if (operation_ != opNone)
file() << regionTypeNames_[regionType_] << " " << regionName_ << endl;
writeCommented(file(), "Faces : ");
file() << nFaces_ << endl;
writeCommented(file(), "Area : ");
file() << totalArea_ << endl;
writeCommented(file(), "Time");
if (writeArea_)
{ {
file() << tab << "Area"; writeCommented(file(), "Region type : ");
} file() << regionTypeNames_[regionType_] << " " << regionName_ << endl;
writeCommented(file(), "Faces : ");
file() << nFaces_ << endl;
writeCommented(file(), "Area : ");
file() << totalArea_ << endl;
forAll(fields_, i) writeCommented(file(), "Time");
{ if (writeArea_)
file() {
file() << tab << "Area";
}
forAll(fields_, i)
{
file()
<< tab << operationTypeNames_[operation_] << tab << operationTypeNames_[operation_]
<< "(" << fields_[i] << ")"; << "(" << fields_[i] << ")";
} }
file() << endl; file() << endl;
}
} }
@ -723,14 +726,17 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::read
bool Foam::functionObjects::fieldValues::surfaceRegion::write() bool Foam::functionObjects::fieldValues::surfaceRegion::write()
{ {
fieldValue::write(); if (operation_ != opNone)
{
fieldValue::write();
}
if (surfacePtr_.valid()) if (surfacePtr_.valid())
{ {
surfacePtr_().update(); surfacePtr_().update();
} }
if (Pstream::master()) if (operation_ != opNone && Pstream::master())
{ {
writeTime(file()); writeTime(file());
} }
@ -738,14 +744,42 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::write()
if (writeArea_) if (writeArea_)
{ {
totalArea_ = totalArea(); totalArea_ = totalArea();
if (Pstream::master()) if (operation_ != opNone && Pstream::master())
{ {
file() << tab << totalArea_; file() << tab << totalArea_;
} }
Log << " total area = " << totalArea_ << endl; Log << " total area = " << totalArea_ << endl;
} }
// construct weight field. Note: zero size means weight = 1 // Write the surface geometry
if (surfaceWriterPtr_.valid())
{
faceList faces;
pointField points;
if (surfacePtr_.valid())
{
combineSurfaceGeometry(faces, points);
}
else
{
combineMeshGeometry(faces, points);
}
if (Pstream::master())
{
surfaceWriterPtr_->write
(
outputDir(),
regionTypeNames_[regionType_] + ("_" + regionName_),
points,
faces,
false
);
}
}
// Construct weight field. Note: zero size means weight = 1
scalarField weightField; scalarField weightField;
if (weightFieldName_ != "none") if (weightFieldName_ != "none")
{ {
@ -761,7 +795,7 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::write()
// Combine onto master // Combine onto master
combineFields(weightField); combineFields(weightField);
// process the fields // Process the fields
forAll(fields_, i) forAll(fields_, i)
{ {
const word& fieldName = fields_[i]; const word& fieldName = fields_[i];
@ -784,9 +818,9 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::write()
} }
} }
if (Pstream::master()) if (operation_ != opNone && Pstream::master())
{ {
file()<< endl; file() << endl;
} }
Log << endl; Log << endl;

View File

@ -113,7 +113,7 @@ Note
faces faces
- the `oriented' entries relate to mesh-oriented fields, such as the - the `oriented' entries relate to mesh-oriented fields, such as the
flux, phi. These fields will be oriented according to the face normals. flux, phi. These fields will be oriented according to the face normals.
- using \c sampledSurfaces: - using \c sampledSurface:
- not available for surface fields - not available for surface fields
- if interpolate=true they use \c interpolationCellPoint - if interpolate=true they use \c interpolationCellPoint
otherwise they use cell values otherwise they use cell values
@ -371,6 +371,9 @@ public:
//- Return the list of +1/-1 representing face flip map //- Return the list of +1/-1 representing face flip map
inline const labelList& faceSign() const; inline const labelList& faceSign() const;
//- Return the output directory
inline fileName outputDir() const;
//- Templated helper function to output field values //- Templated helper function to output field values
template<class Type> template<class Type>
bool writeValues bool writeValues

View File

@ -55,4 +55,11 @@ Foam::functionObjects::fieldValues::surfaceRegion::faceSign() const
} }
inline Foam::fileName
Foam::functionObjects::fieldValues::surfaceRegion::outputDir() const
{
return baseFileDir()/name()/"surface"/obr_.time().timeName();
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -315,13 +315,10 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::writeValues
if (Pstream::master()) if (Pstream::master())
{ {
fileName outputDir =
baseFileDir()/name()/"surface"/obr_.time().timeName();
surfaceWriterPtr_->write surfaceWriterPtr_->write
( (
outputDir, outputDir(),
word(regionTypeNames_[regionType_]) + "_" + regionName_, regionTypeNames_[regionType_] + ("_" + regionName_),
points, points,
faces, faces,
fieldName, fieldName,
@ -331,22 +328,24 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::writeValues
} }
} }
if (operation_ != opNone)
// Apply scale factor
values *= scaleFactor_;
if (Pstream::master())
{ {
Type result = processValues(values, Sf, weightField); // Apply scale factor
values *= scaleFactor_;
// Add to result dictionary, over-writing any previous entry if (Pstream::master())
resultDict_.add(fieldName, result, true); {
Type result = processValues(values, Sf, weightField);
file()<< tab << result; // Add to result dictionary, over-writing any previous entry
resultDict_.add(fieldName, result, true);
Log << " " << operationTypeNames_[operation_] file() << tab << result;
<< "(" << regionName_ << ") of " << fieldName
<< " = " << result << endl; Log << " " << operationTypeNames_[operation_]
<< "(" << regionName_ << ") of " << fieldName
<< " = " << result << endl;
}
} }
} }