Skip to content
Snippets Groups Projects
Commit 39aa3dc1 authored by mattijs's avatar mattijs
Browse files

ENH: checkMesh: write correct faceWeights. Fixes #1099.

parent 97f273b1
No related branches found
No related tags found
No related merge requests found
#include "writeFields.H" #include "writeFields.H"
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H"
#include "polyMeshTools.H" #include "polyMeshTools.H"
#include "zeroGradientFvPatchFields.H" #include "zeroGradientFvPatchFields.H"
#include "syncTools.H" #include "syncTools.H"
...@@ -68,6 +69,52 @@ void minFaceToCell ...@@ -68,6 +69,52 @@ void minFaceToCell
} }
void minFaceToCell
(
const surfaceScalarField& faceData,
volScalarField& cellData,
const bool correctBoundaryConditions
)
{
scalarField& cellFld = cellData.ref();
cellFld = GREAT;
const labelUList& own = cellData.mesh().owner();
const labelUList& nei = cellData.mesh().neighbour();
// Internal faces
forAll(own, facei)
{
cellFld[own[facei]] = min(cellFld[own[facei]], faceData[facei]);
cellFld[nei[facei]] = min(cellFld[nei[facei]], faceData[facei]);
}
// Patch faces
forAll(faceData.boundaryField(), patchi)
{
const fvsPatchScalarField& fvp = faceData.boundaryField()[patchi];
const labelUList& fc = fvp.patch().faceCells();
forAll(fc, i)
{
cellFld[fc[i]] = min(cellFld[fc[i]], fvp[i]);
}
}
volScalarField::Boundary& bfld = cellData.boundaryFieldRef();
forAll(bfld, patchi)
{
bfld[patchi] = faceData.boundaryField()[patchi];
}
if (correctBoundaryConditions)
{
cellData.correctBoundaryConditions();
}
}
void Foam::writeFields void Foam::writeFields
( (
const fvMesh& mesh, const fvMesh& mesh,
...@@ -112,7 +159,8 @@ void Foam::writeFields ...@@ -112,7 +159,8 @@ void Foam::writeFields
mesh.time().timeName(), mesh.time().timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE,
false
), ),
mesh, mesh,
dimensionedScalar(dimless, Zero), dimensionedScalar(dimless, Zero),
...@@ -127,17 +175,6 @@ void Foam::writeFields ...@@ -127,17 +175,6 @@ void Foam::writeFields
if (selectedFields.found("faceWeight")) if (selectedFields.found("faceWeight"))
{ {
const scalarField faceWeights
(
polyMeshTools::faceWeights
(
mesh,
mesh.faceCentres(),
mesh.faceAreas(),
mesh.cellCentres()
)
);
volScalarField cellWeights volScalarField cellWeights
( (
IOobject IOobject
...@@ -146,14 +183,20 @@ void Foam::writeFields ...@@ -146,14 +183,20 @@ void Foam::writeFields
mesh.time().timeName(), mesh.time().timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE,
false
), ),
mesh, mesh,
dimensionedScalar(dimless, Zero), dimensionedScalar(dimless, Zero),
calculatedFvPatchScalarField::typeName wordList // wanted bc types
(
mesh.boundary().size(),
calculatedFvPatchScalarField::typeName
),
mesh.weights().boundaryField().types() // current bc types
); );
//- Take min //- Take min
minFaceToCell(faceWeights, cellWeights); minFaceToCell(mesh.weights(), cellWeights, false);
Info<< " Writing face interpolation weights (0..0.5) to " Info<< " Writing face interpolation weights (0..0.5) to "
<< cellWeights.name() << endl; << cellWeights.name() << endl;
cellWeights.write(); cellWeights.write();
...@@ -187,7 +230,8 @@ void Foam::writeFields ...@@ -187,7 +230,8 @@ void Foam::writeFields
mesh.time().timeName(), mesh.time().timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE,
false
), ),
mesh, mesh,
dimensionedScalar(dimless, Zero), dimensionedScalar(dimless, Zero),
...@@ -346,7 +390,8 @@ void Foam::writeFields ...@@ -346,7 +390,8 @@ void Foam::writeFields
mesh.time().timeName(), mesh.time().timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE,
false
), ),
mesh, mesh,
dimensionedScalar(dimless, Zero), dimensionedScalar(dimless, Zero),
...@@ -435,7 +480,8 @@ void Foam::writeFields ...@@ -435,7 +480,8 @@ void Foam::writeFields
mesh.time().timeName(), mesh.time().timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE,
false
), ),
mesh, mesh,
dimensionedScalar(dimless, Zero), dimensionedScalar(dimless, Zero),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment