ENH: pointMesh: support for subsetMesh

This commit is contained in:
mattijs 2024-02-19 11:35:51 +00:00
parent 343126df7b
commit a4aa16b509
3 changed files with 24 additions and 10 deletions

View File

@ -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(); }

View File

@ -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();

View File

@ -17,6 +17,7 @@ FoamFile
DebugSwitches
{
pointBoundaryMesh 1;
fvMeshSubset 1;
}
application blockMesh;