diff --git a/src/overset/oversetMesh/oversetAdjustPhi/oversetAdjustPhi.C b/src/overset/oversetMesh/oversetAdjustPhi/oversetAdjustPhi.C index 31086ad42..2f40298be 100644 --- a/src/overset/oversetMesh/oversetAdjustPhi/oversetAdjustPhi.C +++ b/src/overset/oversetMesh/oversetAdjustPhi/oversetAdjustPhi.C @@ -59,7 +59,7 @@ void Foam::oversetAdjustPhi const unallocLabelList& neighbour = mesh.neighbour(); // Get region split to identify separate mesh components - const labelList& regionID = om.regionID(); + const scalarField& regionID = om.regionID().internalField(); // Sum up incoming and outgoing flux scalar fringeIn = 0; @@ -80,8 +80,12 @@ void Foam::oversetAdjustPhi { // Internal face - // Debug check - if (regionID[owner[curFace]] != regionID[neighbour[curFace]]) + // Debug check. Note: use notEqual since we are comparing two + // scalars + if + ( + notEqual(regionID[owner[curFace]], regionID[neighbour[curFace]]) + ) { FatalErrorIn ( diff --git a/src/overset/oversetMesh/oversetAdjustPhi/regionWiseOversetAdjustPhi.C b/src/overset/oversetMesh/oversetAdjustPhi/regionWiseOversetAdjustPhi.C index 21d25cb47..73e682e49 100644 --- a/src/overset/oversetMesh/oversetAdjustPhi/regionWiseOversetAdjustPhi.C +++ b/src/overset/oversetMesh/oversetAdjustPhi/regionWiseOversetAdjustPhi.C @@ -60,7 +60,7 @@ void Foam::regionWiseOversetAdjustPhi const unallocLabelList& neighbour = mesh.neighbour(); // Get region split to identify separate mesh components - const labelList& regionID = om.regionID(); + const scalarField& regionID = om.regionID().internalField(); // Incoming and outgoing region fluxes scalarField regionIn(om.regions().size(), 0); @@ -94,7 +94,7 @@ void Foam::regionWiseOversetAdjustPhi // scaled forAll (phip, i) { - // Get current region index + // Get current region index. Note: conversion to label const label curRegion = regionID[fc[i]]; if (phip[i] < 0.0) @@ -124,11 +124,12 @@ void Foam::regionWiseOversetAdjustPhi { // Internal face - // Get region index + // Get region index. Note: conversion to label const label curRegion = regionID[owner[curFace]]; - // Check whether owner and neighbour belong to the same region - if (curRegion != regionID[neighbour[curFace]]) + // Check whether owner and neighbour belong to the same region. + // Note: use notEqual function since we are comparing two scalars + if (notEqual(curRegion, regionID[neighbour[curFace]])) { FatalErrorIn ( @@ -210,7 +211,7 @@ void Foam::regionWiseOversetAdjustPhi { // Processor patch, master side - // Get region index + // Get region index. Note: conversion to label const label curRegion = regionID[mesh.boundary()[patchI].faceCells()[faceI]]; @@ -321,7 +322,7 @@ void Foam::regionWiseOversetAdjustPhi { // Internal face - // Get region index + // Get region index. Note: conversion to label const label curRegion = regionID[owner[curFace]]; // Get reference to the flux for scaling @@ -358,7 +359,7 @@ void Foam::regionWiseOversetAdjustPhi if (procPatch.master()) // Owner side { - // Get region index + // Get region index. Note: conversion to label const label curRegion = regionID[mesh.boundary()[patchI].faceCells()[faceI]]; @@ -374,7 +375,7 @@ void Foam::regionWiseOversetAdjustPhi } else // Neighbouring processor side { - // Get region index + // Get region index. Note: conversion to label const label curRegion = regionID[mesh.boundary()[patchI].faceCells()[faceI]]; diff --git a/src/overset/oversetMesh/oversetMesh/oversetMesh.H b/src/overset/oversetMesh/oversetMesh/oversetMesh.H index 19bb07a72..1cc7092d0 100644 --- a/src/overset/oversetMesh/oversetMesh/oversetMesh.H +++ b/src/overset/oversetMesh/oversetMesh/oversetMesh.H @@ -121,8 +121,9 @@ private: //- Return overset type indicator field mutable volScalarField* oversetTypesPtr_; - //- Region ID: region index for each cell - mutable labelList* regionIDPtr_; + //- Region ID: region index for each cell as a volScalarField for + // visualization. VV, 15/Apr/2019 + mutable volScalarField* regionIDPtr_; // Overset discretisation support @@ -286,7 +287,7 @@ public: const volScalarField& oversetTypes() const; //- Return region indicator - const labelList& regionID() const; + const volScalarField& regionID() const; // Overset discretisation support diff --git a/src/overset/oversetMesh/oversetMesh/oversetMeshAddressing.C b/src/overset/oversetMesh/oversetMesh/oversetMeshAddressing.C index a3bd410cd..f59e5e030 100644 --- a/src/overset/oversetMesh/oversetMesh/oversetMeshAddressing.C +++ b/src/overset/oversetMesh/oversetMesh/oversetMeshAddressing.C @@ -27,6 +27,7 @@ License #include "surfaceFields.H" #include "volFields.H" #include "polyPatchID.H" +#include "oversetFvPatchFields.H" #include "demandDrivenData.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -190,24 +191,52 @@ void Foam::oversetMesh::calcDomainMarkup() const } } - // Region ID - regionIDPtr_ = new labelList(mesh().nCells(), -1); - labelList& rID = *regionIDPtr_; - - // Mark regions + // Region ID, initialized with -1 for sanity check later on + regionIDPtr_ = new volScalarField + ( + IOobject + ( + "regionIndex", + mesh().time().timeName(), + mesh(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh(), + dimensionedScalar("minusOne", dimless, -1.0), + "zeroGradient" + ); + volScalarField& regionID = *regionIDPtr_; + scalarField& regionIDIn = regionID.internalField(); + // Mark regions (internal field) forAll (regions_, regionI) { const labelList& curCells = regions_[regionI].zone(); forAll (curCells, curCellI) { - rID[curCells[curCellI]] = regionI; + regionIDIn[curCells[curCellI]] = regionI; + } + } + + // Update boundary values, making sure that we skip the overset patch + volScalarField::GeometricBoundaryField& regionIDb = + regionID.boundaryField(); + + forAll (regionIDb, patchI) + { + // Get the patch field + fvPatchScalarField& ripf = regionIDb[patchI]; + + if (!isA(ripf)) + { + ripf = ripf.patchInternalField(); } } // Check regions - if (min(rID) < 0) + if (min(regionID).value() < 0) { FatalErrorIn("void oversetMesh::calcDomainMarkup() const") << "Found cells without region ID. Please check overset setup" @@ -1166,7 +1195,7 @@ const Foam::volScalarField& Foam::oversetMesh::oversetTypes() const } -const Foam::labelList& Foam::oversetMesh::regionID() const +const Foam::volScalarField& Foam::oversetMesh::regionID() const { if (!regionIDPtr_) {