41 explicit tutorial17(
int argc,
char* argv[])
54 List<scalar> mu_now(1);
55 volVectorField U0 = U;
56 volScalarField P0 = p;
78 surfaceScalarField& phi =
_phi();
79 fvMesh& mesh =
_mesh();
80 volScalarField p =
_p();
81 volVectorField U =
_U();
82 IOMRFZoneList& MRF =
_MRF();
84 volVectorField Ulift(
"Ulift" + name(k), U);
85 instantList Times = runTime.times();
86 runTime.setTime(Times[1], 1);
87 pisoControl potentialFlow(mesh,
"potentialFlow");
88 Info <<
"Solving a lifting Problem" << endl;
89 Vector<double> v1(0, 0, 0);
92 Vector<double> v0(0, 0, 0);
94 for (label j = 0; j < U.boundaryField().size(); j++)
100 else if (U.boundaryField()[BCind].type() ==
"fixedValue")
109 phi = linearInterpolate(Ulift) & mesh.Sf();
112 Info <<
"Constructing velocity potential field Phi\n" << endl;
120 IOobject::READ_IF_PRESENT,
124 dimensionedScalar(
"Phi", dimLength * dimVelocity, 0),
125 p.boundaryField().types()
127 label PhiRefCell = 0;
128 scalar PhiRefValue = 0;
132 potentialFlow.dict(),
136 mesh.setFluxRequired(Phi.name());
137 runTime.functionObjects().start();
138 MRF.makeRelative(phi);
139 adjustPhi(phi, Ulift, p);
141 while (potentialFlow.correctNonOrthogonal())
143 fvScalarMatrix PhiEqn
145 fvm::laplacian(dimensionedScalar(
"1", dimless, 1), Phi)
149 PhiEqn.setReference(PhiRefCell, PhiRefValue);
152 if (potentialFlow.finalNonOrthogonalIter())
154 phi -= PhiEqn.flux();
158 MRF.makeAbsolute(phi);
159 Info <<
"Continuity error = "
160 << mag(fvc::div(phi))().weightedAverage(mesh.V()).value()
162 Ulift = fvc::reconstruct(phi);
163 Ulift.correctBoundaryConditions();
164 Info <<
"Interpolated velocity error = "
165 << (sqrt(sum(sqr((fvc::interpolate(U) & mesh.Sf()) - phi)))
166 / sum(mesh.magSf())).value()
180 dimensionedVector(
"zero", U.dimensions(), vector::zero)
182 volVectorField Uliftx(
"Uliftx" + name(k), Uzero);
183 Uliftx.replace(0, Ulift.component(0));
186 volVectorField Ulifty(
"Ulifty" + name(k), Uzero);
187 Ulifty.replace(1, Ulift.component(1));
198int main(
int argc,
char* argv[])
203 word par_offline_BC(
"./timeBCoff");
206 Eigen::MatrixXd timeBCoff3D = Eigen::MatrixXd::Zero(6, timeBCoff2D.cols());
207 timeBCoff3D.row(0) = timeBCoff2D.row(0);
208 timeBCoff3D.row(1) = timeBCoff2D.row(1);
209 timeBCoff3D.row(3) = timeBCoff2D.row(2);
210 timeBCoff3D.row(4) = timeBCoff2D.row(3);
211 example.timeBCoff = timeBCoff3D;
212 Eigen::MatrixXd par_on_BC;
213 word par_online_BC(
"./timeBCon");
218 int NmodesUout = para->ITHACAdict->lookupOrDefault<
int>(
"NmodesUout", 15);
219 int NmodesPout = para->ITHACAdict->lookupOrDefault<
int>(
"NmodesPout", 15);
220 int NmodesSUPout = para->ITHACAdict->lookupOrDefault<
int>(
"NmodesSUPout", 15);
221 int NmodesUproj = para->ITHACAdict->lookupOrDefault<
int>(
"NmodesUproj", 10);
222 int NmodesPproj = para->ITHACAdict->lookupOrDefault<
int>(
"NmodesPproj", 10);
223 int NmodesSUPproj = para->ITHACAdict->lookupOrDefault<
int>(
"NmodesSUPproj", 10);
224 int NmodesOut = para->ITHACAdict->lookupOrDefault<
int>(
"NmodesOut", 20);
230 example.setParameters();
232 example.mu_range(0, 0) = 0.01;
233 example.mu_range(0, 1) = 0.01;
235 example.genEquiPar();
237 example.inletIndex.resize(4, 2);
238 example.inletIndex(0, 0) = 1;
239 example.inletIndex(0, 1) = 0;
240 example.inletIndex(1, 0) = 1;
241 example.inletIndex(1, 1) = 1;
242 example.inletIndex(2, 0) = 2;
243 example.inletIndex(2, 1) = 0;
244 example.inletIndex(3, 0) = 2;
245 example.inletIndex(3, 1) = 1;
246 example.inletPatch.resize(2, 1);
247 example.inletPatch(0, 0) = example.inletIndex(0, 0);
248 example.inletPatch(1, 0) = example.inletIndex(2, 0);
250 example.startTime = 0;
251 example.finalTime = 12;
252 example.timeStep = 0.0005;
253 example.writeEvery = 0.03;
255 example.offlineSolve();
258 if (example.bcMethod ==
"lift")
267 example.liftSolve(BCs);
271 example.computeLift(example.Ufield, example.liftfield, example.Uomfield);
280 else if (example.bcMethod ==
"penalty")
292 example.projectPPE(
"./Matrices", NmodesUproj, NmodesPproj, NmodesSUPproj);
297 reduced.finalTime = 18;
299 reduced.storeEvery = 0.0005;
300 reduced.exportEvery = 0.03;
302 Eigen::MatrixXd vel_now = par_on_BC;
304 if (example.bcMethod ==
"penalty")
307 reduced.maxIterPenalty = 100;
308 reduced.tolerancePenalty = 1e-5;
309 reduced.timeStepPenalty = 5;
311 reduced.tauIter = Eigen::MatrixXd::Zero(4, 1);
312 reduced.tauIter << 1e-6, 1e-6, 1e-6, 1e-6;
314 reduced.tauU = reduced.penalty_PPE(vel_now, reduced.tauIter);
318 reduced.solveOnline_PPE(vel_now);
319 reduced.reconstruct(
false,
"./ITHACAoutput/Reconstruction/");
Header file of the ITHACAPOD class.
Header file of the ITHACAstream class, it contains the implementation of several methods for input ou...
Header file of the reducedUnsteadyNS class.
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.
Class where it is implemented a reduced problem for the unsteady Navier-stokes problem.
Eigen::MatrixXi inletPatch
Matrix that contains informations about the inlet boundaries without specifing the direction Rows = N...
void assignBC(volVectorField &s, label BC_ind, Vector< double > &value)
Assign Boundary Condition to a volVectorField.
void assignIF(T &s, G &value)
Assign internal field condition.
bool offline
Boolean variable, it is 1 if the Offline phase has already been computed, else 0.
Eigen::MatrixXd mu
Row matrix of parameters.
void truthSolve()
Perform a TruthSolve.
autoPtr< surfaceScalarField > _phi
Flux.
PtrList< volScalarField > Pfield
List of pointers used to form the pressure snapshots matrix.
autoPtr< Time > _runTime
Time.
PtrList< volVectorField > Ufield
List of pointers used to form the velocity snapshots matrix.
autoPtr< fvMesh > _mesh
Mesh.
PtrList< volVectorField > liftfield
List of pointers used to form the list of lifting functions.
autoPtr< IOMRFZoneList > _MRF
MRF variable.
autoPtr< volVectorField > _U
Velocity field.
void liftSolve()
Perform a lift solve.
autoPtr< volScalarField > _p
Pressure field.
unsteadyNS()
Construct Null.
void getModes(PtrList< GeometricField< Type, PatchField, GeoMesh > > &snapshots, PtrList< GeometricField< Type, PatchField, GeoMesh > > &modes, word fieldName, bool podex, bool supex, bool sup, label nmodes, bool correctBC)
Computes the bases or reads them for a field.
List< Eigen::MatrixXd > readMatrix(word folder, word mat_name)
Read a three dimensional matrix from a txt file in Eigen format.
void read_fields(PtrList< GeometricField< Type, PatchField, GeoMesh > > &Lfield, word Name, fileName casename, int first_snap, int n_snap)
Function to read a list of fields from the name of the field and casename.
void normalizeFields(PtrList< GeometricField< Type, fvPatchField, volMesh > > &fields)
Normalize list of Geometric fields.
Header file of the unsteadyNS class.