Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Sergio Ferraris
2013-06-20 12:37:17 +01:00
15 changed files with 208 additions and 87 deletions

View File

@ -429,18 +429,21 @@ void Foam::searchableSurfaceControl::initialVertices
pointAlignment.set(new triad(normals[0]));
// Limit cell size
const vector vN =
infoList[0].hitPoint()
- 2.0*normals[0]*defaultCellSize_;
if (infoList[0].hit())
{
// Limit cell size
const vector vN =
infoList[0].hitPoint()
- 2.0*normals[0]*defaultCellSize_;
List<pointIndexHit> intersectionList;
searchableSurface_.findLineAny
(
ptField,
pointField(1, vN),
intersectionList
);
List<pointIndexHit> intersectionList;
searchableSurface_.findLineAny
(
ptField,
pointField(1, vN),
intersectionList
);
}
// if (intersectionList[0].hit())
// {
@ -455,12 +458,13 @@ void Foam::searchableSurfaceControl::initialVertices
label priority = -1;
if (!cellSize(pts[pI], sizes[pI], priority))
{
FatalErrorIn
(
"Foam::searchableSurfaceControl::initialVertices"
"(pointField&, scalarField&, tensorField&)"
) << "Could not calculate cell size"
<< abort(FatalError);
sizes[pI] = defaultCellSize_;
// FatalErrorIn
// (
// "Foam::searchableSurfaceControl::initialVertices"
// "(pointField&, scalarField&, tensorField&)"
// ) << "Could not calculate cell size"
// << abort(FatalError);
}
sizes[pI] = min(limitedCellSize, sizes[pI]);

View File

@ -240,7 +240,10 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs
const Foam::point& surfacePt(surfaceHit.hitPoint());
if (geometryToConformTo_.isBaffle(featureIndex, surfaceHit))
extendedFeatureEdgeMesh::sideVolumeType meshableSide =
geometryToConformTo_.meshableSide(featureIndex, surfaceHit);
if (meshableSide == extendedFeatureEdgeMesh::BOTH)
{
createBafflePointPair
(
@ -250,7 +253,7 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs
pts
);
}
else
else if (meshableSide == extendedFeatureEdgeMesh::INSIDE)
{
createPointPair
(
@ -260,6 +263,25 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs
pts
);
}
else if (meshableSide == extendedFeatureEdgeMesh::OUTSIDE)
{
createPointPair
(
pointPairDistance(surfacePt),
surfacePt,
-normal,
pts
);
}
else
{
WarningIn
(
"Foam::conformalVoronoiMesh::insertSurfacePointPairs"
"(const pointIndexHitAndFeatureList&, const fileName)"
) << meshableSide << ", bad"
<< endl;
}
}
insertPoints(pts, true);

View File

@ -989,8 +989,9 @@ bool Foam::conformalVoronoiMesh::surfaceLocationConformsToInside
{
vectorField norm(1);
allGeometry_[info.second()].getNormal
geometryToConformTo_.getNormal
(
info.second(),
List<pointIndexHit>(1, info.first()),
norm
);
@ -1133,8 +1134,9 @@ bool Foam::conformalVoronoiMesh::dualCellSurfaceAllIntersections
{
vectorField norm(1);
allGeometry_[hitSurfaceIntersection].getNormal
geometryToConformTo_.getNormal
(
hitSurfaceIntersection,
List<pointIndexHit>(1, infoIntersection),
norm
);

View File

@ -179,7 +179,7 @@ void Foam::conformalVoronoiMesh::createEdgePointGroupByCirculating
const labelList& edNormalIs = feMesh.edgeNormals()[edgeI];
const labelList& feNormalDirections = feMesh.normalDirections()[edgeI];
const PackedList<2>& normalVolumeTypes = feMesh.normalVolumeTypes();
const List<sideVolumeType>& normalVolumeTypes = feMesh.normalVolumeTypes();
const_circulator<labelList> circ(edNormalIs);
const_circulator<labelList> circNormalDirs(feNormalDirections);
@ -197,10 +197,8 @@ void Foam::conformalVoronoiMesh::createEdgePointGroupByCirculating
if (circ.size()) do
{
const sideVolumeType volType =
sideVolumeType(normalVolumeTypes[circ()]);
const sideVolumeType nextVolType =
sideVolumeType(normalVolumeTypes[circ.next()]);
const sideVolumeType volType = normalVolumeTypes[circ()];
const sideVolumeType nextVolType = normalVolumeTypes[circ.next()];
const vector& normal = feNormals[circ()];
const vector& nextNormal = feNormals[circ.next()];

View File

@ -53,7 +53,10 @@ void Foam::conformationSurfaces::hasBoundedVolume
if
(
surface.hasVolumeType()
&& !baffleSurfaces_[regionOffset_[s]]
&& (
normalVolumeTypes_[regionOffset_[s]]
!= extendedFeatureEdgeMesh::BOTH
)
)
{
pointField pts(1, locationInMesh_);
@ -87,7 +90,11 @@ void Foam::conformationSurfaces::hasBoundedVolume
+ regionOffset_[s];
// Don't include baffle surfaces in the calculation
if (!baffleSurfaces_[patchID])
if
(
normalVolumeTypes_[patchID]
!= extendedFeatureEdgeMesh::BOTH
)
{
sum += triSurf[sI].normal(surfPts);
}
@ -256,7 +263,7 @@ Foam::conformationSurfaces::conformationSurfaces
locationInMesh_(surfaceConformationDict.lookup("locationInMesh")),
surfaces_(),
allGeometryToSurfaces_(),
baffleSurfaces_(),
normalVolumeTypes_(),
patchNames_(),
regionOffset_(),
patchInfo_(),
@ -283,7 +290,7 @@ Foam::conformationSurfaces::conformationSurfaces
allGeometryToSurfaces_.setSize(allGeometry_.size(), -1);
baffleSurfaces_.setSize(nSurf, false);
normalVolumeTypes_.setSize(nSurf);
// Features may be attached to host surfaces or independent
features_.setSize(nSurf + nAddFeat);
@ -294,8 +301,8 @@ Foam::conformationSurfaces::conformationSurfaces
PtrList<dictionary> globalPatchInfo(nSurf);
List<Map<autoPtr<dictionary> > > regionPatchInfo(nSurf);
boolList globalBaffleSurfaces(nSurf, false);
List<Map<bool> > regionBaffleSurface(nSurf);
List<sideVolumeType> globalVolumeTypes(nSurf);
List<Map<sideVolumeType> > regionVolumeTypes(nSurf);
label surfI = 0;
@ -324,12 +331,15 @@ Foam::conformationSurfaces::conformationSurfaces
const dictionary& surfaceSubDict(surfacesDict.subDict(surfaceName));
globalBaffleSurfaces[surfI] = Switch
globalVolumeTypes[surfI] =
(
surfaceSubDict.lookupOrDefault("baffleSurface", false)
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
surfaceSubDict.lookupOrDefault<word>("meshableSide", "inside")
]
);
if (!globalBaffleSurfaces[surfI])
if (!globalVolumeTypes[surfI])
{
if (!allGeometry_[surfaces_[surfI]].hasVolumeType())
{
@ -384,22 +394,20 @@ Foam::conformationSurfaces::conformationSurfaces
regionI,
regionDict.subDict("patchInfo").clone()
);
// Info<< " patchInfo: "
// << regionPatchInfo[surfI][regionI] << endl;
}
if (regionDict.found("baffleSurface"))
{
regionBaffleSurface[surfI].insert
(
regionI,
regionDict.lookup("baffleSurface")
);
// Info<< " baffle: "
// << regionBaffleSurface[surfI][regionI] << endl;
}
regionVolumeTypes[surfI].insert
(
regionI,
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
regionDict.lookupOrDefault<word>
(
"meshableSide",
"inside"
)
]
);
readFeatures(regionDict, regionName, featureI);
}
@ -420,7 +428,7 @@ Foam::conformationSurfaces::conformationSurfaces
// Rework surface specific information into information per global region
patchInfo_.setSize(nRegions);
baffleSurfaces_.setSize(nRegions, false);
normalVolumeTypes_.setSize(nRegions);
forAll(surfaces_, surfI)
{
@ -430,7 +438,7 @@ Foam::conformationSurfaces::conformationSurfaces
for (label i = 0; i < nRegions; i++)
{
label globalRegionI = regionOffset_[surfI] + i;
baffleSurfaces_[globalRegionI] = globalBaffleSurfaces[surfI];
normalVolumeTypes_[globalRegionI] = globalVolumeTypes[surfI];
if (globalPatchInfo.set(surfI))
{
patchInfo_.set
@ -441,12 +449,12 @@ Foam::conformationSurfaces::conformationSurfaces
}
}
forAllConstIter(Map<bool>, regionBaffleSurface[surfI], iter)
forAllConstIter(Map<sideVolumeType>, regionVolumeTypes[surfI], iter)
{
label globalRegionI = regionOffset_[surfI] + iter.key();
baffleSurfaces_[globalRegionI] =
regionBaffleSurface[surfI][iter.key()];
normalVolumeTypes_[globalRegionI] =
regionVolumeTypes[surfI][iter.key()];
}
const Map<autoPtr<dictionary> >& localInfo = regionPatchInfo[surfI];
@ -516,7 +524,7 @@ Foam::conformationSurfaces::conformationSurfaces
Info<< "Names = " << allGeometry_.names() << endl;
Info<< "Surfaces = " << surfaces_ << endl;
Info<< "AllGeom to Surfaces = " << allGeometryToSurfaces_ << endl;
Info<< "Baffle Surfaces = " << baffleSurfaces_ << endl;
Info<< "Volume types = " << normalVolumeTypes_ << endl;
Info<< "Patch names = " << patchNames_ << endl;
Info<< "Region Offset = " << regionOffset_ << endl;
@ -610,7 +618,7 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInside
const label regionI = regionOffset_[s];
if (!baffleSurfaces_[regionI])
if (normalVolumeTypes_[regionI] != extendedFeatureEdgeMesh::BOTH)
{
// if (surface.hasVolumeType())
// {
@ -653,9 +661,7 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInside
//Check if the points are inside the surface by the given distance squared
labelList hitSurfaces;
List<pointIndexHit> hitInfo;
searchableSurfacesQueries::findNearest
(
allGeometry_,
@ -698,7 +704,7 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInside
// inside, therefore, if this is a testForInside = true call, the
// result is false. If this is a testForInside = false call, then
// the result is true.
if (baffleSurfaces_[regionI])
if (normalVolumeTypes_[regionI] == extendedFeatureEdgeMesh::BOTH)
{
continue;
}
@ -709,9 +715,27 @@ Foam::Field<bool> Foam::conformationSurfaces::wellInside
if (surfaceVolumeTests[s][i] == volumeType::OUTSIDE)
// if (surfaceVolumeTests[s][i] != volumeType::INSIDE)
{
insidePoint[i] = false;
break;
if
(
normalVolumeTypes_[regionI]
== extendedFeatureEdgeMesh::INSIDE
)
{
insidePoint[i] = false;
break;
}
}
else if (surfaceVolumeTests[s][i] == volumeType::INSIDE)
{
if
(
normalVolumeTypes_[regionI]
== extendedFeatureEdgeMesh::OUTSIDE
)
{
insidePoint[i] = false;
break;
}
}
}
}
@ -757,7 +781,7 @@ Foam::Field<bool> Foam::conformationSurfaces::wellOutside
const label regionI = regionOffset_[s];
if (!baffleSurfaces_[regionI])
if (normalVolumeTypes_[regionI] != extendedFeatureEdgeMesh::BOTH)
{
surface.getVolumeType(samplePts, surfaceVolumeTests[s]);
}
@ -773,9 +797,7 @@ Foam::Field<bool> Foam::conformationSurfaces::wellOutside
//Check if the points are inside the surface by the given distance squared
labelList hitSurfaces;
List<pointIndexHit> hitInfo;
searchableSurfacesQueries::findNearest
(
allGeometry_,
@ -795,13 +817,12 @@ Foam::Field<bool> Foam::conformationSurfaces::wellOutside
// If the point is within range of the surface, then it can't be
// well (in|out)side
outsidePoint[i] = false;
//continue;
}
forAll(surfaces_, s)
{
// const searchableSurface& surface(allGeometry_[surfaces_[s]]);
const searchableSurface& surface(allGeometry_[surfaces_[s]]);
// if
// (
@ -814,20 +835,42 @@ Foam::Field<bool> Foam::conformationSurfaces::wellOutside
const label regionI = regionOffset_[s];
// Info<< s << " " << surfaces_[s] << " " << surface.name() << " "
// << normalVolumeTypes_[regionI] << " "
// << surfaceVolumeTests[s][i] << endl;
// If one of the pattern tests is failed, then the point cannot be
// inside, therefore, if this is a testForInside = true call, the
// result is false. If this is a testForInside = false call, then
// the result is true.
if (baffleSurfaces_[regionI])
if (normalVolumeTypes_[regionI] == extendedFeatureEdgeMesh::BOTH)
{
continue;
}
if (surfaceVolumeTests[s][i] == volumeType::OUTSIDE)
{
outsidePoint[i] = true;
break;
if
(
normalVolumeTypes_[regionI]
== extendedFeatureEdgeMesh::INSIDE
)
{
outsidePoint[i] = true;
break;
}
}
else if (surfaceVolumeTests[s][i] == volumeType::INSIDE)
{
if
(
normalVolumeTypes_[regionI]
== extendedFeatureEdgeMesh::OUTSIDE
)
{
outsidePoint[i] = true;
break;
}
}
}
}
@ -1281,7 +1324,8 @@ Foam::label Foam::conformationSurfaces::getPatchID
}
bool Foam::conformationSurfaces::isBaffle
Foam::extendedFeatureEdgeMesh::sideVolumeType
Foam::conformationSurfaces::meshableSide
(
const label hitSurface,
const pointIndexHit& surfHit
@ -1291,10 +1335,33 @@ bool Foam::conformationSurfaces::isBaffle
if (patchID == -1)
{
return false;
return extendedFeatureEdgeMesh::NEITHER;
}
return baffleSurfaces_[patchID];
return normalVolumeTypes_[patchID];
}
void Foam::conformationSurfaces::getNormal
(
const label hitSurface,
const List<pointIndexHit>& surfHit,
vectorField& normal
) const
{
allGeometry_[hitSurface].getNormal
(
surfHit,
normal
);
const label patchID = regionOffset_[allGeometryToSurfaces_[hitSurface]];
// Now flip sign of normal depending on mesh side
if (normalVolumeTypes_[patchID] == extendedFeatureEdgeMesh::OUTSIDE)
{
normal *= -1;
}
}

View File

@ -52,6 +52,8 @@ namespace Foam
class conformationSurfaces
{
typedef extendedFeatureEdgeMesh::sideVolumeType sideVolumeType;
// Private data
const Time& runTime_;
@ -78,7 +80,7 @@ class conformationSurfaces
//- A boolean value for each surface to be conformed to specifying if it
// is to be treated as a baffle
boolList baffleSurfaces_;
List<sideVolumeType> normalVolumeTypes_;
//- A flat list of all of the names of the patches from all of the
// surfaces to be reproduced in the meshed geometry
@ -337,12 +339,19 @@ public:
label findPatch(const point& pt) const;
//- Is the surface a baffle.
bool isBaffle
extendedFeatureEdgeMesh::sideVolumeType meshableSide
(
const label hitSurface,
const pointIndexHit& surfHit
) const;
void getNormal
(
const label hitSurface,
const List<pointIndexHit>& surfHit,
vectorField& normal
) const;
// Write

View File

@ -52,10 +52,16 @@ Foam::searchableBoxFeatures::searchableBoxFeatures
)
:
searchableSurfaceFeatures(surface, dict),
mode_(extendedFeatureEdgeMesh::sideVolumeTypeNames_[dict.lookup("mode")])
mode_
(
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
dict.lookupOrDefault<word>("meshableSide", "INSIDE")
]
)
{
Info<< indent
<< " Mesh mode = "
<< " Meshable region = "
<< extendedFeatureEdgeMesh::sideVolumeTypeNames_[mode_]
<< endl;
}

View File

@ -399,7 +399,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
label openStart,
label multipleStart,
const vectorField& normals,
const PackedList<2>& normalVolumeTypes,
const List<sideVolumeType>& normalVolumeTypes,
const vectorField& edgeDirections,
const labelListList& normalDirections,
const labelListList& edgeNormals,

View File

@ -61,7 +61,6 @@ SourceFiles
#include "treeDataEdge.H"
#include "treeDataPoint.H"
#include "PrimitivePatch.H"
#include "PackedList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -163,7 +162,7 @@ private:
vectorField normals_;
//-
PackedList<2> normalVolumeTypes_;
List<sideVolumeType> normalVolumeTypes_;
//- Flat and open edges require the direction of the edge
vectorField edgeDirections_;
@ -287,7 +286,7 @@ public:
label openStart,
label multipleStart,
const vectorField& normals,
const PackedList<2>& normalVolumeTypes,
const List<sideVolumeType>& normalVolumeTypes,
const vectorField& edgeDirections,
const labelListList& normalDirections,
const labelListList& edgeNormals,
@ -392,7 +391,7 @@ public:
inline const vectorField& normals() const;
//- Return
inline const PackedList<2>& normalVolumeTypes() const;
inline const List<sideVolumeType>& normalVolumeTypes() const;
//- Return the edgeDirection vectors
inline const vectorField& edgeDirections() const;

View File

@ -90,7 +90,7 @@ inline const Foam::vectorField& Foam::extendedFeatureEdgeMesh::normals() const
return normals_;
}
inline const Foam::PackedList<2>&
inline const Foam::List<Foam::extendedFeatureEdgeMesh::sideVolumeType>&
Foam::extendedFeatureEdgeMesh::normalVolumeTypes() const
{
return normalVolumeTypes_;

View File

@ -48,13 +48,15 @@ Foam::pointIndexHit Foam::searchableSphere::findNearest
pointIndexHit info(false, sample, -1);
const vector n(sample-centre_);
scalar magN = mag(n);
scalar magSqrN = magSqr(n);
if (nearestDistSqr > sqr(magN-radius_))
if (nearestDistSqr >= magSqrN)
{
scalar magN = Foam::sqrt(magSqrN);
if (magN < ROOTVSMALL)
{
info.rawPoint() = centre_ + vector(1,0,0)/magN*radius_;
info.rawPoint() = centre_ + vector(1,0,0)*radius_;
}
else
{

View File

@ -311,6 +311,9 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
cornerWeights_()
{
checkType();
// apply zero-gradient condition on start-up
this->operator==(patchInternalField());
}

View File

@ -324,6 +324,9 @@ omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
cornerWeights_()
{
checkType();
// apply zero-gradient condition on start-up
this->operator==(patchInternalField());
}

View File

@ -311,6 +311,9 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
cornerWeights_()
{
checkType();
// apply zero-gradient condition on start-up
this->operator==(patchInternalField());
}

View File

@ -322,6 +322,9 @@ omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
cornerWeights_()
{
checkType();
// apply zero-gradient condition on start-up
this->operator==(patchInternalField());
}