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

moleculeCloud.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::moleculeCloud
00026 
00027 Description
00028 
00029 SourceFiles
00030     moleculeCloudI.H
00031     moleculeCloud.C
00032 
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef moleculeCloud_H
00037 #define moleculeCloud_H
00038 
00039 #include <lagrangian/Cloud.H>
00040 #include <molecule/molecule.H>
00041 #include <OpenFOAM/IOdictionary.H>
00042 #include <potential/potential.H>
00043 #include <molecule/interactionLists.H>
00044 #include <OpenFOAM/labelVector.H>
00045 #include <OpenFOAM/Random.H>
00046 #include <OpenFOAM/fileName.H>
00047 
00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00049 
00050 namespace Foam
00051 {
00052 
00053 /*---------------------------------------------------------------------------*\
00054                        Class moleculeCloud Declaration
00055 \*---------------------------------------------------------------------------*/
00056 
00057 class moleculeCloud
00058 :
00059     public Cloud<molecule>
00060 {
00061 
00062 private:
00063 
00064     // Private data
00065 
00066         const polyMesh& mesh_;
00067 
00068         const potential& pot_;
00069 
00070         List<DynamicList<molecule*> > cellOccupancy_;
00071 
00072         interactionLists il_;
00073 
00074         List<molecule::constantProperties> constPropList_;
00075 
00076         Random rndGen_;
00077 
00078 
00079     // Private Member Functions
00080 
00081         void buildConstProps();
00082 
00083         void setSiteSizesAndPositions();
00084 
00085         //- Determine which molecules are in which cells
00086         void buildCellOccupancy();
00087 
00088         void calculatePairForce();
00089 
00090         inline void evaluatePair
00091         (
00092             molecule* molI,
00093             molecule* molJ
00094         );
00095 
00096         inline void evaluatePair
00097         (
00098             molecule* molReal,
00099             referredMolecule* molRef
00100         );
00101 
00102         inline bool evaluatePotentialLimit
00103         (
00104             molecule* molI,
00105             molecule* molJ
00106         ) const;
00107 
00108         inline bool evaluatePotentialLimit
00109         (
00110             molecule* molReal,
00111             referredMolecule* molRef
00112         ) const;
00113 
00114         void calculateTetherForce();
00115 
00116         void calculateExternalForce();
00117 
00118         void removeHighEnergyOverlaps();
00119 
00120         void initialiseMolecules
00121         (
00122             const IOdictionary& mdInitialiseDict
00123         );
00124 
00125         void createMolecule
00126         (
00127             const point& position,
00128             label cell,
00129             label id,
00130             bool tethered,
00131             scalar temperature,
00132             const vector& bulkVelocity
00133         );
00134 
00135         label nSites() const;
00136 
00137         inline vector equipartitionLinearVelocity
00138         (
00139             scalar temperature,
00140             scalar mass
00141         );
00142 
00143         inline vector equipartitionAngularMomentum
00144         (
00145             scalar temperature,
00146             const molecule::constantProperties& cP
00147         );
00148 
00149         //- Disallow default bitwise copy construct
00150         moleculeCloud(const moleculeCloud&);
00151 
00152         //- Disallow default bitwise assignment
00153         void operator=(const moleculeCloud&);
00154 
00155 
00156 public:
00157 
00158     // Static data members
00159 
00160         static scalar kb;
00161 
00162         static scalar elementaryCharge;
00163 
00164         static scalar vacuumPermittivity;
00165 
00166 
00167     // Constructors
00168 
00169         //- Construct given mesh and potential references
00170         moleculeCloud
00171         (
00172             const polyMesh& mesh,
00173             const potential& pot,
00174             bool readFields = true
00175         );
00176 
00177         //- Construct given mesh, potential and mdInitialiseDict
00178         moleculeCloud
00179         (
00180             const polyMesh& mesh,
00181             const potential& pot,
00182             const IOdictionary& mdInitialiseDict,
00183             bool readFields = true
00184         );
00185 
00186 
00187     // Member Functions
00188 
00189         //- Evolve the molecules (move, calculate forces, control state etc)
00190         void evolve();
00191 
00192         void calculateForce();
00193 
00194         void applyConstraintsAndThermostats
00195         (
00196             const scalar targetTemperature,
00197             const scalar measuredTemperature
00198         );
00199 
00200 
00201         // Access
00202 
00203             inline const polyMesh& mesh() const;
00204 
00205             inline const potential& pot() const;
00206 
00207             inline const List<DynamicList<molecule*> >& cellOccupancy() const;
00208 
00209             inline const interactionLists& il() const;
00210 
00211             inline const List<molecule::constantProperties> constProps() const;
00212 
00213             inline const molecule::constantProperties&
00214                 constProps(label id) const;
00215 
00216             inline Random& rndGen();
00217 
00218 
00219     // Member Operators
00220 
00221         //- Write molecule sites in XYZ format
00222         void writeXYZ(const fileName& fName) const;
00223 };
00224 
00225 
00226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00227 
00228 } // End namespace Foam
00229 
00230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00231 
00232 #include "moleculeCloudI.H"
00233 
00234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00235 
00236 #endif
00237 
00238 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines