Skip to content
Commits on Source (3)
......@@ -16,6 +16,14 @@ set(PROJECT_REQUIRED_MODULES
ParaView::RemotingCore
)
# Catalyst package (ParaView > 5.8)
if (catalyst_FOUND)
set(PROJECT_REQUIRED_MODULES
${PROJECT_REQUIRED_MODULES}
catalyst::catalyst
)
endif()
if (${OLDVTK_NO_MODULES})
# No modules for older VTK. Reuse for MPI handling
unset(PROJECT_REQUIRED_MODULES)
......@@ -32,6 +40,8 @@ if (TARGET VTK::ParallelMPI)
set(FOAM_USING_VTK_MPI TRUE)
endif()
message("Modules: ${PROJECT_REQUIRED_MODULES}")
#-----------------------------------------------------------------------------
# Build directly into library target. FOAM_MPI env for some versioning
......
......@@ -41,10 +41,9 @@ set(OLDVTK_NO_MODULES FALSE)
if (("${VTK_MAJOR_VERSION}" LESS 8) OR
(("${VTK_MAJOR_VERSION}" EQUAL 8) AND ("${VTK_MINOR_VERSION}" LESS 10)))
set(OLDVTK_NO_MODULES TRUE)
message("Using older VTK (no modules)")
endif()
message("OLDVTK_NO_MODULES is ${OLDVTK_NO_MODULES}")
#-----------------------------------------------------------------------------
# New ParaView/VTK: load optional MPI via VTK
......@@ -67,6 +66,12 @@ else()
find_package(ParaView REQUIRED
COMPONENTS PythonCatalyst RemotingCore
OPTIONAL_COMPONENTS VTK::ParallelMPI)
# Catalyst package (ParaView > 5.8)
if (("${PARAVIEW_VERSION_MAJOR}" GREATER 5) OR
("${PARAVIEW_VERSION_MINOR}" GREATER 8))
find_package(catalyst REQUIRED)
endif()
endif()
#-----------------------------------------------------------------------------
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -147,15 +147,14 @@ void Foam::vtkPVblockMesh::updateInfoEdges
rangeEdges_.reset(select->GetNumberOfArrays());
const blockMesh& blkMesh = *meshPtr_;
const blockEdgeList& edges = blkMesh.edges();
forAll(edges, edgeI)
for (const blockEdge& blkEdge : blkMesh.edges())
{
OStringStream ostr;
blockVertex::write(ostr, edges[edgeI].start(), blkMesh.meshDict());
blockVertex::write(ostr, blkEdge.start(), blkMesh.meshDict());
ostr<< ":";
blockVertex::write(ostr, edges[edgeI].end(), blkMesh.meshDict());
ostr << " - " << edges[edgeI].type();
blockVertex::write(ostr, blkEdge.end(), blkMesh.meshDict());
ostr << " - " << blkEdge.type();
// Add "beg:end - type" to GUI list
select->AddArray(ostr.str().c_str());
......@@ -429,8 +428,13 @@ void Foam::vtkPVblockMesh::renderPatchNames
{
const blockMesh& blkMesh = *meshPtr_;
const dictionary& meshDescription = blkMesh.meshDict();
const pointField& cornerPts = blkMesh.vertices();
const scalar scaleFactor = blkMesh.scaleFactor();
#if (OPENFOAM <= 2106)
const pointField cornerPts(blkMesh.vertices() * blkMesh.scaleFactor());
#else
const tmp<pointField> tcornerPts(blkMesh.vertices(true));
const auto& cornerPts = tcornerPts();
#endif
if (!meshDescription.found("boundary"))
{
......@@ -447,10 +451,8 @@ void Foam::vtkPVblockMesh::renderPatchNames
// Read like boundary file
const PtrList<entry> patchesInfo(meshDescription.lookup("boundary"));
forAll(patchesInfo, patchi)
for (const entry& patchInfo : patchesInfo)
{
const entry& patchInfo = patchesInfo[patchi];
if (!patchInfo.isDict())
{
IOWarningInFunction(meshDescription)
......@@ -469,15 +471,13 @@ void Foam::vtkPVblockMesh::renderPatchNames
varDict
);
forAll(patchFaces, facei)
for (const face& f : patchFaces)
{
const face& f = patchFaces[facei];
// Into a list for later removal
patchTextActors_[nActors++] = createTextActor
(
patchName,
f.centre(cornerPts) * scaleFactor
f.centre(cornerPts)
);
if (nActors == patchTextActors_.size())
......@@ -522,10 +522,14 @@ void Foam::vtkPVblockMesh::renderPointNumbers
if (show && meshPtr_)
{
const blockMesh& blkMesh = *meshPtr_;
const pointField& cornerPts = blkMesh.vertices();
const scalar scaleFactor = blkMesh.scaleFactor();
pointTextActors_.setSize(cornerPts.size());
#if (OPENFOAM <= 2106)
const pointField cornerPts(blkMesh.vertices() * blkMesh.scaleFactor());
#else
const tmp<pointField> tcornerPts(blkMesh.vertices(true));
const auto& cornerPts = tcornerPts();
#endif
pointTextActors_.resize(cornerPts.size());
forAll(cornerPts, pointi)
{
// Display either pointi as a number or with its name
......@@ -537,7 +541,7 @@ void Foam::vtkPVblockMesh::renderPointNumbers
pointTextActors_[pointi] = createTextActor
(
os.str(),
cornerPts[pointi]*scaleFactor
cornerPts[pointi]
);
}
}
......@@ -564,4 +568,5 @@ void Foam::vtkPVblockMesh::PrintSelf(ostream& os, vtkIndent indent) const
#endif
}
// ************************************************************************* //
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -64,9 +64,14 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
label datasetNo = 0; // restart at dataset 0
const blockMesh& blkMesh = *meshPtr_;
#if (OPENFOAM <= 2106)
const pointField blkPoints(blkMesh.vertices() * blkMesh.scaleFactor());
#else
const tmp<pointField> tblkPoints(blkMesh.vertices(true));
const auto& blkPoints = tblkPoints();
#endif
vtkIdType nodeIds[8]; // Space for VTK_HEXAHEDRON vertices
vtkIdType nodeIds[8]; // Exact space for VTK_HEXAHEDRON vertices
int blockId = -1;
for (auto partId : range)
{
......@@ -138,7 +143,21 @@ void Foam::vtkPVblockMesh::convertMeshEdges
const blockMesh& blkMesh = *meshPtr_;
const blockEdgeList& edges = blkMesh.edges();
const scalar scaleFactor = blkMesh.scaleFactor();
#if (OPENFOAM <= 2106)
// Edge point and weighting factors for all hex edges
DynamicList<vtkIdType> pointIds;
pointField edgesPoints[12];
scalarList edgesWeights[12];
#else
// Use 8 uniform divisions for visualization purposes (smooth enough)
constexpr label nEdgeDivs = 4;
List<vtkIdType> pointIds(nEdgeDivs + 1);
// Edge point and weighting factors for a specified hex edge
pointField cedgePoints;
scalarList cedgeWeights;
#endif
int edgeId = -1;
for (auto partId : range)
......@@ -151,41 +170,52 @@ void Foam::vtkPVblockMesh::convertMeshEdges
const auto& longName = edgeStatus[partId];
// Search each block
forAll(blkMesh, blockId)
for (const blockDescriptor& blockDef : blkMesh)
{
const blockDescriptor& blockDef = blkMesh[blockId];
edgeList blkEdges = blockDef.blockShape().edges();
edgeList blkEdges(blockDef.blockShape().edges());
// List of edge point and weighting factors
pointField edgesPoints[12];
scalarList edgesWeights[12];
blockDef.edgesPointsWeights(edgesPoints, edgesWeights);
// find the corresponding edge within the block
label foundEdgeI = -1;
forAll(blkEdges, blkEdgeI)
// Find the corresponding edge within the block
label foundEdgei = -1;
forAll(blkEdges, blkEdgei)
{
if (edges[edgeId].compare(blkEdges[blkEdgeI]))
if (edges[edgeId].compare(blkEdges[blkEdgei]))
{
foundEdgeI = blkEdgeI;
foundEdgei = blkEdgei;
break;
}
}
if (foundEdgeI != -1)
if (foundEdgei != -1)
{
const List<point>& edgePoints = edgesPoints[foundEdgeI];
#if (OPENFOAM <= 2106)
blockDef.edgesPointsWeights(edgesPoints, edgesWeights);
const pointField edgePoints
(
edgesPoints[foundEdgei] * blkMesh.scaleFactor()
);
#else
blockDef.edgePointsWeights
(
foundEdgei,
cedgePoints,
cedgeWeights,
nEdgeDivs
);
tmp<pointField> tedgePoints =
blkMesh.globalPosition(cedgePoints);
const auto& edgePoints = tedgePoints();
#endif
auto vtkpoints = vtkSmartPointer<vtkPoints>::New();
vtkpoints->SetNumberOfPoints(edgePoints.size());
vtkIdType pointIds[edgePoints.size()];
pointIds.resize(edgePoints.size());
forAll(edgePoints, pointi)
{
const point p = edgePoints[pointi] * scaleFactor;
vtkpoints->SetPoint(pointi, p.v_);
vtkpoints->SetPoint(pointi, edgePoints[pointi].v_);
pointIds[pointi] = pointi;
}
......@@ -196,7 +226,7 @@ void Foam::vtkPVblockMesh::convertMeshEdges
(
VTK_POLY_LINE,
edgePoints.size(),
pointIds
pointIds.cdata()
);
vtkmesh->SetPoints(vtkpoints);
......@@ -229,7 +259,13 @@ void Foam::vtkPVblockMesh::convertMeshCorners
range.block(blockNo); // set output block
label datasetNo = 0; // restart at dataset 0
const pointField blkPoints(meshPtr_->vertices() * meshPtr_->scaleFactor());
const blockMesh& blkMesh = *meshPtr_;
#if (OPENFOAM <= 2106)
const pointField blkPoints(blkMesh.vertices() * blkMesh.scaleFactor());
#else
const tmp<pointField> tblkPoints(blkMesh.vertices(true));
const auto& blkPoints = tblkPoints();
#endif
DebugInfo << "<beg> " << FUNCTION_NAME << endl;
......
......@@ -4,10 +4,11 @@ cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------
cleanTimeDirectories
cleanAuxiliary 2>/dev/null
cleanPostProcessing
cleanFaMesh
rm -rf processor*
rm -rf insitu
#------------------------------------------------------------------------------