ENH: Further AMI functionality updates

This commit is contained in:
andy
2011-08-03 14:56:01 +01:00
parent 27213aed5a
commit ae6aefde57
6 changed files with 56 additions and 95 deletions

View File

@ -361,17 +361,12 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::calcProcMap
procBb[Pstream::myProcNo()] = treeBoundBoxList(); procBb[Pstream::myProcNo()] = treeBoundBoxList();
} }
// slightly increase size of bounding boxes to allow for cases where
// bounding boxes are perfectly alligned
forAll(procBb[Pstream::myProcNo()], bbI) forAll(procBb[Pstream::myProcNo()], bbI)
{ {
treeBoundBox& bb = procBb[Pstream::myProcNo()][bbI]; treeBoundBox& bb = procBb[Pstream::myProcNo()][bbI];
for (direction dir = 0; dir < vector::nComponents; dir++) bb.inflate(0.01);
{
if (mag(bb.max()[dir] - bb.max()[dir]) < SMALL)
{
bb.min()[dir] -= 1E-6;
bb.max()[dir] += 1E-6;
}
}
} }
Pstream::gatherList(procBb); Pstream::gatherList(procBb);
@ -1076,6 +1071,7 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::AMIInterpolation
srcWeights_(), srcWeights_(),
tgtAddress_(), tgtAddress_(),
tgtWeights_(), tgtWeights_(),
tgtPatchSize_(tgtPatch.size()),
startSeedI_(0), startSeedI_(0),
triMode_(triMode), triMode_(triMode),
projectPoints_(projectPoints), projectPoints_(projectPoints),
@ -1338,7 +1334,8 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
( (
new Field<Type> new Field<Type>
( (
tgtAddress_.size(), // tgtAddress_.size(),
tgtPatchSize_,
pTraits<Type>::zero pTraits<Type>::zero
) )
); );

View File

@ -121,6 +121,10 @@ class AMIInterpolation
//- Weights of wource faces per target face //- Weights of wource faces per target face
scalarListList tgtWeights_; scalarListList tgtWeights_;
//- Cache local size of target patch
// Note: size could be manipulated in parallel
label tgtPatchSize_;
//- Starting face seed index //- Starting face seed index
label startSeedI_; label startSeedI_;

View File

@ -132,7 +132,7 @@ Foam::tmp<Foam::labelField> Foam::cyclicAMIFvPatch::internalFieldTransfer
const labelUList& iF const labelUList& iF
) const ) const
{ {
return interpolate(neighbFvPatch().patchInternalField(iF)); return neighbFvPatch().patchInternalField(iF);
} }

View File

@ -145,29 +145,16 @@ Foam::cyclicAMIFvPatchField<Type>::patchNeighbourField() const
const labelUList& nbrFaceCells = const labelUList& nbrFaceCells =
cyclicAMIPatch_.cyclicAMIPatch().nbrPatch().faceCells(); cyclicAMIPatch_.cyclicAMIPatch().nbrPatch().faceCells();
tmp<Field<Type> > tpnf(new Field<Type>(nbrFaceCells.size())); Field<Type> pnf(iField, nbrFaceCells);
Field<Type>& pnf = tpnf();
tmp<Field<Type> > tpnf(new Field<Type>(cyclicAMIPatch_.interpolate(pnf)));
if (doTransform()) if (doTransform())
{ {
forAll(pnf, faceI) tpnf() = transform(forwardT(), tpnf());
{
pnf[faceI] = transform
(
forwardT()[0], iField[nbrFaceCells[faceI]]
);
}
}
else
{
forAll(pnf, faceI)
{
pnf[faceI] = iField[nbrFaceCells[faceI]];
}
} }
return cyclicAMIPatch_.interpolate(pnf); return tpnf;
} }
@ -202,12 +189,7 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
const labelUList& nbrFaceCells = const labelUList& nbrFaceCells =
cyclicAMIPatch_.cyclicAMIPatch().nbrPatch().faceCells(); cyclicAMIPatch_.cyclicAMIPatch().nbrPatch().faceCells();
scalarField pnf(nbrFaceCells.size()); scalarField pnf(psiInternal, nbrFaceCells);
forAll(pnf, faceI)
{
pnf[faceI] = psiInternal[nbrFaceCells[faceI]];
}
pnf = cyclicAMIPatch_.interpolate(pnf); pnf = cyclicAMIPatch_.interpolate(pnf);

View File

@ -215,36 +215,39 @@ void Foam::cyclicAMIPolyPatch::calcTransforms
} }
} }
if (debug)
// Calculate typical distance per face {
// tols = calcFaceTol(matchTolerance(), pp1, pp1.points(), half1Ctrs); Pout<< "patch: " << name() << nl
<< " forwardT = " << forwardT() << nl
<< " reverseT = " << reverseT() << nl
<< " separation = " << separation() << nl
<< " collocated = " << collocated() << nl << endl;
}
} }
const Foam::searchableSurface& Foam::cyclicAMIPolyPatch::surf() const Foam::searchableSurface& Foam::cyclicAMIPolyPatch::surf()
{ {
if (projectionSurfaceType_ == "patch") word surfType(surfDict_.lookup("type"));
{ word surfName(surfDict_.lookupOrDefault("name", name()));
notImplemented("projectionSurfaceType_ == patch")
} const polyMesh& mesh = boundaryMesh().mesh();
else
{
surfPtr_ = surfPtr_ =
searchableSurface::New searchableSurface::New
( (
projectionSurfaceType_, surfType,
IOobject IOobject
( (
projectionName_, surfName,
boundaryMesh().mesh().time().constant(), boundaryMesh().mesh().time().constant(),
"triSurface", "triSurface",
boundaryMesh().mesh(), boundaryMesh().mesh(),
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
dict_ surfDict_
); );
}
return surfPtr_(); return surfPtr_();
} }
@ -284,6 +287,8 @@ const Foam::AMIPatchToPatchInterpolation& Foam::cyclicAMIPolyPatch::AMI()
meshTools::writeOBJ(osO, this->localFaces(), localPoints()); meshTools::writeOBJ(osO, this->localFaces(), localPoints());
} }
bool projectPoints(readBool(surfDict_.lookup("projectPoints")));
// Construct/apply AMI interpolation to determine addressing and weights // Construct/apply AMI interpolation to determine addressing and weights
AMIPtr_.reset AMIPtr_.reset
( (
@ -293,7 +298,7 @@ const Foam::AMIPatchToPatchInterpolation& Foam::cyclicAMIPolyPatch::AMI()
nbrPatch0, nbrPatch0,
surf(), surf(),
faceAreaIntersect::tmMesh, faceAreaIntersect::tmMesh,
projectPoints_ projectPoints
) )
); );
} }
@ -377,7 +382,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
) )
: :
coupledPolyPatch(name, size, start, index, bm), coupledPolyPatch(name, size, start, index, bm),
dict_(dictionary::null),
nbrPatchName_(word::null), nbrPatchName_(word::null),
nbrPatchID_(-1), nbrPatchID_(-1),
transform_(UNKNOWN), transform_(UNKNOWN),
@ -386,9 +390,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
separationVector_(vector::zero), separationVector_(vector::zero),
AMIPtr_(NULL), AMIPtr_(NULL),
surfPtr_(NULL), surfPtr_(NULL),
projectionSurfaceType_(word::null), surfDict_(dictionary::null)
projectPoints_(false),
projectionName_(word::null)
{ {
// Neighbour patch might not be valid yet so no transformation // Neighbour patch might not be valid yet so no transformation
// calculation possible // calculation possible
@ -404,7 +406,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
) )
: :
coupledPolyPatch(name, dict, index, bm), coupledPolyPatch(name, dict, index, bm),
dict_(dict),
nbrPatchName_(dict.lookup("neighbourPatch")), nbrPatchName_(dict.lookup("neighbourPatch")),
nbrPatchID_(-1), nbrPatchID_(-1),
transform_(UNKNOWN), transform_(UNKNOWN),
@ -413,9 +414,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
separationVector_(vector::zero), separationVector_(vector::zero),
AMIPtr_(NULL), AMIPtr_(NULL),
surfPtr_(NULL), surfPtr_(NULL),
projectionSurfaceType_(dict.lookup("projectionSurfaceType")), surfDict_(dict.subDict("surface"))
projectPoints_(readBool(dict.lookup("projectPoints"))),
projectionName_(dict.lookupOrDefault("surfaceName", name))
{ {
if (nbrPatchName_ == name) if (nbrPatchName_ == name)
{ {
@ -489,7 +488,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
) )
: :
coupledPolyPatch(pp, bm), coupledPolyPatch(pp, bm),
dict_(dictionary::null),
nbrPatchName_(pp.nbrPatchName_), nbrPatchName_(pp.nbrPatchName_),
nbrPatchID_(-1), nbrPatchID_(-1),
transform_(UNKNOWN), transform_(UNKNOWN),
@ -498,9 +496,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
separationVector_(vector::zero), separationVector_(vector::zero),
AMIPtr_(NULL), AMIPtr_(NULL),
surfPtr_(NULL), surfPtr_(NULL),
projectionSurfaceType_(word::null), surfDict_(dictionary::null)
projectPoints_(false),
projectionName_(word::null)
{ {
// Neighbour patch might not be valid yet so no transformation // Neighbour patch might not be valid yet so no transformation
// calculation possible // calculation possible
@ -518,7 +514,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
) )
: :
coupledPolyPatch(pp, bm, index, newSize, newStart), coupledPolyPatch(pp, bm, index, newSize, newStart),
dict_(dictionary::null),
nbrPatchName_(nbrPatchName), nbrPatchName_(nbrPatchName),
nbrPatchID_(-1), nbrPatchID_(-1),
transform_(UNKNOWN), transform_(UNKNOWN),
@ -527,9 +522,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
separationVector_(vector::zero), separationVector_(vector::zero),
AMIPtr_(NULL), AMIPtr_(NULL),
surfPtr_(NULL), surfPtr_(NULL),
projectionSurfaceType_(word::null), surfDict_(dictionary::null)
projectPoints_(false),
projectionName_(word::null)
{ {
if (nbrPatchName_ == name()) if (nbrPatchName_ == name())
{ {
@ -561,7 +554,6 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
) )
: :
coupledPolyPatch(pp, bm, index, mapAddressing, newStart), coupledPolyPatch(pp, bm, index, mapAddressing, newStart),
dict_(pp.dict_),
nbrPatchName_(pp.nbrPatchName_), nbrPatchName_(pp.nbrPatchName_),
nbrPatchID_(-1), nbrPatchID_(-1),
transform_(pp.transform_), transform_(pp.transform_),
@ -570,9 +562,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
separationVector_(pp.separationVector_), separationVector_(pp.separationVector_),
AMIPtr_(NULL), AMIPtr_(NULL),
surfPtr_(NULL), surfPtr_(NULL),
projectionSurfaceType_(pp.projectionSurfaceType_), surfDict_(pp.surfDict_)
projectPoints_(pp.projectPoints_),
projectionName_(pp.projectionName_)
{} {}
@ -759,12 +749,6 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
coupledPolyPatch::write(os); coupledPolyPatch::write(os);
os.writeKeyword("neighbourPatch") << nbrPatchName_ os.writeKeyword("neighbourPatch") << nbrPatchName_
<< token::END_STATEMENT << nl; << token::END_STATEMENT << nl;
os.writeKeyword("projectPoints") << projectPoints_
<< token::END_STATEMENT << nl;
os.writeKeyword("projectionSurfaceType") << projectionSurfaceType_
<< token::END_STATEMENT << nl;
os.writeKeyword("surfaceName") << projectionName_
<< token::END_STATEMENT << nl;
switch (transform_) switch (transform_)
{ {
case ROTATIONAL: case ROTATIONAL:
@ -796,6 +780,9 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
// no additional info to write // no additional info to write
} }
} }
os.writeKeyword(surfDict_.dictName());
os << surfDict_;
} }

View File

@ -57,9 +57,6 @@ private:
// Private data // Private data
//- Dictionary used during construction
const dictionary dict_;
//- Name of other half //- Name of other half
const word nbrPatchName_; const word nbrPatchName_;
@ -94,14 +91,8 @@ private:
//- Projection surface //- Projection surface
autoPtr<searchableSurface> surfPtr_; autoPtr<searchableSurface> surfPtr_;
//- Projection surface type //- Dictionary used during projection surface construction
word projectionSurfaceType_; const dictionary surfDict_;
//- Flag to activate projection
bool projectPoints_;
//- Name of projection object (if read)
const word projectionName_;
// Private Member Functions // Private Member Functions