Skip to content

Commit 5ce9c34

Browse files
authored
Add support for the two-schemes localBlended discretization scheme. (#577)
* Add support for the localBlended scheme. Fix #575. - The `UBlend` volScalarField should be exist in the 0 folder. This field can be initialized using setFields or funkySetFields. - Although we only support the localBlended scheme for div(phi,U), it can be easily extent to other variables. - Reference: https://www.cfd-online.com/Forums/openfoam-programming-development/105843-localblended.html#post544480 * Fix errors in createLocalBlend.
1 parent ed526cc commit 5ce9c34

2 files changed

Lines changed: 76 additions & 1 deletion

File tree

applications/solvers/dfLowMachFoam/createFields.H

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ rho = thermo.rho();
115115
Info<< "Creating field kinetic energy K\n" << endl;
116116
volScalarField K("K", 0.5*magSqr(U));
117117

118+
#include "createLocalBlend.H"
119+
118120
multivariateSurfaceInterpolationScheme<scalar>::fieldTable fields;
119121

120122
#include "createMRF.H"
@@ -206,4 +208,4 @@ const Switch splitting = CanteraTorchProperties.lookupOrDefault("splittingStrate
206208
#ifdef USE_LIBTORCH
207209
const Switch log_ = CanteraTorchProperties.subDict("TorchSettings").lookupOrDefault("log", false);
208210
const Switch torch_ = CanteraTorchProperties.subDict("TorchSettings").lookupOrDefault("torch", false);
209-
#endif
211+
#endif
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*---------------------------------------------------------------------------*\
2+
This function is designed to read the UBlendingFactor for localBlended
3+
schemes used by the divSchemes, i.e.:
4+
```
5+
divSchemes
6+
{
7+
div(phi,U) Gauss localBlended linear upwind;
8+
}
9+
```
10+
\*---------------------------------------------------------------------------*/
11+
12+
// Find and parse the divSchemes sub-dictionary
13+
const dictionary& divSchemesDict = mesh.schemesDict().subDict("divSchemes");
14+
15+
Switch foundLocalBlended = false;
16+
17+
// Parse the divSchemes tokens
18+
wordList keys = divSchemesDict.toc();
19+
forAll(keys, i)
20+
{
21+
const word& key = keys[i];
22+
// Convert to string
23+
ITstream& is = divSchemesDict.lookup(key);
24+
OStringStream os;
25+
os << is;
26+
word schemeStr = os.str();
27+
28+
if (schemeStr.find("localBlended") != word::npos)
29+
{
30+
foundLocalBlended = true;
31+
}
32+
}
33+
34+
// Declare pointer for UBlendingFactor
35+
autoPtr<surfaceScalarField> UBlendingFactorPtr;
36+
37+
// Create the localBlendingFactor field only if localBlended scheme is found
38+
if (foundLocalBlended)
39+
{
40+
Info << " Creating UBlendingFactor field for localBlended schemes " << endl;
41+
42+
// Read the scalarField UBlend
43+
volScalarField UBlend
44+
(
45+
IOobject
46+
(
47+
"UBlend",
48+
mesh.time().timeName(),
49+
mesh,
50+
IOobject::MUST_READ,
51+
IOobject::NO_WRITE
52+
),
53+
mesh
54+
);
55+
56+
// Construct the surfaceScalarField UBlendingFactor by interpolating UBlend to cell faces
57+
UBlendingFactorPtr.reset
58+
(
59+
new surfaceScalarField
60+
(
61+
IOobject
62+
(
63+
"UBlendingFactor",
64+
mesh.time().timeName(),
65+
mesh,
66+
IOobject::READ_IF_PRESENT,
67+
IOobject::NO_WRITE,
68+
true
69+
),
70+
fvc::interpolate(UBlend)
71+
)
72+
);
73+
}

0 commit comments

Comments
 (0)