iso surface on coupled bc

This commit is contained in:
mattijs
2009-02-18 17:05:56 +00:00
parent 80b6624d43
commit 0e2f77b170
2 changed files with 114 additions and 52 deletions

View File

@ -29,6 +29,7 @@ License
#include "mergePoints.H" #include "mergePoints.H"
#include "syncTools.H" #include "syncTools.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "slicedVolFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -347,24 +348,36 @@ void Foam::isoSurface::getNeighbour
{ {
label nbr = (own[faceI] == cellI ? nei[faceI] : own[faceI]); label nbr = (own[faceI] == cellI ? nei[faceI] : own[faceI]);
nbrValue = cVals[nbr]; nbrValue = cVals[nbr];
nbrPoint = mesh_.C()[nbr]; nbrPoint = mesh_.cellCentres()[nbr];
} }
else else
{ {
label bFaceI = faceI-mesh_.nInternalFaces(); label bFaceI = faceI-mesh_.nInternalFaces();
label patchI = boundaryRegion[bFaceI]; label patchI = boundaryRegion[bFaceI];
label patchFaceI = faceI-mesh_.boundaryMesh()[patchI].start(); const polyPatch& pp = mesh_.boundaryMesh()[patchI];
label patchFaceI = faceI-pp.start();
if (isA<emptyPolyPatch>(mesh_.boundaryMesh()[patchI])) if (isA<emptyPolyPatch>(pp))
{ {
// Assume zero gradient // Assume zero gradient
nbrValue = cVals[own[faceI]]; nbrValue = cVals[own[faceI]];
nbrPoint = mesh_.faceCentres()[faceI];
}
else if
(
pp.coupled()
&& !refCast<const coupledPolyPatch>(pp).separated()
)
{
// other side value
nbrValue = cVals.boundaryField()[patchI][patchFaceI];
// other side cell centre
nbrPoint = mesh_.C().boundaryField()[patchI][patchFaceI]; nbrPoint = mesh_.C().boundaryField()[patchI][patchFaceI];
} }
else else
{ {
nbrValue = cVals.boundaryField()[patchI][patchFaceI]; nbrValue = cVals.boundaryField()[patchI][patchFaceI];
nbrPoint = mesh_.C().boundaryField()[patchI][patchFaceI]; nbrPoint = mesh_.faceCentres()[faceI];
} }
} }
} }
@ -383,6 +396,7 @@ void Foam::isoSurface::calcSnappedCc
) const ) const
{ {
const pointField& pts = mesh_.points(); const pointField& pts = mesh_.points();
const pointField& cc = mesh_.cellCentres();
snappedCc.setSize(mesh_.nCells()); snappedCc.setSize(mesh_.nCells());
snappedCc = -1; snappedCc = -1;
@ -427,7 +441,7 @@ void Foam::isoSurface::calcSnappedCc
// From cc to neighbour cc. // From cc to neighbour cc.
s[2] = isoFraction(cVal, nbrValue); s[2] = isoFraction(cVal, nbrValue);
pt[2] = (1.0-s[2])*mesh_.C()[cellI] + s[2]*nbrPoint; pt[2] = (1.0-s[2])*cc[cellI] + s[2]*nbrPoint;
const face& f = mesh_.faces()[cFaces[cFaceI]]; const face& f = mesh_.faces()[cFaces[cFaceI]];
@ -436,12 +450,12 @@ void Foam::isoSurface::calcSnappedCc
// From cc to fp // From cc to fp
label p0 = f[fp]; label p0 = f[fp];
s[0] = isoFraction(cVal, pVals[p0]); s[0] = isoFraction(cVal, pVals[p0]);
pt[0] = (1.0-s[0])*mesh_.C()[cellI] + s[0]*pts[p0]; pt[0] = (1.0-s[0])*cc[cellI] + s[0]*pts[p0];
// From cc to fp+1 // From cc to fp+1
label p1 = f[f.fcIndex(fp)]; label p1 = f[f.fcIndex(fp)];
s[1] = isoFraction(cVal, pVals[p1]); s[1] = isoFraction(cVal, pVals[p1]);
pt[1] = (1.0-s[1])*mesh_.C()[cellI] + s[1]*pts[p1]; pt[1] = (1.0-s[1])*cc[cellI] + s[1]*pts[p1];
if if
( (
@ -548,6 +562,7 @@ void Foam::isoSurface::calcSnappedPoint
) const ) const
{ {
const pointField& pts = mesh_.points(); const pointField& pts = mesh_.points();
const pointField& cc = mesh_.cellCentres();
const point greatPoint(VGREAT, VGREAT, VGREAT); const point greatPoint(VGREAT, VGREAT, VGREAT);
@ -616,7 +631,7 @@ void Foam::isoSurface::calcSnappedPoint
label fp = findIndex(f, pointI); label fp = findIndex(f, pointI);
s[0] = isoFraction(pVals[pointI], cVals[own]); s[0] = isoFraction(pVals[pointI], cVals[own]);
pt[0] = (1.0-s[0])*pts[pointI] + s[0]*mesh_.C()[own]; pt[0] = (1.0-s[0])*pts[pointI] + s[0]*cc[own];
s[1] = isoFraction(pVals[pointI], nbrValue); s[1] = isoFraction(pVals[pointI], nbrValue);
pt[1] = (1.0-s[1])*pts[pointI] + s[1]*nbrPoint; pt[1] = (1.0-s[1])*pts[pointI] + s[1]*nbrPoint;
@ -815,13 +830,6 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints
tris.transfer(dynTris); tris.transfer(dynTris);
} }
if (debug)
{
Pout<< "isoSurface : merged from " << nTris
<< " down to " << tris.size() << " triangles." << endl;
}
// Determine 'flat hole' situation (see RMT paper). // Determine 'flat hole' situation (see RMT paper).
// Two unconnected triangles get connected because (some of) the edges // Two unconnected triangles get connected because (some of) the edges
@ -862,6 +870,12 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints
triMap.transfer(newToOldTri); triMap.transfer(newToOldTri);
tris.setSize(triMap.size()); tris.setSize(triMap.size());
if (debug)
{
Pout<< "isoSurface : merged from " << nTris
<< " down to " << tris.size() << " unique triangles." << endl;
}
} }
return triSurface(tris, geometricSurfacePatchList(0), newPoints, true); return triSurface(tris, geometricSurfacePatchList(0), newPoints, true);
@ -1504,8 +1518,6 @@ Foam::isoSurface::isoSurface
{ {
const polyPatch& pp = patches[patchI]; const polyPatch& pp = patches[patchI];
if (pp.coupled())
{
label faceI = pp.start(); label faceI = pp.start();
forAll(pp, i) forAll(pp, i)
@ -1513,8 +1525,14 @@ Foam::isoSurface::isoSurface
boundaryRegion[faceI-mesh_.nInternalFaces()] = patchI; boundaryRegion[faceI-mesh_.nInternalFaces()] = patchI;
faceI++; faceI++;
} }
}
else // Mark all points that are not physically coupled (so anything
// but collocated coupled patches)
if
(
!pp.coupled()
|| refCast<const coupledPolyPatch>(pp).separated()
)
{ {
label faceI = pp.start(); label faceI = pp.start();
@ -1594,6 +1612,48 @@ Foam::isoSurface::isoSurface
} }
// Generate field to interpolate. This is identical to the mesh.C()
// except on separated coupled patches.
slicedVolVectorField meshC
(
IOobject
(
"C",
mesh_.pointsInstance(),
mesh_.meshSubDir,
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimLength,
mesh_.cellCentres(),
mesh_.faceCentres()
);
{
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
forAll(patches, patchI)
{
if
(
patches[patchI].coupled()
&& refCast<const coupledPolyPatch>(patches[patchI]).separated()
)
{
fvPatchVectorField& pfld = const_cast<fvPatchVectorField&>
(
meshC.boundaryField()[patchI]
);
pfld.operator==
(
patches[patchI].patchSlice(mesh_.faceCentres())
);
}
}
}
DynamicList<point> triPoints(nCutCells_); DynamicList<point> triPoints(nCutCells_);
DynamicList<label> triMeshCells(nCutCells_); DynamicList<label> triMeshCells(nCutCells_);
@ -1602,7 +1662,7 @@ Foam::isoSurface::isoSurface
cVals, cVals,
pVals, pVals,
mesh_.C(), meshC,
mesh_.points(), mesh_.points(),
snappedPoints, snappedPoints,

View File

@ -369,9 +369,12 @@ void Foam::isoSurface::generateTriPoints
{ {
const polyPatch& pp = patches[patchI]; const polyPatch& pp = patches[patchI];
if (isA<processorPolyPatch>(pp)) if
{ (
if (refCast<const processorPolyPatch>(pp).owner()) isA<processorPolyPatch>(pp)
&& refCast<const processorPolyPatch>(pp).owner()
&& !refCast<const processorPolyPatch>(pp).separated()
)
{ {
label faceI = pp.start(); label faceI = pp.start();
@ -403,7 +406,6 @@ void Foam::isoSurface::generateTriPoints
faceI++; faceI++;
} }
} }
}
else if (isA<emptyPolyPatch>(pp)) else if (isA<emptyPolyPatch>(pp))
{ {
// Assume zero-gradient. But what about coordinates? // Assume zero-gradient. But what about coordinates?
@ -482,8 +484,8 @@ void Foam::isoSurface::generateTriPoints
//{ //{
// return tmp<Field<Type> >(new Field<Type>(vField, meshCells())); // return tmp<Field<Type> >(new Field<Type>(vField, meshCells()));
//} //}
//
//
template <class Type> template <class Type>
Foam::tmp<Foam::Field<Type> > Foam::tmp<Foam::Field<Type> >
Foam::isoSurface::interpolate Foam::isoSurface::interpolate