FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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