Commit 55f1a971 authored by Andrew Heather's avatar Andrew Heather
Browse files
parents aa684c3e 7c32ccaa
......@@ -57,7 +57,7 @@ int main(int argc, char *argv[])
//Info<< ck.specieThermo() << endl;
//Info<< ck.reactions() << endl;
PtrList<chemkinReader::reaction> reactions = ck.reactions();
const SLPtrList<gasReaction>& reactions = ck.reactions();
{
OFstream reactionStream("reactions");
......@@ -70,17 +70,17 @@ int main(int argc, char *argv[])
label nReactions(readLabel(reactionStream));
reactionStream.readBeginList(args.executable().c_str());
PtrList<chemkinReader::reaction> testReactions(nReactions);
PtrList<gasReaction> testReactions(nReactions);
forAll (testReactions, i)
{
testReactions.set
(
i,
chemkinReader::reaction::New
gasReaction::New
(
ck.species(),
ck.specieThermo(),
ck.speciesThermo(),
reactionStream
)
);
......
......@@ -39,6 +39,8 @@ Description
\* ------------------------------------------------------------------------- */
#include <sstream>
// For EOF only
#include <cstdio>
#include "scalar.H"
#include "IStringStream.H"
......
......@@ -41,6 +41,9 @@ Description
#include "scalarList.H"
#include "IStringStream.H"
// For EOF only
#include <cstdio>
using namespace Foam;
#include "argList.H"
......
......@@ -62,7 +62,7 @@ void writeProcStats
// Determine surface bounding boxes, faces, points
List<treeBoundBox> surfBb(Pstream::nProcs());
{
surfBb[Pstream::myProcNo()] = boundBox(s.points(), false);
surfBb[Pstream::myProcNo()] = treeBoundBox(s.points());
Pstream::gatherList(surfBb);
Pstream::scatterList(surfBb);
}
......
......@@ -61,8 +61,16 @@ namespace Foam
template<class T, class Container> class CompactListList;
template<class T, class Container> Istream& operator>>(Istream&, CompactListList<T, Container>&);
template<class T, class Container> Ostream& operator<<(Ostream&, const CompactListList<T, Container>&);
template<class T, class Container> Istream& operator>>
(
Istream&,
CompactListList<T, Container>&
);
template<class T, class Container> Ostream& operator<<
(
Ostream&,
const CompactListList<T, Container>&
);
/*---------------------------------------------------------------------------*\
......
......@@ -52,20 +52,11 @@ Foam::tmp
typename Foam::GeometricField<Type, PatchField, GeoMesh>::
GeometricBoundaryField
>
Foam::GeometricField<Type, PatchField, GeoMesh>::readField(Istream& is)
Foam::GeometricField<Type, PatchField, GeoMesh>::readField
(
const dictionary& fieldDict
)
{
if (is.version() < 2.0)
{
FatalIOErrorIn
(
"GeometricField<Type, PatchField, GeoMesh>::readField(Istream&)",
is
) << "IO versions < 2.0 are not supported."
<< exit(FatalIOError);
}
dictionary fieldDict(is);
DimensionedField<Type, GeoMesh>::readField(fieldDict, "internalField");
tmp<GeometricBoundaryField> tboundaryField
......@@ -96,6 +87,28 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::readField(Istream& is)
}
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp
<
typename Foam::GeometricField<Type, PatchField, GeoMesh>::
GeometricBoundaryField
>
Foam::GeometricField<Type, PatchField, GeoMesh>::readField(Istream& is)
{
if (is.version() < 2.0)
{
FatalIOErrorIn
(
"GeometricField<Type, PatchField, GeoMesh>::readField(Istream&)",
is
) << "IO versions < 2.0 are not supported."
<< exit(FatalIOError);
}
return readField(dictionary(is));
}
template<class Type, template<class> class PatchField, class GeoMesh>
bool Foam::GeometricField<Type, PatchField, GeoMesh>::readIfPresent()
{
......@@ -404,6 +417,44 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
}
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
(
const IOobject& io,
const Mesh& mesh,
const dictionary& dict
)
:
DimensionedField<Type, GeoMesh>(io, mesh, dimless),
timeIndex_(this->time().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
boundaryField_(*this, readField(dict))
{
// Check compatibility between field and mesh
if (this->size() != GeoMesh::size(this->mesh()))
{
FatalErrorIn
(
"GeometricField<Type, PatchField, GeoMesh>::GeometricField"
"(const IOobject&, const Mesh&, const dictionary&)"
) << " number of field elements = " << this->size()
<< " number of mesh elements = " << GeoMesh::size(this->mesh())
<< exit(FatalIOError);
}
readOldTimeIfPresent();
if (debug)
{
Info<< "Finishing dictionary-construct of "
"GeometricField<Type, PatchField, GeoMesh>"
<< endl << this->info() << endl;
}
}
// construct as copy
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
......
......@@ -240,6 +240,9 @@ private:
// Private member functions
//- Read the field from the dictionary
tmp<GeometricBoundaryField> readField(const dictionary&);
//- Read the field from the given stream
tmp<GeometricBoundaryField> readField(Istream& is);
......@@ -327,6 +330,14 @@ public:
Istream&
);
//- Construct from dictionary
GeometricField
(
const IOobject&,
const Mesh&,
const dictionary&
);
//- Construct as copy
GeometricField
(
......
......@@ -66,6 +66,14 @@ Foam::UIPstream::UIPstream
label wantedSize = externalBuf_.capacity();
if (debug)
{
Pout<< "UIPstream::UIPstream : read from:" << fromProcNo
<< " tag:" << tag << " wanted size:" << wantedSize
<< Foam::endl;
}
// If the buffer size is not specified, probe the incomming message
// and set it
if (!wantedSize)
......@@ -75,6 +83,12 @@ Foam::UIPstream::UIPstream
externalBuf_.setCapacity(messageSize_);
wantedSize = messageSize_;
if (debug)
{
Pout<< "UIPstream::UIPstream : probed size:" << wantedSize
<< Foam::endl;
}
}
messageSize_ = UIPstream::read
......@@ -127,6 +141,7 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
if (commsType() == UPstream::nonBlocking)
{
// Message is already received into externalBuf
messageSize_ = buffers.recvBuf_[fromProcNo].size();
}
else
{
......@@ -134,6 +149,14 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
label wantedSize = externalBuf_.capacity();
if (debug)
{
Pout<< "UIPstream::UIPstream PstreamBuffers :"
<< " read from:" << fromProcNo
<< " tag:" << tag_ << " wanted size:" << wantedSize
<< Foam::endl;
}
// If the buffer size is not specified, probe the incomming message
// and set it
if (!wantedSize)
......@@ -143,6 +166,12 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
externalBuf_.setCapacity(messageSize_);
wantedSize = messageSize_;
if (debug)
{
Pout<< "UIPstream::UIPstream PstreamBuffers : probed size:"
<< wantedSize << Foam::endl;
}
}
messageSize_ = UIPstream::read
......@@ -180,6 +209,14 @@ Foam::label Foam::UIPstream::read
const int tag
)
{
if (debug)
{
Pout<< "UIPstream::read : starting read from:" << fromProcNo
<< " tag:" << tag << " wanted size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< Foam::endl;
}
if (commsType == blocking || commsType == scheduled)
{
MPI_Status status;
......@@ -214,6 +251,14 @@ Foam::label Foam::UIPstream::read
label messageSize;
MPI_Get_count(&status, MPI_BYTE, &messageSize);
if (debug)
{
Pout<< "UIPstream::read : finished read from:" << fromProcNo
<< " tag:" << tag << " read size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< Foam::endl;
}
if (messageSize > bufSize)
{
FatalErrorIn
......@@ -256,6 +301,15 @@ Foam::label Foam::UIPstream::read
return 0;
}
if (debug)
{
Pout<< "UIPstream::read : started read from:" << fromProcNo
<< " tag:" << tag << " read size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< " request:" << PstreamGlobals::outstandingRequests_.size()
<< Foam::endl;
}
PstreamGlobals::outstandingRequests_.append(request);
// Assume the message is completely received.
......@@ -267,7 +321,8 @@ Foam::label Foam::UIPstream::read
(
"UIPstream::read"
"(const int fromProcNo, char* buf, std::streamsize bufSize)"
) << "Unsupported communications type " << commsType
) << "Unsupported communications type "
<< commsType
<< Foam::abort(FatalError);
return 0;
......
......@@ -43,6 +43,14 @@ bool Foam::UOPstream::write
const int tag
)
{
if (debug)
{
Pout<< "UIPstream::write : starting write to:" << toProcNo
<< " tag:" << tag << " size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< Foam::endl;
}
bool transferFailed = true;
if (commsType == blocking)
......@@ -56,6 +64,14 @@ bool Foam::UOPstream::write
tag,
MPI_COMM_WORLD
);
if (debug)
{
Pout<< "UIPstream::write : finished write to:" << toProcNo
<< " tag:" << tag << " size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< Foam::endl;
}
}
else if (commsType == scheduled)
{
......@@ -68,6 +84,14 @@ bool Foam::UOPstream::write
tag,
MPI_COMM_WORLD
);
if (debug)
{
Pout<< "UIPstream::write : finished write to:" << toProcNo
<< " tag:" << tag << " size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< Foam::endl;
}
}
else if (commsType == nonBlocking)
{
......@@ -84,6 +108,15 @@ bool Foam::UOPstream::write
&request
);
if (debug)
{
Pout<< "UIPstream::write : started write to:" << toProcNo
<< " tag:" << tag << " size:" << label(bufSize)
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< " request:" << PstreamGlobals::outstandingRequests_.size()
<< Foam::endl;
}
PstreamGlobals::outstandingRequests_.append(request);
}
else
......@@ -93,7 +126,8 @@ bool Foam::UOPstream::write
"UOPstream::write"
"(const int fromProcNo, char* buf, std::streamsize bufSize"
", const int)"
) << "Unsupported communications type " << commsType
) << "Unsupported communications type "
<< UPstream::commsTypeNames[commsType]
<< Foam::abort(FatalError);
}
......
......@@ -70,6 +70,12 @@ bool Foam::UPstream::init(int& argc, char**& argv)
MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &myProcNo_);
if (debug)
{
Pout<< "UPstream::init : initialised with numProcs:" << numprocs
<< " myProcNo:" << myProcNo_ << endl;
}
if (numprocs <= 1)
{
FatalErrorIn("UPstream::init(int& argc, char**& argv)")
......@@ -124,6 +130,11 @@ bool Foam::UPstream::init(int& argc, char**& argv)
void Foam::UPstream::exit(int errnum)
{
if (debug)
{
Pout<< "UPstream::exit." << endl;
}
# ifndef SGIMPI
int size;
char* buff;
......@@ -164,6 +175,11 @@ void Foam::UPstream::abort()
void Foam::reduce(scalar& Value, const sumOp<scalar>& bop)
{
if (Pstream::debug)
{
Pout<< "UPstream::reduce : value:" << Value << endl;
}
if (!UPstream::parRun())
{
return;
......@@ -433,11 +449,23 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop)
}
*/
}
if (Pstream::debug)
{
Pout<< "UPstream::reduce : reduced value:" << Value << endl;
}
}
void Foam::UPstream::waitRequests()
{
if (debug)
{
Pout<< "UPstream::waitRequests : starting wait for "
<< PstreamGlobals::outstandingRequests_.size()
<< " outstanding requests." << endl;
}
if (PstreamGlobals::outstandingRequests_.size())
{
if
......@@ -458,11 +486,22 @@ void Foam::UPstream::waitRequests()
PstreamGlobals::outstandingRequests_.clear();
}
if (debug)
{
Pout<< "UPstream::waitRequests : finished wait." << endl;
}
}
bool Foam::UPstream::finishedRequest(const label i)
{
if (debug)
{
Pout<< "UPstream::waitRequests : starting wait for request:" << i
<< endl;
}
if (i >= PstreamGlobals::outstandingRequests_.size())
{
FatalErrorIn
......@@ -483,6 +522,12 @@ bool Foam::UPstream::finishedRequest(const label i)
MPI_STATUS_IGNORE
);
if (debug)
{
Pout<< "UPstream::waitRequests : finished wait for request:" << i
<< endl;
}
return flag != 0;
}
......
......@@ -330,8 +330,6 @@ void Foam::fvMeshAdder::MapVolFields
if (fieldsToAdd.found(fld.name()))
{
Pout<< "Mapping field " << fld.name() << endl;
const GeometricField<Type, fvPatchField, volMesh>& fldToAdd =
*fieldsToAdd[fld.name()];
......@@ -339,7 +337,7 @@ void Foam::fvMeshAdder::MapVolFields
}
else
{
WarningIn("fvMeshAdder::MapVolFields")
WarningIn("fvMeshAdder::MapVolFields(..)")
<< "Not mapping field " << fld.name()
<< " since not present on mesh to add"
<< endl;
......@@ -642,15 +640,13 @@ void Foam::fvMeshAdder::MapSurfaceFields
if (fieldsToAdd.found(fld.name()))
{
Pout<< "Mapping field " << fld.name() << endl;
const fldType& fldToAdd = *fieldsToAdd[fld.name()];
MapSurfaceField<Type>(meshMap, fld, fldToAdd);
}
else
{
WarningIn("fvMeshAdder::MapSurfaceFields")
WarningIn("fvMeshAdder::MapSurfaceFields(..)")
<< "Not mapping field " << fld.name()
<< " since not present on mesh to add"
<< endl;
......
......@@ -82,38 +82,8 @@ class fvMeshDistribute
const scalar mergeTol_;
// Private classes
//- Check words are the same. Used in patch type checking of similarly
// named patches.
class checkEqualType
{
public:
void operator()(word& x, const word& y) const
{
if (x != y)
{
FatalErrorIn("checkEqualType()(word&, const word&) const")
<< "Patch type " << x << " possibly on processor "
<< Pstream::myProcNo()
<< " does not equal patch type " << y
<< " on some other processor." << nl
<< "Please check similarly named patches for"
<< " having exactly the same type."
<< abort(FatalError);
}
}
};
// Private Member Functions
//- Given distribution work out a communication schedule. Is list
// of pairs. First element of pair is send processor, second is
// receive processor.
//static List<labelPair> getSchedule(const labelList&);
//- Find indices with value
static labelList select
(
......@@ -123,7 +93,7 @@ class fvMeshDistribute
);
//- Check all procs have same names and in exactly same order.
static void checkEqualWordList(const wordList&);
static void checkEqualWordList(const string&, const wordList&);
//- Merge wordlists over all processors
static wordList mergeWordList(const wordList&);
......@@ -288,7 +258,8 @@ class fvMeshDistribute
const wordList& cellZoneNames,
const labelList& sourceFace,
const labelList& sourceProc,
const labelList& sourceNewProc
const labelList& sourceNewProc,
UOPstream& toDomain
);
//- Send subset of fields
template<class GeoField>
......@@ -296,7 +267,8 @@ class fvMeshDistribute
(
const label domain,
const wordList& fieldNames,
const fvMeshSubset&
const fvMeshSubset&,
UOPstream& toNbr
);
//- Receive mesh. Opposite of sendMesh
......@@ -309,7 +281,8 @@ class fvMeshDistribute
const Time& runTime,
labelList& domainSourceFace,
labelList& domainSourceProc,
labelList& domainSourceNewProc
labelList& domainSourceNewProc,
UIPstream& fromNbr
);
//- Receive fields. Opposite of sendFields
......@@ -319,7 +292,8 @@ class fvMeshDistribute
const label domain,
const wordList& fieldNames,
fvMesh&,
PtrList<GeoField>&
PtrList<GeoField>&,
const dictionary& fieldDicts
);
//- Disallow default bitwise copy construct
......
......@@ -184,7 +184,7 @@ void Foam::fvMeshDistribute::mapBoundaryFields
if (flds.size() != oldBflds.size())
{
FatalErrorIn("fvMeshDistribute::mapBoundaryFields") << "problem"
FatalErrorIn("fvMeshDistribute::mapBoundaryFields(..)") << "problem"
<< abort(FatalError);
}