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

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