potentialFreeSurfaceFoam.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  potentialFreeSurfaceFoam
26 
27 Description
28  Incompressible Navier-Stokes solver with inclusion of a wave height field
29  to enable single-phase free-surface approximations, with optional mesh
30  motion and mesh topology changes.
31 
32  Wave height field, zeta, used by pressure boundary conditions.
33 
34  Optional mesh motion and mesh topology changes including adaptive
35  re-meshing.
36 
37  Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected.
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #include "fvCFD.H"
42 #include "viscosityModel.H"
44 #include "pimpleControl.H"
45 #include "pressureReference.H"
46 #include "fvModels.H"
47 #include "fvConstraints.H"
48 #include "CorrectPhi.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 int main(int argc, char *argv[])
53 {
54  #include "postProcess.H"
55 
56  #include "setRootCaseLists.H"
57  #include "createTime.H"
58  #include "createMesh.H"
59  #include "initContinuityErrs.H"
60  #include "createDyMControls.H"
61  #include "createFields.H"
62 
64  (
65  IOobject
66  (
67  "rAU",
68  runTime.timeName(),
69  mesh,
70  IOobject::READ_IF_PRESENT,
71  IOobject::AUTO_WRITE
72  ),
73  mesh,
75  );
76 
77  #include "initCorrectPhi.H"
78 
79  #include "createUfIfPresent.H"
80 
81  turbulence->validate();
82 
83  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
84 
85  Info<< "\nStarting time loop\n" << endl;
86 
87  while (pimple.run(runTime))
88  {
89  #include "readDyMControls.H"
90  #include "CourantNo.H"
91  #include "setDeltaT.H"
92 
94 
95  const scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
96 
97  // Update the mesh for topology change, mesh to mesh mapping
98  const bool topoChanged = mesh.update();
99 
100  if (topoChanged)
101  {
102  Info<< "Execution time for mesh.update() = "
103  << runTime.elapsedCpuTime() - timeBeforeMeshUpdate
104  << " s" << endl;
105  }
106 
107  runTime++;
108 
109  Info<< "Time = " << runTime.userTimeName() << nl << endl;
110 
111  // --- Pressure-velocity PIMPLE corrector loop
112  while (pimple.loop())
113  {
114  if (pimple.firstPimpleIter() || moveMeshOuterCorrectors)
115  {
116  // Move the mesh
117  mesh.move();
118 
119  if (mesh.changing())
120  {
121  MRF.update();
122 
123  if (correctPhi)
124  {
125  #include "correctPhi.H"
126  }
127 
128  if (checkMeshCourantNo)
129  {
130  #include "meshCourantNo.H"
131  }
132  }
133  }
134 
135  fvModels.correct();
136 
137  #include "UEqn.H"
138 
139  // --- Pressure corrector loop
140  while (pimple.correct())
141  {
142  #include "pEqn.H"
143  }
144 
145  if (pimple.turbCorr())
146  {
147  viscosity->correct();
148  turbulence->correct();
149  }
150  }
151 
152  runTime.write();
153 
154  Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
155  << " ClockTime = " << runTime.elapsedClockTime() << " s"
156  << nl << endl;
157  }
158 
159  Info<< "End\n" << endl;
160 
161  return 0;
162 }
163 
164 
165 // ************************************************************************* //
pimpleNoLoopControl & pimple
IOMRFZoneList & MRF
virtual void correct()
Correct the fvModels.
Definition: fvModels.C:353
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
virtual void preUpdateMesh()
Prepare for mesh update.
Definition: fvModels.C:255
correctPhi
checkMeshCourantNo
fvMesh & mesh
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:58
const dimensionSet dimTime
Info<< "Reading field p\"<< endl;volScalarField p(IOobject("p", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading field U\"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);pressureReference pressureReference(p, simple.dict());mesh.schemes().setFluxRequired(p.name());Info<< "Reading field pa\"<< endl;volScalarField pa(IOobject("pa", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading field Ua\"<< endl;volVectorField Ua(IOobject("Ua", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);# 65 "/home/ubuntu/OpenFOAM-10/applications/solvers/incompressible/adjointShapeOptimisationFoam/createFields.H" 2label paRefCell=0;scalar paRefValue=0.0;setRefCell(pa, simple.dict(), paRefCell, paRefValue);mesh.schemes().setFluxRequired(pa.name());autoPtr< viscosityModel > viscosity(viscosityModel::New(mesh))
Info<< "Reading field U\"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);volScalarField rho(IOobject("rho", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), thermo.rho());volVectorField rhoU(IOobject("rhoU", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *U);volScalarField rhoE(IOobject("rhoE", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *(e+0.5 *magSqr(U)));surfaceScalarField pos(IOobject("pos", runTime.timeName(), mesh), mesh, dimensionedScalar(dimless, 1.0));surfaceScalarField neg(IOobject("neg", runTime.timeName(), mesh), mesh, dimensionedScalar(dimless, -1.0));surfaceScalarField phi("phi", fvc::flux(rhoU));Info<< "Creating turbulence model\"<< endl;autoPtr< compressible::momentumTransportModel > turbulence(compressible::momentumTransportModel::New(rho, U, phi, thermo))
Definition: createFields.H:94
static const char nl
Definition: Ostream.H:260
moveMeshOuterCorrectors
Foam::fvModels & fvModels
Calculates and outputs the mean and maximum Courant Numbers.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
tmp< volScalarField > rAU
messageStream Info
Execute application functionObjects to post-process existing results.
Creates and initialises the velocity field Uf if required.