Skip to content

Commit 452ce6a

Browse files
author
Bart Doekemeijer
authored
Merge pull request #8 from NREL/master
Merge changes from master
2 parents c6d3574 + b326fa1 commit 452ce6a

36 files changed

+758
-576
lines changed

applications/solvers/incompressible/windEnergy/ABLSolver/Make/options

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ EXE_INC = \
66
-I$(LIB_SRC)/meshTools/lnInclude \
77
-I$(LIB_SRC)/fvOptions/lnInclude \
88
-I$(LIB_SRC)/sampling/lnInclude \
9-
-I./interpolate2D \
10-
-I./windRoseToCartesian
9+
-I../commonAlgorithms \
10+
-I../commonAlgorithms/interpolate2D \
11+
-I../commonAlgorithms/windRoseToCartesian
1112

1213

1314
EXE_LIBS = \

applications/solvers/incompressible/windEnergy/ABLSolver/UEqn.H

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "computeCoriolisForce.H"
44

5+
#include "computeBuoyancyTerm.H"
6+
57
fvVectorMatrix UEqn
68
(
79
fvm::ddt(U) // time derivative
@@ -24,7 +26,7 @@
2426
(
2527
(
2628
- fvc::snGrad(p_rgh) // modified pressure gradient
27-
- ghf*fvc::snGrad(rhok) // buoyancy force
29+
+ buoyancyTerm // buoyancy force
2830
) * mesh.magSf()
2931
)
3032
);

applications/solvers/incompressible/windEnergy/ABLSolver/computeDivergence.H

Lines changed: 0 additions & 34 deletions
This file was deleted.

applications/solvers/incompressible/windEnergy/ABLSolver/createFields.H

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,6 @@
136136
mesh
137137
);
138138

139-
// Create and calculate the gravity potential field
140-
Info << "Creating and calculating the gravity potential field, gh and ghf..." << endl;
141-
volScalarField gh("gh", g & mesh.C());
142-
surfaceScalarField ghf("ghf", g & mesh.Cf());
143139

144140
// Create and calculate the static pressure field
145141
Info << "Creating and calculating the static pressure field, p..." << endl;
@@ -153,9 +149,11 @@
153149
IOobject::NO_READ,
154150
IOobject::AUTO_WRITE
155151
),
156-
p_rgh + rhok*gh
152+
//p_rgh + rhok*gh
153+
p_rgh
157154
);
158155

156+
159157
// Set up the pressure reference cell information
160158
Info << "Setting up the pressure reference cell information..." << endl;
161159
label pRefCell = 0;
@@ -169,13 +167,21 @@
169167
pRefValue
170168
);
171169

172-
if (p_rgh.needReference())
170+
171+
// Create and calculate the gravity potential field
172+
Info << "Creating and calculating the gravity potential field, gh and ghf..." << endl;
173+
174+
vector hRef_ = vector::zero;
175+
if (pRefCell != -1)
173176
{
174-
p += dimensionedScalar
175-
(
176-
"p",
177-
p.dimensions(),
178-
pRefValue - getRefCellValue(p, pRefCell)
179-
);
177+
hRef_ = mesh.C()[pRefCell];
180178
}
179+
reduce(hRef_,sumOp<vector>());
180+
dimensionedVector hRef("hRef",dimLength,hRef_);
181+
182+
volScalarField gh("gh", g & (mesh.C() - hRef));
183+
surfaceScalarField ghf("ghf", g & (mesh.Cf() - hRef));
184+
181185

186+
// Compute the full pressure and adjust the pressure level.
187+
#include "adjustPressureLevel.H"

applications/solvers/incompressible/windEnergy/ABLSolver/pEqn.H

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
{
2+
// The inverse of the momentum equation "A" operator (the matrix diagonal) and
3+
// its projection from cell centers to cell faces. Because it is a diagonal matrix,
4+
// The inverse is just the diagonal matrix of the reciprocals, hence the "r" in the
5+
// name "rAU".
26
volScalarField rAU("rAU", 1.0/UEqn.A());
37
surfaceScalarField rAUf("(1|A(U))", fvc::interpolate(rAU));
48

9+
// The momentum equation "H" operator is the off-diagonal times the last known U.
10+
// In the equations it is always multiplied with inv(A). This is HbyA.
511
volVectorField HbyA("HbyA", U);
612
HbyA = rAU*UEqn.H();
713

8-
surfaceScalarField phig(-rAUf*ghf*fvc::snGrad(rhok)*mesh.magSf());
14+
// This is the Boussinesq buoyancy term multipled by the inverse of the A operator.
15+
#include "computeBuoyancyTerm.H"
16+
surfaceScalarField phig(rAUf * buoyancyTerm * mesh.magSf());
917

18+
// Project HbyA to cell faces and apply a correction for time stepping scheme.
1019
surfaceScalarField phiHbyA
1120
(
1221
"phiHbyA",
1322
(fvc::interpolate(HbyA) & mesh.Sf())
1423
+ rAUf*fvc::ddtCorr(U, phi)
1524
);
1625

17-
adjustPhi(phiHbyA, U, p_rgh);
18-
19-
surfaceScalarField phiFixedFlux = fvc::interpolate(U) & mesh.Sf();
26+
// This part balances global mass flux.
27+
surfaceScalarField phiFixedFlux = phiHbyA;
2028

2129
adjustPhi(phiFixedFlux, U, p_rgh);
2230

@@ -32,14 +40,19 @@
3240
)/(mesh.magSf().boundaryField()*rAUf.boundaryField())
3341
);
3442

43+
44+
// Non-orthogonal corrector loop.
3545
while (pimple.correctNonOrthogonal())
3646
{
3747
fvScalarMatrix p_rghEqn
3848
(
3949
fvm::laplacian(rAUf, p_rgh) == fvc::div(phiHbyA)
4050
);
4151

42-
p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
52+
if (activatePressureRefCell)
53+
{
54+
p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
55+
}
4356

4457
p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter())));
4558

@@ -58,16 +71,6 @@
5871
}
5972
}
6073

61-
p = p_rgh + rhok*gh;
62-
63-
if (p_rgh.needReference())
64-
{
65-
p += dimensionedScalar
66-
(
67-
"p",
68-
p.dimensions(),
69-
pRefValue - getRefCellValue(p, pRefCell)
70-
);
71-
p_rgh = p - rhok*gh;
72-
}
74+
// Compute the full pressure and adjust the pressure level.
75+
#include "adjustPressureLevel.H"
7376
}

applications/solvers/incompressible/windEnergy/ABLSolver/readABLProperties.H

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,55 @@
198198

199199

200200

201+
202+
// PROPERTIES CONCERNING THE WAY IN WHICH PERTURBATION PRESSURE IS DEFINED
203+
204+
// Options for defining the perturbation pressure:
205+
// - noSplit: do not split out hydrostatic part; pressure is then perturbation pressure.
206+
// - rho0Split: split out the hydrostatic part; define hydrostatic as rho_0 * g * z.
207+
// - rhokSplit: split out the hydrostatic part; define hydrostatic as rho_k * g * z.
208+
word perturbationPressureType(ABLProperties.lookupOrDefault<word>("perturbationPressureType","rhokSplit"));
209+
word perturbationOutput;
210+
if (perturbationPressureType == "noSplit")
211+
{
212+
perturbationOutput = "nothing";
213+
}
214+
else if (perturbationPressureType == "rho0Split")
215+
{
216+
perturbationOutput = "rho_0 * g * z";
217+
}
218+
else if (perturbationPressureType == "rhokSplit")
219+
{
220+
perturbationOutput = "rho_k * g * z";
221+
}
222+
Info << "Defining background hydrostatic pressure to be " << perturbationOutput << endl;
223+
224+
225+
// This switch dictates whether or not the pressure reference cell is set explicitly
226+
// in the p_rgh solve. If true, pressure is constrained at the pressure reference
227+
// cell by manipulating the matrix row for that cell to remove the null space. This
228+
// assures that the pressure level is constrained, but it also means the continuity
229+
// equation is no longer solved at that cell, so the divergence error can be significant
230+
// enough there to cause localized oscillations. Iterative solvers can still converge
231+
// even with a null space, but more iterations may be needed, so this switch can be
232+
// set to false.
233+
bool activatePressureRefCell(ABLProperties.lookupOrDefault<bool>("activatePressureRefCell", true));
234+
if (activatePressureRefCell)
235+
{
236+
Info << "Pressure reference cell matrix row modification enabled" << endl;
237+
}
238+
else
239+
{
240+
Info << "Pressure reference cell matrix row modification not enabled" << endl;
241+
}
242+
243+
244+
245+
246+
247+
248+
249+
201250
// PROPERTIES CONCERNING GATHERING STATISTICS
202251

203252
// Gather/write statistics?

applications/solvers/incompressible/windEnergy/ABLTerrainSolver/ABLTerrainSolver.C

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,9 @@ int main(int argc, char *argv[])
9393
// field.
9494
U.correctBoundaryConditions();
9595
phi = linearInterpolate(U) & mesh.Sf();
96+
#include "turbulenceCorrect.H"
9697
T.correctBoundaryConditions();
9798
//p_rgh.correctBoundaryConditions();
98-
turbulence->correct();
99-
Rwall.correctBoundaryConditions();
100-
qwall.correctBoundaryConditions();
101-
10299

103100
while (runTime.loop())
104101
{
@@ -113,14 +110,20 @@ int main(int argc, char *argv[])
113110
// --- Pressure-velocity PIMPLE corrector loop
114111
while (pimple.loop())
115112
{
113+
Info << " Predictor..." << endl;
116114
#include "UEqn.H"
115+
#include "turbulenceCorrect.H"
117116
#include "TEqn.H"
118117

119118
// --- Pressure corrector loop
119+
int corr = 0;
120120
while (pimple.correct())
121121
{
122+
Info << " Corrector Step " << corr << "..." << endl;
122123
#include "pEqn.H"
124+
#include "turbulenceCorrect.H"
123125
#include "TEqn.H"
126+
corr++;
124127
}
125128

126129
// --- Compute the velocity flux divergence
@@ -130,15 +133,15 @@ int main(int argc, char *argv[])
130133
#include "correctGradP.H"
131134

132135
// --- Update the turbulence fields
133-
if (pimple.turbCorr())
134-
{
135-
turbulence->correct();
136-
}
136+
// if (pimple.turbCorr())
137+
// {
138+
// turbulence->correct();
139+
// }
137140

138141
// --- Update the boundary momentum and
139142
// temperature flux conditions
140-
Rwall.correctBoundaryConditions();
141-
qwall.correctBoundaryConditions();
143+
// Rwall.correctBoundaryConditions();
144+
// qwall.correctBoundaryConditions();
142145
}
143146

144147

applications/solvers/incompressible/windEnergy/ABLTerrainSolver/Make/options

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ EXE_INC = \
55
-I$(LIB_SRC)/finiteVolume/lnInclude \
66
-I$(LIB_SRC)/meshTools/lnInclude \
77
-I$(LIB_SRC)/fvOptions/lnInclude \
8-
-I$(LIB_SRC)/sampling/lnInclude
8+
-I$(LIB_SRC)/sampling/lnInclude \
9+
-I../commonAlgorithms \
10+
-I../commonAlgorithms/interpolate2D \
11+
-I../commonAlgorithms/windRoseToCartesian
912

1013

1114
EXE_LIBS = \

applications/solvers/incompressible/windEnergy/ABLTerrainSolver/UEqn.H

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "computeCoriolisForce.H"
44

5+
#include "computeBuoyancyTerm.H"
6+
57
fvVectorMatrix UEqn
68
(
79
fvm::ddt(U) // time derivative
@@ -24,7 +26,7 @@
2426
(
2527
(
2628
- fvc::snGrad(p_rgh) // modified pressure gradient
27-
- ghf*fvc::snGrad(rhok) // buoyancy force
29+
+ buoyancyTerm // buoyancy force
2830
) * mesh.magSf()
2931
)
3032
);

applications/solvers/incompressible/windEnergy/ABLTerrainSolver/computeCoriolisForce.H

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)