ENH: mapDistribute : cleanup

This commit is contained in:
mattijs
2010-12-06 15:54:45 +00:00
parent 15c7d501bb
commit 731f523188
11 changed files with 66 additions and 275 deletions

View File

@ -129,15 +129,7 @@ int main(int argc, char *argv[])
mapDistribute map(constructSize, sendMap.xfer(), recvMap.xfer()); mapDistribute map(constructSize, sendMap.xfer(), recvMap.xfer());
// Distribute complexData // Distribute complexData
mapDistribute::distribute mapDistribute::distribute(complexData);
(
Pstream::nonBlocking,
List<labelPair>(),
map.constructSize(),
map.subMap(),
map.constructMap(),
complexData
);
Pout<< "complexData:" << complexData << endl; Pout<< "complexData:" << complexData << endl;
} }

View File

@ -272,15 +272,7 @@ void directMappedFixedValueFvPatchField<Type>::updateCoeffs()
newValues = sampleField(); newValues = sampleField();
} }
mapDistribute::distribute distMap.distribute(newValues);
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(),
distMap.constructMap(),
newValues
);
break; break;
} }
@ -305,15 +297,7 @@ void directMappedFixedValueFvPatchField<Type>::updateCoeffs()
const fieldType& nbrField = sampleField(); const fieldType& nbrField = sampleField();
newValues = nbrField.boundaryField()[nbrPatchID]; newValues = nbrField.boundaryField()[nbrPatchID];
mapDistribute::distribute distMap.distribute(newValues);
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(),
distMap.constructMap(),
newValues
);
break; break;
} }
@ -335,16 +319,7 @@ void directMappedFixedValueFvPatchField<Type>::updateCoeffs()
} }
} }
mapDistribute::distribute distMap.distribute(allValues);
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(),
distMap.constructMap(),
allValues
);
newValues.transfer(allValues); newValues.transfer(allValues);
break; break;

View File

@ -212,26 +212,10 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
} }
} }
mapDistribute::distribute distMap.distribute(allUValues);
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(),
distMap.constructMap(),
allUValues
);
newUValues.transfer(allUValues); newUValues.transfer(allUValues);
mapDistribute::distribute distMap.distribute(allPhiValues);
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(),
distMap.constructMap(),
allPhiValues
);
newPhiValues.transfer(allPhiValues); newPhiValues.transfer(allPhiValues);
break; break;
@ -244,28 +228,10 @@ void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
); );
newUValues = UField.boundaryField()[nbrPatchID]; newUValues = UField.boundaryField()[nbrPatchID];
distMap.distribute(newUValues);
mapDistribute::distribute
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(),
distMap.constructMap(),
newUValues
);
newPhiValues = phiField.boundaryField()[nbrPatchID]; newPhiValues = phiField.boundaryField()[nbrPatchID];
distMap.distribute(newPhiValues);
mapDistribute::distribute
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(),
distMap.constructMap(),
newPhiValues
);
break; break;
} }

View File

@ -527,13 +527,14 @@ void Foam::directMappedPatchBase::calcMapping() const
constructMap[procI] constructMap[procI]
); );
if (debug) //if (debug)
{ //{
Pout<< "To proc:" << procI << " sending values of cells/faces:" // Pout<< "To proc:" << procI << " sending values of cells/faces:"
<< subMap[procI] << endl; // << subMap[procI] << endl;
Pout<< "From proc:" << procI << " receiving values of patch faces:" // Pout<< "From proc:" << procI
<< constructMap[procI] << endl; // << " receiving values of patch faces:"
} // << constructMap[procI] << endl;
//}
} }
// Redo constructSize // Redo constructSize
@ -644,6 +645,28 @@ Foam::directMappedPatchBase::directMappedPatchBase
{} {}
Foam::directMappedPatchBase::directMappedPatchBase
(
const polyPatch& pp,
const word& sampleRegion,
const sampleMode mode,
const word& samplePatch,
const scalar distance
)
:
patch_(pp),
sampleRegion_(sampleRegion),
mode_(mode),
samplePatch_(samplePatch),
offsetMode_(NORMAL),
offset_(vector::zero),
offsets_(0),
distance_(distance),
sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
mapPtr_(NULL)
{}
Foam::directMappedPatchBase::directMappedPatchBase Foam::directMappedPatchBase::directMappedPatchBase
( (
const polyPatch& pp, const polyPatch& pp,

View File

@ -206,15 +206,15 @@ public:
const vector& offset const vector& offset
); );
////- Construct from normal and distance //- Construct from offsetMode=normal and distance
//directMappedPatchBase directMappedPatchBase
//( (
// const polyPatch& pp, const polyPatch& pp,
// const word& sampleRegion, const word& sampleRegion,
// const word& samplePatch, const sampleMode sampleMode,
// const sampleMode sampleMode, const word& samplePatch,
// const vector& offset const scalar distance
//); );
//- Construct from dictionary //- Construct from dictionary
directMappedPatchBase(const polyPatch&, const dictionary&); directMappedPatchBase(const polyPatch&, const dictionary&);

View File

@ -440,15 +440,7 @@ void Foam::distributedTriSurfaceMesh::findLine
// Exchange the segments // Exchange the segments
// ~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~
map.distribute map.distribute(allSegments);
(
Pstream::nonBlocking, //Pstream::scheduled,
List<labelPair>(0), //map.schedule(),
map.constructSize(),
map.subMap(), // what to send
map.constructMap(), // what to receive
allSegments
);
// Do tests I need to do // Do tests I need to do
@ -490,21 +482,7 @@ void Foam::distributedTriSurfaceMesh::findLine
// Exchange the intersections (opposite to segments) // Exchange the intersections (opposite to segments)
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
map.distribute map.reverseDistribute(nOldAllSegments, intersections);
(
//Pstream::scheduled,
//map.schedule // Note reverse schedule
//(
// map.constructMap(),
// map.subMap()
//),
Pstream::nonBlocking,
List<labelPair>(0),
nOldAllSegments,
map.constructMap(), // what to send
map.subMap(), // what to receive
intersections
);
// Extract the hits // Extract the hits
@ -657,17 +635,7 @@ Foam::distributedTriSurfaceMesh::calcLocalQueries
// Send over queries // Send over queries
// ~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~
map.distribute map.distribute(triangleIndex);
(
//Pstream::scheduled,
//map.schedule(),
Pstream::nonBlocking,
List<labelPair>(0),
map.constructSize(),
map.subMap(), // what to send
map.constructMap(), // what to receive
triangleIndex
);
return mapPtr; return mapPtr;
@ -1594,28 +1562,8 @@ void Foam::distributedTriSurfaceMesh::findNearest
// swap samples to local processor // swap samples to local processor
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
map.distribute map.distribute(allCentres);
( map.distribute(allRadiusSqr);
//Pstream::scheduled,
//map.schedule(),
Pstream::nonBlocking,
List<labelPair>(0),
map.constructSize(),
map.subMap(), // what to send
map.constructMap(), // what to receive
allCentres
);
map.distribute
(
//Pstream::scheduled,
//map.schedule(),
Pstream::nonBlocking,
List<labelPair>(0),
map.constructSize(),
map.subMap(), // what to send
map.constructMap(), // what to receive
allRadiusSqr
);
// Do my tests // Do my tests
@ -1639,21 +1587,7 @@ void Foam::distributedTriSurfaceMesh::findNearest
// Send back results // Send back results
// ~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~
map.distribute map.reverseDistribute(allSegmentMap.size(), allInfo);
(
//Pstream::scheduled,
//map.schedule // note reverse schedule
//(
// map.constructMap(),
// map.subMap()
//),
Pstream::nonBlocking,
List<labelPair>(0),
allSegmentMap.size(),
map.constructMap(), // what to send
map.subMap(), // what to receive
allInfo
);
// Extract information // Extract information
@ -1892,21 +1826,7 @@ void Foam::distributedTriSurfaceMesh::getRegion
// Send back results // Send back results
// ~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~
map.distribute map.reverseDistribute(info.size(), region);
(
//Pstream::scheduled,
//map.schedule // note reverse schedule
//(
// map.constructMap(),
// map.subMap()
//),
Pstream::nonBlocking,
List<labelPair>(0),
info.size(),
map.constructMap(), // what to send
map.subMap(), // what to receive
region
);
} }
@ -1956,21 +1876,7 @@ void Foam::distributedTriSurfaceMesh::getNormal
// Send back results // Send back results
// ~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~
map.distribute map.reverseDistribute(info.size(), normal);
(
//Pstream::scheduled,
//map.schedule // note reverse schedule
//(
// map.constructMap(),
// map.subMap()
//),
Pstream::nonBlocking,
List<labelPair>(0),
info.size(),
map.constructMap(), // what to send
map.subMap(), // what to receive
normal
);
} }
@ -2024,15 +1930,7 @@ void Foam::distributedTriSurfaceMesh::getField
// Send back results // Send back results
// ~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~
map.distribute map.reverseDistribute(info.size(), values);
(
Pstream::nonBlocking,
List<labelPair>(0),
info.size(),
map.constructMap(), // what to send
map.subMap(), // what to receive
values
);
} }
} }

View File

@ -76,15 +76,7 @@ License
// // Send back results // // Send back results
// // ~~~~~~~~~~~~~~~~~ // // ~~~~~~~~~~~~~~~~~
// //
// map.distribute // map.reverseDistribute(info.size(), values);
// (
// Pstream::nonBlocking,
// List<labelPair>(0),
// info.size(),
// map.constructMap(), // what to send
// map.subMap(), // what to receive
// values
// );
//} //}
@ -115,15 +107,7 @@ void Foam::distributedTriSurfaceMesh::distributeFields
label oldSize = field.size(); label oldSize = field.size();
map.distribute map.distribute(field);
(
Pstream::nonBlocking,
List<labelPair>(0),
map.constructSize(),
map.subMap(),
map.constructMap(),
field
);
if (debug) if (debug)
{ {

View File

@ -426,7 +426,8 @@ void Foam::streamLine::write()
); );
// Distribute the track positions // Distribute the track positions. Note: use scheduled comms
// to prevent buffering.
mapDistribute::distribute mapDistribute::distribute
( (
Pstream::scheduled, Pstream::scheduled,

View File

@ -132,15 +132,7 @@ void directMappedFixedInternalValueFvPatchField<Type>::updateCoeffs()
// Retrieve the neighbour patch internal field // Retrieve the neighbour patch internal field
Field<Type> nbrIntFld = nbrField.patchInternalField(); Field<Type> nbrIntFld = nbrField.patchInternalField();
mapDistribute::distribute distMap.distribute(nbrIntFld);
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(), // what to send
distMap.constructMap(), // what to receive
nbrIntFld
);
// Assign (this) patch internal field to its neighbour values // Assign (this) patch internal field to its neighbour values
Field<Type>& intFld = const_cast<Field<Type>&>(this->internalField()); Field<Type>& intFld = const_cast<Field<Type>&>(this->internalField());

View File

@ -222,27 +222,11 @@ void Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField::updateCoeffs()
// Swap to obtain full local values of neighbour internal field // Swap to obtain full local values of neighbour internal field
scalarField nbrIntFld = nbrField.patchInternalField(); scalarField nbrIntFld = nbrField.patchInternalField();
mapDistribute::distribute distMap.distribute(nbrIntFld);
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(), // what to send
distMap.constructMap(), // what to receive
nbrIntFld
);
// Swap to obtain full local values of neighbour K*delta // Swap to obtain full local values of neighbour K*delta
scalarField nbrKDelta = nbrField.K(nbrField)*nbrPatch.deltaCoeffs(); scalarField nbrKDelta = nbrField.K(nbrField)*nbrPatch.deltaCoeffs();
mapDistribute::distribute distMap.distribute(nbrKDelta);
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(), // what to send
distMap.constructMap(), // what to receive
nbrKDelta
);
tmp<scalarField> myKDelta = K(*this)*patch().deltaCoeffs(); tmp<scalarField> myKDelta = K(*this)*patch().deltaCoeffs();
@ -255,15 +239,7 @@ void Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField::updateCoeffs()
// Assign to me // Assign to me
fvPatchScalarField::operator=(Twall); fvPatchScalarField::operator=(Twall);
// Distribute back and assign to neighbour // Distribute back and assign to neighbour
mapDistribute::distribute distMap.reverseDistribute(nbrField.size(), Twall);
(
Pstream::defaultCommsType,
distMap.schedule(),
nbrField.size(),
distMap.constructMap(), // reverse : what to send
distMap.subMap(),
Twall
);
const_cast<turbulentTemperatureCoupledBaffleFvPatchScalarField&> const_cast<turbulentTemperatureCoupledBaffleFvPatchScalarField&>
( (
nbrField nbrField

View File

@ -179,27 +179,11 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
// Swap to obtain full local values of neighbour internal field // Swap to obtain full local values of neighbour internal field
scalarField nbrIntFld = nbrField.patchInternalField(); scalarField nbrIntFld = nbrField.patchInternalField();
mapDistribute::distribute distMap.distribute(nbrIntFld);
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(), // what to send
distMap.constructMap(), // what to receive
nbrIntFld
);
// Swap to obtain full local values of neighbour K*delta // Swap to obtain full local values of neighbour K*delta
scalarField nbrKDelta = nbrField.K(nbrField)*nbrPatch.deltaCoeffs(); scalarField nbrKDelta = nbrField.K(nbrField)*nbrPatch.deltaCoeffs();
mapDistribute::distribute distMap.distribute(nbrKDelta);
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(), // what to send
distMap.constructMap(), // what to receive
nbrKDelta
);
tmp<scalarField> myKDelta = K(*this)*patch().deltaCoeffs(); tmp<scalarField> myKDelta = K(*this)*patch().deltaCoeffs();