Forward compatibility: flex
[foam-extend-3.2.git] / applications / solvers / incompressible / icoDyMSimpleFoam / icoDyMSimpleFoam.C
blobb29c58ad9167a01d80cec2dc406396aab7d29038
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Application
25     icoDyMSimpleFoam
27 Description
28     Transient solver for incompressible, laminar flow of Newtonian fluids
29     with dynamic mesh.  Solver implements a SIMPLE-based algorithm
30     in time-stepping mode.
32 Author
33     Hrvoje Jasak, Wikki Ltd.  All rights reserved.
35 \*---------------------------------------------------------------------------*/
37 #include "fvCFD.H"
38 #include "dynamicFvMesh.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 int main(int argc, char *argv[])
44 #   include "setRootCase.H"
45 #   include "createTime.H"
46 #   include "createDynamicFvMesh.H"
47 #   include "initContinuityErrs.H"
48 #   include "initTotalVolume.H"
49 #   include "createFields.H"
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53     Info<< "\nStarting time loop\n" << endl;
55     while (runTime.run())
56     {
57 #       include "readControls.H"
58 #       include "checkTotalVolume.H"
59 #       include "CourantNo.H"
61         // Make the fluxes absolute
62         fvc::makeAbsolute(phi, U);
64 #       include "setDeltaT.H"
66         runTime++;
68         Info<< "Time = " << runTime.timeName() << nl << endl;
70         bool meshChanged = mesh.update();
71         reduce(meshChanged, orOp<bool>());
73 #       include "volContinuity.H"
75         if (correctPhi && meshChanged)
76         {
77             // Fluxes will be corrected to absolute velocity
78             // HJ, 6/Feb/2009
79 #           include "correctPhi.H"
80         }
82         // Make the fluxes relative to the mesh motion
83         fvc::makeRelative(phi, U);
85         if (checkMeshCourantNo)
86         {
87 #           include "meshCourantNo.H"
88         }
90         // --- SIMPLE loop
92         for (int ocorr = 0; ocorr < nOuterCorr; ocorr++)
93         {
94 #           include "CourantNo.H"
96 #           include "UEqn.H"
98             rAU = 1.0/UEqn.A();
100             U = rAU*UEqn.H();
101             phi = (fvc::interpolate(U) & mesh.Sf());
102               //+ fvc::ddtPhiCorr(rAU, U, phi);
104             adjustPhi(phi, U, p);
106             p.storePrevIter();
108             for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
109             {
110                 fvScalarMatrix pEqn
111                 (
112                     fvm::laplacian(rAU, p) == fvc::div(phi)
113                 );
115                 pEqn.setReference(pRefCell, pRefValue);
117                 if
118                 (
119                     ocorr == nOuterCorr - 1
120                  && nonOrth == nNonOrthCorr
121                 )
122                 {
123                     pEqn.solve(mesh.solutionDict().solver(p.name() + "Final"));
124                 }
125                 else
126                 {
127                     pEqn.solve(mesh.solutionDict().solver(p.name()));
128                 }
130                 if (nonOrth == nNonOrthCorr)
131                 {
132                     phi -= pEqn.flux();
133                 }
134             }
136 #           include "continuityErrs.H"
138             // Explicitly relax pressure for momentum corrector
139             p.relax();
141             // Make the fluxes relative to the mesh motion
142             fvc::makeRelative(phi, U);
144             U -= rAU*fvc::grad(p);
145             U.correctBoundaryConditions();
146         }
148         runTime.write();
150         Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
151             << "  ClockTime = " << runTime.elapsedClockTime() << " s"
152             << nl << endl;
153     }
155     Info<< "End\n" << endl;
157     return(0);
161 // ************************************************************************* //