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

View File

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

View File

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

View File

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

View File

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

View File

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