diff --git a/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.C b/src/surfMesh/writers/boundaryData/boundaryDataSurfaceWriter.C index 2300c14ea87ff135780a61ca2edf9a950256da97..94a63e2a510074e9e9c83fb323e61fcb2564b850 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. @@ -108,6 +108,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(); @@ -129,6 +180,7 @@ Foam::fileName Foam::surfaceWriters::boundaryDataWriter::write() mkDir(surfaceDir); } + // Write sample locations pointIOField iopts ( IOobject @@ -140,30 +192,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; @@ -212,67 +243,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 @@ -286,6 +279,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 f8628882fed39cb3a09ae41cd55fadbf09f93c0a..ec7df24459cd4a74a4e2c493e90ada9f4b2d40d7 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. @@ -134,6 +134,10 @@ SourceFiles namespace Foam { + +// Forward Declarations +class regIOobject; + namespace surfaceWriters { @@ -159,6 +163,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