Initial commit of NavalHydro package from Wikki to the ShipHydroSIG
[ShipHydroSIG.git] / src / navalFoam / navalFoam.C
blobb93d3c9b75aa0d97ec618175b0373bf5dd878319
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM 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 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Application
26     interDyMFoam
28 Description
29     Solver for 2 incompressible fluids capturing the interface with
30     dynamic mesh motion.
32     Turbulence modelling is generic, i.e.  laminar, RAS or LES may be selected.
34 Author
35     Hrvoje Jasak, Wikki Ltd.  All rights reserved.
37 \*---------------------------------------------------------------------------*/
39 #include "fvCFD.H"
40 #include "MULES.H"
41 #include "dynamicFvMesh.H"
42 #include "interfaceProperties.H"
43 #include "subCycle.H"
44 #include "twoPhaseMixture.H"
45 #include "turbulenceModel.H"
46 #include "numericalBeach.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 int main(int argc, char *argv[])
53 #   include "setRootCase.H"
54 #   include "createTime.H"
55 #   include "createDynamicFvMesh.H"
56 #   include "readGravitationalAcceleration.H"
57 #   include "initContinuityErrs.H"
58 #   include "initTotalVolume.H"
59 #   include "createFields.H"
60 #   include "readControls.H"
61 #   include "correctPhi.H"
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65     // Execute function objects
66     runTime.functionObjects().execute();
68     Info<< "\nStarting time loop\n" << endl;
70     while (runTime.run())
71     {
72 #       include "readControls.H"
73 #       include "checkTotalVolume.H"
74 #       include "CourantNo.H"
75 #       include "setDeltaT.H"
77         // Make the fluxes absolute
78         fvc::makeAbsolute(phi, U);
80         runTime++;
82         Info<< "Time = " << runTime.timeName() << nl << endl;
84         if (runTime.value() > startMotionTime)
85         {
86             bool meshChanged = mesh.update();
88 #           include "volContinuity.H"
90             // Mesh motion update
91             if (correctPhi && meshChanged)
92             {
93 #               include "correctPhi.H"
94             }
96             // Make the fluxes relative to the mesh motion
97             fvc::makeRelative(phi, U);
99             if (meshChanged)
100             {
101 #               include "CourantNo.H"
102             }
103         }
105         // Pressure-velocity corrector
106         int oCorr = 0;
107         do
108         {
109             gh = (g & mesh.C());
110             ghf = (g & mesh.Cf());
112             twoPhaseProperties.correct();
114 #           include "UEqn.H"
116             // --- PISO loop
117             for (int corr=0; corr < nCorr; corr++)
118             {
119 #               include "pdEqn.H"
120             }
122 #           include "limitU.H"
124             if (mesh.moving())
125             {
126                 // Make the fluxes relative
127                 phi -= fvc::meshPhi(rho, U);
128                 rhoPhi = phi*fvc::interpolate(rho);
129             }
131 #           include "movingMeshRhoUContinuityErrs.H"
133             // Calculate static pressure
134             if (oCorr == nOuterCorr - 1)
135             {
136                 // Calculate static pressure
137                 Info << "Calculating static pressure" << endl;
138 #               include "pEqn.H"
139             }
141 #           include "alphaEqn.H"
143             turbulence->correct();
144         } while (++oCorr < nOuterCorr);
146         runTime.write();
148         Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
149             << "  ClockTime = " << runTime.elapsedClockTime() << " s"
150             << nl << endl;
151     }
153     Info<< "End\n" << endl;
155     return(0);
159 // ************************************************************************* //