initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / lagrangian / molecularDynamics / molecule / molecule / molecule.H
blobf0104963ac8230e150d84e90d0423eab52205987
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 Class
26     Foam::molecule
28 Description
29     Foam::molecule
31 SourceFiles
32     moleculeI.H
33     molecule.C
34     moleculeIO.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef molecule_H
39 #define molecule_H
41 #include "Particle.H"
42 #include "IOstream.H"
43 #include "autoPtr.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 // Class forward declarations
51 class moleculeCloud;
53 /*---------------------------------------------------------------------------*\
54                            Class molecule Declaration
55 \*---------------------------------------------------------------------------*/
57 class molecule
59     public Particle<molecule>
61     // Private data
63         //- Be careful with the ordering of data.
64         //  It has an impact on binary transfer:
65         //    -# Put the largest data members 1st
66         //    -# Pair up labels,
67         //    -# Don't go scalar-label, scalar-label, because in 64bit mode,
68         //       the labels will be padded by 4bytes.
70         // - mass of molecule
71         scalar mass_;
73         // - Velocity of molecule
74         vector U_;
76         // - Acceleration of molecule
77         vector A_;
79         // - Tether position
80         vector tetherPosition_;
82         // - Potential energy that this molecules posseses
83         scalar potentialEnergy_;
85         // - r_ij f_ij, stress dyad
86         tensor rf_;
88         // - Is the molecule tethered?
89         label tethered_;
91         // - id (type) of molecule
92         label id_;
95 public:
97     friend class Cloud<molecule>;
99     //- Class used to pass tracking data to the trackToFace function
100     class trackData
101     :
102         public Particle<molecule>::trackData
103     {
104         //- Reference to the cloud containing this particle
105         moleculeCloud& molCloud_;
107         // label specifying which part of the integration algorithm is taking
108         // place (i.e. leapfrog 1 or leapfrog 2. Predictor or Corrector)
109         label part_;
112     public:
114         // Constructors
116             inline trackData
117             (
118                 moleculeCloud& molCloud,
119                 label part
120             );
122         // Member functions
124             inline moleculeCloud& molCloud();
126             inline label part() const;
127     };
129     // Constructors
131         //- Construct from components
132         inline molecule
133         (
134             const Cloud<molecule>& c,
135             const vector& position,
136             const label celli,
137             const scalar mass,
138             const vector& U,
139             const vector& A,
140             const vector& tetherPosition,
141             const label tethered,
142             const label id
143         );
145         //- Construct from Istream
146         molecule
147         (
148             const Cloud<molecule>& c,
149             Istream& is,
150             bool readFields = true
151         );
153         //- Construct and return a clone
154         autoPtr<molecule> clone() const
155         {
156             return autoPtr<molecule>(new molecule(*this));
157         }
160     // Member Functions
162         void transformProperties(const tensor& T);
164         void transformProperties(const vector& separation);
166         // Access
168             //- Return id
169             inline label id() const;
171             //- Return mass
172             inline scalar mass() const;
174             //- Return velocity
175             inline const vector& U() const;
176             inline vector& U();
178             //- Return acceleration
179             inline const vector& A() const;
180             inline vector& A();
182             //- Return potential energy
183             inline scalar potentialEnergy() const;
184             inline scalar& potentialEnergy();
186             //- Return stress contribution
187             inline const tensor& rf() const;
188             inline tensor& rf();
190             //- Return tethered
191             inline label tethered() const;
193             //- Return tetherPosition
194             inline const vector& tetherPosition() const;
195             inline vector& tetherPosition();
198         //- Tracking
199         bool move(trackData&);
202     // Member Operators
204         //- Overridable function to handle the particle hitting a processorPatch
205         void hitProcessorPatch
206         (
207             const processorPolyPatch&,
208             molecule::trackData& td
209         );
211         //- Overridable function to handle the particle hitting a processorPatch
212         //  without trackData
213         void hitProcessorPatch
214         (
215             const processorPolyPatch&,
216             int&
217         );
219         //- Overridable function to handle the particle hitting a wallPatch
220         void hitWallPatch
221         (
222             const wallPolyPatch&,
223             molecule::trackData& td
224         );
226         //- Overridable function to handle the particle hitting a wallPatch
227         //  without trackData
228         void hitWallPatch
229         (
230             const wallPolyPatch&,
231             int&
232         );
234         //- Overridable function to handle the particle hitting a polyPatch
235         void hitPatch
236         (
237             const polyPatch&,
238             molecule::trackData& td
239         );
241         //- Overridable function to handle the particle hitting a polyPatch
242         //  without trackData
243         void hitPatch
244         (
245             const polyPatch&,
246             int&
247         );
249         static void readFields(moleculeCloud& mC);
251         static void writeFields(const moleculeCloud& mC);
254     // IOstream Operators
256         friend Ostream& operator<<(Ostream&, const molecule&);
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 } // End namespace Foam
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 #include "moleculeI.H"
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 #endif
271 // ************************************************************************* //