Lots of changes from Mark and my changes to ddtPhiCorr all mixed together

because I failed to work out how to merge Mark's stuff -- HELP!!!
This commit is contained in:
henry 2008-05-25 21:46:37 +01:00
parent a016fa314e
commit 4a2a23a710
60 changed files with 938 additions and 410 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
set -x
(cd solvers ; wmake all)
(cd utilities ; wmake all)
( cd solvers && wmake all )
( cd utilities && wmake all )

View File

@ -56,32 +56,35 @@ int main(int argc, char *argv[])
{
# include "readControls.H"
# include "CourantNo.H"
p.storePrevIter();
// Make the fluxes absolute
fvc::makeAbsolute(phi, U);
# include "setDeltaT.H"
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
bool meshChanged = mesh.update();
// Make the fluxes absolute
if (mesh.changing())
{
phi = fvc::interpolate(U) & mesh.Sf();
}
if (correctPhi && meshChanged)
mesh.update();
if (mesh.changing() && correctPhi)
{
# include "correctPhi.H"
}
// Keep the absolute fluxes for use in ddtPhiCorr
surfaceScalarField phiAbs("phiAbs", phi);
surfaceScalarField phiAbs0("phiAbs0", phi);
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
if (mesh.changing())
{
fvc::makeRelative(phi, U);
}
if (meshChanged && checkMeshCourantNo)
if (mesh.changing() && checkMeshCourantNo)
{
# include "meshCourantNo.H"
}
@ -89,6 +92,8 @@ int main(int argc, char *argv[])
// --- PIMPLE loop
for (int ocorr=0; ocorr<nOuterCorr; ocorr++)
{
p.storePrevIter();
# include "UEqn.H"
// --- PISO loop
@ -101,10 +106,50 @@ int main(int argc, char *argv[])
if (ddtPhiCorr)
{
phi += fvc::ddtPhiCorr(rAU, U, phiAbs);
if (mesh.changing())
{
dimensionedScalar rDeltaT = 1.0/mesh.time().deltaT();
volScalarField V0byV
(
IOobject
(
"V0byV",
mesh.time().timeName(),
mesh
),
mesh,
dimensionedScalar("V0byV", dimless, 1),
zeroGradientFvPatchScalarField::typeName
);
V0byV.dimensionedInternalField() = mesh.V0()/mesh.V();
V0byV.correctBoundaryConditions();
phi += rDeltaT*
(
fvc::interpolate(rAU*V0byV)*phiAbs0
- (fvc::interpolate(rAU*V0byV*U.oldTime()) & mesh.Sf())
);
}
else
{
phi += fvc::ddtPhiCorr(rAU, U, phiAbs0);
}
}
adjustPhi(phi, U, p);
if (p.needReference())
{
if (mesh.changing())
{
fvc::makeRelative(phi, U);
adjustPhi(phi, U, p);
fvc::makeAbsolute(phi, U);
}
else
{
adjustPhi(phi, U, p);
}
}
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
@ -138,11 +183,11 @@ int main(int argc, char *argv[])
p.relax();
}
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
U -= rAU*fvc::grad(p);
U.correctBoundaryConditions();
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
}
}

View File

@ -41,6 +41,7 @@ Description
#include "twoPhaseMixture.H"
#include "incompressible/turbulenceModel/turbulenceModel.H"
#include "probes.H"
#include "EulerDdtScheme.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -66,7 +67,6 @@ int main(int argc, char *argv[])
{
#include "readControls.H"
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
@ -76,7 +76,7 @@ int main(int argc, char *argv[])
// Make the fluxes absolute
if (mesh.changing())
{
fvc::makeAbsolute(phi, U);
phi = fvc::interpolate(U) & mesh.Sf();
}
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
@ -100,7 +100,7 @@ int main(int argc, char *argv[])
}
// Keep the absolute fluxes for use in ddtPhiCorr
surfaceScalarField phiAbs("phiAbs", phi);
surfaceScalarField phiAbs0("phiAbs0", phi);
// Make the fluxes relative to the mesh motion
if (mesh.changing())
@ -125,8 +125,6 @@ int main(int argc, char *argv[])
#include "pEqn.H"
}
#include "continuityErrs.H"
p = pd + rho*gh;
if (pd.needReference())

View File

@ -2,21 +2,42 @@
volScalarField rAU = 1.0/UEqn.A();
surfaceScalarField rAUf = fvc::interpolate(rAU);
volVectorField HU = UEqn.H();
U = rAU*HU;
U = rAU*UEqn.H();
surfaceScalarField phiU("phiU", (fvc::interpolate(U) & mesh.Sf()));
if (ddtPhiCorr)
{
phiU += fvc::ddtPhiCorr(rAU, rho, U, phiAbs);
//phiU += fvc::ddtPhiCorr(rAU, rho, U, phiAbs0);
dimensionedScalar rDeltaT = 1.0/mesh.time().deltaT();
volScalarField V0byV
(
IOobject
(
"V0byV",
mesh.time().timeName(),
mesh
),
mesh,
dimensionedScalar("V0byV", dimless, 1),
zeroGradientFvPatchScalarField::typeName
);
V0byV.dimensionedInternalField() = mesh.V0()/mesh.V();
V0byV.correctBoundaryConditions();
phiU += rDeltaT*
(
fvc::interpolate(rAU*rho.oldTime()*V0byV)*phiAbs0
- (fvc::interpolate(rAU*rho.oldTime()*V0byV*U.oldTime()) & mesh.Sf())
);
}
phi = phiU +
(
fvc::interpolate(interface.sigmaK())*fvc::snGrad(gamma)
- ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf();
(
fvc::interpolate(interface.sigmaK())*fvc::snGrad(gamma)
- ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf();
if (pd.needReference())
{
@ -59,6 +80,8 @@
U += rAU*fvc::reconstruct((phi - phiU)/rAUf);
U.correctBoundaryConditions();
#include "continuityErrs.H"
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
}

View File

@ -1,9 +1,9 @@
#!/bin/sh
set -x
# Some fun: prostar uses ccmio2.3, Star-ccm+ uses ccmio2.4
# compile cd-adapco's CCM library
wmake libso libccmio/libadf
wmake libso libccmio/libccmio
wmake libso libccmio/libcgns
(cd libccmio; wmake libso libadf)
(cd libccmio; wmake libso libccmio)
(cd libccmio; wmake libso libcgns)
(cd ccm26ToFoam; wmake)
wmake ccm26ToFoam

View File

@ -72,6 +72,7 @@ find -H $newDir \
! -type d -type f \
! -name "*~" \
-a ! -name ".*~" \
-a ! -name ".#*" \
-a ! -name "*.orig" \
-a ! -name "*.dep" \
-a ! -name "*.o" \
@ -83,10 +84,11 @@ find -H $newDir \
-a ! -name "log[0-9]*" \
| sed \
-e "\@$newDir/lib/@d" \
-e "\@$newDir/src/mico-[0-9.]*/platforms@d" \
-e "\@$newDir/src/mpich-[0-9.]*/platforms@d" \
-e "\@$newDir/src/mpich-[0-9.]*/lib@d" \
-e "\@$newDir/src/lam-[0-9.]*/platforms@d" \
-e "\@$newDir/src/other/mico-*/platforms@d" \
-e "\@$newDir/src/other/mpich-*/platforms@d" \
-e "\@$newDir/src/other/mpich-*/lib@d" \
-e "\@$newDir/src/other/lam-*/platforms@d" \
-e "\@$newDir/src/other/openmpi-*/platforms@d" \
-e '\@applications/bin/@d' \
-e '\@/t/@d' \
-e '\@Make[.A-Za-z]*/[^/]*/@d' \
@ -118,7 +120,7 @@ find -H $newDir \
done
)
# file fileCount
# file fileCount
fileCount=$(cat $tmpFile | wc -l)
echo "----------------------------------------------------------------------"
echo "pack $fileCount changed/new files"

View File

@ -86,10 +86,11 @@ find -H $packDir \
-a ! -name "so_locations" \
| sed \
-e "\@$packDir/lib/@d" \
-e "\@$packDir/src/mico-[0-9.]*/platforms@d" \
-e "\@$packDir/src/mpich-[0-9.]*/platforms@d" \
-e "\@$packDir/src/mpich-[0-9.]*/lib@d" \
-e "\@$packDir/src/lam-[0-9.]*/platforms@d" \
-e "\@$packDir/src/other/mico-*/platforms@d" \
-e "\@$packDir/src/other/mpich-*/platforms@d" \
-e "\@$packDir/src/other/mpich-*/lib@d" \
-e "\@$packDir/src/other/lam-*/platforms@d" \
-e "\@$packDir/src/other/openmpi-*/platforms@d" \
-e '\@applications/bin/@d' \
-e '\@/t/@d' \
-e '\@Make[.A-Za-z]*/[^/]*/@d' \

View File

@ -75,11 +75,11 @@ find -H $packDir \
-a ! -name "log[0-9]*" \
| sed \
-e "\@$packDir/lib/@d" \
-e "\@$packDir/src/other/mico-[0-9.]*/platforms@d" \
-e "\@$packDir/src/other/mpich-[0-9.]*/platforms@d" \
-e "\@$packDir/src/other/mpich-[0-9.]*/lib@d" \
-e "\@$packDir/src/other/lam-[0-9.]*/platforms@d" \
-e "\@$packDir/src/other/openmpi-[0-9.]*/platforms@d" \
-e "\@$packDir/src/other/mico-*/platforms@d" \
-e "\@$packDir/src/other/mpich-*/platforms@d" \
-e "\@$packDir/src/other/mpich-*/lib@d" \
-e "\@$packDir/src/other/lam-*/platforms@d" \
-e "\@$packDir/src/other/openmpi-*/platforms@d" \
-e '\@applications/bin/@d' \
-e '\@/t/@d' \
-e '\@Make[.A-Za-z]*/[^/]*/@d' \

View File

@ -33,33 +33,33 @@
Script=${0##*/}
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: $Script [-case dir]
* start paraview $ParaView_VERSION with the OpenFOAM libraries
USAGE
exit 1
exit 1
}
# parse options
if [ "$#" -gt 0 ]; then
case "$1" in
-h | -help)
usage
;;
-case)
shift
caseDir=$1
[ "$#" -ge 1 ] || usage "'-case' option requires an argument"
cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'"
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
case "$1" in
-h | -help)
usage
;;
-case)
shift
caseDir=$1
[ "$#" -ge 1 ] || usage "'-case' option requires an argument"
cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'"
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
fi
# get a sensible caseName
@ -67,41 +67,38 @@ caseName=${PWD##*/}
# parent directory for normal or parallel results
case "$caseName" in
processor*) parentDir=".." ;;
*) parentDir="." ;;
processor*) parentDir=".." ;;
*) parentDir="." ;;
esac
# check existence of essential files
for check in system/controlDict system/fvSchemes system/fvSolution
do
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
done
OpenFoamExt="foam"
# OpenFoamExt="OpenFOAM"
caseFile="$caseName.foam"
# caseFile="$caseName.OpenFOAM"
if [ "$ParaView_VERSION" = "3" ]; then
case "$ParaView_VERSION" in
2*)
# Clean up on termination and on Ctrl-C
trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch $caseFile
# check existence of essential files
for check in system/controlDict system/fvSchemes system/fvSolution
do
[ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'"
done
# since we are now in the cwd, %CASE% is '$PWD/$caseFile'
sed -e s@%CASE%@$PWD/$caseFile@g \
$WM_PROJECT_DIR/bin/paraFoam.pvs > paraFoam.pvs
touch $caseName.$OpenFoamExt
paraview --data=$caseName.$OpenFoamExt
rm $caseName.$OpenFoamExt 2>/dev/null
paraview paraFoam.pvs
;;
else
# since we are now in the cwd, FOAM_ROOT/FOAM_CASE is '$PWD'
sed -e s%FOAM_ROOT/FOAM_CASE%$PWD%g \
-e s%FOAM_CASE%$caseName%g $WM_PROJECT_DIR/bin/paraFoam.pvs > paraFoam.pvs
touch $caseName.$OpenFoamExt
paraview paraFoam.pvs
rm paraFoam.pvs $caseName.$OpenFoamExt 2>/dev/null
fi
*)
# Clean up on termination and on Ctrl-C
trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT
touch $caseFile
paraview --data=$caseFile
;;
esac
#------------------------------------------------------------------------------

View File

@ -41,18 +41,26 @@ export CMAKE_HOME=$WM_PROJECT_INST_DIR/$WM_ARCH/cmake-2.4.6
if [ -r $CMAKE_HOME ]; then
export PATH=$CMAKE_HOME/bin:$PATH
else
unset CMAKE_HOME
fi
export ParaView_VERSION=3
# export ParaView_VERSION="3.3-cvs"
export ParaView_VERSION=3.3
export ParaView_INST_DIR=$WM_PROJECT_INST_DIR/ParaView3.3-cvs
export ParaView_INST_DIR=$WM_PROJECT_INST_DIR/paraview-$ParaView_VERSION
export ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_OPTIONS
export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/bin:$ParaView_DIR/Utilities/VTKPythonWrapping
if [ "$PYTHONPATH" ]; then
export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/Utilities/VTKPythonWrapping
else
export PYTHONPATH=$ParaView_DIR/Utilities/VTKPythonWrapping
fi
if [ -r $ParaView_DIR ]; then
export PATH=$ParaView_DIR/bin:$PATH
export LD_LIBRARY_PATH=${ParaView_DIR}/bin:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=$ParaView_DIR/lib/paraview-$ParaView_VERSION:$LD_LIBRARY_PATH
export PV_PLUGIN_PATH=$FOAM_LIBBIN
fi

View File

@ -41,11 +41,14 @@ setenv CMAKE_HOME $WM_PROJECT_INST_DIR/$WM_ARCH/cmake-2.4.6
if ( -r $CMAKE_HOME ) then
set path=($CMAKE_HOME/bin $path)
else
unset CMAKE_HOME
endif
setenv ParaView_VERSION 3
# setenv ParaView_VERSION 3.3-cvs
setenv ParaView_VERSION 3.3
setenv ParaView_INST_DIR $WM_PROJECT_INST_DIR/ParaView3.3-cvs
export ParaView_INST_DIR=$WM_PROJECT_INST_DIR/paraview-$ParaView_VERSION
setenv ParaView_DIR $ParaView_INST_DIR/platforms/$WM_OPTIONS
if ($?PYTHONPATH) then
@ -56,7 +59,7 @@ endif
if ( -r $ParaView_INST_DIR ) then
set path=($ParaView_DIR/bin $path)
setenv LD_LIBRARY_PATH ${ParaView_DIR}/bin:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH $ParaView_DIR/lib/paraview-$ParaView_VERSION:$LD_LIBRARY_PATH
setenv PV_PLUGIN_PATH $FOAM_LIBBIN
endif

View File

@ -63,7 +63,7 @@ export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
# Compiler (if set to "" use the system compiler)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export WM_COMPILER=Gcc
export WM_COMPILER=Gcc43
export WM_COMPILER_ARCH=
export WM_COMPILER_LIB_ARCH=

View File

@ -97,7 +97,14 @@ WM_COMPILER_INST=OpenFOAM
case "$WM_COMPILER_INST" in
OpenFOAM)
export WM_COMPILER_DIR=$FOAM_INST_DIR/$WM_ARCH/gcc-4.2.2$WM_COMPILER_ARCH
case "$WM_COMPILER" in
Gcc43)
export WM_COMPILER_DIR=$FOAM_INST_DIR/$WM_ARCH/gcc-4.3.0$WM_COMPILER_ARCH
;;
Gcc)
export WM_COMPILER_DIR=$FOAM_INST_DIR/$WM_ARCH/gcc-4.2.2$WM_COMPILER_ARCH
;;
esac
# Check that the compiler directory can be found
if [ ! -d "$WM_COMPILER_DIR" ]

View File

@ -202,7 +202,12 @@ List<Key> HashTable<T, Key, Hash>::toc() const
template<class T, class Key, class Hash>
bool HashTable<T, Key, Hash>::insert(const Key& key, const T& newEntry)
bool HashTable<T, Key, Hash>::set
(
const Key& key,
const T& newEntry,
const bool protect
)
{
if (tableSize_ == 0)
{
@ -210,40 +215,70 @@ bool HashTable<T, Key, Hash>::insert(const Key& key, const T& newEntry)
}
label ii = Hash()(key, tableSize_);
hashedEntry* existing = 0;
hashedEntry* prev = 0;
for (hashedEntry* n=table_[ii]; n; n=n->next_)
for (hashedEntry* curr = table_[ii]; curr; curr = curr->next_)
{
if (key == n->key_)
if (key == curr->key_)
{
existing = curr;
break;
}
prev = curr;
}
// not found, insert it at the head
if (!existing)
{
table_[ii] = new hashedEntry(key, table_[ii], newEntry);
nElmts_++;
if (double(nElmts_)/tableSize_ > 0.8)
{
# ifdef FULLDEBUG
if (debug)
{
Info<< "HashTable<T, Key, Hash>::insert"
"(const Key& key, T newEntry) : "
"Cannot insert " << key << " already in hash table\n";
Info<< "HashTable<T, Key, Hash>::set"
"(const Key& key, T newEntry) : "
"Doubling table size\n";
}
# endif
return false;
resize(2*tableSize_);
}
}
table_[ii] = new hashedEntry(key, table_[ii], newEntry);
nElmts_++;
if (double(nElmts_)/tableSize_ > 0.8)
else if (protect)
{
// found - but protected from overwriting
// this corresponds to the STL 'insert' convention
# ifdef FULLDEBUG
if (debug)
{
Info<< "HashTable<T, Key, Hash>::insert"
"(const Key& key, T newEntry) : "
"Doubling table size\n";
Info<< "HashTable<T, Key, Hash>::set"
"(const Key& key, T newEntry, false) : "
"Cannot insert " << key << " already in hash table\n";
}
# endif
return false;
}
else
{
// found - overwrite existing entry
// this corresponds to the Perl convention
hashedEntry* elemPtr = new hashedEntry(key, existing->next_, newEntry);
resize(2*tableSize_);
// replace existing element - within list or insert at the head
if (prev)
{
prev->next_ = elemPtr;
}
else
{
table_[ii] = elemPtr;
}
delete existing;
}
return true;

View File

@ -123,6 +123,11 @@ class HashTable
label nElmts_;
// Private Member Functions
//- Assign a new hashedEntry to a possibly already existing key
bool set(const Key& key, const T& newElmt, bool protect);
public:
//- Declare friendship with the HashPtrTable class
@ -181,7 +186,10 @@ public:
// Edit
//- Insert a new hashedEntry
bool insert(const Key& key, const T& newElmt);
inline bool insert(const Key& key, const T& newElmt);
//- Assign a new hashedEntry, overwriting existing entries
inline bool set(const Key& key, const T& newElmt);
//- Erase an hashedEntry specified by given iterator
bool erase(const iterator& it);

View File

@ -56,6 +56,19 @@ inline label HashTable<T, Key, Hash>::size() const
}
template<class T, class Key, class Hash>
inline bool HashTable<T, Key, Hash>::insert(const Key& key, const T& newEntry)
{
return set(key, newEntry, true);
}
template<class T, class Key, class Hash>
inline bool HashTable<T, Key, Hash>::set(const Key& key, const T& newEntry)
{
return set(key, newEntry, false);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T, class Key, class Hash>
@ -292,7 +305,7 @@ inline HashTable<T, Key, Hash>::const_iterator::const_iterator
template<class T, class Key, class Hash>
inline HashTable<T, Key, Hash>::const_iterator::const_iterator
(
(
const iterator& iter
)
:

View File

@ -229,6 +229,43 @@ DLListBase::link* DLListBase::remove(DLListBase::link* l)
}
DLListBase::link* DLListBase::replace
(
DLListBase::link* oldLink,
DLListBase::link* newLink
)
{
link* ret = oldLink;
newLink->prev_ = oldLink->prev_;
newLink->next_ = oldLink->next_;
if (oldLink == first_ && first_ == last_)
{
first_ = newLink;
last_ = newLink;
}
else if (oldLink == first_)
{
first_ = newLink;
newLink->next_->prev_ = newLink;
}
else if (oldLink == last_)
{
last_ = newLink;
newLink->prev_->next_ = newLink;
}
else
{
newLink->prev_->next_ = newLink;
newLink->next_->prev_ = newLink;
}
ret->deregister();
return ret;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -158,6 +158,12 @@ public:
// Remove and return element specified by iterator
inline link* remove(iterator&);
//- Replace oldLink with newLink and return element
link* replace(link* oldLink, link* newLink);
//- Replace oldIter with newLink and return element
inline link* replace(iterator& oldIter, link* newLink);
//- Clear the list
inline void clear();

View File

@ -148,6 +148,16 @@ inline DLListBase::link* DLListBase::remove(DLListBase::iterator& it)
}
inline DLListBase::link* DLListBase::replace
(
DLListBase::iterator& oldIter,
DLListBase::link* newLink
)
{
return replace(oldIter.curElmt_, newLink);
}
// * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * * //
inline DLListBase::iterator::iterator(DLListBase& s, link* elmt)

View File

@ -435,6 +435,20 @@ void sort(List<T>& a, const Cmp& cmp)
}
template<class T>
void stableSort(List<T>& a)
{
std::stable_sort(a.begin(), a.end());
}
template<class T, class Cmp>
void stableSort(List<T>& a, const Cmp& cmp)
{
std::stable_sort(a.begin(), a.end(), cmp);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// Assignment to UList operator. Takes linear time.

View File

@ -28,7 +28,7 @@ Class
Description
A 1D array of objects of type \<T\>, where the size of the vector
is known and used for subscript bounds checking, etc.
Storage is allocated on free-store during construction.
SourceFiles
@ -195,6 +195,12 @@ void sort(List<T>& a);
template<class T, class Cmp>
void sort(List<T>& a, const Cmp&);
template<class T>
void stableSort(List<T>& a);
template<class T, class Cmp>
void stableSort(List<T>& a, const Cmp&);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -28,14 +28,11 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from List
template <class Type>
SortableList<Type>::SortableList(const List<Type>& values)
Foam::SortableList<Type>::SortableList(const List<Type>& values)
:
List<Type>(values),
indices_(values.size())
@ -46,7 +43,7 @@ SortableList<Type>::SortableList(const List<Type>& values)
// Construct given size. Sort later on.
template <class Type>
SortableList<Type>::SortableList(const label size)
Foam::SortableList<Type>::SortableList(const label size)
:
List<Type>(size),
indices_(size)
@ -55,7 +52,7 @@ SortableList<Type>::SortableList(const label size)
// Construct given size and initial value. Sort later on.
template <class Type>
SortableList<Type>::SortableList(const label size, const Type& val)
Foam::SortableList<Type>::SortableList(const label size, const Type& val)
:
List<Type>(size, val),
indices_(size)
@ -64,7 +61,7 @@ SortableList<Type>::SortableList(const label size, const Type& val)
// Construct as copy.
template <class Type>
SortableList<Type>::SortableList(const SortableList<Type>& lst)
Foam::SortableList<Type>::SortableList(const SortableList<Type>& lst)
:
List<Type>(lst),
indices_(lst.indices())
@ -74,7 +71,7 @@ SortableList<Type>::SortableList(const SortableList<Type>& lst)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template <class Type>
void SortableList<Type>::setSize(const label newSize)
void Foam::SortableList<Type>::setSize(const label newSize)
{
List<Type>::setSize(newSize);
indices_.setSize(newSize);
@ -82,7 +79,7 @@ void SortableList<Type>::setSize(const label newSize)
template <class Type>
void SortableList<Type>::sort()
void Foam::SortableList<Type>::sort()
{
forAll(indices_, i)
{
@ -98,7 +95,29 @@ void SortableList<Type>::sort()
tmpValues[i] = this->operator[](indices_[i]);
}
List<Type>::operator=(tmpValues);
List<Type>::transfer(tmpValues);
}
template <class Type>
void Foam::SortableList<Type>::stableSort()
{
forAll(indices_, i)
{
indices_[i] = i;
}
Foam::stableSort(indices_, less(*this));
List<Type> tmpValues(this->size());
forAll(indices_, i)
{
tmpValues[i] = this->operator[](indices_[i]);
}
List<Type>::transfer(tmpValues);
}
@ -114,6 +133,4 @@ void Foam::SortableList<Type>::operator=(const SortableList<Type>& rhs)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -100,7 +100,7 @@ public:
// Member Functions
//- Return the list of sorted point indices. Updated every sort.
//- Return the list of sorted indices. Updated every sort.
const labelList& indices() const
{
return indices_;
@ -112,6 +112,9 @@ public:
//- Sort the list (if changed after construction time)
void sort();
//- Sort the list (if changed after construction time)
void stableSort();
// Member Operators

View File

@ -34,6 +34,7 @@ defineTypeNameAndDebug(Foam::dictionary, 0);
const Foam::dictionary Foam::dictionary::null;
#undef DICTIONARY_INPLACE_MERGE
// * * * * * * * * * * * * * Private member functions * * * * * * * * * * * //
@ -53,7 +54,27 @@ bool Foam::dictionary::add(entry* ePtr, bool mergeEntry)
}
else
{
#ifdef DICTIONARY_INPLACE_MERGE
if (hashedEntries_.set(ePtr->keyword(), ePtr))
{
ePtr->name() = name_ + "::" + ePtr->keyword();
replace(iter(), ePtr);
return true;
}
else
{
IOWarningIn("dictionary::add(entry* ePtr)", (*this))
<< "problem replacing entry in dictionary "
<< name()
<< endl;
delete ePtr;
return false;
}
#else
remove(ePtr->keyword());
#endif
}
}
@ -517,8 +538,12 @@ bool Foam::dictionary::merge(const dictionary& dict)
}
else
{
#ifdef DICTIONARY_INPLACE_MERGE
add(iter().clone(*this).ptr(), true);
#else
remove(keyword);
add(iter().clone(*this)());
#endif
changed = true;
}
}
@ -526,6 +551,7 @@ bool Foam::dictionary::merge(const dictionary& dict)
{
// not found - just add
add(iter().clone(*this)());
changed = true;
}
}

View File

@ -119,6 +119,12 @@ public:
//- Return edge line
inline linePointRef line(const pointField&) const;
//- compare edges
// - 0: different
// - +1: identical
// - -1: same edge, but different orientation
static inline int compare(const edge&, const edge&);
// Friend Operators
@ -127,7 +133,7 @@ public:
};
//- Hash<edge> specialisation
//- Hash<edge> specialisation
// Simple commutative hash.
template<>
inline label Hash<edge>::operator()(const edge& e) const

View File

@ -26,6 +26,30 @@ License
#include "IOstreams.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
// return
// - 0: different
// - +1: identical
// - -1: same edge, but different orientation
inline int Foam::edge::compare(const edge& a, const edge& b)
{
if (a[0] == b[0] && a[1] == b[1])
{
return 1;
}
else if (a[0] == b[1] && a[1] == b[0])
{
return -1;
}
else
{
return 0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::edge::edge()
@ -146,17 +170,13 @@ inline Foam::linePointRef Foam::edge::line(const pointField& p) const
inline bool Foam::operator==(const edge& a, const edge& b)
{
return
(
(a[0] == b[0] && a[1] == b[1])
|| (a[0] == b[1] && a[1] == b[0])
);
return edge::compare(a,b) != 0;
}
inline bool Foam::operator!=(const edge& a, const edge& b)
{
return !(a == b);
return edge::compare(a,b) == 0;
}

View File

@ -438,7 +438,7 @@ int Foam::face::compare(const face& a, const face& b)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::face::collapse()
Foam::label Foam::face::collapse()
{
if (size() > 1)
{
@ -458,6 +458,8 @@ void Foam::face::collapse()
setSize(ci);
}
return size();
}
@ -696,6 +698,47 @@ Foam::edgeList Foam::face::edges() const
}
int Foam::face::edgeDirection(const edge& e) const
{
if (size() > 2)
{
edge found(-1,-1);
// find start/end points - this breaks down for degenerate faces
forAll (*this, i)
{
if (operator[](i) == e.start())
{
found.start() = i;
}
else if (operator[](i) == e.end())
{
found.end() = i;
}
}
label diff = found.end() - found.start();
if (!diff || found.start() < 0 || found.end() < 0)
{
return 0;
}
// forward direction
if (diff == 1 || diff == 1 - size())
{
return 1;
}
// reverse direction
if (diff == -1 || diff == -1 + size())
{
return -1;
}
}
return 0;
}
// Number of triangles directly known from number of vertices
Foam::label Foam::face::nTriangles
(

View File

@ -145,7 +145,8 @@ public:
// Member Functions
//- Collapse face by removing duplicate point labels
void collapse();
// return the collapsed size
label collapse();
//- Return the points corresponding to this face
inline pointField points(const pointField& meshPoints) const;
@ -251,6 +252,11 @@ public:
//- Return n-th face edge
inline edge faceEdge(const label n) const;
//- Return the edge direction on the face
// - 0: edge not found on the face
// - +1: forward (counter-clockwise) on the face
// - -1: reverse (clockwise) on the face
int edgeDirection(const edge&) const;
// Face splitting utilities

View File

@ -81,18 +81,35 @@ public:
const label c
);
//- Construct from a face, discarding excess points
inline triFace(const face&);
//- Construct from a labelList, discarding excess points
explicit inline triFace(const labelList&);
//- Construct from Istream
inline triFace(Istream&);
// Member Functions
//- Collapse face by removing duplicate point labels
// return the collapsed size, set collapsed point labels to -1
inline label collapse();
//- Return the edge direction on the face
// - +1: forward (counter-clockwise) on the face
// - -1: reverse (clockwise) on the face
// - 0: edge not found on the face
inline int edgeDirection(const edge&) const;
// Properties
//- Return the points corresponding to this face
inline pointField points(const pointField& points) const;
//- Return triagle as a face
//- Return triangle as a face
inline face triFaceFace() const;
//- Return number of edges
@ -128,9 +145,14 @@ public:
const intersection::direction dir = intersection::VECTOR
) const;
//- Return the tetrahedron
//- Return the triangle
inline triPointRef tri(const pointField&) const;
//- compare triFaces
// - 0: different
// - +1: identical
// - -1: same face, but different orientation
static inline int compare(const triFace&, const triFace&);
// Friend Operators
@ -139,7 +161,7 @@ public:
};
//- Hash<triFace> specialisation
//- Hash<triFace> specialisation
// Simple commutative hash.
template<>
inline label Hash<triFace>::operator()(const triFace& t) const

View File

@ -33,14 +33,45 @@ License
namespace Foam
{
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
inline int triFace::compare(const triFace& a, const triFace& b)
{
if
(
(a[0] == b[0] && a[1] == b[1] && a[2] == b[2])
|| (a[0] == b[1] && a[1] == b[2] && a[2] == b[0])
|| (a[0] == b[2] && a[1] == b[0] && a[2] == b[1])
)
{
// identical
return 1;
}
else if
(
(a[0] == b[2] && a[1] == b[1] && a[2] == b[0])
|| (a[0] == b[1] && a[1] == b[0] && a[2] == b[2])
|| (a[0] == b[0] && a[1] == b[2] && a[2] == b[1])
)
{
// same face, but reversed orientation
return -1;
}
else
{
return 0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct null
// Construct null
inline triFace::triFace()
{}
//- Construct from components
// Construct from components
inline triFace::triFace
(
const label a,
@ -53,6 +84,18 @@ inline triFace::triFace
operator[](2) = c;
}
// Construct from a face
inline triFace::triFace(const face& f)
:
FixedList<label, 3>(SubList<label>(f,3))
{}
// Construct from a labelList
inline triFace::triFace(const labelList& l)
:
FixedList<label, 3>(SubList<label>(l,3))
{}
inline triFace::triFace(Istream& is)
:
@ -62,6 +105,34 @@ inline triFace::triFace(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::label Foam::triFace::collapse()
{
// we cannot resize a FixedList, so mark duplicates with '-1'
// (the lower vertex is retained)
// catch any '-1' - ie, if called twice
label n = 3;
if (operator[](0) == operator[](1) || operator[](1) == -1)
{
operator[](1) = -1;
n--;
}
else if (operator[](1) == operator[](2) || operator[](2) == -1)
{
operator[](2) = -1;
n--;
}
if (operator[](0) == operator[](2))
{
operator[](2) = -1;
n--;
}
return n;
}
// Return the points associated with this face
inline pointField triFace::points(const pointField& points) const
{
@ -111,6 +182,37 @@ inline edgeList triFace::edges() const
}
// return
// - +1: forward (counter-clockwise) on the face
// - -1: reverse (clockwise) on the face
// - 0: edge not found on the face
inline int triFace::edgeDirection(const edge& e) const
{
if
(
(operator[](0) == e.start() && operator[](1) == e.end())
|| (operator[](1) == e.start() && operator[](2) == e.end())
|| (operator[](2) == e.start() && operator[](0) == e.end())
)
{
return 1;
}
else if
(
(operator[](0) == e.end() && operator[](1) == e.start())
|| (operator[](1) == e.end() && operator[](2) == e.start())
|| (operator[](2) == e.end() && operator[](0) == e.start())
)
{
return -1;
}
else
{
return 0;
}
}
inline point triFace::centre(const pointField& points) const
{
return (1.0/3.0)*
@ -202,23 +304,15 @@ inline triPointRef triFace::tri(const pointField& points) const
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
inline bool operator==(const triFace& tf1, const triFace& tf2)
inline bool operator==(const triFace& a, const triFace& b)
{
return
(
(tf1[0] == tf2[0] && tf1[1] == tf2[1] && tf1[2] == tf2[2])
|| (tf1[0] == tf2[1] && tf1[1] == tf2[2] && tf1[2] == tf2[0])
|| (tf1[0] == tf2[2] && tf1[1] == tf2[0] && tf1[2] == tf2[1])
|| (tf1[0] == tf2[2] && tf1[1] == tf2[1] && tf1[2] == tf2[0])
|| (tf1[0] == tf2[1] && tf1[1] == tf2[0] && tf1[2] == tf2[2])
|| (tf1[0] == tf2[0] && tf1[1] == tf2[2] && tf1[2] == tf2[1])
);
return triFace::compare(a,b) != 0;
}
inline bool operator!=(const triFace& tf1, const triFace& tf2)
inline bool operator!=(const triFace& a, const triFace& b)
{
return !(tf1 == tf2);
return triFace::compare(a,b) == 0;
}

View File

@ -76,12 +76,12 @@ void ZoneMesh<ZoneType>::calcZoneMap() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Read constructor given IOobject and a polyMesh reference
// Read constructor given IOobject and a MeshType reference
template<class ZoneType>
ZoneMesh<ZoneType>::ZoneMesh
(
const IOobject& io,
const polyMesh& mesh
const MeshType& mesh
)
:
PtrList<ZoneType>(),
@ -122,7 +122,7 @@ ZoneMesh<ZoneType>::ZoneMesh
is.check
(
"ZoneMesh::ZoneMesh"
"(const IOobject&, const polyMesh&)"
"(const IOobject&, const MeshType&)"
);
close();
@ -140,7 +140,7 @@ template<class ZoneType>
ZoneMesh<ZoneType>::ZoneMesh
(
const IOobject& io,
const polyMesh& mesh,
const MeshType& mesh,
const label size
)
:
@ -175,8 +175,8 @@ const Map<label>& ZoneMesh<ZoneType>::zoneMap() const
}
// Given a global object index, return the zone it is in. If
//object does not belong to any zones, return -1
// Given a global object index, return the zone it is in.
// If object does not belong to any zones, return -1
template<class ZoneType>
label ZoneMesh<ZoneType>::whichZone(const label objectIndex) const
{

View File

@ -69,8 +69,11 @@ class ZoneMesh
{
// Private data
//- Typedef in preparation of a second template parameter
typedef polyMesh MeshType;
//- Reference to mesh
const polyMesh& mesh_;
const MeshType& mesh_;
//- Map of zone labels for given element
mutable Map<label>* zoneMapPtr_;
@ -93,18 +96,18 @@ public:
// Constructors
//- Read constructor given IOobject and a polyMesh reference
//- Read constructor given IOobject and a MeshType reference
ZoneMesh
(
const IOobject&,
const polyMesh&
const MeshType&
);
//- Construct given size
ZoneMesh
(
const IOobject&,
const polyMesh&,
const MeshType&,
const label size
);
@ -116,7 +119,7 @@ public:
// Member functions
//- Return the mesh reference
const polyMesh& mesh() const
const MeshType& mesh() const
{
return mesh_;
}

View File

@ -84,11 +84,14 @@ public:
inline word();
//- Construct as copy
inline word(const word& w);
inline word(const word&);
//- Construct as copy of character array
inline word(const char*);
//- Construct as copy with a maximum number of characters
inline word(const char*, const size_type);
//- Construct as copy of string
inline word(const string&);
@ -96,7 +99,7 @@ public:
inline word(const std::string&);
//- Construct from Istream
word(Istream& is);
word(Istream&);
// Member functions

View File

@ -39,7 +39,7 @@ inline void Foam::word::stripInvalid()
std::cerr
<< "word::stripInvalid() called for word "
<< this->c_str() << std::endl;
if (debug > 1)
{
std::cerr
@ -65,25 +65,32 @@ inline Foam::word::word()
{}
inline Foam::word::word(const string& str)
inline Foam::word::word(const string& s)
:
string(str)
string(s)
{
stripInvalid();
}
inline Foam::word::word(const std::string& stdStr)
inline Foam::word::word(const std::string& s)
:
string(stdStr)
string(s)
{
stripInvalid();
}
inline Foam::word::word(const char* chars)
inline Foam::word::word(const char* s)
:
string(chars)
string(s)
{
stripInvalid();
}
inline Foam::word::word(const char* s, const size_type n)
:
string(s, n)
{
stripInvalid();
}

View File

@ -27,21 +27,35 @@ License
#include "engineTime.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
namespace Foam
void Foam::engineTime::timeAdjustment()
{
deltaT_ = degToTime(deltaT_);
endTime_ = degToTime(endTime_);
if
(
writeControl_ == wcRunTime
|| writeControl_ == wcAdjustableRunTime
)
{
writeInterval_ = degToTime(writeInterval_);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct from objectRegistry arguments
engineTime::engineTime
Foam::engineTime::engineTime
(
const word& name,
const fileName& rootPath,
const fileName& caseName,
const fileName& systemName,
const fileName& constantName
const fileName& constantName,
const fileName& dictName
)
:
Time
@ -52,7 +66,7 @@ engineTime::engineTime
systemName,
constantName
),
engineGeometry_
dict_
(
IOobject
(
@ -64,78 +78,84 @@ engineTime::engineTime
false
)
),
conRodLength_(engineGeometry_.lookup("conRodLength")),
bore_(engineGeometry_.lookup("bore")),
stroke_(engineGeometry_.lookup("stroke")),
clearance_(engineGeometry_.lookup("clearance")),
rpm_(engineGeometry_.lookup("rpm"))
rpm_(dict_.lookup("rpm")),
conRodLength_(dimensionedScalar("conRodLength", dimLength, 0)),
bore_(dimensionedScalar("bore", dimLength, 0)),
stroke_(dimensionedScalar("stroke", dimLength, 0)),
clearance_(dimensionedScalar("clearance", dimLength, 0))
{
value() = degToTime(value());
// the geometric parameters are not strictly required for Time
if (dict_.found("conRodLength"))
{
dict_.lookup("conRodLength") >> conRodLength_;
}
if (dict_.found("bore"))
{
dict_.lookup("bore") >> bore_;
}
if (dict_.found("stroke"))
{
dict_.lookup("stroke") >> stroke_;
}
if (dict_.found("clearance"))
{
dict_.lookup("clearance") >> clearance_;
}
timeAdjustment();
startTime_ = degToTime(startTime_);
endTime_ = degToTime(endTime_);
deltaT_ = degToTime(deltaT_);
deltaT0_ = deltaT_;
if
(
writeControl_ == wcRunTime
|| writeControl_ == wcAdjustableRunTime
)
{
writeInterval_ = degToTime(writeInterval_);
}
value() = degToTime(value());
deltaT0_ = deltaT_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Read the controlDict and set all the parameters
bool engineTime::read()
void Foam::engineTime::readDict()
{
if (!Time::read())
Time::readDict();
timeAdjustment();
}
// Read the controlDict and set all the parameters
bool Foam::engineTime::read()
{
if (Time::read())
{
return false;
timeAdjustment();
return true;
}
else
{
deltaT_ = degToTime(deltaT_);
endTime_ = degToTime(endTime_);
if
(
writeControl_ == wcRunTime
|| writeControl_ == wcAdjustableRunTime
)
{
writeInterval_ = degToTime(writeInterval_);
}
return true;
return false;
}
}
scalar engineTime::degToRad(const scalar deg) const
Foam::scalar Foam::engineTime::degToRad(const scalar deg) const
{
return mathematicalConstant::pi*deg/180.0;
}
scalar engineTime::degToTime(const scalar theta) const
Foam::scalar Foam::engineTime::degToTime(const scalar theta) const
{
return theta/(360.0*rpm_.value()/60.0);
// 6 * rpm => deg/s
return theta/(6.0*rpm_.value());
}
scalar engineTime::timeToDeg(const scalar t) const
Foam::scalar Foam::engineTime::timeToDeg(const scalar t) const
{
return t*(360.0*rpm_.value()/60.0);
// 6 * rpm => deg/s
return t*(6.0*rpm_.value());
}
scalar engineTime::theta() const
Foam::scalar Foam::engineTime::theta() const
{
return timeToDeg(value());
}
@ -143,7 +163,7 @@ scalar engineTime::theta() const
// Return current crank-angle translated to a single revolution
// (value between -180 and 180 with 0 = top dead centre)
scalar engineTime::thetaRevolution() const
Foam::scalar Foam::engineTime::thetaRevolution() const
{
scalar t = theta();
@ -161,13 +181,13 @@ scalar engineTime::thetaRevolution() const
}
scalar engineTime::deltaTheta() const
Foam::scalar Foam::engineTime::deltaTheta() const
{
return timeToDeg(deltaT().value());
}
scalar engineTime::pistonPosition(const scalar theta) const
Foam::scalar Foam::engineTime::pistonPosition(const scalar theta) const
{
return
(
@ -186,7 +206,7 @@ scalar engineTime::pistonPosition(const scalar theta) const
}
dimensionedScalar engineTime::pistonPosition() const
Foam::dimensionedScalar Foam::engineTime::pistonPosition() const
{
return dimensionedScalar
(
@ -197,7 +217,7 @@ dimensionedScalar engineTime::pistonPosition() const
}
dimensionedScalar engineTime::pistonDisplacement() const
Foam::dimensionedScalar Foam::engineTime::pistonDisplacement() const
{
return dimensionedScalar
(
@ -208,24 +228,24 @@ dimensionedScalar engineTime::pistonDisplacement() const
}
dimensionedScalar engineTime::pistonSpeed() const
Foam::dimensionedScalar Foam::engineTime::pistonSpeed() const
{
return dimensionedScalar
(
"pistonSpeed",
dimLength/dimTime,
dimVelocity,
pistonDisplacement().value()/(deltaT().value() + VSMALL)
);
}
scalar engineTime::userTimeToTime(const scalar theta) const
Foam::scalar Foam::engineTime::userTimeToTime(const scalar theta) const
{
return degToTime(theta);
}
scalar engineTime::timeToUserTime(const scalar t) const
Foam::scalar Foam::engineTime::timeToUserTime(const scalar t) const
{
return timeToDeg(t);
}
@ -233,6 +253,4 @@ scalar engineTime::timeToUserTime(const scalar t) const
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -26,7 +26,25 @@ Class
Foam::engineTime
Description
Foam::engineTime
Manage time in terms of engine RPM and crank-angle.
When engineTime is in effect, the userTime is reported in degrees
crank-angle instead of in seconds. The RPM to be used is specified in
@c constant/engineGeometry. If only a time conversion is required,
the geometric engine parameters can be dropped or set to zero.
For example,
@verbatim
rpm rpm [0 0 -1 0 0] 2000;
conRodLength conRodLength [0 1 0 0 0] 0.0;
bore bore [0 1 0 0 0] 0.0;
stroke stroke [0 1 0 0 0] 0.0;
clearance clearance [0 1 0 0 0] 0.0;
@endverbatim
Note
The engineTime can currently only be selected at compile-time.
SourceFiles
engineTime.C
@ -46,7 +64,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class engineTime Declaration
Class engineTime Declaration
\*---------------------------------------------------------------------------*/
class engineTime
@ -55,13 +73,16 @@ class engineTime
{
// Private data
IOdictionary engineGeometry_;
IOdictionary dict_;
//- RPM is required
dimensionedScalar rpm_;
//- Optional engine geometry parameters
dimensionedScalar conRodLength_;
dimensionedScalar bore_;
dimensionedScalar stroke_;
dimensionedScalar clearance_;
dimensionedScalar rpm_;
// Private Member Functions
@ -72,6 +93,8 @@ class engineTime
//- Disallow default bitwise assignment
void operator=(const engineTime&);
//- adjust read time values
void timeAdjustment();
public:
@ -84,7 +107,8 @@ public:
const fileName& rootPath,
const fileName& caseName,
const fileName& systemName = "system",
const fileName& constantName = "constant"
const fileName& constantName = "constant",
const fileName& dictName = "engineGeometry"
);
// Destructor
@ -116,7 +140,13 @@ public:
//- Return the engine geometry dictionary
const dictionary& engineDict() const
{
return engineGeometry_;
return dict_;
}
//- Return the engines current operating RPM
const dimensionedScalar& rpm() const
{
return rpm_;
}
//- Return the engines connecting-rod length
@ -143,12 +173,6 @@ public:
return clearance_;
}
//- Return the engines current operating RPM
const dimensionedScalar& rpm() const
{
return rpm_;
}
//- Return current crank-angle
scalar theta() const;
@ -173,16 +197,19 @@ public:
// Member functions overriding the virtual functions in time
//- Convert the user-time (CA deg) to real-time (s).
scalar userTimeToTime(const scalar theta) const;
virtual scalar userTimeToTime(const scalar theta) const;
//- Convert the real-time (s) into user-time (CA deg)
scalar timeToUserTime(const scalar t) const;
virtual scalar timeToUserTime(const scalar t) const;
//- Read the control dictionary and set the write controls etc.
virtual void readDict();
// Edit
//- Read the controlDict and set all the parameters
bool read();
virtual bool read();
};

View File

@ -471,8 +471,8 @@ EulerDdtScheme<Type>::fvcDdtPhiCorr
(
rA*rho.oldTime()*U.oldTime()
) & mesh().Sf()
)
)
)
)
)
);
}

0
src/lagrangian/basic/Make/files Executable file → Normal file
View File

0
src/lagrangian/basic/Make/options Executable file → Normal file
View File

0
src/lagrangian/dieselSpray/Make/files Executable file → Normal file
View File

0
src/lagrangian/dieselSpray/Make/options Executable file → Normal file
View File

View File

@ -38,21 +38,20 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineParticleTypeNameAndDebug(parcel, 0);
defineTemplateTypeNameAndDebug(Cloud<parcel>, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
parcel::parcel
Foam::parcel::parcel
(
const Cloud<parcel>& cloud,
const vector& position,
const label celli,
const label cellI,
const vector& n,
const scalar d,
const scalar T,
@ -67,14 +66,13 @@ parcel::parcel
const vector& U,
const vector& Uturb,
const scalarField& X,
const List<word>& fuelNames
const List<word>& liquidNames
)
:
Particle<parcel>(cloud, position, celli),
fuelNames_
Particle<parcel>(cloud, position, cellI),
liquidComponents_
(
fuelNames
liquidNames
),
d_(d),
T_(T),
@ -96,7 +94,7 @@ parcel::parcel
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool parcel::move(spray& sDB)
bool Foam::parcel::move(spray& sDB)
{
const polyMesh& mesh = cloud().pMesh();
const polyBoundaryMesh& pbMesh = mesh.boundaryMesh();
@ -329,7 +327,7 @@ bool parcel::move(spray& sDB)
}
void parcel::updateParcelProperties
void Foam::parcel::updateParcelProperties
(
const scalar dt,
spray& sDB,
@ -638,18 +636,16 @@ void parcel::updateParcelProperties
}
void parcel::transformProperties(const tensor& T)
void Foam::parcel::transformProperties(const tensor& T)
{
U_ = transform(T, U_);
}
void parcel::transformProperties(const vector&)
void Foam::parcel::transformProperties(const vector&)
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -54,7 +54,7 @@ class parcel
// Private member data
// Reference to the names of the liquid components
List<word> fuelNames_;
List<word> liquidComponents_;
// Defining data (read and written to field files)
@ -85,7 +85,7 @@ class parcel
//- Part of liquid core (1-fully liquid, 0-droplet)
scalar liquidCore_;
//- injected from injector
//- injected from injector
// Should really be a label, but is scalar due to
// post-processing reasons
scalar injector_;
@ -100,7 +100,7 @@ class parcel
// in which the particle moves
vector n_;
//- Liquid fuel molar fractions
//- Liquid components molar fractions
scalarField X_;
// Derived state information (not read or written)
@ -166,7 +166,7 @@ public:
const vector& U,
const vector& Uturb,
const scalarField& X,
const List<word>& fuelNames
const List<word>& liquidNames
);
//- Construct from Istream reading field values if required
@ -182,7 +182,10 @@ public:
// Access
//- Return the names of the liquid fuel components
//- Return the names of the liquid components
inline const List<word>& liquidNames() const;
//- Return the names of the liquid fuel components - identical with liquidNames
inline const List<word>& fuelNames() const;
//- Return diameter of droplets in parcel
@ -265,10 +268,10 @@ public:
//- Return the normal used for 2D purposes
inline vector& n();
//- Return the liquid fuel molar fractions
//- Return the liquid components molar fractions
inline const scalarField& X() const;
//- Return the liquid fuel molar fractions
//- Return the liquid components molar fractions
inline scalarField& X();
//- Return the momentum relaxation time of droplets in parcel
@ -355,7 +358,7 @@ public:
void transformProperties(const vector& separation);
//- fix the 2D plane normal,
// when particle hits a face it is slightly perturbed
// when particle hits a face it is slightly perturbed
// towards the face centre and n_ will no longer be valid
inline void correctNormal(const vector& sym);

View File

@ -31,9 +31,14 @@ namespace Foam
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const List<word>& parcel::liquidNames() const
{
return liquidComponents_;
}
inline const List<word>& parcel::fuelNames() const
{
return fuelNames_;
return liquidComponents_;
}
inline scalar parcel::d() const
@ -115,7 +120,7 @@ inline scalar parcel::tTurb() const
{
return tTurb_;
}
inline scalar& parcel::liquidCore()
{
return liquidCore_;
@ -135,7 +140,7 @@ inline scalar parcel::injector() const
{
return injector_;
}
inline const vector& parcel::U() const
{
return U_;

View File

@ -38,17 +38,17 @@ Foam::parcel::parcel
:
Particle<parcel>(cloud, is),
fuelNames_
liquidComponents_
(
(cloud.pMesh().lookupObject<dictionary>("thermophysicalProperties"))
.lookup("liquidFuelComponents")
.lookup("liquidComponents")
),
X_(fuelNames_.size(), 0.0),
X_(liquidComponents_.size(), 0.0),
tMom_(GREAT)
{
label nX = fuelNames_.size();
label nX = X_.size();
if (readFields)
{
@ -67,7 +67,7 @@ Foam::parcel::parcel
is >> U_;
is >> Uturb_;
is >> n_;
for(label j=0; j<nX; j++)
for (label j=0; j<nX; j++)
{
X_[j] = readScalar(is);
}
@ -79,7 +79,7 @@ Foam::parcel::parcel
reinterpret_cast<char*>(&d_),
sizeof(d_) + sizeof(T_) + sizeof(m_) + sizeof(y_)
+ sizeof(yDot_) + sizeof(ct_) + sizeof(ms_) + sizeof(tTurb_)
+ sizeof(liquidCore_) + sizeof(injector_)
+ sizeof(liquidCore_) + sizeof(injector_)
+ sizeof(U_) + sizeof(Uturb_) + sizeof(n_)
);
@ -175,11 +175,10 @@ void Foam::parcel::readFields
const parcel& p0 = iter();
label nX = p0.X().size();
List<word> names(p0.fuelNames());
const List<word>& names = p0.liquidNames();
for (label j=0; j<nX; j++)
{
IOField<scalar> X(c.fieldIOobject(names[j]));
label i = 0;
@ -262,8 +261,7 @@ void Foam::parcel::writeFields
const parcel& p0 = iter();
label nX = p0.X().size();
List<word> names(p0.fuelNames());
const List<word>& names = p0.liquidNames();
for (label j=0; j<nX; j++)
{
@ -312,7 +310,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const parcel& p)
(
reinterpret_cast<const char*>(&p.d_),
sizeof(p.d_) + sizeof(p.T_) + sizeof(p.m_) + sizeof(p.y_)
+ sizeof(p.yDot_) + sizeof(p.ct_) + sizeof(p.ms_) + sizeof(p.tTurb_)
+ sizeof(p.yDot_) + sizeof(p.ct_) + sizeof(p.ms_) + sizeof(p.tTurb_)
+ sizeof(p.liquidCore_) + sizeof(p.injector_)
+ sizeof(p.U_) + sizeof(p.Uturb_) + sizeof(p.n_)
);

View File

@ -63,7 +63,7 @@ Foam::spray::spray
const dictionary& environmentalProperties
)
:
Cloud<parcel>(U.mesh()),
Cloud<parcel>(U.mesh(), false), // suppress className checking on positions
runTime_(U.time()),
time0_(runTime_.value()),
mesh_(U.mesh()),

0
src/lagrangian/intermediate/Make/options Executable file → Normal file
View File

0
src/lagrangian/solidParticle/Make/files Executable file → Normal file
View File

0
src/lagrangian/solidParticle/Make/options Executable file → Normal file
View File

View File

@ -29,10 +29,8 @@ License
#include "specie.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
const scalar liquidMixture::TrMax = 0.999;
}
const Foam::scalar Foam::liquidMixture::TrMax = 0.999;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -42,17 +40,35 @@ Foam::liquidMixture::liquidMixture
const dictionary& thermophysicalProperties
)
:
components_(thermophysicalProperties.lookup("liquidFuelComponents")),
components_(thermophysicalProperties.lookup("liquidComponents")),
properties_(components_.size())
{
// use sub-dictionary "liquidProperties" if possible to avoid
// collisions with identically named gas-phase entries
// (eg, H2O liquid vs. gas)
forAll(components_, i)
{
properties_.set
const dictionary* subDictPtr = thermophysicalProperties.subDictPtr
(
i,
liquid::New(thermophysicalProperties.lookup(components_[i]))
"liquidProperties"
);
if (subDictPtr)
{
properties_.set
(
i,
liquid::New(subDictPtr->lookup(components_[i]))
);
}
else
{
properties_.set
(
i,
liquid::New(thermophysicalProperties.lookup(components_[i]))
);
}
}
}
@ -347,7 +363,7 @@ Foam::scalar Foam::liquidMixture::mu
mu += x[i]*log(properties_[i].mu(p, Ti));
}
}
return exp(mu);
}
@ -390,7 +406,7 @@ Foam::scalar Foam::liquidMixture::K
K += phii[i]*phii[j]*Kij;
}
}
return K;
}
@ -412,7 +428,7 @@ Foam::scalar Foam::liquidMixture::D
Dinv += x[i]/properties_[i].D(p, Ti);
}
}
return 1.0/Dinv;
}

View File

@ -34,6 +34,48 @@ Description
For now it does not do much, since the perfect gas equation is used.
The dictionary constructor searches for the entry @c liquidComponents,
which is a wordList. The liquid properties of each component can either
be contained within a @c liquidProperties sub-dictionary or (for legacy
purposes) can be found directly in the dictionary.
The @c liquidProperties sub-dictionary entry should be used when possible
to avoid conflicts with identically named gas-phase entries.
A simple example of a single-component liquidMixture:
@verbatim
liquidComponents
(
H2O
);
// the gas-phase species
species
(
AIR H2O
);
// thermo values from BurcatCpData
AIR
AIR 1 28.96518 // specie: name/nMoles/MolWt
200 6000 1000 // low/high/common temperature
3.0879272 0.0012459718 -4.2371895e-07 6.7477479e-11 -3.9707697e-15 -995.26275 5.9596093 // 7 upper Temp. coeffs
3.5683962 -0.00067872943 1.5537148e-06 -3.2993706e-12 -4.6639539e-13 -1062.3466 3.7158296 // 7 lower Temp. coeffs
1.4792e-06 116 // sutherlandTransport for AIR (STAR-CD)
;
H2O
H2O 1 18.01528 // specie: name/nMoles/MolWt
200 6000 1000 // low/high/common temperature
2.6770389 0.0029731816 -7.7376889e-07 9.4433514e-11 -4.2689991e-15 -29885.894 6.88255 // 7 upper Temp. coeffs
4.1986352 -0.0020364017 6.5203416e-06 -5.4879269e-09 1.771968e-12 -30293.726 -0.84900901 // 7 lower Temp. coeffs
1.4792e-06 116 // sutherlandTransport for AIR (STAR-CD)
;
liquidProperties
{
H2O H2O defaultCoeffs;
}
@endverbatim
\*---------------------------------------------------------------------------*/
#ifndef liquidMixture_H
@ -51,7 +93,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class liquidMixture Declaration
Class liquidMixture Declaration
\*---------------------------------------------------------------------------*/
class liquidMixture

0
src/thermophysicalModels/radiation/Make/files Executable file → Normal file
View File

0
src/thermophysicalModels/radiation/Make/options Executable file → Normal file
View File

View File

@ -1,23 +1,17 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.4 |
| \\ / O peration | Version: 1.4.2 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "";
local "";
class dictionary;
object chemistryProperties;
version 2.0;
format ascii;
class dictionary;
object chemistryProperties;
location "constant";
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,23 +1,17 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.4 |
| \\ / O peration | Version: 1.4.2 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "";
local "";
class dictionary;
object combustionProperties;
version 2.0;
format ascii;
class dictionary;
object combustionProperties;
location "constant";
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -27,11 +21,8 @@ Cmix Cmix [ 0 0 0 0 0 0 0 ] 1.0 ;
ignitionProperties1
{
ignite off;
ignitionPoint ignitionPoint [ 0 1 0 0 0 0 0 ] ( 0.2 0 0.02 ) ;
timing timing [ 0 0 1 0 0 0 0 ] 0.0e-1 ;
duration duration [ 0 0 1 0 0 0 0 ] 1.0e-0 ;
}

View File

@ -1,23 +1,17 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.4 |
| \\ / O peration | Version: 1.4.2 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "";
local "";
class dictionary;
object environmentalProperties;
version 2.0;
format ascii;
class dictionary;
object environmentalProperties;
location "constant";
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,23 +1,17 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.4 |
| \\ / O peration | Version: 1.4.2 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "";
local "";
class dictionary;
object injectorProperties;
version 2.0;
format ascii;
class dictionary;
object injectorProperties;
location "constant";
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,23 +1,17 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.4 |
| \\ / O peration | Version: 1.4.2 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "";
local "";
class dictionary;
object sprayProperties;
version 2.0;
format ascii;
class dictionary;
object sprayProperties;
location "constant";
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -61,11 +55,11 @@ wallModel reflect;
specConstAtomizationCoeffs
{
dropletNozzleDiameterRatio
dropletNozzleDiameterRatio
(
0.4
);
sprayAngle
sprayAngle
(
10
);
@ -142,9 +136,9 @@ hollowConeInjectorCoeffs
{
dropletPDF
{
//pdfType exponential;
//pdfType exponential;
pdfType RosinRammler;
RosinRammlerPDF
{
minValue 1.00e-6;
@ -154,7 +148,7 @@ hollowConeInjectorCoeffs
(
1.5e-4
);
n
(
3

View File

@ -1,39 +1,38 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.4 |
| \\ / O peration | Version: 1.4.2 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "";
local "";
class dictionary;
object thermodynamicProperties;
version 2.0;
format ascii;
class dictionary;
object thermodynamicProperties;
location "constant";
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
thermoType hMixtureThermo<reactingMixture>;
CHEMKINFile "$FOAM_ROOT/$FOAM_CASE/chemkin/chem.inp";
CHEMKINThermoFile "$FOAM_ROOT/$FOAM_CASE/chemkin/therm.dat";
CHEMKINFile "$FOAM_CASE/chemkin/chem.inp";
// We use the central thermo data:
CHEMKINThermoFile "~OpenFOAM/thermoData/therm.dat";
inertSpecie N2;
inertSpecie N2;
liquidFuelComponents
liquidComponents
(
C7H16
);
C7H16 C7H16 defaultCoeffs;
liquidProperties
{
C7H16 C7H16 defaultCoeffs;
C7H16
}
/*********************************************************************/

View File

@ -1,23 +1,17 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.4 |
| \\ / O peration | Version: 1.4.2 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
root "";
case "";
instance "";
local "";
class dictionary;
object turbulenceProperties;
version 2.0;
format ascii;
class dictionary;
object turbulenceProperties;
location "constant";
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //