diff --git a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C index 1a195e360067a55c75931ae294c340663fd467d1..1b195acc0322956076116ac4dd7f71335a82c787 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<FieldType> subsetFields const pointMesh& pMesh ) { - const fvMesh& baseMesh = subsetter.baseMesh(); + //const fvMesh& baseMesh = subsetter.baseMesh(); const UPtrList<const IOobject> fieldObjects ( @@ -247,8 +247,8 @@ PtrList<FieldType> 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> + ( + pointMesh::typeName + ); + if (subPointMeshPtr) + { + pointMesh& subPointMesh = const_cast<pointMesh&>(*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 c5b8766ec0135e3f80db939d7ed023967b8bf888..6459c4580f03a1c14e31bb3cf30c9041bc7b63df 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>(pointMesh::typeName)) + const auto* pMeshPtr = + thisDb().cfindObject<pointMesh>(pointMesh::typeName); + if (pMeshPtr) { - const auto& pMesh = thisDb().lookupObject<pointMesh> - ( - 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 56f7504ebcb855e76fe32faa039e7e3b7a7bd7aa..d13ae38f64a79fdb813b9506a12aa712cd912e4a 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;