1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Rotates the mesh and fields from the direcion n1 to the direction n2.
31 \*---------------------------------------------------------------------------*/
34 #include "timeSelector.H"
37 #include "volFields.H"
38 #include "surfaceFields.H"
39 #include "transformGeometricField.H"
40 #include "IOobjectList.H"
44 template<class GeometricField>
48 const IOobjectList& objects,
52 // Search list of objects for volScalarFields
53 IOobjectList fields(objects.lookupClass(GeometricField::typeName));
55 forAllIter(IOobjectList, fields, fieldIter)
57 Info<< " Rotating " << fieldIter()->name() << endl;
59 GeometricField theta(*fieldIter(), mesh);
60 transform(theta, dimensionedTensor(T), theta);
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 int main(int argc, char *argv[])
70 timeSelector::addOptions();
72 argList::validArgs.append("n1");
73 argList::validArgs.append("n2");
75 # include "setRootCase.H"
76 # include "createTime.H"
78 vector n1(IStringStream(args.additionalArgs()[0])());
81 vector n2(IStringStream(args.additionalArgs()[1])());
84 tensor T = rotationTensor(n1, n2);
92 runTime.findInstance(polyMesh::meshSubDir, "points"),
101 points = transform(T, points);
103 // Set the precision of the points data to 10
104 IOstream::defaultPrecision(10);
106 Info << "Writing points into directory " << points.path() << nl << endl;
111 instantList timeDirs = timeSelector::select0(runTime, args);
113 # include "createMesh.H"
116 forAll(timeDirs, timeI)
118 runTime.setTime(timeDirs[timeI], timeI);
120 Info<< "Time = " << runTime.timeName() << endl;
122 // Search for list of objects for this time
123 IOobjectList objects(mesh, runTime.timeName());
125 RotateFields<volVectorField>(mesh, objects, T);
126 RotateFields<volSphericalTensorField>(mesh, objects, T);
127 RotateFields<volSymmTensorField>(mesh, objects, T);
128 RotateFields<volTensorField>(mesh, objects, T);
130 RotateFields<surfaceVectorField>(mesh, objects, T);
131 RotateFields<surfaceSphericalTensorField>(mesh, objects, T);
132 RotateFields<surfaceSymmTensorField>(mesh, objects, T);
133 RotateFields<surfaceTensorField>(mesh, objects, T);
136 Info<< "\nEnd.\n" << endl;
142 // ************************************************************************* //