diff --git a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C index 1a195e3600..1b195acc03 100644 --- a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C +++ b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2023 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -220,7 +220,7 @@ PtrList subsetFields const pointMesh& pMesh ) { - const fvMesh& baseMesh = subsetter.baseMesh(); + //const fvMesh& baseMesh = subsetter.baseMesh(); const UPtrList fieldObjects ( @@ -247,8 +247,8 @@ PtrList subsetFields IOobject ( io.name(), - baseMesh.time().timeName(), - baseMesh, + pMesh.thisDb().time().timeName(), + pMesh.thisDb(), IOobjectOption::MUST_READ, IOobjectOption::NO_WRITE, IOobjectOption::NO_REGISTER @@ -382,6 +382,8 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createNamedMesh.H" + // Make sure pointMesh gets constructed/read as well + (void)pointMesh::New(mesh, IOobject::READ_IF_PRESENT); // arg[1] = word (cellSet) or wordRes (cellZone) // const word selectionName = args[1]; @@ -583,7 +585,7 @@ int main(int argc, char *argv[]) // Read point fields and subset // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - const pointMesh& pMesh = pointMesh::New(mesh); + const pointMesh& pMesh = pointMesh::New(mesh, IOobject::READ_IF_PRESENT); #undef createSubsetFields #define createSubsetFields(FieldType, Variable) \ @@ -663,6 +665,18 @@ int main(int argc, char *argv[]) subsetter.subMesh().write(); processorMeshes::removeFiles(subsetter.subMesh()); + auto* subPointMeshPtr = + subsetter.subMesh().thisDb().findObject + ( + pointMesh::typeName + ); + if (subPointMeshPtr) + { + pointMesh& subPointMesh = const_cast(*subPointMeshPtr); + subPointMesh.setInstance(subsetter.subMesh().facesInstance()); + subPointMesh.write(); + } + // Volume fields for (const auto& fld : vScalarFlds) { fld.write(); } diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C index c5b8766ec0..6459c4580f 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C @@ -747,12 +747,11 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets) procMesh.write(); // Add pointMesh if it was available - if (thisDb().foundObject(pointMesh::typeName)) + const auto* pMeshPtr = + thisDb().cfindObject(pointMesh::typeName); + if (pMeshPtr) { - const auto& pMesh = thisDb().lookupObject - ( - pointMesh::typeName - ); + const auto& pMesh = *pMeshPtr; const auto& pMeshBoundary = pMesh.boundary(); diff --git a/tutorials/mesh/blockMesh/sphere7/system/controlDict b/tutorials/mesh/blockMesh/sphere7/system/controlDict index 56f7504ebc..d13ae38f64 100644 --- a/tutorials/mesh/blockMesh/sphere7/system/controlDict +++ b/tutorials/mesh/blockMesh/sphere7/system/controlDict @@ -17,6 +17,7 @@ FoamFile DebugSwitches { pointBoundaryMesh 1; + fvMeshSubset 1; } application blockMesh;