rotateMesh.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "argList.H"
00034 #include "timeSelector.H"
00035 #include "Time.H"
00036 #include "fvMesh.H"
00037 #include "volFields.H"
00038 #include "surfaceFields.H"
00039 #include "transformGeometricField.H"
00040 #include "IOobjectList.H"
00041
00042 using namespace Foam;
00043
00044 template<class GeometricField>
00045 void RotateFields
00046 (
00047 const fvMesh& mesh,
00048 const IOobjectList& objects,
00049 const tensor& T
00050 )
00051 {
00052
00053 IOobjectList fields(objects.lookupClass(GeometricField::typeName));
00054
00055 forAllIter(IOobjectList, fields, fieldIter)
00056 {
00057 Info<< " Rotating " << fieldIter()->name() << endl;
00058
00059 GeometricField theta(*fieldIter(), mesh);
00060 transform(theta, dimensionedTensor(T), theta);
00061 theta.write();
00062 }
00063 }
00064
00065
00066
00067
00068 int main(int argc, char *argv[])
00069 {
00070 timeSelector::addOptions();
00071
00072 argList::validArgs.append("n1");
00073 argList::validArgs.append("n2");
00074
00075 # include "setRootCase.H"
00076 # include "createTime.H"
00077
00078 vector n1(IStringStream(args.additionalArgs()[0])());
00079 n1 /= mag(n1);
00080
00081 vector n2(IStringStream(args.additionalArgs()[1])());
00082 n2 /= mag(n2);
00083
00084 tensor T = rotationTensor(n1, n2);
00085
00086 {
00087 pointIOField points
00088 (
00089 IOobject
00090 (
00091 "points",
00092 runTime.findInstance(polyMesh::meshSubDir, "points"),
00093 polyMesh::meshSubDir,
00094 runTime,
00095 IOobject::MUST_READ,
00096 IOobject::NO_WRITE,
00097 false
00098 )
00099 );
00100
00101 points = transform(T, points);
00102
00103
00104 IOstream::defaultPrecision(10);
00105
00106 Info << "Writing points into directory " << points.path() << nl << endl;
00107 points.write();
00108 }
00109
00110
00111 instantList timeDirs = timeSelector::select0(runTime, args);
00112
00113 # include "createMesh.H"
00114
00115
00116 forAll(timeDirs, timeI)
00117 {
00118 runTime.setTime(timeDirs[timeI], timeI);
00119
00120 Info<< "Time = " << runTime.timeName() << endl;
00121
00122
00123 IOobjectList objects(mesh, runTime.timeName());
00124
00125 RotateFields<volVectorField>(mesh, objects, T);
00126 RotateFields<volSphericalTensorField>(mesh, objects, T);
00127 RotateFields<volSymmTensorField>(mesh, objects, T);
00128 RotateFields<volTensorField>(mesh, objects, T);
00129
00130 RotateFields<surfaceVectorField>(mesh, objects, T);
00131 RotateFields<surfaceSphericalTensorField>(mesh, objects, T);
00132 RotateFields<surfaceSymmTensorField>(mesh, objects, T);
00133 RotateFields<surfaceTensorField>(mesh, objects, T);
00134 }
00135
00136 Info<< "\nEnd.\n" << endl;
00137
00138 return 0;
00139 }
00140
00141
00142
Copyright © 2000-2009 OpenCFD Ltd