ENH: improve diagnostic fields for checkFaMesh -write-vtk

ENH: support VTK output of procIDs for point data for some writers

TUT: areaWrite for drippingChair
This commit is contained in:
Mark Olesen
2023-03-01 20:52:11 +01:00
parent 4284d02c99
commit d5c0852de1
18 changed files with 182 additions and 43 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd. Copyright (C) 2021-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later. This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -76,9 +76,9 @@ Description
writer.beginCellData(4); writer.beginCellData(4);
writer.writeProcIDs(); writer.writeProcIDs();
{ {
// Use primitive patch order
Field<scalar> fld Field<scalar> fld
( (
// Use primitive patch order
faMeshTools::flattenEdgeField(aMesh.magLe(), true) faMeshTools::flattenEdgeField(aMesh.magLe(), true)
); );
writer.write("magLe", fld); writer.write("magLe", fld);
@ -93,11 +93,17 @@ Description
} }
{ {
const Field<vector> edgeCentres
(
// Use primitive patch order
faMeshTools::flattenEdgeField(aMesh.edgeCentres(), true)
);
// finiteArea - edgeCentres // finiteArea - edgeCentres
// (no other convenient way to display vectors on the edges) // (no other convenient way to display vectors on the edges)
vtk::lineWriter writer vtk::lineWriter writer
( (
aMesh.edgeCentres(), edgeCentres,
edgeList::null(), edgeList::null(),
// vtk::formatType::INLINE_ASCII, // vtk::formatType::INLINE_ASCII,
fileName fileName
@ -109,19 +115,20 @@ Description
writer.writeGeometry(); writer.writeGeometry();
// PointData // PointData
writer.beginPointData(4); writer.beginPointData(3);
writer.writeProcIDs(); // Unfortunately cannot threshold on points
{ {
// Use primitive patch order
Field<vector> fld Field<vector> fld
( (
// Use primitive patch order
faMeshTools::flattenEdgeField(aMesh.Le(), true) faMeshTools::flattenEdgeField(aMesh.Le(), true)
); );
writer.write("Le", fld); writer.write("Le", fld);
} }
{ {
// Use primitive patch order
Field<vector> fld Field<vector> fld
( (
// Use primitive patch order
faMeshTools::flattenEdgeField(aMesh.edgeAreaNormals(), true) faMeshTools::flattenEdgeField(aMesh.edgeAreaNormals(), true)
); );
writer.write("normal", fld); writer.write("normal", fld);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd. Copyright (C) 2018-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -76,11 +76,11 @@ Foam::Ostream& Foam::vtk::fileWriter::reportBadState
Foam::Ostream& Foam::vtk::fileWriter::reportBadState Foam::Ostream& Foam::vtk::fileWriter::reportBadState
( (
Ostream& os, Ostream& os,
outputState expected, outputState expected1,
outputState expected2 outputState expected2
) const ) const
{ {
reportBadState(os, expected) reportBadState(os, expected1)
<< " or (" << stateNames[expected2] << ')'; << " or (" << stateNames[expected2] << ')';
return os; return os;
} }
@ -554,10 +554,18 @@ bool Foam::vtk::fileWriter::writeProcIDs(const label nValues)
{ {
++nCellData_; ++nCellData_;
} }
else if (isState(outputState::POINT_DATA))
{
++nPointData_;
}
else else
{ {
reportBadState(FatalErrorInFunction, outputState::CELL_DATA) reportBadState
<< " for procID field" << nl << endl (
FatalErrorInFunction,
outputState::CELL_DATA,
outputState::POINT_DATA
) << " for procID field" << nl << endl
<< exit(FatalError); << exit(FatalError);
return false; return false;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd. Copyright (C) 2018-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -201,7 +201,8 @@ protected:
const UList<Type>& field const UList<Type>& field
); );
//- Write nValues of processor ids as CellData (no-op in serial) //- Write nValues of processor ids as CellData or PointData
//- (no-op in serial)
bool writeProcIDs(const label nValues); bool writeProcIDs(const label nValues);
@ -305,10 +306,16 @@ public:
// \return True if the state changed // \return True if the state changed
virtual bool beginPointData(label nFields = 0) = 0; virtual bool beginPointData(label nFields = 0) = 0;
//- Return the number of CellData written for the Piece thus far. //- True if output state corresponds to CELL_DATA
inline bool isCellData() const noexcept;
//- True if output state corresponds to POINT_DATA
inline bool isPointData() const noexcept;
//- The number of CellData written for the Piece thus far.
inline label nCellData() const noexcept; inline label nCellData() const noexcept;
//- Return the number of PointData written for the Piece thus far. //- The number of PointData written for the Piece thus far.
inline label nPointData() const noexcept; inline label nPointData() const noexcept;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd. Copyright (C) 2018-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -107,4 +107,16 @@ inline Foam::label Foam::vtk::fileWriter::nPointData() const noexcept
} }
inline bool Foam::vtk::fileWriter::isCellData() const noexcept
{
return (outputState::CELL_DATA == state_);
}
inline bool Foam::vtk::fileWriter::isPointData() const noexcept
{
return (outputState::POINT_DATA == state_);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -131,6 +131,10 @@ void Foam::vtk::lineWriter::piece
bool Foam::vtk::lineWriter::writeProcIDs() bool Foam::vtk::lineWriter::writeProcIDs()
{ {
if (this->isPointData())
{
return vtk::fileWriter::writeProcIDs(nLocalPoints_);
}
return vtk::fileWriter::writeProcIDs(nLocalLines_); return vtk::fileWriter::writeProcIDs(nLocalLines_);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -155,8 +155,8 @@ public:
void piece(const pointField& points, const edgeList& edges); void piece(const pointField& points, const edgeList& edges);
//- Write processor ids for each line as CellData //- Write processor ids for each line as CellData or for each point
//- (no-op in serial) //- as PointData, depending on isPointData() state. No-op in serial.
bool writeProcIDs(); bool writeProcIDs();
//- Write a uniform field of Cell (Line) or Point values //- Write a uniform field of Cell (Line) or Point values

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd. Copyright (C) 2018-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -131,6 +131,10 @@ void Foam::vtk::surfaceWriter::piece
bool Foam::vtk::surfaceWriter::writeProcIDs() bool Foam::vtk::surfaceWriter::writeProcIDs()
{ {
if (this->isPointData())
{
return vtk::fileWriter::writeProcIDs(nLocalPoints_);
}
return vtk::fileWriter::writeProcIDs(nLocalPolys_); return vtk::fileWriter::writeProcIDs(nLocalPolys_);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd. Copyright (C) 2018-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -155,8 +155,8 @@ public:
void piece(const pointField& points, const faceList& faces); void piece(const pointField& points, const faceList& faces);
//- Write processor ids for each poly as CellData //- Write processor ids for each poly as CellData or for each point
//- (no-op in serial) //- as PointData, depending on isPointData() state. No-op in serial.
bool writeProcIDs(); bool writeProcIDs();
//- Write a uniform field of Cell (Poly) or Point values //- Write a uniform field of Cell (Poly) or Point values

View File

@ -201,8 +201,9 @@ public:
void piece(const UPtrList<const pointField>& points); void piece(const UPtrList<const pointField>& points);
//- Write processor ids for each line as CellData //- Write processor ids for each line as CellData or for each point
//- (no-op in serial) //- as PointData, depending on isPointData() state. No-op in serial.
// Not implemented.
bool writeProcIDs(); bool writeProcIDs();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd. Copyright (C) 2018-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -159,6 +159,10 @@ public:
//- Write processor ids for each poly as CellData //- Write processor ids for each poly as CellData
bool writeProcIDs() bool writeProcIDs()
{ {
if (this->isPointData())
{
return vtk::fileWriter::writeProcIDs(nLocalPoints_);
}
return vtk::polyWriter::writeProcIDs(nLocalPolys_); return vtk::polyWriter::writeProcIDs(nLocalPolys_);
} }
}; };

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -585,6 +585,10 @@ void Foam::vtk::patchMeshWriter::writePatchIDs()
bool Foam::vtk::patchMeshWriter::writeProcIDs() bool Foam::vtk::patchMeshWriter::writeProcIDs()
{ {
if (this->isPointData())
{
return vtk::fileWriter::writeProcIDs(nLocalPoints_);
}
return vtk::fileWriter::writeProcIDs(nLocalPolys_); return vtk::fileWriter::writeProcIDs(nLocalPolys_);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -209,8 +209,8 @@ public:
// Must be called within the CELL_DATA state. // Must be called within the CELL_DATA state.
void writePatchIDs(); void writePatchIDs();
//- Write processor ids as CellData. This is no-op in serial. //- Write processor ids for each line as CellData or for each point
// Must be called within the CELL_DATA state. //- as PointData, depending on isPointData() state. No-op in serial.
bool writeProcIDs(); bool writeProcIDs();
//- Write processor neighbour ids as CellData. This is no-op in serial. //- Write processor neighbour ids as CellData. This is no-op in serial.

View File

@ -3,19 +3,30 @@ cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions . ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
unset decompDict
# decompDict=system/decomposeParDict-6
# decompDict=system/decomposeParDict-7
runApplication blockMesh runApplication blockMesh
runApplication makeFaMesh runApplication makeFaMesh
runApplication decomposePar runApplication -decompose-dict="$decompDict" decomposePar
# For the processor partitioning # For ids and processor partitioning
runParallel -s finiteVolume foamToVTK -name VTK-parallel -time 0 \ runParallel -s volume -decompose-dict="$decompDict" \
-no-finite-area -no-internal -no-lagrangian -no-fields -with-ids foamToVTK -name VTK-parallel -time 0 \
-no-finite-area -no-internal -no-lagrangian -no-fields -with-ids \
-patches filmWalls
runParallel $(getApplication) runParallel -decompose-dict="$decompDict" $(getApplication)
runParallel -s finiteArea foamToVTK -name VTK-parallel \ if false
-no-boundary -no-internal -no-lagrangian then
# Not usually needed - uses areaWrite
runParallel -s area -decompose-dict="$decompDict" \
foamToVTK -name VTK-parallel \
-no-boundary -no-internal -no-lagrangian -with-ids
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -7,13 +7,18 @@ runApplication blockMesh
runApplication makeFaMesh runApplication makeFaMesh
# For the cell ids etc # For ids and processor partitioning
runApplication -s finiteVolume.serial foamToVTK -name VTK-serial -time 0 \ runApplication -s volume.serial foamToVTK -name VTK-serial -time 0 \
-no-finite-area -no-internal -no-lagrangian -no-fields -with-ids -no-finite-area -no-internal -no-lagrangian -no-fields -with-ids \
-patches filmWalls
runApplication $(getApplication) runApplication $(getApplication)
runApplication -s finiteArea.serial foamToVTK -name VTK-serial \ if false
-no-boundary -no-internal -no-lagrangian then
# Not usually needed - uses areaWrite
runApplication -s area.serial foamToVTK -name VTK-serial \
-no-boundary -no-internal -no-lagrangian
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -0,0 +1,25 @@
// -*- C++ -*-
// Use the areaWrite function object
areaWrite
{
type areaWrite;
libs (utilityFunctionObjects);
log true;
writeControl writeTime;
writeInterval 1;
// Fields to output (words or regex)
fields (Uf_film hf_film pf_film);
surfaceFormat ensight;
formatOptions
{
default { format binary; }
}
}
// ************************************************************************* //

View File

@ -52,5 +52,10 @@ regionFaMaxCo 1;
maxDeltaT 0.1; maxDeltaT 0.1;
functions
{
#include "areaWrite"
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 6;
method scotch;
// ************************************************************************* //

View File

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 7;
method scotch;
// ************************************************************************* //