24 Info <<
"Deform the mesh for field inversion...." << endl;
29 "prescribe the origin to deform the mesh");
34 "prescribe the axis to deform the mesh");
39 "prescribe the angular velocity to deform the mesh");
44 "prescribe a specific time to deform the mesh");
46 #include "setRootCase.H"
47 #include "createTime.H"
48 #include "createMesh.H"
50 vector origin = {0.0, 0.0, 0.0};
51 if (
args.readIfPresent(
"origin", origin))
53 Info <<
"The origin to rotate the mesh: " << origin << endl;
57 Info <<
"origin not set!" << endl;
60 vector
axis = {0, 0, 0};
61 if (
args.readIfPresent(
"axis",
axis))
63 Info <<
"The axis to rotate the mesh: " <<
axis << endl;
67 Info <<
"axis center not set!" << endl;
71 if (
args.readIfPresent(
"omega", omega))
73 Info <<
"The angular velocity to rotate the mesh: " << omega << endl;
77 Info <<
"omega not set! Don't rotate mesh." << endl;
81 if (
args.optionFound(
"time"))
83 time = readScalar(
args.optionLookup(
"time")());
86 Info <<
"Deform latestTime" << endl;
90 Info <<
"Deform time = " << time << endl;
95 Info <<
"Time not set! Deform all time instances." << endl;
98 Info <<
"Deforming the mesh..." << endl;
104 Info <<
"Time = " <<
runTime.timeName() << nl << endl;
106 pointField ourNewPoints(
mesh.points());
108 scalar cosTheta = std::cos(
theta);
109 scalar sinTheta = std::sin(
theta);
111 forAll(ourNewPoints, pointI)
113 scalar xTemp = ourNewPoints[pointI][0] - origin[0];
114 scalar yTemp = ourNewPoints[pointI][1] - origin[1];
116 ourNewPoints[pointI][0] = cosTheta * xTemp - sinTheta * yTemp + origin[0];
117 ourNewPoints[pointI][1] = sinTheta * xTemp + cosTheta * yTemp + origin[1];
120 mesh.movePoints(ourNewPoints);
122 pointIOField writePoints(
129 IOobject::AUTO_WRITE),
135 Info <<
"Finished!" << endl;