25fv::options& fvOptions = _fvOptions();
26surfaceScalarField& phi = _phi();
27volScalarField& rho = _rho();
28fluidThermo& thermo = pThermo();
29volScalarField& psi = _psi();
30pressureControl& pressureControl = _pressureControl();
31fvMesh& mesh = _mesh();
32dimensionedScalar& initialMass = _initialMass();
33bool closedVolume =
false;
37Vector<double> uresidual_v(0, 0, 0);
41middleStep = para->ITHACAdict->lookupOrDefault<
int>(
"middleStep", 20);
48startOff = std::clock();
53std::ofstream snaps_os;
58std::ofstream cpuTimes;
61res_os.open(folder +
"/residuals", std::ios_base::app);
62snaps_os.open(folder +
"/snaps", std::ios_base::app);
63iters.open(folder +
"/iters", std::ios_base::app);
64cpuTimes.open(folder +
"/cpuTimes", std::ios_base::app);
66res_U.open(folder + name(counter) +
"/res_U", std::ios_base::app);
67res_P.open(folder + name(counter) +
"/res_P", std::ios_base::app);
68res_E.open(folder + name(counter) +
"/res_E", std::ios_base::app);
74tolerance = ITHACAdict->lookupOrDefault<scalar>(
"tolerance", 1e-5);
75maxIter = ITHACAdict->lookupOrDefault<scalar>(
"maxIter", 2000);
77turbulence->validate();
81while (simple.loop(runTime) && residual > tolerance && csolve < maxIter )
83while (simple.loop() && residual > tolerance && csolve < maxIter )
86 Info <<
"Time = " << runTime.timeName() << nl << endl;
90 if (simple.momentumPredictor())
92 uresidual_v = solve(Ueqn_global() == - getGradP(p)).initialResidual();
98 eresidual = Eeqn_global().solve().initialResidual();
99 fvOptions.correct(thermo.he());
102 constrainPressure(p, rho, U, getPhiHbyA(Ueqn_global(), U, p),
103 getRhorAUf(Ueqn_global()));
104 surfaceScalarField phiHbyACalculated = getPhiHbyA(Ueqn_global(), U, p);
105 closedVolume = adjustPhi(phiHbyACalculated, U, p);
107 while (simple.correctNonOrthogonal())
109 getPmatrix(Ueqn_global(), U, p);
110 presidual = Peqn_global().solve().initialResidual();
112 if (simple.finalNonOrthogonalIter())
114 phi = getPhiHbyA(Ueqn_global(), U, p) + Peqn_global().flux();
118#include "continuityErrs.H"
120 U = HbyA() - (1.0 / Ueqn_global().A()) * getGradP(p);
121 U.correctBoundaryConditions();
122 fvOptions.correct(U);
123 bool pLimited = pressureControl.limit(p);
128 p += (initialMass - fvc::domainIntegrate(psi * p))
129 / fvc::domainIntegrate(psi);
132 if (pLimited || closedVolume)
134 p.correctBoundaryConditions();
139 auto uresidual =
max(
max(uresidual_v[0], uresidual_v[1]), uresidual_v[2]);
140 residual =
max(
max(presidual, uresidual), eresidual);
141 Foam::Info <<
"\nResidual: " << residual << Foam::endl << Foam::endl;
142 turbulence->correct();
144 Foam::Info <<
"ExecutionTime = " << runTime.elapsedCpuTime() <<
" s"
145 <<
" ClockTime = " << runTime.elapsedClockTime() <<
" s"
146 << Foam::endl << Foam::endl;
148 Foam::Info <<
"saver ================== \t" << saver << Foam::endl;
150 if (middleExport && saver == middleStep)
157 auto nut = _mesh().lookupObject<volScalarField>(
"nut");
159 Ufield.append(U.clone());
160 Pfield.append(p.clone());
161 Efield.append(E.clone());
162 nutFields.append(nut.clone());
163 res_U << uresidual << std::endl;
164 res_P << presidual << std::endl;
165 res_E << eresidual << std::endl;
169snaps_os << folderN + 1 << std::endl;
171iters << csolve << std::endl;
172res_os << residual << std::endl;
174cpuTimes << std::clock() - startOff << std::endl;
187 auto nut = _mesh().lookupObject<volScalarField>(
"nut");
195 auto nut = _mesh().lookupObject<volScalarField>(
"nut");
199Ufield.append(U.clone());
200Pfield.append(p.clone());
201Efield.append(E.clone());
202auto nut = _mesh().lookupObject<volScalarField>(
"nut");
203nutFields.append(nut.clone());
207runTime.setTime(runTime.startTime(), 0);
Class for the definition of some general parameters, the parameters must be defined from the file ITH...
static ITHACAparameters * getInstance()
Gets an instance of ITHACAparameters, to be used if the instance is already existing.
T max(Eigen::SparseMatrix< T > &mat, label &ind_row, label &ind_col)
Find the maximum of a sparse Matrix (Useful for DEIM).
void exportSolution(GeometricField< Type, PatchField, GeoMesh > &s, fileName subfolder, fileName folder, word fieldName)
Export a field to file in a certain folder and subfolder.