Commit 05314755 authored by graham's avatar graham
Browse files

ENH: IO Improvements, seg fault in parallel needing found.

parent 0f7a1241
......@@ -70,8 +70,11 @@ Usage
#include "vectorIOField.H"
#include "vectorFieldIOField.H"
#include "sphericalTensorIOField.H"
#include "sphericalTensorFieldIOField.H"
#include "symmTensorIOField.H"
#include "symmTensorFieldIOField.H"
#include "tensorIOField.H"
#include "tensorFieldIOField.H"
#include "pointFields.H"
#include "readFields.H"
......@@ -395,14 +398,24 @@ int main(int argc, char *argv[])
(
cloudDirs.size()
);
PtrList<PtrList<sphericalTensorIOFieldField> >
lagrangianSphericalTensorFieldFields(cloudDirs.size());
PtrList<PtrList<symmTensorIOField> > lagrangianSymmTensorFields
(
cloudDirs.size()
);
PtrList<PtrList<symmTensorIOFieldField> > lagrangianSymmTensorFieldFields
(
cloudDirs.size()
);
PtrList<PtrList<tensorIOField> > lagrangianTensorFields
(
cloudDirs.size()
);
PtrList<PtrList<tensorIOFieldField> > lagrangianTensorFieldFields
(
cloudDirs.size()
);
label cloudI = 0;
......@@ -545,6 +558,13 @@ int main(int argc, char *argv[])
lagrangianSphericalTensorFields
);
lagrangianFieldDecomposer::readFieldFields
(
cloudI,
lagrangianObjects,
lagrangianSphericalTensorFieldFields
);
lagrangianFieldDecomposer::readFields
(
cloudI,
......@@ -552,6 +572,13 @@ int main(int argc, char *argv[])
lagrangianSymmTensorFields
);
lagrangianFieldDecomposer::readFieldFields
(
cloudI,
lagrangianObjects,
lagrangianSymmTensorFieldFields
);
lagrangianFieldDecomposer::readFields
(
cloudI,
......@@ -559,6 +586,13 @@ int main(int argc, char *argv[])
lagrangianTensorFields
);
lagrangianFieldDecomposer::readFieldFields
(
cloudI,
lagrangianObjects,
lagrangianTensorFieldFields
);
cloudI++;
}
}
......@@ -572,8 +606,11 @@ int main(int argc, char *argv[])
lagrangianVectorFields.setSize(cloudI);
lagrangianVectorFieldFields.setSize(cloudI);
lagrangianSphericalTensorFields.setSize(cloudI);
lagrangianSphericalTensorFieldFields.setSize(cloudI);
lagrangianSymmTensorFields.setSize(cloudI);
lagrangianSymmTensorFieldFields.setSize(cloudI);
lagrangianTensorFields.setSize(cloudI);
lagrangianTensorFieldFields.setSize(cloudI);
// Any uniform data to copy/link?
......@@ -771,8 +808,11 @@ int main(int argc, char *argv[])
|| lagrangianVectorFields[cloudI].size()
|| lagrangianVectorFieldFields[cloudI].size()
|| lagrangianSphericalTensorFields[cloudI].size()
|| lagrangianSphericalTensorFieldFields[cloudI].size()
|| lagrangianSymmTensorFields[cloudI].size()
|| lagrangianSymmTensorFieldFields[cloudI].size()
|| lagrangianTensorFields[cloudI].size()
|| lagrangianTensorFieldFields[cloudI].size()
)
{
fieldDecomposer.decomposeFields
......@@ -810,16 +850,31 @@ int main(int argc, char *argv[])
cloudDirs[cloudI],
lagrangianSphericalTensorFields[cloudI]
);
fieldDecomposer.decomposeFieldFields
(
cloudDirs[cloudI],
lagrangianSphericalTensorFieldFields[cloudI]
);
fieldDecomposer.decomposeFields
(
cloudDirs[cloudI],
lagrangianSymmTensorFields[cloudI]
);
fieldDecomposer.decomposeFieldFields
(
cloudDirs[cloudI],
lagrangianSymmTensorFieldFields[cloudI]
);
fieldDecomposer.decomposeFields
(
cloudDirs[cloudI],
lagrangianTensorFields[cloudI]
);
fieldDecomposer.decomposeFieldFields
(
cloudDirs[cloudI],
lagrangianTensorFieldFields[cloudI]
);
}
}
}
......
......@@ -444,6 +444,13 @@ int main(int argc, char *argv[])
procMeshes.meshes(),
sprayObjs
);
reconstructLagrangianFieldFields<sphericalTensor>
(
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs
);
reconstructLagrangianFields<symmTensor>
(
cloudName,
......@@ -451,6 +458,13 @@ int main(int argc, char *argv[])
procMeshes.meshes(),
sprayObjs
);
reconstructLagrangianFieldFields<symmTensor>
(
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs
);
reconstructLagrangianFields<tensor>
(
cloudName,
......@@ -458,6 +472,13 @@ int main(int argc, char *argv[])
procMeshes.meshes(),
sprayObjs
);
reconstructLagrangianFieldFields<tensor>
(
cloudName,
mesh,
procMeshes.meshes(),
sprayObjs
);
}
}
else
......
......@@ -38,6 +38,7 @@ SourceFiles
#include "cloud.H"
#include "IDLList.H"
#include "IOField.H"
#include "IOFieldField.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -267,6 +268,14 @@ public:
const IOField<DataType>& data
) const;
//- Check lagrangian data fieldfield
template<class DataType>
void checkFieldFieldIOobject
(
const Cloud<ParticleType>& c,
const IOFieldField<Field<DataType>, DataType>& data
) const;
//- Read the field data for the cloud of particles. Dummy at
// this level.
virtual void readFields();
......
......@@ -205,6 +205,31 @@ void Foam::Cloud<ParticleType>::checkFieldIOobject
}
template<class ParticleType>
template<class DataType>
void Foam::Cloud<ParticleType>::checkFieldFieldIOobject
(
const Cloud<ParticleType>& c,
const IOFieldField<Field<DataType>, DataType>& data
) const
{
if (data.size() != c.size())
{
FatalErrorIn
(
"void Cloud<ParticleType>::checkFieldFieldIOobject"
"("
"const Cloud<ParticleType>&, "
"const IOFieldField<Field<DataType>, DataType>&"
") const"
) << "Size of " << data.name()
<< " field " << data.size()
<< " does not match the number of particles " << c.size()
<< abort(FatalError);
}
}
template<class ParticleType>
void Foam::Cloud<ParticleType>::readFields()
{}
......
......@@ -51,6 +51,104 @@ Foam::CollisionRecordList<PairType, WallType>::CollisionRecordList(Istream& is)
}
template<class PairType, class WallType>
Foam::CollisionRecordList<PairType, WallType>::CollisionRecordList
(
const labelField& pairAccessed,
const labelField& pairOrigProcOfOther,
const labelField& pairOrigIdOfOther,
const Field<PairType>& pairData,
const labelField& wallAccessed,
const vectorField& wallPRel,
const Field<WallType>& wallData
)
:
pairRecords_(),
wallRecords_()
{
label nPair = pairAccessed.size();
if
(
pairOrigProcOfOther.size() != nPair
|| pairOrigIdOfOther.size() != nPair
|| pairData.size() != nPair
)
{
FatalErrorIn
(
"Foam::CollisionRecordList<PairType, WallType>::CollisionRecordList"
"("
"const labelField& pairAccessed,"
"const labelField& pairOrigProcOfOther,"
"const labelField& pairOrigIdOfOther,"
"const Field<PairType>& pairData,"
"const labelField& wallAccessed,"
"const vectorField& wallPRel,"
"const Field<WallType>& wallData"
")"
)
<< "Pair field size mismatch." << nl
<< pairAccessed << nl
<< pairOrigProcOfOther << nl
<< pairOrigIdOfOther << nl
<< pairData << nl
<< abort(FatalError);
}
forAll(pairAccessed, i)
{
pairRecords_.append
(
PairCollisionRecord<PairType>
(
pairAccessed[i],
pairOrigProcOfOther[i],
pairOrigIdOfOther[i],
pairData[i]
)
);
}
label nWall = wallAccessed.size();
if (wallPRel.size() != nWall || wallData.size() != nWall)
{
FatalErrorIn
(
"Foam::CollisionRecordList<PairType, WallType>::CollisionRecordList"
"("
"const labelField& pairAccessed,"
"const labelField& pairOrigProcOfOther,"
"const labelField& pairOrigIdOfOther,"
"const Field<PairType>& pairData,"
"const labelField& wallAccessed,"
"const vectorField& wallPRel,"
"const Field<WallType>& wallData"
")"
)
<< "Wall field size mismatch." << nl
<< wallAccessed << nl
<< wallPRel << nl
<< wallData << nl
<< abort(FatalError);
}
forAll(wallAccessed, i)
{
wallRecords_.append
(
WallCollisionRecord<WallType>
(
wallAccessed[i],
wallPRel[i],
wallData[i]
)
);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * /
template<class PairType, class WallType>
......@@ -60,6 +158,51 @@ Foam::CollisionRecordList<PairType, WallType>::~CollisionRecordList()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class PairType, class WallType>
Foam::labelField
Foam::CollisionRecordList<PairType, WallType>::pairAccessed() const
{
labelField f(pairRecords_.size());
forAll(pairRecords_, i)
{
f[i] = pairRecords_[i].accessed();
}
return f;
}
template<class PairType, class WallType>
Foam::labelField
Foam::CollisionRecordList<PairType, WallType>::pairOrigProcOfOther() const
{
labelField f(pairRecords_.size());
forAll(pairRecords_, i)
{
f[i] = pairRecords_[i].origProcOfOther();
}
return f;
}
template<class PairType, class WallType>
Foam::labelField
Foam::CollisionRecordList<PairType, WallType>::pairOrigIdOfOther() const
{
labelField f(pairRecords_.size());
forAll(pairRecords_, i)
{
f[i] = pairRecords_[i].origIdOfOther();
}
return f;
}
template<class PairType, class WallType>
Foam::Field<PairType>
Foam::CollisionRecordList<PairType, WallType>::pairData() const
......@@ -75,6 +218,51 @@ Foam::CollisionRecordList<PairType, WallType>::pairData() const
}
template<class PairType, class WallType>
Foam::labelField
Foam::CollisionRecordList<PairType, WallType>::wallAccessed() const
{
labelField f(wallRecords_.size());
forAll(wallRecords_, i)
{
f[i] = wallRecords_[i].accessed();
}
return f;
}
template<class PairType, class WallType>
Foam::vectorField
Foam::CollisionRecordList<PairType, WallType>::wallPRel() const
{
vectorField f(wallRecords_.size());
forAll(wallRecords_, i)
{
f[i] = wallRecords_[i].pRel();
}
return f;
}
template<class PairType, class WallType>
Foam::Field<WallType>
Foam::CollisionRecordList<PairType, WallType>::wallData() const
{
Field<WallType> f(wallRecords_.size());
forAll(wallRecords_, i)
{
f[i] = wallRecords_[i].collisionData();
}
return f;
}
template<class PairType, class WallType>
Foam::PairCollisionRecord<PairType>&
Foam::CollisionRecordList<PairType, WallType>::matchPairRecord
......@@ -100,12 +288,12 @@ Foam::CollisionRecordList<PairType, WallType>::matchPairRecord
}
// Record not found, create a new one and return it as the last
// member of the list. The status of the record will be accessed
// by construction.
// member of the list. Setting the status of the record to be accessed
// on construction.
pairRecords_.append
(
PairCollisionRecord<PairType>(origProcOfOther, origIdOfOther)
PairCollisionRecord<PairType>(true, origProcOfOther, origIdOfOther)
);
return pairRecords_.last();
......@@ -136,10 +324,10 @@ Foam::CollisionRecordList<PairType, WallType>::matchWallRecord
}
// Record not found, create a new one and return it as the last
// member of the list. The status of the record will be accessed
// by construction.
// member of the list. Setting the status of the record to be accessed
// on construction.
wallRecords_.append(WallCollisionRecord<WallType>(pRel));
wallRecords_.append(WallCollisionRecord<WallType>(true, pRel));
return wallRecords_.last();
}
......
......@@ -95,6 +95,17 @@ public:
//- Construct from Istream
CollisionRecordList(Istream&);
//- Construct from component fields (for IO)
CollisionRecordList
(
const labelField& pairAccessed,
const labelField& pairOrigProcOfOther,
const labelField& pairOrigIdOfOther,
const Field<PairType>& pairData,
const labelField& wallAccessed,
const vectorField& wallPRel,
const Field<WallType>& wallData
);
//- Destructor
~CollisionRecordList();
......@@ -110,9 +121,42 @@ public:
inline const DynamicList<WallCollisionRecord<WallType> >&
wallRecords() const;
// Fields representing the data from each record, i.e if the
// records 0-N containing each data members {a, b, c, d...}
// are organised:
//
// a0 b0 c0 d0 ...
// a1 b1 c1 d1 ...
// a2 b2 c2 d2 ...
// ...
// aN bN cN dN ...
//
// Then these field return, for example, (c0, c1, c2,... cN)
//- Return field of pair accessed from each record, used for
// field IO
labelField pairAccessed() const;
//- Return field of pair origProcOfOther from each record,
// used for field IO
labelField pairOrigProcOfOther() const;
//- Return field of pair origIdOfOther from each record, used
// for field IO
labelField pairOrigIdOfOther() const;
//- Return field of pair data from each record, used for field IO
Field<PairType> pairData() const;
//- Return field of wall accessed from each record, used for field IO
labelField wallAccessed() const;
//- Return field of wall pRel from each record, used for field IO
vectorField wallPRel() const;
//- Return field of wall data from each record, used for field IO
Field<WallType> wallData() const;
//- Enquires if the proc and id pair of the other particle are
// present in the records. If so, return non-const access to
// the PairCollisionRecord (hence the data) and mark the
......
......@@ -30,8 +30,8 @@ License
template<class Type>
Foam::PairCollisionRecord<Type>::PairCollisionRecord()
:
origProcOfOther_(-VGREAT),
origIdOfOther_(-VGREAT),
origProcOfOther_(0),
origIdOfOther_(-1),
data_(pTraits<Type>::zero)
{}
......@@ -39,6 +39,7 @@ Foam::PairCollisionRecord<Type>::PairCollisionRecord()
template<class Type>
Foam::PairCollisionRecord<Type>::PairCollisionRecord
(
bool accessed,
label origProcOfOther,
label origIdOfOther,
const Type& data
......@@ -47,7 +48,14 @@ Foam::PairCollisionRecord<Type>::PairCollisionRecord
origProcOfOther_(origProcOfOther + 1),
origIdOfOther_(origIdOfOther),
data_(data)
{}
{
// Default assignment to origProcOfOther_ assumes accessed is true
if (!accessed)
{
setUnaccessed();
}
}
template<class Type>
......@@ -56,7 +64,7 @@ Foam::PairCollisionRecord<Type>::PairCollisionRecord
const PairCollisionRecord<Type>& pCR
)
:
origProcOfOther_(pCR.origProcOfOther() + 1),
origProcOfOther_(pCR.origProcOfOther_),
origIdOfOther_(pCR.origIdOfOther_),
data_(pCR.data_)
{}
......
......@@ -108,6 +108,7 @@ public:
//- Construct from components
PairCollisionRecord
(
bool accessed,
label origProcOfOther,
label origIdOfOther,
const Type& data = pTraits<Type>::zero
......
......@@ -45,11 +45,12 @@ Foam::WallCollisionRecord<Type>::WallCollisionRecord()
template<class Type>
Foam::WallCollisionRecord<Type>::WallCollisionRecord
(