initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / tutorials / interDyMFoam / sloshingTank3D6DoF / gen6DoF / gen6DoF.C
blob0d97918551c1b4218414e817c5e86e6f5fedd100
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
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 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
19     for more details.
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
25 Application
26     gen6DoF
28 Description
29     Generate simple sinusoidal 6-DoF motion control-file.
31 \*---------------------------------------------------------------------------*/
33 #include "List.H"
34 #include "vector.H"
35 #include "Vector2D.H"
36 #include "Tuple2.H"
37 #include "OFstream.H"
39 using namespace Foam;
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 // Main program:
44 int main(int argc, char *argv[])
46     // End-time of the table
47     const scalar endTime = 40;
49     // Number of entries in the table
50     const label nTimes = 100;
52     // Amplitude of the translation [m]
53     const vector transAmp(2, 3, 2);
55     // Frequency of the translation [rad/s]
56     const vector transOmega(0.5, 0.8, 0.4);
58     // Amplitude of the rotation [deg]
59     const vector rotAmp(30, 10, 10);
61     // Frequency of the rotation [rad/s]
62     const vector rotOmega(0.4, 0.7, 0.5);
64     List<Tuple2<scalar,  Vector2D<vector> > > timeValues(nTimes);
66     forAll(timeValues, i)
67     {
68         scalar t = (endTime*i)/(nTimes - 1);
69         timeValues[i].first() = t;
71         timeValues[i].second()[0] = vector
72         (
73             transAmp.x()*Foam::sin(transOmega.x()*t),
74             transAmp.y()*Foam::sin(transOmega.y()*t),
75             transAmp.z()*Foam::sin(transOmega.z()*t)
76         );
78         timeValues[i].second()[1] = vector
79         (
80             rotAmp.x()*Foam::sin(rotOmega.x()*t),
81             rotAmp.y()*Foam::sin(rotOmega.y()*t),
82             rotAmp.z()*Foam::sin(rotOmega.z()*t)
83         );
84     }
86     {
87         OFstream dataFile("6DoF.dat");
88         dataFile << timeValues << endl;
89     }
91     Info << "End\n" << endl;
93     return 0;
97 // ************************************************************************* //