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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

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

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

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

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

View File

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

View File

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

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

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