molecularDynamics: Consolidated into a single library
This simplifies the directory structure and resolves some name clashes with other parts of OpenFOAM.
This commit is contained in:
@ -1,15 +1,11 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/molecule/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/potential/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/molecularMeasurements/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-lfiniteVolume \
|
||||
-llagrangian \
|
||||
-lmolecule \
|
||||
-lpotential \
|
||||
-lmolecularMeasurements
|
||||
-lmolecularDynamics
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -30,7 +30,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "md.H"
|
||||
#include "moleculeCloud.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/molecule/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/potential/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/molecularMeasurements/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-lfiniteVolume \
|
||||
-llagrangian \
|
||||
-lmolecule \
|
||||
-lpotential \
|
||||
-lmolecularMeasurements
|
||||
-lmolecularDynamics
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -31,7 +31,7 @@ Description
|
||||
|
||||
#include "argList.H"
|
||||
#include "timeSelector.H"
|
||||
#include "md.H"
|
||||
#include "moleculeCloud.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -1,18 +1,13 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/polyTopoChange/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/molecule/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/potential/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/molecularMeasurements/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools \
|
||||
-lpolyTopoChange \
|
||||
-lfiniteVolume \
|
||||
-llagrangian \
|
||||
-lmolecule \
|
||||
-lpotential \
|
||||
-lmolecularMeasurements
|
||||
|
||||
-lmolecularDynamics
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,7 +27,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "md.H"
|
||||
#include "moleculeCloud.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
@ -8,9 +8,7 @@ wmake $targetType basic
|
||||
wmake $targetType solidParticle
|
||||
wmake $targetType parcel
|
||||
wmake $targetType DSMC
|
||||
|
||||
molecularDynamics/Allwmake $targetType $*
|
||||
|
||||
wmake $targetType molecularDynamics
|
||||
wmake $targetType functionObjects
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Parse arguments for library compilation
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
|
||||
wmake $targetType potential
|
||||
wmake $targetType molecularMeasurements
|
||||
wmake $targetType molecule
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
45
src/lagrangian/molecularDynamics/Make/files
Normal file
45
src/lagrangian/molecularDynamics/Make/files
Normal file
@ -0,0 +1,45 @@
|
||||
reducedUnits/reducedUnits.C
|
||||
reducedUnits/reducedUnitsIO.C
|
||||
|
||||
molecule/molecule.C
|
||||
molecule/moleculeIO.C
|
||||
|
||||
moleculeCloud/moleculeCloud.C
|
||||
|
||||
potential/potential/potential.C
|
||||
|
||||
potential/pairPotential/pairPotentialList/pairPotentialList.C
|
||||
|
||||
potential/pairPotential/basic/pairPotential.C
|
||||
potential/pairPotential/basic/pairPotentialIO.C
|
||||
potential/pairPotential/basic/pairPotentialNew.C
|
||||
|
||||
potential/pairPotential/derived/lennardJones/lennardJones.C
|
||||
potential/pairPotential/derived/maitlandSmith/maitlandSmith.C
|
||||
potential/pairPotential/derived/azizChen/azizChen.C
|
||||
potential/pairPotential/derived/exponentialRepulsion/exponentialRepulsion.C
|
||||
potential/pairPotential/derived/coulomb/coulomb.C
|
||||
potential/pairPotential/derived/dampedCoulomb/dampedCoulomb.C
|
||||
potential/pairPotential/derived/noInteraction/noInteraction.C
|
||||
|
||||
potential/energyScalingFunction/basic/energyScalingFunction.C
|
||||
potential/energyScalingFunction/basic/energyScalingFunctionNew.C
|
||||
|
||||
potential/energyScalingFunction/derived/shifted/shifted.C
|
||||
potential/energyScalingFunction/derived/shiftedForce/shiftedForce.C
|
||||
potential/energyScalingFunction/derived/noScaling/noScaling.C
|
||||
potential/energyScalingFunction/derived/sigmoid/sigmoid.C
|
||||
potential/energyScalingFunction/derived/doubleSigmoid/doubleSigmoid.C
|
||||
|
||||
potential/tetherPotential/tetherPotentialList/tetherPotentialList.C
|
||||
|
||||
potential/tetherPotential/basic/tetherPotential.C
|
||||
potential/tetherPotential/basic/tetherPotentialNew.C
|
||||
|
||||
potential/tetherPotential/derived/harmonicSpring/harmonicSpring.C
|
||||
potential/tetherPotential/derived/restrainedHarmonicSpring/restrainedHarmonicSpring.C
|
||||
potential/tetherPotential/derived/pitchForkRing/pitchForkRing.C
|
||||
|
||||
potential/electrostaticPotential/electrostaticPotential.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libmolecularDynamics
|
||||
9
src/lagrangian/molecularDynamics/Make/options
Normal file
9
src/lagrangian/molecularDynamics/Make/options
Normal file
@ -0,0 +1,9 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools \
|
||||
-llagrangian
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -1,3 +0,0 @@
|
||||
distribution/distribution.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libmolecularMeasurements
|
||||
@ -1,478 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 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)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "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()
|
||||
{
|
||||
// Reference:
|
||||
// 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)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "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)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "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,155 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 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
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class distribution;
|
||||
|
||||
Ostream& operator<<(Ostream&, const distribution&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
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);
|
||||
|
||||
//- Copy constructor
|
||||
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 | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 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,9 +0,0 @@
|
||||
reducedUnits/reducedUnits.C
|
||||
reducedUnits/reducedUnitsIO.C
|
||||
|
||||
molecule/molecule.C
|
||||
molecule/moleculeIO.C
|
||||
|
||||
moleculeCloud/moleculeCloud.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libmolecule
|
||||
@ -1,13 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/potential/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/molecularDynamics/molecularMeasurements/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lmeshTools \
|
||||
-llagrangian \
|
||||
-lpotential \
|
||||
-lmolecularMeasurements
|
||||
@ -1,8 +0,0 @@
|
||||
#ifndef md_H
|
||||
#define md_H
|
||||
#include "potential.H"
|
||||
#include "moleculeCloud.H"
|
||||
#include "correlationFunction.H"
|
||||
#include "distribution.H"
|
||||
#include "reducedUnits.H"
|
||||
#endif
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -1,47 +0,0 @@
|
||||
potential = potential
|
||||
|
||||
$(potential)/potential.C
|
||||
|
||||
pairPotential = pairPotential
|
||||
|
||||
$(pairPotential)/pairPotentialList/pairPotentialList.C
|
||||
|
||||
$(pairPotential)/basic/pairPotential.C
|
||||
$(pairPotential)/basic/pairPotentialIO.C
|
||||
$(pairPotential)/basic/pairPotentialNew.C
|
||||
|
||||
$(pairPotential)/derived/lennardJones/lennardJones.C
|
||||
$(pairPotential)/derived/maitlandSmith/maitlandSmith.C
|
||||
$(pairPotential)/derived/azizChen/azizChen.C
|
||||
$(pairPotential)/derived/exponentialRepulsion/exponentialRepulsion.C
|
||||
$(pairPotential)/derived/coulomb/coulomb.C
|
||||
$(pairPotential)/derived/dampedCoulomb/dampedCoulomb.C
|
||||
$(pairPotential)/derived/noInteraction/noInteraction.C
|
||||
|
||||
energyScalingFunction = energyScalingFunction
|
||||
|
||||
$(energyScalingFunction)/basic/energyScalingFunction.C
|
||||
$(energyScalingFunction)/basic/energyScalingFunctionNew.C
|
||||
|
||||
$(energyScalingFunction)/derived/shifted/shifted.C
|
||||
$(energyScalingFunction)/derived/shiftedForce/shiftedForce.C
|
||||
$(energyScalingFunction)/derived/noScaling/noScaling.C
|
||||
$(energyScalingFunction)/derived/sigmoid/sigmoid.C
|
||||
$(energyScalingFunction)/derived/doubleSigmoid/doubleSigmoid.C
|
||||
|
||||
tetherPotential = tetherPotential
|
||||
|
||||
$(tetherPotential)/tetherPotentialList/tetherPotentialList.C
|
||||
|
||||
$(tetherPotential)/basic/tetherPotential.C
|
||||
$(tetherPotential)/basic/tetherPotentialNew.C
|
||||
|
||||
$(tetherPotential)/derived/harmonicSpring/harmonicSpring.C
|
||||
$(tetherPotential)/derived/restrainedHarmonicSpring/restrainedHarmonicSpring.C
|
||||
$(tetherPotential)/derived/pitchForkRing/pitchForkRing.C
|
||||
|
||||
electrostaticPotential = electrostaticPotential
|
||||
|
||||
$(electrostaticPotential)/electrostaticPotential.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libpotential
|
||||
@ -1,6 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I.. \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfiniteVolume
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
Reference in New Issue
Block a user