diff --git a/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.C b/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.C index b7b5d49ef3f0a414763ff1682decd35c1b7a2275..ea2142c56ddb1ed1758c2a9876f7bf8d32fd243b 100644 --- a/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.C +++ b/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -106,6 +106,57 @@ Foam::surfaceWriters::boundaryDataWriter::boundaryDataWriter // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void Foam::surfaceWriters::boundaryDataWriter::serialWriteGeometry +( + const regIOobject& iopts, + const meshedSurf& surf +) +{ + const pointField& points = surf.points(); + const faceList& faces = surf.faces(); + + if (verbose_) + { + if (this->isPointData()) + { + Info<< "Writing points: " << iopts.objectPath() << endl; + } + else + { + Info<< "Writing face centres: " << iopts.objectPath() << endl; + } + } + + // Like regIOobject::writeObject without instance() adaptation + // since this would write to e.g. 0/ instead of postProcessing/ + + OFstream osGeom(iopts.objectPath(), streamOpt_); + + if (header_) + { + iopts.writeHeader(osGeom); + } + + if (this->isPointData()) + { + // Just like writeData, but without copying beforehand + osGeom << points; + } + else + { + primitivePatch pp(SubList<face>(faces), points); + + // Just like writeData, but without copying beforehand + osGeom << pp.faceCentres(); + } + + if (header_) + { + iopts.writeEndDivider(osGeom); + } +} + + Foam::fileName Foam::surfaceWriters::boundaryDataWriter::write() { checkOpen(); @@ -127,6 +178,7 @@ Foam::fileName Foam::surfaceWriters::boundaryDataWriter::write() mkDir(surfaceDir); } + // Write sample locations pointIOField iopts ( IOobject @@ -138,30 +190,9 @@ Foam::fileName Foam::surfaceWriters::boundaryDataWriter::write() false ) ); + iopts.note() = (this->isPointData() ? "point data" : "face data"); - if (verbose_) - { - Info<< "Writing points: " << iopts.objectPath() << endl; - } - - - // Like regIOobject::writeObject without instance() adaptation - // since this would write to e.g. 0/ instead of postProcessing/ - - OFstream osGeom(iopts.objectPath(), streamOpt_); - - if (header_) - { - iopts.writeHeader(osGeom); - } - - // Just like writeData, but without copying beforehand - osGeom << surf.points(); - - if (header_) - { - iopts.writeEndDivider(osGeom); - } + serialWriteGeometry(iopts, surf); } wroteGeom_ = true; @@ -199,67 +230,29 @@ Foam::fileName Foam::surfaceWriters::boundaryDataWriter::writeTemplate if (Pstream::master() || !parallel_) { - const pointField& points = surf.points(); - const faceList& faces = surf.faces(); - if (!isDir(outputFile.path())) { mkDir(outputFile.path()); } - pointIOField iopts - ( - IOobject - ( - surfaceDir/"points", - *dummyTimePtr, - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ) - ); - - if (verbose_) - { - if (this->isPointData()) - { - Info<< "Writing points: " << iopts.objectPath() << endl; - } - else - { - Info<< "Writing face centres: " << iopts.objectPath() << endl; - } - } - - // Like regIOobject::writeObject without instance() adaptation - // since this would write to e.g. 0/ instead of postProcessing/ - - OFstream osGeom(iopts.objectPath(), streamOpt_); - - if (header_) + // Write sample locations { - iopts.writeHeader(osGeom); - } - - if (this->isPointData()) - { - // Just like writeData, but without copying beforehand - osGeom << points; - } - else - { - primitivePatch pp(SubList<face>(faces), points); - - // Just like writeData, but without copying beforehand - osGeom << pp.faceCentres(); - } + pointIOField iopts + ( + IOobject + ( + surfaceDir/"points", + *dummyTimePtr, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ) + ); + iopts.note() = (this->isPointData() ? "point data" : "face data"); - if (header_) - { - iopts.writeEndDivider(osGeom); + serialWriteGeometry(iopts, surf); } - // Write field { IOField<Type> iofld @@ -273,6 +266,7 @@ Foam::fileName Foam::surfaceWriters::boundaryDataWriter::writeTemplate false ) ); + iofld.note() = (this->isPointData() ? "point data" : "face data"); OFstream osField(iofld.objectPath(), streamOpt_); diff --git a/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.H b/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.H index ee422186d418fb3e87d9b9b5043f2ebd4fb63789..410b37ae2c172b01dc28422b6027c060f6d950c8 100644 --- a/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.H +++ b/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -129,6 +129,10 @@ SourceFiles namespace Foam { + +// Forward Declarations +class regIOobject; + namespace surfaceWriters { @@ -151,6 +155,9 @@ class boundaryDataWriter // Private Member Functions + //- Write serial surface geometry to "points" file. + void serialWriteGeometry(const regIOobject&, const meshedSurf& surf); + //- Templated write field operation template<class Type> fileName writeTemplate