Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/applications/solvers/common/solver_controls.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ struct DeviceSimpleControls
// whenever a `wall`-typed patch carries a plain BC. EMPTY means "fall back to the patch type",
// which is what the SA and LES paths use -- they have no epsilon/omega field to read.
std::vector<char> turbWallPatch;
// WHICH PATCHES CARRY A NUT WALL FUNCTION, one entry per fvPatch, 1 = yes: a `wall` patch whose 0/nut condition is one of the
// nut wall-function family (isNutWallFnType). OpenFOAM's nut on a wall patch is whatever that patch's own nut condition
// evaluates (nut_.correctBoundaryConditions() in correctNut), so a wall patch carrying a plain nut condition -- a slip ground
// with nut calculated or zeroGradient, a low-Re wall with fixedValue 0 -- is not given a wall function's value. EMPTY means
// "fall back to the patch type", for a caller that does not read nut's conditions.
std::vector<char> nutWallFnPatch;
// OF createDyMControls.H, default FALSE: the mesh moves once per time step, on the first outer
// iteration. When true it moves before EVERY outer corrector, so the outer loop converges the mesh
// position alongside the pressure-velocity coupling.
Expand Down
41 changes: 22 additions & 19 deletions src/applications/solvers/common/turbulence_setup.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -822,14 +822,26 @@ inline TurbulenceFields readTurbulenceFields(const std::string& fieldDir, const
|| t == "symmetryPlane" || t == "wedge" || t == "empty" || t == "inletOutlet" || t == "freestream"
|| t == "outletInlet";
};
for (const auto& q : fvp)
// ...which includes a `wall` patch whose nut condition is not a wall function (ctl.nutWallFnPatch): its faces are
// evaluated the same way
ctl.nutWallFnPatch.assign(fvp.size(), 0);
for (std::size_t pi = 0; pi < fvp.size(); ++pi)
{
if (q.type == "wall" || isCoupledInterfaceType(q.type)) continue;
const auto* e = findPatchEntry(fd.boundary, fvp[pi]);
if (fvp[pi].type == "wall" && e && isNutWallFnType(e->type))
{
ctl.nutWallFnPatch[pi] = 1;
}
}
for (std::size_t pi = 0; pi < fvp.size(); ++pi)
{
const FvPatch& q = fvp[pi];
if (ctl.nutWallFnPatch[pi] || isCoupledInterfaceType(q.type)) continue;
const auto* e = findPatchEntry(fd.boundary, q);
if (e && !carried(e->type))
throw std::runtime_error(
"brae: patch '" + q.name + "' resolves its nut BC to key '" + e->name + "' of type '" + e->type
+ "', which this driver does not evaluate on a patch that is not a wall (it carries calculated, "
+ "', which this driver does not evaluate on a patch without a nut wall function (it carries calculated, "
"fixedValue, zeroGradient, slip, symmetry, symmetryPlane, wedge, empty, inletOutlet, freestream and "
"outletInlet there). Refusing rather than keeping the file's value.");
}
Expand Down Expand Up @@ -910,24 +922,15 @@ inline TurbulenceFields readTurbulenceFields(const std::string& fieldDir, const
saWallFn = pb.type;
}
}
// The plain-BC-on-a-wall check runs PATCH-DRIVEN, resolving each wall patch's entry the way
// buildField does -- an entry keyed `"wal.*"` used to be invisible to the exact-name compare
// here (audit finding #16), so a regex-keyed plain fixedValue on the walls still got the
// Spalding hard-force. A wall patch with NO entry at all is left to buildField's own fatal.
for (const auto& q : fvp)
{
if (q.type != "wall") continue;
const auto* e = findPatchEntry(nutFD.boundary, q);
if (e && !isNutWallFn(e->type))
throw std::runtime_error(
"brae: wall patch '" + q.name + "' resolves its nut BC to key '" + e->name +
"' of type '" + e->type + "' (no wall function) on SpalartAllmaras. The SA "
"path writes its wall function on every wall face and would overwrite this "
"BC; OpenFOAM evaluates it. Refusing rather than substituting Spalding.");
}
// A wall patch whose nut condition is not a wall function was refused here ("the SA path writes its wall
// function on every wall face"). It no longer does: the wall function is written on the patches whose nut
// condition is one (ctl.nutWallFnPatch, set by guardNonWallNut above, which also refuses any type it does not
// evaluate), and every other wall's nut takes its own condition, as OpenFOAM's correctNut does. A low-Re wall,
// nut and nuTilda fixedValue 0 beside a nutUSpaldingWallFunction wall on pimpleFoam/RAS/pitzDaily: brae could
// not run it. A wall patch with NO entry at all is left to buildField's own fatal.
ctl.nutWall = (saWallFn == "nutLowReWallFunction") ? NutWall::LowRe : NutWall::Spalding;
std::printf(" nut wall function: %s (honoured on %s per the BC)\n",
saWallFn.empty() ? "nutUSpaldingWallFunction (no wall BC named one; SA default)"
saWallFn.empty() ? "none (no wall's nut condition names one; each wall takes its own)"
: saWallFn.c_str(),
ctl.modelName.c_str());
nut = buildField<scalar>(nutFD, fvp, nC);
Expand Down
23 changes: 19 additions & 4 deletions src/applications/solvers/simpleFoam/device_simple_foam.cu
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,21 @@ SimplecSnGrad simplecSnGrad(
dbPcorr_ = buildDeviceBoundary(pc, fvp, g);
}
wall_ = buildDeviceWallData(m, g, fvp, U, ctl_.turbWallPatch);
// a patch whose nut carries a wall function: a `wall` whose 0/nut condition is one (DeviceSimpleControls::nutWallFnPatch;
// the patch type alone when the caller gave no mask). Every other patch's nut takes its own condition, a wall's included:
// pimpleFoam/RAS/pitzDaily with upperWall a slip ground (U slip, k and epsilon zeroGradient, nut calculated) had its nut
// there from nutkWallFunction where OpenFOAM's is Cmu k^2/epsilon of the patch values.
// CONTROL BRAE_CONTROL_WALL_NUT_BY_PATCH_TYPE=1: every `wall` patch's nut from the wall function, as before
static const bool wallNutByType = std::getenv("BRAE_CONTROL_WALL_NUT_BY_PATCH_TYPE") != nullptr;
const auto nutWallPatch = [&](std::size_t pi)
{
if (fvp[pi].type != "wall")
{
return false;
}
return wallNutByType || ctl_.nutWallFnPatch.empty()
|| (pi < ctl_.nutWallFnPatch.size() && ctl_.nutWallFnPatch[pi]);
};
{ // DeviceBoundary face offset of each patch, for setPatchVelocity
label st = 0;
patchStart_.assign(fvp.size(), 0);
Expand All @@ -335,7 +350,7 @@ SimplecSnGrad simplecSnGrad(
{
if (isCoupledInterfaceType(fvp[pi].type)) continue;
const int nutCat = nut->boundary[pi]->bcCategory();
const bool calc = (fvp[pi].type != "wall") && (nutCat == 2);
const bool calc = !nutWallPatch(pi) && (nutCat == 2);
// A non-wall `fixedValue` nut patch is NOT a `calculated` one and must not be lumped in
// with it: `calculated` means "correctNut filled this in", so Cmu*k_b^2/eps_b is right
// there, while `fixedValue` means the case PINNED it -- conventionally to 0 -- and the
Expand All @@ -344,7 +359,7 @@ SimplecSnGrad simplecSnGrad(
// 1e-06 but Cmu*k^2/eps is 7.03e-04 in the first cell, so the inlet's momentum
// internalCoeffs came out 704x OpenFOAM's (predicted 704.1, measured 703.1) -- which is
// where that case's H(), and everything downstream of it, went wrong.
const bool nutFixed = (fvp[pi].type != "wall") && (nutCat == 1);
const bool nutFixed = !nutWallPatch(pi) && (nutCat == 1);
if (nutFixed) hasNutFixed_ = true;
if (calc) hasNutCalc_ = true;
const std::vector<scalar>& pv = nut->boundary[pi]->value();
Expand Down Expand Up @@ -373,7 +388,7 @@ SimplecSnGrad simplecSnGrad(
const fvPatchField<scalar>* pf = nut->boundary[pi].get();
label kd = NutPatchUntouched;
std::vector<scalar> rv = pf->value();
if (fvp[pi].type != "wall")
if (!nutWallPatch(pi))
{
if (dynamic_cast<const TurbulentInletPatchField<scalar>*>(pf))
{
Expand Down Expand Up @@ -620,7 +635,7 @@ SimplecSnGrad simplecSnGrad(
for (std::size_t pi = 0; pi < fvp.size(); ++pi)
{
if (isCoupledInterfaceType(fvp[pi].type)) continue;
const bool wall = (fvp[pi].type == "wall");
const bool wall = nutWallPatch(pi); // the faces the nut wall function writes
for (label i = 0; i < fvp[pi].size; ++i)
{
isW.push_back(wall ? 1 : 0);
Expand Down
6 changes: 6 additions & 0 deletions tests/cmake/solver_pimplefoam.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,9 @@ set_tests_properties(pimple_controldict_defaults_vs_openfoam PROPERTIES SKIP_RET
add_test(NAME pimple_cranknicolson_vs_openfoam COMMAND bash ${PROJECT_SOURCE_DIR}/tests/pimple_cranknicolson_vs_openfoam.sh)
set_tests_properties(pimple_cranknicolson_vs_openfoam PROPERTIES SKIP_RETURN_CODE 77 LABELS slow TIMEOUT 1800
ENVIRONMENT "BRAE_BIN=$<TARGET_FILE:brae_pimpleFoam>;BRAE_OF_TUTORIALS=${BRAE_OF_TUTORIALS}")

# nut on a WALL patch that carries no nut wall function, RAS/pitzDaily: a slip ground with nut calculated or zeroGradient
# (kEpsilon) and a low-Re wall with nut fixedValue 0 (SpalartAllmaras), every entry against OpenFOAM; a premise, one control.
add_test(NAME pimple_wall_nut_vs_openfoam COMMAND bash ${PROJECT_SOURCE_DIR}/tests/pimple_wall_nut_vs_openfoam.sh)
set_tests_properties(pimple_wall_nut_vs_openfoam PROPERTIES SKIP_RETURN_CODE 77 LABELS slow TIMEOUT 1800
ENVIRONMENT "BRAE_BIN=$<TARGET_FILE:brae_pimpleFoam>;BRAE_OF_TUTORIALS=${BRAE_OF_TUTORIALS}")
Loading
Loading