BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / applications / utilities / mesh / manipulation / rotateMesh / rotateMesh.C
blob2046e2e700c76fe586cbd2963738418405e06e09
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 Application
25     rotateMesh
27 Description
28     Rotates the mesh and fields from the direcion n1 to the direction n2.
30 \*---------------------------------------------------------------------------*/
32 #include "argList.H"
33 #include "timeSelector.H"
34 #include "Time.H"
35 #include "fvMesh.H"
36 #include "volFields.H"
37 #include "surfaceFields.H"
38 #include "transformGeometricField.H"
39 #include "IOobjectList.H"
41 using namespace Foam;
43 template<class GeometricField>
44 void RotateFields
46     const fvMesh& mesh,
47     const IOobjectList& objects,
48     const tensor& T
51     // Search list of objects for volScalarFields
52     IOobjectList fields(objects.lookupClass(GeometricField::typeName));
54     forAllIter(IOobjectList, fields, fieldIter)
55     {
56         Info<< "    Rotating " << fieldIter()->name() << endl;
58         GeometricField theta(*fieldIter(), mesh);
59         transform(theta, dimensionedTensor(T), theta);
60         theta.write();
61     }
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67 int main(int argc, char *argv[])
69     timeSelector::addOptions();
71     argList::validArgs.append("n1");
72     argList::validArgs.append("n2");
74 #   include "setRootCase.H"
75 #   include "createTime.H"
77     vector n1 = args.argRead<vector>(1);
78     n1 /= mag(n1);
80     vector n2 = args.argRead<vector>(2);
81     n2 /= mag(n2);
83     tensor T = rotationTensor(n1, n2);
85     {
86         pointIOField points
87         (
88             IOobject
89             (
90                 "points",
91                 runTime.findInstance(polyMesh::meshSubDir, "points"),
92                 polyMesh::meshSubDir,
93                 runTime,
94                 IOobject::MUST_READ,
95                 IOobject::NO_WRITE,
96                 false
97             )
98         );
100         points = transform(T, points);
102         // Set the precision of the points data to 10
103         IOstream::defaultPrecision(10);
105         Info<< "Writing points into directory " << points.path() << nl << endl;
106         points.write();
107     }
110     instantList timeDirs = timeSelector::select0(runTime, args);
112 #   include "createMesh.H"
115     forAll(timeDirs, timeI)
116     {
117         runTime.setTime(timeDirs[timeI], timeI);
119         Info<< "Time = " << runTime.timeName() << endl;
121         // Search for list of objects for this time
122         IOobjectList objects(mesh, runTime.timeName());
124         RotateFields<volVectorField>(mesh, objects, T);
125         RotateFields<volSphericalTensorField>(mesh, objects, T);
126         RotateFields<volSymmTensorField>(mesh, objects, T);
127         RotateFields<volTensorField>(mesh, objects, T);
129         RotateFields<surfaceVectorField>(mesh, objects, T);
130         RotateFields<surfaceSphericalTensorField>(mesh, objects, T);
131         RotateFields<surfaceSymmTensorField>(mesh, objects, T);
132         RotateFields<surfaceTensorField>(mesh, objects, T);
133     }
135     Info<< "\nEnd.\n" << endl;
137     return 0;
141 // ************************************************************************* //