Skip to content

Commit d8df5ca

Browse files
committed
Updated compilation for latest Ubuntu arch and OF6
1 parent 159b846 commit d8df5ca

File tree

20 files changed

+227
-194
lines changed

20 files changed

+227
-194
lines changed

applications/pisoFoam_c3po/UEqn.H

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Solve the Momentum equation
2+
3+
MRF.correctBoundaryVelocity(U);
4+
5+
fvVectorMatrix UEqn
6+
(
7+
fvm::ddt(U) + fvm::div(phi, U)
8+
+ MRF.DDt(U)
9+
+ turbulence->divDevReff(U)
10+
==
11+
fvOptions(U)
12+
);
13+
14+
UEqn.relax();
15+
16+
fvOptions.constrain(UEqn);
17+
18+
if (piso.momentumPredictor())
19+
{
20+
solve(UEqn == -fvc::grad(p));
21+
22+
fvOptions.correct(U);
23+
}

applications/pisoFoam_c3po/c3po_modifications_1.H

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,33 @@ Description
5151

5252
// * * * * * * * * * * * * CODE MODIFICATIONS * * * * * * * * * * * * * * *
5353

54+
// This initialises MPI to properly run CPPPO with the WORLD communicator
55+
int flag;
56+
MPI_Initialized(&flag);
57+
if (!flag)
58+
{
59+
int argc = 0;
60+
char **argv = NULL;
61+
MPI_Init(&argc,&argv);
62+
}
63+
int proc_name;
64+
MPI_Comm_rank(MPI_COMM_WORLD,&proc_name);
5465

5566
// These lines are used to create the C3PO object and run a check of the mesh.In case
5667
// CPPPO finds incompabilities with the input script an error will be thrown.
5768

58-
59-
60-
Info << "\n Creating C3PO object...\n";
69+
Info << "\n Creating C3PO object...\n";
6170

6271
// The c3poOFInterface object requires a fvMesh& and a valid MPI communicator as arguments for
6372
// its constructor
6473

6574
C3PO_NS::c3poOFInterface *myC3PO= new C3PO_NS::c3poOFInterface(mesh,MPI_COMM_WORLD);
66-
67-
68-
75+
6976
// checkMyMesh() tells CPPPO to read the mesh and collect data. In case of multiple calls,
7077
// the mesh information will be updated. It has to be called at least one time before doing
7178
// any operation.
7279

73-
myC3PO->checkMyMesh();
74-
80+
myC3PO->checkMyMesh();
7581

7682
// Particles can be registered in CPPPO at any point of the solver C file. Normally, if there is no change
7783
// in particle properties (position, velocity, ecc.) they can be registered just one time before the main loop.

applications/pisoFoam_c3po/createFields.H

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
1-
Info<< "Reading field p\n" << endl;
2-
volScalarField p
1+
Info<< "Reading field p\n" << endl;
2+
volScalarField p
3+
(
4+
IOobject
35
(
4-
IOobject
5-
(
6-
"p",
7-
runTime.timeName(),
8-
mesh,
9-
IOobject::MUST_READ,
10-
IOobject::AUTO_WRITE
11-
),
12-
mesh
13-
);
14-
15-
Info<< "Reading field U\n" << endl;
16-
volVectorField U
6+
"p",
7+
runTime.timeName(),
8+
mesh,
9+
IOobject::MUST_READ,
10+
IOobject::AUTO_WRITE
11+
),
12+
mesh
13+
);
14+
15+
Info<< "Reading field U\n" << endl;
16+
volVectorField U
17+
(
18+
IOobject
1719
(
18-
IOobject
19-
(
20-
"U",
21-
runTime.timeName(),
22-
mesh,
23-
IOobject::MUST_READ,
24-
IOobject::AUTO_WRITE
25-
),
26-
mesh
27-
);
20+
"U",
21+
runTime.timeName(),
22+
mesh,
23+
IOobject::MUST_READ,
24+
IOobject::AUTO_WRITE
25+
),
26+
mesh
27+
);
2828

29-
# include "createPhi.H"
29+
#include "createPhi.H"
3030

3131

32-
label pRefCell = 0;
33-
scalar pRefValue = 0.0;
34-
setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue);
32+
label pRefCell = 0;
33+
scalar pRefValue = 0.0;
34+
setRefCell(p, piso.dict(), pRefCell, pRefValue);
35+
mesh.setFluxRequired(p.name());
3536

3637

37-
singlePhaseTransportModel laminarTransport(U, phi);
38+
singlePhaseTransportModel laminarTransport(U, phi);
39+
40+
autoPtr<incompressible::turbulenceModel> turbulence
41+
(
42+
incompressible::turbulenceModel::New(U, phi, laminarTransport)
43+
);
44+
45+
#include "createMRF.H"
46+
#include "createFvOptions.H"
3847

39-
autoPtr<incompressible::turbulenceModel> turbulence
40-
(
41-
incompressible::turbulenceModel::New(U, phi, laminarTransport)
42-
);

applications/pisoFoam_c3po/pEqn.H

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
volScalarField rAU(1.0/UEqn.A());
2+
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
3+
surfaceScalarField phiHbyA
4+
(
5+
"phiHbyA",
6+
fvc::flux(HbyA)
7+
+ MRF.zeroFilter(fvc::interpolate(rAU)*fvc::ddtCorr(U, phi))
8+
);
9+
10+
MRF.makeRelative(phiHbyA);
11+
12+
adjustPhi(phiHbyA, U, p);
13+
14+
// Update the pressure BCs to ensure flux consistency
15+
constrainPressure(p, U, phiHbyA, rAU, MRF);
16+
17+
// Non-orthogonal pressure corrector loop
18+
while (piso.correctNonOrthogonal())
19+
{
20+
// Pressure corrector
21+
22+
fvScalarMatrix pEqn
23+
(
24+
fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
25+
);
26+
27+
pEqn.setReference(pRefCell, pRefValue);
28+
29+
pEqn.solve(mesh.solver(p.select(piso.finalInnerIter())));
30+
31+
if (piso.finalNonOrthogonalIter())
32+
{
33+
phi = phiHbyA - pEqn.flux();
34+
}
35+
}
36+
37+
#include "continuityErrs.H"
38+
39+
U = HbyA - rAU*fvc::grad(p);
40+
U.correctBoundaryConditions();
41+
fvOptions.correct(U);

applications/pisoFoam_c3po/pisoFoam_c3po.C

Lines changed: 16 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -34,179 +34,45 @@ Description
3434
//Include CPPPO
3535
#include "c3po_OF_interface.H"
3636

37-
#include "OFversion.H"
38-
#if defined(version30)
39-
#include "turbulentTransportModel.H"
40-
#include "pisoControl.H"
41-
#else
42-
#include "turbulenceModel.H"
43-
#endif
44-
45-
4637
#include "fvCFD.H"
4738
#include "singlePhaseTransportModel.H"
48-
#include "turbulenceModel.H"
49-
50-
#if defined(versionv1606plus) || defined(version40)
51-
#include "fvOptions.H"
52-
#else
53-
#include "fvIOoptionList.H"
54-
#endif
55-
56-
#include "cellSet.H"
57-
#include "mpi.h"
58-
59-
60-
39+
#include "turbulentTransportModel.H"
40+
#include "pisoControl.H"
41+
#include "fvOptions.H"
6142

6243
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
6344

6445
int main(int argc, char *argv[])
6546
{
66-
#include "setRootCase.H"
47+
#include "postProcess.H"
6748

49+
#include "setRootCaseLists.H"
6850
#include "createTime.H"
6951
#include "createMesh.H"
70-
71-
#if defined(version30)
72-
pisoControl piso(mesh);
73-
#include "createTimeControls.H"
74-
#endif
75-
52+
#include "createControl.H"
7653
#include "createFields.H"
7754
#include "initContinuityErrs.H"
78-
#include "createFvOptions.H"
79-
80-
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81-
82-
int flag;
83-
MPI_Initialized(&flag);
84-
if (!flag)
85-
{
86-
int argc = 0;
87-
char **argv = NULL;
88-
MPI_Init(&argc,&argv);
89-
}
90-
int proc_name;
91-
MPI_Comm_rank(MPI_COMM_WORLD,&proc_name);
92-
93-
94-
9555

56+
turbulence->validate();
9657

97-
# include "c3po_modifications_1.H"
9858

59+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
9960

61+
// Initialise C3PO library
62+
#include "c3po_modifications_1.H"
10063

10164
Info<< "\nStarting time loop\n" << endl;
102-
10365
while (runTime.loop())
10466
{
105-
Info<< "Time = " << runTime.timeName() << nl << endl;
106-
107-
#if defined(version30)
108-
#include "readTimeControls.H"
109-
#include "CourantNo.H"
110-
#include "setDeltaT.H"
111-
#else
112-
#include "readPISOControls.H"
113-
#include "CourantNo.H"
114-
#endif
67+
68+
#include "solvePISO.H"
11569

116-
117-
118-
// Pressure-velocity PISO corrector
70+
// Call C3PO every time OF writes to disk
71+
if(runTime.write())
11972
{
120-
// Momentum predictor
121-
122-
fvVectorMatrix UEqn
123-
(
124-
fvm::ddt(U)
125-
+ fvm::div(phi, U)
126-
+ turbulence->divDevReff(U)
127-
- fvOptions(U)
128-
);
129-
130-
UEqn.relax();
131-
132-
#if defined(version30)
133-
if (piso.momentumPredictor())
134-
#else
135-
if (momentumPredictor)
136-
#endif
137-
{
138-
solve(UEqn == -fvc::grad(p));
139-
}
140-
141-
// --- PISO loop
142-
143-
#if defined(version30)
144-
while (piso.correct())
145-
#else
146-
int nCorrSoph = nCorr + 5 * pow((1-particleCloud.dataExchangeM().timeStepFraction()),1);
147-
for (int corr=0; corr<nCorrSoph; corr++)
148-
#endif
149-
{
150-
volScalarField rAU(1.0/UEqn.A());
151-
152-
volVectorField HbyA("HbyA", U);
153-
HbyA = rAU*UEqn.H();
154-
surfaceScalarField phiHbyA
155-
(
156-
"phiHbyA",
157-
(fvc::interpolate(HbyA) & mesh.Sf())
158-
+ fvc::interpolate(rAU)*fvc::ddtCorr(U, phi)
159-
);
160-
161-
adjustPhi(phiHbyA, U, p);
162-
163-
// Non-orthogonal pressure corrector loop
164-
#if defined(version30)
165-
while (piso.correctNonOrthogonal())
166-
#else
167-
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
168-
#endif
169-
{
170-
// Pressure corrector
171-
172-
fvScalarMatrix pEqn
173-
(
174-
fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
175-
);
176-
177-
pEqn.setReference(pRefCell, pRefValue);
178-
179-
#if defined(version30)
180-
pEqn.solve(mesh.solver(p.select(piso.finalInnerIter())));
181-
182-
#else
183-
if( corr == nCorr-1 && nonOrth == nNonOrthCorr )
184-
pEqn.solve(mesh.solver("pFinal"));
185-
else
186-
pEqn.solve();
187-
188-
189-
#endif
190-
191-
}
192-
193-
#include "continuityErrs.H"
194-
195-
U = HbyA - rAU*fvc::grad(p);
196-
U.correctBoundaryConditions();
197-
}
73+
# include "c3po_modifications_2.H"
74+
runTime.write();
19875
}
199-
200-
turbulence->correct();
201-
202-
//In this example CPPPO is called when OF writes data to disk
203-
204-
if(runTime.write())
205-
{
206-
# include "c3po_modifications_2.H"
207-
208-
runTime.write();
209-
}
21076
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
21177
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
21278
<< nl << endl;

0 commit comments

Comments
 (0)