Commit 481f4730 authored by henry's avatar henry
Browse files
parents 7b4e30d8 b1ddfadd
......@@ -187,21 +187,21 @@ time ({digit}{digit}":"{digit}{digit}":"{digit}{digit})
versionNumber ({digit}|".")*
header {spaceNl}"(1"{some_space}
dimension {spaceNl}"(2"{some_space}
points {spaceNl}"(10"{some_space}
faces {spaceNl}"(13"{some_space}
cells {spaceNl}"(12"{some_space}
zoneVariant1 {spaceNl}"(39"{some_space}
zoneVariant2 {spaceNl}"(45"{some_space}
faceTree {spaceNl}"(59"{some_space}
comment "0"{some_space}
unknownPeriodicFace "17"{some_space}
periodicFace "18"{some_space}
cellTree "58"{some_space}
faceParents "61"{some_space}
ignoreBlocks ("4"|"37"|"38"|"41"|"60"|"64"){some_space}
header {spaceNl}"(1"{space}
dimension {spaceNl}"(2"{space}
points {spaceNl}"(10"{space}
faces {spaceNl}"(13"{space}
cells {spaceNl}"(12"{space}
zoneVariant1 {spaceNl}"(39"{space}
zoneVariant2 {spaceNl}"(45"{space}
faceTree {spaceNl}"(59"{space}
comment "0"{space}
unknownPeriodicFace "17"{space}
periodicFace "18"{space}
cellTree "58"{space}
faceParents "61"{space}
ignoreBlocks ("4"|"37"|"38"|"41"|"60"|"64"){space}
redundantBlock {spaceNl}({comment}|{unknownPeriodicFace}|{periodicFace}|{cellTree}|{faceParents}|{ignoreBlocks}){space}
......
......@@ -15,11 +15,13 @@ FoamFile
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Nx 40;
Ny
(
50
);
Nz 30;
Nx 40;
Ny
(
25
25
);
Nz 30;
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 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
\*---------------------------------------------------------------------------*/
#ifndef HashSet_C
#define HashSet_C
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Key, class Hash>
bool HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& ht) const
{
const HashTable<empty, Key, Hash>& a = *this;
// Are all my elements in ht?
for
(
typename HashTable<empty, Key, Hash>::const_iterator iter = a.begin();
iter != a.end();
++iter
)
{
if (!ht.found(iter.key()))
{
return false;
}
}
// Are all ht elements in me?
for
(
typename HashTable<empty, Key, Hash>::const_iterator iter = ht.begin();
iter != ht.end();
++iter
)
{
if (!found(iter.key()))
{
return false;
}
}
return true;
}
template<class Key, class Hash>
bool HashSet<Key, Hash>::operator!=(const HashSet<Key, Hash>& ht) const
{
return !(operator==(ht));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -100,6 +100,17 @@ public:
{
return HashTable<empty, Key, Hash>::insert(key, empty());
}
// Member Operators
//- Equality. Two hashtables are equal if all contents of first are
// also in second and vice versa. So does not depend on table size or
// order!
bool operator==(const HashSet<Key, Hash>&) const;
//- The opposite of the equality operation.
bool operator!=(const HashSet<Key, Hash>&) const;
};
......@@ -112,6 +123,12 @@ typedef HashSet<> wordHashSet;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "HashSet.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -321,7 +321,7 @@ List<T>::List(const BiIndirectList<T>& idl)
template<class T>
List<T>::~List()
{
if (this->size_) delete[] this->v_;
if (this->v_) delete[] this->v_;
}
......@@ -367,9 +367,8 @@ void List<T>::setSize(const label newSize)
register T* av = &nv[i];
while (i--) *--av = *--vv;
}
delete[] this->v_;
}
if (this->v_) delete[] this->v_;
this->size_ = newSize;
this->v_ = nv;
......@@ -400,7 +399,7 @@ void List<T>::setSize(const label newSize, const T& a)
template<class T>
void List<T>::clear()
{
if (this->size_) delete[] this->v_;
if (this->v_) delete[] this->v_;
this->size_ = 0;
this->v_ = 0;
}
......@@ -411,7 +410,7 @@ void List<T>::clear()
template<class T>
void List<T>::transfer(List<T>& a)
{
if (this->size_) delete[] this->v_;
if (this->v_) delete[] this->v_;
this->size_ = a.size_;
this->v_ = a.v_;
......@@ -457,7 +456,8 @@ void List<T>::operator=(const UList<T>& a)
{
if (a.size_ != this->size_)
{
if (this->size_) delete[] this->v_;
if (this->v_) delete[] this->v_;
this->v_ = 0;
this->size_ = a.size_;
if (this->size_) this->v_ = new T[this->size_];
}
......@@ -503,7 +503,8 @@ void List<T>::operator=(const SLList<T>& sll)
{
if (sll.size() != this->size_)
{
if (this->size_) delete[] this->v_;
if (this->v_) delete[] this->v_;
this->v_ = 0;
this->size_ = sll.size();
if (this->size_) this->v_ = new T[this->size_];
}
......@@ -530,7 +531,8 @@ void List<T>::operator=(const IndirectList<T>& idl)
{
if (idl.size() != this->size_)
{
if (this->size_) delete[] this->v_;
if (this->v_) delete[] this->v_;
this->v_ = 0;
this->size_ = idl.size();
if (this->size_) this->v_ = new T[this->size_];
}
......@@ -551,7 +553,8 @@ void List<T>::operator=(const BiIndirectList<T>& idl)
{
if (idl.size() != this->size_)
{
if (this->size_) delete[] this->v_;
if (this->v_) delete[] this->v_;
this->v_ = 0;
this->size_ = idl.size();
if (this->size_) this->v_ = new T[this->size_];
}
......
......@@ -137,6 +137,9 @@ public:
//- Return a null List
static const List<T>& null();
//- Return the number of elements in the UList.
inline label size() const;
// Edit
......@@ -156,6 +159,10 @@ public:
//- Return subscript-checked element of UList.
inline T& newElmt(const label);
//- Override size to be inconsistent with allocated storage.
// Use with care.
inline label& size();
// Member operators
......
......@@ -52,6 +52,20 @@ inline T& Foam::List<T>::newElmt(const label i)
}
template<class T>
inline Foam::label Foam::List<T>::size() const
{
return UList<T>::size_;
}
template<class T>
inline Foam::label& Foam::List<T>::size()
{
return UList<T>::size_;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T>
......
......@@ -282,8 +282,7 @@ const Foam::labelList& Foam::polyPatch::meshEdges() const
primitivePatch::meshEdges
(
boundaryMesh().mesh().edges(),
boundaryMesh().mesh().cellEdges(),
faceCells()
boundaryMesh().mesh().pointEdges()
)
);
}
......
......@@ -362,16 +362,27 @@ const Foam::labelList& Foam::faceZone::meshEdges() const
{
if (!mePtr_)
{
labelList faceCells(size());
const labelList& own = zoneMesh().mesh().faceOwner();
const labelList& faceLabels = *this;
forAll (faceCells, faceI)
{
faceCells[faceI] = own[faceLabels[faceI]];
}
//labelList faceCells(size());
//
//const labelList& own = zoneMesh().mesh().faceOwner();
//
//const labelList& faceLabels = *this;
//
//forAll (faceCells, faceI)
//{
// faceCells[faceI] = own[faceLabels[faceI]];
//}
//
//mePtr_ =
// new labelList
// (
// operator()().meshEdges
// (
// zoneMesh().mesh().edges(),
// zoneMesh().mesh().cellEdges(),
// faceCells
// )
// );
mePtr_ =
new labelList
......@@ -379,8 +390,7 @@ const Foam::labelList& Foam::faceZone::meshEdges() const
operator()().meshEdges
(
zoneMesh().mesh().edges(),
zoneMesh().mesh().cellEdges(),
faceCells
zoneMesh().mesh().pointEdges()
)
);
}
......
......@@ -348,7 +348,8 @@ public:
// index in the edge list. If the edge is not found, return -1
label whichEdge(const edge& e) const;
//- Return labels of patch edges in the global edge list
//- Return labels of patch edges in the global edge list using
// cell addressing
labelList meshEdges
(
const edgeList& allEdges,
......@@ -356,6 +357,14 @@ public:
const labelList& faceCells
) const;
//- Return labels of patch edges in the global edge list using
// basic edge addressing.
labelList meshEdges
(
const edgeList& allEdges,
const labelListList& pointEdges
) const;
//- Return face normals for patch
const Field<PointType>& faceNormals() const;
......
......@@ -111,6 +111,60 @@ labelList PrimitivePatch<Face, FaceList, PointField, PointType>::meshEdges
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
labelList PrimitivePatch<Face, FaceList, PointField, PointType>::meshEdges
(
const edgeList& allEdges,
const labelListList& pointEdges
) const
{
if (debug)
{
Info<< "labelList PrimitivePatch<Face, FaceList, PointField, PointType>"
<< "::meshEdges() : "
<< "calculating labels of patch edges in mesh edge list"
<< endl;
}
// get reference to the list of edges on the patch
const edgeList& PatchEdges = edges();
// create the storage
labelList meshEdges(PatchEdges.size());
// get reference to the points on the patch
const labelList& pp = meshPoints();
// WARNING: Remember that local edges address into local point list;
// local-to-global point label translation is necessary
forAll (PatchEdges, edgeI)
{
const label globalPointI = pp[PatchEdges[edgeI].start()];
const edge curEdge(globalPointI, pp[PatchEdges[edgeI].end()]);
const labelList& pe = pointEdges[globalPointI];
forAll (pe, i)
{
if (allEdges[pe[i]] == curEdge)
{
meshEdges[edgeI] = pe[i];
break;
}
}
}
return meshEdges;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
......
......@@ -66,6 +66,9 @@ primitiveMesh::primitiveMesh()
ppPtr_(NULL),
cpPtr_(NULL),
allocSize_(0),
labels_(0),
cellCentresPtr_(NULL),
faceCentresPtr_(NULL),
cellVolumesPtr_(NULL),
......@@ -106,6 +109,9 @@ primitiveMesh::primitiveMesh
ppPtr_(NULL),
cpPtr_(NULL),
allocSize_(0),
labels_(0),
cellCentresPtr_(NULL),
faceCentresPtr_(NULL),
cellVolumesPtr_(NULL),
......
......@@ -155,6 +155,17 @@ class primitiveMesh
mutable labelListList* cpPtr_;
// On-the-fly edge addresing storage
//- Temporary storage for addressing. allocSize is the real size
// of the labelList.
mutable label allocSize_;
mutable labelList labels_;
//- Temporary storage for addressing
mutable labelHashSet labelSet_;
// Geometric data
//- Cell centres
......@@ -209,8 +220,14 @@ class primitiveMesh
(
List<DynamicList<label> >&,
DynamicList<edge>&,
const label pA,
const label pB
const label,
const label
);
//- For on-the-fly addressing calculation
static label findFirstCommonElementFromSortedLists
(
const labelList&,
const labelList&
);
......@@ -667,6 +684,55 @@ public:
//- Print a list of all the currently allocated mesh data
void printAllocated() const;
// Per storage whether allocated
inline bool hasCellShapes() const;
inline bool hasEdges() const;
inline bool hasCellCells() const;
inline bool hasEdgeCells() const;
inline bool hasPointCells() const;
inline bool hasCells() const;
inline bool hasEdgeFaces() const;
inline bool hasPointFaces() const;
inline bool hasCellEdges() const;
inline bool hasFaceEdges() const;
inline bool hasPointEdges() const;
inline bool hasPointPoints() const;
inline bool hasCellPoints() const;
inline bool hasCellCentres() const;
inline bool hasFaceCentres() const;
inline bool hasCellVolumes() const;
inline bool hasFaceAreas() const;
// On-the-fly addressing calculation. These functions return either
// a reference to the full addressing (if already calculated) or
// a reference to member data labels_ so be careful when not storing
// result.
//- cellCells using cells
const labelList& cellCells(const label cellI) const;
//- cellPoints using cells
const labelList& cellPoints(const label cellI) const;
//- pointCells using pointFaces
const labelList& pointCells(const label pointI) const;
//- pointPoints using edges, pointEdges
const labelList& pointPoints(const label pointI) const;
//- faceEdges using pointFaces, edges, pointEdges
const labelList& faceEdges(const label faceI) const;
//- edgeFaces using pointFaces, edges, pointEdges
const labelList& edgeFaces(const label edgeI) const;
//- edgeCells using pointFaces, edges, pointEdges
const labelList& edgeCells(const label edgeI) const;
//- cellEdges using cells, pointFaces, edges, pointEdges
const labelList& cellEdges(const label cellI) const;
//- Clear geometry
void clearGeom();
......
......@@ -105,6 +105,53 @@ const labelListList& primitiveMesh::cellCells() const
}
const labelList& primitiveMesh::cellCells(const label cellI) const
{
if (hasCellCells())
{
return cellCells()[cellI];
}
else
{
const labelList& own = faceOwner();
const labelList& nei = faceNeighbour();
const cell& cFaces = cells()[cellI];
labels_.size() = allocSize_;
if (cFaces.size() > allocSize_)
{
labels_.clear();
allocSize_ = cFaces.size();
labels_.setSize(allocSize_);
}
label n = 0;
forAll(cFaces, i)
{
label faceI = cFaces[i];
if (faceI < nInternalFaces())
{
if (own[faceI] == cellI)
{
labels_[n++] = nei[faceI];
}
else
{
labels_[n++] = own[faceI];
}
}
}
labels_.size() = n;
return labels_;
}
}