fixed writing out entries in advective bc
[OpenFOAM-1.6-ext.git] / src / ODE / sixDOF / sixDOFbodies / sixDOFbodies.C
blob9e2e6521bb399b0626a1bbbaab25baef4a8132c9
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
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 Class
26     sixDOFbodies
28 Description
29     6-DOF solver for multiple bodies
31 Author
32     Dubravko Matijasevic, FSB Zagreb.  All rights reserved.
34 \*----------------------------------------------------------------------------*/
36 #include "sixDOFbodies.H"
38 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
40 void Foam::sixDOFbodies::setBodies()
42     // Find if duplicate name existes
43     forAll (names_, bodyI)
44     {
45         for
46         (
47             label otherBody = bodyI + 1;
48             otherBody < names_.size();
49             otherBody++
50         )
51         {
52             if (names_[bodyI] == names_[otherBody])
53             {
54                 FatalErrorIn("sixDOFbodies::setBodies()")
55                     << "Duplicate names of bodies: this is not allowed" 
56                     << exit(FatalError);
57             }
58         }
59     }
61     odes_.setSize(names_.size());
62     solvers_.setSize(names_.size());
64     forAll (names_, bodyI)
65     {
66         odes_.set
67         (
68             bodyI,
69             new sixDOFqODE
70             (
71                 IOobject
72                 (
73                     names_[bodyI],
74                     runTime_.timeName(),
75                     runTime_,
76                     IOobject::MUST_READ,
77                     IOobject::AUTO_WRITE
78                 )
79             )
80         );
82         solvers_.set
83         (
84             bodyI,
85             ODESolver::New
86             (
87                 lookup("solver"),
88                 odes_[bodyI]
89             )
90         );
91     }
95 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
97 Foam::sixDOFbodies::sixDOFbodies
99     const Time& runTime
102     IOdictionary
103     (
104         IOobject
105         (
106             "sixDOFsolverDict",
107             runTime.system(),
108             runTime,
109             IOobject::MUST_READ,
110             IOobject::NO_WRITE
111         )
112     ),
113     runTime_(runTime),
114     odes_(),
115     solvers_(),
116     names_(lookup("bodies"))
118     setBodies();
122 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
124 void Foam::sixDOFbodies::solve()
126     const scalar tol = readScalar(lookup("eps"));
128     forAll (odes_, bodyI)
129     {
130         Info << "Solving 6-DOF for " << names_[bodyI] << " in time" 
131          << tab << "T = " << runTime_.value() << " s" << endl;
133         solvers_[bodyI].solve
134         (
135             runTime_.value(),
136             runTime_.value() + runTime_.deltaT().value(),
137             tol,
138             runTime_.deltaT().value()
139         );
140     }
144 const Foam::wordList& Foam::sixDOFbodies::names() const
146     return names_;
150 const Foam::PtrList<Foam::sixDOFqODE>& Foam::sixDOFbodies::operator()() const
152     return odes_;
156 // ************************************************************************* //