Commit b125db9e authored by laurence's avatar laurence
Browse files

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

parent 2bfe3cef
/*--------------------------------*- 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;
// ************************************************************************* //
......@@ -47,23 +47,23 @@ defineTypeNameAndDebug(cellShapeControl, 0);
Foam::cellShapeControl::cellShapeControl
(
const Time& runTime,
const dictionary& motionDict,
const cvControls& cvMeshControls,
const searchableSurfaces& allGeometry,
const conformationSurfaces& geometryToConformTo
)
:
dictionary(motionDict),
dictionary(cvMeshControls.cvMeshDict().subDict("motionControl")),
runTime_(runTime),
allGeometry_(allGeometry),
geometryToConformTo_(geometryToConformTo),
defaultCellSize_(readScalar(lookup("defaultCellSize"))),
minimumCellSize_(readScalar(lookup("minimumCellSize"))),
defaultCellSize_(cvMeshControls.defaultCellSize()),
minimumCellSize_(cvMeshControls.minimumCellSize()),
shapeControlMesh_(runTime),
aspectRatio_(motionDict),
aspectRatio_(*this),
sizeAndAlignment_
(
runTime,
motionDict.subDict("shapeControlFunctions"),
subDict("shapeControlFunctions"),
geometryToConformTo_,
defaultCellSize_
)
......
......@@ -48,6 +48,7 @@ SourceFiles
#include "cellSizeAndAlignmentControls.H"
#include "cellShapeControlMesh.H"
#include "backgroundMeshDecomposition.H"
#include "cvControls.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -104,7 +105,7 @@ public:
cellShapeControl
(
const Time& runTime,
const dictionary& cellShapeControlDict,
const cvControls& cvMeshControls,
const searchableSurfaces& allGeometry,
const conformationSurfaces& geometryToConformTo
);
......
......@@ -46,10 +46,12 @@ Foam::cellSizeAndAlignmentControl::cellSizeAndAlignmentControl
const Time& runTime,
const word& name,
const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo
const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
)
:
runTime_(runTime),
defaultCellSize_(defaultCellSize),
name_(name)
{}
......@@ -62,7 +64,8 @@ Foam::cellSizeAndAlignmentControl::New
const Time& runTime,
const word& name,
const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo
const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
)
{
word cellSizeAndAlignmentControlTypeName
......@@ -70,7 +73,7 @@ Foam::cellSizeAndAlignmentControl::New
controlFunctionDict.lookup("type")
);
Info<< " Selecting cellSizeAndAlignmentControl "
Info<< indent << "Selecting cellSizeAndAlignmentControl "
<< cellSizeAndAlignmentControlTypeName << endl;
dictionaryConstructorTable::iterator cstrIter =
......@@ -99,7 +102,8 @@ Foam::cellSizeAndAlignmentControl::New
runTime,
name,
controlFunctionDict,
geometryToConformTo
geometryToConformTo,
defaultCellSize
)
);
}
......
......@@ -57,6 +57,8 @@ protected:
const Time& runTime_;
const scalar& defaultCellSize_;
private:
......@@ -91,9 +93,16 @@ public:
const Time& runTime,
const word& name,
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 word& name,
const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo
const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
);
......@@ -118,7 +128,8 @@ public:
const Time& runTime,
const word& name,
const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo
const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
);
......@@ -135,8 +146,6 @@ public:
return name_;
}
virtual label priority() const = 0;
// Query
......
......@@ -63,43 +63,10 @@ bool Foam::cellSizeAndAlignmentControls::evalCellSizeFunctions
if (debug)
{
Info<< "size function "
<< sSC.name()
<< " priority " << sSC.priority()
<< endl;
Info<< "size function " << sSC.name() << endl;
}
if (sSC.priority() < 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();
}
anyFunctionFound = sSC.cellSize(pt, minSize, previousPriority);
}
}
}
......@@ -115,7 +82,7 @@ Foam::cellSizeAndAlignmentControls::cellSizeAndAlignmentControls
const Time& runTime,
const dictionary& shapeControlDict,
const conformationSurfaces& geometryToConformTo,
const scalar defaultCellSize
const scalar& defaultCellSize
)
:
shapeControlDict_(shapeControlDict),
......@@ -135,6 +102,7 @@ Foam::cellSizeAndAlignmentControls::cellSizeAndAlignmentControls
);
Info<< nl << "Shape Control : " << shapeControlEntryName << endl;
Info<< incrIndent;
controlFunctions_.set
(
......@@ -144,10 +112,13 @@ Foam::cellSizeAndAlignmentControls::cellSizeAndAlignmentControls
runTime,
shapeControlEntryName,
controlFunctionDict,
geometryToConformTo
geometryToConformTo_,
defaultCellSize_
)
);
Info<< decrIndent;
functionI++;
}
}
......
......@@ -56,7 +56,7 @@ class cellSizeAndAlignmentControls
PtrList<cellSizeAndAlignmentControl> controlFunctions_;
const scalar defaultCellSize_;
const scalar& defaultCellSize_;
// Private Member Functions
......@@ -84,7 +84,7 @@ public:
const Time& runTime,
const dictionary& shapeControlDict,
const conformationSurfaces& geometryToConformTo,
const scalar defaultCellSize
const scalar& defaultCellSize
);
......
......@@ -58,7 +58,8 @@ Foam::fileControl::fileControl
const Time& runTime,
const word& name,
const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo
const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
)
:
cellSizeAndAlignmentControl
......@@ -66,14 +67,14 @@ Foam::fileControl::fileControl
runTime,
name,
controlFunctionDict,
geometryToConformTo
geometryToConformTo,
defaultCellSize
),
pointsFile_(controlFunctionDict.lookup("pointsFile")),
sizesFile_(controlFunctionDict.lookup("sizesFile")),
alignmentsFile_(controlFunctionDict.lookup("alignmentsFile")),
priority_(readLabel(controlFunctionDict.lookup("priority")))
alignmentsFile_(controlFunctionDict.lookup("alignmentsFile"))
{
Info<< indent << "Loading from file... " << nl
Info<< indent << "Loading " << name << " from file:" << nl
<< indent << " points : " << pointsFile_ << nl
<< indent << " sizes : " << sizesFile_ << nl
<< indent << " alignments : " << alignmentsFile_
......
......@@ -58,8 +58,6 @@ class fileControl
const fileName alignmentsFile_;
label priority_;
// Private Member Functions
......@@ -85,7 +83,8 @@ public:
const Time& runTime,
const word& name,
const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo
const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
);
//- Destructor
......@@ -121,11 +120,6 @@ public:
scalarField& sizes,
triadField& alignments
) const;
virtual label priority() const
{
return priority_;
}
};
......
......@@ -158,7 +158,8 @@ Foam::searchableSurfaceControl::searchableSurfaceControl
const Time& runTime,
const word& name,
const dictionary& controlFunctionDict,
const conformationSurfaces& geometryToConformTo
const conformationSurfaces& geometryToConformTo,
const scalar& defaultCellSize
)
:
cellSizeAndAlignmentControl
......@@ -166,174 +167,91 @@ Foam::searchableSurfaceControl::searchableSurfaceControl
runTime,
name,
controlFunctionDict,
geometryToConformTo
geometryToConformTo,
defaultCellSize
),
surfaceName_(controlFunctionDict.lookupOrDefault<word>("surface", name)),
searchableSurface_(geometryToConformTo.geometry()[surfaceName_]),
geometryToConformTo_(geometryToConformTo),
cellSizeFunction_
(
cellSizeFunction::New(controlFunctionDict, searchableSurface_)
)
// geometryToConformTo_(geometryToConformTo),
// surfaces_(),
// cellSizeFunctions_(),
// triangulatedMesh_()
cellSizeFunctions_(1),
maxPriority_(-1)
{
// const dictionary& surfacesDict = coeffDict();
//
// Info<< nl << "Reading cellSizeControlGeometry" << endl;
//
// surfaces_.setSize(surfacesDict.size());
//
// cellSizeFunctions_.setSize(surfacesDict.size());
//
// label surfI = 0;
//
// DynamicList<point> pointsToInsert;
// DynamicList<scalar> sizesToInsert;
// DynamicList<tensor> alignmentsToInsert;
//
// forAllConstIter(dictionary, surfacesDict, iter)
// {
// const dictionary& surfaceSubDict
// (
// surfacesDict.subDict(iter().keyword())
// );
//
// // If the "surface" keyword is not found in the dictionary, assume
// // the name of the dictionary is the surface. Distinction required to
// // allow the same surface to be used multiple times to supply multiple
// // cellSizeFunctions
//
// word surfaceName = surfaceSubDict.lookupOrDefault<word>
// (
// "surface",
// iter().keyword()
// );
//
// surfaces_[surfI] = allGeometry_.findSurfaceID(surfaceName);
//
// if (surfaces_[surfI] < 0)
// {
// FatalErrorIn
// (
// "Foam::surfaceControl::surfaceControl"
// ) << "No surface " << surfaceName << " found. "
// << "Valid geometry is " << nl << allGeometry_.names()
// << exit(FatalError);
// }
//
// const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
//
// Info<< nl << " " << iter().keyword() << nl
// << " surface: " << surfaceName << nl
// << " size : " << surface.size() << endl;
//
// cellSizeFunctions_.set
// (
// surfI,
// cellSizeFunction::New
// (
// surfaceSubDict,
// surface
// )
// );
//
// surfI++;
//
// if (isA<triSurfaceMesh>(surface))
// {
// const triSurfaceMesh& tsm
// = refCast<const triSurfaceMesh>(surface);
//
// const pointField& points = tsm.points();
// const vectorField& faceNormals = tsm.faceNormals();
// const labelListList& pointFaces = tsm.pointFaces();
//
// Info<< " Number of points: " << tsm.nPoints() << endl;
//
// forAll(points, pI)
// {
// 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_
// );
//