OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

molecule.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2008-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::molecule
00027 
00028 Description
00029     Foam::molecule
00030 
00031 SourceFiles
00032     moleculeI.H
00033     molecule.C
00034     moleculeIO.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef molecule_H
00039 #define molecule_H
00040 
00041 #include "Particle.H"
00042 #include "IOstream.H"
00043 #include "autoPtr.H"
00044 #include "diagTensor.H"
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 // Class forward declarations
00052 class moleculeCloud;
00053 
00054 /*---------------------------------------------------------------------------*\
00055                            Class molecule Declaration
00056 \*---------------------------------------------------------------------------*/
00057 
00058 class molecule
00059 :
00060     public Particle<molecule>
00061 {
00062 
00063 public:
00064 
00065     // Values of special that are less than zero are for built-in functionality.
00066     // Values greater than zero are user specifiable/expandable (i.e. test
00067     // special_ >= SPECIAL_USER)
00068 
00069     enum specialTypes
00070     {
00071         SPECIAL_TETHERED = -1,
00072         SPECIAL_FROZEN   = -2,
00073         NOT_SPECIAL      = 0,
00074         SPECIAL_USER     = 1
00075     };
00076 
00077     //- Class to hold molecule constant properties
00078     class constantProperties
00079     {
00080 
00081         // Private data
00082 
00083             Field<vector> siteReferencePositions_;
00084 
00085             List<scalar> siteMasses_;
00086 
00087             List<scalar> siteCharges_;
00088 
00089             List<label> siteIds_;
00090 
00091             List<bool> pairPotentialSites_;
00092 
00093             List<bool> electrostaticSites_;
00094 
00095             diagTensor momentOfInertia_;
00096 
00097             scalar mass_;
00098 
00099         // Private Member Functions
00100 
00101             void checkSiteListSizes() const;
00102 
00103             void setInteracionSiteBools
00104             (
00105                 const List<word>& siteIds,
00106                 const List<word>& pairPotSiteIds
00107             );
00108 
00109             bool linearMoleculeTest() const;
00110 
00111 
00112     public:
00113 
00114         inline constantProperties();
00115 
00116         //- Construct from dictionary
00117         inline constantProperties(const dictionary& dict);
00118 
00119         // Member functions
00120 
00121         inline const Field<vector>& siteReferencePositions() const;
00122 
00123         inline const List<scalar>& siteMasses() const;
00124 
00125         inline const List<scalar>& siteCharges() const;
00126 
00127         inline const List<label>& siteIds() const;
00128 
00129         inline List<label>& siteIds();
00130 
00131         inline const List<bool>& pairPotentialSites() const;
00132 
00133         inline bool pairPotentialSite(label sId) const;
00134 
00135         inline const List<bool>& electrostaticSites() const;
00136 
00137         inline bool electrostaticSite(label sId) const;
00138 
00139         inline const diagTensor& momentOfInertia() const;
00140 
00141         inline bool linearMolecule() const;
00142 
00143         inline bool pointMolecule() const;
00144 
00145         inline label degreesOfFreedom() const;
00146 
00147         inline scalar mass() const;
00148 
00149         inline label nSites() const;
00150     };
00151 
00152 
00153     //- Class used to pass tracking data to the trackToFace function
00154     class trackData
00155     :
00156         public Particle<molecule>::trackData
00157     {
00158         moleculeCloud& molCloud_;
00159 
00160         // label specifying which part of the integration algorithm is taking
00161         label part_;
00162 
00163 
00164     public:
00165 
00166         // Constructors
00167 
00168             trackData
00169             (
00170                 moleculeCloud& molCloud,
00171                 label part
00172             );
00173 
00174         // Member functions
00175 
00176             inline moleculeCloud& molCloud();
00177 
00178             inline label part() const;
00179     };
00180 
00181 
00182 private:
00183 
00184     // Private data
00185 
00186         //- Be careful with the ordering of data.
00187         //  It has an impact on binary transfer:
00188         //    -# Put the largest data members 1st
00189         //    -# Pair up labels,
00190         //    -# Don't go scalar-label, scalar-label, because in 64bit mode,
00191         //       the labels will be padded by 4bytes.
00192 
00193         tensor Q_;
00194 
00195         vector v_;
00196 
00197         vector a_;
00198 
00199         vector pi_;
00200 
00201         vector tau_;
00202 
00203         vector specialPosition_;
00204 
00205         scalar potentialEnergy_;
00206 
00207         // - r_ij f_ij, stress dyad
00208         tensor rf_;
00209 
00210         label special_;
00211 
00212         label id_;
00213 
00214         List<vector> siteForces_;
00215 
00216         List<vector> sitePositions_;
00217 
00218 
00219     // Private Member Functions
00220 
00221         tensor rotationTensorX(scalar deltaT) const;
00222 
00223         tensor rotationTensorY(scalar deltaT) const;
00224 
00225         tensor rotationTensorZ(scalar deltaT) const;
00226 
00227 
00228 public:
00229 
00230     friend class Cloud<molecule>;
00231 
00232     // Constructors
00233 
00234         //- Construct from components
00235         inline molecule
00236         (
00237             const Cloud<molecule>& c,
00238             const vector& position,
00239             const label celli,
00240             const tensor& Q,
00241             const vector& v,
00242             const vector& a,
00243             const vector& pi,
00244             const vector& tau,
00245             const vector& specialPosition,
00246             const constantProperties& constProps,
00247             const label special,
00248             const label id
00249         );
00250 
00251         //- Construct from Istream
00252         molecule
00253         (
00254             const Cloud<molecule>& c,
00255             Istream& is,
00256             bool readFields = true
00257         );
00258 
00259         //- Construct and return a clone
00260         autoPtr<molecule> clone() const
00261         {
00262             return autoPtr<molecule>(new molecule(*this));
00263         }
00264 
00265 
00266     // Member Functions
00267 
00268         // Tracking
00269 
00270             bool move(trackData&);
00271 
00272             void transformProperties(const tensor& T);
00273 
00274             void transformProperties(const vector& separation);
00275 
00276             void setSitePositions(const constantProperties& constProps);
00277 
00278             void setSiteSizes(label size);
00279 
00280 
00281         // Access
00282 
00283             inline const tensor& Q() const;
00284             inline tensor& Q();
00285 
00286             inline const vector& v() const;
00287             inline vector& v();
00288 
00289             inline const vector& a() const;
00290             inline vector& a();
00291 
00292             inline const vector& pi() const;
00293             inline vector& pi();
00294 
00295             inline const vector& tau() const;
00296             inline vector& tau();
00297 
00298             inline const List<vector>& siteForces() const;
00299             inline List<vector>& siteForces();
00300 
00301             inline const List<vector>& sitePositions() const;
00302             inline List<vector>& sitePositions();
00303 
00304             inline const vector& specialPosition() const;
00305             inline vector& specialPosition();
00306 
00307             inline scalar potentialEnergy() const;
00308             inline scalar& potentialEnergy();
00309 
00310             inline const tensor& rf() const;
00311             inline tensor& rf();
00312 
00313             inline label special() const;
00314 
00315             inline bool tethered() const;
00316 
00317             inline label id() const;
00318 
00319 
00320     // Member Operators
00321 
00322         //- Overridable function to handle the particle hitting a patch
00323         //  Executed before other patch-hitting functions
00324         bool hitPatch
00325         (
00326             const polyPatch&,
00327             molecule::trackData& td,
00328             const label patchI
00329         );
00330 
00331         //- Overridable function to handle the particle hitting a patch
00332         //  Executed before other patch-hitting functions without trackData
00333         bool hitPatch
00334         (
00335             const polyPatch& p,
00336             int& td,
00337             const label patchI
00338         );
00339 
00340         //- Overridable function to handle the particle hitting a processorPatch
00341         void hitProcessorPatch
00342         (
00343             const processorPolyPatch&,
00344             molecule::trackData& td
00345         );
00346 
00347         //- Overridable function to handle the particle hitting a processorPatch
00348         //  without trackData
00349         void hitProcessorPatch
00350         (
00351             const processorPolyPatch&,
00352             int&
00353         );
00354 
00355         //- Overridable function to handle the particle hitting a wallPatch
00356         void hitWallPatch
00357         (
00358             const wallPolyPatch&,
00359             molecule::trackData& td
00360         );
00361 
00362         //- Overridable function to handle the particle hitting a wallPatch
00363         //  without trackData
00364         void hitWallPatch
00365         (
00366             const wallPolyPatch&,
00367             int&
00368         );
00369 
00370         //- Overridable function to handle the particle hitting a polyPatch
00371         void hitPatch
00372         (
00373             const polyPatch&,
00374             molecule::trackData& td
00375         );
00376 
00377         //- Overridable function to handle the particle hitting a polyPatch
00378         //  without trackData
00379         void hitPatch
00380         (
00381             const polyPatch&,
00382             int&
00383         );
00384 
00385         static void readFields(moleculeCloud& mC);
00386 
00387         static void writeFields(const moleculeCloud& mC);
00388 
00389 
00390     // IOstream Operators
00391 
00392         friend Ostream& operator<<(Ostream&, const molecule&);
00393 };
00394 
00395 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00396 
00397 } // End namespace Foam
00398 
00399 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00400 
00401 #include "moleculeI.H"
00402 
00403 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00404 
00405 #endif
00406 
00407 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd