Merge branch 'master' of ssh://noisy/home/noisy2/OpenFOAM/OpenFOAM-dev

This commit is contained in:
henry 2008-06-24 17:01:14 +01:00
commit da76e14229
228 changed files with 51748 additions and 2373 deletions

View File

@ -1,5 +1,6 @@
EXE_INC = \
-I$(LIB_SRC)/lagrangian/molecule/lnInclude \
-I$(LIB_SRC)/lagrangian/molecularDynamics/molecule/lnInclude \
-I$(LIB_SRC)/lagrangian/molecularDynamics/potential/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
@ -8,4 +9,5 @@ EXE_LIBS = \
-lmeshTools \
-lfiniteVolume \
-llagrangian \
-lmolecule
-lmolecule \
-lpotential

View File

View File

@ -1,5 +1,6 @@
EXE_INC = \
-I$(LIB_SRC)/lagrangian/molecule/lnInclude \
-I$(LIB_SRC)/lagrangian/molecularDynamics/molecule/lnInclude \
-I$(LIB_SRC)/lagrangian/molecularDynamics/potential/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
@ -8,4 +9,5 @@ EXE_LIBS = \
-lmeshTools \
-lfiniteVolume \
-llagrangian \
-lmolecule
-lmolecule \
-lpotential

View File

@ -405,64 +405,71 @@ bool doCommand
backup(mesh, setName, currentSet, setName + "_old");
}
if (action == topoSetSource::CLEAR)
switch (action)
{
// Already handled above by not reading
}
else if (action == topoSetSource::INVERT)
{
currentSet.invert(currentSet.maxSize(mesh));
}
else if (action == topoSetSource::LIST)
{
currentSet.writeDebug(Pout, mesh, 100);
Pout<< endl;
}
else if (action == topoSetSource::SUBSET)
{
if (is >> sourceType)
case topoSetSource::CLEAR:
{
autoPtr<topoSetSource> setSource
(
topoSetSource::New
(
sourceType,
mesh,
is
)
);
// Backup current set.
topoSet oldSet
(
mesh,
currentSet.name() + "_old2",
currentSet
);
currentSet.clear();
currentSet.resize(oldSet.size());
setSource().applyToSet(topoSetSource::NEW, currentSet);
// Combine new value of currentSet with old one.
currentSet.subset(oldSet);
// Already handled above by not reading
break;
}
}
else
{
if (is >> sourceType)
case topoSetSource::INVERT:
{
autoPtr<topoSetSource> setSource
(
topoSetSource::New
currentSet.invert(currentSet.maxSize(mesh));
break;
}
case topoSetSource::LIST:
{
currentSet.writeDebug(Pout, mesh, 100);
Pout<< endl;
break;
}
case topoSetSource::SUBSET:
{
if (is >> sourceType)
{
autoPtr<topoSetSource> setSource
(
sourceType,
mesh,
is
)
);
topoSetSource::New
(
sourceType,
mesh,
is
)
);
setSource().applyToSet(action, currentSet);
// Backup current set.
topoSet oldSet
(
mesh,
currentSet.name() + "_old2",
currentSet
);
currentSet.clear();
currentSet.resize(oldSet.size());
setSource().applyToSet(topoSetSource::NEW, currentSet);
// Combine new value of currentSet with old one.
currentSet.subset(oldSet);
}
break;
}
default:
{
if (is >> sourceType)
{
autoPtr<topoSetSource> setSource
(
topoSetSource::New
(
sourceType,
mesh,
is
)
);
setSource().applyToSet(action, currentSet);
}
}
}
@ -532,7 +539,7 @@ bool doCommand
}
}
return error;
return !error;
}
@ -612,31 +619,36 @@ commandStatus parseType
switch(stat)
{
case polyMesh::UNCHANGED:
{
Pout<< " mesh not changed." << endl;
break;
break;
}
case polyMesh::POINTS_MOVED:
{
Pout<< " points moved; topology unchanged." << endl;
break;
break;
}
case polyMesh::TOPO_CHANGE:
{
Pout<< " topology changed; patches unchanged." << nl
<< " ";
printMesh(runTime, mesh);
break;
break;
}
case polyMesh::TOPO_PATCH_CHANGE:
{
Pout<< " topology changed and patches changed." << nl
<< " ";
printMesh(runTime, mesh);
break;
break;
}
default:
{
FatalErrorIn("parseType") << "Illegal mesh update state "
<< stat << abort(FatalError);
break;
break;
}
}
return INVALID;

View File

@ -0,0 +1,3 @@
patchSummary.C
EXE = $(FOAM_USER_APPBIN)/patchSummary

View File

@ -0,0 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-lfiniteVolume

View File

@ -0,0 +1,117 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
patchSummary
Description
Writes fields and boundary condition info for each patch at each requested
time instance.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "volFields.H"
#include "IOobjectList.H"
#include "patchSummaryTemplates.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "addTimeOptions.H"
# include "setRootCase.H"
# include "createTime.H"
// Get times list
instantList Times = runTime.times();
// set startTime and endTime depending on -time and -latestTime options
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
# include "createMesh.H"
for (label i=startTime; i<endTime; i++)
{
runTime.setTime(Times[i], i);
Info<< "Time = " << runTime.timeName() << nl << endl;
const IOobjectList fieldObjs(mesh, runTime.timeName());
const wordList objNames = fieldObjs.names();
PtrList<volScalarField> vsf(objNames.size());
PtrList<volVectorField> vvf(objNames.size());
PtrList<volSphericalTensorField> vsptf(objNames.size());
PtrList<volSymmTensorField> vsytf(objNames.size());
PtrList<volTensorField> vtf(objNames.size());
Info<< "Valid fields:" << endl;
forAll(objNames, objI)
{
IOobject obj
(
objNames[objI],
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
if (obj.headerOk())
{
addToFieldList<scalar>(vsf, obj, objI, mesh);
addToFieldList<vector>(vvf, obj, objI, mesh);
addToFieldList<sphericalTensor>(vsptf, obj, objI, mesh);
addToFieldList<symmTensor>(vsytf, obj, objI, mesh);
addToFieldList<tensor>(vtf, obj, objI, mesh);
}
}
Info<< endl;
const polyBoundaryMesh& bm = mesh.boundaryMesh();
forAll(bm, patchI)
{
Info<< "Patch: " << bm[patchI].name() << nl;
outputFieldList<scalar>(vsf, patchI);
outputFieldList<vector>(vvf, patchI);
outputFieldList<sphericalTensor>(vsptf, patchI);
outputFieldList<symmTensor>(vsytf, patchI);
outputFieldList<tensor>(vtf, patchI);
Info << endl;
}
}
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2005 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,80 +22,53 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
inline Foam::scalar Foam::pairPotential::m() const
{
return m_;
}
#include "patchSummaryTemplates.H"
#include "IOmanip.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline Foam::scalar Foam::pairPotential::gamma() const
{
return gamma_;
}
inline Foam::scalar Foam::pairPotential::rm() const
{
return rm_;
}
inline Foam::scalar Foam::pairPotential::epsilon() const
{
return epsilon_;
}
inline Foam::scalar Foam::pairPotential::rCut() const
{
return rCut_;
}
inline Foam::scalar Foam::pairPotential::rCutSqr() const
{
return rCutSqr_;
}
inline Foam::scalar Foam::pairPotential::rMin() const
{
return rMin_;
}
inline Foam::scalar Foam::pairPotential::dr() const
{
return dr_;
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
inline bool Foam::operator==
template<class Type>
void Foam::addToFieldList
(
const pairPotential& a,
const pairPotential& b
PtrList<GeometricField<Type, fvPatchField, volMesh> >& fieldList,
const IOobject& obj,
const label fieldI,
const fvMesh& mesh
)
{
return
(a.m() == b.m())
&& (a.gamma() == b.gamma())
&& (a.rm() == b.rm())
&& (a.epsilon() == b.epsilon())
&& (a.rCut() == b.rCut());
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
if (obj.headerClassName() == fieldType::typeName)
{
fieldList.set
(
fieldI,
new fieldType(obj, mesh)
);
Info<< " " << fieldType::typeName << tab << obj.name() << endl;
}
}
inline bool Foam::operator!=
template<class Type>
void Foam::outputFieldList
(
const pairPotential& a,
const pairPotential& b
PtrList<GeometricField<Type, fvPatchField, volMesh> >& fieldList,
const label patchI
)
{
return !(a == b);
forAll(fieldList, fieldI)
{
if (fieldList.set(fieldI))
{
Info<< " " << pTraits<Type>::typeName << tab << tab
<< fieldList[fieldI].name() << tab << tab
<< fieldList[fieldI].boundaryField()[patchI].type() << nl;
}
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2005 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,33 +24,42 @@ License
\*---------------------------------------------------------------------------*/
#ifndef patchSummaryTemplates_H
#define patchSummaryTemplates_H
#include "fvCFD.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
void addToFieldList
(
PtrList<GeometricField<Type, fvPatchField, volMesh> >& fieldList,
const IOobject& obj,
const label fieldI,
const fvMesh& mesh
);
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const word& tetherPotential::tetherPotentialName() const
{
return tetherPotentialName_;
}
inline const word& tetherPotential::tetherPotentialType() const
{
return tetherPotentialType_;
}
inline scalar tetherPotential::springConstant() const
{
return springConstant_;
}
template<class Type>
void outputFieldList
(
PtrList<GeometricField<Type, fvPatchField, volMesh> >& fieldList,
const label patchI
);
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
#ifdef NoRepository
# include "patchSummaryTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -3,7 +3,8 @@ EXE_INC = \
-I$(velocityDistributions) \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/lagrangian/molecule/lnInclude \
-I$(LIB_SRC)/lagrangian/molecularDynamics/molecule/lnInclude \
-I$(LIB_SRC)/lagrangian/molecularDynamics/potential/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude
@ -12,4 +13,5 @@ EXE_LIBS = \
-ldynamicMesh \
-lfiniteVolume \
-llagrangian \
-lmolecule
-lmolecule \
-lpotential

View File

@ -47,7 +47,7 @@ printUsage() {
cat <<LABUSAGE
$PROGNAME - extracts xy files from Foam logs.
Usage: $PROGNAME [-n][-s] <root> <case> <log>
Usage: $PROGNAME [-n][-s] <log>
extracts xy files from log
$PROGNAME -l <log>
lists but does not extract
@ -82,11 +82,11 @@ files with the extracted data only.
The query database is a simple text format with three entries per line,
separated with '/'. Column 1 is the name of the variable (cannot contain
spaces), column 2 is the regular expression to select the line and
column 3 is the string to select the column inside the line. The value
taken will be the first (non-space)word after this column.
The database will either be \$HOME/.${PROGNAME}.db or if not found
$PROGDIR/${PROGNAME}.db.
spaces), column 2 is the extended regular expression (egrep) to select
the line and column 3 is the string (fgrep) to select the column inside the
line. The value taken will be the first (non-space)word after this
column. The database will either be \$HOME/.${PROGNAME}.db or if not
found $PROGDIR/${PROGNAME}.db.
Option -s suppresses the default information and only prints the extracted
variables.
@ -105,7 +105,7 @@ myEcho() {
# getSolvedVars logFile
# Prints names of all 'solved for' variables in the log file.
getSolvedVars() {
grep ' Solving for ' $1 | fgrep ',' | sed -e 's/.* Solving for \([^,]*\)[,:].*/\1/' | sort -u
fgrep ' Solving for ' $1 | fgrep ',' | sed -e 's/.* Solving for \([^,]*\)[,:].*/\1/' | sort -u
}
@ -163,7 +163,7 @@ getAllQueries() {
for var in $dbQueries
do
getQueries $1 "$var"
line=`grep "$LINEQ" $2`
line=`egrep "$LINEQ" $2`
if [ "$line" ]; then
column=`echo "$line" | fgrep "$NUMQ"`
if [ "$column" ]; then
@ -228,14 +228,13 @@ if [ "$LISTONLY" ]; then
exit 0
fi
if [ $# -ne 3 ]; then
if [ $# -ne 1 ]; then
printUsage
exit 1
fi
ROOT=$1
CASE=$2
LOG=$3
CASEDIR=.
LOG=$1
if [ ! -r $LOG ]; then
echo "$PROGNAME: Cannot read log $LOG"
exit 1
@ -244,13 +243,13 @@ fi
QUERYNAMES=`getAllQueries $DBFILE $LOG`
if [ ! "$ROOT" -o ! "$CASE" ]; then
if [ ! "$CASEDIR" ]; then
printUsage
exit 1
fi
if [ ! -d "$ROOT/$CASE" ]; then
echo "$PROGNAME: Cannot read $ROOT/$CASE"
if [ ! -d "$CASEDIR" ]; then
echo "$PROGNAME: Cannot read $CASEDIR"
exit 1
fi
@ -262,16 +261,14 @@ fi
#-- Make logs dir in case directory and put awk file there.
mkdir -p $ROOT/$CASE/logs
AWKFILE=$ROOT/$CASE/logs/$PROGNAME.awk
mkdir -p $CASEDIR/logs
AWKFILE=$CASEDIR/logs/$PROGNAME.awk
myEcho "Using:"
myEcho " root : $ROOT"
myEcho " case : $CASE"
myEcho " log : $LOG"
myEcho " database : $DBFILE"
myEcho " awk file : $AWKFILE"
myEcho " files to : $ROOT/$CASE/logs"
myEcho " files to : $CASEDIR/logs"
myEcho ""
@ -364,19 +361,19 @@ cat <<LABSOLVE >> $AWKFILE
varName=varNameVal[1]
file=varName "_" subIter[varName]++
file="$ROOT/$CASE/logs/" file
file="$CASEDIR/logs/" file
extract(\$0, "Initial residual = ", val)
print $TIMENAME "\t" val[1] > file
varName=varNameVal[1] "FinalRes"
file=varName "_" subIter[varName]++
file="$ROOT/$CASE/logs/" file
file="$CASEDIR/logs/" file
extract(\$0, "Final residual = ", val)
print $TIMENAME "\t" val[1] > file
varName=varNameVal[1] "Iters"
file=varName "_" subIter[varName]++
file="$ROOT/$CASE/logs/" file
file="$CASEDIR/logs/" file
extract(\$0, "No Iterations ", val)
print $TIMENAME "\t" val[1] > file
}
@ -393,7 +390,7 @@ do
echo "#-- Extraction of $queryName" >> $AWKFILE
echo "/$LINEQ/ {" >> $AWKFILE
echo " extract(\$0, \"$NUMQ\", val)" >> $AWKFILE
echo " file=\"$ROOT/$CASE/logs/${queryName}_\" ${counter}" >> $AWKFILE
echo " file=\"$CASEDIR/logs/${queryName}_\" ${counter}" >> $AWKFILE
echo " print $TIMENAME \"\\t\" val[1] > file" >> $AWKFILE
echo " ${counter}++" >> $AWKFILE
echo "}" >> $AWKFILE

View File

@ -48,6 +48,6 @@ epsMax/bounding epsilon,/max:
epsAvg/bounding epsilon,/average:
#- gamma bounding
gammaMin/Min\(gamma\) =/Min(gamma) =
gammaMax/Max\(gamma\) =/Max(gamma) =
gammaMin/Min\(gamma\) =/Min(gamma) =
gammaMax/Max\(gamma\) =/Max(gamma) =

85
bin/upgradeTurbulenceProperties Executable file
View File

@ -0,0 +1,85 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
# \\/ 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 2 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, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
# upgradeTurbulenceProperties
#
# Description
# Upgrade the turbulenceProperties dictionary to the new format employed
# in OpenFOAM version 1.5
# - RAS turbulence models now defined by the RASProperties dictionary,
# and RASModel keyword, and
# - LES turbulence models now defined by the LESProperties dictionary,
# and LESModel keyword.
#
#------------------------------------------------------------------------------
printUsage()
{
echo "Usage: `basename $0` <turbulenceProperties>"
echo " Where <turbulenceProperties> is the full path to the"
echo " turbulenceProperties dictionary"
}
convertDict()
{
echo " Identified $1 turbulence model"
sed -e "s/turbulenceProperties/$1Properties/" \
-e "s/$2/$1Model/" \
-e "s/[a-zA-Z0-9]* [ ]*\[[0-9 ]*\]//" \
$3 > "$outputPath/$1Properties"
echo " written $1Properties to $outputPath/"
}
outputPath=`dirname $1`
if [ $# -ne 1 ]; then
printUsage
exit 1
elif [ ! -e $1 ]; then
echo " Error: file $1 does not exist"
echo ""
printUsage
exit 1
fi
# Identify type of turbulence model
RAS=`grep turbulenceModel $1`
LES=`grep LESmodel $1`
if [ -n "$RAS" ]; then
convertDict "RAS" "turbulenceModel" $1
elif [ -n "$LES" ]; then
convertDict "LES" "LESmodel" $1
else
echo "Unable to determine turbulence model type - nothing changed"
exit 1
fi
echo "done."
exit 0

View File

@ -11,4 +11,5 @@ Misc Tools
1. find-templateInComments
2. find-its
3. find-junkFiles
4. find-longlines

View File

@ -0,0 +1,46 @@
#!/usr/bin/perl -w
use strict;
use File::Find ();
# -----------------------------------------------------------------------------
#
# Script
# find-longlines
#
# Description
# Search for *.[CH] files that exceed the 80-column width
#
# - print filename lineNumber and offending line (with truncation point)
#
# -----------------------------------------------------------------------------
my $maxlen = 80;
my $re_filespec = qr{^.+\.[CH]$};
my $count;
sub wanted {
unless ( lstat($_) and -f _ and -r _ and not -l _ and /$re_filespec/ ) {
return;
}
local @ARGV = $_;
while (<>) {
chomp;
s{\s+$}{}; # trim
if ( $maxlen < length ) {
$count++;
substr( $_, $maxlen, 0 ) = "||->>"; # show truncation point
print "$ARGV $. $_\n";
}
}
close ARGV;
}
## Traverse desired filesystems
for my $dir (@ARGV) {
no warnings 'File::Find';
warn "(**) checking '$dir' ...\n";
File::Find::find( { wanted => \&wanted }, $dir );
}

View File

@ -1,165 +0,0 @@
// ============================================================================
// gzstream, C++ iostream classes wrapping the zlib compression library.
// Copyright (C) 2001 Deepak Bandyopadhyay, Lutz Kettner
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// ============================================================================
//
// File : gzstream.C
// Revision : $Revision: 1.7 $
// Revision_date : $Date: 2003/01/08 14:41:27 $
// Author(s) : Deepak Bandyopadhyay, Lutz Kettner
//
// Standard streambuf implementation following Nicolai Josuttis, "The
// Standard C++ Library".
// ============================================================================
#include <gzstream.h>
#include <iostream>
#include <string.h> // for memcpy
#ifdef GZSTREAM_NAMESPACE
namespace GZSTREAM_NAMESPACE {
#endif
// ----------------------------------------------------------------------------
// Internal classes to implement gzstream. See header file for user classes.
// ----------------------------------------------------------------------------
// --------------------------------------
// class gzstreambuf:
// --------------------------------------
gzstreambuf* gzstreambuf::open( const char* name, int open_mode) {
if ( is_open())
return reinterpret_cast<gzstreambuf*>(0);
mode = open_mode;
// no append nor read/write mode
if ((mode & std::ios::ate) || (mode & std::ios::app)
|| ((mode & std::ios::in) && (mode & std::ios::out)))
return reinterpret_cast<gzstreambuf*>(0);
char fmode[10];
char* fmodeptr = fmode;
if ( mode & std::ios::in)
*fmodeptr++ = 'r';
else if ( mode & std::ios::out)
*fmodeptr++ = 'w';
*fmodeptr++ = 'b';
*fmodeptr = '\0';
file = gzopen( name, fmode);
if (file == 0)
return reinterpret_cast<gzstreambuf*>(0);
opened = 1;
return this;
}
gzstreambuf * gzstreambuf::close() {
if ( is_open()) {
sync();
opened = 0;
if ( gzclose( file) == Z_OK)
return this;
}
return reinterpret_cast<gzstreambuf*>(0);
}
int gzstreambuf::underflow() { // used for input buffer only
if ( gptr() && ( gptr() < egptr()))
return * reinterpret_cast<unsigned char *>( gptr());
if ( ! (mode & std::ios::in) || ! opened)
return EOF;
// Josuttis' implementation of inbuf
int n_putback = gptr() - eback();
if ( n_putback > 4)
n_putback = 4;
memcpy( buffer + (4 - n_putback), gptr() - n_putback, n_putback);
int num = gzread( file, buffer+4, bufferSize-4);
if (num <= 0) // ERROR or EOF
return EOF;
// reset buffer pointers
setg( buffer + (4 - n_putback), // beginning of putback area
buffer + 4, // read position
buffer + 4 + num); // end of buffer
// return next character
return * reinterpret_cast<unsigned char *>( gptr());
}
int gzstreambuf::flush_buffer() {
// Separate the writing of the buffer from overflow() and
// sync() operation.
int w = pptr() - pbase();
if ( gzwrite( file, pbase(), w) != w)
return EOF;
pbump( -w);
return w;
}
int gzstreambuf::overflow( int c) { // used for output buffer only
if ( ! ( mode & std::ios::out) || ! opened)
return EOF;
if (c != EOF) {
*pptr() = c;
pbump(1);
}
if ( flush_buffer() == EOF)
return EOF;
return c;
}
int gzstreambuf::sync() {
// Changed to use flush_buffer() instead of overflow( EOF)
// which caused improper behavior with std::endl and flush(),
// bug reported by Vincent Ricard.
if ( pptr() && pptr() > pbase()) {
if ( flush_buffer() == EOF)
return -1;
}
return 0;
}
// --------------------------------------
// class gzstreambase:
// --------------------------------------
gzstreambase::gzstreambase( const char* name, int mode) {
init( &buf);
open( name, mode);
}
gzstreambase::~gzstreambase() {
buf.close();
}
void gzstreambase::open( const char* name, int open_mode) {
if ( ! buf.open( name, open_mode))
clear( rdstate() | std::ios::badbit);
}
void gzstreambase::close() {
if ( buf.is_open())
if ( ! buf.close())
clear( rdstate() | std::ios::badbit);
}
#ifdef GZSTREAM_NAMESPACE
} // namespace GZSTREAM_NAMESPACE
#endif
// ============================================================================
// EOF //

View File

@ -1,121 +0,0 @@
// ============================================================================
// gzstream, C++ iostream classes wrapping the zlib compression library.
// Copyright (C) 2001 Deepak Bandyopadhyay, Lutz Kettner
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// ============================================================================
//
// File : gzstream.h
// Revision : $Revision: 1.5 $
// Revision_date : $Date: 2002/04/26 23:30:15 $
// Author(s) : Deepak Bandyopadhyay, Lutz Kettner
//
// Standard streambuf implementation following Nicolai Josuttis, "The
// Standard C++ Library".
// ============================================================================
#ifndef GZSTREAM_H
#define GZSTREAM_H 1
// standard C++ with new header file names and std:: namespace
#include <iostream>
#include <fstream>
#include <zlib.h>
#ifdef GZSTREAM_NAMESPACE
namespace GZSTREAM_NAMESPACE {
#endif
// ----------------------------------------------------------------------------
// Internal classes to implement gzstream. See below for user classes.
// ----------------------------------------------------------------------------
class gzstreambuf : public std::streambuf {
private:
static const int bufferSize = 47+256; // size of data buff
// totals 512 bytes under g++ for igzstream at the end.
gzFile file; // file handle for compressed file
char buffer[bufferSize]; // data buffer
char opened; // open/close state of stream
int mode; // I/O mode
int flush_buffer();
public:
gzstreambuf() : opened(0) {
setp( buffer, buffer + (bufferSize-1));
setg( buffer + 4, // beginning of putback area
buffer + 4, // read position
buffer + 4); // end position
// ASSERT: both input & output capabilities will not be used together
}
int is_open() { return opened; }
gzstreambuf* open( const char* name, int open_mode);
gzstreambuf* close();
~gzstreambuf() { close(); }
virtual int overflow( int c = EOF);
virtual int underflow();
virtual int sync();
};
class gzstreambase : virtual public std::ios {
protected:
gzstreambuf buf;
public:
gzstreambase() { init(&buf); }
gzstreambase( const char* name, int open_mode);
~gzstreambase();
void open( const char* name, int open_mode);
void close();
gzstreambuf* rdbuf() { return &buf; }
};
// ----------------------------------------------------------------------------
// User classes. Use igzstream and ogzstream analogously to ifstream and
// ofstream respectively. They read and write files based on the gz*
// function interface of the zlib. Files are compatible with gzip compression.
// ----------------------------------------------------------------------------
class igzstream : public gzstreambase, public std::istream {
public:
igzstream() : std::istream( &buf) {}
igzstream( const char* name, int open_mode = std::ios::in)
: gzstreambase( name, open_mode), std::istream( &buf) {}
gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
void open( const char* name, int open_mode = std::ios::in) {
gzstreambase::open( name, open_mode);
}
};
class ogzstream : public gzstreambase, public std::ostream {
public:
ogzstream() : std::ostream( &buf) {}
ogzstream( const char* name, int mode = std::ios::out)
: gzstreambase( name, mode), std::ostream( &buf) {}
gzstreambuf* rdbuf() { return gzstreambase::rdbuf(); }
void open( const char* name, int open_mode = std::ios::out) {
gzstreambase::open( name, open_mode);
}
};
#ifdef GZSTREAM_NAMESPACE
} // namespace GZSTREAM_NAMESPACE
#endif
#endif // GZSTREAM_H
// ============================================================================
// EOF //

View File

@ -803,7 +803,7 @@ public:
(
const dictionary& shrinkDict,
const dictionary& motionDict,
const scalar nAllowableErrors,
const label nAllowableErrors,
motionSmoother&
);

View File

@ -2346,7 +2346,7 @@ void Foam::autoHexMeshDriver::addLayers
(
const dictionary& shrinkDict,
const dictionary& motionDict,
const scalar nAllowableErrors,
const label nAllowableErrors,
motionSmoother& meshMover
)
{

View File

@ -103,8 +103,6 @@ $(derivedFvPatchFields)/timeVaryingUniformTotalPressure/timeVaryingUniformTotalP
$(derivedFvPatchFields)/totalTemperature/totalTemperatureFvPatchScalarField.C
$(derivedFvPatchFields)/turbulentInlet/turbulentInletFvPatchFields.C
$(derivedFvPatchFields)/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C
$(derivedFvPatchFields)/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C
$(derivedFvPatchFields)/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C
$(derivedFvPatchFields)/uniformFixedValue/uniformFixedValueFvPatchFields.C
$(derivedFvPatchFields)/waveTransmissive/waveTransmissiveFvPatchFields.C

View File

@ -32,15 +32,28 @@ License
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
// adjust negative resistance values to be multiplier of max value
void Foam::porousZone::adjustNegativeResistance(vector& resist)
void Foam::porousZone::adjustNegativeResistance(dimensionedVector& resist)
{
scalar maxCmpt = max(0, cmptMax(resist));
scalar maxCmpt = max(0, cmptMax(resist.value()));
for (label cmpt=0; cmpt < vector::nComponents; ++cmpt)
if (maxCmpt < 0)
{
if (resist[cmpt] < 0)
FatalErrorIn
(
"Foam::porousZone::porousZone::adjustNegativeResistance"
"(dimensionedVector&)"
) << "negative resistances! " << resist
<< exit(FatalError);
}
else
{
vector& val = resist.value();
for (label cmpt=0; cmpt < vector::nComponents; ++cmpt)
{
resist[cmpt] *= -maxCmpt;
if (val[cmpt] < 0)
{
val[cmpt] *= -maxCmpt;
}
}
}
}
@ -71,24 +84,20 @@ Foam::porousZone::porousZone
FatalErrorIn
(
"Foam::porousZone::porousZone"
"(const fvMesh&, const Istream&)"
"(const fvMesh&, const word&, const dictionary&)"
) << "cannot find porous cellZone " << name_
<< exit(FatalError);
}
// local-to-global transformation tensor
const tensor& E = coordSys_.R();
// porosity
if (dict_.found("porosity"))
if (dict_.readIfPresent("porosity", porosity_))
{
dict_.lookup("porosity") >> porosity_;
if (porosity_ <= 0.0 || porosity_ > 1.0)
{
FatalIOErrorIn
(
"Foam::porousZone::porousZone(const fvMesh&, const Istream&)",
"Foam::porousZone::porousZone"
"(const fvMesh&, const word&, const dictionary&)",
dict_
)
<< "out-of-range porosity value " << porosity_
@ -97,73 +106,64 @@ Foam::porousZone::porousZone
}
// powerLaw coefficients
if (dict_.found("powerLaw"))
if (const dictionary* dictPtr = dict_.subDictPtr("powerLaw"))
{
const dictionary& subDict = dict_.subDict("powerLaw");
if (subDict.found("C0"))
{
subDict.lookup("C0") >> C0_;
}
if (subDict.found("C1"))
{
subDict.lookup("C1") >> C1_;
}
dictPtr->readIfPresent("C0", C0_);
dictPtr->readIfPresent("C1", C1_);
}
// Darcy-Forchheimer coefficients
if (dict_.found("Darcy"))
if (const dictionary* dictPtr = dict_.subDictPtr("Darcy"))
{
const dictionary& subDict = dict_.subDict("Darcy");
// local-to-global transformation tensor
const tensor& E = coordSys_.R();
dimensionedVector d("d", D_.dimensions(), vector::zero);
dimensionedVector f("f", F_.dimensions(), vector::zero);
if (subDict.found("d"))
dimensionedVector d(vector::zero);
if (dictPtr->readIfPresent("d", d))
{
// d = dimensionedVector("d", subDict.lookup("d"));
subDict.lookup("d") >> d;
adjustNegativeResistance(d.value());
if (D_.dimensions() != d.dimensions())
{
FatalIOErrorIn
(
"Foam::porousZone::porousZone"
"(const fvMesh&, const word&, const dictionary&)",
dict_
) << "incorrect dimensions for d: " << d.dimensions()
<< " should be " << D_.dimensions()
<< exit(FatalIOError);
}
}
if (subDict.found("f"))
{
// f = dimensionedVector("f", subDict.lookup("f"));
subDict.lookup("f") >> f;
adjustNegativeResistance(f.value());
adjustNegativeResistance(d);
D_.value().xx() = d.value().x();
D_.value().yy() = d.value().y();
D_.value().zz() = d.value().z();
D_.value() = (E & D_ & E.T()).value();
}
if (D_.dimensions() != d.dimensions())
dimensionedVector f(vector::zero);
if (dictPtr->readIfPresent("f", f))
{
FatalIOErrorIn
(
"Foam::porousZone::porousZone(const fvMesh&, const Istream&)",
dict_
) << "incorrect dimensions for d: " << d.dimensions()
<< " should be " << D_.dimensions()
<< exit(FatalIOError);
if (F_.dimensions() != f.dimensions())
{
FatalIOErrorIn
(
"Foam::porousZone::porousZone"
"(const fvMesh&, const word&, const dictionary&)",
dict_
) << "incorrect dimensions for f: " << f.dimensions()
<< " should be " << F_.dimensions()
<< exit(FatalIOError);
}
adjustNegativeResistance(f);
// leading 0.5 is from 1/2 * rho
F_.value().xx() = 0.5*f.value().x();
F_.value().yy() = 0.5*f.value().y();
F_.value().zz() = 0.5*f.value().z();
F_.value() = (E & F_ & E.T()).value();
}
if (F_.dimensions() != f.dimensions())
{
FatalIOErrorIn
(
"Foam::porousZone::porousZone(const fvMesh&, const Istream&)",
dict_
) << "incorrect dimensions for f: " << f.dimensions()
<< " should be " << F_.dimensions()
<< exit(FatalIOError);
}
D_.value().xx() = d.value().x();
D_.value().yy() = d.value().y();
D_.value().zz() = d.value().z();
D_.value() = (E & D_ & E.T()).value();
// leading 0.5 is from 1/2 * rho
F_.value().xx() = 0.5*f.value().x();
F_.value().yy() = 0.5*f.value().y();
F_.value().zz() = 0.5*f.value().z();
F_.value() = (E & F_ & E.T()).value();
}
// provide some feedback for the user
@ -179,7 +179,8 @@ Foam::porousZone::porousZone
{
FatalIOErrorIn
(
"Foam::porousZone::porousZone(const fvMesh&, const Istream&)",
"Foam::porousZone::porousZone"
"(const fvMesh&, const word&, const dictionary&)",
dict_
) << "neither powerLaw (C0/C1) "
"nor Darcy-Forchheimer law (d/f) specified"

View File

@ -128,7 +128,7 @@ class porousZone
// Private Member Functions
//- adjust negative resistance values to be multiplier of max value
static void adjustNegativeResistance(vector& resist);
static void adjustNegativeResistance(dimensionedVector& resist);
//- Power-law resistance
template<class RhoFieldType>

View File

@ -5,4 +5,6 @@ wmake libso basic
wmake libso solidParticle
wmake libso intermediate
wmake libso dieselSpray
wmake libso molecule
(cd molecularDynamics && wmake libso potential)
(cd molecularDynamics && wmake libso molecule)

View File

@ -11,11 +11,6 @@ referredMolecule = referredMolecule
referredCellList = referredCellList
referredCell = referredCell
referralLists = referralLists
potentials = potentials
pairPotential = $(potentials)/pairPotential
tetherPotential = $(potentials)/tetherPotential
$(distribution)/distribution.C
$(reducedUnits)/reducedUnits.C
@ -42,11 +37,6 @@ $(moleculeCloud)/moleculeCloudIntegrateEquationsOfMotion.C
$(moleculeCloud)/moleculeCloudRemoveHighEnergyOverlaps.C
$(moleculeCloud)/moleculeCloudApplyConstraintsAndThermostats.C
$(pairPotential)/basic/pairPotential.C
$(pairPotential)/basic/pairPotentialList.C
$(tetherPotential)/tetherPotential.C
$(tetherPotential)/tetherPotentialList.C
$(referralLists)/receivingReferralList.C
$(referralLists)/sendingReferralList.C
$(referredCellList)/referredCellList.C

View File

@ -1,8 +1,10 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/lagrangian/molecularDynamics/potential/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-llagrangian
-llagrangian \
-lpotential

View File

@ -135,7 +135,7 @@ scalar distribution::median()
scalar runningSum = 0.0;
List< Pair<scalar> > normDist(normalised());
List<Pair<scalar> > normDist(normalised());
if (normDist.size())
{
@ -259,7 +259,7 @@ List< Pair<scalar> > distribution::normalised()
sort(keys);
List< Pair<scalar> > normDist(size());
List<Pair<scalar> > normDist(size());
forAll(keys,k)
{
@ -282,9 +282,9 @@ List< Pair<scalar> > distribution::normalisedMinusMean()
List< Pair<scalar> > distribution::normalisedShifted(const scalar shiftValue)
{
List< Pair<scalar> > oldDist(normalised());
List<Pair<scalar> > oldDist(normalised());
List< Pair<scalar> > newDist(oldDist.size());
List<Pair<scalar> > newDist(oldDist.size());
forAll(oldDist,u)
{
@ -383,7 +383,7 @@ List< Pair<scalar> > distribution::normalisedShifted(const scalar shiftValue)
}
List< Pair<scalar> > distribution::raw()
List<Pair<scalar> > distribution::raw()
{
insertMissingKeys();
@ -391,7 +391,7 @@ List< Pair<scalar> > distribution::raw()
sort(keys);
List< Pair<scalar> > rawDist(size());
List<Pair<scalar> > rawDist(size());
forAll(keys,k)
{

View File

@ -102,6 +102,7 @@ public:
List<Pair<scalar> > raw();
// Access
inline scalar binWidth() const;

View File

@ -79,5 +79,27 @@ if (mesh.time().timeIndex() % pacf.sampleSteps() == 0)
if (mesh.time().timeIndex() % hfacf.sampleSteps() == 0)
{
// hFacf.calculateCorrelationFunction();
IDLList<molecule>::iterator mol(molecules.begin());
vector s = vector::zero;
for
(
mol = molecules.begin();
mol != molecules.end();
++mol
)
{
s +=
(
0.5 * mol().mass() * magSqr(mol().U())
+
mol().potentialEnergy()
) * mol().U()
+
0.5 * ( mol().rf() & mol().U() );
}
hfacf.calculateCorrelationFunction(s);
}

View File

@ -59,7 +59,24 @@ Info<< "Viscosity = "
if(writeHFacf)
{
OFstream hfacfFile
(
runTime.path()/ + "hfacf"
);
if (!hfacf.writeAveraged(hfacfFile))
{
FatalErrorIn(args.executable())
<< "Failed writing to "
<< hfacfFile.name()
<< abort(FatalError);
}
}
Info << "Thermal conductivity = "
<< hfacf.integral()
/averageTemperature
/averageTemperature
/moleculeCloud::kb
/ meshVolume
<< endl;

View File

@ -2,25 +2,25 @@
List< scalarField > allSpeciesN_RU
(
molecules.nIds(),
molecules.pairPotentials().nIds(),
scalarField (mesh.nCells(), 0.0)
);
List< scalarField > allSpeciesM_RU
(
molecules.nIds(),
molecules.pairPotentials().nIds(),
scalarField (mesh.nCells(), 0.0)
);
List< vectorField > allSpeciesVelocitySum_RU
(
molecules.nIds(),
molecules.pairPotentials().nIds(),
vectorField (mesh.nCells(), vector::zero)
);
List< scalarField > allSpeciesVelocityMagSquaredSum_RU
(
molecules.nIds(),
molecules.pairPotentials().nIds(),
scalarField (mesh.nCells(), 0.0)
);
@ -34,13 +34,13 @@ Info << nl << "Creating fields." << endl;
PtrList<volScalarField> allSpeciesRhoN
(
molecules.nIds()
molecules.pairPotentials().nIds()
);
forAll (allSpeciesRhoN, rN)
{
Info << " Creating number density field for "
<< molecules.idList()[rN] << endl;
<< molecules.pairPotentials().idList()[rN] << endl;
allSpeciesRhoN.set
(
@ -49,7 +49,7 @@ forAll (allSpeciesRhoN, rN)
(
IOobject
(
"rhoN_" + molecules.idList()[rN],
"rhoN_" + molecules.pairPotentials().idList()[rN],
runTime.timeName(),
mesh,
IOobject::NO_READ,
@ -89,13 +89,13 @@ totalRhoN.correctBoundaryConditions();
PtrList<volScalarField> allSpeciesRhoM
(
molecules.nIds()
molecules.pairPotentials().nIds()
);
forAll (allSpeciesRhoM, rM)
{
Info << " Creating mass density field for "
<< molecules.idList()[rM] << endl;
<< molecules.pairPotentials().idList()[rM] << endl;
allSpeciesRhoM.set
(
@ -104,7 +104,7 @@ forAll (allSpeciesRhoM, rM)
(
IOobject
(
"rhoM_" + molecules.idList()[rM],
"rhoM_" + molecules.pairPotentials().idList()[rM],
runTime.timeName(),
mesh,
IOobject::NO_READ,
@ -144,13 +144,13 @@ totalRhoM.correctBoundaryConditions();
PtrList<volVectorField> allSpeciesVelocity
(
molecules.nIds()
molecules.pairPotentials().nIds()
);
forAll (allSpeciesVelocity, v)
{
Info << " Creating velocity field for "
<< molecules.idList()[v] << endl;
<< molecules.pairPotentials().idList()[v] << endl;
allSpeciesVelocity.set
(
@ -159,7 +159,7 @@ forAll (allSpeciesVelocity, v)
(
IOobject
(
"velocity_" + molecules.idList()[v],
"velocity_" + molecules.pairPotentials().idList()[v],
runTime.timeName(),
mesh,
IOobject::NO_READ,
@ -177,22 +177,40 @@ forAll (allSpeciesVelocity, v)
Info << " Creating total velocity field" << endl;
// volVectorField totalVelocity
// (
// IOobject
// (
// "velocity_total",
// runTime.timeName(),
// mesh,
// IOobject::NO_READ,
// IOobject::AUTO_WRITE
// ),
// mesh,
// dimVelocity,
// "zeroGradient"
// );
// totalVelocity.internalField() = vectorField (mesh.nCells(), vector::zero);
// totalVelocity.correctBoundaryConditions();
volVectorField totalVelocity
(
IOobject
(
"velocity_total",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
"velocity_total",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimVelocity,
"zeroGradient"
dimensionedVector("zero", dimVelocity, vector::zero)
);
totalVelocity.internalField() = vectorField (mesh.nCells(), vector::zero);
totalVelocity.correctBoundaryConditions();
/*---------------------------------------------------------------------------*\
Kinetic temperature
@ -200,13 +218,13 @@ totalVelocity.correctBoundaryConditions();
PtrList<volScalarField> allSpeciesTemperature
(
molecules.nIds()
molecules.pairPotentials().nIds()
);
forAll (allSpeciesTemperature, t)
{
Info << " Creating temperature field for "
<< molecules.idList()[t] << endl;
<< molecules.pairPotentials().idList()[t] << endl;
allSpeciesTemperature.set
(
@ -215,7 +233,7 @@ forAll (allSpeciesTemperature, t)
(
IOobject
(
"temperature_" + molecules.idList()[t],
"temperature_" + molecules.pairPotentials().idList()[t],
runTime.timeName(),
mesh,
IOobject::NO_READ,
@ -256,13 +274,13 @@ totalTemperature.correctBoundaryConditions();
PtrList<volScalarField> allSpeciesMeanKE
(
molecules.nIds()
molecules.pairPotentials().nIds()
);
forAll (allSpeciesMeanKE, mKE)
{
Info << " Creating mean kinetic energy field for "
<< molecules.idList()[mKE] << endl;
<< molecules.pairPotentials().idList()[mKE] << endl;
allSpeciesMeanKE.set
(
@ -271,7 +289,7 @@ forAll (allSpeciesMeanKE, mKE)
(
IOobject
(
"meanKE_" + molecules.idList()[mKE],
"meanKE_" + molecules.pairPotentials().idList()[mKE],
runTime.timeName(),
mesh,
IOobject::NO_READ,

View File

@ -2,25 +2,25 @@ if (runTime.outputTime())
{
allSpeciesN_RU = List< scalarField >
(
molecules.nIds(),
molecules.pairPotentials().nIds(),
scalarField (mesh.nCells(), 0.0)
);
allSpeciesM_RU = List< scalarField >
(
molecules.nIds(),
molecules.pairPotentials().nIds(),
scalarField (mesh.nCells(), 0.0)
);
allSpeciesVelocitySum_RU = List< vectorField >
(
molecules.nIds(),
molecules.pairPotentials().nIds(),
vectorField (mesh.nCells(), vector::zero)
);
allSpeciesVelocityMagSquaredSum_RU = List< scalarField >
(
molecules.nIds(),
molecules.pairPotentials().nIds(),
scalarField (mesh.nCells(), 0.0)
);
}

View File

@ -86,6 +86,8 @@ if (runTime.outputTime())
<< " m/s" << nl
<< "Average temperature = "
<< averageTemperature << " K" << nl
<< "accumulatedTotalrDotfSum = "
<< accumulatedTotalrDotfSum << nl
<< "Average pressure = "
<< averagePressure << " N/m^2" << nl
<< "----------------------------------------" << endl;

View File

@ -54,7 +54,7 @@ bool molecule::move(molecule::trackData& td)
U_ += 0.5*deltaT*A_;
}
while (td.keepParticle && !td.switchProcessor && tEnd > SMALL)
while (td.keepParticle && !td.switchProcessor && tEnd > (SMALL*SMALL))
{
// set the lagrangian time-step
scalar dt = min(dtMax, tEnd);
@ -178,6 +178,7 @@ void molecule::hitWallPatch
{
U_ -= 2*Un*nw;
}
// }
}

View File

@ -23,10 +23,9 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::molecule
molecule
Description
Foam::molecule
SourceFiles
moleculeI.H
@ -192,6 +191,7 @@ public:
//- Return tetherPosition
inline const vector& tetherPosition() const;
inline vector& tetherPosition();
//- Tracking

View File

@ -24,9 +24,12 @@ License
\*---------------------------------------------------------------------------*/
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::molecule::molecule
inline molecule::molecule
(
const Cloud<molecule>& c,
const vector& position,
@ -51,7 +54,7 @@ inline Foam::molecule::molecule
{}
inline Foam::molecule::trackData::trackData
inline molecule::trackData::trackData
(
moleculeCloud& molCloud,
label part
@ -65,88 +68,98 @@ inline Foam::molecule::trackData::trackData
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::label Foam::molecule::id() const
inline label molecule::id() const
{
return id_;
}
inline Foam::scalar Foam::molecule::mass() const
inline scalar molecule::mass() const
{
return mass_;
}
inline const Foam::vector& Foam::molecule::U() const
inline const vector& molecule::U() const
{
return U_;
}
inline Foam::vector& Foam::molecule::U()
inline vector& molecule::U()
{
return U_;
}
inline const Foam::vector& Foam::molecule::A() const
inline const vector& molecule::A() const
{
return A_;
}
inline Foam::vector& Foam::molecule::A()
inline vector& molecule::A()
{
return A_;
}
inline Foam::scalar Foam::molecule::potentialEnergy() const
inline scalar molecule::potentialEnergy() const
{
return potentialEnergy_;
}
inline Foam::scalar& Foam::molecule::potentialEnergy()
inline scalar& molecule::potentialEnergy()
{
return potentialEnergy_;
}
inline const Foam::tensor& Foam::molecule::rf() const
inline const tensor& molecule::rf() const
{
return rf_;
}
inline Foam::tensor& Foam::molecule::rf()
inline tensor& molecule::rf()
{
return rf_;
}
inline Foam::label Foam::molecule::tethered() const
inline label molecule::tethered() const
{
return tethered_;
}
inline const Foam::vector& Foam::molecule::tetherPosition() const
inline const vector& molecule::tetherPosition() const
{
return tetherPosition_;
}
inline Foam::moleculeCloud& Foam::molecule::trackData::molCloud()
inline vector& molecule::tetherPosition()
{
return tetherPosition_;
}
inline moleculeCloud& molecule::trackData::molCloud()
{
return molCloud_;
}
inline Foam::label Foam::molecule::trackData::part() const
inline label molecule::trackData::part() const
{
return part_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -97,18 +97,6 @@ private:
scalar potentialEnergyLimit_;
scalar guardRadius_;
scalar rCutMax_;
//- storing rCutMaxSqr in class as well as rCutMax to
//- avoid needing to calculate it often.
//- Possibilty of inconsistency if tinkered with.
scalar rCutMaxSqr_;
List<word> idList_;
labelList removalOrder_;
labelListList directInteractionList_;
@ -189,20 +177,10 @@ public:
inline scalar potentialEnergyLimit() const;
inline scalar guardRadius() const;
inline scalar rCutMax() const;
inline scalar rCutMaxSqr() const;
inline const List<word>& idList() const;
inline const labelList& removalOrder() const;
inline label nPairPotentials() const;
inline label nIds() const;
inline const labelListList& directInteractionList() const;
inline const referredCellList& referredInteractionList() const;

View File

@ -22,13 +22,21 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
moleculeCloud
Description
\*----------------------------------------------------------------------------*/
#include "moleculeCloud.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::moleculeCloud::buildCellOccupancy()
namespace Foam
{
void moleculeCloud::buildCellOccupancy()
{
forAll(cellOccupancy_, cO)
{
@ -37,7 +45,12 @@ void Foam::moleculeCloud::buildCellOccupancy()
iterator mol(this->begin());
for (mol = this->begin(); mol != this->end(); ++mol)
for
(
mol = this->begin();
mol != this->end();
++mol
)
{
cellOccupancy_[mol().cell()].append(&mol());
}
@ -50,5 +63,6 @@ void Foam::moleculeCloud::buildCellOccupancy()
referredInteractionList_.referMolecules();
}
} // End namespace Foam
// ************************************************************************* //

View File

@ -6,7 +6,7 @@ rIJ = molI->position() - molJ->position();
rIJMagSq = magSqr(rIJ);
if (pairPotentials_.rCutSqr(idI, idJ, rIJMagSq))
if(pairPotentials_.rCutSqr(idI, idJ, rIJMagSq))
{
rIJMag = mag(rIJ);

View File

@ -0,0 +1,193 @@
// Parallel coding to access boundary information to build up interaction cell info
// See preservePatchTypes for how to read the boundary file.
// Read faceProcAddressing, as per reconstructPar, to get hold of the original,
// undecomposed face label from a face on a processor mesh. See email from Mattijs:
// > Is it a case of reading the faceProcAddressing file, in the same way as
// > something like reconstructPar?
// Correct.
//
// Note that faceProcAddressing is a bit weird since it also includes which side
// of an internal face we have. If I remember correctly:
//
// faceI == 0 illegal
// faceI > 0 we have the original owner of  faceI-1 i.e. we have the face in the
// original order.
// faceI < 0 we have the original neighbour of -faceI-1 so the face is flipped.
// Use the same functionality as
// label polyBoundaryMesh::whichPatch(const label faceIndex) const
// To determine which patch a face was on originally.
if (Pstream::parRun())
{
// if (Pstream::myProcNo() == Pstream::masterNo())
// // {
// dictionary patchDictionary;
//
// DynamicList<word> patchNames;
//
// {
// IOobject undecomposedBoundaryHeader
// (
// "undecomposedBoundary",
// mesh_.time().constant(),
// polyMesh::meshSubDir,
// mesh_,
// IOobject::MUST_READ,
// IOobject::NO_WRITE,
// false
// );
//
// if (undecomposedBoundaryHeader.headerOk())
// {
// polyBoundaryMeshEntries undecomposedPatchEntries
// (
// undecomposedBoundaryHeader
// );
//
// forAll(undecomposedPatchEntries, patchi)
// {
// patchNames.append
// (
// undecomposedPatchEntries[patchi].keyword()
// );
//
// patchDictionary.add
// (
// undecomposedPatchEntries[patchi]
// );
// }
// }
// else
// {
// FatalErrorIn
// (
// "moleculeCloudBuildCellInteractionLists.C\n"
// )
// << "undecomposedBoundary file not found in "
// "constant/polyMesh"
// << abort(FatalError);
// }
// }
//
// labelIOList faceProcAddressing
// (
// IOobject
// (
// "faceProcAddressing",
// mesh_.time().constant(),
// polyMesh::meshSubDir,
// mesh_,
// IOobject::MUST_READ,
// IOobject::NO_WRITE,
// false
// )
// );
labelList procPatches(mesh_.globalData().processorPatches());
forAll(procPatches,pP)
{
const processorPolyPatch& patch =
refCast<const processorPolyPatch>
(
mesh_.boundaryMesh()[procPatches[pP]]
);
//
// Pout << nl << "name: " << patch.name() << nl
// << "start: " << patch.start() << nl
// << "size: " << patch.size() << nl
// << "separated: " << Switch(patch.separated()) << nl
// << "parallel: " << Switch(patch.parallel()) << nl << endl;
//
// forAll (patch, pI)
// {
// label decomposedMeshFace = patch.start() + pI;
//
// label faceProcAdd = faceProcAddressing[decomposedMeshFace];
//
// label globalFace = abs(faceProcAdd)-1;
//
// Pout << "Patch index: " << pI
// << " " << patch[pI]
// << " Mesh index: " << decomposedMeshFace
// << " faceProcAdd: " << faceProcAdd
// << " globalFace:" << globalFace;
//
// label minStart = -1;
//
// // Scanning the dictionary each time is a very ugly way of
// // finding out what patch a face originally belonged to, but
// // it proves the concept. Read the patch info a container
// // class and have a neat way of tell which patch a face is from
// // embedded in that. Split each processor face down into
// // separate lists for each different originiating patch.
//
// forAll(patchNames, patchi)
// {
// if (patchDictionary.found(patchNames[patchi]))
// {
// const dictionary& patchDict =
// patchDictionary.subDict(patchNames[patchi]);
//
// word faceName(patchNames[patchi]);
// label startFace(readLabel(patchDict.lookup("startFace")));
// label nFaces(readLabel(patchDict.lookup("nFaces")));
//
// if
// (
// minStart < 0
// || startFace < minStart
// )
// {
// minStart = startFace;
// }
//
// if
// (
// globalFace >= startFace
// && globalFace < startFace + nFaces
// )
// {
// Pout << " original patch: " << faceName << endl;
// }
// }
// }
//
// if (globalFace < minStart)
// {
// Pout << " originally an internal face" << endl;
// }
// }
//
if (patch.separated())
{
Pout << patch.separation();
}
if (!patch.parallel())
{
Pout << patch.forwardT();
}
}
// }
// else
// {
//
// }
// Get coords of my shared points
// vector sharedPoints(vector::one*(Pstream::myProcNo()+1));
// label testRedLab(Pstream::myProcNo()+1);
// Pout << testRedLab << endl;
// Append from all processors
// combineReduce(sharedPoints, plusEqOp<vector>());
// reduce(testRedLab, plusOp<label>());
// Pout << testRedLab << endl;
}

View File

@ -50,42 +50,12 @@ inline scalar moleculeCloud::potentialEnergyLimit() const
}
inline scalar moleculeCloud::guardRadius() const
{
return guardRadius_;
}
inline scalar moleculeCloud::rCutMax() const
{
return rCutMax_;
}
inline scalar moleculeCloud::rCutMaxSqr() const
{
return rCutMaxSqr_;
}
inline const List<word>& moleculeCloud::idList() const
{
return idList_;
}
inline label moleculeCloud::nPairPotentials() const
{
return pairPotentials_.size();
}
inline label moleculeCloud::nIds() const
{
return idList_.size();
}
inline const labelList& moleculeCloud::removalOrder() const
{
return removalOrder_;

View File

@ -0,0 +1,177 @@
Info<< nl << "Reading MD solution parameters:" << endl;
IOdictionary mdSolution
(
IOobject
(
"mdSolution",
mesh_.time().system(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
integrationMethod_ = integrationMethodNames_.read
(
mdSolution.lookup("integrationMethod")
);
potentialEnergyLimit_ = readScalar
(
mdSolution.lookup("potentialEnergyLimit")
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
IOdictionary potentialDict
(
IOobject
(
"potentialDict",
mesh_.time().system(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
IOdictionary idListDict
(
IOobject
(
"idList",
mesh_.time().constant(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
// ****************************************************************************
// Pair potentials
if (!potentialDict.found("pair"))
{
FatalErrorIn("moleculeCloudReadPotentials.H") << nl
<< "pair potential specification subDict not found"
<< abort(FatalError);
}
const dictionary& pairDict = potentialDict.subDict("pair");
pairPotentials_.buildPotentials(idListDict, pairDict, mesh_);
if (potentialDict.found("removalOrder"))
{
List<word> remOrd = potentialDict.lookup("removalOrder");
removalOrder_.setSize(remOrd.size());
forAll(removalOrder_, rO)
{
removalOrder_[rO] = findIndex(pairPotentials_.idList(), remOrd[rO]);
}
}
// ****************************************************************************
// Tether potentials
iterator mol(this->begin());
DynamicList<label> tetherIds;
for
(
mol = this->begin();
mol != this->end();
++mol
)
{
if (mol().tethered())
{
if (findIndex(tetherIds, mol().id()) == -1)
{
tetherIds.append
(
mol().id()
);
}
}
}
if (Pstream::parRun())
{
List< labelList > allTetherIds(Pstream::nProcs());
allTetherIds[Pstream::myProcNo()] = tetherIds;
Pstream::gatherList(allTetherIds);
if (Pstream::master())
{
DynamicList<label> globalTetherIds;
forAll(allTetherIds, procN)
{
const labelList& procNTetherIds = allTetherIds[procN];
forAll(procNTetherIds, id)
{
if (findIndex(globalTetherIds, procNTetherIds[id]) == -1)
{
globalTetherIds.append
(
procNTetherIds[id]
);
}
}
}
globalTetherIds.shrink();
tetherIds = globalTetherIds;
}
Pstream::scatter(tetherIds);
}
tetherIds.shrink();
if (tetherIds.size())
{
if (!potentialDict.found("tether"))
{
FatalErrorIn("moleculeCloudReadPotentials.H") << nl
<< "tether potential specification subDict not found"
<< abort(FatalError);
}
const dictionary& tetherDict = potentialDict.subDict("tether");
tetherPotentials_.buildPotentials(idListDict, tetherDict, tetherIds);
}
// ****************************************************************************
// External Forces
gravity_ = vector::zero;
if (potentialDict.found("external"))
{
Info << nl << "Reading external forces:" << endl;
const dictionary& externalDict = potentialDict.subDict("external");
// ************************************************************************
// gravity
if (externalDict.found("gravity"))
{
gravity_ = externalDict.lookup("gravity");
}
}
Info << nl << tab << "gravity = " << gravity_ << endl;

View File

@ -34,7 +34,7 @@ void Foam::moleculeCloud::removeHighEnergyOverlaps()
forAll(removalOrder_, rO)
{
Info << " " << idList_[removalOrder_[rO]];
Info << " " << pairPotentials_.idList()[removalOrder_[rO]];
}
Info << nl ;

View File

@ -12,6 +12,10 @@ if (pairPotentials_.rCutSqr(idI, idJ, rIJMagSq))
bool remove = false;
// Guard against pairPotentials_.energy being evaluated
// if rIJMag < SMALL. A floating point exception will
// happen otherwise.
if (rIJMag < SMALL)
{
WarningIn("moleculeCloud::removeHighEnergyOverlaps()")
@ -30,10 +34,14 @@ if (pairPotentials_.rCutSqr(idI, idJ, rIJMagSq))
remove = true;
}
// Guard against pairPotentials_.energy being evaluated
// if rIJMag < SMALL. A floating point exception will
// happen otherwise.
// if rIJMag < rMin. A tabulation lookup error will occur otherwise.
if (rIJMag < pairPotentials_.rMin(idI, idJ))
{
remove = true;
}
if (!remove)
{
@ -42,6 +50,7 @@ if (pairPotentials_.rCutSqr(idI, idJ, rIJMagSq))
pairPotentials_.energy(idI, idJ, rIJMag) > potentialEnergyLimit_
)
{
remove = true;
}
}

View File

@ -47,6 +47,10 @@
bool remove = false;
// Guard against pairPotentials_.energy being evaluated
// if rKLMag < SMALL. A floating point exception will
// happen otherwise.
if (rKLMag < SMALL)
{
WarningIn
@ -72,8 +76,12 @@
}
// Guard against pairPotentials_.energy being evaluated
// if rKLMag < SMALL. A floating point exception will
// happen otherwise.
// if rIJMag < rMin. A tubulation lookup error will occur otherwise.
if (rKLMag < pairPotentials_.rMin(idK, idL))
{
remove = true;
}
if (!remove)
{

View File

@ -75,7 +75,7 @@ bool Foam::moleculeCloud::testEdgeEdgeDistance
&& s <= 1
&& t >= 0
&& t <= 1
&& magSqr(eIs + a*s - eJs - b*t) <= rCutMaxSqr()
&& magSqr(eIs + a*s - eJs - b*t) <= pairPotentials_.rCutMaxSqr()
);
}

View File

@ -128,14 +128,14 @@ bool Foam::moleculeCloud::testPointFaceDistance
scalar perpDist((p - faceC) & faceN);
if (mag(perpDist) > rCutMax())
if (mag(perpDist) > pairPotentials_.rCutMax())
{
return false;
}
vector pointOnPlane = (p - faceN * perpDist);
if (magSqr(faceC - pointOnPlane) < rCutMaxSqr()*1e-8)
if (magSqr(faceC - pointOnPlane) < pairPotentials_.rCutMaxSqr()*1e-8)
{
// If pointOnPlane is very close to the face centre
// then defining the local axes will be inaccurate
@ -143,7 +143,7 @@ bool Foam::moleculeCloud::testPointFaceDistance
// inside the face, so return true if the points
// are in range to be safe
return (magSqr(pointOnPlane - p) <= rCutMaxSqr());
return (magSqr(pointOnPlane - p) <= pairPotentials_.rCutMaxSqr());
}
vector xAxis = (faceC - pointOnPlane)/mag(faceC - pointOnPlane);
@ -158,7 +158,7 @@ bool Foam::moleculeCloud::testPointFaceDistance
{
const vector& V(points[faceToTest[fTT]]);
if (magSqr(V-p) <= rCutMaxSqr())
if (magSqr(V-p) <= pairPotentials_.rCutMaxSqr())
{
return true;
}
@ -206,7 +206,7 @@ bool Foam::moleculeCloud::testPointFaceDistance
if (la_valid < 0)
{
// perpendicular point inside face, nearest point is pointOnPlane;
return (magSqr(pointOnPlane-p) <= rCutMaxSqr());
return (magSqr(pointOnPlane-p) <= pairPotentials_.rCutMaxSqr());
}
else
{
@ -215,7 +215,7 @@ bool Foam::moleculeCloud::testPointFaceDistance
return
(
magSqr(pointOnPlane + la_valid*(faceC - pointOnPlane) - p)
<= rCutMaxSqr()
<= pairPotentials_.rCutMaxSqr()
);
}

View File

@ -105,7 +105,7 @@ public:
//- Construct with no argument, uses default values:
// length = 1nm
// mass = 1.660538782e27kg (unified atomic mass unit)
// mass = 1.660538782e−27kg (unified atomic mass unit)
// temperature = 1K (therefore, energy = 1*kb)
reducedUnits();

View File

@ -24,9 +24,6 @@ License
\*---------------------------------------------------------------------------*/
namespace Foam
{
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline const Foam::moleculeCloud& Foam::referredCellList::molCloud()
@ -35,8 +32,4 @@ inline const Foam::moleculeCloud& Foam::referredCellList::molCloud()
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

Some files were not shown because too many files have changed in this diff Show More