ENH: processorField: provision for mesh changes. Fixes #2319

This commit is contained in:
mattijs
2022-01-06 10:21:44 +00:00
parent 34e226dfe3
commit 99b2550af2
2 changed files with 33 additions and 4 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -68,11 +68,11 @@ Foam::functionObjects::processorField::processorField
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
mesh_, mesh_,
dimensionedScalar(dimless, Zero) dimensionedScalar(dimless, Pstream::myProcNo())
) )
); );
mesh_.objectRegistry::store(procFieldPtr); mesh_.thisDb().store(procFieldPtr);
} }
@ -109,4 +109,29 @@ bool Foam::functionObjects::processorField::write()
} }
void Foam::functionObjects::processorField::updateMesh(const mapPolyMesh& mpm)
{
const_cast<objectRegistry&>(mesh_.thisDb()).erase("processorID");
volScalarField* procFieldPtr
(
new volScalarField
(
IOobject
(
"processorID",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar(dimless, Pstream::myProcNo())
)
);
mesh_.thisDb().store(procFieldPtr);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -138,6 +138,10 @@ public:
//- Write the processorID field //- Write the processorID field
virtual bool write(); virtual bool write();
//- Update for changes of mesh
// The base implementation is a no-op.
virtual void updateMesh(const mapPolyMesh& mpm);
}; };