ENH: foamToVTK improvements for (-no-internal, -no-boundary)

- skip loading of fields with -no-internal, -no-boundary

- suppress reporting fields with -no-internal, -no-boundary

- cache loaded volume field for reuse with point interpolation.
  Trade off some memory overhead against reading twice.

  NOTE: this issue will not be evident with foamToEnsight since there
  it only handles cell data *or* point data (not both), so a field is
  only ever loaded/processed once.
This commit is contained in:
Mark Olesen
2023-01-30 22:43:55 +01:00
parent 72bfaa2be9
commit 8ee7595a77
13 changed files with 251 additions and 417 deletions

View File

@ -8,20 +8,7 @@
Copyright (C) 2018-2022 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 <http://www.gnu.org/licenses/>.
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Code chunk for converting finite-area - included by foamToVTK.

View File

@ -8,20 +8,7 @@
Copyright (C) 2018-2022 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 <http://www.gnu.org/licenses/>.
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Code chunk for post-processing conversion of cloud(s) to VTK PolyData

View File

@ -5,23 +5,10 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2023 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 <http://www.gnu.org/licenses/>.
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Code chunk for converting volume fields on processor boundaries,
@ -145,7 +132,8 @@ Description
patchWriters,
meshProxy,
objects,
true // syncPar
true, // syncPar
nullptr // no field cache (object registry)
);
// End CellData is implicit

View File

@ -8,20 +8,7 @@
Copyright (C) 2018-2022 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 <http://www.gnu.org/licenses/>.
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Code chunk for post-processing surface fields to VTK PolyData

View File

@ -8,20 +8,7 @@
Copyright (C) 2018-2021 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 <http://www.gnu.org/licenses/>.
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Code chunk for converting face and point sets - included by foamToVTK.

View File

@ -5,23 +5,10 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 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 <http://www.gnu.org/licenses/>.
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Code chunk for converting volume and dimensioned fields
@ -56,8 +43,14 @@ Description
);
reportFields::volume(Info, objects);
reportFields::internal(Info, objects);
if (doInternal || doBoundary)
{
reportFields::volume(Info, objects);
}
if (doInternal)
{
reportFields::internal(Info, objects);
}
// Setup for the vtm writer.
@ -269,6 +262,26 @@ Description
patchInterps.resize(nPatchInterps);
}
// With point-interpolation, cache fields to avoid multiple re-reading
std::unique_ptr<objectRegistry> cacheFieldsPtr;
if (doPointValues && (nVolFields || nDimFields))
{
cacheFieldsPtr.reset
(
new objectRegistry
(
IOobject
(
"foamToVTK::volume",
runTime.timeName(),
runTime,
IOobject::NO_REGISTER
)
)
);
}
// CellData
{
@ -314,7 +327,8 @@ Description
patchWriters,
meshProxy,
objects,
true // syncPar
true, // syncPar
cacheFieldsPtr.get()
);
writeAllDimFields
@ -322,7 +336,8 @@ Description
internalWriter,
meshProxy,
objects,
true // syncPar
true, // syncPar
cacheFieldsPtr.get()
);
// End CellData is implicit
@ -373,7 +388,8 @@ Description
patchWriters, patchInterps,
meshProxy,
objects,
true // syncPar
true, // syncPar
cacheFieldsPtr.get()
);
writeAllDimFields
@ -381,7 +397,8 @@ Description
internalWriter, pInterp,
meshProxy,
objects,
true // syncPar
true, // syncPar
cacheFieldsPtr.get()
);
writeAllPointFields

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2022 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -49,14 +49,47 @@ Foam::tmp<GeoField> Foam::getField
(
const IOobject* io,
const fvMeshSubsetProxy& proxy,
const bool syncPar
const bool syncPar,
objectRegistry* cache
)
{
return
proxy.interpolate
tmp<GeoField> tfield;
if (io)
{
const word& fieldName = io->name();
if (cache)
{
// Get reference from cache if possible
tfield.cref(cache->cfindObject<GeoField>(fieldName));
if (tfield)
{
return tfield;
}
}
tfield = proxy.interpolate
(
getField<GeoField>(io, proxy.baseMesh(), syncPar)
);
if (tfield && cache)
{
// Move field to the cache
IOobject newIO(tfield(), *cache);
newIO.readOpt(IOobject::NO_READ);
newIO.writeOpt(IOobject::NO_WRITE);
tfield.ref().checkOut(); // Paranoid
cache->store(new GeoField(newIO, tfield));
tfield.cref(cache->cfindObject<GeoField>(fieldName));
}
}
return tfield;
}
@ -71,7 +104,12 @@ Foam::tmp<GeoField> Foam::getField
{
// Can do something with syncPar on failure ...
return getField<GeoField>(objects.findObject(fieldName), mesh, syncPar);
return getField<GeoField>
(
objects.findObject(fieldName),
mesh,
syncPar
);
}
@ -81,12 +119,19 @@ Foam::tmp<GeoField> Foam::getField
const fvMeshSubsetProxy& proxy,
const IOobjectList& objects,
const word& fieldName,
const bool syncPar
const bool syncPar,
objectRegistry* cache
)
{
// Can do something with syncPar on failure ...
return getField<GeoField>(objects.findObject(fieldName), proxy, syncPar);
return getField<GeoField>
(
objects.findObject(fieldName),
proxy,
syncPar,
cache
);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2022 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,10 +35,11 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef Foam_readFields_H
#define Foam_readFields_H
#ifndef FoamToVTK_readFields_H
#define FoamToVTK_readFields_H
#include "fvMeshSubsetProxy.H"
#include "objectRegistry.H"
#include "IOobjectList.H"
#include "PtrList.H"
@ -63,7 +64,8 @@ tmp<GeoField> getField
(
const IOobject* io,
const fvMeshSubsetProxy& proxy,
const bool syncPar
const bool syncPar,
objectRegistry* cache = nullptr
);
@ -78,14 +80,17 @@ tmp<GeoField> getField
);
//- Get the named field from the objects and subset it, or return nullptr
//- Return the named field from the optional cache (if found),
//- or get it from the objects and subset it (add to cache).
//- Return nullptr if nothing worked.
template<class GeoField>
tmp<GeoField> getField
(
const fvMeshSubsetProxy& proxy,
const IOobjectList& objects,
const word& fieldName,
const bool syncPar
const bool syncPar,
objectRegistry* cache = nullptr
);

View File

@ -5,38 +5,19 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 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 <http://www.gnu.org/licenses/>.
InNamespace
Foam
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Read finite-area fields from disk
Code chunk for reading finite-area fields from disk
and write with vtk::uindirectPatchGeoFieldsWriter
SourceFiles
writeAreaFields.H
\*---------------------------------------------------------------------------*/
#ifndef writeAreaFields_H
#define writeAreaFields_H
#ifndef FoamToVTK_writeAreaFields_H
#define FoamToVTK_writeAreaFields_H
#include "readFields.H"
#include "foamVtkIndPatchGeoFieldsWriter.H"
@ -49,25 +30,6 @@ namespace Foam
// Writer type for finite-area mesh + fields
typedef vtk::uindirectPatchGeoFieldsWriter vtkWriterType_areaMesh;
template<class GeoField>
bool writeAreaField
(
vtkWriterType_areaMesh& writer,
const tmp<GeoField>& tfield
)
{
if (tfield)
{
writer.write(tfield());
tfield.clear();
return true;
}
return false;
}
template<class GeoField>
label writeAreaFields
(
@ -81,15 +43,14 @@ label writeAreaFields
for (const word& fieldName : objects.sortedNames<GeoField>())
{
if
(
writeAreaField<GeoField>
(
writer,
getField<GeoField>(mesh, objects, fieldName, syncPar)
)
)
tmp<GeoField> tfield =
getField<GeoField>(mesh, objects, fieldName, syncPar);
if (tfield)
{
writer.write(tfield());
tfield.clear();
++count;
}
}

View File

@ -5,38 +5,19 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 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 <http://www.gnu.org/licenses/>.
InNamespace
Foam
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Read dimensioned fields from disk
Code chunk for reading dimensioned fields from disk
and write with vtk::internalWriter
SourceFiles
writeDimFields.H
\*---------------------------------------------------------------------------*/
#ifndef writeDimFields_H
#define writeDimFields_H
#ifndef FoamToVTK_writeDimFields_H
#define FoamToVTK_writeDimFields_H
#include "readFields.H"
#include "foamVtkInternalWriter.H"
@ -46,77 +27,31 @@ SourceFiles
namespace Foam
{
template<class GeoField>
bool writeDimField
(
autoPtr<vtk::internalWriter>& internalWriter,
const tmp<GeoField>& tfield
)
{
if (!tfield)
{
return false;
}
const auto& field = tfield();
if (internalWriter)
{
internalWriter->write(field);
}
tfield.clear();
return true;
}
template<class GeoField>
bool writeDimField
(
autoPtr<vtk::internalWriter>& internalWriter,
const autoPtr<volPointInterpolation>& pInterp,
const tmp<GeoField>& tfield
)
{
if (!tfield)
{
return false;
}
const auto& field = tfield();
if (internalWriter && pInterp)
{
internalWriter->write(field, *pInterp);
}
tfield.clear();
return true;
}
template<class GeoField>
label writeDimFields
(
autoPtr<vtk::internalWriter>& internalWriter,
const fvMeshSubsetProxy& proxy,
const IOobjectList& objects,
const bool syncPar
const bool syncPar,
objectRegistry* cache
)
{
// Sanity test
if (!internalWriter) return 0;
label count = 0;
for (const word& fieldName : objects.sortedNames<GeoField>())
{
if
(
writeDimField<GeoField>
(
internalWriter,
getField<GeoField>(proxy, objects, fieldName, syncPar)
)
)
tmp<GeoField> tfield =
getField<GeoField>(proxy, objects, fieldName, syncPar, cache);
if (tfield)
{
internalWriter->write(tfield());
tfield.clear();
++count;
}
}
@ -133,22 +68,25 @@ label writeDimFields
const fvMeshSubsetProxy& proxy,
const IOobjectList& objects,
const bool syncPar
const bool syncPar,
objectRegistry* cache
)
{
// Sanity test
if (!internalWriter || !pInterp) return 0;
label count = 0;
for (const word& fieldName : objects.sortedNames<GeoField>())
{
if
(
writeDimField<GeoField>
(
internalWriter, pInterp,
getField<GeoField>(proxy, objects, fieldName, syncPar)
)
)
tmp<GeoField> tfield =
getField<GeoField>(proxy, objects, fieldName, syncPar, cache);
if (tfield)
{
internalWriter->write(tfield(), *pInterp);
tfield.clear();
++count;
}
}
@ -163,9 +101,13 @@ label writeAllDimFields
const fvMeshSubsetProxy& proxy,
const IOobjectList& objects,
const bool syncPar
const bool syncPar,
objectRegistry* cache
)
{
// Sanity test
if (!internalWriter) return 0;
#undef foamToVtk_WRITE_FIELD
#define foamToVtk_WRITE_FIELD(FieldType) \
writeDimFields<FieldType> \
@ -173,7 +115,8 @@ label writeAllDimFields
internalWriter, \
proxy, \
objects, \
syncPar \
syncPar, \
cache \
)
label count = 0;
@ -195,9 +138,13 @@ label writeAllDimFields
const fvMeshSubsetProxy& proxy,
const IOobjectList& objects,
const bool syncPar
const bool syncPar,
objectRegistry* cache
)
{
// Sanity test
if (!internalWriter || !pInterp) return 0;
#undef foamToVtk_WRITE_FIELD
#define foamToVtk_WRITE_FIELD(FieldType) \
writeDimFields<FieldType> \
@ -205,7 +152,8 @@ label writeAllDimFields
internalWriter, pInterp, \
proxy, \
objects, \
syncPar \
syncPar, \
cache \
)
label count = 0;

View File

@ -5,38 +5,19 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 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 <http://www.gnu.org/licenses/>.
InNamespace
Foam
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Read point fields from disk
Code chunk for reading point fields from disk
and write with vtk::internalWriter and vtk::patchWriter
SourceFiles
writePointFields.H
\*---------------------------------------------------------------------------*/
#ifndef writePointFields_H
#define writePointFields_H
#ifndef FoamToVTK_writePointFields_H
#define FoamToVTK_writePointFields_H
#include "readFields.H"
#include "foamVtkInternalWriter.H"
@ -57,6 +38,9 @@ bool writePointField
const fvMeshSubsetProxy& proxy
)
{
// Sanity test
if (!internalWriter && patchWriters.empty()) return false;
if (!tfield)
{
return false;
@ -113,6 +97,9 @@ label writePointFields
const bool syncPar
)
{
// Sanity test
if (!internalWriter && patchWriters.empty()) return 0;
label count = 0;
for (const word& fieldName : objects.sortedNames<GeoField>())
@ -146,6 +133,9 @@ label writeAllPointFields
const bool syncPar
)
{
// Sanity test
if (!internalWriter && patchWriters.empty()) return 0;
const pointMesh& ptMesh = pointMesh::New(proxy.baseMesh());
#undef foamToVtk_WRITE_FIELD

View File

@ -8,30 +8,11 @@
Copyright (C) 2021 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 <http://www.gnu.org/licenses/>.
InNamespace
Foam
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Write surface fields from volume mesh
SourceFiles
writeSurfaceFields.H
\*---------------------------------------------------------------------------*/
#ifndef writeSurfaceFields_H

View File

@ -5,38 +5,19 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 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 <http://www.gnu.org/licenses/>.
InNamespace
Foam
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Read volume fields from disk
Code chunk for reading volume fields from disk
and write with vtk::internalWriter and vtk::patchWriter
SourceFiles
writeVolFields.H
\*---------------------------------------------------------------------------*/
#ifndef writeVolFields_H
#define writeVolFields_H
#ifndef FoamToVTK_writeVolFields_H
#define FoamToVTK_writeVolFields_H
#include "readFields.H"
#include "foamVtkInternalWriter.H"
@ -47,79 +28,6 @@ SourceFiles
namespace Foam
{
template<class GeoField>
bool writeVolField
(
autoPtr<vtk::internalWriter>& internalWriter,
UPtrList<vtk::patchWriter>& patchWriters,
const tmp<GeoField>& tfield
)
{
if (!tfield)
{
return false;
}
const auto& field = tfield();
// Internal
if (internalWriter)
{
internalWriter->write(field);
}
// Boundary
for (vtk::patchWriter& writer : patchWriters)
{
writer.write(field);
}
tfield.clear();
return true;
}
template<class GeoField>
bool writeVolField
(
autoPtr<vtk::internalWriter>& internalWriter,
const autoPtr<volPointInterpolation>& pInterp,
UPtrList<vtk::patchWriter>& patchWriters,
const UPtrList<PrimitivePatchInterpolation<primitivePatch>>& patchInterps,
const tmp<GeoField>& tfield
)
{
if (!tfield)
{
return false;
}
const auto& field = tfield();
// Internal
if (internalWriter && pInterp)
{
internalWriter->write(field, *pInterp);
}
// Boundary
label writeri = 0;
for (vtk::patchWriter& writer : patchWriters)
{
if (writeri < patchInterps.size() && patchInterps.set(writeri))
{
writer.write(field, patchInterps[writeri]);
}
++writeri;
}
tfield.clear();
return true;
}
template<class GeoField>
label writeVolFields
(
@ -127,23 +35,35 @@ label writeVolFields
UPtrList<vtk::patchWriter>& patchWriters,
const fvMeshSubsetProxy& proxy,
const IOobjectList& objects,
const bool syncPar
const bool syncPar,
objectRegistry* cache
)
{
// Sanity test
if (!internalWriter && patchWriters.empty()) return 0;
label count = 0;
for (const word& fieldName : objects.sortedNames<GeoField>())
{
if
(
writeVolField<GeoField>
(
internalWriter,
patchWriters,
getField<GeoField>(proxy, objects, fieldName, syncPar)
)
)
tmp<GeoField> tfield =
getField<GeoField>(proxy, objects, fieldName, syncPar, cache);
if (tfield)
{
// Internal
if (internalWriter)
{
internalWriter->write(tfield());
}
// Boundary
for (vtk::patchWriter& writer : patchWriters)
{
writer.write(tfield());
}
tfield.clear();
++count;
}
}
@ -163,23 +83,47 @@ label writeVolFields
const fvMeshSubsetProxy& proxy,
const IOobjectList& objects,
const bool syncPar
const bool syncPar,
objectRegistry* cache
)
{
// Sanity test
if
(
(!internalWriter || !pInterp)
&& (patchWriters.empty() || patchInterps.empty())
)
{
return 0;
}
label count = 0;
for (const word& fieldName : objects.sortedNames<GeoField>())
{
if
(
writeVolField<GeoField>
(
internalWriter, pInterp,
patchWriters, patchInterps,
getField<GeoField>(proxy, objects, fieldName, syncPar)
)
)
tmp<GeoField> tfield =
getField<GeoField>(proxy, objects, fieldName, syncPar, cache);
if (tfield)
{
// Internal
if (internalWriter && pInterp)
{
internalWriter->write(tfield(), *pInterp);
}
// Boundary
label writeri = 0;
for (vtk::patchWriter& writer : patchWriters)
{
if (writeri < patchInterps.size() && patchInterps.set(writeri))
{
writer.write(tfield(), patchInterps[writeri]);
}
++writeri;
}
tfield.clear();
++count;
}
}
@ -195,9 +139,13 @@ label writeAllVolFields
const fvMeshSubsetProxy& proxy,
const IOobjectList& objects,
const bool syncPar
const bool syncPar,
objectRegistry* cache
)
{
// Sanity test
if (!internalWriter && patchWriters.empty()) return 0;
#undef foamToVtk_WRITE_FIELD
#define foamToVtk_WRITE_FIELD(FieldType) \
writeVolFields<FieldType> \
@ -206,7 +154,8 @@ label writeAllVolFields
patchWriters, \
proxy, \
objects, \
syncPar \
syncPar, \
cache \
)
label count = 0;
@ -231,7 +180,8 @@ label writeAllVolFields
const fvMeshSubsetProxy& proxy,
const IOobjectList& objects,
const bool syncPar
const bool syncPar,
objectRegistry* cache
)
{
#undef foamToVtk_WRITE_FIELD
@ -242,7 +192,8 @@ label writeAllVolFields
patchWriters, patchInterps, \
proxy, \
objects, \
syncPar \
syncPar, \
cache \
)