66 NPdModes = Dmodes.size();
69 problem->samples.resize(NPdModes);
70 problem->rbfSplines.resize(NPdModes);
71 Eigen::MatrixXd weights;
73 for (label i = 0; i < NPdModes; i++)
75 word weightName =
"wRBF_M" + name(i + 1);
79 problem->samples[i] =
new SPLINTER::DataTable(
true,
true);
81 for (label j = 0; j < coeffL2.cols();
84 problem->samples[i]->addSample(muu.row(j), coeffL2(i, j));
88 problem->rbfSplines[i] =
new SPLINTER::RBFSpline(*(
problem->samples)[i],
89 SPLINTER::RadialBasisFunctionType::THIN_PLATE_SPLINE, weights);
90 Info <<
"Constructing RadialBasisFunction for mode " << i + 1 << endl;
94 problem->samples[i] =
new SPLINTER::DataTable(
true,
true);
96 for (label j = 0; j < coeffL2.cols();
99 problem->samples[i]->addSample(muu.row(j), coeffL2(i, j));
102 problem->rbfSplines[i] =
new SPLINTER::RBFSpline(*(
problem->samples)[i],
103 SPLINTER::RadialBasisFunctionType::THIN_PLATE_SPLINE);
105 "./ITHACAoutput/weights/", weightName);
106 Info <<
"Constructing RadialBasisFunction for mode " << i + 1 << endl;
118 Eigen::MatrixXd a = Eigen::VectorXd::Zero(NmodesUproj);
119 Eigen::MatrixXd b = Eigen::VectorXd::Zero(NmodesPproj);
120 Time& runTime =
problem->_runTime();
121 dynamicFvMesh& mesh =
problem->meshPtr();
123 fv::options& fvOptions =
problem->_fvOptions();
124 pimpleControl& pimple =
problem->_pimple();
125 volScalarField& p =
problem->_p();
126 volVectorField& U =
problem->_U();
127 surfaceScalarField& phi =
problem->_phi();
128 pointVectorField& pointDisplacement =
problem->_pointDisplacement();
129 IOMRFZoneList& MRF =
problem->_MRF();
130 singlePhaseTransportModel& laminarTransport =
problem->_laminarTransport();
132 autoPtr<incompressible::turbulenceModel> turbulence(
133 incompressible::turbulenceModel::New(U,
134 phi, laminarTransport));
135 instantList Times = runTime.times();
136 runTime.setEndTime(finalTime);
138 runTime.setTime(Times[1], 1);
139 runTime.setDeltaT(timeStep);
140 nextWrite = startTime;
142 scalar pRefValue = 0.0;
143 bool correctPhi =
problem->correctPhi;
144 bool checkMeshCourantNo =
problem->checkMeshCourantNo;
145 bool moveMeshOuterCorrectors =
problem->moveMeshOuterCorrectors;
146 scalar cumulativeContErr =
problem->cumulativeContErr;
147#include "createUfIfPresent.H"
148 turbulence->validate();
149 dictionary dictCoeffs(
150 problem->dyndict->findDict(
"sixDoFRigidBodyMotionCoeffs"));
151 Foam::functionObjects::forces romforces(
"romforces", mesh, dictCoeffs);
152 sixDoFRigidBodyMotion sDRBM(dictCoeffs, dictCoeffs, runTime );
153 Foam::dimensionedVector g(
"g", dimAcceleration, Zero);
154 dictCoeffs.readIfPresent(
"g", g);
157 bool firstIter =
false;
158 Eigen::MatrixXd pdCoeff(NmodesDproj, 1);
160 label curTimeIndex_ = -1;
162 Eigen::MatrixXd muEval(1, 1);
178 while (runTime.run())
180 runTime.setEndTime(finalTime);
183 Info <<
"Time = " << runTime.timeName() << nl << endl;
187 while (pimple.loop())
189#include "CourantNo.H"
191 if (pimple.firstIter() || moveMeshOuterCorrectors)
193#include"CylinderMotion.H"
202 phi = mesh.Sf() & Uf();
204 fvc::makeRelative(phi, U);
207 if (checkMeshCourantNo)
209#include "meshCourantNo.H"
221 + turbulence->divDevReff(U)
226 fvOptions.constrain(UEqn);
227 List<Eigen::MatrixXd> RedLinSysU;
229 if (pimple.momentumPredictor())
232 RedLinSysU = Umodes.project(UEqn, NmodesUproj,
"G");
233 volVectorField gradpfull = -fvc::grad(p);
234 Eigen::MatrixXd projGrad = Umodes.project(gradpfull, NmodesUproj);
235 RedLinSysU[1] = RedLinSysU[1] + projGrad;
240 a = RedLinSysU[0].colPivHouseholderQr().solve(RedLinSysU[1]);
270 Umodes.reconstruct(U, a,
"U");
272 fvOptions.correct(U);
279 while (pimple.correct())
281 volScalarField rAU(1.0 / UEqn.A());
282 volVectorField HbyA(constrainHbyA(rAU * UEqn.H(), U, p));
283 surfaceScalarField phiHbyA(
"phiHbyA", fvc::flux(HbyA));
284 tmp<volScalarField> rAtU(rAU);
286 constrainPressure(p, U, phiHbyA, rAtU(), MRF);
287 List<Eigen::MatrixXd> RedLinSysP;
290 while (pimple.correctNonOrthogonal())
294 fvm::laplacian(rAtU(), p)
298 pEqn.setReference(pRefCell, pRefValue);
300 RedLinSysP =
Pmodes.project(pEqn, NmodesPproj,
"G");
303 b = RedLinSysP[0].colPivHouseholderQr().solve(RedLinSysP[1]);
319 Pmodes.reconstruct(p, b,
"p");
325 if (pimple.finalNonOrthogonalIter())
327 phi = phiHbyA - pEqn.flux();
334 U = HbyA - rAtU * fvc::grad(p);
335 U.correctBoundaryConditions();
336 fvOptions.correct(U);
341 fvc::correctUf(Uf, U, phi);
343 fvc::makeRelative(phi, U);
349 centerofmassy.append(sDRBM.centreOfMass().y());
350 pdcoeffrbf.append(pdCoeff(0, 0));
353 romforcey.append(romforces.forceEff().y());
354 romforcex.append(romforces.forceEff().x());
356 if (runTime.time().value() + runTime.deltaT().value() >= finalTime)
358 Info <<
"===== Storing final mesh =====" << endl;
363 ListOfpoints.append(mesh.points().clone());
365 UredFields.append(U.clone());
366 PredFields.append(p.clone());
367 Dfield.append(pointDisplacement.clone());
369 nextWrite += writeEvery;