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

reducedUnits.C

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 \*---------------------------------------------------------------------------*/
00025 
00026 #include <molecule/reducedUnits.H>
00027 
00028 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00029 
00030 const  Foam::scalar Foam::reducedUnits::kb = 1.3806504e-23;
00031 
00032 
00033 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00034 
00035 void Foam::reducedUnits::calcRefValues()
00036 {
00037     if
00038     (
00039         refTime_ < VSMALL
00040      || refLength_ < VSMALL
00041      || refMass_ < VSMALL
00042     )
00043     {
00044         FatalErrorIn("Foam::reducedUnits::calcRefValues() ")
00045             << "One of more referencence values too small for floating point "
00046             << "calculation: "
00047             << "refTime_ = " << refTime_
00048             << ", refLength = " << refTemp_
00049             << ", refMass = " << refMass_
00050             << nl << abort(FatalError);
00051     }
00052 
00053     refEnergy_ = refLength_*refLength_*refMass_/(refTime_*refTime_);
00054 
00055     refTemp_ = refEnergy_ / kb;
00056 
00057     refForce_ = refEnergy_/refLength_;
00058 
00059     refVelocity_ = Foam::sqrt(refEnergy_/refMass_);
00060 
00061     refVolume_ = Foam::pow(refLength_,3.0);
00062 
00063     refPressure_ = refEnergy_/refVolume_;
00064 
00065     refMassDensity_ = refMass_/refVolume_;
00066 
00067     refNumberDensity_ = 1.0/refVolume_;
00068 }
00069 
00070 
00071 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00072 
00073 Foam::reducedUnits::reducedUnits()
00074 :
00075     refLength_(1e-9),
00076     refTime_(1e-12),
00077     refMass_(1.660538782e-27)
00078 {
00079     calcRefValues();
00080 }
00081 
00082 
00083 Foam::reducedUnits::reducedUnits
00084 (
00085     scalar refLength,
00086     scalar refTime,
00087     scalar refMass
00088 )
00089 :
00090     refLength_(refLength),
00091     refTime_(refTime),
00092     refMass_(refMass)
00093 {
00094     calcRefValues();
00095 }
00096 
00097 
00098 Foam::reducedUnits::reducedUnits(const IOdictionary& reducedUnitsDict)
00099 :
00100     refLength_(),
00101     refTime_(),
00102     refMass_()
00103 {
00104     setRefValues(reducedUnitsDict);
00105 }
00106 
00107 
00108 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00109 
00110 Foam::reducedUnits::~reducedUnits()
00111 {}
00112 
00113 
00114 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00115 
00116 void Foam::reducedUnits::setRefValues
00117 (
00118     scalar refLength,
00119     scalar refTime,
00120     scalar refMass
00121 )
00122 {
00123     refLength_ = refLength;
00124 
00125     refTime_ = refTime;
00126 
00127     refMass_ = refMass;
00128 
00129     calcRefValues();
00130 }
00131 
00132 
00133 void Foam::reducedUnits::setRefValues
00134 (
00135     const IOdictionary& reducedUnitsDict
00136 )
00137 {
00138     refLength_ = readScalar(reducedUnitsDict.lookup("refLength"));
00139 
00140     refTime_ = readScalar(reducedUnitsDict.lookup("refTime"));
00141 
00142     refMass_  = readScalar(reducedUnitsDict.lookup("refMass"));
00143 
00144     calcRefValues();
00145 }
00146 
00147 
00148 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00149 
00150 void Foam::reducedUnits::operator=(const reducedUnits& rhs)
00151 {
00152     // Check for assignment to self
00153     if (this == &rhs)
00154     {
00155         FatalErrorIn
00156         (
00157             "Foam::reducedUnits::operator=(const Foam::reducedUnits&)"
00158         )   << "Attempted assignment to self"
00159             << abort(FatalError);
00160     }
00161 }
00162 
00163 
00164 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines