ENH: Removed redundant molecularDynamics code
This commit is contained in:
parent
4e415d541c
commit
ce68fb16a3
@ -1,227 +0,0 @@
|
||||
if (runTime.outputTime())
|
||||
{
|
||||
/*-----------------------------------------------------------------------*\
|
||||
Number density
|
||||
\*-----------------------------------------------------------------------*/
|
||||
|
||||
scalarField totalRhoN_sum(mesh.nCells(), 0.0);
|
||||
|
||||
forAll(allSpeciesRhoN, rN)
|
||||
{
|
||||
allSpeciesRhoN[rN].internalField() =
|
||||
allSpeciesN_RU[rN]
|
||||
/mesh.cellVolumes()
|
||||
/nAveragingSteps;
|
||||
|
||||
totalRhoN_sum += allSpeciesRhoN[rN].internalField();
|
||||
}
|
||||
|
||||
totalRhoN.internalField() = totalRhoN_sum;
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*\
|
||||
Mass density
|
||||
\*-----------------------------------------------------------------------*/
|
||||
|
||||
scalarField totalRhoM_sum(mesh.nCells(), 0.0);
|
||||
|
||||
forAll(allSpeciesRhoM, rM)
|
||||
{
|
||||
allSpeciesRhoM[rM].internalField() =
|
||||
allSpeciesM_RU[rM]
|
||||
/mesh.cellVolumes()
|
||||
/nAveragingSteps;
|
||||
|
||||
totalRhoM_sum += allSpeciesRhoM[rM].internalField();
|
||||
}
|
||||
|
||||
totalRhoM.internalField() = totalRhoM_sum;
|
||||
|
||||
/*-----------------------------------------------------------------------*\
|
||||
Bulk velocity
|
||||
\*-----------------------------------------------------------------------*/
|
||||
|
||||
vectorField totalMomentum_sum(mesh.nCells(), vector::zero);
|
||||
|
||||
scalarField totalMass_sum(mesh.nCells(), 0.0);
|
||||
|
||||
forAll(allSpeciesVelocity, v)
|
||||
{
|
||||
// A check for 1/0 molecules is required.
|
||||
|
||||
vectorField& singleSpeciesVelocity
|
||||
(
|
||||
allSpeciesVelocity[v].internalField()
|
||||
);
|
||||
|
||||
forAll(singleSpeciesVelocity, sSV)
|
||||
{
|
||||
if (allSpeciesN_RU[v][sSV])
|
||||
{
|
||||
singleSpeciesVelocity[sSV] =
|
||||
allSpeciesVelocitySum_RU[v][sSV]
|
||||
/allSpeciesN_RU[v][sSV];
|
||||
|
||||
totalMomentum_sum[sSV] +=
|
||||
allSpeciesM_RU[v][sSV]
|
||||
/allSpeciesN_RU[v][sSV]
|
||||
*allSpeciesVelocitySum_RU[v][sSV];
|
||||
|
||||
totalMass_sum[sSV] += allSpeciesM_RU[v][sSV];
|
||||
}
|
||||
else
|
||||
{
|
||||
singleSpeciesVelocity[sSV] = vector::zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
volVectorField::InternalField& itotalVelocity =
|
||||
totalVelocity.internalField();
|
||||
|
||||
forAll(itotalVelocity, tV)
|
||||
{
|
||||
if (totalMass_sum[tV] > VSMALL)
|
||||
{
|
||||
itotalVelocity[tV] = totalMomentum_sum[tV]/totalMass_sum[tV];
|
||||
}
|
||||
else
|
||||
{
|
||||
itotalVelocity[tV] = vector::zero;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*\
|
||||
Kinetic temperature
|
||||
\*-----------------------------------------------------------------------*/
|
||||
|
||||
scalarField totalTemperatureVTerms_sum(mesh.nCells(), 0.0);
|
||||
|
||||
scalarField totalN_sum(mesh.nCells(), 0.0);
|
||||
|
||||
forAll(allSpeciesTemperature, t)
|
||||
{
|
||||
// A check for 1/0 molecules is required.
|
||||
|
||||
scalarField& singleSpeciesTemp
|
||||
(
|
||||
allSpeciesTemperature[t].internalField()
|
||||
);
|
||||
|
||||
forAll(singleSpeciesTemp, sST)
|
||||
{
|
||||
if (allSpeciesN_RU[t][sST])
|
||||
{
|
||||
singleSpeciesTemp[sST] =
|
||||
allSpeciesM_RU[t][sST]
|
||||
/allSpeciesN_RU[t][sST]
|
||||
/(3.0 * moleculeCloud::kb * allSpeciesN_RU[t][sST])
|
||||
*(
|
||||
allSpeciesVelocityMagSquaredSum_RU[t][sST]
|
||||
-
|
||||
(
|
||||
allSpeciesVelocitySum_RU[t][sST]
|
||||
&
|
||||
allSpeciesVelocitySum_RU[t][sST]
|
||||
)
|
||||
/allSpeciesN_RU[t][sST]
|
||||
);
|
||||
|
||||
totalTemperatureVTerms_sum[sST] +=
|
||||
allSpeciesM_RU[t][sST]
|
||||
/allSpeciesN_RU[t][sST]
|
||||
*(
|
||||
allSpeciesVelocityMagSquaredSum_RU[t][sST]
|
||||
-
|
||||
(
|
||||
allSpeciesVelocitySum_RU[t][sST]
|
||||
&
|
||||
allSpeciesVelocitySum_RU[t][sST]
|
||||
)
|
||||
/allSpeciesN_RU[t][sST]
|
||||
);
|
||||
|
||||
totalN_sum[sST] += allSpeciesN_RU[t][sST];
|
||||
}
|
||||
else
|
||||
{
|
||||
singleSpeciesTemp[sST] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
volScalarField::InternalField& itotalTemperature =
|
||||
totalTemperature.internalField();
|
||||
|
||||
forAll(itotalTemperature, tT)
|
||||
{
|
||||
if (totalN_sum[tT] > 0)
|
||||
{
|
||||
itotalTemperature[tT] =
|
||||
totalTemperatureVTerms_sum[tT]
|
||||
/(3.0 * moleculeCloud::kb * totalN_sum[tT]);
|
||||
}
|
||||
else
|
||||
{
|
||||
itotalTemperature[tT] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*\
|
||||
Mean kinetic energy
|
||||
\*-----------------------------------------------------------------------*/
|
||||
|
||||
scalarField totalKE_sum(mesh.nCells(), 0.0);
|
||||
|
||||
forAll(allSpeciesMeanKE, mKE)
|
||||
{
|
||||
// A check for 1/0 molecules is required.
|
||||
|
||||
scalarField& singleSpeciesMeanKE
|
||||
(
|
||||
allSpeciesMeanKE[mKE].internalField()
|
||||
);
|
||||
|
||||
forAll(singleSpeciesMeanKE, sSMKE)
|
||||
{
|
||||
if (allSpeciesN_RU[mKE][sSMKE])
|
||||
{
|
||||
singleSpeciesMeanKE[sSMKE] =
|
||||
allSpeciesM_RU[mKE][sSMKE]
|
||||
/allSpeciesN_RU[mKE][sSMKE]
|
||||
/(2.0*allSpeciesN_RU[mKE][sSMKE])
|
||||
*(
|
||||
allSpeciesVelocityMagSquaredSum_RU[mKE][sSMKE]
|
||||
);
|
||||
|
||||
totalKE_sum[sSMKE] +=
|
||||
allSpeciesM_RU[mKE][sSMKE]
|
||||
/allSpeciesN_RU[mKE][sSMKE]
|
||||
/2.0
|
||||
*(
|
||||
allSpeciesVelocityMagSquaredSum_RU[mKE][sSMKE]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
singleSpeciesMeanKE[sSMKE] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
volScalarField::InternalField& itotalMeanKE = totalMeanKE.internalField();
|
||||
|
||||
forAll(itotalMeanKE, tMKE)
|
||||
{
|
||||
if (totalN_sum[tMKE] > 0)
|
||||
{
|
||||
itotalMeanKE[tMKE] =
|
||||
totalKE_sum[tMKE]
|
||||
/totalN_sum[tMKE];
|
||||
}
|
||||
else
|
||||
{
|
||||
itotalMeanKE[tMKE] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
if (mesh.time().timeIndex() % vacf.sampleSteps() == 0)
|
||||
{
|
||||
Field<vector> uVals(molecules.size());
|
||||
|
||||
label uV = 0;
|
||||
|
||||
forAllConstIter(IDLList<molecule>, molecules, mol)
|
||||
{
|
||||
uVals[uV++] = mol().U();
|
||||
}
|
||||
|
||||
vacf.calculateCorrelationFunction(uVals);
|
||||
}
|
||||
|
||||
if (mesh.time().timeIndex() % pacf.sampleSteps() == 0)
|
||||
{
|
||||
vector p = vector::zero;
|
||||
|
||||
forAllConstIter(IDLList<molecule>, molecules, mol)
|
||||
{
|
||||
p.x() +=
|
||||
mol().mass() * mol().U().y() * mol().U().z()
|
||||
+ 0.5*mol().rf().yz();
|
||||
|
||||
p.y() +=
|
||||
mol().mass() * mol().U().z() * mol().U().x()
|
||||
+ 0.5*mol().rf().zx();
|
||||
|
||||
p.z() +=
|
||||
mol().mass() * mol().U().x() * mol().U().y()
|
||||
+ 0.5*mol().rf().xy();
|
||||
}
|
||||
|
||||
pacf.calculateCorrelationFunction(p);
|
||||
}
|
||||
|
||||
if (mesh.time().timeIndex() % hfacf.sampleSteps() == 0)
|
||||
{
|
||||
vector s = vector::zero;
|
||||
|
||||
forAllConstIter(IDLList<molecule>, molecules, mol)
|
||||
{
|
||||
s +=
|
||||
(
|
||||
0.5*mol().mass()*magSqr(mol().U())
|
||||
+ mol().potentialEnergy()
|
||||
)*mol().U()
|
||||
+ 0.5*(mol().rf() & mol().U());
|
||||
}
|
||||
|
||||
hfacf.calculateCorrelationFunction(s);
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
const List<DynamicList<molecule*> >& cellOccupancy = molecules.cellOccupancy();
|
||||
|
||||
forAll(cellOccupancy, cell)
|
||||
{
|
||||
const List<molecule*>& molsInCell = cellOccupancy[cell];
|
||||
|
||||
forAll(molsInCell, mIC)
|
||||
{
|
||||
molecule* mol = molsInCell[mIC];
|
||||
|
||||
const label molId = mol->id();
|
||||
|
||||
const vector& molU = mol->U();
|
||||
|
||||
allSpeciesN_RU[molId][cell]++;
|
||||
|
||||
allSpeciesM_RU[molId][cell] += mol->mass();
|
||||
|
||||
allSpeciesVelocitySum_RU[molId][cell] += molU;
|
||||
|
||||
allSpeciesVelocityMagSquaredSum_RU[molId][cell] += molU & molU;
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
if (writeVacf)
|
||||
{
|
||||
OFstream vacfFile(runTime.path()/"vacf");
|
||||
|
||||
if (!vacf.writeAveraged(vacfFile))
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Failed writing to "
|
||||
<< vacfFile.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "Diffusion coefficient = "
|
||||
<< vacf.integral() << endl;
|
||||
|
||||
if (writePacf)
|
||||
{
|
||||
OFstream pacfFile(runTime.path()/"pacf");
|
||||
|
||||
if (!pacf.writeAveraged(pacfFile))
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Failed writing to "
|
||||
<< pacfFile.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "Viscosity = "
|
||||
<< pacf.integral()/averageTemperature/moleculeCloud::kb/meshVolume
|
||||
<< endl;
|
||||
|
||||
if (writeHFacf)
|
||||
{
|
||||
OFstream hfacfFile
|
||||
(
|
||||
runTime.path()/ + "hfacf"
|
||||
);
|
||||
|
||||
if (!hfacf.writeAveraged(hfacfFile))
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Failed writing to "
|
||||
<< hfacfFile.name()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "Thermal conductivity = "
|
||||
<< hfacf.integral()
|
||||
/averageTemperature
|
||||
/averageTemperature
|
||||
/moleculeCloud::kb
|
||||
/ meshVolume
|
||||
<< endl;
|
@ -1,98 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
Info << nl << "Creating autocorrelation functions." << endl;
|
||||
|
||||
IOdictionary mdTransportProperitesDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"mdTransportProperitesDict",
|
||||
mesh.time().system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
const dictionary& autocorrelationFunctionDict
|
||||
(
|
||||
mdTransportProperitesDict.subDict("autocorrelationFunctions")
|
||||
);
|
||||
|
||||
//- Velocity autocorrelation function
|
||||
|
||||
Info << tab << "velocty" << endl;
|
||||
|
||||
const dictionary& velocityACFDict
|
||||
(
|
||||
autocorrelationFunctionDict.subDict("velocity")
|
||||
);
|
||||
|
||||
correlationFunction<vector> vacf
|
||||
(
|
||||
mesh,
|
||||
velocityACFDict,
|
||||
molecules.size()
|
||||
);
|
||||
|
||||
bool writeVacf(Switch(velocityACFDict.lookup("writeFile")));
|
||||
|
||||
//- Pressure autocorrelation function
|
||||
|
||||
Info << tab << "pressure" << endl;
|
||||
|
||||
const dictionary& pressureACFDict
|
||||
(
|
||||
autocorrelationFunctionDict.subDict("pressure")
|
||||
);
|
||||
|
||||
correlationFunction<vector> pacf
|
||||
(
|
||||
mesh,
|
||||
pressureACFDict,
|
||||
1
|
||||
);
|
||||
|
||||
bool writePacf(Switch(pressureACFDict.lookup("writeFile")));
|
||||
|
||||
//- Heat flux autocorrelation function
|
||||
|
||||
Info << tab << "heat flux" << endl;
|
||||
|
||||
const dictionary& heatFluxACFDict
|
||||
(
|
||||
autocorrelationFunctionDict.subDict("heatFlux")
|
||||
);
|
||||
|
||||
correlationFunction<vector> hfacf
|
||||
(
|
||||
mesh,
|
||||
heatFluxACFDict,
|
||||
1
|
||||
);
|
||||
|
||||
bool writeHFacf(Switch(heatFluxACFDict.lookup("writeFile")));
|
@ -1,324 +0,0 @@
|
||||
// Fields for data gathering
|
||||
|
||||
List< scalarField > allSpeciesN_RU
|
||||
(
|
||||
molecules.potential().nIds(),
|
||||
scalarField (mesh.nCells(), 0.0)
|
||||
);
|
||||
|
||||
List< scalarField > allSpeciesM_RU
|
||||
(
|
||||
molecules.potential().nIds(),
|
||||
scalarField (mesh.nCells(), 0.0)
|
||||
);
|
||||
|
||||
List< vectorField > allSpeciesVelocitySum_RU
|
||||
(
|
||||
molecules.potential().nIds(),
|
||||
vectorField (mesh.nCells(), vector::zero)
|
||||
);
|
||||
|
||||
List< scalarField > allSpeciesVelocityMagSquaredSum_RU
|
||||
(
|
||||
molecules.potential().nIds(),
|
||||
scalarField (mesh.nCells(), 0.0)
|
||||
);
|
||||
|
||||
// Geometric Fields for IO
|
||||
|
||||
Info << nl << "Creating fields." << endl;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Number density
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
PtrList<volScalarField> allSpeciesRhoN
|
||||
(
|
||||
molecules.potential().nIds()
|
||||
);
|
||||
|
||||
forAll(allSpeciesRhoN, rN)
|
||||
{
|
||||
Info<< " Creating number density field for "
|
||||
<< molecules.potential().idList()[rN] << endl;
|
||||
|
||||
allSpeciesRhoN.set
|
||||
(
|
||||
rN,
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"rhoN_" + molecules.potential().idList()[rN],
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimless/dimVolume,
|
||||
"zeroGradient"
|
||||
)
|
||||
);
|
||||
allSpeciesRhoN[rN].internalField() = scalarField (mesh.nCells(), 0.0);
|
||||
allSpeciesRhoN[rN].correctBoundaryConditions();
|
||||
}
|
||||
|
||||
Info << " Creating total number density field" << endl;
|
||||
|
||||
volScalarField totalRhoN
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"rhoN_total",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimless/dimVolume,
|
||||
"zeroGradient"
|
||||
);
|
||||
totalRhoN.internalField() = scalarField (mesh.nCells(), 0.0);
|
||||
totalRhoN.correctBoundaryConditions();
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Mass density
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
PtrList<volScalarField> allSpeciesRhoM
|
||||
(
|
||||
molecules.potential().nIds()
|
||||
);
|
||||
|
||||
forAll(allSpeciesRhoM, rM)
|
||||
{
|
||||
Info<< " Creating mass density field for "
|
||||
<< molecules.potential().idList()[rM] << endl;
|
||||
|
||||
allSpeciesRhoM.set
|
||||
(
|
||||
rM,
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"rhoM_" + molecules.potential().idList()[rM],
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimMass/dimVolume,
|
||||
"zeroGradient"
|
||||
)
|
||||
);
|
||||
allSpeciesRhoM[rM].internalField() = scalarField (mesh.nCells(), 0.0);
|
||||
allSpeciesRhoM[rM].correctBoundaryConditions();
|
||||
}
|
||||
|
||||
Info << " Creating total mass density field" << endl;
|
||||
|
||||
volScalarField totalRhoM
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"rhoM_total",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimMass/dimVolume,
|
||||
"zeroGradient"
|
||||
);
|
||||
totalRhoM.internalField() = scalarField (mesh.nCells(), 0.0);
|
||||
totalRhoM.correctBoundaryConditions();
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Bulk velocity
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
PtrList<volVectorField> allSpeciesVelocity
|
||||
(
|
||||
molecules.potential().nIds()
|
||||
);
|
||||
|
||||
forAll(allSpeciesVelocity, v)
|
||||
{
|
||||
Info<< " Creating velocity field for "
|
||||
<< molecules.potential().idList()[v] << endl;
|
||||
|
||||
allSpeciesVelocity.set
|
||||
(
|
||||
v,
|
||||
new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"velocity_" + molecules.potential().idList()[v],
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimVelocity,
|
||||
"zeroGradient"
|
||||
)
|
||||
);
|
||||
allSpeciesVelocity[v].internalField() =
|
||||
vectorField (mesh.nCells(), vector::zero);
|
||||
allSpeciesVelocity[v].correctBoundaryConditions();
|
||||
}
|
||||
|
||||
Info << " Creating total velocity field" << endl;
|
||||
|
||||
// volVectorField totalVelocity
|
||||
// (
|
||||
// IOobject
|
||||
// (
|
||||
// "velocity_total",
|
||||
// runTime.timeName(),
|
||||
// mesh,
|
||||
// IOobject::NO_READ,
|
||||
// IOobject::AUTO_WRITE
|
||||
// ),
|
||||
// mesh,
|
||||
// dimVelocity,
|
||||
// "zeroGradient"
|
||||
// );
|
||||
// totalVelocity.internalField() = vectorField (mesh.nCells(), vector::zero);
|
||||
// totalVelocity.correctBoundaryConditions();
|
||||
|
||||
|
||||
volVectorField totalVelocity
|
||||
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
|
||||
"velocity_total",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
|
||||
),
|
||||
mesh,
|
||||
dimensionedVector("zero", dimVelocity, vector::zero)
|
||||
);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Kinetic temperature
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
PtrList<volScalarField> allSpeciesTemperature
|
||||
(
|
||||
molecules.potential().nIds()
|
||||
);
|
||||
|
||||
forAll(allSpeciesTemperature, t)
|
||||
{
|
||||
Info<< " Creating temperature field for "
|
||||
<< molecules.potential().idList()[t] << endl;
|
||||
|
||||
allSpeciesTemperature.set
|
||||
(
|
||||
t,
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"temperature_" + molecules.potential().idList()[t],
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimTemperature,
|
||||
"zeroGradient"
|
||||
)
|
||||
);
|
||||
allSpeciesTemperature[t].internalField() = scalarField (mesh.nCells(), 0.0);
|
||||
allSpeciesTemperature[t].correctBoundaryConditions();
|
||||
}
|
||||
|
||||
Info << " Creating total temperature field" << endl;
|
||||
|
||||
volScalarField totalTemperature
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"temperature_total",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimTemperature,
|
||||
"zeroGradient"
|
||||
);
|
||||
totalTemperature.internalField() = scalarField (mesh.nCells(), 0.0);
|
||||
totalTemperature.correctBoundaryConditions();
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Mean kinetic energy
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
PtrList<volScalarField> allSpeciesMeanKE
|
||||
(
|
||||
molecules.potential().nIds()
|
||||
);
|
||||
|
||||
forAll(allSpeciesMeanKE, mKE)
|
||||
{
|
||||
Info<< " Creating mean kinetic energy field for "
|
||||
<< molecules.potential().idList()[mKE] << endl;
|
||||
|
||||
allSpeciesMeanKE.set
|
||||
(
|
||||
mKE,
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"meanKE_" + molecules.potential().idList()[mKE],
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionSet(1, 2, -2, 0, 0, 0, 0),
|
||||
"zeroGradient"
|
||||
)
|
||||
);
|
||||
allSpeciesMeanKE[mKE].internalField() = scalarField (mesh.nCells(), 0.0);
|
||||
allSpeciesMeanKE[mKE].correctBoundaryConditions();
|
||||
}
|
||||
|
||||
Info << " Creating total mean kinetic energy field" << endl;
|
||||
|
||||
volScalarField totalMeanKE
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"meanKE_total",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionSet(1, 2, -2, 0, 0, 0, 0),
|
||||
"zeroGradient"
|
||||
);
|
||||
totalMeanKE.internalField() = scalarField (mesh.nCells(), 0.0);
|
||||
totalMeanKE.correctBoundaryConditions();
|
@ -1,22 +0,0 @@
|
||||
reducedUnits refUnits;
|
||||
|
||||
IOobject reducedUnitsDictIOobject
|
||||
(
|
||||
"reducedUnitsDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
if (reducedUnitsDictIOobject.headerOk())
|
||||
{
|
||||
Info<< nl
|
||||
<< "Reading reference quantities from reducedUnitsDict file." << endl;
|
||||
|
||||
IOdictionary reducedUnitsDict(reducedUnitsDictIOobject);
|
||||
|
||||
refUnits.setRefValues(reducedUnitsDict);
|
||||
}
|
||||
|
||||
Info << refUnits << endl;
|
@ -1,9 +0,0 @@
|
||||
#ifndef md_H
|
||||
#define md_H
|
||||
#include "potential.H"
|
||||
#include "moleculeCloud.H"
|
||||
#include "correlationFunction.H"
|
||||
#include "distribution.H"
|
||||
#include "reducedUnits.H"
|
||||
#endif
|
||||
|
@ -1,180 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Global
|
||||
meanMomentumEnergyAndNMols.H
|
||||
|
||||
Description
|
||||
Calculates and prints the mean momentum and energy in the system
|
||||
and the number of molecules.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
vector singleStepTotalLinearMomentum(vector::zero);
|
||||
|
||||
vector singleStepTotalAngularMomentum(vector::zero);
|
||||
|
||||
scalar singleStepMaxVelocityMag = 0.0;
|
||||
|
||||
scalar singleStepTotalMass = 0.0;
|
||||
|
||||
scalar singleStepTotalLinearKE = 0.0;
|
||||
|
||||
scalar singleStepTotalAngularKE = 0.0;
|
||||
|
||||
scalar singleStepTotalPE = 0.0;
|
||||
|
||||
scalar singleStepTotalrDotf = 0.0;
|
||||
|
||||
//vector singleStepCentreOfMass(vector::zero);
|
||||
|
||||
label singleStepNMols = molecules.size();
|
||||
|
||||
label singleStepDOFs = 0;
|
||||
|
||||
{
|
||||
forAllConstIter(IDLList<molecule>, molecules, mol)
|
||||
{
|
||||
const label molId = mol().id();
|
||||
|
||||
scalar molMass(molecules.constProps(molId).mass());
|
||||
|
||||
singleStepTotalMass += molMass;
|
||||
|
||||
//singleStepCentreOfMass += mol().position()*molMass;
|
||||
}
|
||||
|
||||
// if (singleStepNMols)
|
||||
// {
|
||||
// singleStepCentreOfMass /= singleStepTotalMass;
|
||||
// }
|
||||
|
||||
forAllConstIter(IDLList<molecule>, molecules, mol)
|
||||
{
|
||||
const label molId = mol().id();
|
||||
|
||||
const molecule::constantProperties cP(molecules.constProps(molId));
|
||||
|
||||
scalar molMass(cP.mass());
|
||||
|
||||
const diagTensor& molMoI(cP.momentOfInertia());
|
||||
|
||||
const vector& molV(mol().v());
|
||||
|
||||
const vector& molOmega(inv(molMoI) & mol().pi());
|
||||
|
||||
vector molPiGlobal = mol().Q() & mol().pi();
|
||||
|
||||
singleStepTotalLinearMomentum += molV * molMass;
|
||||
|
||||
singleStepTotalAngularMomentum += molPiGlobal;
|
||||
//+((mol().position() - singleStepCentreOfMass) ^ (molV * molMass));
|
||||
|
||||
if (mag(molV) > singleStepMaxVelocityMag)
|
||||
{
|
||||
singleStepMaxVelocityMag = mag(molV);
|
||||
}
|
||||
|
||||
singleStepTotalLinearKE += 0.5*molMass*magSqr(molV);
|
||||
|
||||
singleStepTotalAngularKE += 0.5*(molOmega & molMoI & molOmega);
|
||||
|
||||
singleStepTotalPE += mol().potentialEnergy();
|
||||
|
||||
singleStepTotalrDotf += tr(mol().rf());
|
||||
|
||||
singleStepDOFs += cP.degreesOfFreedom();
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
reduce(singleStepTotalLinearMomentum, sumOp<vector>());
|
||||
|
||||
reduce(singleStepTotalAngularMomentum, sumOp<vector>());
|
||||
|
||||
reduce(singleStepMaxVelocityMag, maxOp<scalar>());
|
||||
|
||||
reduce(singleStepTotalMass, sumOp<scalar>());
|
||||
|
||||
reduce(singleStepTotalLinearKE, sumOp<scalar>());
|
||||
|
||||
reduce(singleStepTotalAngularKE, sumOp<scalar>());
|
||||
|
||||
reduce(singleStepTotalPE, sumOp<scalar>());
|
||||
|
||||
reduce(singleStepTotalrDotf, sumOp<scalar>());
|
||||
|
||||
reduce(singleStepNMols, sumOp<label>());
|
||||
|
||||
reduce(singleStepDOFs, sumOp<label>());
|
||||
}
|
||||
|
||||
if (singleStepNMols)
|
||||
{
|
||||
Info<< "Number of molecules in system = "
|
||||
<< singleStepNMols << nl
|
||||
<< "Overall number density = "
|
||||
<< singleStepNMols/meshVolume << nl
|
||||
<< "Overall mass density = "
|
||||
<< singleStepTotalMass/meshVolume << nl
|
||||
<< "Average linear momentum per molecule = "
|
||||
<< singleStepTotalLinearMomentum/singleStepNMols << ' '
|
||||
<< mag(singleStepTotalLinearMomentum)/singleStepNMols << nl
|
||||
<< "Average angular momentum per molecule = "
|
||||
<< singleStepTotalAngularMomentum << ' '
|
||||
<< mag(singleStepTotalAngularMomentum)/singleStepNMols << nl
|
||||
<< "Maximum |velocity| = "
|
||||
<< singleStepMaxVelocityMag << nl
|
||||
<< "Average linear KE per molecule = "
|
||||
<< singleStepTotalLinearKE/singleStepNMols << nl
|
||||
<< "Average angular KE per molecule = "
|
||||
<< singleStepTotalAngularKE/singleStepNMols << nl
|
||||
<< "Average PE per molecule = "
|
||||
<< singleStepTotalPE/singleStepNMols << nl
|
||||
<< "Average TE per molecule = "
|
||||
<<
|
||||
(
|
||||
singleStepTotalLinearKE
|
||||
+ singleStepTotalAngularKE
|
||||
+ singleStepTotalPE
|
||||
)
|
||||
/singleStepNMols
|
||||
<< endl;
|
||||
|
||||
// Info<< singleStepNMols << " "
|
||||
// << singleStepTotalMomentum/singleStepTotalMass << " "
|
||||
// << singleStepMaxVelocityMag << " "
|
||||
// << singleStepTotalKE/singleStepNMols << " "
|
||||
// << singleStepTotalPE/singleStepNMols << " "
|
||||
// << (singleStepTotalKE + singleStepTotalPE)
|
||||
// /singleStepNMols << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "No molecules in system" << endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -1,26 +0,0 @@
|
||||
if (runTime.outputTime())
|
||||
{
|
||||
allSpeciesN_RU = List< scalarField >
|
||||
(
|
||||
molecules.potential().nIds(),
|
||||
scalarField(mesh.nCells(), 0.0)
|
||||
);
|
||||
|
||||
allSpeciesM_RU = List< scalarField >
|
||||
(
|
||||
molecules.potential().nIds(),
|
||||
scalarField(mesh.nCells(), 0.0)
|
||||
);
|
||||
|
||||
allSpeciesVelocitySum_RU = List< vectorField >
|
||||
(
|
||||
molecules.potential().nIds(),
|
||||
vectorField(mesh.nCells(), vector::zero)
|
||||
);
|
||||
|
||||
allSpeciesVelocityMagSquaredSum_RU = List< scalarField >
|
||||
(
|
||||
molecules.potential().nIds(),
|
||||
scalarField(mesh.nCells(), 0.0)
|
||||
);
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Global
|
||||
temperatureAndPressure.H
|
||||
|
||||
Description
|
||||
Accumulates values for temperature and pressure measurement, and
|
||||
calculates and outputs the average values at output times.
|
||||
Requires temperatureAndPressureVariables.H to be declared before the
|
||||
timeloop.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
accumulatedTotalLinearMomentum += singleStepTotalLinearMomentum;
|
||||
|
||||
accumulatedTotalMass += singleStepTotalMass;
|
||||
|
||||
accumulatedTotalLinearKE += singleStepTotalLinearKE;
|
||||
|
||||
accumulatedTotalAngularKE += singleStepTotalAngularKE;
|
||||
|
||||
accumulatedTotalPE += singleStepTotalPE;
|
||||
|
||||
accumulatedTotalrDotfSum += singleStepTotalrDotf;
|
||||
|
||||
accumulatedNMols += singleStepNMols;
|
||||
|
||||
accumulatedDOFs += singleStepDOFs;
|
||||
|
||||
if (runTime.outputTime())
|
||||
{
|
||||
if (accumulatedNMols)
|
||||
{
|
||||
Info<< "calculating averages" << endl;
|
||||
|
||||
averageTemperature =
|
||||
(
|
||||
2.0/(physicoChemical::k.value()*accumulatedDOFs)
|
||||
*
|
||||
(
|
||||
accumulatedTotalLinearKE + accumulatedTotalAngularKE
|
||||
-
|
||||
0.5*magSqr(accumulatedTotalLinearMomentum)/accumulatedTotalMass
|
||||
)
|
||||
);
|
||||
|
||||
averagePressure =
|
||||
(
|
||||
(
|
||||
(accumulatedNMols/nAveragingSteps)
|
||||
*physicoChemical::k.value()*averageTemperature
|
||||
+ accumulatedTotalrDotfSum/(6.0*nAveragingSteps)
|
||||
)
|
||||
/
|
||||
meshVolume
|
||||
);
|
||||
|
||||
Info<< "----------------------------------------" << nl
|
||||
<< "Averaged properties" << nl
|
||||
<< "Average |velocity| = "
|
||||
<< mag(accumulatedTotalLinearMomentum)/accumulatedTotalMass << nl
|
||||
<< "Average temperature = " << averageTemperature << nl
|
||||
<< "Average pressure = " << averagePressure << nl
|
||||
<< "----------------------------------------" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Not averaging temperature and pressure: "
|
||||
<< "no molecules in system" << endl;
|
||||
}
|
||||
|
||||
accumulatedTotalLinearMomentum = vector::zero;
|
||||
|
||||
accumulatedTotalMass = 0.0;
|
||||
|
||||
accumulatedTotalLinearKE = 0.0;
|
||||
|
||||
accumulatedTotalAngularKE = 0.0;
|
||||
|
||||
accumulatedTotalPE = 0.0;
|
||||
|
||||
accumulatedTotalrDotfSum = 0.0;
|
||||
|
||||
accumulatedNMols = 0;
|
||||
|
||||
accumulatedDOFs = 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -1,62 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Global
|
||||
temperatureAndPressureVariables.H
|
||||
|
||||
Description
|
||||
Provides accumulation variables for temperatureAndPressure.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
vector accumulatedTotalLinearMomentum(vector::zero);
|
||||
|
||||
scalar accumulatedTotalMass = 0.0;
|
||||
|
||||
scalar accumulatedTotalAngularKE = 0.0;
|
||||
|
||||
scalar accumulatedTotalLinearKE = 0.0;
|
||||
|
||||
scalar accumulatedTotalPE = 0.0;
|
||||
|
||||
scalar accumulatedTotalrDotfSum = 0.0;
|
||||
|
||||
label accumulatedNMols = 0;
|
||||
|
||||
label accumulatedDOFs = 0;
|
||||
|
||||
scalar averageTemperature = 0.0;
|
||||
|
||||
scalar averagePressure = 0.0;
|
||||
|
||||
const scalarField& cellVols = mesh.cellVolumes();
|
||||
|
||||
scalar meshVolume = sum(cellVols);
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
reduce(meshVolume, sumOp<scalar>());
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -1,42 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Global
|
||||
temperatureEquilibration.H
|
||||
|
||||
Description
|
||||
Applies temperature control to molecules
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
if (runTime.outputTime())
|
||||
{
|
||||
molecules.applyConstraintsAndThermostats
|
||||
(
|
||||
targetTemperature,
|
||||
averageTemperature
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -1,3 +0,0 @@
|
||||
distribution/distribution.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libmolecularMeasurements
|
@ -1,236 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "bufferedAccumulator.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const char* const
|
||||
Foam::bufferedAccumulator<Type>::typeName("bufferedAccumulator");
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::bufferedAccumulator<Type>::accumulateAndResetBuffer(const label b)
|
||||
{
|
||||
accumulationBuffer() += (*this)[b];
|
||||
|
||||
averagesTaken_++;
|
||||
|
||||
(*this)[b] = Field<Type>(bufferLength(), pTraits<Type>::zero);
|
||||
|
||||
bufferOffsets_[b] = 0;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::bufferedAccumulator<Type>::bufferedAccumulator()
|
||||
:
|
||||
List< Field<Type> >(),
|
||||
averagesTaken_(),
|
||||
bufferOffsets_()
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::bufferedAccumulator<Type>::bufferedAccumulator
|
||||
(
|
||||
const label nBuffers,
|
||||
const label bufferLength,
|
||||
const label bufferingInterval
|
||||
)
|
||||
:
|
||||
List< Field<Type> >(),
|
||||
averagesTaken_(),
|
||||
bufferOffsets_()
|
||||
{
|
||||
setSizes
|
||||
(
|
||||
nBuffers,
|
||||
bufferLength,
|
||||
bufferingInterval
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::bufferedAccumulator<Type>::bufferedAccumulator
|
||||
(
|
||||
const bufferedAccumulator<Type>& bA
|
||||
)
|
||||
:
|
||||
List< Field<Type> >(static_cast< List< Field<Type> > >(bA)),
|
||||
averagesTaken_(bA.averagesTaken()),
|
||||
bufferOffsets_(bA.bufferOffsets())
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::bufferedAccumulator<Type>::~bufferedAccumulator()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::bufferedAccumulator<Type>::setSizes
|
||||
(
|
||||
const label nBuffers,
|
||||
const label bufferLength,
|
||||
const label bufferingInterval
|
||||
)
|
||||
{
|
||||
(*this).setSize(nBuffers + 1);
|
||||
|
||||
forAll((*this), b)
|
||||
{
|
||||
(*this)[b] = Field<Type>(bufferLength, pTraits<Type>::zero);
|
||||
}
|
||||
|
||||
averagesTaken_ = 0;
|
||||
|
||||
bufferOffsets_.setSize(nBuffers);
|
||||
|
||||
forAll(bufferOffsets_, bO)
|
||||
{
|
||||
bufferOffsets_[bO] = -bufferingInterval * bO - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::label Foam::bufferedAccumulator<Type>::addToBuffers
|
||||
(
|
||||
const List<Type>& valuesToAdd
|
||||
)
|
||||
{
|
||||
label bufferToRefill = -1;
|
||||
|
||||
for (label b = 0; b < nBuffers(); b++)
|
||||
{
|
||||
Field<Type>& buf((*this)[b]);
|
||||
|
||||
label& bO = bufferOffsets_[b];
|
||||
|
||||
if (bO >= 0)
|
||||
{
|
||||
buf[bO] = valuesToAdd[b];
|
||||
}
|
||||
|
||||
bO++;
|
||||
|
||||
if (bO == bufferLength())
|
||||
{
|
||||
accumulateAndResetBuffer(b);
|
||||
}
|
||||
|
||||
if (bO == 0)
|
||||
{
|
||||
if (bufferToRefill != -1)
|
||||
{
|
||||
FatalErrorIn("bufferedAccumulator<Type>::addToBuffers ")
|
||||
<< "More than one bufferedAccumulator accumulation "
|
||||
<< "buffer filled at once, this is considered an error."
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
bufferToRefill = b;
|
||||
}
|
||||
}
|
||||
|
||||
return bufferToRefill;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Field<Type> Foam::bufferedAccumulator<Type>::averaged() const
|
||||
{
|
||||
if (averagesTaken_)
|
||||
{
|
||||
Field<Type> bA = accumulationBuffer()/averagesTaken_;
|
||||
|
||||
return bA;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"bufferedAccumulator<Type>::averagedbufferedAccumulator() const"
|
||||
) << "Averaged correlation function requested but averagesTaken = "
|
||||
<< averagesTaken_
|
||||
<< ". Returning empty field."
|
||||
<< endl;
|
||||
|
||||
return Field<Type>(bufferLength(), pTraits<Type>::zero);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::bufferedAccumulator<Type>::resetAveraging()
|
||||
{
|
||||
accumulationBuffer() = Field<Type>(bufferLength(), pTraits<Type>::zero);
|
||||
|
||||
averagesTaken_ = 0;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::bufferedAccumulator<Type>::operator=
|
||||
(
|
||||
const bufferedAccumulator<Type>& rhs
|
||||
)
|
||||
{
|
||||
// Check for assignment to self
|
||||
if (this == &rhs)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"bufferedAccumulator<Type>::operator=(const bufferedAccumulator&)"
|
||||
) << "Attempted assignment to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
List< Field<Type> >::operator=(rhs);
|
||||
|
||||
averagesTaken_ = rhs.averagesTaken();
|
||||
|
||||
bufferOffsets_ = rhs.bufferOffsets();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
# include "bufferedAccumulatorIO.C"
|
||||
|
||||
// ************************************************************************* //
|
@ -1,176 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::bufferedAccumulator
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
bufferedAccumulatorI.H
|
||||
bufferedAccumulator.C
|
||||
bufferedAccumulatorIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef bufferedAccumulator_H
|
||||
#define bufferedAccumulator_H
|
||||
|
||||
#include "Field.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<class Type>
|
||||
class bufferedAccumulator;
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const bufferedAccumulator<Type>&
|
||||
);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class bufferedAccumulator Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class bufferedAccumulator
|
||||
:
|
||||
public List< Field<Type> >
|
||||
{
|
||||
// Private data
|
||||
|
||||
label averagesTaken_;
|
||||
|
||||
List<label> bufferOffsets_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
inline Field<Type>& accumulationBuffer();
|
||||
|
||||
inline const Field<Type>& accumulationBuffer() const;
|
||||
|
||||
void accumulateAndResetBuffer(const label b);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Component type
|
||||
typedef typename pTraits<Type>::cmptType cmptType;
|
||||
|
||||
|
||||
// Static data members
|
||||
|
||||
static const char* const typeName;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
bufferedAccumulator();
|
||||
|
||||
//- Construct from components
|
||||
bufferedAccumulator
|
||||
(
|
||||
const label nBuffers,
|
||||
const label bufferLength,
|
||||
const label bufferingInterval
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
bufferedAccumulator(const bufferedAccumulator<Type>&);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~bufferedAccumulator();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
label addToBuffers(const List<Type>& valuesToAdd);
|
||||
|
||||
Field<Type> averaged() const;
|
||||
|
||||
void resetAveraging();
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
inline label averagesTaken() const;
|
||||
|
||||
inline label nBuffers() const;
|
||||
|
||||
inline label bufferLength() const;
|
||||
|
||||
inline const List<label>& bufferOffsets() const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
void setSizes
|
||||
(
|
||||
const label nBuffers,
|
||||
const label bufferLength,
|
||||
const label bufferingInterval
|
||||
);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
void operator=(const bufferedAccumulator<Type>&);
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<< <Type>
|
||||
(
|
||||
Ostream&,
|
||||
const bufferedAccumulator<Type>&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "bufferedAccumulatorI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "bufferedAccumulator.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
@ -1,79 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline Field<Type>& bufferedAccumulator<Type>::accumulationBuffer()
|
||||
{
|
||||
return (*this)[nBuffers()];
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline const Field<Type>& bufferedAccumulator<Type>::accumulationBuffer() const
|
||||
{
|
||||
return (*this)[nBuffers()];
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline label bufferedAccumulator<Type>::averagesTaken() const
|
||||
{
|
||||
return averagesTaken_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline label bufferedAccumulator<Type>::nBuffers() const
|
||||
{
|
||||
return bufferOffsets_.size();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline label bufferedAccumulator<Type>::bufferLength() const
|
||||
{
|
||||
return (*this)[0].size();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline const List<label>& bufferedAccumulator<Type>::bufferOffsets() const
|
||||
{
|
||||
return bufferOffsets_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
@ -1,51 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "bufferedAccumulator.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream&
|
||||
Foam::operator<<(Ostream& os, const bufferedAccumulator<Type>& bA)
|
||||
{
|
||||
|
||||
os << bA.averagesTaken_
|
||||
<< static_cast<const List< Field<Type> >&>(bA)
|
||||
<< bA.bufferOffsets();
|
||||
|
||||
// Check state of Ostream
|
||||
os.check
|
||||
(
|
||||
"Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
|
||||
"const Foam::bufferedAccumulator&)"
|
||||
);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -1,223 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "correlationFunction.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const char* const
|
||||
Foam::correlationFunction<Type>::typeName("correlationFunction");
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::correlationFunction<Type>::setTimesAndSizes
|
||||
(
|
||||
const label tZeroBufferSize
|
||||
)
|
||||
{
|
||||
sampleSteps_ = ceil(sampleInterval_/mesh_.time().deltaTValue());
|
||||
|
||||
sampleInterval_ = sampleSteps_*mesh_.time().deltaTValue();
|
||||
|
||||
label bufferLength(ceil(duration_/sampleInterval_));
|
||||
|
||||
duration_ = bufferLength*sampleInterval_;
|
||||
|
||||
label bufferingInterval(ceil(averagingInterval_/sampleInterval_));
|
||||
|
||||
averagingInterval_ = bufferingInterval*sampleInterval_;
|
||||
|
||||
label nBuffers(ceil(duration_/averagingInterval_));
|
||||
|
||||
this->setSizes
|
||||
(
|
||||
nBuffers,
|
||||
bufferLength,
|
||||
bufferingInterval
|
||||
);
|
||||
|
||||
tZeroBuffers_ =
|
||||
Field< Field<Type> >
|
||||
(
|
||||
nBuffers,
|
||||
Field<Type>
|
||||
(
|
||||
tZeroBufferSize,
|
||||
pTraits<Type>::zero
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::correlationFunction<Type>::correlationFunction
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& cfDict,
|
||||
const label tZeroBufferSize
|
||||
)
|
||||
:
|
||||
bufferedAccumulator<scalar>(),
|
||||
mesh_(mesh)
|
||||
{
|
||||
duration_ = readScalar(cfDict.lookup("duration"));
|
||||
|
||||
sampleInterval_ = readScalar(cfDict.lookup("sampleInterval"));
|
||||
|
||||
averagingInterval_ = readScalar(cfDict.lookup("averagingInterval"));
|
||||
|
||||
setTimesAndSizes(tZeroBufferSize);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::correlationFunction<Type>::correlationFunction
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const label tZeroBufferSize,
|
||||
const scalar duration,
|
||||
const scalar sampleInterval,
|
||||
const scalar averagingInterval
|
||||
)
|
||||
:
|
||||
bufferedAccumulator<scalar>(),
|
||||
mesh_(mesh),
|
||||
duration_(duration),
|
||||
sampleInterval_(sampleInterval),
|
||||
averagingInterval_(averagingInterval)
|
||||
{
|
||||
setTimesAndSizes(tZeroBufferSize);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::correlationFunction<Type>::~correlationFunction()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::correlationFunction<Type>::calculateCorrelationFunction
|
||||
(
|
||||
const Field<Type>& currentValues
|
||||
)
|
||||
{
|
||||
if (measurandFieldSize() != currentValues.size())
|
||||
{
|
||||
FatalErrorIn("correlationFunction<Type>::calculateCorrelationFunction")
|
||||
<< "Trying to supply a Field of length"
|
||||
<< currentValues.size()
|
||||
<< " to calculate the correlation function. "
|
||||
<< "Expecting a Field of length "
|
||||
<< measurandFieldSize() << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
List<scalar> cFSums(nBuffers(),0.0);
|
||||
|
||||
forAll(tZeroBuffers_, tZB)
|
||||
{
|
||||
scalar& cFSum = cFSums[tZB];
|
||||
|
||||
const Field<Type>& tZeroBuffer = tZeroBuffers_[tZB];
|
||||
|
||||
forAll(currentValues, cV)
|
||||
{
|
||||
const Type& tZeroBufferValue = tZeroBuffer[cV];
|
||||
|
||||
const Type& currentValue = currentValues[cV];
|
||||
|
||||
forAll(currentValue, component)
|
||||
{
|
||||
cFSum +=
|
||||
(
|
||||
tZeroBufferValue[component]*currentValue[component]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
cFSum /= (measurandFieldSize()*currentValues[0].size());
|
||||
}
|
||||
|
||||
label bufferToRefill = addToBuffers(cFSums);
|
||||
|
||||
if (bufferToRefill != -1)
|
||||
{
|
||||
tZeroBuffers_[bufferToRefill] = currentValues;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::correlationFunction<Type>::calculateCorrelationFunction
|
||||
(
|
||||
const Type& currentValue
|
||||
)
|
||||
{
|
||||
if (measurandFieldSize() != 1)
|
||||
{
|
||||
FatalErrorIn("correlationFunction<Type>::calculateCorrelationFunction")
|
||||
<< "Trying to supply a single value to calculate the correlation "
|
||||
<< "function. Expecting a Field of length "
|
||||
<< measurandFieldSize()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
calculateCorrelationFunction(Field<Type>(1, currentValue));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::scalar Foam::correlationFunction<Type>::integral() const
|
||||
{
|
||||
Field<scalar> averageCF(averaged());
|
||||
|
||||
scalar cFIntegral = 0.0;
|
||||
|
||||
for (label v = 0; v < averageCF.size() - 1; v++)
|
||||
{
|
||||
cFIntegral +=
|
||||
0.5
|
||||
*sampleInterval_
|
||||
*(averageCF[v+1] + averageCF[v]);
|
||||
}
|
||||
|
||||
return cFIntegral;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
# include "correlationFunctionIO.C"
|
||||
|
||||
// ************************************************************************* //
|
@ -1,181 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::correlationFunction
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
correlationFunctionI.H
|
||||
correlationFunction.C
|
||||
correlationFunctionIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef correlationFunction_H
|
||||
#define correlationFunction_H
|
||||
|
||||
#include "bufferedAccumulator.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<class Type>
|
||||
class correlationFunction;
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const correlationFunction<Type>&
|
||||
);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class correlationFunction Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class correlationFunction
|
||||
:
|
||||
public bufferedAccumulator<scalar>
|
||||
{
|
||||
// Private data
|
||||
|
||||
const polyMesh& mesh_;
|
||||
|
||||
Field< Field<Type> > tZeroBuffers_;
|
||||
|
||||
scalar duration_;
|
||||
scalar sampleInterval_;
|
||||
scalar averagingInterval_;
|
||||
|
||||
label sampleSteps_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void setTimesAndSizes(const label);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
correlationFunction(const correlationFunction<Type>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const correlationFunction<Type>&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Component type
|
||||
typedef typename pTraits<Type>::cmptType cmptType;
|
||||
|
||||
|
||||
// Static data members
|
||||
|
||||
static const char* const typeName;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
correlationFunction
|
||||
(
|
||||
const polyMesh&,
|
||||
const dictionary&,
|
||||
const label tZeroBufferSize
|
||||
);
|
||||
|
||||
//- Construct from components
|
||||
correlationFunction
|
||||
(
|
||||
const polyMesh&,
|
||||
const label tZeroBufferSize,
|
||||
const scalar duration,
|
||||
const scalar sampleInterval,
|
||||
const scalar averagingInterval
|
||||
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~correlationFunction();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
void calculateCorrelationFunction(const Field<Type>&);
|
||||
|
||||
void calculateCorrelationFunction(const Type&);
|
||||
|
||||
scalar integral() const;
|
||||
|
||||
bool writeAveraged(Ostream&) const;
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
inline const Field< Field<Type> >& tZeroBuffers() const;
|
||||
|
||||
inline scalar duration() const;
|
||||
|
||||
inline scalar sampleInterval() const;
|
||||
|
||||
inline scalar averagingInterval() const;
|
||||
|
||||
inline label sampleSteps() const;
|
||||
|
||||
inline label measurandFieldSize() const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<< <Type>
|
||||
(
|
||||
Ostream&,
|
||||
const correlationFunction<Type>&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "correlationFunctionI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "correlationFunction.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
@ -1,69 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
inline const Foam::Field< Foam::Field<Type> >&
|
||||
Foam::correlationFunction<Type>::tZeroBuffers() const
|
||||
{
|
||||
return tZeroBuffers_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Foam::scalar Foam::correlationFunction<Type>::duration() const
|
||||
{
|
||||
return duration_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Foam::scalar Foam::correlationFunction<Type>::sampleInterval() const
|
||||
{
|
||||
return sampleInterval_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Foam::scalar Foam::correlationFunction<Type>::averagingInterval() const
|
||||
{
|
||||
return averagingInterval_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Foam::label Foam::correlationFunction<Type>::sampleSteps() const
|
||||
{
|
||||
return sampleSteps_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Foam::label Foam::correlationFunction<Type>::measurandFieldSize() const
|
||||
{
|
||||
return tZeroBuffers_[0].size();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -1,71 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "correlationFunction.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
template<class Type>
|
||||
bool Foam::correlationFunction<Type>::writeAveraged(Ostream& os) const
|
||||
{
|
||||
Field<scalar> averageCF(averaged());
|
||||
|
||||
forAll(averageCF, v)
|
||||
{
|
||||
os << v*sampleInterval()
|
||||
<< token::SPACE
|
||||
<< averageCF[v]
|
||||
<< nl;
|
||||
}
|
||||
|
||||
return os.good();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const correlationFunction<Type>& cF
|
||||
)
|
||||
{
|
||||
os << cF.duration()
|
||||
<< nl << cF.sampleInterval()
|
||||
<< nl << cF.averagingInterval()
|
||||
<< nl << cF.sampleSteps()
|
||||
<< nl << cF.tZeroBuffers()
|
||||
<< nl << static_cast<const bufferedAccumulator<scalar>&>(cF);
|
||||
|
||||
// Check state of Ostream
|
||||
os.check
|
||||
(
|
||||
"Foam::Ostream& Foam::operator<<"
|
||||
"(Ostream&, const correlationFunction<Type>&)"
|
||||
);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -1,478 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "distribution.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(distribution, 0);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
void Foam::distribution::write
|
||||
(
|
||||
const fileName& file,
|
||||
const List<Pair<scalar> >& pairs
|
||||
)
|
||||
{
|
||||
OFstream os(file);
|
||||
|
||||
forAll(pairs, i)
|
||||
{
|
||||
os << pairs[i].first() << ' ' << pairs[i].second() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::distribution::distribution()
|
||||
:
|
||||
Map<label>(),
|
||||
binWidth_(1)
|
||||
{}
|
||||
|
||||
|
||||
Foam::distribution::distribution(const scalar binWidth)
|
||||
:
|
||||
Map<label>(),
|
||||
binWidth_(binWidth)
|
||||
{}
|
||||
|
||||
|
||||
Foam::distribution::distribution(const distribution& d)
|
||||
:
|
||||
Map<label>(static_cast< Map<label> >(d)),
|
||||
binWidth_(d.binWidth())
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::distribution::~distribution()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::distribution::totalEntries() const
|
||||
{
|
||||
label sumOfEntries = 0;
|
||||
|
||||
forAllConstIter(Map<label>, *this, iter)
|
||||
{
|
||||
sumOfEntries += iter();
|
||||
|
||||
if (sumOfEntries < 0)
|
||||
{
|
||||
WarningIn("label distribution::totalEntries()")
|
||||
<< "Accumulated distribution values total has become negative: "
|
||||
<< "sumOfEntries = " << sumOfEntries
|
||||
<< ". This is most likely to be because too many samples "
|
||||
<< "have been added to the bins and the label has 'rolled "
|
||||
<< "round'. Try distribution::approxTotalEntries which "
|
||||
<< "returns a scalar." << endl;
|
||||
|
||||
sumOfEntries = -1;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return sumOfEntries;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distribution::approxTotalEntries() const
|
||||
{
|
||||
scalar sumOfEntries = 0;
|
||||
|
||||
forAllConstIter(Map<label>, *this, iter)
|
||||
{
|
||||
sumOfEntries += scalar(iter());
|
||||
}
|
||||
|
||||
return sumOfEntries;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distribution::mean() const
|
||||
{
|
||||
scalar runningSum = 0;
|
||||
|
||||
scalar totEnt = approxTotalEntries();
|
||||
|
||||
List<label> keys = toc();
|
||||
|
||||
forAll(keys,k)
|
||||
{
|
||||
label key = keys[k];
|
||||
|
||||
runningSum +=
|
||||
(0.5 + scalar(key))
|
||||
*binWidth_
|
||||
*scalar((*this)[key])
|
||||
/totEnt;
|
||||
}
|
||||
|
||||
return runningSum;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distribution::median()
|
||||
{
|
||||
// From:
|
||||
// http://mathworld.wolfram.com/StatisticalMedian.html
|
||||
// The statistical median is the value of the distribution variable
|
||||
// where the cumulative distribution = 0.5.
|
||||
|
||||
scalar median = 0.0;
|
||||
|
||||
scalar runningSum = 0.0;
|
||||
|
||||
List<Pair<scalar> > normDist(normalised());
|
||||
|
||||
if (normDist.size())
|
||||
{
|
||||
if (normDist.size() == 1)
|
||||
{
|
||||
median = normDist[0].first();
|
||||
}
|
||||
else if
|
||||
(
|
||||
normDist.size() > 1
|
||||
&& normDist[0].second()*binWidth_ > 0.5
|
||||
)
|
||||
{
|
||||
scalar xk = normDist[1].first();
|
||||
scalar xkm1 = normDist[0].first();
|
||||
scalar Sk =
|
||||
(normDist[0].second() + normDist[1].second())*binWidth_;
|
||||
scalar Skm1 = normDist[0].second()*binWidth_;
|
||||
|
||||
median = (0.5 - Skm1)*(xk - xkm1)/(Sk - Skm1) + xkm1;
|
||||
}
|
||||
else
|
||||
{
|
||||
label lastNonZeroIndex = 0;
|
||||
|
||||
forAll(normDist,nD)
|
||||
{
|
||||
if (runningSum + (normDist[nD].second()*binWidth_) > 0.5)
|
||||
{
|
||||
scalar xk = normDist[nD].first();
|
||||
scalar xkm1 = normDist[lastNonZeroIndex].first();
|
||||
scalar Sk = runningSum + (normDist[nD].second()*binWidth_);
|
||||
scalar Skm1 = runningSum;
|
||||
|
||||
median = (0.5 - Skm1)*(xk - xkm1)/(Sk - Skm1) + xkm1;
|
||||
|
||||
break;
|
||||
}
|
||||
else if (normDist[nD].second() > 0.0)
|
||||
{
|
||||
runningSum += normDist[nD].second()*binWidth_;
|
||||
|
||||
lastNonZeroIndex = nD;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return median;
|
||||
}
|
||||
|
||||
|
||||
void Foam::distribution::add(const scalar valueToAdd)
|
||||
{
|
||||
iterator iter(this->begin());
|
||||
|
||||
label n = label(valueToAdd/binWidth_) - label(neg(valueToAdd/binWidth_));
|
||||
|
||||
iter = find(n);
|
||||
|
||||
if (iter == this->end())
|
||||
{
|
||||
this->insert(n,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*this)[n]++;
|
||||
}
|
||||
|
||||
if ((*this)[n] < 0)
|
||||
{
|
||||
FatalErrorIn("distribution::add(const scalar valueToAdd)")
|
||||
<< "Accumulated distribution value has become negative: "
|
||||
<< "bin = " << (0.5 + scalar(n)) * binWidth_
|
||||
<< ", value = " << (*this)[n]
|
||||
<< ". This is most likely to be because too many samples "
|
||||
<< "have been added to a bin and the label has 'rolled round'"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::distribution::add(const label valueToAdd)
|
||||
{
|
||||
add(scalar(valueToAdd));
|
||||
}
|
||||
|
||||
|
||||
void Foam::distribution::insertMissingKeys()
|
||||
{
|
||||
iterator iter(this->begin());
|
||||
|
||||
List<label> keys = toc();
|
||||
|
||||
sort(keys);
|
||||
|
||||
if (keys.size())
|
||||
{
|
||||
for (label k = keys[0]; k < keys.last(); k++)
|
||||
{
|
||||
iter = find(k);
|
||||
|
||||
if (iter == this->end())
|
||||
{
|
||||
this->insert(k,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::List<Foam::Pair<Foam::scalar> > Foam::distribution::normalised()
|
||||
{
|
||||
scalar totEnt = approxTotalEntries();
|
||||
|
||||
insertMissingKeys();
|
||||
|
||||
List<label> keys = toc();
|
||||
|
||||
sort(keys);
|
||||
|
||||
List<Pair<scalar> > normDist(size());
|
||||
|
||||
forAll(keys,k)
|
||||
{
|
||||
label key = keys[k];
|
||||
|
||||
normDist[k].first() = (0.5 + scalar(key))*binWidth_;
|
||||
|
||||
normDist[k].second() = scalar((*this)[key])/totEnt/binWidth_;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "totEnt: " << totEnt << endl;
|
||||
}
|
||||
|
||||
return normDist;
|
||||
}
|
||||
|
||||
|
||||
Foam::List<Foam::Pair<Foam::scalar> > Foam::distribution::normalisedMinusMean()
|
||||
{
|
||||
return normalisedShifted(mean());
|
||||
}
|
||||
|
||||
|
||||
Foam::List<Foam::Pair<Foam::scalar> > Foam::distribution::normalisedShifted
|
||||
(
|
||||
scalar shiftValue
|
||||
)
|
||||
{
|
||||
List<Pair<scalar> > oldDist(normalised());
|
||||
|
||||
List<Pair<scalar> > newDist(oldDist.size());
|
||||
|
||||
forAll(oldDist,u)
|
||||
{
|
||||
oldDist[u].first() -= shiftValue;
|
||||
}
|
||||
|
||||
scalar lowestOldBin = oldDist[0].first()/binWidth_ - 0.5;
|
||||
|
||||
label lowestNewKey = label
|
||||
(
|
||||
lowestOldBin + 0.5*sign(lowestOldBin)
|
||||
);
|
||||
|
||||
scalar interpolationStartDirection =
|
||||
sign(scalar(lowestNewKey) - lowestOldBin);
|
||||
|
||||
label newKey = lowestNewKey;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< shiftValue
|
||||
<< nl << lowestOldBin
|
||||
<< nl << lowestNewKey
|
||||
<< nl << interpolationStartDirection
|
||||
<< endl;
|
||||
|
||||
scalar checkNormalisation = 0;
|
||||
|
||||
forAll(oldDist, oD)
|
||||
{
|
||||
checkNormalisation += oldDist[oD].second()*binWidth_;
|
||||
}
|
||||
|
||||
Info<< "Initial normalisation = " << checkNormalisation << endl;
|
||||
}
|
||||
|
||||
forAll(oldDist,u)
|
||||
{
|
||||
newDist[u].first() = (0.5 + scalar(newKey)) * binWidth_;
|
||||
|
||||
if (interpolationStartDirection < 0)
|
||||
{
|
||||
if (u == 0)
|
||||
{
|
||||
newDist[u].second() =
|
||||
(0.5 + scalar(newKey))*oldDist[u].second()
|
||||
- oldDist[u].second()
|
||||
*(oldDist[u].first() - binWidth_)/ binWidth_;
|
||||
}
|
||||
else
|
||||
{
|
||||
newDist[u].second() =
|
||||
(0.5 + scalar(newKey))
|
||||
*(oldDist[u].second() - oldDist[u-1].second())
|
||||
+
|
||||
(
|
||||
oldDist[u-1].second()*oldDist[u].first()
|
||||
- oldDist[u].second()*oldDist[u-1].first()
|
||||
)
|
||||
/binWidth_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (u == oldDist.size() - 1)
|
||||
{
|
||||
newDist[u].second() =
|
||||
(0.5 + scalar(newKey))*-oldDist[u].second()
|
||||
+ oldDist[u].second()*(oldDist[u].first() + binWidth_)
|
||||
/binWidth_;
|
||||
}
|
||||
else
|
||||
{
|
||||
newDist[u].second() =
|
||||
(0.5 + scalar(newKey))
|
||||
*(oldDist[u+1].second() - oldDist[u].second())
|
||||
+
|
||||
(
|
||||
oldDist[u].second()*oldDist[u+1].first()
|
||||
- oldDist[u+1].second()*oldDist[u].first()
|
||||
)
|
||||
/binWidth_;
|
||||
}
|
||||
}
|
||||
|
||||
newKey++;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
scalar checkNormalisation = 0;
|
||||
|
||||
forAll(newDist, nD)
|
||||
{
|
||||
checkNormalisation += newDist[nD].second()*binWidth_;
|
||||
}
|
||||
|
||||
Info<< "Shifted normalisation = " << checkNormalisation << endl;
|
||||
}
|
||||
|
||||
return newDist;
|
||||
}
|
||||
|
||||
|
||||
Foam::List<Foam::Pair<Foam::scalar> > Foam::distribution::raw()
|
||||
{
|
||||
insertMissingKeys();
|
||||
|
||||
List<label> keys = toc();
|
||||
|
||||
sort(keys);
|
||||
|
||||
List<Pair<scalar> > rawDist(size());
|
||||
|
||||
forAll(keys,k)
|
||||
{
|
||||
label key = keys[k];
|
||||
|
||||
rawDist[k].first() = (0.5 + scalar(key))*binWidth_;
|
||||
|
||||
rawDist[k].second() = scalar((*this)[key]);
|
||||
}
|
||||
|
||||
return rawDist;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::distribution::operator=(const distribution& rhs)
|
||||
{
|
||||
// Check for assignment to self
|
||||
if (this == &rhs)
|
||||
{
|
||||
FatalErrorIn("distribution::operator=(const distribution&)")
|
||||
<< "Attempted assignment to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
Map<label>::operator=(rhs);
|
||||
|
||||
binWidth_ = rhs.binWidth();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const distribution& d)
|
||||
{
|
||||
os << d.binWidth_
|
||||
<< static_cast<const Map<label>&>(d);
|
||||
|
||||
// Check state of Ostream
|
||||
os.check
|
||||
(
|
||||
"Ostream& operator<<(Ostream&, "
|
||||
"const distribution&)"
|
||||
);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -1,148 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::distribution
|
||||
|
||||
Description
|
||||
Accumulating histogram of values. Specified bin resolution
|
||||
automatic generation of bins.
|
||||
|
||||
SourceFiles
|
||||
distributionI.H
|
||||
distribution.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef distribution_H
|
||||
#define distribution_H
|
||||
|
||||
#include "Map.H"
|
||||
#include "Pair.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class distribution Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class distribution
|
||||
:
|
||||
public Map<label>
|
||||
{
|
||||
// Private data
|
||||
|
||||
scalar binWidth_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
|
||||
TypeName("distribution");
|
||||
|
||||
// Static functions
|
||||
|
||||
//- write to file
|
||||
|
||||
static void write
|
||||
(
|
||||
const fileName& file,
|
||||
const List<Pair<scalar> >& pairs
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
distribution();
|
||||
|
||||
//- Construct from binWidth
|
||||
distribution(const scalar binWidth);
|
||||
|
||||
//- Construct as copy
|
||||
distribution(const distribution&);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~distribution();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
label totalEntries() const;
|
||||
|
||||
scalar approxTotalEntries() const;
|
||||
|
||||
scalar mean() const;
|
||||
|
||||
scalar median();
|
||||
|
||||
//- Add a value to the appropriate bin of the distribution.
|
||||
void add(const scalar valueToAdd);
|
||||
|
||||
void add(const label valueToAdd);
|
||||
|
||||
void insertMissingKeys();
|
||||
|
||||
List<Pair<scalar> > normalised();
|
||||
|
||||
List<Pair<scalar> > normalisedMinusMean();
|
||||
|
||||
List<Pair<scalar> > normalisedShifted(scalar shiftValue);
|
||||
|
||||
List<Pair<scalar> > raw();
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
inline scalar binWidth() const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
void operator=(const distribution&);
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const distribution&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "distributionI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
@ -1,34 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::distribution::binWidth() const
|
||||
{
|
||||
return binWidth_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -1,164 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "reducedUnits.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::scalar Foam::reducedUnits::kb = 1.3806504e-23;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::reducedUnits::calcRefValues()
|
||||
{
|
||||
if
|
||||
(
|
||||
refTime_ < VSMALL
|
||||
|| refLength_ < VSMALL
|
||||
|| refMass_ < VSMALL
|
||||
)
|
||||
{
|
||||
FatalErrorIn("Foam::reducedUnits::calcRefValues() ")
|
||||
<< "One of more referencence values too small for floating point "
|
||||
<< "calculation: "
|
||||
<< "refTime_ = " << refTime_
|
||||
<< ", refLength = " << refTemp_
|
||||
<< ", refMass = " << refMass_
|
||||
<< nl << abort(FatalError);
|
||||
}
|
||||
|
||||
refEnergy_ = refLength_*refLength_*refMass_/(refTime_*refTime_);
|
||||
|
||||
refTemp_ = refEnergy_ / kb;
|
||||
|
||||
refForce_ = refEnergy_/refLength_;
|
||||
|
||||
refVelocity_ = Foam::sqrt(refEnergy_/refMass_);
|
||||
|
||||
refVolume_ = Foam::pow(refLength_,3.0);
|
||||
|
||||
refPressure_ = refEnergy_/refVolume_;
|
||||
|
||||
refMassDensity_ = refMass_/refVolume_;
|
||||
|
||||
refNumberDensity_ = 1.0/refVolume_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::reducedUnits::reducedUnits()
|
||||
:
|
||||
refLength_(1e-9),
|
||||
refTime_(1e-12),
|
||||
refMass_(1.660538782e-27)
|
||||
{
|
||||
calcRefValues();
|
||||
}
|
||||
|
||||
|
||||
Foam::reducedUnits::reducedUnits
|
||||
(
|
||||
scalar refLength,
|
||||
scalar refTime,
|
||||
scalar refMass
|
||||
)
|
||||
:
|
||||
refLength_(refLength),
|
||||
refTime_(refTime),
|
||||
refMass_(refMass)
|
||||
{
|
||||
calcRefValues();
|
||||
}
|
||||
|
||||
|
||||
Foam::reducedUnits::reducedUnits(const IOdictionary& reducedUnitsDict)
|
||||
:
|
||||
refLength_(),
|
||||
refTime_(),
|
||||
refMass_()
|
||||
{
|
||||
setRefValues(reducedUnitsDict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::reducedUnits::~reducedUnits()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::reducedUnits::setRefValues
|
||||
(
|
||||
scalar refLength,
|
||||
scalar refTime,
|
||||
scalar refMass
|
||||
)
|
||||
{
|
||||
refLength_ = refLength;
|
||||
|
||||
refTime_ = refTime;
|
||||
|
||||
refMass_ = refMass;
|
||||
|
||||
calcRefValues();
|
||||
}
|
||||
|
||||
|
||||
void Foam::reducedUnits::setRefValues
|
||||
(
|
||||
const IOdictionary& reducedUnitsDict
|
||||
)
|
||||
{
|
||||
refLength_ = readScalar(reducedUnitsDict.lookup("refLength"));
|
||||
|
||||
refTime_ = readScalar(reducedUnitsDict.lookup("refTime"));
|
||||
|
||||
refMass_ = readScalar(reducedUnitsDict.lookup("refMass"));
|
||||
|
||||
calcRefValues();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::reducedUnits::operator=(const reducedUnits& rhs)
|
||||
{
|
||||
// Check for assignment to self
|
||||
if (this == &rhs)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::reducedUnits::operator=(const Foam::reducedUnits&)"
|
||||
) << "Attempted assignment to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -1,182 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::reducedUnits
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
reducedUnitsI.H
|
||||
reducedUnits.C
|
||||
reducedUnitsIO.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef reducedUnits_H
|
||||
#define reducedUnits_H
|
||||
|
||||
#include "scalar.H"
|
||||
#include "IOdictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class reducedUnits Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class reducedUnits
|
||||
{
|
||||
// Private data
|
||||
|
||||
// Reduced units
|
||||
|
||||
// Fundamental values
|
||||
|
||||
scalar refLength_;
|
||||
|
||||
scalar refTime_;
|
||||
|
||||
scalar refMass_;
|
||||
|
||||
// Derived values
|
||||
|
||||
scalar refEnergy_;
|
||||
|
||||
scalar refTemp_;
|
||||
|
||||
scalar refForce_;
|
||||
|
||||
scalar refVelocity_;
|
||||
|
||||
scalar refVolume_;
|
||||
|
||||
scalar refPressure_;
|
||||
|
||||
scalar refMassDensity_;
|
||||
|
||||
scalar refNumberDensity_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void calcRefValues();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
reducedUnits(const reducedUnits&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const reducedUnits&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Static data members
|
||||
|
||||
//- Static data someStaticData
|
||||
static const scalar kb;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct with no argument, uses default values:
|
||||
// length = 1nm
|
||||
// mass = 1.660538782e-27kg (unified atomic mass unit)
|
||||
// temperature = 1K (therefore, energy = 1*kb)
|
||||
reducedUnits();
|
||||
|
||||
//- Construct from components
|
||||
reducedUnits
|
||||
(
|
||||
scalar refLength,
|
||||
scalar refTime,
|
||||
scalar refMass
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
reducedUnits(const IOdictionary& reducedUnitsDict);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~reducedUnits();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
void setRefValues
|
||||
(
|
||||
scalar refLength,
|
||||
scalar refTime,
|
||||
scalar refMass
|
||||
);
|
||||
|
||||
void setRefValues(const IOdictionary& reducedUnitsDict);
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
inline scalar refLength() const;
|
||||
|
||||
inline scalar refTime() const;
|
||||
|
||||
inline scalar refMass() const;
|
||||
|
||||
inline scalar refTemp() const;
|
||||
|
||||
inline scalar refEnergy() const;
|
||||
|
||||
inline scalar refForce() const;
|
||||
|
||||
inline scalar refVelocity() const;
|
||||
|
||||
inline scalar refVolume() const;
|
||||
|
||||
inline scalar refPressure() const;
|
||||
|
||||
inline scalar refMassDensity() const;
|
||||
|
||||
inline scalar refNumberDensity() const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const reducedUnits&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "reducedUnitsI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
@ -1,94 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::reducedUnits::refLength() const
|
||||
{
|
||||
return refLength_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::reducedUnits::refTime() const
|
||||
{
|
||||
return refTime_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::reducedUnits::refMass() const
|
||||
{
|
||||
return refMass_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::reducedUnits::refTemp() const
|
||||
{
|
||||
return refTemp_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::reducedUnits::refEnergy() const
|
||||
{
|
||||
return refEnergy_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::reducedUnits::refForce() const
|
||||
{
|
||||
return refForce_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::reducedUnits::refVelocity() const
|
||||
{
|
||||
return refVelocity_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::reducedUnits::refVolume() const
|
||||
{
|
||||
return refVolume_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::reducedUnits::refPressure() const
|
||||
{
|
||||
return refPressure_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::reducedUnits::refMassDensity() const
|
||||
{
|
||||
return refMassDensity_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::reducedUnits::refNumberDensity() const
|
||||
{
|
||||
return refNumberDensity_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
@ -1,60 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "reducedUnits.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const reducedUnits& rU)
|
||||
{
|
||||
os << nl << "Defined: " << nl
|
||||
<< tab << "refLength = " << rU.refLength() << " m" << nl
|
||||
<< tab << "refTime = " << rU.refTime() << " s" << nl
|
||||
<< tab << "refMass = " << rU.refMass() << " kg" << nl
|
||||
<< tab << "Boltzmann constant, kb = " << reducedUnits::kb << " J/K"
|
||||
<< nl << "Calculated: " << nl
|
||||
<< tab << "refEnergy = " << rU.refEnergy() << " J" << nl
|
||||
<< tab << "refTemp = " << rU.refTemp() << " K" << nl
|
||||
<< tab << "refForce = " << rU.refForce() << " N" << nl
|
||||
<< tab << "refVelocity = " << rU.refVelocity() << " m/s" << nl
|
||||
<< tab << "refVolume = " << rU.refVolume() << " m^3" << nl
|
||||
<< tab << "refPressure = " << rU.refPressure() << " N/m^2" << nl
|
||||
<< tab << "refMassDensity = " << rU.refMassDensity() << " kg/m^3" << nl
|
||||
<< tab << "refNumberDensity = " << rU.refNumberDensity() << " m^-3"
|
||||
<< endl;
|
||||
|
||||
// Check state of Ostream
|
||||
os.check
|
||||
(
|
||||
"Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
|
||||
"const Foam::reducedUnits&)"
|
||||
);
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
Loading…
Reference in New Issue
Block a user