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,6 +538,8 @@ void Foam::functionObjects::fieldValues::surfaceRegion::writeFileHeader
const label i const label i
) )
{ {
if (operation_ != opNone)
{
writeCommented(file(), "Region type : "); writeCommented(file(), "Region type : ");
file() << regionTypeNames_[regionType_] << " " << regionName_ << endl; file() << regionTypeNames_[regionType_] << " " << regionName_ << endl;
writeCommented(file(), "Faces : "); writeCommented(file(), "Faces : ");
@ -559,6 +561,7 @@ void Foam::functionObjects::fieldValues::surfaceRegion::writeFileHeader
} }
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()
{ {
if (operation_ != opNone)
{
fieldValue::write(); 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,7 +328,8 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::writeValues
} }
} }
if (operation_ != opNone)
{
// Apply scale factor // Apply scale factor
values *= scaleFactor_; values *= scaleFactor_;
@ -342,13 +340,14 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::writeValues
// Add to result dictionary, over-writing any previous entry // Add to result dictionary, over-writing any previous entry
resultDict_.add(fieldName, result, true); resultDict_.add(fieldName, result, true);
file()<< tab << result; file() << tab << result;
Log << " " << operationTypeNames_[operation_] Log << " " << operationTypeNames_[operation_]
<< "(" << regionName_ << ") of " << fieldName << "(" << regionName_ << ") of " << fieldName
<< " = " << result << endl; << " = " << result << endl;
} }
} }
}
return ok; return ok;
} }