diff --git a/applications/solvers/dfLowMachFoam/createFields.H b/applications/solvers/dfLowMachFoam/createFields.H index 32c8cd2c..c1c9d7d9 100644 --- a/applications/solvers/dfLowMachFoam/createFields.H +++ b/applications/solvers/dfLowMachFoam/createFields.H @@ -115,6 +115,8 @@ rho = thermo.rho(); Info<< "Creating field kinetic energy K\n" << endl; volScalarField K("K", 0.5*magSqr(U)); +#include "createLocalBlend.H" + multivariateSurfaceInterpolationScheme::fieldTable fields; #include "createMRF.H" @@ -206,4 +208,4 @@ const Switch splitting = CanteraTorchProperties.lookupOrDefault("splittingStrate #ifdef USE_LIBTORCH const Switch log_ = CanteraTorchProperties.subDict("TorchSettings").lookupOrDefault("log", false); const Switch torch_ = CanteraTorchProperties.subDict("TorchSettings").lookupOrDefault("torch", false); -#endif +#endif \ No newline at end of file diff --git a/applications/solvers/dfLowMachFoam/createLocalBlend.H b/applications/solvers/dfLowMachFoam/createLocalBlend.H new file mode 100644 index 00000000..80b5a47d --- /dev/null +++ b/applications/solvers/dfLowMachFoam/createLocalBlend.H @@ -0,0 +1,73 @@ +/*---------------------------------------------------------------------------*\ +This function is designed to read the UBlendingFactor for localBlended +schemes used by the divSchemes, i.e.: +``` +divSchemes +{ + div(phi,U) Gauss localBlended linear upwind; +} +``` +\*---------------------------------------------------------------------------*/ + +// Find and parse the divSchemes sub-dictionary +const dictionary& divSchemesDict = mesh.schemesDict().subDict("divSchemes"); + +Switch foundLocalBlended = false; + +// Parse the divSchemes tokens +wordList keys = divSchemesDict.toc(); +forAll(keys, i) +{ + const word& key = keys[i]; + // Convert to string + ITstream& is = divSchemesDict.lookup(key); + OStringStream os; + os << is; + word schemeStr = os.str(); + + if (schemeStr.find("localBlended") != word::npos) + { + foundLocalBlended = true; + } +} + +// Declare pointer for UBlendingFactor +autoPtr UBlendingFactorPtr; + +// Create the localBlendingFactor field only if localBlended scheme is found +if (foundLocalBlended) +{ + Info << " Creating UBlendingFactor field for localBlended schemes " << endl; + + // Read the scalarField UBlend + volScalarField UBlend + ( + IOobject + ( + "UBlend", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + mesh + ); + + // Construct the surfaceScalarField UBlendingFactor by interpolating UBlend to cell faces + UBlendingFactorPtr.reset + ( + new surfaceScalarField + ( + IOobject + ( + "UBlendingFactor", + mesh.time().timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE, + true + ), + fvc::interpolate(UBlend) + ) + ); +}