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

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