ENH: cvMesh: Enable use of regions in conformationSurfaces. Make cell sizing relative to default.

This commit is contained in:
laurence
2013-02-05 14:47:50 +00:00
parent 2bfe3cefd0
commit b125db9ecb
41 changed files with 754 additions and 803 deletions

View File

@ -1,73 +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;
root "";
case "";
instance "";
local "";
class dictionary;
object meshQualityDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Maximum non-orthogonality allowed. Set to 180 to disable.
maxNonOrtho 65;
//- Max skewness allowed. Set to <0 to disable.
maxBoundarySkewness 50;
maxInternalSkewness 10;
//- Max concaveness allowed. Is angle (in degrees) below which concavity
// is allowed. 0 is straight face, <0 would be convex face.
// Set to 180 to disable.
maxConcave 80;
//- Minimum quality of the tet formed by the face-centre
// and variable base point minimum decomposition triangles and
// the cell centre. This has to be a positive number for tracking
// to work. Set to very negative number (e.g. -1E30) to
// disable.
// <0 = inside out tet,
// 0 = flat tet
// 1 = regular tet
minTetQuality 1e-30;
//- Minimum pyramid volume. Is absolute volume of cell pyramid.
// Set to a sensible fraction of the smallest cell volume expected.
// Set to very negative number (e.g. -1E30) to disable.
minVol 1e-20;
//- Minimum face area. Set to <0 to disable.
minArea -1;
//- Minimum face twist. Set to <-1 to disable. dot product of face normal
//- and face centre triangles normal
minTwist 0.001;
//- minimum normalised cell determinant
//- 1 = hex, <= 0 = folded or flattened illegal cell
minDeterminant 0.001;
//- minFaceWeight (0 -> 0.5)
minFaceWeight 0.02;
//- minVolRatio (0 -> 1)
minVolRatio 0.01;
//must be >0 for Fluent compatibility
minTriangleTwist -1;
// ************************************************************************* //

View File

@ -47,23 +47,23 @@ defineTypeNameAndDebug(cellShapeControl, 0);
Foam::cellShapeControl::cellShapeControl Foam::cellShapeControl::cellShapeControl
( (
const Time& runTime, const Time& runTime,
const dictionary& motionDict, const cvControls& cvMeshControls,
const searchableSurfaces& allGeometry, const searchableSurfaces& allGeometry,
const conformationSurfaces& geometryToConformTo const conformationSurfaces& geometryToConformTo
) )
: :
dictionary(motionDict), dictionary(cvMeshControls.cvMeshDict().subDict("motionControl")),
runTime_(runTime), runTime_(runTime),
allGeometry_(allGeometry), allGeometry_(allGeometry),
geometryToConformTo_(geometryToConformTo), geometryToConformTo_(geometryToConformTo),
defaultCellSize_(readScalar(lookup("defaultCellSize"))), defaultCellSize_(cvMeshControls.defaultCellSize()),
minimumCellSize_(readScalar(lookup("minimumCellSize"))), minimumCellSize_(cvMeshControls.minimumCellSize()),
shapeControlMesh_(runTime), shapeControlMesh_(runTime),
aspectRatio_(motionDict), aspectRatio_(*this),
sizeAndAlignment_ sizeAndAlignment_
( (
runTime, runTime,
motionDict.subDict("shapeControlFunctions"), subDict("shapeControlFunctions"),
geometryToConformTo_, geometryToConformTo_,
defaultCellSize_ defaultCellSize_
) )

View File

@ -48,6 +48,7 @@ SourceFiles
#include "cellSizeAndAlignmentControls.H" #include "cellSizeAndAlignmentControls.H"
#include "cellShapeControlMesh.H" #include "cellShapeControlMesh.H"
#include "backgroundMeshDecomposition.H" #include "backgroundMeshDecomposition.H"
#include "cvControls.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -104,7 +105,7 @@ public:
cellShapeControl cellShapeControl
( (
const Time& runTime, const Time& runTime,
const dictionary& cellShapeControlDict, const cvControls& cvMeshControls,
const searchableSurfaces& allGeometry, const searchableSurfaces& allGeometry,
const conformationSurfaces& geometryToConformTo const conformationSurfaces& geometryToConformTo
); );

View File

@ -46,10 +46,12 @@ Foam::cellSizeAndAlignmentControl::cellSizeAndAlignmentControl
const Time& runTime, const Time& runTime,
const word& name, const word& name,
const dictionary& controlFunctionDict, const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
) )
: :
runTime_(runTime), runTime_(runTime),
defaultCellSize_(defaultCellSize),
name_(name) name_(name)
{} {}
@ -62,7 +64,8 @@ Foam::cellSizeAndAlignmentControl::New
const Time& runTime, const Time& runTime,
const word& name, const word& name,
const dictionary& controlFunctionDict, const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
) )
{ {
word cellSizeAndAlignmentControlTypeName word cellSizeAndAlignmentControlTypeName
@ -70,7 +73,7 @@ Foam::cellSizeAndAlignmentControl::New
controlFunctionDict.lookup("type") controlFunctionDict.lookup("type")
); );
Info<< " Selecting cellSizeAndAlignmentControl " Info<< indent << "Selecting cellSizeAndAlignmentControl "
<< cellSizeAndAlignmentControlTypeName << endl; << cellSizeAndAlignmentControlTypeName << endl;
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
@ -99,7 +102,8 @@ Foam::cellSizeAndAlignmentControl::New
runTime, runTime,
name, name,
controlFunctionDict, controlFunctionDict,
geometryToConformTo geometryToConformTo,
defaultCellSize
) )
); );
} }

View File

@ -57,6 +57,8 @@ protected:
const Time& runTime_; const Time& runTime_;
const scalar& defaultCellSize_;
private: private:
@ -91,9 +93,16 @@ public:
const Time& runTime, const Time& runTime,
const word& name, const word& name,
const dictionary& controlFunctionDict, const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
), ),
(runTime, name, controlFunctionDict, geometryToConformTo) (
runTime,
name,
controlFunctionDict,
geometryToConformTo,
defaultCellSize
)
); );
@ -106,7 +115,8 @@ public:
const Time& runTime, const Time& runTime,
const word& name, const word& name,
const dictionary& controlFunctionDict, const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
); );
@ -118,7 +128,8 @@ public:
const Time& runTime, const Time& runTime,
const word& name, const word& name,
const dictionary& controlFunctionDict, const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
); );
@ -135,8 +146,6 @@ public:
return name_; return name_;
} }
virtual label priority() const = 0;
// Query // Query

View File

@ -63,43 +63,10 @@ bool Foam::cellSizeAndAlignmentControls::evalCellSizeFunctions
if (debug) if (debug)
{ {
Info<< "size function " Info<< "size function " << sSC.name() << endl;
<< sSC.name()
<< " priority " << sSC.priority()
<< endl;
} }
if (sSC.priority() < previousPriority) anyFunctionFound = sSC.cellSize(pt, minSize, previousPriority);
{
return minSize;
}
scalar sizeI;
if (sSC.sizeFunction().cellSize(pt, sizeI))
{
anyFunctionFound = true;
if (sSC.priority() == previousPriority)
{
if (sizeI < minSize)
{
minSize = sizeI;
}
}
else
{
minSize = sizeI;
}
if (debug)
{
Info<< "sizeI " << sizeI
<<" minSize " << minSize << endl;
}
previousPriority = sSC.priority();
}
} }
} }
} }
@ -115,7 +82,7 @@ Foam::cellSizeAndAlignmentControls::cellSizeAndAlignmentControls
const Time& runTime, const Time& runTime,
const dictionary& shapeControlDict, const dictionary& shapeControlDict,
const conformationSurfaces& geometryToConformTo, const conformationSurfaces& geometryToConformTo,
const scalar defaultCellSize const scalar& defaultCellSize
) )
: :
shapeControlDict_(shapeControlDict), shapeControlDict_(shapeControlDict),
@ -135,6 +102,7 @@ Foam::cellSizeAndAlignmentControls::cellSizeAndAlignmentControls
); );
Info<< nl << "Shape Control : " << shapeControlEntryName << endl; Info<< nl << "Shape Control : " << shapeControlEntryName << endl;
Info<< incrIndent;
controlFunctions_.set controlFunctions_.set
( (
@ -144,10 +112,13 @@ Foam::cellSizeAndAlignmentControls::cellSizeAndAlignmentControls
runTime, runTime,
shapeControlEntryName, shapeControlEntryName,
controlFunctionDict, controlFunctionDict,
geometryToConformTo geometryToConformTo_,
defaultCellSize_
) )
); );
Info<< decrIndent;
functionI++; functionI++;
} }
} }

View File

@ -56,7 +56,7 @@ class cellSizeAndAlignmentControls
PtrList<cellSizeAndAlignmentControl> controlFunctions_; PtrList<cellSizeAndAlignmentControl> controlFunctions_;
const scalar defaultCellSize_; const scalar& defaultCellSize_;
// Private Member Functions // Private Member Functions
@ -84,7 +84,7 @@ public:
const Time& runTime, const Time& runTime,
const dictionary& shapeControlDict, const dictionary& shapeControlDict,
const conformationSurfaces& geometryToConformTo, const conformationSurfaces& geometryToConformTo,
const scalar defaultCellSize const scalar& defaultCellSize
); );

View File

@ -58,7 +58,8 @@ Foam::fileControl::fileControl
const Time& runTime, const Time& runTime,
const word& name, const word& name,
const dictionary& controlFunctionDict, const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
) )
: :
cellSizeAndAlignmentControl cellSizeAndAlignmentControl
@ -66,14 +67,14 @@ Foam::fileControl::fileControl
runTime, runTime,
name, name,
controlFunctionDict, controlFunctionDict,
geometryToConformTo geometryToConformTo,
defaultCellSize
), ),
pointsFile_(controlFunctionDict.lookup("pointsFile")), pointsFile_(controlFunctionDict.lookup("pointsFile")),
sizesFile_(controlFunctionDict.lookup("sizesFile")), sizesFile_(controlFunctionDict.lookup("sizesFile")),
alignmentsFile_(controlFunctionDict.lookup("alignmentsFile")), alignmentsFile_(controlFunctionDict.lookup("alignmentsFile"))
priority_(readLabel(controlFunctionDict.lookup("priority")))
{ {
Info<< indent << "Loading from file... " << nl Info<< indent << "Loading " << name << " from file:" << nl
<< indent << " points : " << pointsFile_ << nl << indent << " points : " << pointsFile_ << nl
<< indent << " sizes : " << sizesFile_ << nl << indent << " sizes : " << sizesFile_ << nl
<< indent << " alignments : " << alignmentsFile_ << indent << " alignments : " << alignmentsFile_

View File

@ -58,8 +58,6 @@ class fileControl
const fileName alignmentsFile_; const fileName alignmentsFile_;
label priority_;
// Private Member Functions // Private Member Functions
@ -85,7 +83,8 @@ public:
const Time& runTime, const Time& runTime,
const word& name, const word& name,
const dictionary& controlFunctionDict, const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
); );
//- Destructor //- Destructor
@ -121,11 +120,6 @@ public:
scalarField& sizes, scalarField& sizes,
triadField& alignments triadField& alignments
) const; ) const;
virtual label priority() const
{
return priority_;
}
}; };

View File

@ -158,7 +158,8 @@ Foam::searchableSurfaceControl::searchableSurfaceControl
const Time& runTime, const Time& runTime,
const word& name, const word& name,
const dictionary& controlFunctionDict, const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
) )
: :
cellSizeAndAlignmentControl cellSizeAndAlignmentControl
@ -166,174 +167,91 @@ Foam::searchableSurfaceControl::searchableSurfaceControl
runTime, runTime,
name, name,
controlFunctionDict, controlFunctionDict,
geometryToConformTo geometryToConformTo,
defaultCellSize
), ),
surfaceName_(controlFunctionDict.lookupOrDefault<word>("surface", name)), surfaceName_(controlFunctionDict.lookupOrDefault<word>("surface", name)),
searchableSurface_(geometryToConformTo.geometry()[surfaceName_]), searchableSurface_(geometryToConformTo.geometry()[surfaceName_]),
geometryToConformTo_(geometryToConformTo), geometryToConformTo_(geometryToConformTo),
cellSizeFunction_ cellSizeFunctions_(1),
( maxPriority_(-1)
cellSizeFunction::New(controlFunctionDict, searchableSurface_)
)
// geometryToConformTo_(geometryToConformTo),
// surfaces_(),
// cellSizeFunctions_(),
// triangulatedMesh_()
{ {
// const dictionary& surfacesDict = coeffDict(); Info<< indent << "Master settings:" << endl;
// Info<< incrIndent;
// Info<< nl << "Reading cellSizeControlGeometry" << endl;
// cellSizeFunctions_.set
// surfaces_.setSize(surfacesDict.size()); (
// 0,
// cellSizeFunctions_.setSize(surfacesDict.size()); cellSizeFunction::New
// (
// label surfI = 0; controlFunctionDict,
// searchableSurface_,
// DynamicList<point> pointsToInsert; defaultCellSize_
// DynamicList<scalar> sizesToInsert; )
// DynamicList<tensor> alignmentsToInsert; );
//
// forAllConstIter(dictionary, surfacesDict, iter) Info<< decrIndent;
// {
// const dictionary& surfaceSubDict PtrList<cellSizeFunction> regionCellSizeFunctions
// ( (
// surfacesDict.subDict(iter().keyword()) searchableSurface_.regions().size()
// ); );
//
// // If the "surface" keyword is not found in the dictionary, assume label functionI = 0;
// // the name of the dictionary is the surface. Distinction required to
// // allow the same surface to be used multiple times to supply multiple // Loop over regions - if any entry is not specified they should
// // cellSizeFunctions // inherit values from the parent surface.
// if (controlFunctionDict.found("regions"))
// word surfaceName = surfaceSubDict.lookupOrDefault<word> {
// ( const dictionary& regionsDict = controlFunctionDict.subDict("regions");
// "surface", const wordList& regionNames = geometryToConformTo.patchNames();
// iter().keyword()
// ); forAll(regionNames, regionI)
// {
// surfaces_[surfI] = allGeometry_.findSurfaceID(surfaceName); const word& regionName = regionNames[regionI];
//
// if (surfaces_[surfI] < 0) if (regionsDict.found(regionName))
// { {
// FatalErrorIn // Get the dictionary for region
// ( const dictionary& regionDict = regionsDict.subDict(regionName);
// "Foam::surfaceControl::surfaceControl"
// ) << "No surface " << surfaceName << " found. " Info<< indent << "Region " << regionName << " settings:"
// << "Valid geometry is " << nl << allGeometry_.names() << endl;
// << exit(FatalError); Info<< incrIndent;
// }
// regionCellSizeFunctions.set
// const searchableSurface& surface = allGeometry_[surfaces_[surfI]]; (
// functionI,
// Info<< nl << " " << iter().keyword() << nl cellSizeFunction::New
// << " surface: " << surfaceName << nl (
// << " size : " << surface.size() << endl; regionDict,
// searchableSurface_,
// cellSizeFunctions_.set defaultCellSize_
// ( )
// surfI, );
// cellSizeFunction::New Info<< decrIndent;
// (
// surfaceSubDict, functionI++;
// surface }
// ) }
// ); }
//
// surfI++; regionCellSizeFunctions.setSize(functionI);
//
// if (isA<triSurfaceMesh>(surface)) if (functionI > 0)
// { {
// const triSurfaceMesh& tsm cellSizeFunctions_.transfer(regionCellSizeFunctions);
// = refCast<const triSurfaceMesh>(surface); }
//
// const pointField& points = tsm.points(); forAll(cellSizeFunctions_, funcI)
// const vectorField& faceNormals = tsm.faceNormals(); {
// const labelListList& pointFaces = tsm.pointFaces(); const label funcPriority = cellSizeFunctions_[funcI].priority();
//
// Info<< " Number of points: " << tsm.nPoints() << endl; if (funcPriority > maxPriority_)
// {
// forAll(points, pI) maxPriority_ = funcPriority;
// { }
// const Foam::point& pt = points[pI]; }
// const labelList& ptFaces = pointFaces[pI];
//
// vectorField pointNormals(ptFaces.size());
//
// forAll(pointNormals, pnI)
// {
// pointNormals[pnI] = faceNormals[ptFaces[pnI]];
// }
//
// pointsToInsert.append(pt);
//
// // Get the value of the point from surfaceCellSizeFunction. If
// // adding points internally then will need to interpolate.
// scalar newSize = 0;
//
// cellSizeFunctions_[surfI - 1].cellSize(pt, newSize);
// sizesToInsert.append(newSize);
//
// tensor newAlignment = requiredAlignment(pt, pointNormals);
//
// alignmentsToInsert.append(newAlignment);
// }
// }
// }
//
// // Add the global bound box to ensure that all internal point queries
// // will return sizes and alignments
//// boundBox bb = allGeometry_.bounds();
////
//// pointField bbPoints = bb.points();
////
//// forAll(bbPoints, pI)
//// {
//// pointsToInsert.append(bbPoints[pI]);
//// sizesToInsert.append(defaultCellSize());
//// alignmentsToInsert.append(tensor(1,0,0,0,1,0,0,0,1));
//// }
//
// triangulatedMesh_.set
// (
// new triangulatedMesh
// (
// runTime,
// pointsToInsert,
// sizesToInsert,
// alignmentsToInsert,
// defaultCellSize()
// )
// );
//
// scalar factor = 1.0;
// label maxIteration = cellShapeControlDict.lookupOrDefault<label>
// (
// "maxRefinementIterations", 1
// );
//
//
// for (label iteration = 0; iteration < maxIteration; ++iteration)
// {
// Info<< "Iteration : " << iteration << endl;
//
// label nRefined = triangulatedMesh_().refineTriangulation
// (
// factor,
// allGeometry_,
// geometryToConformTo_
// );
//
// Info<< " Number of cells refined in refinement iteration : "
// << nRefined << nl << endl;
//
// if (nRefined <= 0 && iteration != 0)
// {
// break;
// }
//
// factor *= 1.5;
// }
} }
@ -345,219 +263,6 @@ Foam::searchableSurfaceControl::~searchableSurfaceControl()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
//Foam::scalar Foam::surfaceControl::cellSize(const point& pt) const
//{
// scalarList bary;
// Cell_handle ch;
//
// triangulatedMesh_().barycentricCoords(pt, bary, ch);
//
// scalar size = 0;
// forAll(bary, pI)
// {
// size += bary[pI]*ch->vertex(pI)->size();
// }
//
// return size;
//}
//
//
////- Return the cell alignment at the given location
//Foam::tensor Foam::surfaceControl::cellAlignment(const point& pt) const
//{
// scalarList bary;
// Cell_handle ch;
//
// triangulatedMesh_().barycentricCoords(pt, bary, ch);
//
//// vectorField cartesianDirections(3);
////
//// cartesianDirections[0] = vector(0,0,1);
//// cartesianDirections[1] = vector(0,1,0);
//// cartesianDirections[2] = vector(1,0,0);
////
//// // Rearrange each alignment tensor so that the x/y/z components are
//// // in order of whichever makes the smallest angle with the global
//// // coordinate system
//// FixedList<tensor, 4> alignments;
////
//// forAll(alignments, aI)
//// {
//// tensor a = ch->vertex(aI)->alignment();
////
//// tensor tmpA = a;
////
////// Info<< nl << indent<< a << endl;
////
//// scalar minAngle = 0;
////
//// scalar axx = vectorTools::cosPhi(a.x(), cartesianDirections[0]);
//// scalar axy = vectorTools::cosPhi(a.y(), cartesianDirections[0]);
//// scalar axz = vectorTools::cosPhi(a.z(), cartesianDirections[0]);
////
//// scalar ayx = vectorTools::cosPhi(a.x(), cartesianDirections[1]);
//// scalar ayy = vectorTools::cosPhi(a.y(), cartesianDirections[1]);
//// scalar ayz = vectorTools::cosPhi(a.z(), cartesianDirections[1]);
////
//// scalar azx = vectorTools::cosPhi(a.x(), cartesianDirections[2]);
//// scalar azy = vectorTools::cosPhi(a.y(), cartesianDirections[2]);
//// scalar azz = vectorTools::cosPhi(a.z(), cartesianDirections[2]);
////
////// Info<< indent << axx << " " << axy << " " << axz << nl
////// << indent << ayx << " " << ayy << " " << ayz << nl
////// << indent << azx << " " << azy << " " << azz << endl;
////
//// if (mag(axx) >= minAngle)
//// {
//// tmpA.xx() = mag(a.xx());
//// tmpA.xy() = mag(a.xy());
//// tmpA.xz() = mag(a.xz());
//// minAngle = mag(axx);
//// }
//// if (mag(axy) >= minAngle)
//// {
//// tmpA.xx() = mag(a.yx());
//// tmpA.xy() = mag(a.yy());
//// tmpA.xz() = mag(a.yz());
//// minAngle = mag(axy);
//// }
//// if (mag(axz) >= minAngle)
//// {
//// tmpA.xx() = mag(a.zx());
//// tmpA.xy() = mag(a.zy());
//// tmpA.xz() = mag(a.zz());
//// }
////
//// minAngle = 0;
////
//// if (mag(ayx) >= minAngle)
//// {
//// tmpA.yx() = mag(a.xx());
//// tmpA.yy() = mag(a.xy());
//// tmpA.yz() = mag(a.xz());
//// minAngle = mag(ayx);
//// }
//// if (mag(ayy) >= minAngle)
//// {
//// tmpA.yx() = mag(a.yx());
//// tmpA.yy() = mag(a.yy());
//// tmpA.yz() = mag(a.yz());
//// minAngle = mag(ayy);
//// }
//// if (mag(ayz) >= minAngle)
//// {
//// tmpA.yx() = mag(a.zx());
//// tmpA.yy() = mag(a.zy());
//// tmpA.yz() = mag(a.zz());
//// }
////
//// minAngle = 0;
////
//// if (mag(azx) >= minAngle)
//// {
//// tmpA.zx() = mag(a.xx());
//// tmpA.zy() = mag(a.xy());
//// tmpA.zz() = mag(a.xz());
//// minAngle = mag(azx);
//// }
//// if (mag(azy) >= minAngle)
//// {
//// tmpA.zx() = mag(a.yx());
//// tmpA.zy() = mag(a.yy());
//// tmpA.zz() = mag(a.yz());
//// minAngle = mag(azy);
//// }
//// if (mag(azz) >= minAngle)
//// {
//// tmpA.zx() = mag(a.zx());
//// tmpA.zy() = mag(a.zy());
//// tmpA.zz() = mag(a.zz());
//// }
////
//// alignments[aI] = tmpA;
//// }
//
// scalar nearest = 0;
//
//// Info<< nl << "Point " << pt << endl;
////
//// FixedList<quaternion, 4> qAlignments;
//// forAll(qAlignments, aI)
//// {
////// Info<< " Direction " << aI << endl;
////// Info<< " Rot tensor" << alignments[aI] << endl;
//// qAlignments[aI] = quaternion(alignments[aI]);
//// qAlignments[aI].normalize();
////// Info<< " Quaternion: " << qAlignments[aI] << endl;
////// Info<< " Rot tensor from quat: " << qAlignments[aI].R()
////// << endl;
//// }
//
// tensor alignment = Foam::tensor::zero;
// forAll(bary, pI)
// {
//// alignment += bary[pI]*ch->vertex(pI)->alignment();
//
//// alignment += bary[pI]*alignments[pI];
//
// // Try slerp with quaternions
//
// // Find nearest point
// if (bary[pI] > nearest)
// {
// alignment = ch->vertex(pI)->alignment();
// nearest = bary[pI];
// }
// }
//
//// quaternion alignment;
//
//// alignment = qAlignments[0]*bary[0]
//// + qAlignments[1]*bary[1]
//// + qAlignments[2]*bary[2]
//// + qAlignments[3]*bary[3];
//
//// alignment =
//// slerp(qAlignments[0], qAlignments[1], bary[0]+bary[1]+bary[2]);
//// alignment = slerp(alignment, qAlignments[2], bary[0]+bary[1]+bary[2]);
//// alignment = slerp(alignment, qAlignments[3], bary[0]+bary[1]+bary[2]);
//// alignment =
//// slerp(alignment, qAlignments[0], bary[0]/(bary[0]+bary[1]+bary[2]));
//
//// Info<< " Interp alignment : " << alignment << endl;
//// Info<< " Interp rot tensor: " << alignment.R() << endl;
//
// return alignment;
//}
//
//
//void Foam::surfaceControl::cellSizeAndAlignment
//(
// const point& pt,
// scalar& size,
// tensor& alignment
//) const
//{
// scalarList bary;
// Cell_handle ch;
//
// triangulatedMesh_().barycentricCoords(pt, bary, ch);
//
// size = 0;
// forAll(bary, pI)
// {
// size += bary[pI]*ch->vertex(pI)->size();
// }
//
//// alignment = Foam::tensor::zero;
//// forAll(bary, pI)
//// {
//// alignment += bary[pI]*ch->vertex(pI)->alignment();
//// }
//
// alignment = cellAlignment(pt);
//}
void Foam::searchableSurfaceControl::initialVertices void Foam::searchableSurfaceControl::initialVertices
( (
pointField& pts, pointField& pts,
@ -648,7 +353,8 @@ void Foam::searchableSurfaceControl::initialVertices
} }
} }
if (!cellSizeFunction_().cellSize(pts[pI], sizes[pI])) label priority = -1;
if (!cellSize(pts[pI], sizes[pI], priority))
{ {
FatalErrorIn FatalErrorIn
( (
@ -663,4 +369,54 @@ void Foam::searchableSurfaceControl::initialVertices
} }
bool Foam::searchableSurfaceControl::cellSize
(
const Foam::point& pt,
scalar& cellSize,
label& priority
) const
{
bool anyFunctionFound = false;
forAll(sizeFunctions(), funcI)
{
const cellSizeFunction& sizeFunc = sizeFunctions()[funcI];
if (sizeFunc.priority() < priority)
{
continue;
}
scalar sizeI = GREAT;
if (sizeFunc.cellSize(pt, sizeI))
{
anyFunctionFound = true;
if (sizeFunc.priority() == priority)
{
if (sizeI < cellSize)
{
cellSize = sizeI;
}
}
else
{
cellSize = sizeI;
}
if (debug)
{
Info<< "sizeI " << sizeI
<<" minSize " << cellSize << endl;
}
priority = sizeFunc.priority();
}
}
return anyFunctionFound;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -61,7 +61,9 @@ class searchableSurfaceControl
const conformationSurfaces& geometryToConformTo_; const conformationSurfaces& geometryToConformTo_;
autoPtr<cellSizeFunction> cellSizeFunction_; PtrList<cellSizeFunction> cellSizeFunctions_;
label maxPriority_;
// const conformationSurfaces& geometryToConformTo_; // const conformationSurfaces& geometryToConformTo_;
@ -106,7 +108,8 @@ public:
const Time& runTime, const Time& runTime,
const word& name, const word& name,
const dictionary& controlFunctionDict, const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
); );
//- Destructor //- Destructor
@ -147,16 +150,23 @@ public:
triadField& alignments triadField& alignments
) const; ) const;
const cellSizeFunction& sizeFunction() const const PtrList<cellSizeFunction>& sizeFunctions() const
{ {
return cellSizeFunction_(); return cellSizeFunctions_;
} }
virtual label priority() const virtual label maxPriority() const
{ {
return cellSizeFunction_().priority(); return maxPriority_;
} }
bool cellSize
(
const Foam::point& pt,
scalar& cellSize,
label& priority
) const;
// Edit // Edit
}; };

View File

@ -42,7 +42,8 @@ Foam::cellSizeFunction::cellSizeFunction
( (
const word& type, const word& type,
const dictionary& cellSizeFunctionDict, const dictionary& cellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
) )
: :
dictionary(cellSizeFunctionDict), dictionary(cellSizeFunctionDict),
@ -52,14 +53,16 @@ Foam::cellSizeFunction::cellSizeFunction
surfaceCellSizeFunction::New surfaceCellSizeFunction::New
( (
cellSizeFunctionDict, cellSizeFunctionDict,
surface surface,
defaultCellSize
) )
), ),
coeffsDict_(subDict(type + "Coeffs")), coeffsDict_(subDict(type + "Coeffs")),
defaultCellSize_(defaultCellSize),
sideMode_(), sideMode_(),
priority_(readLabel(cellSizeFunctionDict.lookup("priority"))) priority_(readLabel(cellSizeFunctionDict.lookup("priority", true)))
{ {
word mode = cellSizeFunctionDict.lookup("mode"); word mode = cellSizeFunctionDict.lookup("mode", true);
if (surface_.hasVolumeType()) if (surface_.hasVolumeType())
{ {
@ -102,7 +105,8 @@ Foam::cellSizeFunction::cellSizeFunction
Foam::autoPtr<Foam::cellSizeFunction> Foam::cellSizeFunction::New Foam::autoPtr<Foam::cellSizeFunction> Foam::cellSizeFunction::New
( (
const dictionary& cellSizeFunctionDict, const dictionary& cellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
) )
{ {
word cellSizeFunctionTypeName word cellSizeFunctionTypeName
@ -110,7 +114,7 @@ Foam::autoPtr<Foam::cellSizeFunction> Foam::cellSizeFunction::New
cellSizeFunctionDict.lookup("cellSizeFunction") cellSizeFunctionDict.lookup("cellSizeFunction")
); );
Info<< " Selecting cellSizeFunction " << cellSizeFunctionTypeName Info<< indent << "Selecting cellSizeFunction " << cellSizeFunctionTypeName
<< endl; << endl;
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
@ -132,7 +136,7 @@ Foam::autoPtr<Foam::cellSizeFunction> Foam::cellSizeFunction::New
return autoPtr<cellSizeFunction> return autoPtr<cellSizeFunction>
( (
cstrIter()(cellSizeFunctionDict, surface) cstrIter()(cellSizeFunctionDict, surface, defaultCellSize)
); );
} }

View File

@ -94,6 +94,8 @@ protected:
//- Method details dictionary //- Method details dictionary
dictionary coeffsDict_; dictionary coeffsDict_;
const scalar& defaultCellSize_;
//- Mode of size specification, i.e. inside, outside or bothSides //- Mode of size specification, i.e. inside, outside or bothSides
sideMode sideMode_; sideMode sideMode_;
@ -122,9 +124,10 @@ public:
dictionary, dictionary,
( (
const dictionary& cellSizeFunctionDict, const dictionary& cellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
), ),
(cellSizeFunctionDict, surface) (cellSizeFunctionDict, surface, defaultCellSize)
); );
@ -135,7 +138,8 @@ public:
( (
const word& type, const word& type,
const dictionary& cellSizeFunctionDict, const dictionary& cellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
); );
@ -145,7 +149,8 @@ public:
static autoPtr<cellSizeFunction> New static autoPtr<cellSizeFunction> New
( (
const dictionary& cellSizeFunctionDict, const dictionary& cellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
); );

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -44,12 +44,20 @@ addToRunTimeSelectionTable(cellSizeFunction, linearDistance, dictionary);
linearDistance::linearDistance linearDistance::linearDistance
( (
const dictionary& initialPointsDict, const dictionary& initialPointsDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
) )
: :
cellSizeFunction(typeName, initialPointsDict, surface), cellSizeFunction(typeName, initialPointsDict, surface, defaultCellSize),
distanceCellSize_(readScalar(coeffsDict().lookup("distanceCellSize"))), distanceCellSize_
distance_(readScalar(coeffsDict().lookup("distance"))), (
readScalar(coeffsDict().lookup("distanceCellSizeCoeff"))
*defaultCellSize_
),
distance_
(
readScalar(coeffsDict().lookup("distanceCoeff"))*defaultCellSize_
),
distanceSqr_(sqr(distance_)) distanceSqr_(sqr(distance_))
{} {}

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -81,7 +81,8 @@ public:
linearDistance linearDistance
( (
const dictionary& initialPointsDict, const dictionary& initialPointsDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
); );

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -42,12 +42,17 @@ addToRunTimeSelectionTable(cellSizeFunction, linearSpatial, dictionary);
linearSpatial::linearSpatial linearSpatial::linearSpatial
( (
const dictionary& initialPointsDict, const dictionary& initialPointsDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
) )
: :
cellSizeFunction(typeName, initialPointsDict, surface), cellSizeFunction(typeName, initialPointsDict, surface, defaultCellSize),
referencePoint_(coeffsDict().lookup("referencePoint")), referencePoint_(coeffsDict().lookup("referencePoint")),
referenceCellSize_(readScalar(coeffsDict().lookup("referenceCellSize"))), referenceCellSize_
(
readScalar(coeffsDict().lookup("referenceCellSizeCoeff"))
*defaultCellSize_
),
direction_(coeffsDict().lookup("direction")), direction_(coeffsDict().lookup("direction")),
cellSizeGradient_(readScalar(coeffsDict().lookup("cellSizeGradient"))) cellSizeGradient_(readScalar(coeffsDict().lookup("cellSizeGradient")))
{ {

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -85,7 +85,8 @@ public:
linearSpatial linearSpatial
( (
const dictionary& initialPointsDict, const dictionary& initialPointsDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
); );

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,25 +46,33 @@ addToRunTimeSelectionTable
surfaceOffsetLinearDistance::surfaceOffsetLinearDistance surfaceOffsetLinearDistance::surfaceOffsetLinearDistance
( (
const dictionary& initialPointsDict, const dictionary& initialPointsDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
) )
: :
cellSizeFunction(typeName, initialPointsDict, surface), cellSizeFunction(typeName, initialPointsDict, surface, defaultCellSize),
distanceCellSize_(readScalar(coeffsDict().lookup("distanceCellSize"))), distanceCellSize_
surfaceOffset_(readScalar(coeffsDict().lookup("surfaceOffset"))), (
readScalar(coeffsDict().lookup("distanceCellSizeCoeff"))
*defaultCellSize_
),
surfaceOffset_
(
readScalar(coeffsDict().lookup("surfaceOffsetCoeff"))*defaultCellSize_
),
totalDistance_(), totalDistance_(),
totalDistanceSqr_() totalDistanceSqr_()
{ {
if if
( (
coeffsDict().found("totalDistance") coeffsDict().found("totalDistanceCoeff")
|| coeffsDict().found("linearDistance") || coeffsDict().found("linearDistanceCoeff")
) )
{ {
if if
( (
coeffsDict().found("totalDistance") coeffsDict().found("totalDistanceCoeff")
&& coeffsDict().found("linearDistance") && coeffsDict().found("linearDistanceCoeff")
) )
{ {
FatalErrorIn FatalErrorIn
@ -72,23 +80,26 @@ surfaceOffsetLinearDistance::surfaceOffsetLinearDistance
"surfaceOffsetLinearDistance::surfaceOffsetLinearDistance" "surfaceOffsetLinearDistance::surfaceOffsetLinearDistance"
"(" "("
" const dictionary& initialPointsDict," " const dictionary& initialPointsDict,"
"const conformalVoronoiMesh& cvMesh, " " const searchableSurface& surface,"
"const searchableSurface& surface" " const scalar& defaultCellSize"
")" ")"
) )
<< "totalDistance and linearDistance found, " << "totalDistanceCoeff and linearDistanceCoeff found, "
<< "specify one or other, not both." << "specify one or other, not both."
<< nl << exit(FatalError) << endl; << nl << exit(FatalError) << endl;
} }
if (coeffsDict().found("totalDistance")) if (coeffsDict().found("totalDistanceCoeff"))
{ {
totalDistance_ = readScalar(coeffsDict().lookup("totalDistance")); totalDistance_ =
readScalar(coeffsDict().lookup("totalDistanceCoeff"))
*defaultCellSize_;
} }
else else
{ {
totalDistance_ = totalDistance_ =
readScalar(coeffsDict().lookup("linearDistance")) readScalar(coeffsDict().lookup("linearDistanceCoeff"))
*defaultCellSize_
+ surfaceOffset_; + surfaceOffset_;
} }
} }
@ -99,11 +110,11 @@ surfaceOffsetLinearDistance::surfaceOffsetLinearDistance
"surfaceOffsetLinearDistance::surfaceOffsetLinearDistance" "surfaceOffsetLinearDistance::surfaceOffsetLinearDistance"
"(" "("
" const dictionary& initialPointsDict," " const dictionary& initialPointsDict,"
"const conformalVoronoiMesh& cvMesh, " " const searchableSurface& surface,"
"const searchableSurface& surface" " const scalar& defaultCellSize"
")" ")"
) )
<< "totalDistance or linearDistance not found." << "totalDistanceCoeff or linearDistanceCoeff not found."
<< nl << exit(FatalError) << endl; << nl << exit(FatalError) << endl;
} }

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -85,7 +85,8 @@ public:
surfaceOffsetLinearDistance surfaceOffsetLinearDistance
( (
const dictionary& initialPointsDict, const dictionary& initialPointsDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
); );

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -41,10 +41,11 @@ addToRunTimeSelectionTable(cellSizeFunction, uniform, dictionary);
uniform::uniform uniform::uniform
( (
const dictionary& initialPointsDict, const dictionary& initialPointsDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
) )
: :
cellSizeFunction(typeName, initialPointsDict, surface) cellSizeFunction(typeName, initialPointsDict, surface, defaultCellSize)
{} {}

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -66,7 +66,8 @@ public:
uniform uniform
( (
const dictionary& initialPointsDict, const dictionary& initialPointsDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
); );

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -42,11 +42,15 @@ addToRunTimeSelectionTable(cellSizeFunction, uniformDistance, dictionary);
uniformDistance::uniformDistance uniformDistance::uniformDistance
( (
const dictionary& initialPointsDict, const dictionary& initialPointsDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
) )
: :
cellSizeFunction(typeName, initialPointsDict, surface), cellSizeFunction(typeName, initialPointsDict, surface, defaultCellSize),
distance_(readScalar(coeffsDict().lookup("distance"))), distance_
(
readScalar(coeffsDict().lookup("distanceCoeff"))*defaultCellSize_
),
distanceSqr_(sqr(distance_)) distanceSqr_(sqr(distance_))
{} {}

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -72,7 +72,8 @@ public:
uniformDistance uniformDistance
( (
const dictionary& initialPointsDict, const dictionary& initialPointsDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
); );

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -95,10 +95,17 @@ void Foam::automatic::smoothField(triSurfaceScalarField& surf)
Foam::automatic::automatic Foam::automatic::automatic
( (
const dictionary& cellSizeCalcTypeDict, const dictionary& cellSizeCalcTypeDict,
const triSurfaceMesh& surface const triSurfaceMesh& surface,
const scalar& defaultCellSize
) )
: :
cellSizeCalculationType(typeName, cellSizeCalcTypeDict, surface), cellSizeCalculationType
(
typeName,
cellSizeCalcTypeDict,
surface,
defaultCellSize
),
coeffsDict_(cellSizeCalcTypeDict.subDict(typeName + "Coeffs")), coeffsDict_(cellSizeCalcTypeDict.subDict(typeName + "Coeffs")),
surface_(surface), surface_(surface),
surfaceName_(surface.searchableSurface::name()), surfaceName_(surface.searchableSurface::name()),
@ -108,13 +115,13 @@ Foam::automatic::automatic
featureProximityFile_(coeffsDict_.lookup("featureProximityFile")), featureProximityFile_(coeffsDict_.lookup("featureProximityFile")),
readInternalCloseness_(Switch(coeffsDict_.lookup("internalCloseness"))), readInternalCloseness_(Switch(coeffsDict_.lookup("internalCloseness"))),
internalClosenessFile_(coeffsDict_.lookup("internalClosenessFile")), internalClosenessFile_(coeffsDict_.lookup("internalClosenessFile")),
curvatureCellSizeFactor_ curvatureCellSizeCoeff_
( (
readScalar(coeffsDict_.lookup("curvatureCellSizeFactor")) readScalar(coeffsDict_.lookup("curvatureCellSizeCoeff"))
), ),
maximumCellSize_ maximumCellSize_
( (
readScalar(coeffsDict_.lookup("maximumCellSize")) readScalar(coeffsDict_.lookup("maximumCellSizeCoeff"))*defaultCellSize_
) )
{} {}
@ -186,7 +193,7 @@ Foam::triSurfaceScalarField Foam::automatic::load()
1.0 1.0
/max /max
( (
(1.0/curvatureCellSizeFactor_) (1.0/curvatureCellSizeCoeff_)
*interpolatedCurvatureToFace, *interpolatedCurvatureToFace,
1.0/maximumCellSize_ 1.0/maximumCellSize_
), ),

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -79,7 +79,7 @@ private:
//- The curvature values are multiplied by the inverse of this value to //- The curvature values are multiplied by the inverse of this value to
// get the cell size // get the cell size
const scalar curvatureCellSizeFactor_; const scalar curvatureCellSizeCoeff_;
//- The maximum allowable sell size //- The maximum allowable sell size
const scalar maximumCellSize_; const scalar maximumCellSize_;
@ -102,7 +102,8 @@ public:
automatic automatic
( (
const dictionary& cellSizeCalcTypeDict, const dictionary& cellSizeCalcTypeDict,
const triSurfaceMesh& surface const triSurfaceMesh& surface,
const scalar& defaultCellSize
); );

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -41,10 +41,12 @@ Foam::cellSizeCalculationType::cellSizeCalculationType
( (
const word& type, const word& type,
const dictionary& cellSizeCalculationTypeDict, const dictionary& cellSizeCalculationTypeDict,
const triSurfaceMesh& surface const triSurfaceMesh& surface,
const scalar& defaultCellSize
) )
: :
cellSizeCalculationTypeDict_(cellSizeCalculationTypeDict) cellSizeCalculationTypeDict_(cellSizeCalculationTypeDict),
defaultCellSize_(defaultCellSize)
{} {}
@ -53,7 +55,8 @@ Foam::cellSizeCalculationType::cellSizeCalculationType
Foam::autoPtr<Foam::cellSizeCalculationType> Foam::cellSizeCalculationType::New Foam::autoPtr<Foam::cellSizeCalculationType> Foam::cellSizeCalculationType::New
( (
const dictionary& cellSizeCalculationTypeDict, const dictionary& cellSizeCalculationTypeDict,
const triSurfaceMesh& surface const triSurfaceMesh& surface,
const scalar& defaultCellSize
) )
{ {
word cellSizeCalculationTypeTypeName word cellSizeCalculationTypeTypeName
@ -61,7 +64,7 @@ Foam::autoPtr<Foam::cellSizeCalculationType> Foam::cellSizeCalculationType::New
cellSizeCalculationTypeDict.lookup("cellSizeCalculationType") cellSizeCalculationTypeDict.lookup("cellSizeCalculationType")
); );
Info<< " Selecting cellSizeCalculationType " Info<< indent << "Selecting cellSizeCalculationType "
<< cellSizeCalculationTypeTypeName << endl; << cellSizeCalculationTypeTypeName << endl;
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
@ -83,7 +86,7 @@ Foam::autoPtr<Foam::cellSizeCalculationType> Foam::cellSizeCalculationType::New
return autoPtr<cellSizeCalculationType> return autoPtr<cellSizeCalculationType>
( (
cstrIter()(cellSizeCalculationTypeDict, surface) cstrIter()(cellSizeCalculationTypeDict, surface, defaultCellSize)
); );
} }

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -58,6 +58,8 @@ protected:
const dictionary& cellSizeCalculationTypeDict_; const dictionary& cellSizeCalculationTypeDict_;
const scalar& defaultCellSize_;
private: private:
@ -85,9 +87,10 @@ public:
dictionary, dictionary,
( (
const dictionary& cellSizeCalculationTypeDict, const dictionary& cellSizeCalculationTypeDict,
const triSurfaceMesh& surface const triSurfaceMesh& surface,
const scalar& defaultCellSize
), ),
(cellSizeCalculationTypeDict, surface) (cellSizeCalculationTypeDict, surface, defaultCellSize)
); );
@ -98,7 +101,8 @@ public:
( (
const word& type, const word& type,
const dictionary& cellSizeCalculationTypeDict, const dictionary& cellSizeCalculationTypeDict,
const triSurfaceMesh& surface const triSurfaceMesh& surface,
const scalar& defaultCellSize
); );
@ -108,7 +112,8 @@ public:
static autoPtr<cellSizeCalculationType> New static autoPtr<cellSizeCalculationType> New
( (
const dictionary& cellSizeCalculationTypeDict, const dictionary& cellSizeCalculationTypeDict,
const triSurfaceMesh& surface const triSurfaceMesh& surface,
const scalar& defaultCellSize
); );

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -47,10 +47,17 @@ namespace Foam
Foam::fieldFromFile::fieldFromFile Foam::fieldFromFile::fieldFromFile
( (
const dictionary& cellSizeCalcTypeDict, const dictionary& cellSizeCalcTypeDict,
const triSurfaceMesh& surface const triSurfaceMesh& surface,
const scalar& defaultCellSize
) )
: :
cellSizeCalculationType(typeName, cellSizeCalcTypeDict, surface), cellSizeCalculationType
(
typeName,
cellSizeCalcTypeDict,
surface,
defaultCellSize
),
surface_(surface), surface_(surface),
fileName_ fileName_
( (

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -78,7 +78,8 @@ public:
fieldFromFile fieldFromFile
( (
const dictionary& cellSizeCalcTypeDict, const dictionary& cellSizeCalcTypeDict,
const triSurfaceMesh& surface const triSurfaceMesh& surface,
const scalar& defaultCellSize
); );

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -48,10 +48,17 @@ namespace Foam
Foam::nonUniformField::nonUniformField Foam::nonUniformField::nonUniformField
( (
const dictionary& cellSizeFunctionDict, const dictionary& cellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
) )
: :
surfaceCellSizeFunction(typeName, cellSizeFunctionDict, surface), surfaceCellSizeFunction
(
typeName,
cellSizeFunctionDict,
surface,
defaultCellSize
),
surfaceTriMesh_(refCast<const triSurfaceMesh>(surface)), surfaceTriMesh_(refCast<const triSurfaceMesh>(surface)),
surfaceCellSize_ surfaceCellSize_
( (
@ -70,17 +77,20 @@ Foam::nonUniformField::nonUniformField
), ),
cellSizeCalculationType_ cellSizeCalculationType_
( (
cellSizeCalculationType::New(coeffsDict(), surfaceTriMesh_) cellSizeCalculationType::New
(
coeffsDict(),
surfaceTriMesh_,
defaultCellSize_
)
), ),
pointCellSize_(), pointCellSize_(),
patch_() patch_()
{ {
Info<< incrIndent << incrIndent; Info<< incrIndent;
surfaceCellSize_ = cellSizeCalculationType_().load(); surfaceCellSize_ = cellSizeCalculationType_().load();
Info<< decrIndent;
Info<< indent << "Cell size field statistics:" << nl Info<< indent << "Cell size field statistics:" << nl
<< indent << " Minimum: " << min(surfaceCellSize_).value() << nl << indent << " Minimum: " << min(surfaceCellSize_).value() << nl
<< indent << " Average: " << average(surfaceCellSize_).value() << nl << indent << " Average: " << average(surfaceCellSize_).value() << nl

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -91,7 +91,8 @@ public:
nonUniformField nonUniformField
( (
const dictionary& cellSizeFunctionDict, const dictionary& cellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
); );

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -40,12 +40,14 @@ Foam::surfaceCellSizeFunction::surfaceCellSizeFunction
( (
const word& type, const word& type,
const dictionary& surfaceCellSizeFunctionDict, const dictionary& surfaceCellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
) )
: :
dictionary(surfaceCellSizeFunctionDict), dictionary(surfaceCellSizeFunctionDict),
surface_(surface), surface_(surface),
coeffsDict_(subDict(type + "Coeffs")), coeffsDict_(subDict(type + "Coeffs")),
defaultCellSize_(defaultCellSize),
refinementFactor_ refinementFactor_
( (
lookupOrDefault<scalar>("refinementFactor", 1.0) lookupOrDefault<scalar>("refinementFactor", 1.0)
@ -58,7 +60,8 @@ Foam::surfaceCellSizeFunction::surfaceCellSizeFunction
Foam::autoPtr<Foam::surfaceCellSizeFunction> Foam::surfaceCellSizeFunction::New Foam::autoPtr<Foam::surfaceCellSizeFunction> Foam::surfaceCellSizeFunction::New
( (
const dictionary& surfaceCellSizeFunctionDict, const dictionary& surfaceCellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
) )
{ {
word surfaceCellSizeFunctionTypeName word surfaceCellSizeFunctionTypeName
@ -66,7 +69,7 @@ Foam::autoPtr<Foam::surfaceCellSizeFunction> Foam::surfaceCellSizeFunction::New
surfaceCellSizeFunctionDict.lookup("surfaceCellSizeFunction") surfaceCellSizeFunctionDict.lookup("surfaceCellSizeFunction")
); );
Info<< " Selecting surfaceCellSizeFunction " Info<< indent << "Selecting surfaceCellSizeFunction "
<< surfaceCellSizeFunctionTypeName << endl; << surfaceCellSizeFunctionTypeName << endl;
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
@ -88,7 +91,7 @@ Foam::autoPtr<Foam::surfaceCellSizeFunction> Foam::surfaceCellSizeFunction::New
return autoPtr<surfaceCellSizeFunction> return autoPtr<surfaceCellSizeFunction>
( (
cstrIter()(surfaceCellSizeFunctionDict, surface) cstrIter()(surfaceCellSizeFunctionDict, surface, defaultCellSize)
); );
} }

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -64,6 +64,8 @@ protected:
const dictionary coeffsDict_; const dictionary coeffsDict_;
const scalar& defaultCellSize_;
//- If cell resizing is allowed, this is the factor of the old cell size //- If cell resizing is allowed, this is the factor of the old cell size
// to get the new cell size // to get the new cell size
scalar refinementFactor_; scalar refinementFactor_;
@ -95,9 +97,10 @@ public:
dictionary, dictionary,
( (
const dictionary& surfaceCellSizeFunctionDict, const dictionary& surfaceCellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
), ),
(surfaceCellSizeFunctionDict, surface) (surfaceCellSizeFunctionDict, surface, defaultCellSize)
); );
@ -108,7 +111,8 @@ public:
( (
const word& type, const word& type,
const dictionary& surfaceCellSizeFunctionDict, const dictionary& surfaceCellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
); );
@ -118,7 +122,8 @@ public:
static autoPtr<surfaceCellSizeFunction> New static autoPtr<surfaceCellSizeFunction> New
( (
const dictionary& surfaceCellSizeFunctionDict, const dictionary& surfaceCellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
); );

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -45,11 +45,21 @@ namespace Foam
Foam::uniformValue::uniformValue Foam::uniformValue::uniformValue
( (
const dictionary& cellSizeFunctionDict, const dictionary& cellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
) )
: :
surfaceCellSizeFunction(typeName, cellSizeFunctionDict, surface), surfaceCellSizeFunction
surfaceCellSize_(readScalar(coeffsDict().lookup("surfaceCellSize"))) (
typeName,
cellSizeFunctionDict,
surface,
defaultCellSize
),
surfaceCellSize_
(
readScalar(coeffsDict().lookup("surfaceCellSizeCoeff"))*defaultCellSize_
)
{} {}

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -69,7 +69,8 @@ public:
uniformValue uniformValue
( (
const dictionary& cellSizeFunctionDict, const dictionary& cellSizeFunctionDict,
const searchableSurface& surface const searchableSurface& surface,
const scalar& defaultCellSize
); );

View File

@ -539,7 +539,7 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs
const Foam::point& surfacePt(surfaceHit.hitPoint()); const Foam::point& surfacePt(surfaceHit.hitPoint());
if (geometryToConformTo_.isBaffle(featureIndex)) if (geometryToConformTo_.isBaffle(featureIndex, surfaceHit))
{ {
createBafflePointPair createBafflePointPair
( (
@ -1213,7 +1213,7 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh
cellShapeControl_ cellShapeControl_
( (
runTime_, runTime_,
cvMeshDict.subDict("motionControl"), cvMeshControls_,
allGeometry_, allGeometry_,
geometryToConformTo_ geometryToConformTo_
), ),

View File

@ -1823,12 +1823,23 @@ Foam::label Foam::conformalVoronoiMesh::createPatchInfo
patchTypes.setSize(patchNames.size() + 1, wallPolyPatch::typeName); patchTypes.setSize(patchNames.size() + 1, wallPolyPatch::typeName);
procNeighbours.setSize(patchNames.size() + 1, -1); procNeighbours.setSize(patchNames.size() + 1, -1);
const PtrList<dictionary>& patchInfo = geometryToConformTo_.patchInfo();
forAll(patchNames, patchI)
{
if (patchInfo.set(patchI))
{
patchTypes[patchI] =
patchInfo[patchI].lookupOrDefault<word>
(
"type",
wallPolyPatch::typeName
);
}
}
patchNames.setSize(patchNames.size() + 1); patchNames.setSize(patchNames.size() + 1);
label defaultPatchIndex = patchNames.size() - 1; label defaultPatchIndex = patchNames.size() - 1;
patchTypes[defaultPatchIndex] = wallPolyPatch::typeName;
procNeighbours[defaultPatchIndex] = -1;
patchNames[defaultPatchIndex] = "cvMesh_defaultPatch"; patchNames[defaultPatchIndex] = "cvMesh_defaultPatch";
label nProcPatches = 0; label nProcPatches = 0;

View File

@ -27,111 +27,96 @@ License
#include "conformalVoronoiMesh.H" #include "conformalVoronoiMesh.H"
#include "triSurface.H" #include "triSurface.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::conformationSurfaces::conformationSurfaces void Foam::conformationSurfaces::hasBoundedVolume
( (
const Time& runTime, List<searchableSurface::volumeType>& referenceVolumeTypes
Random& rndGen, ) const
const searchableSurfaces& allGeometry, {
const dictionary& surfaceConformationDict vector sum = vector::zero;
label totalTriangles = 0;
Info<< baffleSurfaces_ << endl;
Info<< surfaces_ << endl;
Info<< regionOffset_ << endl;
Info<< allGeometryToSurfaces_ << endl;
forAll(surfaces_, s)
{
const searchableSurface& surface(allGeometry_[surfaces_[s]]);
if (surface.hasVolumeType())
{
pointField pts(1, locationInMesh_);
List<searchableSurface::volumeType> vTypes
(
pts.size(),
searchableSurface::UNKNOWN
);
surface.getVolumeType(pts, vTypes);
referenceVolumeTypes[s] = vTypes[0];
Info<< " is "
<< searchableSurface::volumeTypeNames[referenceVolumeTypes[s]]
<< " surface " << surface.name()
<< endl;
}
if (isA<triSurface>(surface))
{
const triSurface& triSurf = refCast<const triSurface>(surface);
const pointField& surfPts = triSurf.points();
forAll(triSurf, sI)
{
const label patchID =
triSurf[sI].region()
+ regionOffset_[allGeometryToSurfaces_[s]];
// Don't include baffle surfaces in the calculation
if (!baffleSurfaces_[patchID])
{
sum += triSurf[sI].normal(surfPts);
}
}
totalTriangles += triSurf.size();
}
}
Info<< " Sum of all the surface normals (if near zero, surface is"
<< " probably closed):" << nl
<< " Sum = " << sum/totalTriangles << nl
<< " mag(Sum) = " << mag(sum)/totalTriangles
<< endl;
}
void Foam::conformationSurfaces::readFeatures
(
const dictionary& featureDict,
const word& surfaceName,
label& featureIndex
) )
:
runTime_(runTime),
rndGen_(rndGen),
allGeometry_(allGeometry),
features_(),
locationInMesh_(surfaceConformationDict.lookup("locationInMesh")),
surfaces_(),
allGeometryToSurfaces_(),
baffleSurfaces_(),
patchNames_(0),
patchOffsets_(),
globalBounds_(),
referenceVolumeTypes_(0)
{ {
const dictionary& surfacesDict word featureMethod =
( featureDict.lookupOrDefault<word>("featureMethod", "none");
surfaceConformationDict.subDict("geometryToConformTo")
);
const dictionary& additionalFeaturesDict
(
surfaceConformationDict.subDict("additionalFeatures")
);
Info<< nl << "Reading geometryToConformTo" << endl;
surfaces_.setSize(surfacesDict.size(), -1);
allGeometryToSurfaces_.setSize(allGeometry_.size(), -1);
baffleSurfaces_.setSize(surfacesDict.size(), false);
// Features may be attached to host surfaces or independent
features_.setSize(surfacesDict.size() + additionalFeaturesDict.size());
label featureI = 0;
patchOffsets_.setSize(surfacesDict.size(), -1);
label surfI = 0;
forAllConstIter(dictionary, surfacesDict, iter)
{
word surfaceName = iter().keyword();
surfaces_[surfI] = allGeometry_.findSurfaceID(surfaceName);
allGeometryToSurfaces_[surfaces_[surfI]] = surfI;
if (surfaces_[surfI] < 0)
{
FatalErrorIn("Foam::conformationSurfaces::conformationSurfaces")
<< "No surface " << iter().keyword() << " found. "
<< "Valid geometry is " << nl << allGeometry_.names()
<< exit(FatalError);
}
Info<< nl << " " << iter().keyword() << endl;
patchOffsets_[surfI] = patchNames_.size();
patchNames_.append(allGeometry.regionNames()[surfaces_[surfI]]);
const dictionary& surfaceSubDict(surfacesDict.subDict(surfaceName));
baffleSurfaces_[surfI] = Switch
(
surfaceSubDict.lookupOrDefault("baffleSurface", false)
);
if (!baffleSurfaces_[surfI])
{
if (!allGeometry_[surfaces_[surfI]].hasVolumeType())
{
WarningIn("conformationSurfaces::conformationSurfaces(..)")
<< "Non-baffle surface "
<< allGeometry_[surfaces_[surfI]].name()
<< " does not allow inside/outside queries."
<< " This usually is an error." << endl;
}
}
word featureMethod = surfaceSubDict.lookup("featureMethod");
if (featureMethod == "extendedFeatureEdgeMesh") if (featureMethod == "extendedFeatureEdgeMesh")
{ {
fileName feMeshName fileName feMeshName(featureDict.lookup("extendedFeatureEdgeMesh"));
(
surfaceSubDict.lookup("extendedFeatureEdgeMesh")
);
Info<< " features: " << feMeshName << endl; Info<< " features: " << feMeshName << endl;
features_.set features_.set
( (
featureI++, featureIndex++,
new extendedFeatureEdgeMesh new extendedFeatureEdgeMesh
( (
IOobject IOobject
@ -150,7 +135,7 @@ Foam::conformationSurfaces::conformationSurfaces
{ {
notImplemented notImplemented
( (
"conformationSurfaces::conformationSurfaces, " "Foam::conformationSurfaces::readFeatures, "
"else if (featureMethod == \"extractFeatures\")" "else if (featureMethod == \"extractFeatures\")"
); );
} }
@ -160,16 +145,230 @@ Foam::conformationSurfaces::conformationSurfaces
} }
else else
{ {
FatalErrorIn("Foam::conformationSurfaces::conformationSurfaces") FatalErrorIn("Foam::conformationSurfaces::readFeatures")
<< "No valid featureMethod found for surface " << surfaceName << "No valid featureMethod found for surface " << surfaceName
<< nl << "Use \"extendedFeatureEdgeMesh\" " << nl << "Use \"extendedFeatureEdgeMesh\" "
<< "or \"extractFeatures\"." << "or \"extractFeatures\"."
<< exit(FatalError); << exit(FatalError);
} }
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::conformationSurfaces::conformationSurfaces
(
const Time& runTime,
Random& rndGen,
const searchableSurfaces& allGeometry,
const dictionary& surfaceConformationDict
)
:
runTime_(runTime),
rndGen_(rndGen),
allGeometry_(allGeometry),
features_(),
locationInMesh_(surfaceConformationDict.lookup("locationInMesh")),
surfaces_(),
allGeometryToSurfaces_(),
baffleSurfaces_(),
patchNames_(),
regionOffset_(),
patchInfo_(),
globalBounds_(),
referenceVolumeTypes_(0)
{
const dictionary& surfacesDict
(
surfaceConformationDict.subDict("geometryToConformTo")
);
const label nSurf = surfacesDict.size();
const dictionary& additionalFeaturesDict
(
surfaceConformationDict.subDict("additionalFeatures")
);
const label nAddFeat = additionalFeaturesDict.size();
Info<< nl << "Reading geometryToConformTo" << endl;
surfaces_.setSize(nSurf, -1);
allGeometryToSurfaces_.setSize(allGeometry_.size(), -1);
baffleSurfaces_.setSize(nSurf, false);
// Features may be attached to host surfaces or independent
features_.setSize(nSurf + nAddFeat);
label featureI = 0;
regionOffset_.setSize(nSurf, 0);
PtrList<dictionary> globalPatchInfo(nSurf);
List<Map<autoPtr<dictionary> > > regionPatchInfo(nSurf);
boolList globalBaffleSurfaces(nSurf, false);
List<Map<bool> > regionBaffleSurface(nSurf);
label surfI = 0;
forAllConstIter(dictionary, surfacesDict, iter)
{
word surfaceName = iter().keyword();
surfaces_[surfI] = allGeometry_.findSurfaceID(surfaceName);
if (surfaces_[surfI] < 0)
{
FatalErrorIn("Foam::conformationSurfaces::conformationSurfaces")
<< "No surface " << surfaceName << " found. "
<< "Valid geometry is " << nl << allGeometry_.names()
<< exit(FatalError);
}
allGeometryToSurfaces_[surfaces_[surfI]] = surfI;
Info<< nl << " " << surfaceName << endl;
const wordList& regionNames =
allGeometry_.regionNames()[surfaces_[surfI]];
patchNames_.append(regionNames);
const dictionary& surfaceSubDict(surfacesDict.subDict(surfaceName));
globalBaffleSurfaces[surfI] = Switch
(
surfaceSubDict.lookupOrDefault("baffleSurface", false)
);
if (!globalBaffleSurfaces[surfI])
{
if (!allGeometry_[surfaces_[surfI]].hasVolumeType())
{
WarningIn("conformationSurfaces::conformationSurfaces(..)")
<< "Non-baffle surface "
<< allGeometry_[surfaces_[surfI]].name()
<< " does not allow inside/outside queries."
<< " This usually is an error." << endl;
}
}
// Load patch info
if (surfaceSubDict.found("patchInfo"))
{
globalPatchInfo.set
(
surfI,
surfaceSubDict.subDict("patchInfo").clone()
);
}
readFeatures(surfaceSubDict, surfaceName, featureI);
if (surfaceSubDict.found("regions"))
{
const dictionary& regionsDict = surfaceSubDict.subDict("regions");
forAll(regionNames, regionI)
{
const word& regionName = regionNames[regionI];
if (regionsDict.found(regionName))
{
Info<< " region " << regionName << endl;
// Get the dictionary for region
const dictionary& regionDict = regionsDict.subDict
(
regionName
);
if (regionDict.found("patchInfo"))
{
regionPatchInfo[surfI].insert
(
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;
}
readFeatures(regionDict, regionName, featureI);
}
}
}
surfI++; surfI++;
} }
// Calculate local to global region offset
label nRegions = 0;
forAll(surfaces_, surfI)
{
regionOffset_[surfI] = nRegions;
nRegions += allGeometry_[surfaces_[surfI]].regions().size();
}
// Rework surface specific information into information per global region
patchInfo_.setSize(nRegions);
baffleSurfaces_.setSize(nRegions, false);
forAll(surfaces_, surfI)
{
label nRegions = allGeometry_[surfaces_[surfI]].regions().size();
// Initialise to global (i.e. per surface)
for (label i = 0; i < nRegions; i++)
{
label globalRegionI = regionOffset_[surfI] + i;
baffleSurfaces_[globalRegionI] = globalBaffleSurfaces[surfI];
if (globalPatchInfo.set(surfI))
{
patchInfo_.set
(
globalRegionI,
globalPatchInfo[surfI].clone()
);
}
}
forAllConstIter(Map<bool>, regionBaffleSurface[surfI], iter)
{
label globalRegionI = regionOffset_[surfI] + iter.key();
baffleSurfaces_[globalRegionI] =
regionBaffleSurface[surfI][iter.key()];
}
const Map<autoPtr<dictionary> >& localInfo = regionPatchInfo[surfI];
forAllConstIter(Map<autoPtr<dictionary> >, localInfo, iter)
{
label globalRegionI = regionOffset_[surfI] + iter.key();
patchInfo_.set(globalRegionI, iter()().clone());
}
}
if (!additionalFeaturesDict.empty()) if (!additionalFeaturesDict.empty())
{ {
Info<< nl << "Reading additionalFeatures" << endl; Info<< nl << "Reading additionalFeatures" << endl;
@ -186,38 +385,7 @@ Foam::conformationSurfaces::conformationSurfaces
additionalFeaturesDict.subDict(featureName) additionalFeaturesDict.subDict(featureName)
); );
word featureMethod = featureSubDict.lookupOrDefault readFeatures(featureSubDict, featureName, featureI);
(
"featureMethod",
word("none")
);
if (featureMethod == "extendedFeatureEdgeMesh")
{
fileName feMeshName
(
featureSubDict.lookup("extendedFeatureEdgeMesh")
);
Info<< " features: " << feMeshName << endl;
features_.set
(
featureI++,
new extendedFeatureEdgeMesh
(
IOobject
(
feMeshName,
runTime_.time().constant(),
"extendedFeatureEdgeMesh",
runTime_.time(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
}
} }
// Remove unnecessary space from the features list // Remove unnecessary space from the features list
@ -251,53 +419,7 @@ Foam::conformationSurfaces::conformationSurfaces
Info<< endl Info<< endl
<< "Testing for locationInMesh " << locationInMesh_ << endl; << "Testing for locationInMesh " << locationInMesh_ << endl;
vector sum = vector::zero; hasBoundedVolume(referenceVolumeTypes_);
label totalTriangles = 0;
forAll(surfaces_, s)
{
const searchableSurface& surface(allGeometry_[surfaces_[s]]);
if (surface.hasVolumeType())
{
pointField pts(1, locationInMesh_);
List<searchableSurface::volumeType> vTypes
(
pts.size(),
searchableSurface::UNKNOWN
);
surface.getVolumeType(pts, vTypes);
referenceVolumeTypes_[s] = vTypes[0];
Info<< " is "
<< searchableSurface::volumeTypeNames[referenceVolumeTypes_[s]]
<< " surface " << surface.name()
<< endl;
}
if (isA<triSurface>(surface))
{
const triSurface& triSurf = refCast<const triSurface>(surface);
const pointField& surfPts = triSurf.points();
forAll(triSurf, sI)
{
sum += triSurf[sI].normal(surfPts);
}
totalTriangles += triSurf.size();
}
}
Info<< " Sum of all the surface normals (if near zero, surface is"
<< " probably closed):" << nl
<< " Sum = " << sum/totalTriangles << nl
<< " mag(Sum) = " << mag(sum)/totalTriangles
<< endl;
} }
@ -867,21 +989,7 @@ Foam::label Foam::conformationSurfaces::findPatch
findSurfaceAnyIntersection(ptA, ptB, surfHit, hitSurface); findSurfaceAnyIntersection(ptA, ptB, surfHit, hitSurface);
if (!surfHit.hit()) return getPatchID(hitSurface, surfHit);
{
return -1;
}
labelList surfLocalRegion;
allGeometry_[hitSurface].getRegion
(
List<pointIndexHit>(1, surfHit),
surfLocalRegion
);
return
surfLocalRegion[0] + patchOffsets_[allGeometryToSurfaces_[hitSurface]];
} }
@ -898,6 +1006,16 @@ Foam::label Foam::conformationSurfaces::findPatch(const point& pt) const
hitSurface hitSurface
); );
return getPatchID(hitSurface, surfHit);
}
Foam::label Foam::conformationSurfaces::getPatchID
(
const label hitSurface,
const pointIndexHit& surfHit
) const
{
if (!surfHit.hit()) if (!surfHit.hit())
{ {
return -1; return -1;
@ -911,8 +1029,28 @@ Foam::label Foam::conformationSurfaces::findPatch(const point& pt) const
surfLocalRegion surfLocalRegion
); );
return const label patchID =
surfLocalRegion[0] + patchOffsets_[allGeometryToSurfaces_[hitSurface]]; surfLocalRegion[0]
+ regionOffset_[allGeometryToSurfaces_[hitSurface]];
return patchID;
}
bool Foam::conformationSurfaces::isBaffle
(
const label hitSurface,
const pointIndexHit& surfHit
) const
{
const label patchID = getPatchID(hitSurface, surfHit);
if (patchID == -1)
{
return false;
}
return baffleSurfaces_[patchID];
} }

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -85,7 +85,10 @@ class conformationSurfaces
//- The offset between the patch indices of the individual surface and //- The offset between the patch indices of the individual surface and
// the entry in the overall patch list // the entry in the overall patch list
labelList patchOffsets_; labelList regionOffset_;
//- From global region number to patchType
PtrList<dictionary> patchInfo_;
//- The overall boundBox of all of the surfaces to be conformed to //- The overall boundBox of all of the surfaces to be conformed to
treeBoundBox globalBounds_; treeBoundBox globalBounds_;
@ -97,6 +100,19 @@ class conformationSurfaces
// Private Member Functions // Private Member Functions
void hasBoundedVolume
(
List<searchableSurface::volumeType>& referenceVolumeTypes
) const;
//- Read into features_ from a dictionary
void readFeatures
(
const dictionary& featureDict,
const word& surfaceName,
label& featureIndex
);
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
conformationSurfaces(const conformationSurfaces&); conformationSurfaces(const conformationSurfaces&);
@ -142,6 +158,9 @@ public:
//- Return the patch names //- Return the patch names
inline const List<word>& patchNames() const; inline const List<word>& patchNames() const;
//- Return the patch info
inline const PtrList<dictionary>& patchInfo() const;
//- Return the global bounds //- Return the global bounds
inline const treeBoundBox& globalBounds() const; inline const treeBoundBox& globalBounds() const;
@ -293,6 +312,13 @@ public:
List<label>& featuresHit List<label>& featuresHit
) const; ) const;
//- Get the region number of a hit surface
label getPatchID
(
const label hitSurface,
const pointIndexHit& surfHit
) const;
//- Find which patch is intersected by the line from one point to //- Find which patch is intersected by the line from one point to
// another // another
label findPatch(const point& ptA, const point& ptB) const; label findPatch(const point& ptA, const point& ptB) const;
@ -300,8 +326,12 @@ public:
//- Find which patch is closest to the point //- Find which patch is closest to the point
label findPatch(const point& pt) const; label findPatch(const point& pt) const;
//- Is the surface a baffle //- Is the surface a baffle.
inline bool isBaffle(const label index) const; bool isBaffle
(
const label hitSurface,
const pointIndexHit& surfHit
) const;
// Write // Write

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -56,16 +56,17 @@ const Foam::List<Foam::word>& Foam::conformationSurfaces::patchNames() const
} }
const Foam::PtrList<Foam::dictionary>&
Foam::conformationSurfaces::patchInfo() const
{
return patchInfo_;
}
const Foam::treeBoundBox& Foam::conformationSurfaces::globalBounds() const const Foam::treeBoundBox& Foam::conformationSurfaces::globalBounds() const
{ {
return globalBounds_; return globalBounds_;
} }
bool Foam::conformationSurfaces::isBaffle(const label index) const
{
return baffleSurfaces_[index];
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -127,7 +127,8 @@ Foam::cvControls::cvControls
defaultCellSize_ = readScalar(motionDict.lookup("defaultCellSize")); defaultCellSize_ = readScalar(motionDict.lookup("defaultCellSize"));
minimumCellSize_ = readScalar(motionDict.lookup("minimumCellSize")); minimumCellSize_ =
readScalar(motionDict.lookup("minimumCellSizeCoeff"))*defaultCellSize_;
objOutput_ = Switch(motionDict.lookupOrDefault<Switch>("objOutput", false)); objOutput_ = Switch(motionDict.lookupOrDefault<Switch>("objOutput", false));