Commit 507b8988 authored by Henry Weller's avatar Henry Weller
Browse files

functionObjects::surfaceRegion: Write the surface geometry for formats in...

functionObjects::surfaceRegion: Write the surface geometry for formats in which the data is in separate files
parent c224d19c
......@@ -371,7 +371,7 @@ void Foam::functionObjects::fieldValues::surfaceRegion::combineSurfaceGeometry
if (Pstream::parRun())
{
// dimension as fraction of mesh bounding box
// Dimension as fraction of mesh bounding box
scalar mergeDim = 1e-10*mesh().bounds().mag();
labelList pointsMap;
......@@ -538,27 +538,30 @@ void Foam::functionObjects::fieldValues::surfaceRegion::writeFileHeader
const label i
)
{
writeCommented(file(), "Region type : ");
file() << regionTypeNames_[regionType_] << " " << regionName_ << endl;
writeCommented(file(), "Faces : ");
file() << nFaces_ << endl;
writeCommented(file(), "Area : ");
file() << totalArea_ << endl;
writeCommented(file(), "Time");
if (writeArea_)
if (operation_ != opNone)
{
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)
{
file()
writeCommented(file(), "Time");
if (writeArea_)
{
file() << tab << "Area";
}
forAll(fields_, i)
{
file()
<< 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()
{
fieldValue::write();
if (operation_ != opNone)
{
fieldValue::write();
}
if (surfacePtr_.valid())
{
surfacePtr_().update();
}
if (Pstream::master())
if (operation_ != opNone && Pstream::master())
{
writeTime(file());
}
......@@ -738,14 +744,42 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::write()
if (writeArea_)
{
totalArea_ = totalArea();
if (Pstream::master())
if (operation_ != opNone && Pstream::master())
{
file() << tab << totalArea_;
}
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;
if (weightFieldName_ != "none")
{
......@@ -761,7 +795,7 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::write()
// Combine onto master
combineFields(weightField);
// process the fields
// Process the fields
forAll(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;
......
......@@ -113,7 +113,7 @@ Note
faces
- the `oriented' entries relate to mesh-oriented fields, such as the
flux, phi. These fields will be oriented according to the face normals.
- using \c sampledSurfaces:
- using \c sampledSurface:
- not available for surface fields
- if interpolate=true they use \c interpolationCellPoint
otherwise they use cell values
......@@ -371,6 +371,9 @@ public:
//- Return the list of +1/-1 representing face flip map
inline const labelList& faceSign() const;
//- Return the output directory
inline fileName outputDir() const;
//- Templated helper function to output field values
template<class Type>
bool writeValues
......
......@@ -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();
}
// ************************************************************************* //
......@@ -315,13 +315,10 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::writeValues
if (Pstream::master())
{
fileName outputDir =
baseFileDir()/name()/"surface"/obr_.time().timeName();
surfaceWriterPtr_->write
(
outputDir,
word(regionTypeNames_[regionType_]) + "_" + regionName_,
outputDir(),
regionTypeNames_[regionType_] + ("_" + regionName_),
points,
faces,
fieldName,
......@@ -331,22 +328,24 @@ bool Foam::functionObjects::fieldValues::surfaceRegion::writeValues
}
}
// Apply scale factor
values *= scaleFactor_;
if (Pstream::master())
if (operation_ != opNone)
{
Type result = processValues(values, Sf, weightField);
// Apply scale factor
values *= scaleFactor_;
// Add to result dictionary, over-writing any previous entry
resultDict_.add(fieldName, result, true);
if (Pstream::master())
{
Type result = processValues(values, Sf, weightField);
// Add to result dictionary, over-writing any previous entry
resultDict_.add(fieldName, result, true);
file()<< tab << result;
file() << tab << result;
Log << " " << operationTypeNames_[operation_]
<< "(" << regionName_ << ") of " << fieldName
<< " = " << result << endl;
Log << " " << operationTypeNames_[operation_]
<< "(" << regionName_ << ") of " << fieldName
<< " = " << result << endl;
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment