Loading...
Searching...
No Matches
NLsolve.H
1
2//Time& runTime = _runTime();
3dynamicFvMesh& mesh = meshPtr();
4dimensionedScalar& initialMass = _initialMass();
5surfaceScalarField& phi = _phi();
6volScalarField& rho = _rho();
7fluidThermo& thermo = pThermo();
8pressureControl& pressureControl = _pressureControl();
9volScalarField& psi = _psi();
10bool closedVolume = false;
11IOMRFZoneList& MRF = _MRF();
12fv::options& fvOptions = _fvOptions();
13const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, pimple.dict());
14const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, pimple.dict());
15
16
17Info << "\nStarting time loop\n" << endl;
18#include "createRhoUfIfPresent.H"
19#include "createDpdt.H"
20#include "createK.H"
21
22while (runTime.run())
23{
24 //#include "readDyMControls.H"
25 // Store divrhoU from the previous mesh so that it can be mapped
26 // and used in correctPhi to ensure the corrected phi has the
27 // same divergence
28 autoPtr<volScalarField> divrhoU;
29
30 if (correctPhi)
31 {
32 divrhoU.reset
33 (
34 new volScalarField
35 (
36 "divrhoU",
37 fvc::div(fvc::absolute(phi, rho, U))
38 )
39 );
40 }
41
42#include "compressibleCourantNo.H"
43 //#include "setDeltaT.H"
44 runTime.setEndTime(finalTime);
45 ++runTime;
46 Info << "Time = " << runTime.timeName() << nl << endl;
47
48 // --- Pressure-velocity PIMPLE corrector loop
49 while (pimple.loop())
50 {
51 if (pimple.firstIter() || moveMeshOuterCorrectors)
52 {
53 // Store momentum to set rhoUf for introduced faces.
54 autoPtr<volVectorField> rhoU;
55
56 if (rhoUf.valid())
57 {
58 rhoU.reset(new volVectorField("rhoU", rho * U));
59 }
60
61 // Do any mesh changes
62 mesh.controlledUpdate();
63
64 if (mesh.changing())
65 {
66 MRF.update();
67
68 if (correctPhi)
69 {
70 // Calculate absolute flux
71 // from the mapped surface velocity
72 phi = mesh.Sf() & rhoUf();
73#include "correctPhi.H"
74 // Make the fluxes relative to the mesh-motion
75 fvc::makeRelative(phi, rho, U);
76 }
77
78 if (checkMeshCourantNo)
79 {
80#include "meshCourantNo.H"
81 }
82 }
83 }
84
85 if (pimple.firstIter() && !pimple.SIMPLErho())
86 {
87#include "rhoEqn.H"
88 }
89
90#include "UEqn.H"
91#include "EEqn.H"
92
93 // --- Pressure corrector loop
94 while (pimple.correct())
95 {
96#include "pEqn.H"
97 }
98
99 if (pimple.turbCorr())
100 {
101 turbulence->correct();
102 }
103 }
104
105 rho = thermo.rho();
106
107 if (checkWrite(runTime))
108 {
109 ITHACAstream::exportSolution(U, name(counter), folder);
110 ITHACAstream::exportSolution(p, name(counter), folder);
111 ITHACAstream::exportSolution(E, name(counter), folder);
112 ITHACAstream::writePoints(meshPtr().points(), folder,
113 name(counter) + "/polyMesh/");
114 //ITHACAstream::exportSolution(_nut, name(counter), "./ITHACAoutput/Offline/");
115 std::ofstream of(folder + name(counter) + "/" + runTime.timeName());
116 Ufield.append(U.clone());
117 Pfield.append(p.clone());
118 Efield.append(E.clone());
119 nextWrite += writeEvery;
120 counter++;
121 //nutFields.append(_nut);
122 }
123}
void writePoints(pointField points, fileName folder, fileName subfolder)
Write points of a mesh to a file.
void exportSolution(GeometricField< Type, PatchField, GeoMesh > &s, fileName subfolder, fileName folder, word fieldName)
Export a field to file in a certain folder and subfolder.