diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files
index a474a8fcfc..87ee002e04 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files
@@ -1,4 +1,3 @@
-ensightOutputCloud.C
foamToEnsight.C
EXE = $(FOAM_APPBIN)/foamToEnsight
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/options b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/options
index 82fc2ecd28..2ca27b9fbc 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/options
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/options
@@ -4,10 +4,10 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
- -I$(LIB_SRC)/lagrangian/basic/lnInclude
+ -I$(LIB_SRC)/lagrangian/intermediate/lnInclude
EXE_LIBS = \
-ldynamicMesh \
-lgenericPatchFields \
- -llagrangian \
+ -llagrangianIntermediate \
-lconversion
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightOutputCloud.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightOutputCloud.C
deleted file mode 100644
index ed76498ad0..0000000000
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightOutputCloud.C
+++ /dev/null
@@ -1,161 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration |
- \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
- \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
--------------------------------------------------------------------------------
-License
- This file is part of OpenFOAM.
-
- OpenFOAM is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License
- along with OpenFOAM. If not, see .
-
-\*---------------------------------------------------------------------------*/
-
-#include "ensightOutputCloud.H"
-
-#include "fvMesh.H"
-#include "passiveParticle.H"
-#include "Cloud.H"
-#include "pointList.H"
-
-// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
-
-void Foam::ensightCloud::writePositions
-(
- const fvMesh& mesh,
- const word& cloudName,
- const bool exists,
- autoPtr& output
-)
-{
- // Total number of parcels on all processes
- label nTotParcels = 0;
- autoPtr> cloudPtr;
-
- if (exists)
- {
- cloudPtr.reset(new Cloud(mesh, cloudName, false));
- nTotParcels = cloudPtr().size();
- }
- reduce(nTotParcels, sumOp());
-
- if (Pstream::master())
- {
- ensightFile& os = output();
-
- os.beginParticleCoordinates(nTotParcels);
- if (!nTotParcels)
- {
- return; // DONE
- }
-
- if (os.format() == IOstream::BINARY)
- {
- // binary write is Ensight6 - first ids, then positions
-
- // 1-index
- for (label parcelId = 0; parcelId < nTotParcels; ++parcelId)
- {
- os.write(parcelId+1);
- }
-
- // Master
- forAllConstIter(Cloud, cloudPtr(), elmnt)
- {
- const point p(elmnt().position());
-
- os.write(p.x());
- os.write(p.y());
- os.write(p.z());
- }
-
- // Slaves
- for (int slave=1; slave, cloudPtr(), elmnt)
- {
- const point p(elmnt().position());
-
- os.write(++parcelId, 8); // unusual width
- os.write(p.x());
- os.write(p.y());
- os.write(p.z());
- os.newline();
- }
-
- // Slaves
- for (int slave=1; slave, cloudPtr(), elmnt)
- {
- const point p(elmnt().position());
- points[pti++] = p;
- }
-
- {
- OPstream toMaster
- (
- Pstream::commsTypes::scheduled,
- Pstream::masterNo()
- );
-
- toMaster
- << points;
- }
- }
-}
-
-
-// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/Make/files b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/Make/files
index 63e9998478..739c971551 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/Make/files
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/Make/files
@@ -1,4 +1,3 @@
-ensightOutputSerialCloud.C
foamToEnsightParts.C
EXE = $(FOAM_APPBIN)/foamToEnsightParts
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/Make/options b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/Make/options
index b975639649..481d843cac 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/Make/options
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/Make/options
@@ -3,11 +3,11 @@ EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude \
- -I$(LIB_SRC)/lagrangian/basic/lnInclude
+ -I$(LIB_SRC)/lagrangian/intermediate/lnInclude
EXE_LIBS = \
-lfiniteVolume \
- -llagrangian \
+ -llagrangianIntermediate \
-lmeshTools \
-lconversion \
-lgenericPatchFields
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputSerialCloud.C b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputSerialCloud.C
deleted file mode 100644
index db87438e46..0000000000
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputSerialCloud.C
+++ /dev/null
@@ -1,95 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration |
- \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
- \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
--------------------------------------------------------------------------------
-License
- This file is part of OpenFOAM.
-
- OpenFOAM is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License
- along with OpenFOAM. If not, see .
-
-\*---------------------------------------------------------------------------*/
-
-#include "ensightOutputSerialCloud.H"
-#include "ensightPTraits.H"
-
-#include "passiveParticle.H"
-#include "IOField.H"
-#include "volFields.H"
-#include "surfaceFields.H"
-
-// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
-
-void Foam::ensightSerialCloud::writePositions
-(
- const polyMesh& mesh,
- const word& cloudName,
- autoPtr output
-)
-{
- label nTotParcels = 0;
- autoPtr> cloudPtr;
-
- cloudPtr.reset(new Cloud(mesh, cloudName, false));
- nTotParcels = cloudPtr().size();
-
- Cloud parcels(mesh, cloudName, false);
-
- if (Pstream::master())
- {
- ensightFile& os = output();
- os.beginParticleCoordinates(nTotParcels);
-
- // binary write is Ensight6 - first ids, then positions
- if (os.format() == IOstream::BINARY)
- {
- // 1-index
- for (label parcelId = 0; parcelId < nTotParcels; ++parcelId)
- {
- os.write(parcelId+1);
- }
-
-
- forAllConstIter(Cloud, cloudPtr(), elmnt)
- {
- const vector p(elmnt().position());
-
- os.write(p.x());
- os.write(p.y());
- os.write(p.z());
- }
- }
- else
- {
- // ASCII id + position together
-
- label parcelId = 0;
- forAllConstIter(Cloud, cloudPtr(), elmnt)
- {
- const vector p(elmnt().position());
-
- os.write(++parcelId, 8); // unusual width
- os.write(p.x());
- os.write(p.y());
- os.write(p.z());
- os.newline();
- }
- }
- }
-}
-
-
-// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputSerialCloud.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputSerialCloud.H
deleted file mode 100644
index 16efb842c1..0000000000
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputSerialCloud.H
+++ /dev/null
@@ -1,89 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration |
- \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
- \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
--------------------------------------------------------------------------------
-License
- This file is part of OpenFOAM.
-
- OpenFOAM is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License
- along with OpenFOAM. If not, see .
-
-Description
- Miscellaneous collection of functions and template related to Ensight data
-
-SourceFiles
- ensightOutputFunctions.C
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef ensightOutputSerialCloud_H
-#define ensightOutputSerialCloud_H
-
-#include "ensightFile.H"
-#include "Cloud.H"
-#include "polyMesh.H"
-#include "IOobject.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-
-namespace Foam
-{
-namespace ensightSerialCloud
-{
-
-//- Write cloud positions
-void writePositions
-(
- const polyMesh& mesh,
- const word& cloudName,
- autoPtr output
-);
-
-
-//- Write cloud field
-template
-bool writeCloudField
-(
- const IOField& field,
- ensightFile& os
-);
-
-
-//- Write cloud field
-template
-bool writeCloudField
-(
- const IOobject& fieldObject,
- autoPtr output
-);
-
-
-} // End namespace ensightSerialCloud
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-
-#ifdef NoRepository
- #include "ensightOutputSerialCloudTemplates.C"
-#endif
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputSerialCloudTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputSerialCloudTemplates.C
deleted file mode 100644
index 060e139b7a..0000000000
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputSerialCloudTemplates.C
+++ /dev/null
@@ -1,90 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration |
- \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
- \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
--------------------------------------------------------------------------------
-License
- This file is part of OpenFOAM.
-
- OpenFOAM is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License
- along with OpenFOAM. If not, see .
-
-\*---------------------------------------------------------------------------*/
-
-#include "ensightOutputSerialCloud.H"
-#include "ensightSerialOutput.H"
-#include "ensightPTraits.H"
-
-#include "passiveParticle.H"
-#include "IOField.H"
-#include "volFields.H"
-#include "surfaceFields.H"
-
-// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
-
-template
-bool Foam::ensightSerialCloud::writeCloudField
-(
- const IOField& field,
- ensightFile& os
-)
-{
- // 6 values per line
- label count = 0;
-
- forAll(field, i)
- {
- Type val = field[i];
-
- if (mag(val) < 1e-90)
- {
- val = Zero;
- }
-
- for (direction d=0; d < pTraits::nComponents; ++d)
- {
- label cmpt = ensightPTraits::componentOrder[d];
- os.write(component(val, cmpt));
-
- if (++count % 6 == 0)
- {
- os.newline();
- }
- }
- }
-
- // add final newline if required
- if (count % 6)
- {
- os.newline();
- }
-
- return true;
-}
-
-
-template
-bool Foam::ensightSerialCloud::writeCloudField
-(
- const IOobject& fieldObject,
- autoPtr output
-)
-{
- IOField field(fieldObject);
- return writeCloudField(field, output.ref());
-}
-
-
-// ************************************************************************* //
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C
index 6b269b4ceb..4509beece3 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C
+++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C
@@ -79,9 +79,7 @@ Note
#include "ensightGeoFile.H"
#include "ensightParts.H"
#include "ensightSerialOutput.H"
-
-// local files
-#include "ensightOutputSerialCloud.H"
+#include "ensightOutputCloud.H"
#include "memInfo.H"
@@ -398,13 +396,19 @@ int main(int argc, char *argv[])
Info<< "Write " << cloudName << " (" << flush;
- ensightSerialCloud::writePositions
- (
- mesh,
- cloudName,
- ensCase.newCloud(cloudName)
- );
- Info<< " positions";
+ {
+ auto os = ensCase.newCloud(cloudName);
+
+ ensightCloud::writePositions
+ (
+ mesh,
+ cloudName,
+ cloudExists,
+ os
+ );
+
+ Info<< " positions";
+ }
forAllConstIters(theseCloudFields, fieldIter)
@@ -425,26 +429,38 @@ int main(int argc, char *argv[])
bool wrote = false;
if (fieldType == scalarIOField::typeName)
{
- wrote = ensightSerialCloud::writeCloudField
+ auto os =
+ ensCase.newCloudData(cloudName, fieldName);
+
+ wrote = ensightCloud::writeCloudField
(
*fieldObject,
- ensCase.newCloudData(cloudName, fieldName)
+ true, // field exists
+ os
);
}
else if (fieldType == vectorIOField::typeName)
{
- wrote = ensightSerialCloud::writeCloudField
+ auto os =
+ ensCase.newCloudData(cloudName, fieldName);
+
+ wrote = ensightCloud::writeCloudField
(
*fieldObject,
- ensCase.newCloudData(cloudName, fieldName)
+ true, // field exists
+ os
);
}
else if (fieldType == tensorIOField::typeName)
{
- wrote = ensightSerialCloud::writeCloudField
+ auto os =
+ ensCase.newCloudData(cloudName, fieldName);
+
+ wrote = ensightCloud::writeCloudField
(
*fieldObject,
- ensCase.newCloudData(cloudName, fieldName)
+ true, // field exists
+ os
);
}
diff --git a/src/lagrangian/intermediate/Make/files b/src/lagrangian/intermediate/Make/files
index 0eb9db55d2..8789d3c0bd 100644
--- a/src/lagrangian/intermediate/Make/files
+++ b/src/lagrangian/intermediate/Make/files
@@ -119,6 +119,7 @@ clouds/Templates/KinematicCloud/cloudSolution/cloudSolution.C
submodels/MPPIC/AveragingMethods/makeAveragingMethods.C
/* conversion methods */
+conversion/ensight/ensightOutputCloud.C
conversion/vtk/foamVtkLagrangianWriter.C
diff --git a/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloud.C b/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloud.C
new file mode 100644
index 0000000000..7fef643f0d
--- /dev/null
+++ b/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloud.C
@@ -0,0 +1,172 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+\*---------------------------------------------------------------------------*/
+
+#include "ensightOutputCloud.H"
+#include "fvMesh.H"
+#include "Cloud.H"
+#include "passiveParticle.H"
+#include "pointField.H"
+
+// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+ //- Binary output
+ static inline void writeMeasured
+ (
+ ensightFile& os,
+ const pointField& points
+ )
+ {
+ for (const point& p : points)
+ {
+ os.write(p.x());
+ os.write(p.y());
+ os.write(p.z());
+ }
+ }
+
+ //- ASCII output. Id + position together
+ static inline label writeMeasured
+ (
+ ensightFile& os,
+ label pointId,
+ const pointField& points
+ )
+ {
+ for (const point& p : points)
+ {
+ os.write(++pointId, 8); // 1-index and an unusual width
+ os.write(p.x());
+ os.write(p.y());
+ os.write(p.z());
+ os.newline();
+ }
+
+ return pointId;
+ }
+
+} // End namespace Foam
+
+
+// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
+
+bool Foam::ensightCloud::writePositions
+(
+ const fvMesh& mesh,
+ const word& cloudName,
+ bool exists,
+ autoPtr& output,
+ Pstream::commsTypes comm
+)
+{
+ pointField positions;
+
+ if (exists)
+ {
+ Cloud parcels(mesh, cloudName, false);
+
+ positions.resize(parcels.size());
+
+ auto outIter = positions.begin();
+
+ forAllConstIters(parcels, iter)
+ {
+ *outIter = iter().position();
+ ++outIter;
+ }
+ }
+
+
+ // Total number of parcels on all processes
+ const label nTotParcels = returnReduce(positions.size(), sumOp());
+
+ // Update the exists/not exists information (for return value)
+ exists = nTotParcels;
+
+ if (Pstream::master())
+ {
+ ensightFile& os = output();
+
+ os.beginParticleCoordinates(nTotParcels);
+ if (!exists)
+ {
+ return exists; // DONE
+ }
+
+ if (os.format() == IOstream::BINARY)
+ {
+ // binary write is Ensight6 - first ids, then positions
+
+ // 1-index
+ for (label parcelId = 1; parcelId <= nTotParcels; ++parcelId)
+ {
+ os.write(parcelId);
+ }
+
+ // Master
+ writeMeasured(os, positions);
+
+ // Slaves
+ for (int slave=1; slave .
Namespace
- Foam::ensightOutput
+ Foam::ensightCloud
Description
- A collection of global functions for writing ensight file content.
+ A collection of global functions for writing clouds as
+ ensight file content.
SourceFiles
ensightOutputCloud.C
@@ -37,27 +38,27 @@ SourceFiles
#define ensightOutputCloud_H
#include "ensightFile.H"
-#include "ensightMesh.H"
-
#include "autoPtr.H"
#include "IOField.H"
-#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
namespace Foam
{
+// Forward declarations
+class fvMesh;
+
namespace ensightCloud
{
//- Write cloud positions
-void writePositions
+bool writePositions
(
const fvMesh& mesh,
const word& cloudName,
- const bool exists,
- autoPtr& output
+ bool exists,
+ autoPtr& output,
+ Pstream::commsTypes comm = Pstream::commsTypes::blocking
);
@@ -66,17 +67,20 @@ template
bool writeCloudField
(
const IOField& field,
- ensightFile& os
+ ensightFile& os,
+ Pstream::commsTypes comm = Pstream::commsTypes::blocking
);
-//- Write cloud field from IOobject, always returning true.
+//- Read cloud field from IOobject (if exists == true) and write,
+//- always returning true.
template
bool writeCloudField
(
- IOobject& fieldObject,
- const bool exists,
- autoPtr& output
+ const IOobject& io,
+ bool exists,
+ autoPtr& output,
+ Pstream::commsTypes comm = Pstream::commsTypes::blocking
);
diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightOutputCloudTemplates.C b/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloudTemplates.C
similarity index 50%
rename from applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightOutputCloudTemplates.C
rename to src/lagrangian/intermediate/conversion/ensight/ensightOutputCloudTemplates.C
index fb318c062d..aa0ead7b4f 100644
--- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightOutputCloudTemplates.C
+++ b/src/lagrangian/intermediate/conversion/ensight/ensightOutputCloudTemplates.C
@@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
- \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
- \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
+ \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
+ \\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -26,42 +26,66 @@ License
#include "ensightOutputCloud.H"
#include "ensightPTraits.H"
-#include "IOField.H"
-#include "Time.H"
-#include "globalIndex.H"
-
-
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template
bool Foam::ensightCloud::writeCloudField
(
const IOField& field,
- ensightFile& os
+ ensightFile& os,
+ Pstream::commsTypes comm
)
{
- const bool exists = (returnReduce(field.size(), sumOp()) > 0);
-
- if (exists)
+ if (returnReduce(field.empty(), andOp()))
{
- if (Pstream::master())
+ return false;
+ }
+
+ if (Pstream::master())
+ {
+ // 6 values per line
+ label count = 0;
+
+ // Master
+ for (Type val : field) // <-- working on a copy
{
- // 6 values per line
- label count = 0;
-
- // Master
- forAll(field, i)
+ if (mag(val) < 1e-90) // approximately root(ROOTVSMALL)
{
- Type val = field[i];
+ val = Zero;
+ }
- if (mag(val) < 1e-90)
+ for (direction d=0; d < pTraits::nComponents; ++d)
+ {
+ const direction cmpt =
+ ensightPTraits::componentOrder[d];
+
+ os.write(component(val, cmpt));
+
+ if (++count % 6 == 0)
+ {
+ os.newline();
+ }
+ }
+ }
+
+ // Slaves
+ for (int slave=1; slave recv(fromSlave);
+
+ for (Type val : field) // <-- working on a copy
+ {
+ if (mag(val) < 1e-90) // approximately root(ROOTVSMALL)
{
val = Zero;
}
for (direction d=0; d < pTraits::nComponents; ++d)
{
- label cmpt = ensightPTraits::componentOrder[d];
+ const direction cmpt =
+ ensightPTraits::componentOrder[d];
+
os.write(component(val, cmpt));
if (++count % 6 == 0)
@@ -70,79 +94,45 @@ bool Foam::ensightCloud::writeCloudField
}
}
}
-
- // Slaves
- for (int slave=1; slave slaveData(fromSlave);
-
- forAll(slaveData, i)
- {
- Type val = slaveData[i];
-
- if (mag(val) < 1e-90)
- {
- val = Zero;
- }
-
- for (direction d=0; d < pTraits::nComponents; ++d)
- {
- label cmpt = ensightPTraits::componentOrder[d];
- os.write(component(val, cmpt));
-
- if (++count % 6 == 0)
- {
- os.newline();
- }
- }
- }
- }
-
- // add final newline if required
- if (count % 6)
- {
- os.newline();
- }
}
- else
- {
- OPstream toMaster
- (
- Pstream::commsTypes::scheduled,
- Pstream::masterNo()
- );
- toMaster
- << field;
+ // Add final newline if required
+ if (count % 6)
+ {
+ os.newline();
}
}
+ else
+ {
+ OPstream toMaster(comm, Pstream::masterNo());
+ toMaster << field;
+ }
- return exists;
+ return true;
}
template
bool Foam::ensightCloud::writeCloudField
(
- IOobject& fieldObject,
+ const IOobject& io,
const bool exists,
- autoPtr& output
+ autoPtr& output,
+ Pstream::commsTypes comm
)
{
if (exists)
{
- // when exists == true, it exists globally,
+ // When exists == true, it exists globally,
// but can still be missing on the local processor.
// Handle this by READ_IF_PRESENT instead.
- const IOobject::readOption rOpt = fieldObject.readOpt();
- fieldObject.readOpt() = IOobject::READ_IF_PRESENT;
+ IOobject fieldObj(io);
+ fieldObj.readOpt() = IOobject::READ_IF_PRESENT;
- IOField field(fieldObject);
- fieldObject.readOpt() = rOpt;
+ IOField field(fieldObj);
- writeCloudField(field, output.ref());
+ writeCloudField(field, output.ref(), comm);
}
return true;