Commit c3d4f899 authored by henry's avatar henry
Browse files
parents 15bc2dd1 908c6168
......@@ -45,7 +45,7 @@ Description
so cannot have any cells in any other zone.
- useCellZonesOnly does not do a walk and uses the cellZones only. Use
this if you don't mind having disconnected domains in a single region.
This option requires all cells to be in one (and one only) region.
This option requires all cells to be in one (and one only) cellZone.
\*---------------------------------------------------------------------------*/
......
......@@ -206,6 +206,21 @@ done
cmd=""
if [ .$WM_MPLIB = .OPENMPI ]; then
cmd="mpirun -app $PWD/mpirun.schema </dev/null"
elif [ .$WM_MPLIB = .MPICH ]; then
cmd="mpiexec"
for ((proc=0; proc<$nProcs; proc++))
do
read procCmd
procXtermCmdFile="$PWD/processor${proc}Xterm.sh"
echo "#!/bin/sh" > $procXtermCmdFile
echo "$procCmd" >> $procXtermCmdFile
chmod +x $procXtermCmdFile
if [ $proc -ne 0 ]; then
cmd="${cmd} :"
fi
cmd="${cmd} -n 1 ${procXtermCmdFile}"
done < $PWD/mpirun.schema
fi
echo "Constructed $PWD/mpirun.schema file."
......
......@@ -184,6 +184,12 @@ public:
// an out-of-range element returns false without any ill-effects
inline const T& operator[](const label) const;
//- Return last element of UList.
inline T& last();
//- Return last element of UList.
inline const T& last() const;
//- Allow cast to a const List<T>&
inline operator const Foam::List<T>&() const;
......
......@@ -114,6 +114,20 @@ inline void Foam::UList<T>::checkIndex(const label i) const
}
template<class T>
inline T& Foam::UList<T>::last()
{
return this->operator[](this->size()-1);
}
template<class T>
inline const T& Foam::UList<T>::last() const
{
return this->operator[](this->size()-1);
}
template<class T>
inline const T* Foam::UList<T>::cdata() const
{
......
......@@ -82,9 +82,6 @@ void Foam::PstreamBuffers::finishedSends(labelListList& sizes, const bool block)
if (commsType_ == UPstream::nonBlocking)
{
labelListList sizes;
labelListList send,recv;
Pstream::exchange<DynamicList<char>, char>
(
sendBuf_,
......@@ -96,20 +93,30 @@ void Foam::PstreamBuffers::finishedSends(labelListList& sizes, const bool block)
}
else
{
sizes.setSize(UPstream::nProcs());
labelList& nsTransPs = sizes[UPstream::myProcNo()];
nsTransPs.setSize(UPstream::nProcs());
forAll(sendBuf_, procI)
{
nsTransPs[procI] = sendBuf_[procI].size();
}
// Send sizes across.
int oldTag = UPstream::msgType();
UPstream::msgType() = tag_;
combineReduce(sizes, UPstream::listEq());
UPstream::msgType() = oldTag;
FatalErrorIn
(
"PstreamBuffers::finishedSends(labelListList&, const bool)"
) << "Obtaining sizes not supported in "
<< UPstream::commsTypeNames[commsType_] << endl
<< " since transfers already in progress. Use non-blocking instead."
<< exit(FatalError);
// Note: possible only if using different tag from write started
// by ~UOPstream. Needs some work.
//sizes.setSize(UPstream::nProcs());
//labelList& nsTransPs = sizes[UPstream::myProcNo()];
//nsTransPs.setSize(UPstream::nProcs());
//
//forAll(sendBuf_, procI)
//{
// nsTransPs[procI] = sendBuf_[procI].size();
//}
//
//// Send sizes across.
//int oldTag = UPstream::msgType();
//UPstream::msgType() = tag_;
//combineReduce(sizes, UPstream::listEq());
//UPstream::msgType() = oldTag;
}
}
......
......@@ -138,7 +138,8 @@ public:
void finishedSends(const bool block = true);
//- Mark all sends as having been done. Same as above but also returns
// sizes (bytes) transferred.
// sizes (bytes) transferred. Note:currently only valid for
// non-blocking.
void finishedSends(labelListList& sizes, const bool block = true);
};
......
......@@ -50,43 +50,42 @@ void Pstream::exchange
const bool block
)
{
if (UPstream::parRun())
if (!contiguous<T>())
{
if (!contiguous<T>())
{
FatalErrorIn
(
"Pstream::exchange(..)"
) << "Continuous data only." << Foam::abort(FatalError);
}
if (sendBufs.size() != UPstream::nProcs())
{
FatalErrorIn
(
"Pstream::exchange(..)"
) << "Size of list:" << sendBufs.size()
<< " does not equal the number of processors:"
<< UPstream::nProcs()
<< Foam::abort(FatalError);
}
FatalErrorIn
(
"Pstream::exchange(..)"
) << "Continuous data only." << Foam::abort(FatalError);
}
sizes.setSize(UPstream::nProcs());
labelList& nsTransPs = sizes[UPstream::myProcNo()];
nsTransPs.setSize(UPstream::nProcs());
if (sendBufs.size() != UPstream::nProcs())
{
FatalErrorIn
(
"Pstream::exchange(..)"
) << "Size of list:" << sendBufs.size()
<< " does not equal the number of processors:"
<< UPstream::nProcs()
<< Foam::abort(FatalError);
}
forAll(sendBufs, procI)
{
nsTransPs[procI] = sendBufs[procI].size();
}
sizes.setSize(UPstream::nProcs());
labelList& nsTransPs = sizes[UPstream::myProcNo()];
nsTransPs.setSize(UPstream::nProcs());
// Send sizes across.
int oldTag = UPstream::msgType();
UPstream::msgType() = tag;
combineReduce(sizes, UPstream::listEq());
UPstream::msgType() = oldTag;
forAll(sendBufs, procI)
{
nsTransPs[procI] = sendBufs[procI].size();
}
// Send sizes across.
int oldTag = UPstream::msgType();
UPstream::msgType() = tag;
combineReduce(sizes, UPstream::listEq());
UPstream::msgType() = oldTag;
if (Pstream::parRun())
{
// Set up receives
// ~~~~~~~~~~~~~~~
......
......@@ -37,8 +37,43 @@ void Foam::OutputFilterFunctionObject<OutputFilter>::readDict()
dict_.readIfPresent("region", regionName_);
dict_.readIfPresent("dictionary", dictName_);
dict_.readIfPresent("enabled", enabled_);
dict_.readIfPresent("storeFilter", storeFilter_);
}
template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::allocateFilter()
{
if (dictName_.size())
{
ptr_.reset
(
new IOOutputFilter<OutputFilter>
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
);
}
else
{
ptr_.reset
(
new OutputFilter
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
);
}
}
template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::destroyFilter()
{
ptr_.reset();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -56,6 +91,7 @@ Foam::OutputFilterFunctionObject<OutputFilter>::OutputFilterFunctionObject
regionName_(polyMesh::defaultRegion),
dictName_(),
enabled_(true),
storeFilter_(true),
outputControl_(t, dict)
{
readDict();
......@@ -83,32 +119,9 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::start()
{
readDict();
if (enabled_)
if (enabled_&&storeFilter_)
{
if (dictName_.size())
{
ptr_.reset
(
new IOOutputFilter<OutputFilter>
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
);
}
else
{
ptr_.reset
(
new OutputFilter
(
name(),
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
);
}
allocateFilter();
}
return true;
......@@ -120,12 +133,22 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::execute()
{
if (enabled_)
{
if (!storeFilter_)
{
allocateFilter();
}
ptr_->execute();
if (enabled_ && outputControl_.output())
{
ptr_->write();
}
if (!storeFilter_)
{
destroyFilter();
}
}
return true;
......@@ -137,12 +160,22 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::end()
{
if (enabled_)
{
if (!storeFilter_)
{
allocateFilter();
}
ptr_->end();
if (enabled_ && outputControl_.output())
{
ptr_->write();
}
if (!storeFilter_)
{
destroyFilter();
}
}
return true;
......
......@@ -78,6 +78,10 @@ class OutputFilterFunctionObject
//- Switch for the execution of the functionObject
bool enabled_;
//- Switch to store filter in between writes or use on-the-fly
// construction
bool storeFilter_;
//- Output controls
outputFilterOutputControl outputControl_;
......@@ -89,6 +93,12 @@ class OutputFilterFunctionObject
//- Read relevant dictionary entries
void readDict();
//- Creates most of the data associated with this object.
void allocateFilter();
//- Destroys most of the data associated with this object.
void destroyFilter();
//- Disallow default bitwise copy construct
OutputFilterFunctionObject(const OutputFilterFunctionObject&);
......
......@@ -28,6 +28,9 @@ License
#include "polyBoundaryMesh.H"
#include "facePointPatch.H"
#include "globalPointPatch.H"
#include "PstreamBuffers.H"
#include "lduSchedule.H"
#include "globalMeshData.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -58,14 +61,46 @@ Foam::pointBoundaryMesh::pointBoundaryMesh
void Foam::pointBoundaryMesh::calcGeometry()
{
forAll(*this, patchi)
PstreamBuffers pBufs(Pstream::defaultCommsType);
if
(
Pstream::defaultCommsType == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking
)
{
operator[](patchi).initGeometry();
}
forAll(*this, patchi)
{
operator[](patchi).initGeometry(pBufs);
}
forAll(*this, patchi)
pBufs.finishedSends();
forAll(*this, patchi)
{
operator[](patchi).calcGeometry(pBufs);
}
}
else if (Pstream::defaultCommsType == Pstream::scheduled)
{
operator[](patchi).calcGeometry();
const lduSchedule& patchSchedule = mesh().globalData().patchSchedule();
// Dummy.
pBufs.finishedSends();
forAll(patchSchedule, patchEvali)
{
label patchi = patchSchedule[patchEvali].patch;
if (patchSchedule[patchEvali].init)
{
operator[](patchi).initGeometry(pBufs);
}
else
{
operator[](patchi).calcGeometry(pBufs);
}
}
}
}
......@@ -97,32 +132,92 @@ Foam::pointBoundaryMesh::globalPatch() const
void Foam::pointBoundaryMesh::movePoints(const pointField& p)
{
pointPatchList& patches = *this;
PstreamBuffers pBufs(Pstream::defaultCommsType);
forAll(patches, patchi)
if
(
Pstream::defaultCommsType == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking
)
{
patches[patchi].initMovePoints(p);
}
forAll(*this, patchi)
{
operator[](patchi).initMovePoints(pBufs, p);
}
forAll(patches, patchi)
pBufs.finishedSends();
forAll(*this, patchi)
{
operator[](patchi).movePoints(pBufs, p);
}
}
else if (Pstream::defaultCommsType == Pstream::scheduled)
{
patches[patchi].movePoints(p);
const lduSchedule& patchSchedule = mesh().globalData().patchSchedule();
// Dummy.
pBufs.finishedSends();
forAll(patchSchedule, patchEvali)
{
label patchi = patchSchedule[patchEvali].patch;
if (patchSchedule[patchEvali].init)
{
operator[](patchi).initMovePoints(pBufs, p);
}
else
{
operator[](patchi).movePoints(pBufs, p);
}
}
}
}
void Foam::pointBoundaryMesh::updateMesh()
{
pointPatchList& patches = *this;
PstreamBuffers pBufs(Pstream::defaultCommsType);
forAll(patches, patchi)
if
(
Pstream::defaultCommsType == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking
)
{
patches[patchi].initUpdateMesh();
}
forAll(*this, patchi)
{
operator[](patchi).initUpdateMesh(pBufs);
}
pBufs.finishedSends();
forAll(patches, patchi)
forAll(*this, patchi)
{
operator[](patchi).updateMesh(pBufs);
}
}
else if (Pstream::defaultCommsType == Pstream::scheduled)
{
patches[patchi].updateMesh();
const lduSchedule& patchSchedule = mesh().globalData().patchSchedule();
// Dummy.
pBufs.finishedSends();
forAll(patchSchedule, patchEvali)
{
label patchi = patchSchedule[patchEvali].patch;
if (patchSchedule[patchEvali].init)
{
operator[](patchi).initUpdateMesh(pBufs);
}
else
{
operator[](patchi).updateMesh(pBufs);
}
}
}
}
......
......@@ -66,22 +66,22 @@ protected:
// Protected Member Functions
//- Initialise the calculation of the patch geometry
virtual void initGeometry() = 0;
virtual void initGeometry(PstreamBuffers&) = 0;
//- Calculate the patch geometry
virtual void calcGeometry() = 0;
virtual void calcGeometry(PstreamBuffers&) = 0;
//- Initialise the patches for moving points
virtual void initMovePoints(const pointField&) = 0;
virtual void initMovePoints(PstreamBuffers&, const pointField&) = 0;
//- Correct patches after moving points
virtual void movePoints(const pointField&) = 0;
virtual void movePoints(PstreamBuffers&, const pointField&) = 0;
//- Initialise the update of the patch topology
virtual void initUpdateMesh() = 0;
virtual void initUpdateMesh(PstreamBuffers&) = 0;
//- Update of the patch topology
virtual void updateMesh() = 0;
virtual void updateMesh(PstreamBuffers&) = 0;
public:
......
......@@ -50,13 +50,13 @@ addToRunTimeSelectionTable
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::cyclicPointPatch::initGeometry()
void Foam::cyclicPointPatch::initGeometry(PstreamBuffers&)
{
transformPairs_.setSize(0);
}
void Foam::cyclicPointPatch::calcGeometry()
void Foam::cyclicPointPatch::calcGeometry(PstreamBuffers&)
{
const edgeList& cp = cyclicPolyPatch_.coupledPoints();
const labelList& mp = cyclicPolyPatch_.meshPoints();
......@@ -128,16 +128,20 @@ void Foam::cyclicPointPatch::calcGeometry()
}
else if (pointMap[cp[i][0]] == -1 && pointMap[cp[i][1]] != -1)
{
FatalErrorIn("cyclicPointPatch::calcGeometry() const")
<< "Point " << cp[i][0] << "of point-pair " << i
FatalErrorIn
(
"cyclicPointPatch::calcGeometry(PstreamBuffers&) const"
) << "Point " << cp[i][0] << "of point-pair " << i
<< " is a global point but the other point "
<< cp[i][1] << " is not"
<< exit(FatalError);
}