ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / lagrangian / molecularDynamics / molecule / reducedUnits / reducedUnits.C
blob61c768c9fe766559478e0670ac87ee1dd61de892
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "reducedUnits.H"
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 const  Foam::scalar Foam::reducedUnits::kb = 1.3806504e-23;
33 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
35 void Foam::reducedUnits::calcRefValues()
37     if
38     (
39         refTime_ < VSMALL
40      || refLength_ < VSMALL
41      || refMass_ < VSMALL
42     )
43     {
44         FatalErrorIn("Foam::reducedUnits::calcRefValues() ")
45             << "One of more referencence values too small for floating point "
46             << "calculation: "
47             << "refTime_ = " << refTime_
48             << ", refLength = " << refTemp_
49             << ", refMass = " << refMass_
50             << nl << abort(FatalError);
51     }
53     refEnergy_ = refLength_*refLength_*refMass_/(refTime_*refTime_);
55     refTemp_ = refEnergy_ / kb;
57     refForce_ = refEnergy_/refLength_;
59     refVelocity_ = Foam::sqrt(refEnergy_/refMass_);
61     refVolume_ = Foam::pow(refLength_,3.0);
63     refPressure_ = refEnergy_/refVolume_;
65     refMassDensity_ = refMass_/refVolume_;
67     refNumberDensity_ = 1.0/refVolume_;
71 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
73 Foam::reducedUnits::reducedUnits()
75     refLength_(1e-9),
76     refTime_(1e-12),
77     refMass_(1.660538782e-27)
79     calcRefValues();
83 Foam::reducedUnits::reducedUnits
85     scalar refLength,
86     scalar refTime,
87     scalar refMass
90     refLength_(refLength),
91     refTime_(refTime),
92     refMass_(refMass)
94     calcRefValues();
98 Foam::reducedUnits::reducedUnits(const IOdictionary& reducedUnitsDict)
100     refLength_(),
101     refTime_(),
102     refMass_()
104     setRefValues(reducedUnitsDict);
108 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
110 Foam::reducedUnits::~reducedUnits()
114 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
116 void Foam::reducedUnits::setRefValues
118     scalar refLength,
119     scalar refTime,
120     scalar refMass
123     refLength_ = refLength;
125     refTime_ = refTime;
127     refMass_ = refMass;
129     calcRefValues();
133 void Foam::reducedUnits::setRefValues
135     const IOdictionary& reducedUnitsDict
138     refLength_ = readScalar(reducedUnitsDict.lookup("refLength"));
140     refTime_ = readScalar(reducedUnitsDict.lookup("refTime"));
142     refMass_  = readScalar(reducedUnitsDict.lookup("refMass"));
144     calcRefValues();
148 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
150 void Foam::reducedUnits::operator=(const reducedUnits& rhs)
152     // Check for assignment to self
153     if (this == &rhs)
154     {
155         FatalErrorIn
156         (
157             "Foam::reducedUnits::operator=(const Foam::reducedUnits&)"
158         )   << "Attempted assignment to self"
159             << abort(FatalError);
160     }
164 // ************************************************************************* //