Merge branch 'master' into molecularDynamics

This commit is contained in:
graham
2009-06-18 15:19:57 +01:00
1027 changed files with 54101 additions and 10907 deletions

View File

@ -6,10 +6,10 @@ set -x
wmakePrintBuild -check || /bin/rm -f OpenFOAM/Make/$WM_OPTIONS/global.? 2>/dev/null
wmakeLnInclude -f OpenFOAM
wmakeLnInclude -f OSspecific/$WM_OS
wmakeLnInclude -f OSspecific/$WM_OSTYPE
Pstream/Allwmake
wmake libo OSspecific/$WM_OS
wmake libo OSspecific/$WM_OSTYPE
wmake libso OpenFOAM
wmake libso lagrangian/basic

View File

@ -5,14 +5,14 @@ signals/sigQuit.C
regExp.C
timer.C
fileStat.C
Unix.C
POSIX.C
cpuTime/cpuTime.C
clockTime/clockTime.C
#ifndef SunOS64
printStack.C
#else
#ifdef SunOS64
dummyPrintStack.C
#else
printStack.C
#endif
LIB = $(FOAM_LIBBIN)/libOSspecific

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
UNIX versions of the functions declared in OSspecific.H
POSIX versions of the functions declared in OSspecific.H
\*---------------------------------------------------------------------------*/
@ -32,7 +32,7 @@ Description
#endif
#include "OSspecific.H"
#include "Unix.H"
#include "POSIX.H"
#include "foamVersion.H"
#include "fileName.H"
#include "fileStat.H"
@ -56,7 +56,7 @@ Description
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::Unix, 0);
defineTypeNameAndDebug(Foam::POSIX, 0);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -222,14 +222,14 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
{
// Check for user file in ~/.OpenFOAM/VERSION
fileName fullName = searchDir/FOAMversion/name;
if (exists(fullName))
if (isFile(fullName))
{
return fullName;
}
// Check for version-independent user file in ~/.OpenFOAM
fullName = searchDir/name;
if (exists(fullName))
if (isFile(fullName))
{
return fullName;
}
@ -243,14 +243,14 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
{
// Check for site file in $WM_PROJECT_INST_DIR/site/VERSION
fileName fullName = searchDir/"site"/FOAMversion/name;
if (exists(fullName))
if (isFile(fullName))
{
return fullName;
}
// Check for version-independent site file in $WM_PROJECT_INST_DIR/site
fullName = searchDir/"site"/name;
if (exists(fullName))
if (isFile(fullName))
{
return fullName;
}
@ -263,7 +263,7 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
{
// Check for shipped OpenFOAM file in $WM_PROJECT_DIR/etc
fileName fullName = searchDir/"etc"/name;
if (exists(fullName))
if (isFile(fullName))
{
return fullName;
}
@ -536,7 +536,7 @@ Foam::fileNameList Foam::readDir
// also used as increment if initial size found to be insufficient
static const int maxNnames = 100;
if (Unix::debug)
if (POSIX::debug)
{
Info<< "readDir(const fileName&, const fileType, const bool filtergz)"
<< " : reading directory " << directory << endl;
@ -557,7 +557,7 @@ Foam::fileNameList Foam::readDir
{
dirEntries.setSize(0);
if (Unix::debug)
if (POSIX::debug)
{
Info<< "readDir(const fileName&, const fileType, "
"const bool filtergz) : cannot open directory "
@ -690,7 +690,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
fileNameList contents = readDir(src, fileName::FILE, false);
forAll(contents, i)
{
if (Unix::debug)
if (POSIX::debug)
{
Info<< "Copying : " << src/contents[i]
<< " to " << destFile/contents[i] << endl;
@ -704,7 +704,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
fileNameList subdirs = readDir(src, fileName::DIRECTORY);
forAll(subdirs, i)
{
if (Unix::debug)
if (POSIX::debug)
{
Info<< "Copying : " << src/subdirs[i]
<< " to " << destFile << endl;
@ -722,7 +722,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
// Create a softlink. dst should not exist. Returns true if successful.
bool Foam::ln(const fileName& src, const fileName& dst)
{
if (Unix::debug)
if (POSIX::debug)
{
Info<< "Create softlink from : " << src << " to " << dst
<< endl;
@ -759,7 +759,7 @@ bool Foam::ln(const fileName& src, const fileName& dst)
// Rename srcFile dstFile
bool Foam::mv(const fileName& srcFile, const fileName& dstFile)
{
if (Unix::debug)
if (POSIX::debug)
{
Info<< "Move : " << srcFile << " to " << dstFile << endl;
}
@ -784,7 +784,7 @@ bool Foam::mv(const fileName& srcFile, const fileName& dstFile)
// Remove a file returning true if successful otherwise false
bool Foam::rm(const fileName& file)
{
if (Unix::debug)
if (POSIX::debug)
{
Info<< "Removing : " << file << endl;
}
@ -804,7 +804,7 @@ bool Foam::rm(const fileName& file)
// Remove a dirctory and its contents
bool Foam::rmDir(const fileName& directory)
{
if (Unix::debug)
if (POSIX::debug)
{
Info<< "rmDir(const fileName&) : "
<< "removing directory " << directory << endl;

View File

@ -23,18 +23,18 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Namespace
Foam::Unix
Foam::POSIX
Description
UNIX versions of OS-specific functions.
OS-specific functions implemented in POSIX.
SourceFiles
Unix.C
POSIX.C
\*---------------------------------------------------------------------------*/
#ifndef Unix_H
#define Unix_H
#ifndef POSIX_H
#define POSIX_H
#include "className.H"
@ -45,10 +45,10 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Unix
namespace POSIX
{
//- Declare name of the class and its debug switch
NamespaceName("Unix");
NamespaceName("POSIX");
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -177,7 +177,7 @@ Foam::sigFpe::~sigFpe()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::sigFpe::set()
void Foam::sigFpe::set(const bool verbose)
{
if (oldAction_.sa_handler)
{
@ -190,6 +190,12 @@ void Foam::sigFpe::set()
if (env("FOAM_SIGFPE"))
{
if (verbose)
{
Info<< "SigFpe : Enabling floating point exception trapping"
<< " (FOAM_SIGFPE)." << endl;
}
# ifdef LINUX_GNUC
feenableexcept
@ -240,6 +246,12 @@ void Foam::sigFpe::set()
if (env("FOAM_SETNAN"))
{
if (verbose)
{
Info<< "SetNaN : Initialising allocated memory to NaN"
<< " (FOAM_SETNAN)." << endl;
}
# ifdef LINUX_GNUC
// Set our malloc

View File

@ -107,7 +107,7 @@ public:
// Member functions
void set();
void set(const bool verbose);
};

View File

@ -81,7 +81,7 @@ Foam::sigInt::~sigInt()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::sigInt::set()
void Foam::sigInt::set(const bool verbose)
{
if (oldAction_.sa_handler)
{

View File

@ -78,7 +78,7 @@ public:
// Member functions
void set();
void set(const bool verbose);
};

View File

@ -83,7 +83,7 @@ Foam::sigQuit::~sigQuit()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::sigQuit::set()
void Foam::sigQuit::set(const bool verbose)
{
if (oldAction_.sa_handler)
{

View File

@ -78,7 +78,7 @@ public:
// Member functions
void set();
void set(const bool verbose);
};

View File

@ -83,7 +83,7 @@ Foam::sigSegv::~sigSegv()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::sigSegv::set()
void Foam::sigSegv::set(const bool verbose)
{
if (oldAction_.sa_handler)
{

View File

@ -78,7 +78,7 @@ public:
// Member functions
void set();
void set(const bool verbose);
};

View File

@ -72,6 +72,7 @@ primitiveLists = primitives/Lists
$(primitiveLists)/boolList.C
$(primitiveLists)/labelIOList.C
$(primitiveLists)/scalarList.C
$(primitiveLists)/scalarIOList.C
$(primitiveLists)/vectorList.C
$(primitiveLists)/sphericalTensorList.C
$(primitiveLists)/symmTensorList.C

View File

@ -330,6 +330,9 @@ public:
inline T& operator*();
inline T& operator()();
inline const T& operator*() const;
inline const T& operator()() const;
inline iterator& operator++();
inline iterator operator++(int);
@ -389,8 +392,8 @@ public:
inline bool operator==(const iterator&) const;
inline bool operator!=(const iterator&) const;
inline const T& operator*();
inline const T& operator()();
inline const T& operator*() const;
inline const T& operator()() const;
inline const_iterator& operator++();
inline const_iterator operator++(int);

View File

@ -220,16 +220,34 @@ inline bool Foam::HashTable<T, Key, Hash>::iterator::operator!=
template<class T, class Key, class Hash>
inline T& Foam::HashTable<T, Key, Hash>::iterator::operator*()
inline T&
Foam::HashTable<T, Key, Hash>::iterator::operator*()
{
return elmtPtr_->obj_;
}
template<class T, class Key, class Hash>
inline T& Foam::HashTable<T, Key, Hash>::iterator::operator()()
inline T&
Foam::HashTable<T, Key, Hash>::iterator::operator()()
{
return operator*();
return elmtPtr_->obj_;
}
template<class T, class Key, class Hash>
inline const T&
Foam::HashTable<T, Key, Hash>::iterator::operator*() const
{
return elmtPtr_->obj_;
}
template<class T, class Key, class Hash>
inline const T&
Foam::HashTable<T, Key, Hash>::iterator::operator()() const
{
return elmtPtr_->obj_;
}
@ -410,16 +428,18 @@ inline bool Foam::HashTable<T, Key, Hash>::const_iterator::operator!=
template<class T, class Key, class Hash>
inline const T& Foam::HashTable<T, Key, Hash>::const_iterator::operator*()
inline const T&
Foam::HashTable<T, Key, Hash>::const_iterator::operator*() const
{
return elmtPtr_->obj_;
}
#ifndef __CINT__
template<class T, class Key, class Hash>
inline const T& Foam::HashTable<T, Key, Hash>::const_iterator::operator()()
inline const T&
Foam::HashTable<T, Key, Hash>::const_iterator::operator()() const
{
return operator*();
return elmtPtr_->obj_;
}
#endif

View File

@ -241,17 +241,27 @@ public:
};
//- Read a bracket-delimited list, or handle a single value as list of size 1.
// For example,
// @code
// wList = readList<word>(IStringStream("(patch1 patch2 patch3)")());
// wList = readList<word>(IStringStream("patch0")());
// @endcode
// Mostly useful for handling command-line arguments.
template<class T>
void sort(List<T>& a);
template<class T, class Cmp>
void sort(List<T>& a, const Cmp&);
List<T> readList(Istream&);
template<class T>
void stableSort(List<T>& a);
void sort(List<T>&);
template<class T, class Cmp>
void stableSort(List<T>& a, const Cmp&);
void sort(List<T>&, const Cmp&);
template<class T>
void stableSort(List<T>&);
template<class T, class Cmp>
void stableSort(List<T>&, const Cmp&);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -131,7 +131,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
if (firstToken.pToken() != token::BEGIN_LIST)
{
FatalIOErrorIn("operator>>(Istream&, List<T>&)", is)
<< "incorrect first token, expected '(' or '{', found "
<< "incorrect first token, expected '(', found "
<< firstToken.info()
<< exit(FatalIOError);
}
@ -156,4 +156,37 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
return is;
}
template<class T>
Foam::List<T> Foam::readList(Istream& is)
{
List<T> L;
token firstToken(is);
is.putBack(firstToken);
if (firstToken.isPunctuation())
{
if (firstToken.pToken() != token::BEGIN_LIST)
{
FatalIOErrorIn("readList<T>(Istream&)", is)
<< "incorrect first token, expected '(', found "
<< firstToken.info()
<< exit(FatalIOError);
}
// read via a singly-linked list
L = SLList<T>(is);
}
else
{
// create list with a single item
L.setSize(1);
is >> L[0];
}
return L;
}
// ************************************************************************* //

View File

@ -63,6 +63,21 @@ Foam::IOPtrList<T>::IOPtrList(const IOobject& io)
}
template<class T>
Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const label s)
:
regIOobject(io),
PtrList<T>(s)
{
if (io.readOpt() != IOobject::NO_READ)
{
FatalErrorIn("IOPtrList<T>::IOPtrList(const IOobject&, const label)")
<< "NO_READ must be set if specifying size" << nl
<< exit(FatalError);
}
}
template<class T>
Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const PtrList<T>& list)
:

View File

@ -70,6 +70,9 @@ public:
//- Construct from IOobject
IOPtrList(const IOobject&);
//- Construct from IOobject with given size
IOPtrList(const IOobject&, const label);
//- Construct from IOobject and a PtrList
IOPtrList(const IOobject&, const PtrList<T>&);

View File

@ -109,20 +109,20 @@ void Foam::Time::setControls()
else
{
// Search directory for valid time directories
instantList Times = findTimes(path());
instantList timeDirs = findTimes(path());
if (startFrom == "firstTime")
{
if (Times.size())
if (timeDirs.size())
{
startTime_ = Times[0].value();
startTime_ = timeDirs[0].value();
}
}
else if (startFrom == "latestTime")
{
if (Times.size())
if (timeDirs.size())
{
startTime_ = Times[Times.size()-1].value();
startTime_ = timeDirs[timeDirs.size()-1].value();
}
}
else
@ -385,13 +385,13 @@ Foam::instantList Foam::Time::times() const
Foam::word Foam::Time::findInstancePath(const instant& t) const
{
instantList times = Time::findTimes(path());
instantList timeDirs = findTimes(path());
forAllReverse(times, i)
forAllReverse(timeDirs, timeI)
{
if (times[i] == t)
if (timeDirs[timeI] == t)
{
return times[i].name();
return timeDirs[timeI].name();
}
}
@ -401,37 +401,37 @@ Foam::word Foam::Time::findInstancePath(const instant& t) const
Foam::instant Foam::Time::findClosestTime(const scalar t) const
{
instantList times = Time::findTimes(path());
instantList timeDirs = findTimes(path());
// If there is only one time it is "constant" so return it
if (times.size() == 1)
// there is only one time (likely "constant") so return it
if (timeDirs.size() == 1)
{
return times[0];
return timeDirs[0];
}
if (t < times[1].value())
if (t < timeDirs[1].value())
{
return times[1];
return timeDirs[1];
}
else if (t > times[times.size() - 1].value())
else if (t > timeDirs[timeDirs.size()-1].value())
{
return times[times.size() - 1];
return timeDirs[timeDirs.size()-1];
}
label nearestIndex = -1;
scalar deltaT = GREAT;
for (label i=1; i < times.size(); i++)
for (label timeI=1; timeI < timeDirs.size(); ++timeI)
{
scalar diff = mag(times[i].value() - t);
scalar diff = mag(timeDirs[timeI].value() - t);
if (diff < deltaT)
{
deltaT = diff;
nearestIndex = i;
nearestIndex = timeI;
}
}
return times[nearestIndex];
return timeDirs[nearestIndex];
}
@ -440,29 +440,29 @@ Foam::instant Foam::Time::findClosestTime(const scalar t) const
//
// Foam::instant Foam::Time::findClosestTime(const scalar t) const
// {
// instantList times = Time::findTimes(path());
// label timeIndex = min(findClosestTimeIndex(times, t), 0);
// return times[timeIndex];
// instantList timeDirs = findTimes(path());
// label timeIndex = min(findClosestTimeIndex(timeDirs, t), 0);
// return timeDirs[timeIndex];
// }
Foam::label Foam::Time::findClosestTimeIndex
(
const instantList& times,
const instantList& timeDirs,
const scalar t
)
{
label nearestIndex = -1;
scalar deltaT = GREAT;
forAll (times, i)
forAll(timeDirs, timeI)
{
if (times[i].name() == "constant") continue;
if (timeDirs[timeI].name() == "constant") continue;
scalar diff = fabs(times[i].value() - t);
scalar diff = mag(timeDirs[timeI].value() - t);
if (diff < deltaT)
{
deltaT = diff;
nearestIndex = i;
nearestIndex = timeI;
}
}

View File

@ -170,7 +170,7 @@ Foam::List<Foam::instant> Foam::timeSelector::select
// determine latestTime selection (if any)
// this must appear before the -time option processing
label latestIdx = -1;
if (args.options().found("latestTime"))
if (args.optionFound("latestTime"))
{
selectTimes = false;
latestIdx = timeDirs.size() - 1;
@ -182,12 +182,12 @@ Foam::List<Foam::instant> Foam::timeSelector::select
}
}
if (args.options().found("time"))
if (args.optionFound("time"))
{
// can match 0/, but can never match constant/
selectTimes = timeSelector
(
IStringStream(args.options()["time"])()
args.optionLookup("time")()
).selected(timeDirs);
}
@ -201,13 +201,13 @@ Foam::List<Foam::instant> Foam::timeSelector::select
if (constantIdx >= 0)
{
// only add constant/ if specifically requested
selectTimes[constantIdx] = args.options().found("constant");
selectTimes[constantIdx] = args.optionFound("constant");
}
// special treatment for 0/
if (zeroIdx >= 0)
{
if (args.options().found("noZero"))
if (args.optionFound("noZero"))
{
// exclude 0/ if specifically requested
selectTimes[zeroIdx] = false;
@ -215,7 +215,7 @@ Foam::List<Foam::instant> Foam::timeSelector::select
else if (argList::validOptions.found("zeroTime"))
{
// with -zeroTime enabled, drop 0/ unless specifically requested
selectTimes[zeroIdx] = args.options().found("zeroTime");
selectTimes[zeroIdx] = args.optionFound("zeroTime");
}
}

View File

@ -85,7 +85,7 @@ class argList;
class Time;
/*---------------------------------------------------------------------------*\
Class timeSelector Declaration
Class timeSelector Declaration
\*---------------------------------------------------------------------------*/
class timeSelector
@ -136,7 +136,7 @@ public:
);
//- Return the set of times selected based on the argList options
static List<Foam::instant> select
static List<instant> select
(
const List<instant>&,
const argList& args
@ -144,7 +144,7 @@ public:
//- Return the set of times selected based on the argList options
// also set the runTime to the first instance
static List<Foam::instant> select0
static List<instant> select0
(
Time& runTime,
const argList& args

View File

@ -140,7 +140,7 @@ bool Foam::regIOobject::checkIn()
{
WarningIn("regIOobject::checkIn()")
<< "failed to register object " << objectPath()
<< " the name already exists in the objectRegistry"
<< " the name already exists in the objectRegistry"
<< endl;
}
}

View File

@ -0,0 +1,112 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#include "DynamicField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Static Members * * * * * * * * * * * * * * //
template<class Type>
const char* const DynamicField<Type>::typeName("DynamicField");
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
DynamicField<Type>::DynamicField(Istream& is)
:
Field<Type>(is),
capacity_(Field<Type>::size())
{}
template<class Type>
tmp<DynamicField<Type> > DynamicField<Type>::clone() const
{
return tmp<DynamicField<Type> >(new DynamicField<Type>(*this));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void DynamicField<Type>::setSize(const label nElem)
{
// allocate more capacity?
if (nElem > capacity_)
{
capacity_ = max(nElem, label(1 + capacity_*2));
Field<Type>::setSize(capacity_);
}
// adjust addressed size
Field<Type>::size(nElem);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * IOstream Operator * * * * * * * * * * * * * //
template<class Type>
Ostream& operator<<(Ostream& os, const DynamicField<Type>& f)
{
os << static_cast<const Field<Type>&>(f);
return os;
}
template<class Type>
Ostream& operator<<(Ostream& os, const tmp<DynamicField<Type> >& tf)
{
os << tf();
tf.clear();
return os;
}
template<class Type>
Istream& operator>>(Istream& is, DynamicField<Type>& lst)
{
is >> static_cast<Field<Type>&>(lst);
lst.capacity_ = lst.Field<Type>::size();
return is;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,227 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Class
Foam::DynamicField
Description
Dynamically sized Field. WIP.
SourceFiles
DynamicField.C
\*---------------------------------------------------------------------------*/
#ifndef DynamicField_H
#define DynamicField_H
#include "Field.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
template<class Type>
class DynamicField;
template<class Type>
Ostream& operator<<(Ostream&, const DynamicField<Type>&);
template<class Type>
Ostream& operator<<(Ostream&, const tmp<DynamicField<Type> >&);
template<class Type>
Istream& operator>>(Istream&, DynamicField<Type>&);
/*---------------------------------------------------------------------------*\
Class DynamicField Declaration
\*---------------------------------------------------------------------------*/
#include "CintDefs.H"
template<class Type>
class DynamicField
:
public Field<Type> //private Field<Type>
{
// Private data
//- The capacity (allocated size) of the underlying field.
label capacity_;
//- Construct given size and initial value
DynamicField(const label, const Type&);
//- Construct as copy of tmp<DynamicField>
# ifdef ConstructFromTmp
DynamicField(const tmp<DynamicField<Type> >&);
# endif
//- Construct from a dictionary entry
DynamicField(const word&, const dictionary&, const label);
public:
// Static data members
static const char* const typeName;
// Static Member Functions
//- Return a null field
inline static const DynamicField<Type>& null()
{
return *reinterpret_cast< DynamicField<Type>* >(0);
}
// Constructors
//- Construct null
// Used for temporary fields which are initialised after construction
DynamicField();
//- Construct given size
// Used for temporary fields which are initialised after construction
explicit inline DynamicField(const label);
//- Construct as copy of a UList\<Type\>
explicit inline DynamicField(const UList<Type>&);
//- Construct by transferring the List contents
explicit inline DynamicField(const Xfer<List<Type> >&);
//- Construct by 1 to 1 mapping from the given field
inline DynamicField
(
const UList<Type>& mapF,
const labelList& mapAddressing
);
//- Construct by interpolative mapping from the given field
inline DynamicField
(
const UList<Type>& mapF,
const labelListList& mapAddressing,
const scalarListList& weights
);
//- Construct by mapping from the given field
inline DynamicField
(
const UList<Type>& mapF,
const FieldMapper& map
);
//- Construct as copy
inline DynamicField(const DynamicField<Type>&);
//- Construct as copy or re-use as specified.
inline DynamicField(DynamicField<Type>&, bool reUse);
//- Construct by transferring the Field contents
inline DynamicField(const Xfer<DynamicField<Type> >&);
//- Construct from Istream
inline DynamicField(Istream&);
//- Clone
tmp<DynamicField<Type> > clone() const;
// Member Functions
//- Size of the underlying storage.
inline label capacity() const;
//- Append an element at the end of the list
inline void append(const Type&);
//- Alter the addressed list size.
// New space will be allocated if required.
// Use this to resize the list prior to using the operator[] for
// setting values (as per List usage).
void setSize(const label nElem);
// Member operators
inline void operator=(const DynamicField<Type>&);
inline void operator=(const UList<Type>&);
inline void operator=(const tmp<DynamicField<Type> >&);
//- Return element of Field.
inline Type& operator[](const label i);
//- Return element of constant Field.
inline const Type& operator[](const label) const;
// IOstream operators
friend Ostream& operator<<
#ifndef __CINT__
<Type>
#endif
(Ostream&, const DynamicField<Type>&);
friend Ostream& operator<<
#ifndef __CINT__
<Type>
#endif
(Ostream&, const tmp<DynamicField<Type> >&);
friend Istream& operator>>
#ifndef __CINT__
<Type>
#endif
(Istream&, DynamicField<Type>&);
};
#include "CintUndefs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "DynamicFieldI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "DynamicField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,221 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#include "DynamicField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
DynamicField<Type>::DynamicField()
:
Field<Type>(),
capacity_(0)
{}
template<class Type>
DynamicField<Type>::DynamicField(const label size)
:
Field<Type>(size),
capacity_(Field<Type>::size())
{
Field<Type>::size(0);
}
template<class Type>
inline Foam::DynamicField<Type>::DynamicField
(
const UList<Type>& lst
)
:
Field<Type>(lst),
capacity_(Field<Type>::size())
{}
template<class Type>
inline Foam::DynamicField<Type>::DynamicField
(
const Xfer<List<Type> >& lst
)
:
Field<Type>(lst),
capacity_(Field<Type>::size())
{}
template<class Type>
DynamicField<Type>::DynamicField
(
const UList<Type>& mapF,
const labelList& mapAddressing
)
:
Field<Type>(mapF, mapAddressing),
capacity_(Field<Type>::size())
{}
template<class Type>
DynamicField<Type>::DynamicField
(
const UList<Type>& mapF,
const labelListList& mapAddressing,
const scalarListList& weights
)
:
Field<Type>(mapF, mapAddressing, weights),
capacity_(Field<Type>::size())
{}
//- Construct by mapping from the given field
template<class Type>
DynamicField<Type>::DynamicField
(
const UList<Type>& mapF,
const FieldMapper& map
)
:
DynamicField<Type>(mapF, map),
capacity_(Field<Type>::size())
{}
template<class Type>
DynamicField<Type>::DynamicField(const DynamicField<Type>& f)
:
Field<Type>(f),
capacity_(Field<Type>::size())
{}
template<class Type>
DynamicField<Type>::DynamicField(DynamicField<Type>& f, bool reUse)
:
Field<Type>(f, reUse),
capacity_(Field<Type>::size())
{}
template<class Type>
DynamicField<Type>::DynamicField(const Xfer<DynamicField<Type> >& f)
:
Field<Type>(f),
capacity_(Field<Type>::size())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::label DynamicField<Type>::capacity() const
{
return capacity_;
}
template<class Type>
void DynamicField<Type>::append(const Type& t)
{
label elemI = Field<Type>::size();
setSize(elemI + 1);
this->operator[](elemI) = t;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type>
void DynamicField<Type>::operator=(const DynamicField<Type>& rhs)
{
if (this == &rhs)
{
FatalErrorIn("DynamicField<Type>::operator=(const DynamicField<Type>&)")
<< "attempted assignment to self"
<< abort(FatalError);
}
Field<Type>::operator=(rhs);
capacity_ = Field<Type>::size();
}
template<class Type>
void DynamicField<Type>::operator=(const UList<Type>& rhs)
{
Field<Type>::operator=(rhs);
capacity_ = Field<Type>::size();
}
template<class Type>
void DynamicField<Type>::operator=(const tmp<DynamicField>& rhs)
{
if (this == &(rhs()))
{
FatalErrorIn("DynamicField<Type>::operator=(const tmp<DynamicField>&)")
<< "attempted assignment to self"
<< abort(FatalError);
}
// This is dodgy stuff, don't try it at home.
DynamicField* fieldPtr = rhs.ptr();
List<Type>::transfer(*fieldPtr);
delete fieldPtr;
capacity_ = Field<Type>::size();
}
template<class Type>
Type& DynamicField<Type>::operator[](const label i)
{
return Field<Type>::operator[](i);
}
template<class Type>
const Type& DynamicField<Type>::operator[](const label i) const
{
return Field<Type>::operator[](i);
}
// * * * * * * * * * * * * * * * IOstream Operator * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -526,10 +526,10 @@ Foam::argList::argList
// Switch on signal trapping. We have to wait until after Pstream::init
// since this sets up its own ones.
sigFpe_.set();
sigInt_.set();
sigQuit_.set();
sigSegv_.set();
sigFpe_.set(bannerEnabled);
sigInt_.set(bannerEnabled);
sigQuit_.set(bannerEnabled);
sigSegv_.set(bannerEnabled);
if (Pstream::master() && bannerEnabled)
{

View File

@ -56,10 +56,10 @@ Description
global case (same for serial and parallel jobs).
Note
- Adjustment of the valid (mandatory) arguments by directly manipulating
the static member argList::validArgs.
- Adjustment of the valid options by directly manipulating
the static member argList::validOptions.
- Adjustment of the valid (mandatory) arguments
by directly manipulating the static member argList::validArgs.
- Adjustment of the valid options
by directly manipulating the static member argList::validOptions.
SourceFiles
argList.C
@ -76,6 +76,7 @@ SourceFiles
#include "word.H"
#include "fileName.H"
#include "parRun.H"
#include "IStringStream.H"
#include "sigFpe.H"
#include "sigInt.H"
@ -165,22 +166,6 @@ public:
// Access
//- Return arguments
const stringList& args() const
{
return args_;
}
//- Return additionl arguments,
// i.e. those additional to the executable itself
stringList::subList additionalArgs() const;
//- Return options
const Foam::HashTable<string>& options() const
{
return options_;
}
//- Name of executable
const word& executable() const
{
@ -211,6 +196,72 @@ public:
return rootPath()/caseName();
}
//- Return arguments
const stringList& args() const
{
return args_;
}
//- Return additionl arguments,
// i.e. those additional to the executable itself
stringList::subList additionalArgs() const;
//- Return options
const Foam::HashTable<string>& options() const
{
return options_;
}
//- Return the argument string associated with the named option
const string& option(const word& opt) const
{
return options_.operator[](opt);
}
//- Return true if the named option is found
bool optionFound(const word& opt) const
{
return options_.found(opt);
}
//- Return an IStringStream to the named option
IStringStream optionLookup(const word& opt) const
{
return IStringStream(option(opt));
}
//- Read a value from the named option
template<class T>
T optionRead(const word& opt) const
{
T val;
optionLookup(opt)() >> val;
return val;
}
//- Read a value from the named option if present.
// Return true if the named option was found.
template<class T>
bool optionReadIfPresent(const word& opt, T& val) const
{
if (optionFound(opt))
{
optionLookup(opt)() >> val;
return true;
}
else
{
return false;
}
}
//- Read a List of values from the named option
template<class T>
List<T> optionReadList(const word& opt) const
{
return readList<T>(optionLookup(opt)());
}
// Edit

View File

@ -1,6 +1,6 @@
#ifdef __CINT__
#define tmp Foam::tmp
#define UList Foam::UList
#define List Foam::List
#define InfoProxy Foam::InfoProxy
# define tmp Foam::tmp
# define UList Foam::UList
# define List Foam::List
# define InfoProxy Foam::InfoProxy
#endif

View File

@ -1,6 +1,6 @@
#ifdef __CINT__
#undef tmp
#undef UList
#undef List
#undef InfoProxy
# undef tmp
# undef UList
# undef List
# undef InfoProxy
#endif

View File

@ -26,11 +26,11 @@ InNamespace
Foam
Description
Functions used by OpenFOAM that are specific to the UNIX operating system
and need to be replaced or emulated on other systems.
Functions used by OpenFOAM that are specific to POSIX compliant
operating systems and need to be replaced or emulated on other systems.
SourceFiles
Unix.C
POSIX.C
\*---------------------------------------------------------------------------*/

View File

@ -1 +0,0 @@
argList::validOptions.insert("constant", "");

View File

@ -1 +0,0 @@
argList::validOptions.insert("latestTime", "");

View File

@ -1 +0,0 @@
argList::validOptions.insert("noZero", "");

View File

@ -1 +1,5 @@
argList::validOptions.insert("region", "name");
//
// addRegionOption.H
// ~~~~~~~~~~~~~~~~~
Foam::argList::validOptions.insert("region", "name");

View File

@ -1 +0,0 @@
argList::validOptions.insert("time", "time");

View File

@ -1,4 +1,8 @@
#include "addConstantOption.H"
#include "addTimeOption.H"
#include "addLatestTimeOption.H"
#include "addNoZeroOption.H"
//
// addTimeOptions.H
// ~~~~~~~~~~~~~~~~
Foam::argList::validOptions.insert("constant", "");
Foam::argList::validOptions.insert("latestTime", "");
Foam::argList::validOptions.insert("noZero", "");
Foam::argList::validOptions.insert("time", "time");

View File

@ -1,2 +0,0 @@
#include "addTimeOption.H"
#include "addLatestTimeOption.H"

View File

@ -1,8 +1,14 @@
//
// checkConstantOption.H
// ~~~~~~~~~~~~~~~~~~~~~
// unless -constant is present, skip startTime if it is "constant"
if
(
!args.options().found("constant")
&& Times.size() > 1
!args.optionFound("constant")
&& (startTime < Times.size()-1)
&& (Times[startTime].name() == "constant")
)
{
startTime = 1;
{
startTime++;
}

View File

@ -1,4 +0,0 @@
if (args.options().found("latestTime"))
{
startTime = Times.size() - 1;
}

View File

@ -1,7 +1,17 @@
if (args.options().found("time"))
{
scalar timeValue(readScalar(IStringStream(args.options()["time"])()));
//
// checkTimeOption.H
// ~~~~~~~~~~~~~~~~~
// check -time and -latestTime options
startTime = Time::findClosestTimeIndex(Times, timeValue);
if (args.optionFound("time"))
{
Foam::scalar timeValue = args.optionRead<scalar>("time");
startTime = Foam::Time::findClosestTimeIndex(Times, timeValue);
endTime = startTime + 1;
}
if (args.optionFound("latestTime"))
{
startTime = Times.size() - 1;
}

View File

@ -1,6 +1,12 @@
label startTime = 0;
label endTime = Times.size();
//
// checkTimeOptions.H
// ~~~~~~~~~~~~~~~~~~
Foam::label startTime = 0;
Foam::label endTime = Times.size();
// unless -constant is present, skip startTime if it is "constant"
# include "checkConstantOption.H"
// check -time and -latestTime options
# include "checkTimeOption.H"
# include "checkLatestTimeOption.H"

View File

@ -1,5 +1,9 @@
label startTime = 0;
label endTime = Times.size();
//
// checkTimeOptionsNoConstant.H
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Foam::label startTime = 0;
Foam::label endTime = Times.size();
// check -time and -latestTime options
# include "checkTimeOption.H"
# include "checkLatestTimeOption.H"

View File

@ -1,4 +1,9 @@
Foam::Info<< "Create mesh for time = "
//
// createMesh.H
// ~~~~~~~~~~~~
Foam::Info
<< "Create mesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
Foam::fvMesh mesh

View File

@ -1,13 +1,19 @@
Info<< "Create mesh, no clear-out for time = "
<< runTime.timeName() << nl << endl;
//
// createMeshNoClear.H
// ~~~~~~~~~~~~~~~~~~~
// currently identical to createMesh.H
fvMesh mesh
Foam::Info
<< "Create mesh, no clear-out for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
Foam::fvMesh mesh
(
IOobject
Foam::IOobject
(
fvMesh::defaultRegion,
Foam::fvMesh::defaultRegion,
runTime.timeName(),
runTime,
IOobject::MUST_READ
Foam::IOobject::MUST_READ
)
);

View File

@ -1,27 +1,30 @@
word regionName;
//
// createNamedMesh.H
// ~~~~~~~~~~~~~~~~~
if (args.options().found("region"))
Foam::word regionName;
if (args.optionReadIfPresent("region", regionName))
{
regionName = args.options()["region"];
Info<< "Create mesh " << regionName << " for time = "
<< runTime.timeName() << nl << endl;
Foam::Info
<< "Create mesh " << regionName << " for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
}
else
{
regionName = fvMesh::defaultRegion;
Info<< "Create mesh for time = "
<< runTime.timeName() << nl << endl;
regionName = Foam::fvMesh::defaultRegion;
Foam::Info
<< "Create mesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
}
fvMesh mesh
Foam::fvMesh mesh
(
IOobject
Foam::IOobject
(
regionName,
runTime.timeName(),
runTime,
IOobject::MUST_READ
Foam::IOobject::MUST_READ
)
);

View File

@ -1,27 +1,30 @@
word regionName;
//
// createNamedPolyMesh.H
// ~~~~~~~~~~~~~~~~~~~~~
if (args.options().found("region"))
Foam::word regionName;
if (args.optionReadIfPresent("region", regionName))
{
regionName = args.options()["region"];
Info<< "Create polyMesh " << regionName << " for time = "
<< runTime.timeName() << nl << endl;
Foam::Info
<< "Create polyMesh " << regionName << " for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
}
else
{
regionName = polyMesh::defaultRegion;
Info<< "Create polyMesh for time = "
<< runTime.timeName() << nl << endl;
regionName = Foam::polyMesh::defaultRegion;
Foam::Info
<< "Create polyMesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
}
polyMesh mesh
Foam::polyMesh mesh
(
IOobject
Foam::IOobject
(
regionName,
runTime.timeName(),
runTime,
IOobject::MUST_READ
Foam::IOobject::MUST_READ
)
);

View File

@ -1,13 +1,18 @@
Info<< "Create polyMesh for time = "
<< runTime.timeName() << nl << endl;
//
// createPolyMesh.H
// ~~~~~~~~~~~~~~~~
polyMesh mesh
Foam::Info
<< "Create polyMesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
Foam::polyMesh mesh
(
IOobject
Foam::IOobject
(
polyMesh::defaultRegion,
Foam::polyMesh::defaultRegion,
runTime.timeName(),
runTime,
IOobject::MUST_READ
Foam::IOobject::MUST_READ
)
);

View File

@ -1,3 +1,7 @@
//
// createTime.H
// ~~~~~~~~~~~~
Foam::Info<< "Create time\n" << Foam::endl;
Foam::Time runTime

View File

@ -1,6 +1,9 @@
Foam::argList args(argc, argv);
//
// setRootCase.H
// ~~~~~~~~~~~~~
if (!args.checkRootCase())
{
Foam::FatalError.exit();
}
Foam::argList args(argc, argv);
if (!args.checkRootCase())
{
Foam::FatalError.exit();
}

View File

@ -137,7 +137,7 @@ const Type& Foam::MeshObject<Mesh, Type>::New
{
if (!mesh.thisDb().objectRegistry::foundObject<Type>(Type::typeName))
{
return store(new Type(mesh, d3, d4));
return store(new Type(mesh, d1, d2, d3, d4));
}
else
{

View File

@ -84,6 +84,9 @@ public:
//- Start of procI+1 data
inline const labelList& offsets() const;
//- my local size
inline label localSize() const;
//- Global sum of localSizes
inline label size() const;

View File

@ -34,6 +34,17 @@ inline const Foam::labelList& Foam::globalIndex::offsets() const
}
inline Foam::label Foam::globalIndex::localSize() const
{
return
(
Pstream::myProcNo() == 0
? offsets_[Pstream::myProcNo()]
: offsets_[Pstream::myProcNo()] - offsets_[Pstream::myProcNo()-1]
);
}
inline Foam::label Foam::globalIndex::size() const
{
return offsets_[Pstream::nProcs()-1];

View File

@ -273,6 +273,15 @@ Foam::mapDistribute::mapDistribute
}
Foam::mapDistribute::mapDistribute(const mapDistribute& map)
:
constructSize_(map.constructSize_),
subMap_(map.subMap_),
constructMap_(map.constructMap_),
schedulePtr_()
{}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::mapDistribute::compact(const boolList& elemIsUsed)
@ -413,4 +422,24 @@ void Foam::mapDistribute::compact(const boolList& elemIsUsed)
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::mapDistribute::operator=(const mapDistribute& rhs)
{
// Check for assignment to self
if (this == &rhs)
{
FatalErrorIn
(
"Foam::mapDistribute::operator=(const Foam::mapDistribute&)"
) << "Attempted assignment to self"
<< abort(FatalError);
}
constructSize_ = rhs.constructSize_;
subMap_ = rhs.subMap_;
constructMap_ = rhs.constructMap_;
schedulePtr_.clear();
}
// ************************************************************************* //

View File

@ -81,16 +81,6 @@ class mapDistribute
mutable autoPtr<List<labelPair> > schedulePtr_;
// Private Member Functions
//- Disallow default bitwise copy construct
mapDistribute(const mapDistribute&);
//- Disallow default bitwise assignment
void operator=(const mapDistribute&);
public:
// Constructors
@ -120,6 +110,9 @@ public:
const labelList& recvProcs
);
//- Construct copy
mapDistribute(const mapDistribute&);
// Member Functions
@ -262,6 +255,11 @@ public:
"mapDistribute::updateMesh(const mapPolyMesh&)"
);
}
// Member Operators
void operator=(const mapDistribute&);
};

View File

@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
Declaration of scalar IOList containers
\*---------------------------------------------------------------------------*/
#include "scalarIOList.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTemplateTypeNameAndDebugWithName(scalarIOList, "scalarList", 0);
defineTemplateTypeNameAndDebugWithName
(
scalarListIOList,
"scalarListList",
0
);
}
// ************************************************************************* //

View File

@ -22,24 +22,30 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef
Foam::scalarIOList
Description
Scalar container classes
\*---------------------------------------------------------------------------*/
#include "Cs.H"
#include "addToRunTimeSelectionTable.H"
#ifndef scalarIOList_H
#define scalarIOList_H
#include "scalarList.H"
#include "IOList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Cs, 0);
addToRunTimeSelectionTable(solid, Cs,);
addToRunTimeSelectionTable(solid, Cs, Istream);
typedef IOList<scalar> scalarIOList;
typedef IOList<scalarList> scalarListIOList;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
#endif
// ************************************************************************* //

View File

@ -148,6 +148,7 @@ Foam::scalar Foam::autoHexMeshDriver::getMergeDistance(const scalar mergeTol)
Foam::autoHexMeshDriver::autoHexMeshDriver
(
fvMesh& mesh,
const bool overwrite,
const dictionary& dict,
const dictionary& decomposeDict
)
@ -292,6 +293,41 @@ Foam::autoHexMeshDriver::autoHexMeshDriver
meshRefinement::checkCoupledFaceZones(mesh_);
// Refinement engine
// ~~~~~~~~~~~~~~~~~
{
Info<< nl
<< "Determining initial surface intersections" << nl
<< "-----------------------------------------" << nl
<< endl;
// Main refinement engine
meshRefinerPtr_.reset
(
new meshRefinement
(
mesh,
mergeDist_, // tolerance used in sorting coordinates
overwrite,
surfaces(),
shells()
)
);
Info<< "Calculated surface intersections in = "
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
// Some stats
meshRefinerPtr_().printMeshInfo(debug_, "Initial mesh");
meshRefinerPtr_().write
(
debug_&meshRefinement::OBJINTERSECTIONS,
mesh_.time().path()/meshRefinerPtr_().timeName()
);
}
// Add all the surface regions as patches
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -319,9 +355,8 @@ Foam::autoHexMeshDriver::autoHexMeshDriver
forAll(regNames, i)
{
label patchI = meshRefinement::addPatch
label patchI = meshRefinerPtr_().addMeshedPatch
(
mesh,
regNames[i],
wallPolyPatch::typeName
);
@ -404,40 +439,6 @@ Foam::autoHexMeshDriver::autoHexMeshDriver
// Mesh distribution engine (uses tolerance to reconstruct meshes)
distributorPtr_.reset(new fvMeshDistribute(mesh_, mergeDist_));
}
// Refinement engine
// ~~~~~~~~~~~~~~~~~
{
Info<< nl
<< "Determining initial surface intersections" << nl
<< "-----------------------------------------" << nl
<< endl;
// Main refinement engine
meshRefinerPtr_.reset
(
new meshRefinement
(
mesh,
mergeDist_, // tolerance used in sorting coordinates
surfaces(),
shells()
)
);
Info<< "Calculated surface intersections in = "
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
// Some stats
meshRefinerPtr_().printMeshInfo(debug_, "Initial mesh");
meshRefinerPtr_().write
(
debug_&meshRefinement::OBJINTERSECTIONS,
mesh_.time().path()/mesh_.time().timeName()
);
}
}
@ -448,7 +449,7 @@ void Foam::autoHexMeshDriver::writeMesh(const string& msg) const
const meshRefinement& meshRefiner = meshRefinerPtr_();
meshRefiner.printMeshInfo(debug_, msg);
Info<< "Writing mesh to time " << mesh_.time().timeName() << endl;
Info<< "Writing mesh to time " << meshRefiner.timeName() << endl;
meshRefiner.write(meshRefinement::MESH|meshRefinement::SCALARLEVELS, "");
if (debug_ & meshRefinement::OBJINTERSECTIONS)
@ -456,7 +457,7 @@ void Foam::autoHexMeshDriver::writeMesh(const string& msg) const
meshRefiner.write
(
meshRefinement::OBJINTERSECTIONS,
mesh_.time().path()/mesh_.time().timeName()
mesh_.time().path()/meshRefiner.timeName()
);
}
Info<< "Written mesh in = "
@ -522,11 +523,7 @@ void Foam::autoHexMeshDriver::doMesh()
const dictionary& shrinkDict = dict_.subDict("shrinkDict");
PtrList<dictionary> surfaceDicts(dict_.lookup("surfaces"));
autoLayerDriver layerDriver
(
meshRefinerPtr_(),
globalToPatch_
);
autoLayerDriver layerDriver(meshRefinerPtr_());
// Get all the layer specific params
layerParameters layerParams

View File

@ -174,6 +174,7 @@ public:
autoHexMeshDriver
(
fvMesh& mesh,
const bool overwrite,
const dictionary& meshDict,
const dictionary& decomposeDict
);

View File

@ -75,7 +75,7 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
labelHashSet boundaryCells(mesh.nFaces()-mesh.nInternalFaces());
{
labelList patchIDs(meshRefinement::addedPatches(globalToPatch_));
labelList patchIDs(meshRefiner_.meshedPatches());
const polyBoundaryMesh& patches = mesh.boundaryMesh();
@ -159,12 +159,16 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
mesh.clearOut();
}
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
faceCombiner.updateMesh(map);
meshRefiner_.updateMesh(map, labelList(0));
for (label iteration = 0; iteration < 100; iteration++)
{
Info<< nl
@ -313,6 +317,11 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
mesh.clearOut();
}
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
faceCombiner.updateMesh(map);
// Renumber restore maps
@ -336,7 +345,7 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
if (debug)
{
Pout<< "Writing merged-faces mesh to time "
<< mesh.time().timeName() << nl << endl;
<< meshRefiner_.timeName() << nl << endl;
mesh.write();
}
}
@ -380,6 +389,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoLayerDriver::doRemovePoints
mesh.clearOut();
}
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
pointRemover.updateMesh(map);
meshRefiner_.updateMesh(map, labelList(0));
@ -433,6 +447,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoLayerDriver::doRestorePoints
mesh.clearOut();
}
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
pointRemover.updateMesh(map);
meshRefiner_.updateMesh(map, labelList(0));
@ -656,7 +675,7 @@ Foam::label Foam::autoLayerDriver::mergeEdgesUndo
if (debug)
{
Pout<< "Writing merged-edges mesh to time "
<< mesh.time().timeName() << nl << endl;
<< meshRefiner_.timeName() << nl << endl;
mesh.write();
}
}
@ -2446,14 +2465,9 @@ void Foam::autoLayerDriver::getLayerCellsFaces
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::autoLayerDriver::autoLayerDriver
(
meshRefinement& meshRefiner,
const labelList& globalToPatch
)
Foam::autoLayerDriver::autoLayerDriver(meshRefinement& meshRefiner)
:
meshRefiner_(meshRefiner),
globalToPatch_(globalToPatch)
meshRefiner_(meshRefiner)
{}
@ -2729,7 +2743,7 @@ void Foam::autoLayerDriver::addLayers
IOobject
(
"pointMedialDist",
mesh.time().timeName(),
meshRefiner_.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
@ -2744,7 +2758,7 @@ void Foam::autoLayerDriver::addLayers
IOobject
(
"dispVec",
mesh.time().timeName(),
meshRefiner_.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
@ -2759,7 +2773,7 @@ void Foam::autoLayerDriver::addLayers
IOobject
(
"medialRatio",
mesh.time().timeName(),
meshRefiner_.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
@ -2911,7 +2925,7 @@ void Foam::autoLayerDriver::addLayers
);
const_cast<Time&>(mesh.time())++;
Info<< "Writing shrunk mesh to " << mesh.time().timeName() << endl;
Info<< "Writing shrunk mesh to " << meshRefiner_.timeName() << endl;
// See comment in autoSnapDriver why we should not remove meshPhi
// using mesh.clearPout().
@ -3012,6 +3026,11 @@ void Foam::autoLayerDriver::addLayers
//?neccesary? Update fields
newMesh.updateMesh(map);
if (meshRefiner_.overwrite())
{
newMesh.setInstance(meshRefiner_.oldInstance());
}
// Update numbering on addLayer:
// - cell/point labels to be newMesh.
// - patchFaces to remain in oldMesh order.
@ -3034,7 +3053,7 @@ void Foam::autoLayerDriver::addLayers
if (debug)
{
Info<< "Writing layer mesh to " << mesh.time().timeName() << endl;
Info<< "Writing layer mesh to " << meshRefiner_.timeName() << endl;
newMesh.write();
cellSet addedCellSet
(
@ -3113,6 +3132,11 @@ void Foam::autoLayerDriver::addLayers
mesh.clearOut();
}
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
meshRefiner_.updateMesh(map, labelList(0));
@ -3181,8 +3205,6 @@ void Foam::autoLayerDriver::doLayers
<< "----------------------------------" << nl
<< endl;
const_cast<Time&>(mesh.time())++;
Info<< "Using mesh parameters " << motionDict << nl << endl;
// Merge coplanar boundary faces

View File

@ -101,9 +101,6 @@ class autoLayerDriver
//- Mesh+surface
meshRefinement& meshRefiner_;
//- From surface region to patch
const labelList globalToPatch_;
// Private Member Functions
@ -509,11 +506,7 @@ public:
// Constructors
//- Construct from components
autoLayerDriver
(
meshRefinement& meshRefiner,
const labelList& globalToPatch
);
autoLayerDriver(meshRefinement& meshRefiner);
// Member Functions

View File

@ -344,8 +344,8 @@ void Foam::autoRefineDriver::removeInsideCells
if (debug)
{
Pout<< "Writing subsetted mesh to time "
<< mesh.time().timeName() << '.' << endl;
meshRefiner_.write(debug, mesh.time().path()/mesh.time().timeName());
<< meshRefiner_.timeName() << '.' << endl;
meshRefiner_.write(debug, mesh.time().path()/meshRefiner_.timeName());
Pout<< "Dumped mesh in = "
<< mesh.time().cpuTimeIncrement() << " s\n" << nl << endl;
}
@ -561,11 +561,11 @@ void Foam::autoRefineDriver::zonify
if (debug)
{
Pout<< "Writing zoned mesh to time "
<< mesh.time().timeName() << '.' << endl;
<< meshRefiner_.timeName() << '.' << endl;
meshRefiner_.write
(
debug,
mesh.time().path()/mesh.time().timeName()
mesh.time().path()/meshRefiner_.timeName()
);
}
@ -653,8 +653,8 @@ void Foam::autoRefineDriver::splitAndMergeBaffles
if (debug)
{
Pout<< "Writing handleProblemCells mesh to time "
<< mesh.time().timeName() << '.' << endl;
meshRefiner_.write(debug, mesh.time().path()/mesh.time().timeName());
<< meshRefiner_.timeName() << '.' << endl;
meshRefiner_.write(debug, mesh.time().path()/meshRefiner_.timeName());
}
}
@ -680,7 +680,7 @@ void Foam::autoRefineDriver::mergePatchFaces
(
Foam::cos(45*mathematicalConstant::pi/180.0),
Foam::cos(45*mathematicalConstant::pi/180.0),
meshRefinement::addedPatches(globalToPatch_)
meshRefiner_.meshedPatches()
);
if (debug)
@ -712,9 +712,6 @@ void Foam::autoRefineDriver::doRefine
const fvMesh& mesh = meshRefiner_.mesh();
const_cast<Time&>(mesh.time())++;
// Check that all the keep points are inside the mesh.
refineParams.findCells(mesh);

View File

@ -557,7 +557,7 @@ Foam::tmp<Foam::scalarField> Foam::autoSnapDriver::edgePatchDist
// IOobject
// (
// "pointDist",
// mesh.DB().timeName(),
// meshRefiner_.timeName(),
// mesh.DB(),
// IOobject::NO_READ,
// IOobject::AUTO_WRITE
@ -580,7 +580,7 @@ Foam::tmp<Foam::scalarField> Foam::autoSnapDriver::edgePatchDist
// pointDist[pointI] /= mesh.pointEdges()[pointI].size();
// }
// Info<< "Writing patch distance to " << pointDist.name()
// << " at time " << mesh.DB().timeName() << endl;
// << " at time " << meshRefiner_.timeName() << endl;
//
// pointDist.write();
//}
@ -750,7 +750,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoSnapDriver::createZoneBaffles
{
const_cast<Time&>(mesh.time())++;
Pout<< "Writing baffled mesh to time "
<< mesh.time().timeName() << endl;
<< meshRefiner_.timeName() << endl;
mesh.write();
}
}
@ -830,35 +830,6 @@ Foam::scalarField Foam::autoSnapDriver::calcSnapDistance
}
//// Invert globalToPatch_ to get the patches related to surfaces.
//Foam::labelList Foam::autoSnapDriver::getSurfacePatches() const
//{
// // Set of patches originating from surface
// labelHashSet surfacePatchSet(globalToPatch_.size());
//
// forAll(globalToPatch_, i)
// {
// if (globalToPatch_[i] != -1)
// {
// surfacePatchSet.insert(globalToPatch_[i]);
// }
// }
//
// const fvMesh& mesh = meshRefiner_.mesh();
//
// DynamicList<label> surfacePatches(surfacePatchSet.size());
//
// for (label patchI = 0; patchI < mesh.boundaryMesh().size(); patchI++)
// {
// if (surfacePatchSet.found(patchI))
// {
// surfacePatches.append(patchI);
// }
// }
// return surfacePatches.shrink();
//}
void Foam::autoSnapDriver::preSmoothPatch
(
const snapParameters& snapParams,
@ -928,7 +899,7 @@ void Foam::autoSnapDriver::preSmoothPatch
if (debug)
{
const_cast<Time&>(mesh.time())++;
Pout<< "Writing patch smoothed mesh to time " << mesh.time().timeName()
Pout<< "Writing patch smoothed mesh to time " << meshRefiner_.timeName()
<< endl;
mesh.write();
@ -1222,7 +1193,7 @@ void Foam::autoSnapDriver::smoothDisplacement
if (debug)
{
const_cast<Time&>(mesh.time())++;
Pout<< "Writing smoothed mesh to time " << mesh.time().timeName()
Pout<< "Writing smoothed mesh to time " << meshRefiner_.timeName()
<< endl;
// Moving mesh creates meshPhi. Can be cleared out by a mesh.clearOut
@ -1284,7 +1255,7 @@ void Foam::autoSnapDriver::scaleMesh
if (debug)
{
const_cast<Time&>(mesh.time())++;
Pout<< "Writing scaled mesh to time " << mesh.time().timeName()
Pout<< "Writing scaled mesh to time " << meshRefiner_.timeName()
<< endl;
mesh.write();
@ -1476,10 +1447,8 @@ void Foam::autoSnapDriver::doSnap
<< "--------------" << nl
<< endl;
const_cast<Time&>(mesh.time())++;
// Get the labels of added patches.
labelList adaptPatchIDs(meshRefinement::addedPatches(globalToPatch_));
labelList adaptPatchIDs(meshRefiner_.meshedPatches());
// Create baffles (pairs of faces that share the same points)
// Baffles stored as owner and neighbour face that have been created.

View File

@ -170,9 +170,6 @@ public:
const indirectPrimitivePatch&
) const;
////- Get patches generated for surfaces.
//labelList getSurfacePatches() const;
//- Smooth the mesh (patch and internal) to increase visibility
// of surface points (on castellated mesh) w.r.t. surface.
void preSmoothPatch

View File

@ -84,12 +84,15 @@ void Foam::meshRefinement::calcNeighbourData
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
labelHashSet addedPatchIDSet(meshedPatches());
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
const unallocLabelList& faceCells = pp.faceCells();
const vectorField::subField faceCentres = pp.faceCentres();
const vectorField::subField faceAreas = pp.faceAreas();
label bFaceI = pp.start()-mesh_.nInternalFaces();
@ -102,6 +105,36 @@ void Foam::meshRefinement::calcNeighbourData
bFaceI++;
}
}
else if (addedPatchIDSet.found(patchI))
{
// Face was introduced from cell-cell intersection. Try to
// reconstruct other side cell(centre). Three possibilities:
// - cells same size.
// - preserved cell smaller. Not handled.
// - preserved cell larger.
forAll(faceCells, i)
{
// Extrapolate the face centre.
vector fn = faceAreas[i];
fn /= mag(fn)+VSMALL;
label own = faceCells[i];
label ownLevel = cellLevel[own];
label faceLevel = meshCutter_.getAnchorLevel(pp.start()+i);
// Normal distance from face centre to cell centre
scalar d = ((faceCentres[i] - cellCentres[own]) & fn);
if (faceLevel > ownLevel)
{
// Other cell more refined. Adjust normal distance
d *= 0.5;
}
neiLevel[bFaceI] = cellLevel[ownLevel];
// Calculate other cell centre by extrapolation
neiCc[bFaceI] = faceCentres[i] + d*fn;
bFaceI++;
}
}
else
{
forAll(faceCells, i)
@ -432,6 +465,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::doRemoveCells
mesh_.clearOut();
}
if (overwrite_)
{
mesh_.setInstance(oldInstance_);
}
// Update local mesh data
cellRemover.updateMesh(map);
@ -784,12 +822,15 @@ Foam::meshRefinement::meshRefinement
(
fvMesh& mesh,
const scalar mergeDistance,
const bool overwrite,
const refinementSurfaces& surfaces,
const shellSurfaces& shells
)
:
mesh_(mesh),
mergeDistance_(mergeDistance),
overwrite_(overwrite),
oldInstance_(mesh.pointsInstance()),
surfaces_(surfaces),
shells_(shells),
meshCutter_
@ -1166,8 +1207,6 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
// Helper function to get intersected faces
Foam::labelList Foam::meshRefinement::intersectedFaces() const
{
// Mark all faces that will become baffles
label nBoundaryFaces = 0;
forAll(surfaceIndex_, faceI)
@ -1193,10 +1232,7 @@ Foam::labelList Foam::meshRefinement::intersectedFaces() const
// Helper function to get points used by faces
Foam::labelList Foam::meshRefinement::intersectedPoints
(
// const labelList& globalToPatch
) const
Foam::labelList Foam::meshRefinement::intersectedPoints() const
{
const faceList& faces = mesh_.faces();
@ -1221,9 +1257,10 @@ Foam::labelList Foam::meshRefinement::intersectedPoints
}
//// Insert all meshed patches.
//forAll(globalToPatch, i)
//labelList adaptPatchIDs(meshedPatches());
//forAll(adaptPatchIDs, i)
//{
// label patchI = globalToPatch[i];
// label patchI = adaptPatchIDs[i];
//
// if (patchI != -1)
// {
@ -1262,27 +1299,6 @@ Foam::labelList Foam::meshRefinement::intersectedPoints
}
Foam::labelList Foam::meshRefinement::addedPatches
(
const labelList& globalToPatch
)
{
labelList patchIDs(globalToPatch.size());
label addedI = 0;
forAll(globalToPatch, i)
{
if (globalToPatch[i] != -1)
{
patchIDs[addedI++] = globalToPatch[i];
}
}
patchIDs.setSize(addedI);
return patchIDs;
}
//- Create patch from set of patches
Foam::autoPtr<Foam::indirectPrimitivePatch> Foam::meshRefinement::makePatch
(
@ -1372,7 +1388,7 @@ Foam::tmp<Foam::pointVectorField> Foam::meshRefinement::makeDisplacementField
IOobject
(
"pointDisplacement",
mesh.time().timeName(),
mesh.time().timeName(), //timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
@ -1653,6 +1669,53 @@ Foam::label Foam::meshRefinement::addPatch
}
Foam::label Foam::meshRefinement::addMeshedPatch
(
const word& name,
const word& type
)
{
label meshedI = findIndex(meshedPatches_, name);
if (meshedI != -1)
{
// Already there. Get corresponding polypatch
return mesh_.boundaryMesh().findPatchID(name);
}
else
{
// Add patch
label patchI = addPatch(mesh_, name, type);
// Store
label sz = meshedPatches_.size();
meshedPatches_.setSize(sz+1);
meshedPatches_[sz] = name;
return patchI;
}
}
Foam::labelList Foam::meshRefinement::meshedPatches() const
{
labelList patchIDs(meshedPatches_.size());
forAll(meshedPatches_, i)
{
patchIDs[i] = mesh_.boundaryMesh().findPatchID(meshedPatches_[i]);
if (patchIDs[i] == -1)
{
FatalErrorIn("meshRefinement::meshedPatches() const")
<< "Problem : did not find patch " << meshedPatches_[i]
<< abort(FatalError);
}
}
return patchIDs;
}
Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMeshRegions
(
const point& keepPoint
@ -2000,6 +2063,20 @@ void Foam::meshRefinement::printMeshInfo(const bool debug, const string& msg)
}
//- Return either time().constant() or oldInstance
Foam::word Foam::meshRefinement::timeName() const
{
if (overwrite_ && mesh_.time().timeIndex() == 0)
{
return oldInstance_;
}
else
{
return mesh_.time().timeName();
}
}
void Foam::meshRefinement::dumpRefinementLevel() const
{
volScalarField volRefLevel
@ -2007,7 +2084,7 @@ void Foam::meshRefinement::dumpRefinementLevel() const
IOobject
(
"cellLevel",
mesh_.time().timeName(),
timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
@ -2034,7 +2111,7 @@ void Foam::meshRefinement::dumpRefinementLevel() const
IOobject
(
"pointLevel",
mesh_.time().timeName(),
timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,

View File

@ -110,6 +110,12 @@ private:
//- tolerance used for sorting coordinates (used in 'less' routine)
const scalar mergeDistance_;
//- overwrite the mesh?
const bool overwrite_;
//- Instance of mesh upon construction. Used when in overwrite_ mode.
const word oldInstance_;
//- All surface-intersection interaction
const refinementSurfaces& surfaces_;
@ -125,6 +131,10 @@ private:
//- user supplied face based data.
List<Tuple2<mapType, labelList> > userFaceData_;
//- Meshed patches - are treated differently. Stored as wordList since
// order changes.
wordList meshedPatches_;
// Private Member Functions
@ -163,9 +173,6 @@ private:
//- Find any intersection of surface. Store in surfaceIndex_.
void updateIntersections(const labelList& changedFaces);
//- Set instance of all local IOobjects
void setInstance(const fileName&);
//- Remove cells. Put exposedFaces into exposedPatchIDs.
autoPtr<mapPolyMesh> doRemoveCells
(
@ -400,12 +407,11 @@ private:
const labelList& globalToPatch
) const;
//- Initial test of marking faces using geometric information.
labelList markFacesOnProblemCellsGeometric
(
const dictionary& motionDict,
const labelList& globalToPatch
) const;
////- Initial test of marking faces using geometric information.
//labelList markFacesOnProblemCellsGeometric
//(
// const dictionary& motionDict
//) const;
// Baffle merging
@ -475,6 +481,7 @@ public:
(
fvMesh& mesh,
const scalar mergeDistance,
const bool overwrite,
const refinementSurfaces&,
const shellSurfaces&
);
@ -499,6 +506,18 @@ public:
return mergeDistance_;
}
//- Overwrite the mesh?
bool overwrite() const
{
return overwrite_;
}
//- (points)instance of mesh upon construction
const word& oldInstance() const
{
return oldInstance_;
}
//- reference to surface search engines
const refinementSurfaces& surfaces() const
{
@ -578,9 +597,6 @@ public:
//- Get points on surfaces with intersection and boundary faces.
labelList intersectedPoints() const;
//- Get added patches (inverse of globalToPatch)
static labelList addedPatches(const labelList& globalToPatch);
//- Create patch from set of patches
static autoPtr<indirectPrimitivePatch> makePatch
(
@ -688,9 +704,16 @@ public:
// Other topo changes
//- Helper function to add patch to mesh
//- Helper:add patch to mesh. Update all registered fields.
// Use addMeshedPatch to add patches originating from surfaces.
static label addPatch(fvMesh&, const word& name, const word& type);
//- Add patch originating from meshing. Update meshedPatches_.
label addMeshedPatch(const word& name, const word& type);
//- Get patchIDs for patches added in addMeshedPatch.
labelList meshedPatches() const;
//- Split mesh. Keep part containing point.
autoPtr<mapPolyMesh> splitMeshRegions(const point& keepPoint);
@ -699,7 +722,11 @@ public:
//- Update for external change to mesh. changedFaces are in new mesh
// face labels.
void updateMesh(const mapPolyMesh&, const labelList& changedFaces);
void updateMesh
(
const mapPolyMesh&,
const labelList& changedFaces
);
// Restoring : is where other processes delete and reinsert data.
@ -757,6 +784,13 @@ public:
//- Print some mesh stats.
void printMeshInfo(const bool, const string&) const;
//- Replacement for Time::timeName() : return oldInstance (if
// overwrite_)
word timeName() const;
//- Set instance of all local IOobjects
void setInstance(const fileName&);
//- Write mesh and all data
bool write() const;

View File

@ -226,7 +226,13 @@ void Foam::meshRefinement::getBafflePatches
label vertI = 0;
if (debug&OBJINTERSECTIONS)
{
str.reset(new OFstream(mesh_.time().timePath()/"intersections.obj"));
str.reset
(
new OFstream
(
mesh_.time().path()/timeName()/"intersections.obj"
)
);
Pout<< "getBafflePatches : Writing surface intersections to file "
<< str().name() << nl << endl;
@ -461,6 +467,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::createBaffles
mesh_.clearOut();
}
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
//- Redo the intersections on the newly create baffle faces. Note that
// this changes also the cell centre positions.
faceSet baffledFacesSet(mesh_, "baffledFacesSet", 2*nBaffles);
@ -820,6 +831,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::mergeBaffles
mesh_.clearOut();
}
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
// Update intersections. Recalculate intersections on merged faces since
// this seems to give problems? Note: should not be nessecary since
// baffles preserve intersections from when they were created.
@ -1482,7 +1498,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
if (debug)
{
Pout<< "Writing baffled mesh to time " << mesh_.time().timeName()
Pout<< "Writing baffled mesh to time " << timeName()
<< endl;
write(debug, runTime.path()/"baffles");
Pout<< "Dumped debug data in = "
@ -1511,11 +1527,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
perpendicularAngle,
globalToPatch
)
//markFacesOnProblemCellsGeometric
//(
// motionDict,
// globalToPatch
//)
//markFacesOnProblemCellsGeometric(motionDict)
);
Info<< "Analyzed problem cells in = "
<< runTime.cpuTimeIncrement() << " s\n" << nl << endl;
@ -1569,7 +1581,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
if (debug)
{
Pout<< "Writing extra baffled mesh to time "
<< mesh_.time().timeName() << endl;
<< timeName() << endl;
write(debug, runTime.path()/"extraBaffles");
Pout<< "Dumped debug data in = "
<< runTime.cpuTimeIncrement() << " s\n" << nl << endl;
@ -1604,9 +1616,9 @@ void Foam::meshRefinement::baffleAndSplitMesh
if (debug)
{
Pout<< "Writing subsetted mesh to time " << mesh_.time().timeName()
Pout<< "Writing subsetted mesh to time " << timeName()
<< endl;
write(debug, runTime.timePath());
write(debug, runTime.path()/timeName());
Pout<< "Dumped debug data in = "
<< runTime.cpuTimeIncrement() << " s\n" << nl << endl;
}
@ -1665,7 +1677,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
// Split off (with optional buffer layers) unreachable areas of mesh.
Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
(
const label nBufferLayers,
const labelList& globalToPatch,
@ -1998,6 +2010,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::dupNonManifoldPoints()
mesh_.clearOut();
}
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
// Update intersections. Is mapping only (no faces created, positions stay
// same) so no need to recalculate intersections.
updateMesh(map, labelList(0));
@ -2429,6 +2446,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
mesh_.clearOut();
}
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
// None of the faces has changed, only the zones. Still...
updateMesh(map, labelList());

View File

@ -29,10 +29,6 @@ License
#include "polyTopoChange.H"
#include "removePoints.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Merge faces that are in-line.
@ -108,6 +104,11 @@ Foam::label Foam::meshRefinement::mergePatchFaces
mesh_.clearOut();
}
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
faceCombiner.updateMesh(map);
// Get the kept faces that need to be recalculated.
@ -203,6 +204,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::mergeEdges
mesh_.clearOut();
}
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
pointRemover.updateMesh(map);
// Get the kept faces that need to be recalculated.

View File

@ -136,15 +136,13 @@ Foam::Map<Foam::label> Foam::meshRefinement::findEdgeConnectedProblemCells
const labelList& globalToPatch
) const
{
labelList adaptPatchIDs(meshRefinement::addedPatches(globalToPatch));
// Construct addressing engine.
// Construct addressing engine from all patches added for meshing.
autoPtr<indirectPrimitivePatch> ppPtr
(
meshRefinement::makePatch
(
mesh_,
adaptPatchIDs
meshedPatches()
)
);
const indirectPrimitivePatch& pp = ppPtr();
@ -386,11 +384,6 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
const labelList& pointLevel = meshCutter_.pointLevel();
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
// Swap neighbouring cell centres and cell level
labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
calcNeighbourData(neiLevel, neiCc);
// Per internal face (boundary faces not used) the patch that the
// baffle should get (or -1)
labelList facePatch(mesh_.nFaces(), -1);
@ -403,7 +396,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
// Fill boundary data. All elements on meshed patches get marked.
// Get the labels of added patches.
labelList adaptPatchIDs(meshRefinement::addedPatches(globalToPatch));
labelList adaptPatchIDs(meshedPatches());
forAll(adaptPatchIDs, i)
{
@ -427,6 +420,12 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
}
}
// Swap neighbouring cell centres and cell level
labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
calcNeighbourData(neiLevel, neiCc);
// Count of faces marked for baffling
label nBaffleFaces = 0;
@ -961,20 +960,16 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
//// test to find nearest surface and checks which faces would get squashed.
//Foam::labelList Foam::meshRefinement::markFacesOnProblemCellsGeometric
//(
// const dictionary& motionDict,
// const labelList& globalToPatch
// const dictionary& motionDict
//) const
//{
// // Get the labels of added patches.
// labelList adaptPatchIDs(meshRefinement::addedPatches(globalToPatch));
//
// // Construct addressing engine.
// autoPtr<indirectPrimitivePatch> ppPtr
// (
// meshRefinement::makePatch
// (
// mesh_,
// adaptPatchIDs
// meshedPatches()
// )
// );
// const indirectPrimitivePatch& pp = ppPtr();

View File

@ -1232,6 +1232,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::refine
mesh_.clearOut();
}
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
// Update intersection info
updateMesh(map, getChangedFaces(map, cellsToRefine));
@ -1256,12 +1261,12 @@ Foam::meshRefinement::refineAndBalance
if (debug)
{
Pout<< "Writing refined but unbalanced " << msg
<< " mesh to time " << mesh_.time().timeName() << endl;
<< " mesh to time " << timeName() << endl;
write
(
debug,
mesh_.time().path()
/mesh_.time().timeName()
/timeName()
);
Pout<< "Dumped debug data in = "
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
@ -1299,12 +1304,11 @@ Foam::meshRefinement::refineAndBalance
if (debug)
{
Pout<< "Writing balanced " << msg
<< " mesh to time " << mesh_.time().timeName() << endl;
<< " mesh to time " << timeName() << endl;
write
(
debug,
mesh_.time().path()
/mesh_.time().timeName()
mesh_.time().path()/timeName()
);
Pout<< "Dumped debug data in = "
<< mesh_.time().cpuTimeIncrement() << " s" << endl;

View File

@ -115,6 +115,28 @@ bool Foam::trackedParticle::move(trackedParticle::trackData& td)
}
bool Foam::trackedParticle::hitPatch
(
const polyPatch&,
trackedParticle::trackData& td,
const label patchI
)
{
return false;
}
bool Foam::trackedParticle::hitPatch
(
const polyPatch&,
int&,
const label
)
{
return false;
}
void Foam::trackedParticle::hitWedgePatch
(
const wedgePolyPatch&,

View File

@ -169,6 +169,21 @@ public:
bool move(trackData&);
//- Overridable function to handle the particle hitting a patch
// Executed before other patch-hitting functions
bool hitPatch
(
const polyPatch&,
trackedParticle::trackData& td,
const label patchI
);
bool hitPatch
(
const polyPatch&,
int&,
const label patchI
);
//- Overridable function to handle the particle hitting a wedge
void hitWedgePatch
(

View File

@ -75,6 +75,24 @@ extern "C"
}
// Hack: scotch generates floating point errors so need to switch of error
// trapping!
#if defined(linux) || defined(linuxAMD64) || defined(linuxIA64)
# define LINUX
#endif
#if defined(LINUX) && defined(__GNUC__)
# define LINUX_GNUC
#endif
#ifdef LINUX_GNUC
# ifndef __USE_GNU
# define __USE_GNU
# endif
# include <fenv.h>
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
@ -113,13 +131,30 @@ Foam::label Foam::scotchDecomp::decompose
{
// Strategy
// ~~~~~~~~
// Default.
SCOTCH_Strat stradat;
check(SCOTCH_stratInit(&stradat), "SCOTCH_stratInit");
//SCOTCH_stratGraphMap(&stradat, &argv[i][2]);
//fprintf(stdout, "S\tStrat=");
//SCOTCH_stratSave(&stradat, stdout);
//fprintf(stdout, "\n");
if (decompositionDict_.found("scotchCoeffs"))
{
const dictionary& scotchCoeffs =
decompositionDict_.subDict("scotchCoeffs");
string strategy;
if (scotchCoeffs.readIfPresent("strategy", strategy))
{
if (debug)
{
Info<< "scotchDecomp : Using strategy " << strategy << endl;
}
SCOTCH_stratGraphMap(&stradat, strategy.c_str());
//fprintf(stdout, "S\tStrat=");
//SCOTCH_stratSave(&stradat, stdout);
//fprintf(stdout, "\n");
}
}
// Graph
@ -153,37 +188,40 @@ Foam::label Foam::scotchDecomp::decompose
const dictionary& scotchCoeffs =
decompositionDict_.subDict("scotchCoeffs");
Switch writeGraph(scotchCoeffs.lookup("writeGraph"));
if (writeGraph)
if (scotchCoeffs.found("writeGraph"))
{
OFstream str(mesh_.time().path() / mesh_.name() + ".grf");
Switch writeGraph(scotchCoeffs.lookup("writeGraph"));
Info<< "Dumping Scotch graph file to " << str.name() << endl
<< "Use this in combination with gpart." << endl;
label version = 0;
str << version << nl;
// Numer of vertices
str << xadj.size()-1 << ' ' << adjncy.size() << nl;
// Numbering starts from 0
label baseval = 0;
// Has weights?
label hasEdgeWeights = 0;
label hasVertexWeights = 0;
label numericflag = 10*hasEdgeWeights+hasVertexWeights;
str << baseval << ' ' << numericflag << nl;
for (label cellI = 0; cellI < xadj.size()-1; cellI++)
if (writeGraph)
{
label start = xadj[cellI];
label end = xadj[cellI+1];
str << end-start;
OFstream str(mesh_.time().path() / mesh_.name() + ".grf");
for (label i = start; i < end; i++)
Info<< "Dumping Scotch graph file to " << str.name() << endl
<< "Use this in combination with gpart." << endl;
label version = 0;
str << version << nl;
// Numer of vertices
str << xadj.size()-1 << ' ' << adjncy.size() << nl;
// Numbering starts from 0
label baseval = 0;
// Has weights?
label hasEdgeWeights = 0;
label hasVertexWeights = 0;
label numericflag = 10*hasEdgeWeights+hasVertexWeights;
str << baseval << ' ' << numericflag << nl;
for (label cellI = 0; cellI < xadj.size()-1; cellI++)
{
str << ' ' << adjncy[i];
label start = xadj[cellI];
label end = xadj[cellI+1];
str << end-start;
for (label i = start; i < end; i++)
{
str << ' ' << adjncy[i];
}
str << nl;
}
str << nl;
}
}
}
@ -195,12 +233,36 @@ Foam::label Foam::scotchDecomp::decompose
SCOTCH_Arch archdat;
check(SCOTCH_archInit(&archdat), "SCOTCH_archInit");
check
(
// SCOTCH_archCmpltw for weighted.
SCOTCH_archCmplt(&archdat, nProcessors_),
"SCOTCH_archCmplt"
);
List<label> processorWeights;
if (decompositionDict_.found("scotchCoeffs"))
{
const dictionary& scotchCoeffs =
decompositionDict_.subDict("scotchCoeffs");
scotchCoeffs.readIfPresent("processorWeights", processorWeights);
}
if (processorWeights.size())
{
if (debug)
{
Info<< "scotchDecomp : Using procesor weights " << processorWeights
<< endl;
}
check
(
SCOTCH_archCmpltw(&archdat, nProcessors_, processorWeights.begin()),
"SCOTCH_archCmpltw"
);
}
else
{
check
(
SCOTCH_archCmplt(&archdat, nProcessors_),
"SCOTCH_archCmplt"
);
}
//SCOTCH_Mapping mapdat;
@ -209,6 +271,16 @@ Foam::label Foam::scotchDecomp::decompose
//SCOTCH_graphMapExit(&grafdat, &mapdat);
// Hack:switch off fpu error trapping
# ifdef LINUX_GNUC
int oldExcepts = fedisableexcept
(
FE_DIVBYZERO
| FE_INVALID
| FE_OVERFLOW
);
# endif
finalDecomp.setSize(xadj.size()-1);
finalDecomp = 0;
check
@ -223,6 +295,11 @@ Foam::label Foam::scotchDecomp::decompose
"SCOTCH_graphMap"
);
# ifdef LINUX_GNUC
feenableexcept(oldExcepts);
# endif
//finalDecomp.setSize(xadj.size()-1);
//check

View File

@ -185,8 +185,6 @@ class hexRef8
const bool searchForward,
const label wantedLevel
) const;
//- Gets level such that the face has four points <= level.
label getAnchorLevel(const label faceI) const;
////- Print levels of list of points.
//void printLevels(Ostream&, const labelList&) const;
@ -370,6 +368,9 @@ public:
// Refinement
//- Gets level such that the face has four points <= level.
label getAnchorLevel(const label faceI) const;
//- Given valid mesh and current cell level and proposed
// cells to refine calculate any clashes (due to 2:1) and return
// ok list of cells to refine.

View File

@ -383,6 +383,35 @@ void Foam::polyTopoChange::checkFace
<< " own:" << own << " nei:" << nei
<< " patchI:" << patchI << abort(FatalError);
}
if (faceI >= 0 && faceI < faces_.size() && faceRemoved(faceI))
{
FatalErrorIn
(
"polyTopoChange::checkFace(const face&, const label"
", const label, const label, const label)"
) << "Face already marked for removal"
<< nl
<< "f:" << f
<< " faceI(-1 if added face):" << faceI
<< " own:" << own << " nei:" << nei
<< " patchI:" << patchI << abort(FatalError);
}
forAll(f, fp)
{
if (f[fp] < points_.size() && pointRemoved(f[fp]))
{
FatalErrorIn
(
"polyTopoChange::checkFace(const face&, const label"
", const label, const label, const label)"
) << "Face uses removed vertices"
<< nl
<< "f:" << f
<< " faceI(-1 if added face):" << faceI
<< " own:" << own << " nei:" << nei
<< " patchI:" << patchI << abort(FatalError);
}
}
}

View File

@ -39,26 +39,41 @@ fvMeshMapper = fvMesh/fvMeshMapper
$(fvMeshMapper)/fvPatchMapper.C
$(fvMeshMapper)/fvSurfaceMapper.C
extendedStencil = fvMesh/extendedStencil
$(extendedStencil)/extendedStencil.C
$(extendedStencil)/extendedUpwindStencil.C
$(extendedStencil)/extendedCentredStencil.C
$(extendedStencil)/faceStencil/faceStencil.C
$(extendedStencil)/faceStencil/faceEdgeCellStencil.C
$(extendedStencil)/faceStencil/cellFaceCellStencil.C
$(extendedStencil)/faceStencil/cellPointCellStencil.C
$(extendedStencil)/faceStencil/cellEdgeCellStencil.C
cellToCell = $(extendedStencil)/cellToCell
$(cellToCell)/fullStencils/cellToCellStencil.C
$(cellToCell)/fullStencils/CFCCellToCellStencil.C
$(cellToCell)/fullStencils/CPCCellToCellStencil.C
$(cellToCell)/fullStencils/CECCellToCellStencil.C
$(extendedStencil)/extendedStencilMeshObjects/centredCECStencilObject.C
$(extendedStencil)/extendedStencilMeshObjects/centredCFCStencilObject.C
$(extendedStencil)/extendedStencilMeshObjects/centredCPCStencilObject.C
$(extendedStencil)/extendedStencilMeshObjects/centredFECStencilObject.C
cellToFace = $(extendedStencil)/cellToFace
$(cellToFace)/fullStencils/cellToFaceStencil.C
$(cellToFace)/fullStencils/CFCCellToFaceStencil.C
$(cellToFace)/fullStencils/CECCellToFaceStencil.C
$(cellToFace)/fullStencils/CPCCellToFaceStencil.C
$(cellToFace)/fullStencils/FECCellToFaceStencil.C
$(cellToFace)/extendedCellToFaceStencil.C
$(cellToFace)/extendedCentredCellToFaceStencil.C
$(cellToFace)/extendedUpwindCellToFaceStencil.C
$(cellToFace)/MeshObjects/centredCECCellToFaceStencilObject.C
$(cellToFace)/MeshObjects/centredCFCCellToFaceStencilObject.C
$(cellToFace)/MeshObjects/centredCPCCellToFaceStencilObject.C
$(cellToFace)/MeshObjects/centredFECCellToFaceStencilObject.C
$(cellToFace)/MeshObjects/upwindCECCellToFaceStencilObject.C
$(cellToFace)/MeshObjects/upwindCFCCellToFaceStencilObject.C
$(cellToFace)/MeshObjects/upwindCPCCellToFaceStencilObject.C
$(cellToFace)/MeshObjects/upwindFECCellToFaceStencilObject.C
$(cellToFace)/MeshObjects/pureUpwindCFCCellToFaceStencilObject.C
faceToCell = $(extendedStencil)/faceToCell
$(faceToCell)/fullStencils/faceToCellStencil.C
$(faceToCell)/fullStencils/CFCFaceToCellStencil.C
$(faceToCell)/extendedFaceToCellStencil.C
$(faceToCell)/extendedCentredFaceToCellStencil.C
$(faceToCell)/MeshObjects/centredCFCFaceToCellStencilObject.C
$(extendedStencil)/extendedStencilMeshObjects/upwindCECStencilObject.C
$(extendedStencil)/extendedStencilMeshObjects/upwindCFCStencilObject.C
$(extendedStencil)/extendedStencilMeshObjects/upwindCPCStencilObject.C
$(extendedStencil)/extendedStencilMeshObjects/upwindFECStencilObject.C
fvPatchFields = fields/fvPatchFields
$(fvPatchFields)/fvPatchField/fvPatchFields.C
@ -166,6 +181,8 @@ $(interpolation)/interpolationCell/makeInterpolationCell.C
$(interpolation)/interpolationCellPoint/cellPointWeight/cellPointWeight.C
$(interpolation)/interpolationCellPoint/makeInterpolationCellPoint.C
$(interpolation)/interpolationCellPointFace/makeInterpolationCellPointFace.C
$(interpolation)/interpolationCellPointWallModified/cellPointWeightWallModified/cellPointWeightWallModified.C
$(interpolation)/interpolationCellPointWallModified/makeInterpolationCellPointWallModified.C
volPointInterpolation = interpolation/volPointInterpolation
$(volPointInterpolation)/pointPatchInterpolation/pointPatchInterpolation.C
@ -200,6 +217,10 @@ $(schemes)/quadraticFit/quadraticFit.C
$(schemes)/quadraticLinearUpwindFit/quadraticLinearUpwindFit.C
$(schemes)/quadraticUpwindFit/quadraticUpwindFit.C
$(schemes)/cubicUpwindFit/cubicUpwindFit.C
/*
$(schemes)/quadraticLinearPureUpwindFit/quadraticLinearPureUpwindFit.C
*/
$(schemes)/linearPureUpwindFit/linearPureUpwindFit.C
limitedSchemes = $(surfaceInterpolation)/limitedSchemes
$(limitedSchemes)/limitedSurfaceInterpolationScheme/limitedSurfaceInterpolationSchemes.C
@ -295,18 +316,32 @@ $(laplacianSchemes)/gaussLaplacianScheme/gaussLaplacianSchemes.C
finiteVolume/fvc/fvcMeshPhi.C
cfdTools/general/findRefCell/findRefCell.C
cfdTools/general/adjustPhi/adjustPhi.C
cfdTools/general/bound/bound.C
cfdTools/general/porousMedia/porousZone.C
cfdTools/general/porousMedia/porousZones.C
cfdTools/general/MRF/MRFZone.C
cfdTools/general/MRF/MRFZones.C
cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C
cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.C
cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C
cfdTools/general/SRF/SRFModel/SRFModel/newSRFModel.C
cfdTools/general/SRF/SRFModel/rpm/rpm.C
cfdTools/general/SRF/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C
general = cfdTools/general
$(general)/findRefCell/findRefCell.C
$(general)/adjustPhi/adjustPhi.C
$(general)/bound/bound.C
porousMedia = $(general)/porousMedia
$(porousMedia)/porousZone.C
$(porousMedia)/porousZones.C
MRF = $(general)/MRF
$(MRF)/MRFZone.C
$(MRF)/MRFZones.C
SRF = $(general)/SRF
$(SRF)/SRFModel/SRFModel/SRFModel.C
$(SRF)/SRFModel/SRFModel/newSRFModel.C
$(SRF)/SRFModel/rpm/rpm.C
$(SRF)/derivedFvPatchFields/SRFVelocityFvPatchVectorField/SRFVelocityFvPatchVectorField.C
fieldSources = $(general)/fieldSources
$(fieldSources)/pressureGradientExplicitSource/pressureGradientExplicitSource.C
$(fieldSources)/timeActivatedExplicitSource/timeActivatedExplicitSource.C
$(fieldSources)/timeActivatedExplicitCellSource/timeActivatedExplicitCellSource.C
$(fieldSources)/timeActivatedExplicitMulticomponentPointSource/timeActivatedExplicitMulticomponentPointSource.C
$(fieldSources)/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourceProperties.C
$(fieldSources)/timeActivatedExplicitMulticomponentPointSource/pointSourceProperties/pointSourcePropertiesIO.C
LIB = $(FOAM_LIBBIN)/libfiniteVolume

View File

@ -312,6 +312,31 @@ void Foam::MRFZone::addCoriolis(fvVectorMatrix& UEqn) const
}
void Foam::MRFZone::addCoriolis
(
const volScalarField& rho,
fvVectorMatrix& UEqn
) const
{
if (cellZoneID_ == -1)
{
return;
}
const labelList& cells = mesh_.cellZones()[cellZoneID_];
const scalarField& V = mesh_.V();
vectorField& Usource = UEqn.source();
const vectorField& U = UEqn.psi();
const vector& Omega = Omega_.value();
forAll(cells, i)
{
label celli = cells[i];
Usource[celli] -= V[celli]*rho[celli]*(Omega ^ U[celli]);
}
}
void Foam::MRFZone::relativeVelocity(volVectorField& U) const
{
const volVectorField& C = mesh_.C();

View File

@ -154,6 +154,9 @@ public:
//- Add the Coriolis force contribution to the momentum equation
void addCoriolis(fvVectorMatrix& UEqn) const;
//- Add the Coriolis force contribution to the momentum equation
void addCoriolis(const volScalarField& rho, fvVectorMatrix& UEqn) const;
//- Make the given absolute velocity relative within the MRF region
void relativeVelocity(volVectorField& U) const;

View File

@ -65,6 +65,19 @@ void Foam::MRFZones::addCoriolis(fvVectorMatrix& UEqn) const
}
void Foam::MRFZones::addCoriolis
(
const volScalarField& rho,
fvVectorMatrix& UEqn
) const
{
forAll(*this, i)
{
operator[](i).addCoriolis(rho, UEqn);
}
}
void Foam::MRFZones::relativeVelocity(volVectorField& U) const
{
forAll(*this, i)

View File

@ -76,6 +76,9 @@ public:
//- Add the Coriolis force contribution to the momentum equation
void addCoriolis(fvVectorMatrix& UEqn) const;
//- Add the Coriolis force contribution to the momentum equation
void addCoriolis(const volScalarField& rho, fvVectorMatrix& UEqn) const;
//- Make the given absolute velocity relative within the MRF region
void relativeVelocity(volVectorField& U) const;

View File

@ -0,0 +1,175 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#include "timeActivatedExplicitCellSource.H"
#include "volFields.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::timeActivatedExplicitCellSource::updateCellSet()
{
cellSelector_->applyToSet(topoSetSource::NEW, selectedCellSet_);
Info<< " " << name_ << ": selected "
<< returnReduce(selectedCellSet_.size(), sumOp<label>())
<< " cells" << nl << endl;
V_ = scalarField(selectedCellSet_.size(), 1.0);
if (volumeType_ == vtAbsolute)
{
label i = 0;
forAllConstIter(cellSet, selectedCellSet_, iter)
{
V_[i++] = mesh_.V()[iter.key()];
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::timeActivatedExplicitCellSource::timeActivatedExplicitCellSource
(
const word& name,
const fvMesh& mesh,
const dimensionSet& dims
)
:
timeActivatedExplicitSource(name, mesh, dims),
onValue_(readScalar(lookup("onValue"))),
offValue_(readScalar(lookup("offValue"))),
V_(0),
cellSource_(lookup("cellSource")),
cellSelector_
(
topoSetSource::New
(
cellSource_,
mesh,
subDict(cellSource_ + "Coeffs")
)
),
selectedCellSet_
(
mesh,
name + "SourceCellSet",
mesh.nCells()/10 + 1 // Reasonable size estimate.
)
{
// Create the cell set
updateCellSet();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::timeActivatedExplicitCellSource::onValue() const
{
return onValue_;
}
Foam::scalar Foam::timeActivatedExplicitCellSource::offValue() const
{
return offValue_;
}
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
Foam::timeActivatedExplicitCellSource::Su()
{
tmp<DimensionedField<scalar, volMesh> > tSource
(
new DimensionedField<scalar, volMesh>
(
IOobject
(
name_ + "Su",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensions_, 0.0)
)
);
scalar value = offValue_;
if
(
active_
&& (runTime_.time().value() >= timeStart_)
&& (runTime_.time().value() <= timeStart_ + duration_)
)
{
// Update the cell set if the mesh is changing
if (mesh_.changing())
{
updateCellSet();
}
value = onValue_;
}
DimensionedField<scalar, volMesh>& sourceField = tSource();
label i = 0;
forAllConstIter(cellSet, selectedCellSet_, iter)
{
sourceField[iter.key()] = value/V_[i++];
}
return tSource;
}
bool Foam::timeActivatedExplicitCellSource::read()
{
if (timeActivatedExplicitSource::read())
{
lookup("onValue") >> onValue_;
lookup("offValue") >> offValue_;
lookup("cellSource") >> cellSource_;
cellSelector_ =
topoSetSource::New
(
cellSource_,
mesh_,
subDict(cellSource_ + "Coeffs")
);
updateCellSet();
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,143 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Class
Foam::timeActivatedExplicitSourceNew
Description
Creates a cell set source that is activated at a given time, and remains
active for a specified duration. The source value is either in specific
(XX/m3) or absolute (XX) units.
SourceFiles
timeActivatedExplicitCellSource.C
\*---------------------------------------------------------------------------*/
#ifndef timeActivatedExplicitCellSource_H
#define timeActivatedExplicitCellSource_H
#include "timeActivatedExplicitSource.H"
#include "topoSetSource.H"
#include "cellSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class timeActivatedExplicitCellSource Declaration
\*---------------------------------------------------------------------------*/
class timeActivatedExplicitCellSource
:
public timeActivatedExplicitSource
{
private:
// Private member functions
//- Update the cell set that the source is acting on
void updateCellSet();
// Private Member Functions
//- Disallow default bitwise copy construct
timeActivatedExplicitCellSource(const timeActivatedExplicitCellSource&);
//- Disallow default bitwise assignment
void operator=(const timeActivatedExplicitCellSource&);
protected:
// Protected data
// Source properties
//- Value when "on"
scalar onValue_;
//- Value when "off"
scalar offValue_;
// Cell set
//- Cell volumes
scalarList V_;
//- Name of cell source (XXXToCell)
word cellSource_;
//- Method by which the cells will be selected
autoPtr<topoSetSource> cellSelector_;
//- Set of selected cells
cellSet selectedCellSet_;
public:
// Constructors
//- Construct from explicit source name and mesh
timeActivatedExplicitCellSource
(
const word&,
const fvMesh&,
const dimensionSet&
);
// Member Functions
// Access
//- Return the "on" value
virtual scalar onValue() const;
//- Return the "off" value
virtual scalar offValue() const;
//- Return a tmp field of the source
virtual tmp<DimensionedField<scalar, volMesh> > Su();
//- Read properties dictionary
virtual bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,87 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#include "pointSourceProperties.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pointSourceProperties::pointSourceProperties()
:
name_("unknownPointSourceName"),
timeStart_(0.0),
duration_(0.0),
location_(point::zero),
fieldData_()
{}
Foam::pointSourceProperties::pointSourceProperties(const dictionary& dict)
:
name_(dict.name().name()),
timeStart_(readScalar(dict.lookup("timeStart"))),
duration_(readScalar(dict.lookup("duration"))),
location_(dict.lookup("location")),
fieldData_(dict.lookup("fieldData"))
{}
Foam::pointSourceProperties::pointSourceProperties
(
const pointSourceProperties& psp
)
:
name_(psp.name_),
timeStart_(psp.timeStart_),
duration_(psp.duration_),
location_(psp.location_),
fieldData_(psp.fieldData_)
{}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::pointSourceProperties::operator=(const pointSourceProperties& rhs)
{
// Check for assignment to self
if (this == &rhs)
{
FatalErrorIn
(
"pointSourceProperties::operator=(const pointSourceProperties&)"
) << "Attempted assignment to self" << nl
<< abort(FatalError);
}
// Set updated values
name_ = rhs.name_;
timeStart_ = rhs.timeStart_;
duration_ = rhs.duration_;
location_ = rhs.location_;
fieldData_ = rhs.fieldData_;}
// ************************************************************************* //

View File

@ -0,0 +1,158 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Class
Foam::pointSourceProperties
Description
Helper class to describe point source properties
SourceFiles
pointSourceProperties.C
\*---------------------------------------------------------------------------*/
#ifndef pointSourceProperties_H
#define pointSourceProperties_H
#include "IOdictionary.H"
#include "fvMesh.H"
#include "Time.H"
#include "Tuple2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class pointSourceProperties Declaration
\*---------------------------------------------------------------------------*/
class pointSourceProperties
{
protected:
// Protected data
typedef Tuple2<word, scalar> fieldNameValuePair;
//- Source name
word name_;
//- Time start
scalar timeStart_;
//- Duration
scalar duration_;
//- Point location
point location_;
//- List of source field name vs value pairs
List<fieldNameValuePair> fieldData_;
public:
// Constructors
//- Construct null
pointSourceProperties();
//- Construct from dictionary
pointSourceProperties(const dictionary& dict);
//- Construct from Istream
pointSourceProperties(Istream& is);
//- Copy constructor
pointSourceProperties(const pointSourceProperties&);
// Member Functions
// Access
//- Return const access to the source name
inline const word& name() const;
//- Return const access to the time start
inline scalar timeStart() const;
//- Return const access to the time end
inline scalar timeEnd() const;
//- Return const access to the duration
inline scalar duration() const;
//- Return const access to the point location
inline const point& location() const;
//- Return const access to the source field name vs value pairs
inline const List<fieldNameValuePair>& fieldData() const;
// Edit
//- Return access to the source name
inline word& name();
//- Return access to the time start
inline scalar& timeStart();
//- Return access to the duration
inline scalar& duration();
//- Return access to the point location
inline point& location();
//- Return access to the source field name vs value pairs
inline List<fieldNameValuePair>& fieldData();
// Member Operators
void operator=(const pointSourceProperties&);
// IOstream operators
friend Istream& operator>>(Istream&, pointSourceProperties&);
friend Ostream& operator<<(Ostream&, const pointSourceProperties&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "pointSourcePropertiesI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,99 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#include "pointSourceProperties.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::word& Foam::pointSourceProperties::name() const
{
return name_;
}
inline Foam::scalar Foam::pointSourceProperties::timeStart() const
{
return timeStart_;
}
inline Foam::scalar Foam::pointSourceProperties::timeEnd() const
{
return timeStart_ + duration_;
}
inline Foam::scalar Foam::pointSourceProperties::duration() const
{
return duration_;
}
inline const Foam::point& Foam::pointSourceProperties::location() const
{
return location_;
}
inline const Foam::List<Foam::pointSourceProperties::fieldNameValuePair>&
Foam::pointSourceProperties::fieldData() const
{
return fieldData_;
}
inline Foam::word& Foam::pointSourceProperties::name()
{
return name_;
}
inline Foam::scalar& Foam::pointSourceProperties::timeStart()
{
return timeStart_;
}
inline Foam::scalar& Foam::pointSourceProperties::duration()
{
return duration_;
}
inline Foam::point& Foam::pointSourceProperties::location()
{
return location_;
}
inline Foam::List<Foam::pointSourceProperties::fieldNameValuePair>&
Foam::pointSourceProperties::fieldData()
{
return fieldData_;
}
// ************************************************************************* //

View File

@ -0,0 +1,88 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#include "pointSourceProperties.H"
#include "dictionaryEntry.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pointSourceProperties::pointSourceProperties(Istream& is)
:
name_("unknownPointSourceName"),
timeStart_(0.0),
duration_(0.0),
location_(point::zero),
fieldData_()
{
is.check("pointSourceProperties(Istream&)");
const dictionaryEntry entry(dictionary::null, is);
name_ = entry.keyword();
entry.lookup("timeStart") >> timeStart_;
entry.lookup("duration") >> duration_;
entry.lookup("location") >> location_;
entry.lookup("fieldData") >> fieldData_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, pointSourceProperties& psp)
{
is.check("Istream& operator>>(Istream&, pointSourceProperties&)");
const dictionaryEntry entry(dictionary::null, is);
psp.name_ = entry.keyword();
entry.lookup("timeStart") >> psp.timeStart_;
entry.lookup("duration") >> psp.duration_;
entry.lookup("location") >> psp.location_;
entry.lookup("fieldData") >> psp.fieldData_;
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const pointSourceProperties& psp)
{
os.check("Ostream& operator<<(Ostream&, const pointSourceProperties&)");
os << psp.name_ << nl << token::BEGIN_BLOCK << nl;
os.writeKeyword("timeStart") << psp.timeStart_ << token::END_STATEMENT << nl;
os.writeKeyword("duration") << psp.duration_ << token::END_STATEMENT << nl;
os.writeKeyword("location") << psp.location_ << token::END_STATEMENT << nl;
os.writeKeyword("fieldData") << psp.fieldData_ << token::END_STATEMENT << nl;
os << token::END_BLOCK << nl;
os.check("Ostream& operator<<(Ostream&, const pointSourceProperties&)");
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,292 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
\*---------------------------------------------------------------------------*/
#include "timeActivatedExplicitMulticomponentPointSource.H"
#include "volFields.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label
Foam::timeActivatedExplicitMulticomponentPointSource::carrierFieldId
(
const word& fieldName
)
{
forAll(carrierFields_, fieldI)
{
if (carrierFields_[fieldI].name() == fieldName)
{
return fieldI;
}
}
return -1;
}
void Foam::timeActivatedExplicitMulticomponentPointSource::updateAddressing()
{
forAll(pointSources_, sourceI)
{
const pointSourceProperties& psp = pointSources_[sourceI];
bool foundCell = false;
label cid = mesh_.findCell(psp.location());
if (cid >= 0)
{
foundCell = mesh_.pointInCell(psp.location(), cid);
}
reduce(foundCell, orOp<bool>());
if (!foundCell)
{
label cid = mesh_.findNearestCell(psp.location());
if (cid >= 0)
{
foundCell = mesh_.pointInCell(psp.location(), cid);
}
}
reduce(foundCell, orOp<bool>());
if (!foundCell)
{
FatalErrorIn
(
"timeActivatedExplicitMulticomponentPointSource::"
"updateAddressing()"
) << "Unable to find location " << psp.location() << " in mesh "
<< "for source " << psp.name() << nl
<< exit(FatalError);
}
else
{
cellOwners_[sourceI] = cid;
}
fieldIds_[sourceI].setSize(psp.fieldData().size());
forAll(psp.fieldData(), fieldI)
{
const word& fieldName = psp.fieldData()[fieldI].first();
label cfid = carrierFieldId(fieldName);
if (cfid < 0)
{
FatalErrorIn
(
"timeActivatedExplicitMulticomponentPointSource::"
"updateAddressing()"
) << "Unable to find field " << fieldName << " in carrier "
<< "fields for source " << psp.name() << nl
<< exit(FatalError);
}
else
{
fieldIds_[sourceI][fieldI] = cfid;
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::timeActivatedExplicitMulticomponentPointSource::
timeActivatedExplicitMulticomponentPointSource
(
const word& name,
const fvMesh& mesh,
const PtrList<volScalarField>& carrierFields,
const dimensionSet& dims
)
:
IOdictionary
(
IOobject
(
name + "Properties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
name_(name),
mesh_(mesh),
runTime_(mesh.time()),
dimensions_(dims),
carrierFields_(carrierFields),
active_(lookup("active")),
pointSources_(lookup("pointSources")),
cellOwners_(pointSources_.size()),
fieldIds_(pointSources_.size())
{
// Initialise the field addressing
updateAddressing();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
Foam::timeActivatedExplicitMulticomponentPointSource::Su
(
const label fieldI
)
{
if (mesh_.changing())
{
updateAddressing();
}
tmp<DimensionedField<scalar, volMesh> > tSource
(
new DimensionedField<scalar, volMesh>
(
IOobject
(
name_ + carrierFields_[fieldI].name() + "Su",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensions_, 0.0)
)
);
if (active_)
{
DimensionedField<scalar, volMesh>& sourceField = tSource();
const scalarField& V = mesh_.V();
const scalar dt = runTime_.deltaT().value();
forAll(pointSources_, sourceI)
{
const pointSourceProperties& psp = pointSources_[sourceI];
forAll(fieldIds_[sourceI], i)
{
if
(
fieldIds_[sourceI][i] == fieldI
&& (runTime_.time().value() >= psp.timeStart())
&& (runTime_.time().value() <= psp.timeEnd())
)
{
const label cid = cellOwners_[sourceI];
if (cid >= 0)
{
sourceField[cid] +=
dt*psp.fieldData()[i].second()/V[cid];
}
}
}
}
}
return tSource;
}
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
Foam::timeActivatedExplicitMulticomponentPointSource::Su()
{
if (mesh_.changing())
{
updateAddressing();
}
tmp<DimensionedField<scalar, volMesh> > tSource
(
new DimensionedField<scalar, volMesh>
(
IOobject
(
name_ + "TotalSu",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimensions_, 0.0)
)
);
if (active_)
{
DimensionedField<scalar, volMesh>& sourceField = tSource();
const scalarField& V = mesh_.V();
const scalar dt = runTime_.deltaT().value();
forAll(pointSources_, sourceI)
{
const pointSourceProperties& psp = pointSources_[sourceI];
forAll(fieldIds_[sourceI], i)
{
if
(
(runTime_.time().value() >= psp.timeStart())
&& (runTime_.time().value() <= psp.timeEnd())
)
{
const label cid = cellOwners_[sourceI];
if (cid >= 0)
{
sourceField[cid] +=
dt*psp.fieldData()[i].second()/V[cid];
}
}
}
}
}
return tSource;
}
bool Foam::timeActivatedExplicitMulticomponentPointSource::read()
{
if (regIOobject::read())
{
lookup("active") >> active_;
lookup("pointSources") >> pointSources_;
cellOwners_.setSize(pointSources_.size());
updateAddressing();
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

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