Development branch merge

This commit is contained in:
Hrvoje Jasak 2011-05-27 18:17:39 +01:00
parent 705c28eac4
commit 6c577922c5
18 changed files with 90 additions and 4150 deletions

View file

@ -466,9 +466,12 @@ initEvaluate
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
) )
{ {
if (this->isPointField()) if (Pstream::parRun())
{ {
initAddFieldTempl(Pstream::blocking, this->internalField()); if (this->isPointField())
{
initAddFieldTempl(Pstream::blocking, this->internalField());
}
} }
} }
@ -491,27 +494,30 @@ evaluate
const Pstream::commsTypes commsType const Pstream::commsTypes commsType
) )
{ {
if (this->isPointField()) if (Pstream::parRun())
{ {
// Get the neighbour side values if (this->isPointField())
tmp<Field<Type> > tpNeighbour = receivePointField<Type>(commsType);
Field<Type>& tpn = tpNeighbour();
if (doTransform())
{ {
const processorPolyPatch& ppp = procPatch_.procPolyPatch(); // Get the neighbour side values
const tensorField& forwardT = ppp.forwardT(); tmp<Field<Type> > tpNeighbour = receivePointField<Type>(commsType);
Field<Type>& tpn = tpNeighbour();
transform(tpn, forwardT[0], tpn); if (doTransform())
{
const processorPolyPatch& ppp = procPatch_.procPolyPatch();
const tensorField& forwardT = ppp.forwardT();
transform(tpn, forwardT[0], tpn);
}
// Average over two sides
tpn = 0.5*(patchInternalField(this->internalField()) + tpn);
// Get internal field to insert values into
Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
this->setInInternalField(iF, tpn);
} }
// Average over two sides
tpn = 0.5*(patchInternalField(this->internalField()) + tpn);
// Get internal field to insert values into
Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
this->setInInternalField(iF, tpn);
} }
} }
@ -697,7 +703,7 @@ initAddUpperLower
{ {
// Gather the data from the given field and send it. Note that the // Gather the data from the given field and send it. Note that the
// size of the field is equal to the number of edges on the field // size of the field is equal to the number of edges on the field
// and NOT the number of points. // and NOT the number of points. HJ, 14/Nov/2001
// Get the addressing // Get the addressing
const labelList& me = procPatch_.localEdgeIndices(); const labelList& me = procPatch_.localEdgeIndices();

View file

@ -144,6 +144,7 @@ public:
const scalarField& y const scalarField& y
); );
//- Create and return a clone
autoPtr<curve> clone() const autoPtr<curve> clone() const
{ {
return autoPtr<curve>(new curve(*this)); return autoPtr<curve>(new curve(*this));

View file

@ -95,7 +95,8 @@ public:
// If object pointer already set issue a FatalError. // If object pointer already set issue a FatalError.
inline void set(T*); inline void set(T*);
//- If object pointer already set, delete object and set to given pointer //- If object pointer already set, delete object and set to
// given pointer
inline void reset(T* = 0); inline void reset(T* = 0);
//- If object pointer points to valid object: //- If object pointer points to valid object:

View file

@ -182,7 +182,7 @@ void Foam::processorPolyPatch::calcGeometry()
// Cache face areas // Cache face areas
const vectorField::subField localFaceAreas = faceAreas(); const vectorField::subField localFaceAreas = faceAreas();
forAll(faceNormals, facei) forAll (faceNormals, facei)
{ {
scalar magSf = mag(localFaceAreas[facei]); scalar magSf = mag(localFaceAreas[facei]);
scalar nbrMagSf = mag(neighbFaceAreas_[facei]); scalar nbrMagSf = mag(neighbFaceAreas_[facei]);
@ -320,6 +320,10 @@ void Foam::processorPolyPatch::updateMesh()
{ {
// Note cannot predict exact size since opposite nPoints might // Note cannot predict exact size since opposite nPoints might
// be different from one over here. // be different from one over here.
// Disagree: This needs to be sorted out, so that processor patches
// are simply internal faces and treat cyclics separately
// HJ, 10/Mar/2011
IPstream fromNeighbProc(Pstream::blocking, neighbProcNo()); IPstream fromNeighbProc(Pstream::blocking, neighbProcNo());
fromNeighbProc fromNeighbProc
@ -338,7 +342,7 @@ void Foam::processorPolyPatch::updateMesh()
neighbPointsPtr_ = new labelList(nPoints(), -1); neighbPointsPtr_ = new labelList(nPoints(), -1);
labelList& neighbPoints = *neighbPointsPtr_; labelList& neighbPoints = *neighbPointsPtr_;
forAll(nbrPointFace, nbrPointI) forAll (nbrPointFace, nbrPointI)
{ {
// Find face and index in face on this side. // Find face and index in face on this side.
const face& f = localFaces()[nbrPointFace[nbrPointI]]; const face& f = localFaces()[nbrPointFace[nbrPointI]];
@ -358,7 +362,7 @@ void Foam::processorPolyPatch::updateMesh()
} }
// Reset all duplicate entries to -1. // Reset all duplicate entries to -1.
forAll(neighbPoints, patchPointI) forAll (neighbPoints, patchPointI)
{ {
if (neighbPoints[patchPointI] == -2) if (neighbPoints[patchPointI] == -2)
{ {
@ -372,7 +376,7 @@ void Foam::processorPolyPatch::updateMesh()
neighbEdgesPtr_ = new labelList(nEdges(), -1); neighbEdgesPtr_ = new labelList(nEdges(), -1);
labelList& neighbEdges = *neighbEdgesPtr_; labelList& neighbEdges = *neighbEdgesPtr_;
forAll(nbrEdgeFace, nbrEdgeI) forAll (nbrEdgeFace, nbrEdgeI)
{ {
// Find face and index in face on this side. // Find face and index in face on this side.
const labelList& f = faceEdges()[nbrEdgeFace[nbrEdgeI]]; const labelList& f = faceEdges()[nbrEdgeFace[nbrEdgeI]];
@ -392,7 +396,7 @@ void Foam::processorPolyPatch::updateMesh()
} }
// Reset all duplicate entries to -1. // Reset all duplicate entries to -1.
forAll(neighbEdges, patchEdgeI) forAll (neighbEdges, patchEdgeI)
{ {
if (neighbEdges[patchEdgeI] == -2) if (neighbEdges[patchEdgeI] == -2)
{ {
@ -414,6 +418,7 @@ const Foam::labelList& Foam::processorPolyPatch::neighbPoints() const
<< "No extended addressing calculated for patch " << name() << "No extended addressing calculated for patch " << name()
<< abort(FatalError); << abort(FatalError);
} }
return *neighbPointsPtr_; return *neighbPointsPtr_;
} }
@ -426,6 +431,7 @@ const Foam::labelList& Foam::processorPolyPatch::neighbEdges() const
<< "No extended addressing calculated for patch " << name() << "No extended addressing calculated for patch " << name()
<< abort(FatalError); << abort(FatalError);
} }
return *neighbEdgesPtr_; return *neighbEdgesPtr_;
} }
@ -437,12 +443,13 @@ void Foam::processorPolyPatch::initOrder(const primitivePatch& pp) const
return; return;
} }
const bool isMaster = Pstream::myProcNo() < neighbProcNo(); // Master side sends the data and slave side rotates the faces
// HJ, 10/Mar/2011
if (isMaster) if (owner())
{ {
pointField ctrs(calcFaceCentres(pp, pp.points())); pointField ctrs(calcFaceCentres(pp, pp.points()));
// Anchor point is the start point of all faces. HJ, 10/Mar/2011
pointField anchors(getAnchorPoints(pp, pp.points())); pointField anchors(getAnchorPoints(pp, pp.points()));
// Now send all info over to the neighbour // Now send all info over to the neighbour
@ -475,7 +482,7 @@ bool Foam::processorPolyPatch::order
fileName nm fileName nm
( (
boundaryMesh().mesh().time().path() boundaryMesh().mesh().time().path()
/name()+"_faces.obj" /name() + "_faces.obj"
); );
Pout<< "processorPolyPatch::order : Writing my " << pp.size() Pout<< "processorPolyPatch::order : Writing my " << pp.size()
<< " faces to OBJ file " << nm << endl; << " faces to OBJ file " << nm << endl;
@ -493,7 +500,7 @@ bool Foam::processorPolyPatch::order
<< "Dumping " << ctrs.size() << "Dumping " << ctrs.size()
<< " local faceCentres to " << localStr.name() << endl; << " local faceCentres to " << localStr.name() << endl;
forAll(ctrs, faceI) forAll (ctrs, faceI)
{ {
writeOBJ(localStr, ctrs[faceI]); writeOBJ(localStr, ctrs[faceI]);
} }
@ -505,13 +512,11 @@ bool Foam::processorPolyPatch::order
rotation.setSize(pp.size()); rotation.setSize(pp.size());
rotation = 0; rotation = 0;
const bool isMaster = Pstream::myProcNo() < neighbProcNo(); if (owner())
if (isMaster)
{ {
// Do nothing (i.e. identical mapping, zero rotation). // Do nothing (i.e. identical mapping, zero rotation).
// See comment at top. // See comment at top.
forAll(faceMap, patchFaceI) forAll (faceMap, patchFaceI)
{ {
faceMap[patchFaceI] = patchFaceI; faceMap[patchFaceI] = patchFaceI;
} }
@ -520,6 +525,7 @@ bool Foam::processorPolyPatch::order
} }
else else
{ {
// Slave side: receive points
vectorField masterCtrs; vectorField masterCtrs;
vectorField masterAnchors; vectorField masterAnchors;
@ -543,10 +549,12 @@ bool Foam::processorPolyPatch::order
boundaryMesh().mesh().time().path() boundaryMesh().mesh().time().path()
/name() + "_nbrFaceCentres.obj" /name() + "_nbrFaceCentres.obj"
); );
Pout<< "processorPolyPatch::order : " Pout<< "processorPolyPatch::order : "
<< "Dumping neighbour faceCentres to " << nbrStr.name() << "Dumping neighbour faceCentres to " << nbrStr.name()
<< endl; << endl;
forAll(masterCtrs, faceI)
forAll (masterCtrs, faceI)
{ {
writeOBJ(nbrStr, masterCtrs[faceI]); writeOBJ(nbrStr, masterCtrs[faceI]);
} }
@ -585,12 +593,13 @@ bool Foam::processorPolyPatch::order
if (v.size() == 1) if (v.size() == 1)
{ {
transformedCtrs = masterCtrs-v[0]; transformedCtrs = masterCtrs - v[0];
} }
else else
{ {
transformedCtrs = masterCtrs-v; transformedCtrs = masterCtrs - v;
} }
matchedAll = matchPoints matchedAll = matchPoints
( (
ctrs, ctrs,
@ -624,6 +633,7 @@ bool Foam::processorPolyPatch::order
{ {
vectorField transformedCtrs = masterCtrs; vectorField transformedCtrs = masterCtrs;
transformList(forwardT(), transformedCtrs); transformList(forwardT(), transformedCtrs);
matchedAll = matchPoints matchedAll = matchPoints
( (
ctrs, ctrs,
@ -656,7 +666,7 @@ bool Foam::processorPolyPatch::order
fileName str fileName str
( (
boundaryMesh().mesh().time().path() boundaryMesh().mesh().time().path()
/name()/name()+"_faces.obj" /name()/name() + "_faces.obj"
); );
Pout<< "processorPolyPatch::order :" Pout<< "processorPolyPatch::order :"
<< " Writing faces to OBJ file " << str.name() << endl; << " Writing faces to OBJ file " << str.name() << endl;
@ -675,7 +685,7 @@ bool Foam::processorPolyPatch::order
label vertI = 0; label vertI = 0;
forAll(ctrs, faceI) forAll (ctrs, faceI)
{ {
label masterFaceI = faceMap[faceI]; label masterFaceI = faceMap[faceI];
@ -690,7 +700,8 @@ bool Foam::processorPolyPatch::order
if (!matchedAll) if (!matchedAll)
{ {
SeriousErrorIn FatalErrorIn
// SeriousErrorIn
( (
"processorPolyPatch::order(const primitivePatch&" "processorPolyPatch::order(const primitivePatch&"
", labelList&, labelList&) const" ", labelList&, labelList&) const"
@ -703,13 +714,13 @@ bool Foam::processorPolyPatch::order
<< " multiple separated (from cyclics) processor patches" << " multiple separated (from cyclics) processor patches"
<< endl << endl
<< " Continuing with incorrect face ordering from now on!" << " Continuing with incorrect face ordering from now on!"
<< endl; << abort(FatalError);
return false; return false;
} }
// Set rotation. // Set rotation
forAll(faceMap, oldFaceI) forAll (faceMap, oldFaceI)
{ {
// The face f will be at newFaceI (after morphing) and we want its // The face f will be at newFaceI (after morphing) and we want its
// anchorPoint (= f[0]) to align with the anchorpoint for the // anchorPoint (= f[0]) to align with the anchorpoint for the
@ -729,7 +740,8 @@ bool Foam::processorPolyPatch::order
if (rotation[newFaceI] == -1) if (rotation[newFaceI] == -1)
{ {
SeriousErrorIn FatalErrorIn
// SeriousErrorIn
( (
"processorPolyPatch::order(const primitivePatch&" "processorPolyPatch::order(const primitivePatch&"
", labelList&, labelList&) const" ", labelList&, labelList&) const"
@ -742,13 +754,13 @@ bool Foam::processorPolyPatch::order
<< " when matching the halves of processor patch " << " when matching the halves of processor patch "
<< name() << name()
<< "Continuing with incorrect face ordering from now on!" << "Continuing with incorrect face ordering from now on!"
<< endl; << abort(FatalError);
return false; return false;
} }
} }
forAll(faceMap, faceI) forAll (faceMap, faceI)
{ {
if (faceMap[faceI] != faceI || rotation[faceI] != 0) if (faceMap[faceI] != faceI || rotation[faceI] != 0)
{ {
@ -768,10 +780,8 @@ void Foam::processorPolyPatch::syncOrder() const
return; return;
} }
// Read and discard info from master side // Read and discard info from owner side from the neighbour
const bool isMaster = Pstream::myProcNo() < neighbProcNo(); if (neighbour())
if (!isMaster)
{ {
vectorField masterCtrs; vectorField masterCtrs;
vectorField masterAnchors; vectorField masterAnchors;
@ -784,6 +794,7 @@ void Foam::processorPolyPatch::syncOrder() const
} }
} }
void Foam::processorPolyPatch::write(Ostream& os) const void Foam::processorPolyPatch::write(Ostream& os) const
{ {
polyPatch::write(os); polyPatch::write(os);

View file

@ -2975,7 +2975,8 @@ void Foam::autoLayerDriver::addLayers
); );
const_cast<Time&>(mesh.time())++; const_cast<Time&>(mesh.time())++;
Info<< "Writing shrunk mesh to " << meshRefiner_.timeName() << endl; Info<< "Writing shrunk mesh to " << meshRefiner_.timeName()
<< endl;
// See comment in autoSnapDriver why we should not remove meshPhi // See comment in autoSnapDriver why we should not remove meshPhi
// using mesh.clearPout(). // using mesh.clearPout().

View file

@ -1613,7 +1613,7 @@ Foam::label Foam::meshRefinement::addPatch
fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh.boundary()); fvBoundaryMesh& fvPatches = const_cast<fvBoundaryMesh&>(mesh.boundary());
// Add polyPatch at the end // Add polyPatch at the end
polyPatches.setSize(sz+1); polyPatches.setSize(sz + 1);
polyPatches.set polyPatches.set
( (
sz, sz,

View file

@ -1,257 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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 "CompactListList_dev.H"
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
template<class T, class Container>
Foam::CompactListList_dev<T, Container>::CompactListList_dev(const List<Container>& ll)
:
size_(ll.size()),
offsets_(ll.size()+1)
{
label sumSize = 0;
offsets_[0] = 0;
forAll(ll, i)
{
sumSize += ll[i].size();
offsets_[i+1] = sumSize;
}
m_.setSize(sumSize);
label k = 0;
forAll(ll, i)
{
const Container& lli = ll[i];
forAll(lli, j)
{
m_[k++] = lli[j];
}
}
}
template<class T, class Container>
Foam::CompactListList_dev<T, Container>::CompactListList_dev
(
const UList<label>& rowSizes
)
:
size_(rowSizes.size()),
offsets_(rowSizes.size()+1)
{
label sumSize = 0;
offsets_[0] = 0;
forAll(rowSizes, i)
{
sumSize += rowSizes[i];
offsets_[i+1] = sumSize;
}
m_.setSize(sumSize);
}
template<class T, class Container>
Foam::CompactListList_dev<T, Container>::CompactListList_dev
(
const UList<label>& rowSizes,
const T& t
)
:
size_(rowSizes.size()),
offsets_(rowSizes.size()+1)
{
label sumSize = 0;
offsets_[0] = 0;
forAll(rowSizes, i)
{
sumSize += rowSizes[i];
offsets_[i+1] = sumSize;
}
m_.setSize(sumSize, t);
}
template<class T, class Container>
Foam::CompactListList_dev<T, Container>::CompactListList_dev
(
const Xfer<CompactListList_dev<T, Container> >& lst
)
{
transfer(lst());
}
template<class T, class Container>
Foam::CompactListList_dev<T, Container>::CompactListList_dev
(
CompactListList_dev<T, Container>& lst,
bool reUse
)
:
size_(lst.size()),
offsets_(lst.offsets_, reUse),
m_(lst.m_, reUse)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, class Container>
void Foam::CompactListList_dev<T, Container>::setSize(const label nRows)
{
if (nRows == 0)
{
clear();
}
if (nRows < size())
{
size_ = nRows;
offsets_.setSize(nRows+1);
m_.setSize(offsets_[nRows]);
}
else if (nRows > size())
{
FatalErrorIn
(
"CompactListList_dev<T, Container>::setSize(const label nRows)"
) << "Cannot be used to extend the list from " << offsets_.size()
<< " to " << nRows << nl
<< " Please use one of the other setSize member functions"
<< abort(FatalError);
}
}
template<class T, class Container>
void Foam::CompactListList_dev<T, Container>::setSize
(
const label nRows,
const label nData
)
{
size_ = nRows;
offsets_.setSize(nRows+1);
m_.setSize(nData);
}
template<class T, class Container>
void Foam::CompactListList_dev<T, Container>::setSize
(
const label nRows,
const label nData,
const T& t
)
{
size_ = nRows;
offsets_.setSize(nRows+1);
m_.setSize(nData, t);
}
template<class T, class Container>
void Foam::CompactListList_dev<T, Container>::setSize(const UList<label>& rowSizes)
{
size_ = rowSizes.size();
offsets_.setSize(rowSizes.size()+1);
label sumSize = 0;
offsets_[0] = 0;
forAll(rowSizes, i)
{
sumSize += rowSizes[i];
offsets_[i+1] = sumSize;
}
m_.setSize(sumSize);
}
template<class T, class Container>
Foam::labelList Foam::CompactListList_dev<T, Container>::sizes() const
{
labelList rowSizes(size());
if (rowSizes.size() > 0)
{
forAll(rowSizes, i)
{
rowSizes[i] = offsets_[i+1] - offsets_[i];
}
}
return rowSizes;
}
template<class T, class Container>
void Foam::CompactListList_dev<T, Container>::clear()
{
size_ = 0;
offsets_.clear();
m_.clear();
}
template<class T, class Container>
void Foam::CompactListList_dev<T, Container>::transfer
(
CompactListList_dev<T, Container>& a
)
{
size_ = a.size_;
offsets_.transfer(a.offsets_);
m_.transfer(a.m_);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T, class Container>
Foam::List<Container> Foam::CompactListList_dev<T, Container>::operator()()
const
{
List<Container> ll(size());
forAll(ll, i)
{
ll[i] = Container(operator[](i));
}
return ll;
}
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
#include "CompactListList_devIO.C"
// ************************************************************************* //

View file

@ -1,270 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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::CompactListList_dev
Description
A packed storage unstructured matrix of objects of type \<T\>
using an offset table for access.
The offset table is the size of the number of rows+1
whose elements are the
accumulated sizes of the rows, i.e.
- offset[i] gives the index of first element of row i
- offset[i+1] - offset[i] is the number of elements in row i
Storage is allocated on free-store during construction.
As a special case a null-contructed CompactListList_dev has an empty
offsets_ (instead of size 1).
SourceFiles
CompactListList_dev.C
CompactListList_devI.H
CompactListList_devIO.C
\*---------------------------------------------------------------------------*/
#ifndef CompactListListDev_H
#define CompactListListDev_H
#include "labelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
template<class T, class Container> class CompactListList_dev;
template<class T, class Container> Istream& operator>>
(
Istream&,
CompactListList_dev<T, Container>&
);
template<class T, class Container> Ostream& operator<<
(
Ostream&,
const CompactListList_dev<T, Container>&
);
/*---------------------------------------------------------------------------*\
Class CompactListList_dev Declaration
\*---------------------------------------------------------------------------*/
template<class T, class Container = List<T> >
class CompactListList_dev
{
// Private data
label size_;
//- Offset table
List<label> offsets_;
//- Packed matrix of data
List<T> m_;
public:
// Static Member Functions
//- Return a null CompactListList_dev
inline static const CompactListList_dev<T, Container>& null();
// Constructors
//- Null constructor.
inline CompactListList_dev();
//- Construct by converting given List<List<T> >
explicit CompactListList_dev(const List<Container>&);
//- Construct given size of offset table (number of rows)
// and number of data.
inline CompactListList_dev(const label nRows, const label nData);
//- Construct given size of offset table (number of rows),
// the number of data and a value for all elements.
inline CompactListList_dev(const label nRows, const label nData, const T&);
//- Construct given list of row-sizes.
explicit CompactListList_dev(const UList<label>& rowSizes);
//- Construct given list of row-sizes
CompactListList_dev(const UList<label>& rowSizes, const T&);
//- Construct by transferring the parameter contents
explicit CompactListList_dev(const Xfer<CompactListList_dev<T, Container> >&);
//- Construct as copy or re-use as specified.
CompactListList_dev(CompactListList_dev<T, Container>&, bool reUse);
//- Construct from Istream.
CompactListList_dev(Istream&);
//- Clone
inline autoPtr<CompactListList_dev<T, Container> > clone() const;
// Member Functions
// Access
//- Return the primary size, i.e. the number of rows
inline label size() const;
//- Return true if the number of rows is zero
inline bool empty() const;
//- Return the offset table (= size()+1)
inline const List<label>& offsets() const;
//- Return non-const access to the offset table
inline List<label>& offsets();
//- Return the packed matrix of data
inline const List<T>& m() const;
//- Return non-const access to the packed matrix of data
inline List<T>& m();
// Edit
//- Reset size of CompactListList_dev.
// This form only allows contraction of the CompactListList_dev.
void setSize(const label nRows);
//- Reset size of CompactListList_dev.
void setSize(const label nRows, const label nData);
//- Reset sizes of CompactListList_dev and value for new elements.
void setSize(const label nRows, const label nData, const T&);
//- Reset size of CompactListList_dev.
void setSize(const UList<label>& rowSizes);
//- Reset size of CompactListList_dev.
// This form only allows contraction of the CompactListList_dev.
inline void resize(const label nRows);
//- Reset size of CompactListList_dev.
inline void resize(const label nRows, const label nData);
//- Reset sizes of CompactListList_dev and value for new elements.
inline void resize(const label nRows, const label nData, const T&);
//- Reset size of CompactListList_dev.
inline void resize(const UList<label>& rowSizes);
//- Clear the CompactListList_dev, i.e. set sizes to zero.
void clear();
//- Return sizes (to be used e.g. for construction)
labelList sizes() const;
//- Transfer the contents of the argument CompactListList_dev
// into this CompactListList_dev and annul the argument list.
void transfer(CompactListList_dev<T, Container>&);
//- Transfer the contents to the Xfer container
inline Xfer<CompactListList_dev<T, Container> > xfer();
// Other
//- Return index into m
inline label index(const label row, const label col) const;
//- Get row for index into m.
inline label whichRow(const label index) const;
//- Get column index (j) given above row
inline label whichColumn(const label row, const label index) const;
// Member operators
//- Return subscript-checked row as UList.
inline UList<T> operator[](const label i);
//- Return const subscript-checked row as UList.
inline const UList<T> operator[](const label i) const;
//- Return subscript-checked element.
inline T& operator()(const label i, const label j);
//- Return const subscript-checked element.
inline const T& operator()(const label i, const label j) const;
//- Return as List<Container>
List<Container> operator()() const;
//- Assignment of all entries to the given value
inline void operator=(const T&);
// Istream operator
//- Read CompactListList_dev from Istream, discarding contents
// of existing CompactListList_dev.
friend Istream& operator>> <T, Container>
(
Istream&,
CompactListList_dev<T, Container>&
);
// Write CompactListList_dev to Ostream.
friend Ostream& operator<< <T, Container>
(
Ostream&,
const CompactListList_dev<T, Container>&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
# include "CompactListList_devI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "CompactListList_dev.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,276 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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 "ListOps.H"
#include "SubList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T, class Container>
inline Foam::CompactListList_dev<T, Container>::CompactListList_dev()
:
size_(0)
{}
template<class T, class Container>
inline Foam::CompactListList_dev<T, Container>::CompactListList_dev
(
const label nRows,
const label nData
)
:
size_(nRows),
offsets_(nRows+1, 0),
m_(nData)
{}
template<class T, class Container>
inline Foam::CompactListList_dev<T, Container>::CompactListList_dev
(
const label nRows,
const label nData,
const T& t
)
:
size_(nRows),
offsets_(nRows+1, 0),
m_(nData, t)
{}
template<class T, class Container>
inline Foam::autoPtr<Foam::CompactListList_dev<T, Container> >
Foam::CompactListList_dev<T, Container>::clone() const
{
return autoPtr<CompactListList_dev<T, Container> >
(
new CompactListList_dev<T, Container>(*this)
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, class Container>
inline const Foam::CompactListList_dev<T, Container>&
Foam::CompactListList_dev<T, Container>::null()
{
return *reinterpret_cast< CompactListList_dev<T, Container>* >(0);
}
template<class T, class Container>
inline Foam::label Foam::CompactListList_dev<T, Container>::size() const
{
return size_;
}
template<class T, class Container>
inline bool Foam::CompactListList_dev<T, Container>::empty() const
{
return !size_;
}
template<class T, class Container>
inline const Foam::List<Foam::label>&
Foam::CompactListList_dev<T, Container>::offsets() const
{
return offsets_;
}
template<class T, class Container>
inline Foam::List<Foam::label>& Foam::CompactListList_dev<T, Container>::offsets()
{
return offsets_;
}
template<class T, class Container>
inline const Foam::List<T>& Foam::CompactListList_dev<T, Container>::m()
const
{
return m_;
}
template<class T, class Container>
inline Foam::List<T>& Foam::CompactListList_dev<T, Container>::m()
{
return m_;
}
template<class T, class Container>
inline Foam::label Foam::CompactListList_dev<T, Container>::index
(
const label i,
const label j
) const
{
return offsets_[i] + j;
}
template<class T, class Container>
inline Foam::label Foam::CompactListList_dev<T, Container>::whichRow(const label i)
const
{
if (i < 0 || i >= m_.size())
{
FatalErrorIn
(
"CompactListList_dev<T, Container>::whichRow(const label) const"
) << "Index " << i << " outside 0.." << m_.size()
<< abort(FatalError);
}
return findLower(offsets_, i+1);
}
template<class T, class Container>
inline Foam::label Foam::CompactListList_dev<T, Container>::whichColumn
(
const label row,
const label i
) const
{
return i - index(row, 0);
}
template<class T, class Container>
inline Foam::Xfer<Foam::CompactListList_dev<T, Container> >
Foam::CompactListList_dev<T, Container>::xfer()
{
return xferMove(*this);
}
template<class T, class Container>
inline void Foam::CompactListList_dev<T, Container>::resize(const label nRows)
{
this->setSize(nRows);
}
template<class T, class Container>
inline void Foam::CompactListList_dev<T, Container>::resize
(
const label nRows,
const label nData
)
{
this->setSize(nRows, nData);
}
template<class T, class Container>
inline void Foam::CompactListList_dev<T, Container>::resize
(
const label nRows,
const label nData,
const T& t
)
{
this->setSize(nRows, nData, t);
}
template<class T, class Container>
inline void Foam::CompactListList_dev<T, Container>::resize
(
const UList<label>& rowSizes
)
{
this->setSize(rowSizes);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T, class Container>
inline Foam::UList<T> Foam::CompactListList_dev<T, Container>::operator[]
(
const label i
)
{
label start = offsets_[i];
return UList<T>((m_.size() ? &m_[start] : NULL), offsets_[i+1] - start);
}
template<class T, class Container>
inline const Foam::UList<T>
Foam::CompactListList_dev<T, Container>::operator[]
(
const label i
) const
{
label start = offsets_[i];
return UList<T>
(
(m_.size() ? const_cast<T*>(&m_[start]) : NULL),
offsets_[i+1] - start
);
}
template<class T, class Container>
inline T& Foam::CompactListList_dev<T, Container>::operator()
(
const label i,
const label j
)
{
return m_[index(i, j)];
}
template<class T, class Container>
inline const T& Foam::CompactListList_dev<T, Container>::operator()
(
const label i,
const label j
) const
{
return m_[index(i, j)];
}
template<class T, class Container>
inline void Foam::CompactListList_dev<T, Container>::operator=(const T& t)
{
m_ = t;
}
// ************************************************************************* //

View file

@ -1,66 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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 "CompactListList_dev.H"
#include "Istream.H"
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
template<class T, class Container>
Foam::CompactListList_dev<T, Container>::CompactListList_dev(Istream& is)
{
operator>>(is, *this);
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class T, class Container>
Foam::Istream& Foam::operator>>(Istream& is, CompactListList_dev<T, Container>& lst)
{
is >> lst.offsets_ >> lst.m_;
// Note: empty list gets output as two empty lists
if (lst.offsets_.size() == 0)
{
lst.size_ = 0;
}
else
{
lst.size_ = lst.offsets_.size()-1;
}
return is;
}
template<class T, class Container>
Foam::Ostream& Foam::operator<<(Ostream& os, const CompactListList_dev<T, Container>& lst)
{
os << lst.offsets_ << lst.m_;
return os;
}
// ************************************************************************* //

View file

@ -1,368 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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::fvMeshDistribute
Description
Sends/receives parts of mesh+fvfields to neighbouring processors.
Used in load balancing.
Input is per local cell the processor it should move to. Moves meshes
and volFields/surfaceFields and returns map which can be used to
distribute other.
Notes:
- does not handle cyclics. Will probably handle separated proc patches.
- if all cells move off processor also all its processor patches will
get deleted so comms might be screwed up (since e.g. globalMeshData
expects procPatches on all)
- initial mesh has to have procPatches last and all normal patches common
to all processors and in the same order. This is checked.
- faces are matched topologically but points on the faces are not. So
expect problems -on separated patches (cyclics?) -on zero sized processor
edges.
SourceFiles
fvMeshDistribute.C
fvMeshDistributeTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef fvMeshDistribute_H
#define fvMeshDistribute_H
#include "Field.H"
//#include "uLabel.H"
#include "fvMeshSubset.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class mapAddedPolyMesh;
class mapDistributePolyMesh;
/*---------------------------------------------------------------------------*\
Class fvMeshDistribute Declaration
\*---------------------------------------------------------------------------*/
class fvMeshDistribute
{
// Private data
//- Underlying fvMesh
fvMesh& mesh_;
//- Absolute merging tolerance (constructing meshes gets done using
// geometric matching)
const scalar mergeTol_;
// Private Member Functions
//- Find indices with value
static labelList select
(
const bool selectEqual,
const labelList& values,
const label value
);
//- Check all procs have same names and in exactly same order.
static void checkEqualWordList(const string&, const wordList&);
//- Merge wordlists over all processors
static wordList mergeWordList(const wordList&);
// Patch handling
//- Find patch to put exposed faces into.
label findNonEmptyPatch() const;
//- Appends processorPolyPatch. Returns patchID.
label addProcPatch(const word& patchName, const label nbrProc);
//- Add patch field
template<class GeoField>
void addPatchFields(const word& patchFieldType);
//- Deletes last patch.
void deleteTrailingPatch();
// Delete trailing patch fields
template<class GeoField>
void deleteTrailingPatchFields();
//- Save boundary fields
template <class T, class Mesh>
void saveBoundaryFields
(
PtrList<FieldField<fvsPatchField, T> >& bflds
) const;
//- Map boundary fields
template <class T, class Mesh>
void mapBoundaryFields
(
const mapPolyMesh& map,
const PtrList<FieldField<fvsPatchField, T> >& oldBflds
);
//- Init patch fields of certain type
template<class GeoField, class PatchFieldType>
void initPatchFields
(
const typename GeoField::value_type& initVal
);
//- Delete all processor patches. Move any processor faces into
// patchI.
autoPtr<mapPolyMesh> deleteProcPatches(const label patchI);
//- Repatch the mesh. This is only nessecary for the proc
// boundary faces. newPatchID is over all boundary faces: -1 or
// new patchID. constructFaceMap is being adapted for the
// possible new face position (since proc faces get automatically
// matched)
autoPtr<mapPolyMesh> repatch
(
const labelList& newPatchID,
labelListList& constructFaceMap
);
//- Merge any shared points that are geometrically shared. Needs
// parallel valid mesh - uses globalMeshData.
// constructPointMap is adapted for the new point labels.
autoPtr<mapPolyMesh> mergeSharedPoints
(
labelListList& constructPointMap
);
// Coupling information
//- Construct the local environment of all boundary faces.
void getNeighbourData
(
const labelList& distribution,
labelList& sourceFace,
labelList& sourceProc,
labelList& sourceNewProc
) const;
// Subset the neighbourCell/neighbourProc fields
static void subsetBoundaryData
(
const fvMesh& mesh,
const labelList& faceMap,
const labelList& cellMap,
const labelList& oldDistribution,
const labelList& oldFaceOwner,
const labelList& oldFaceNeighbour,
const label oldInternalFaces,
const labelList& sourceFace,
const labelList& sourceProc,
const labelList& sourceNewProc,
labelList& subFace,
labelList& subProc,
labelList& subNewProc
);
//- Find cells on mesh whose faceID/procID match the neighbour
// cell/proc of domainMesh. Store the matching face.
static void findCouples
(
const primitiveMesh&,
const labelList& sourceFace,
const labelList& sourceProc,
const label domain,
const primitiveMesh& domainMesh,
const labelList& domainFace,
const labelList& domainProc,
labelList& masterCoupledFaces,
labelList& slaveCoupledFaces
);
//- Map data on boundary faces to new mesh (resulting from adding
// two meshes)
static labelList mapBoundaryData
(
const primitiveMesh& mesh, // mesh after adding
const mapAddedPolyMesh& map,
const labelList& boundaryData0, // mesh before adding
const label nInternalFaces1,
const labelList& boundaryData1 // added mesh
);
// Other
//- Remove cells. Add all exposed faces to patch oldInternalPatchI
autoPtr<mapPolyMesh> doRemoveCells
(
const labelList& cellsToRemove,
const label oldInternalPatchI
);
//- Add processor patches. Changes mesh and returns per neighbour
// proc the processor patchID.
void addProcPatches
(
const labelList&, // processor that neighbour is on
labelList& procPatchID
);
//- Get boundary faces to be repatched. Is -1 or new patchID
static labelList getProcBoundaryPatch
(
const labelList& neighbourNewProc,// new processor per b. face
const labelList& procPatchID // patchID
);
//- Send mesh and coupling data.
static void sendMesh
(
const label domain,
const fvMesh& mesh,
const wordList& pointZoneNames,
const wordList& facesZoneNames,
const wordList& cellZoneNames,
const labelList& sourceFace,
const labelList& sourceProc,
const labelList& sourceNewProc,
OSstream& toDomain
);
//- Send subset of fields
template<class GeoField>
static void sendFields
(
const label domain,
const wordList& fieldNames,
const fvMeshSubset&,
OSstream& toNbr
);
//- Receive mesh. Opposite of sendMesh
static autoPtr<fvMesh> receiveMesh
(
const label domain,
const wordList& pointZoneNames,
const wordList& facesZoneNames,
const wordList& cellZoneNames,
const Time& runTime,
labelList& domainSourceFace,
labelList& domainSourceProc,
labelList& domainSourceNewProc,
ISstream& fromNbr
);
//- Receive fields. Opposite of sendFields
template<class GeoField>
static void receiveFields
(
const label domain,
const wordList& fieldNames,
fvMesh&,
PtrList<GeoField>&,
const dictionary& fieldDicts
);
//- Do parallel exchange
template <class Container, class T>
static void exchange
(
const List<Container >& sendBufs,
List<Container >& recvBufs,
labelListList& sizes
);
//- Disallow default bitwise copy construct
fvMeshDistribute(const fvMeshDistribute&);
//- Disallow default bitwise assignment
void operator=(const fvMeshDistribute&);
public:
ClassName("fvMeshDistribute");
// Constructors
//- Construct from mesh and absolute merge tolerance
fvMeshDistribute(fvMesh& mesh, const scalar mergeTol);
// Member Functions
//- Helper function: count cells per processor in wanted distribution
static labelList countCells(const labelList&);
//- Send cells to neighbours according to distribution
// (for every cell the new proc)
autoPtr<mapDistributePolyMesh> distribute(const labelList& dist);
// Debugging
//- Print some info on coupling data
static void printCoupleInfo
(
const primitiveMesh&,
const labelList&,
const labelList&,
const labelList&
);
//- Print some field info
template<class GeoField>
static void printFieldInfo(const fvMesh&);
//- Print some info on mesh.
static void printMeshInfo(const fvMesh&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "fvMeshDistributeTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,499 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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 "mapPolyMesh.H"
#include "PstreamCombineReduceOps.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
//- combineReduce operator for lists. Used for counting.
class listEq
{
public:
template<class T>
void operator()(T& x, const T& y) const
{
forAll(y, i)
{
if (y[i].size())
{
x[i] = y[i];
}
}
}
};
template <class Container, class T>
void Foam::fvMeshDistribute::exchange
(
const List<Container >& sendBufs,
List<Container >& recvBufs,
labelListList& sizes
)
{
if (Pstream::parRun())
{
if (!contiguous<T>())
{
FatalErrorIn
(
"Pstream::exchange(..)"
) << "Continuous data only." << Foam::abort(FatalError);
}
if (sendBufs.size() != Pstream::nProcs())
{
FatalErrorIn
(
"Pstream::exchange(..)"
) << "Size of list:" << sendBufs.size()
<< " does not equal the number of processors:"
<< Pstream::nProcs()
<< Foam::abort(FatalError);
}
sizes.setSize(Pstream::nProcs());
labelList& nsTransPs = sizes[Pstream::myProcNo()];
nsTransPs.setSize(Pstream::nProcs());
forAll(sendBufs, procI)
{
nsTransPs[procI] = sendBufs[procI].size();
}
Foam::combineReduce(sizes, listEq());
// Set up receives
// ~~~~~~~~~~~~~~~
recvBufs.setSize(sendBufs.size());
forAll(sizes, procI)
{
label nRecv = sizes[procI][Pstream::myProcNo()];
if (procI != Pstream::myProcNo() && nRecv > 0)
{
recvBufs[procI].setSize(nRecv);
IPstream::read
(
Pstream::nonBlocking,
procI,
reinterpret_cast<char*>(recvBufs[procI].begin()),
nRecv*sizeof(T)
);
}
}
// Set up sends
// ~~~~~~~~~~~~
forAll(sendBufs, procI)
{
if (procI != Pstream::myProcNo() && sendBufs[procI].size() > 0)
{
if
(
!OPstream::write
(
Pstream::nonBlocking,
procI,
reinterpret_cast<const char*>(sendBufs[procI].begin()),
sendBufs[procI].size()*sizeof(T)
)
)
{
FatalErrorIn("Pstream::exchange(..)")
<< "Cannot send outgoing message. "
<< "to:" << procI << " nBytes:"
<< label(sendBufs[procI].size()*sizeof(T))
<< Foam::abort(FatalError);
}
}
}
// Wait for all to finish
// ~~~~~~~~~~~~~~~~~~~~~~
IPstream::waitRequests();
OPstream::waitRequests();
}
// Do myself
recvBufs[Pstream::myProcNo()] = sendBufs[Pstream::myProcNo()];
}
template<class GeoField>
void Foam::fvMeshDistribute::printFieldInfo(const fvMesh& mesh)
{
HashTable<const GeoField*> flds
(
mesh.objectRegistry::lookupClass<GeoField>()
);
for
(
typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
{
const GeoField& fld = *iter();
Pout<< "Field:" << iter.key() << " internalsize:" << fld.size()
//<< " value:" << fld
<< endl;
forAll(fld.boundaryField(), patchI)
{
Pout<< " " << patchI
<< ' ' << fld.boundaryField()[patchI].patch().name()
<< ' ' << fld.boundaryField()[patchI].type()
<< ' ' << fld.boundaryField()[patchI].size()
<< endl;
}
}
}
template<class GeoField>
void Foam::fvMeshDistribute::addPatchFields(const word& patchFieldType)
{
HashTable<const GeoField*> flds
(
mesh_.objectRegistry::lookupClass<GeoField>()
);
for
(
typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
{
const GeoField& fld = *iter();
typename GeoField::GeometricBoundaryField& bfld =
const_cast<typename GeoField::GeometricBoundaryField&>
(
fld.boundaryField()
);
label sz = bfld.size();
bfld.setSize(sz + 1);
bfld.set
(
sz,
GeoField::PatchFieldType::New
(
patchFieldType,
mesh_.boundary()[sz],
fld.dimensionedInternalField()
)
);
}
}
// Delete trailing patch fields
template<class GeoField>
void Foam::fvMeshDistribute::deleteTrailingPatchFields()
{
HashTable<const GeoField*> flds
(
mesh_.objectRegistry::lookupClass<GeoField>()
);
for
(
typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
{
const GeoField& fld = *iter();
typename GeoField::GeometricBoundaryField& bfld =
const_cast<typename GeoField::GeometricBoundaryField&>
(
fld.boundaryField()
);
// Shrink patchFields
bfld.setSize(bfld.size() - 1);
}
}
// Save whole boundary field
template <class T, class Mesh>
void Foam::fvMeshDistribute::saveBoundaryFields
(
PtrList<FieldField<fvsPatchField, T> >& bflds
) const
{
typedef GeometricField<T, fvsPatchField, Mesh> fldType;
HashTable<const fldType*> flds
(
mesh_.objectRegistry::lookupClass<fldType>()
);
bflds.setSize(flds.size());
label i = 0;
for
(
typename HashTable<const fldType*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
{
const fldType& fld = *iter();
bflds.set(i, fld.boundaryField().clone().ptr());
i++;
}
}
// Map boundary field
template <class T, class Mesh>
void Foam::fvMeshDistribute::mapBoundaryFields
(
const mapPolyMesh& map,
const PtrList<FieldField<fvsPatchField, T> >& oldBflds
)
{
const labelList& oldPatchStarts = map.oldPatchStarts();
const labelList& faceMap = map.faceMap();
typedef GeometricField<T, fvsPatchField, Mesh> fldType;
HashTable<const fldType*> flds
(
mesh_.objectRegistry::lookupClass<fldType>()
);
if (flds.size() != oldBflds.size())
{
FatalErrorIn("fvMeshDistribute::mapBoundaryFields(..)") << "problem"
<< abort(FatalError);
}
label fieldI = 0;
for
(
typename HashTable<const fldType*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
{
const fldType& fld = *iter();
typename fldType::GeometricBoundaryField& bfld =
const_cast<typename fldType::GeometricBoundaryField&>
(
fld.boundaryField()
);
const FieldField<fvsPatchField, T>& oldBfld = oldBflds[fieldI++];
// Pull from old boundary field into bfld.
forAll(bfld, patchI)
{
fvsPatchField<T>& patchFld = bfld[patchI];
label faceI = patchFld.patch().patch().start();
forAll(patchFld, i)
{
label oldFaceI = faceMap[faceI++];
// Find patch and local patch face oldFaceI was in.
forAll(oldPatchStarts, oldPatchI)
{
label oldLocalI = oldFaceI - oldPatchStarts[oldPatchI];
if (oldLocalI >= 0 && oldLocalI < oldBfld[oldPatchI].size())
{
patchFld[i] = oldBfld[oldPatchI][oldLocalI];
}
}
}
}
}
}
// Init patch fields of certain type
template<class GeoField, class PatchFieldType>
void Foam::fvMeshDistribute::initPatchFields
(
const typename GeoField::value_type& initVal
)
{
HashTable<const GeoField*> flds
(
mesh_.objectRegistry::lookupClass<GeoField>()
);
for
(
typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
{
const GeoField& fld = *iter();
typename GeoField::GeometricBoundaryField& bfld =
const_cast<typename GeoField::GeometricBoundaryField&>
(
fld.boundaryField()
);
forAll(bfld, patchI)
{
if (isA<PatchFieldType>(bfld[patchI]))
{
bfld[patchI] == initVal;
}
}
}
}
// Send fields. Note order supplied so we can receive in exactly the same order.
// Note that field gets written as entry in dictionary so we
// can construct from subdictionary.
// (since otherwise the reading as-a-dictionary mixes up entries from
// consecutive fields)
// The dictionary constructed is:
// volScalarField
// {
// p {internalField ..; boundaryField ..;}
// k {internalField ..; boundaryField ..;}
// }
// volVectorField
// {
// U {internalField ... }
// }
// volVectorField {U {internalField ..; boundaryField ..;}}
//
template<class GeoField>
void Foam::fvMeshDistribute::sendFields
(
const label domain,
const wordList& fieldNames,
const fvMeshSubset& subsetter,
OSstream& toNbr
)
{
toNbr << GeoField::typeName << token::NL << token::BEGIN_BLOCK << token::NL;
forAll(fieldNames, i)
{
if (debug)
{
Pout<< "Subsetting field " << fieldNames[i]
<< " for domain:" << domain << endl;
}
// Send all fieldNames. This has to be exactly the same set as is
// being received!
const GeoField& fld =
subsetter.baseMesh().lookupObject<GeoField>(fieldNames[i]);
tmp<GeoField> tsubfld = subsetter.interpolate(fld);
toNbr
<< fieldNames[i] << token::NL << token::BEGIN_BLOCK
<< tsubfld
<< token::NL << token::END_BLOCK << token::NL;
}
toNbr << token::END_BLOCK << token::NL;
}
// Opposite of sendFields
template<class GeoField>
void Foam::fvMeshDistribute::receiveFields
(
const label domain,
const wordList& fieldNames,
fvMesh& mesh,
PtrList<GeoField>& fields,
const dictionary& fieldDicts
)
{
if (debug)
{
Pout<< "Receiving fields " << fieldNames
<< " from domain:" << domain << endl;
}
fields.setSize(fieldNames.size());
forAll(fieldNames, i)
{
if (debug)
{
Pout<< "Constructing field " << fieldNames[i]
<< " from domain:" << domain << endl;
}
fields.set
(
i,
new GeoField
(
IOobject
(
fieldNames[i],
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
fieldDicts.subDict(fieldNames[i])
)
);
}
}
// ************************************************************************* //

View file

@ -360,7 +360,7 @@ edgeInterpolationScheme<Type>::interpolate
for (label i=0; i<size; i++) for (label i=0; i<size; i++)
{ {
const tensorField& curT = const tensorField& curT =
mesh.edgeTransformTensors()[start + i]; mesh.edgeTransformTensors()[start + i];
const tensor& Te = curT[0]; const tensor& Te = curT[0];
@ -372,13 +372,13 @@ edgeInterpolationScheme<Type>::interpolate
( (
Te.T(), Te.T(),
pLambda[i]*transform(TP, pOwnVf[i]) pLambda[i]*transform(TP, pOwnVf[i])
+ (1.0 - pLambda[i])*transform(TN, pNgbVf[i]) + (1 - pLambda[i])*transform(TN, pNgbVf[i])
); );
} }
// tsf().boundaryField()[pi] = // tsf().boundaryField()[pi] =
// pLambda*vf.boundaryField()[pi].patchInternalField() // pLambda*vf.boundaryField()[pi].patchInternalField()
// + (1.0 - pLambda)*vf.boundaryField()[pi].patchNeighbourField(); // + (1 - pLambda)*vf.boundaryField()[pi].patchNeighbourField();
} }
else else
{ {

View file

@ -118,7 +118,7 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
return; return;
} }
// a simpler way of doing this would be nice // A simpler way of doing this would be nice
scalar avgU = -flowRate_/gSum(patch().magSf()); scalar avgU = -flowRate_/gSum(patch().magSf());
vectorField n = patch().nf(); vectorField n = patch().nf();
@ -128,7 +128,7 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
if (phi.dimensions() == dimVelocity*dimArea) if (phi.dimensions() == dimVelocity*dimArea)
{ {
// volumetric flow-rate // Volumetric flow-rate
operator==(n*avgU); operator==(n*avgU);
} }
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea) else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
@ -136,7 +136,7 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
const fvPatchField<scalar>& rhop = const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_); patch().lookupPatchField<volScalarField, scalar>(rhoName_);
// mass flow-rate // Mass flow-rate
operator==(n*avgU/rhop); operator==(n*avgU/rhop);
} }
else else

View file

@ -69,10 +69,10 @@ tmp<volScalarField> CoEulerDdtScheme<Type>::CorDeltaT() const
forAll(owner, faceI) forAll(owner, faceI)
{ {
corDeltaT[owner[faceI]] = corDeltaT[owner[faceI]] =
max(corDeltaT[owner[faceI]], cofrDeltaT[faceI]); max(corDeltaT[owner[faceI]], cofrDeltaT[faceI]);
corDeltaT[neighbour[faceI]] = corDeltaT[neighbour[faceI]] =
max(corDeltaT[neighbour[faceI]], cofrDeltaT[faceI]); max(corDeltaT[neighbour[faceI]], cofrDeltaT[faceI]);
} }

View file

@ -206,7 +206,10 @@ public:
} }
template<class T> template<class T>
const typename Field<T>::subField patchSlice(const Field<T>& l) const const typename Field<T>::subField patchSlice
(
const Field<T>& l
) const
{ {
return typename Field<T>::subField return typename Field<T>::subField
( (

View file

@ -59,12 +59,11 @@ void Foam::processorTetPolyPatchCellDecomp::calcMeshPoints() const
masterFaces[faceI] = pp[faceI].reverseFace(); masterFaces[faceI] = pp[faceI].reverseFace();
} }
mp = mp = primitiveFacePatch
primitiveFacePatch (
( masterFaces,
masterFaces, pp.points()
pp.points() ).meshPoints();
).meshPoints();
} }
// Get reference to shared points // Get reference to shared points