Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry
2012-07-25 16:54:36 +01:00
9 changed files with 330 additions and 141 deletions

View File

@ -20,6 +20,7 @@ FoamFile
// - always: order faces on coupled patches such that they are opposite. This // - always: order faces on coupled patches such that they are opposite. This
// is done for all coupled faces, not just for any patches created. // is done for all coupled faces, not just for any patches created.
// - optional: synchronise points on coupled patches. // - optional: synchronise points on coupled patches.
// - always: remove zero-sized (non-coupled) patches (that were not added)
// 1. Create cyclic: // 1. Create cyclic:
// - specify where the faces should come from // - specify where the faces should come from

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -147,7 +147,7 @@ void Foam::timeSelector::addOptions
( (
"time", "time",
"ranges", "ranges",
"comma-separated time ranges - eg, ':10,20,40-70,1000:'" "comma-separated time ranges - eg, ':10,20,40:70,1000:'"
); );
} }

View File

@ -713,7 +713,7 @@ Foam::label Foam::AMIInterpolation<SourcePatch, TargetPatch>::findTargetFace
const pointField& srcPts = srcPatch.points(); const pointField& srcPts = srcPatch.points();
const face& srcFace = srcPatch[srcFaceI]; const face& srcFace = srcPatch[srcFaceI];
const point& srcPt = srcFace.centre(srcPts); const point srcPt = srcFace.centre(srcPts);
const scalar srcFaceArea = srcMagSf_[srcFaceI]; const scalar srcFaceArea = srcMagSf_[srcFaceI];
// pointIndexHit sample = treePtr_->findNearest(srcPt, sqr(0.1*bb.mag())); // pointIndexHit sample = treePtr_->findNearest(srcPt, sqr(0.1*bb.mag()));
@ -782,6 +782,62 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::appendNbrFaces
} }
template<class SourcePatch, class TargetPatch>
bool Foam::AMIInterpolation<SourcePatch, TargetPatch>::processSourceFace
(
const SourcePatch& srcPatch,
const TargetPatch& tgtPatch,
const label srcFaceI,
const label tgtStartFaceI,
// list of tgt face neighbour faces
DynamicList<label>& nbrFaces,
// list of faces currently visited for srcFaceI to avoid multiple hits
DynamicList<label>& visitedFaces,
// temporary storage for addressing and weights
List<DynamicList<label> >& srcAddr,
List<DynamicList<scalar> >& srcWght,
List<DynamicList<label> >& tgtAddr,
List<DynamicList<scalar> >& tgtWght
)
{
nbrFaces.clear();
visitedFaces.clear();
// append initial target face and neighbours
nbrFaces.append(tgtStartFaceI);
appendNbrFaces(tgtStartFaceI, tgtPatch, visitedFaces, nbrFaces);
bool faceProcessed = false;
do
{
// process new target face
label tgtFaceI = nbrFaces.remove();
visitedFaces.append(tgtFaceI);
scalar area = interArea(srcFaceI, tgtFaceI, srcPatch, tgtPatch);
// store when intersection area > 0
if (area > 0)
{
srcAddr[srcFaceI].append(tgtFaceI);
srcWght[srcFaceI].append(area);
tgtAddr[tgtFaceI].append(srcFaceI);
tgtWght[tgtFaceI].append(area);
appendNbrFaces(tgtFaceI, tgtPatch, visitedFaces, nbrFaces);
faceProcessed = true;
}
} while (nbrFaces.size() > 0);
return faceProcessed;
}
template<class SourcePatch, class TargetPatch> template<class SourcePatch, class TargetPatch>
void Foam::AMIInterpolation<SourcePatch, TargetPatch>::setNextFaces void Foam::AMIInterpolation<SourcePatch, TargetPatch>::setNextFaces
( (
@ -811,7 +867,8 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::setNextFaces
label faceT = visitedFaces[j]; label faceT = visitedFaces[j];
scalar area = interArea(faceS, faceT, srcPatch0, tgtPatch0); scalar area = interArea(faceS, faceT, srcPatch0, tgtPatch0);
if (area > 0) // Check that faces have enough overlap for robust walking
if (area/srcMagSf_[srcFaceI] > faceAreaIntersect::tolerance())
{ {
// TODO - throwing area away - re-use in next iteration? // TODO - throwing area away - re-use in next iteration?
@ -864,7 +921,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::setNextFaces
<< "target face" << endl; << "target face" << endl;
} }
// foundNextSeed = false; foundNextSeed = false;
for (label faceI = startSeedI; faceI < mapFlag.size(); faceI++) for (label faceI = startSeedI; faceI < mapFlag.size(); faceI++)
{ {
if (mapFlag[faceI]) if (mapFlag[faceI])
@ -887,7 +944,8 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::setNextFaces
FatalErrorIn FatalErrorIn
( (
"void Foam::cyclicAMIPolyPatch::setNextFaces" "void Foam::AMIInterpolation<SourcePatch, TargetPatch>::"
"setNextFaces"
"(" "("
"label&, " "label&, "
"label&, " "label&, "
@ -946,6 +1004,25 @@ Foam::scalar Foam::AMIInterpolation<SourcePatch, TargetPatch>::interArea
{ {
area = inter.calc(src, tgt, n, triMode_); area = inter.calc(src, tgt, n, triMode_);
} }
else
{
WarningIn
(
"void Foam::AMIInterpolation<SourcePatch, TargetPatch>::"
"interArea"
"("
"const label, "
"const label, "
"const SourcePatch&, "
"const TargetPatch&"
") const"
) << "Invalid normal for source face " << srcFaceI
<< " points " << UIndirectList<point>(srcPoints, src)
<< " target face " << tgtFaceI
<< " points " << UIndirectList<point>(tgtPoints, tgt)
<< endl;
}
if ((debug > 1) && (area > 0)) if ((debug > 1) && (area > 0))
{ {
@ -956,6 +1033,105 @@ Foam::scalar Foam::AMIInterpolation<SourcePatch, TargetPatch>::interArea
} }
template<class SourcePatch, class TargetPatch>
void Foam::AMIInterpolation<SourcePatch, TargetPatch>::
restartUncoveredSourceFace
(
const SourcePatch& srcPatch,
const TargetPatch& tgtPatch,
List<DynamicList<label> >& srcAddr,
List<DynamicList<scalar> >& srcWght,
List<DynamicList<label> >& tgtAddr,
List<DynamicList<scalar> >& tgtWght
)
{
// Collect all src faces with a low weight
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
labelHashSet lowWeightFaces(100);
forAll(srcWght, srcFaceI)
{
scalar s = sum(srcWght[srcFaceI]);
scalar t = s/srcMagSf_[srcFaceI];
if (t < 0.5)
{
lowWeightFaces.insert(srcFaceI);
}
}
Info<< "AMIInterpolation : restarting search on "
<< returnReduce(lowWeightFaces.size(), sumOp<label>())
<< " faces since sum of weights < 0.5" << endl;
if (lowWeightFaces.size() > 0)
{
// Erase all the lowWeight source faces from the target
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DynamicList<label> okSrcFaces(10);
DynamicList<scalar> okSrcWeights(10);
forAll(tgtAddr, tgtFaceI)
{
okSrcFaces.clear();
okSrcWeights.clear();
DynamicList<label>& srcFaces = tgtAddr[tgtFaceI];
DynamicList<scalar>& srcWeights = tgtWght[tgtFaceI];
forAll(srcFaces, i)
{
if (!lowWeightFaces.found(srcFaces[i]))
{
okSrcFaces.append(srcFaces[i]);
okSrcWeights.append(srcWeights[i]);
}
}
if (okSrcFaces.size() < srcFaces.size())
{
srcFaces.transfer(okSrcFaces);
srcWeights.transfer(okSrcWeights);
}
}
// Restart search from best hit
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// list of tgt face neighbour faces
DynamicList<label> nbrFaces(10);
// list of faces currently visited for srcFaceI to avoid multiple hits
DynamicList<label> visitedFaces(10);
forAllConstIter(labelHashSet, lowWeightFaces, iter)
{
label srcFaceI = iter.key();
label tgtFaceI = findTargetFace(srcFaceI, srcPatch);
if (tgtFaceI != -1)
{
//bool faceProcessed =
processSourceFace
(
srcPatch,
tgtPatch,
srcFaceI,
tgtFaceI,
nbrFaces,
visitedFaces,
srcAddr,
srcWght,
tgtAddr,
tgtWght
);
// ? Check faceProcessed to see if restarting has worked.
}
}
}
}
template<class SourcePatch, class TargetPatch> template<class SourcePatch, class TargetPatch>
void Foam::AMIInterpolation<SourcePatch, TargetPatch>::calcAddressing void Foam::AMIInterpolation<SourcePatch, TargetPatch>::calcAddressing
( (
@ -1073,37 +1249,22 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::calcAddressing
DynamicList<label> nonOverlapFaces; DynamicList<label> nonOverlapFaces;
do do
{ {
nbrFaces.clear(); // Do advancing front starting from srcFaceI,tgtFaceI
visitedFaces.clear(); bool faceProcessed = processSourceFace
(
srcPatch,
tgtPatch,
srcFaceI,
tgtFaceI,
// append initial target face and neighbours nbrFaces,
nbrFaces.append(tgtFaceI); visitedFaces,
appendNbrFaces(tgtFaceI, tgtPatch, visitedFaces, nbrFaces);
bool faceProcessed = false; srcAddr,
srcWght,
do tgtAddr,
{ tgtWght
// process new target face );
tgtFaceI = nbrFaces.remove();
visitedFaces.append(tgtFaceI);
scalar area = interArea(srcFaceI, tgtFaceI, srcPatch, tgtPatch);
// store when intersection area > 0
if (area > 0)
{
srcAddr[srcFaceI].append(tgtFaceI);
srcWght[srcFaceI].append(area);
tgtAddr[tgtFaceI].append(srcFaceI);
tgtWght[tgtFaceI].append(area);
appendNbrFaces(tgtFaceI, tgtPatch, visitedFaces, nbrFaces);
faceProcessed = true;
}
} while (nbrFaces.size() > 0);
mapFlag[srcFaceI] = false; mapFlag[srcFaceI] = false;
@ -1140,6 +1301,22 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::calcAddressing
srcNonOverlap_.transfer(nonOverlapFaces); srcNonOverlap_.transfer(nonOverlapFaces);
} }
// Check for badly covered faces
if (debug)
{
restartUncoveredSourceFace
(
srcPatch,
tgtPatch,
srcAddr,
srcWght,
tgtAddr,
tgtWght
);
}
// transfer data to persistent storage // transfer data to persistent storage
forAll(srcAddr, i) forAll(srcAddr, i)
{ {

View File

@ -246,6 +246,31 @@ class AMIInterpolation
DynamicList<label>& faceIDs DynamicList<label>& faceIDs
) const; ) const;
bool processSourceFace
(
const SourcePatch& srcPatch,
const TargetPatch& tgtPatch,
const label srcFaceI,
const label tgtStartFaceI,
DynamicList<label>& nbrFaces,
DynamicList<label>& visitedFaces,
List<DynamicList<label> >& srcAddr,
List<DynamicList<scalar> >& srcWght,
List<DynamicList<label> >& tgtAddr,
List<DynamicList<scalar> >& tgtWght
);
void restartUncoveredSourceFace
(
const SourcePatch& srcPatch,
const TargetPatch& tgtPatch,
List<DynamicList<label> >& srcAddr,
List<DynamicList<scalar> >& srcWght,
List<DynamicList<label> >& tgtAddr,
List<DynamicList<scalar> >& tgtWght
);
//- Set the source and target seed faces //- Set the source and target seed faces
void setNextFaces void setNextFaces
( (

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,6 +25,10 @@ License
#include "faceAreaIntersect.H" #include "faceAreaIntersect.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::scalar Foam::faceAreaIntersect::tol = 1e-6;
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::faceAreaIntersect::triSliceWithPlane void Foam::faceAreaIntersect::triSliceWithPlane
@ -36,8 +40,6 @@ void Foam::faceAreaIntersect::triSliceWithPlane
const scalar len const scalar len
) )
{ {
const scalar matchTol = 1e-6;
// distance to cutting plane // distance to cutting plane
FixedList<scalar, 3> d; FixedList<scalar, 3> d;
@ -51,7 +53,7 @@ void Foam::faceAreaIntersect::triSliceWithPlane
{ {
d[i] = ((tri[i] - p.refPoint()) & p.normal()); d[i] = ((tri[i] - p.refPoint()) & p.normal());
if (mag(d[i]) < matchTol*len) if (mag(d[i]) < tol*len)
{ {
nCoPlanar++; nCoPlanar++;
copI = i; copI = i;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -78,6 +78,11 @@ private:
const bool reverseB_; const bool reverseB_;
// Static data members
static scalar tol;
// Private Member Functions // Private Member Functions
//- Get triPoints from face //- Get triPoints from face
@ -152,6 +157,9 @@ public:
// Public Member Functions // Public Member Functions
//- Fraction of local length scale to use as intersection tolerance
inline static scalar& tolerance();
//- Return area of intersection of faceA with faceB //- Return area of intersection of faceA with faceB
scalar calc scalar calc
( (

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,6 +23,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline void Foam::faceAreaIntersect::setTriPoints inline void Foam::faceAreaIntersect::setTriPoints
( (
const point& a, const point& a,
@ -106,4 +108,12 @@ inline Foam::scalar Foam::faceAreaIntersect::triArea(const triPoints& t) const
} }
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::scalar& Foam::faceAreaIntersect::tolerance()
{
return tol;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -107,26 +107,37 @@ edges
( (
); );
patches boundary
( (
// is there no way of defining all my 'defaultFaces' to be 'wall'? // is there no way of defining all my 'defaultFaces' to be 'wall'?
wall front front
{
type wall;
faces
( (
// inlet block // inlet block
frontQuad(in1, join1, join2, in2) frontQuad(in1, join1, join2, in2)
// outlet block // outlet block
frontQuad(poro1, out1, out2, poro2) frontQuad(poro1, out1, out2, poro2)
) );
}
wall back back
{
type wall;
faces
( (
// inlet block // inlet block
backQuad(in1, join1, join2, in2) backQuad(in1, join1, join2, in2)
// outlet block // outlet block
backQuad(poro1, out1, out2, poro2) backQuad(poro1, out1, out2, poro2)
) );
}
wall wall wall
{
type wall;
faces
( (
// inlet block // inlet block
quad2D(in1, join1) quad2D(in1, join1)
@ -134,9 +145,13 @@ patches
// outlet block // outlet block
quad2D(poro1, out1) quad2D(poro1, out1)
quad2D(out2, poro2) quad2D(out2, poro2)
) );
}
wall porosityWall porosityWall
{
type wall;
faces
( (
// porosity block // porosity block
frontQuad(join1, poro1, poro2, join2) frontQuad(join1, poro1, poro2, join2)
@ -145,17 +160,26 @@ patches
// porosity block // porosity block
quad2D(join1, poro1) quad2D(join1, poro1)
quad2D(poro2, join2) quad2D(poro2, join2)
) );
}
patch inlet inlet
{
type patch;
faces
( (
quad2D(in2, in1) quad2D(in2, in1)
) );
}
patch outlet outlet
{
type patch;
faces
( (
quad2D(out2, out1) quad2D(out2, out1)
) );
}
); );
mergePatchPairs mergePatchPairs

View File

@ -1,58 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
6
(
front
{
type wall;
nFaces 700;
startFace 63400;
}
back
{
type wall;
nFaces 700;
startFace 64100;
}
wall
{
type wall;
nFaces 1400;
startFace 64800;
}
porosityWall
{
type wall;
nFaces 1600;
startFace 66200;
}
inlet
{
type patch;
nFaces 400;
startFace 67800;
}
outlet
{
type patch;
nFaces 400;
startFace 68200;
}
)
// ************************************************************************* //