Skip to content
Snippets Groups Projects
Commit 4f130531 authored by mattijs's avatar mattijs
Browse files

fix multiple field transfer

parent 4a5f0fbe
Branches
Tags
No related merge requests found
This diff is collapsed.
......@@ -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);
}
......@@ -273,19 +273,40 @@ void Foam::fvMeshDistribute::initPatchFields
// 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
const fvMeshSubset& subsetter,
UOPstream& toNbr
)
{
toNbr << GeoField::typeName << token::NL << token::BEGIN_BLOCK << token::NL;
forAll(fieldNames, i)
{
//Pout<< "Subsetting field " << fieldNames[i]
// << " for domain:" << domain
// << endl;
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!
......@@ -294,10 +315,12 @@ void Foam::fvMeshDistribute::sendFields
tmp<GeoField> tsubfld = subsetter.interpolate(fld);
// Send
OPstream toNbr(Pstream::blocking, domain);
toNbr << tsubfld();
toNbr
<< fieldNames[i] << token::NL << token::BEGIN_BLOCK
<< tsubfld
<< token::NL << token::END_BLOCK << token::NL;
}
toNbr << token::END_BLOCK << token::NL;
}
......@@ -308,18 +331,25 @@ void Foam::fvMeshDistribute::receiveFields
const label domain,
const wordList& fieldNames,
fvMesh& mesh,
PtrList<GeoField>& fields
PtrList<GeoField>& fields,
const dictionary& fieldDicts
)
{
if (debug)
{
Pout<< "Receiving fields " << fieldNames
<< " from domain:" << domain << endl;
}
fields.setSize(fieldNames.size());
forAll(fieldNames, i)
{
//Pout<< "Receiving field " << fieldNames[i]
// << " from domain:" << domain
// << endl;
IPstream fromNbr(Pstream::blocking, domain);
if (debug)
{
Pout<< "Constructing field " << fieldNames[i]
<< " from domain:" << domain << endl;
}
fields.set
(
......@@ -335,7 +365,7 @@ void Foam::fvMeshDistribute::receiveFields
IOobject::AUTO_WRITE
),
mesh,
fromNbr
fieldDicts.subDict(fieldNames[i])
)
);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment