mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: avoid refCast in favour of the fvMeshFunctionObject mesh_ variable
This commit is contained in:
@ -79,21 +79,19 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZone
|
|||||||
DynamicList<List<scalar>>& faceSign
|
DynamicList<List<scalar>>& faceSign
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
label zonei = mesh_.faceZones().findZoneID(faceZoneName);
|
||||||
|
|
||||||
label zonei = mesh.faceZones().findZoneID(faceZoneName);
|
|
||||||
|
|
||||||
if (zonei == -1)
|
if (zonei == -1)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unable to find faceZone " << faceZoneName
|
<< "Unable to find faceZone " << faceZoneName
|
||||||
<< ". Valid faceZones are: " << mesh.faceZones().names()
|
<< ". Valid faceZones are: " << mesh_.faceZones().names()
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
faceZoneNames.append(faceZoneName);
|
faceZoneNames.append(faceZoneName);
|
||||||
|
|
||||||
const faceZone& fZone = mesh.faceZones()[zonei];
|
const faceZone& fZone = mesh_.faceZones()[zonei];
|
||||||
|
|
||||||
DynamicList<label> faceIDs(fZone.size());
|
DynamicList<label> faceIDs(fZone.size());
|
||||||
DynamicList<label> facePatchIDs(fZone.size());
|
DynamicList<label> facePatchIDs(fZone.size());
|
||||||
@ -105,15 +103,15 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZone
|
|||||||
|
|
||||||
label faceID = -1;
|
label faceID = -1;
|
||||||
label facePatchID = -1;
|
label facePatchID = -1;
|
||||||
if (mesh.isInternalFace(facei))
|
if (mesh_.isInternalFace(facei))
|
||||||
{
|
{
|
||||||
faceID = facei;
|
faceID = facei;
|
||||||
facePatchID = -1;
|
facePatchID = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
facePatchID = mesh.boundaryMesh().whichPatch(facei);
|
facePatchID = mesh_.boundaryMesh().whichPatch(facei);
|
||||||
const polyPatch& pp = mesh.boundaryMesh()[facePatchID];
|
const polyPatch& pp = mesh_.boundaryMesh()[facePatchID];
|
||||||
if (isA<coupledPolyPatch>(pp))
|
if (isA<coupledPolyPatch>(pp))
|
||||||
{
|
{
|
||||||
if (refCast<const coupledPolyPatch>(pp).owner())
|
if (refCast<const coupledPolyPatch>(pp).owner())
|
||||||
@ -170,31 +168,29 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZoneAndDirection
|
|||||||
DynamicList<List<scalar>>& faceSign
|
DynamicList<List<scalar>>& faceSign
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
|
||||||
|
|
||||||
vector refDir = dir/(mag(dir) + ROOTVSMALL);
|
vector refDir = dir/(mag(dir) + ROOTVSMALL);
|
||||||
|
|
||||||
label zonei = mesh.faceZones().findZoneID(faceZoneName);
|
label zonei = mesh_.faceZones().findZoneID(faceZoneName);
|
||||||
|
|
||||||
if (zonei == -1)
|
if (zonei == -1)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unable to find faceZone " << faceZoneName
|
<< "Unable to find faceZone " << faceZoneName
|
||||||
<< ". Valid faceZones are: " << mesh.faceZones().names()
|
<< ". Valid faceZones are: " << mesh_.faceZones().names()
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
faceZoneNames.append(faceZoneName);
|
faceZoneNames.append(faceZoneName);
|
||||||
zoneRefDir.append(refDir);
|
zoneRefDir.append(refDir);
|
||||||
|
|
||||||
const faceZone& fZone = mesh.faceZones()[zonei];
|
const faceZone& fZone = mesh_.faceZones()[zonei];
|
||||||
|
|
||||||
DynamicList<label> faceIDs(fZone.size());
|
DynamicList<label> faceIDs(fZone.size());
|
||||||
DynamicList<label> facePatchIDs(fZone.size());
|
DynamicList<label> facePatchIDs(fZone.size());
|
||||||
DynamicList<scalar> faceSigns(fZone.size());
|
DynamicList<scalar> faceSigns(fZone.size());
|
||||||
|
|
||||||
const surfaceVectorField& Sf = mesh.Sf();
|
const surfaceVectorField& Sf = mesh_.Sf();
|
||||||
const surfaceScalarField& magSf = mesh.magSf();
|
const surfaceScalarField& magSf = mesh_.magSf();
|
||||||
|
|
||||||
vector n(Zero);
|
vector n(Zero);
|
||||||
|
|
||||||
@ -204,15 +200,15 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZoneAndDirection
|
|||||||
|
|
||||||
label faceID = -1;
|
label faceID = -1;
|
||||||
label facePatchID = -1;
|
label facePatchID = -1;
|
||||||
if (mesh.isInternalFace(facei))
|
if (mesh_.isInternalFace(facei))
|
||||||
{
|
{
|
||||||
faceID = facei;
|
faceID = facei;
|
||||||
facePatchID = -1;
|
facePatchID = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
facePatchID = mesh.boundaryMesh().whichPatch(facei);
|
facePatchID = mesh_.boundaryMesh().whichPatch(facei);
|
||||||
const polyPatch& pp = mesh.boundaryMesh()[facePatchID];
|
const polyPatch& pp = mesh_.boundaryMesh()[facePatchID];
|
||||||
if (isA<coupledPolyPatch>(pp))
|
if (isA<coupledPolyPatch>(pp))
|
||||||
{
|
{
|
||||||
if (refCast<const coupledPolyPatch>(pp).owner())
|
if (refCast<const coupledPolyPatch>(pp).owner())
|
||||||
@ -279,27 +275,25 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
|||||||
DynamicList<List<scalar>>& faceSign
|
DynamicList<List<scalar>>& faceSign
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
|
||||||
|
|
||||||
vector refDir = dir/(mag(dir) + ROOTVSMALL);
|
vector refDir = dir/(mag(dir) + ROOTVSMALL);
|
||||||
|
|
||||||
const label cellZonei = mesh.cellZones().findZoneID(cellZoneName);
|
const label cellZonei = mesh_.cellZones().findZoneID(cellZoneName);
|
||||||
|
|
||||||
if (cellZonei == -1)
|
if (cellZonei == -1)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unable to find cellZone " << cellZoneName
|
<< "Unable to find cellZone " << cellZoneName
|
||||||
<< ". Valid zones are: " << mesh.cellZones().names()
|
<< ". Valid zones are: " << mesh_.cellZones().names()
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const label nInternalFaces = mesh.nInternalFaces();
|
const label nInternalFaces = mesh_.nInternalFaces();
|
||||||
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
|
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||||
|
|
||||||
labelList cellAddr(mesh.nCells(), -1);
|
labelList cellAddr(mesh_.nCells(), -1);
|
||||||
const labelList& cellIDs = mesh.cellZones()[cellZonei];
|
const labelList& cellIDs = mesh_.cellZones()[cellZonei];
|
||||||
UIndirectList<label>(cellAddr, cellIDs) = identity(cellIDs.size());
|
UIndirectList<label>(cellAddr, cellIDs) = identity(cellIDs.size());
|
||||||
labelList nbrFaceCellAddr(mesh.nFaces() - nInternalFaces, -1);
|
labelList nbrFaceCellAddr(mesh_.nFaces() - nInternalFaces, -1);
|
||||||
|
|
||||||
forAll(pbm, patchi)
|
forAll(pbm, patchi)
|
||||||
{
|
{
|
||||||
@ -311,17 +305,17 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
|||||||
{
|
{
|
||||||
label facei = pp.start() + i;
|
label facei = pp.start() + i;
|
||||||
label nbrFacei = facei - nInternalFaces;
|
label nbrFacei = facei - nInternalFaces;
|
||||||
label own = mesh.faceOwner()[facei];
|
label own = mesh_.faceOwner()[facei];
|
||||||
nbrFaceCellAddr[nbrFacei] = cellAddr[own];
|
nbrFaceCellAddr[nbrFacei] = cellAddr[own];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Correct boundary values for parallel running
|
// Correct boundary values for parallel running
|
||||||
syncTools::swapBoundaryFaceList(mesh, nbrFaceCellAddr);
|
syncTools::swapBoundaryFaceList(mesh_, nbrFaceCellAddr);
|
||||||
|
|
||||||
// Collect faces
|
// Collect faces
|
||||||
DynamicList<label> faceIDs(floor(0.1*mesh.nFaces()));
|
DynamicList<label> faceIDs(floor(0.1*mesh_.nFaces()));
|
||||||
DynamicList<label> facePatchIDs(faceIDs.size());
|
DynamicList<label> facePatchIDs(faceIDs.size());
|
||||||
DynamicList<label> faceLocalPatchIDs(faceIDs.size());
|
DynamicList<label> faceLocalPatchIDs(faceIDs.size());
|
||||||
DynamicList<scalar> faceSigns(faceIDs.size());
|
DynamicList<scalar> faceSigns(faceIDs.size());
|
||||||
@ -329,12 +323,12 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
|||||||
// Internal faces
|
// Internal faces
|
||||||
for (label facei = 0; facei < nInternalFaces; facei++)
|
for (label facei = 0; facei < nInternalFaces; facei++)
|
||||||
{
|
{
|
||||||
const label own = cellAddr[mesh.faceOwner()[facei]];
|
const label own = cellAddr[mesh_.faceOwner()[facei]];
|
||||||
const label nbr = cellAddr[mesh.faceNeighbour()[facei]];
|
const label nbr = cellAddr[mesh_.faceNeighbour()[facei]];
|
||||||
|
|
||||||
if (((own != -1) && (nbr == -1)) || ((own == -1) && (nbr != -1)))
|
if (((own != -1) && (nbr == -1)) || ((own == -1) && (nbr != -1)))
|
||||||
{
|
{
|
||||||
vector n = mesh.faces()[facei].normal(mesh.points());
|
vector n = mesh_.faces()[facei].normal(mesh_.points());
|
||||||
n /= mag(n) + ROOTVSMALL;
|
n /= mag(n) + ROOTVSMALL;
|
||||||
|
|
||||||
if ((n & refDir) > tolerance_)
|
if ((n & refDir) > tolerance_)
|
||||||
@ -362,12 +356,12 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
|||||||
forAll(pp, localFacei)
|
forAll(pp, localFacei)
|
||||||
{
|
{
|
||||||
const label facei = pp.start() + localFacei;
|
const label facei = pp.start() + localFacei;
|
||||||
const label own = cellAddr[mesh.faceOwner()[facei]];
|
const label own = cellAddr[mesh_.faceOwner()[facei]];
|
||||||
const label nbr = nbrFaceCellAddr[facei - nInternalFaces];
|
const label nbr = nbrFaceCellAddr[facei - nInternalFaces];
|
||||||
|
|
||||||
if ((own != -1) && (nbr == -1))
|
if ((own != -1) && (nbr == -1))
|
||||||
{
|
{
|
||||||
vector n = mesh.faces()[facei].normal(mesh.points());
|
vector n = mesh_.faces()[facei].normal(mesh_.points());
|
||||||
n /= mag(n) + ROOTVSMALL;
|
n /= mag(n) + ROOTVSMALL;
|
||||||
|
|
||||||
if ((n & refDir) > tolerance_)
|
if ((n & refDir) > tolerance_)
|
||||||
@ -391,15 +385,15 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
|||||||
// Convert into primitivePatch for convenience
|
// Convert into primitivePatch for convenience
|
||||||
indirectPrimitivePatch patch
|
indirectPrimitivePatch patch
|
||||||
(
|
(
|
||||||
IndirectList<face>(mesh.faces(), faceIDs),
|
IndirectList<face>(mesh_.faces(), faceIDs),
|
||||||
mesh.points()
|
mesh_.points()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
OBJstream os(mesh.time().path()/"patch.obj");
|
OBJstream os(mesh_.time().path()/"patch.obj");
|
||||||
faceList faces(patch);
|
faceList faces(patch);
|
||||||
os.write(faces, mesh.points(), false);
|
os.write(faces, mesh_.points(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -467,7 +461,7 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
|||||||
patchEdgeFaceRegion
|
patchEdgeFaceRegion
|
||||||
> calc
|
> calc
|
||||||
(
|
(
|
||||||
mesh,
|
mesh_,
|
||||||
patch,
|
patch,
|
||||||
changedEdges,
|
changedEdges,
|
||||||
changedInfo,
|
changedInfo,
|
||||||
@ -524,9 +518,9 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
|||||||
// Write OBj of faces to file
|
// Write OBj of faces to file
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
OBJstream os(mesh.time().path()/zoneName + ".obj");
|
OBJstream os(mesh_.time().path()/zoneName + ".obj");
|
||||||
faceList faces(mesh.faces(), regionFaceIDs[regioni]);
|
faceList faces(mesh_.faces(), regionFaceIDs[regioni]);
|
||||||
os.write(faces, mesh.points(), false);
|
os.write(faces, mesh_.points(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,8 +546,7 @@ void Foam::functionObjects::fluxSummary::initialiseFaceArea()
|
|||||||
{
|
{
|
||||||
faceArea_.setSize(faceID_.size(), 0);
|
faceArea_.setSize(faceID_.size(), 0);
|
||||||
|
|
||||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
const surfaceScalarField& magSf = mesh_.magSf();
|
||||||
const surfaceScalarField& magSf = mesh.magSf();
|
|
||||||
|
|
||||||
forAll(faceID_, zonei)
|
forAll(faceID_, zonei)
|
||||||
{
|
{
|
||||||
@ -788,7 +781,7 @@ bool Foam::functionObjects::fluxSummary::write()
|
|||||||
{
|
{
|
||||||
const surfaceScalarField& phi = lookupObject<surfaceScalarField>(phiName_);
|
const surfaceScalarField& phi = lookupObject<surfaceScalarField>(phiName_);
|
||||||
|
|
||||||
word flowType = "";
|
word flowType;
|
||||||
if (phi.dimensions() == dimVolume/dimTime)
|
if (phi.dimensions() == dimVolume/dimTime)
|
||||||
{
|
{
|
||||||
flowType = "volumetric";
|
flowType = "volumetric";
|
||||||
@ -801,7 +794,7 @@ bool Foam::functionObjects::fluxSummary::write()
|
|||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unsupported flux field " << phi.name() << " with dimensions "
|
<< "Unsupported flux field " << phi.name() << " with dimensions "
|
||||||
<< phi.dimensions() << ". Expected eithe mass flow or volumetric "
|
<< phi.dimensions() << ". Expected either mass flow or volumetric "
|
||||||
<< "flow rate" << abort(FatalError);
|
<< "flow rate" << abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -256,8 +256,6 @@ bool Foam::functionObjects::forceCoeffs::read(const dictionary& dict)
|
|||||||
|
|
||||||
if (writeFields_)
|
if (writeFields_)
|
||||||
{
|
{
|
||||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
|
||||||
|
|
||||||
volVectorField* forceCoeffPtr
|
volVectorField* forceCoeffPtr
|
||||||
(
|
(
|
||||||
new volVectorField
|
new volVectorField
|
||||||
@ -265,12 +263,12 @@ bool Foam::functionObjects::forceCoeffs::read(const dictionary& dict)
|
|||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
fieldName("forceCoeff"),
|
fieldName("forceCoeff"),
|
||||||
mesh.time().timeName(),
|
mesh_.time().timeName(),
|
||||||
mesh,
|
mesh_,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
),
|
),
|
||||||
mesh,
|
mesh_,
|
||||||
dimensionedVector("0", dimless, Zero)
|
dimensionedVector("0", dimless, Zero)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -284,12 +282,12 @@ bool Foam::functionObjects::forceCoeffs::read(const dictionary& dict)
|
|||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
fieldName("momentCoeff"),
|
fieldName("momentCoeff"),
|
||||||
mesh.time().timeName(),
|
mesh_.time().timeName(),
|
||||||
mesh,
|
mesh_,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
),
|
),
|
||||||
mesh,
|
mesh_,
|
||||||
dimensionedVector("0", dimless, Zero)
|
dimensionedVector("0", dimless, Zero)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user