Merge branch 'cvMesh-automaticCellSize'

This commit is contained in:
laurence
2012-03-16 11:27:56 +00:00
91 changed files with 3298 additions and 513 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,6 +42,8 @@ using namespace Foam;
int main(int argc, char *argv[])
{
timeSelector::addOptions();
# include "addOverwriteOption.H"
# include "setRootCase.H"
@ -49,7 +51,7 @@ int main(int argc, char *argv[])
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"
# include "createNamedPolyMesh.H"
runTime.functionObjects().off();
@ -57,14 +59,11 @@ int main(int argc, char *argv[])
{
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Create mesh for time = " << runTime.timeName()
Info<< "Time = " << runTime.timeName()
<< nl << endl;
mesh.readUpdate();
Info<< "Read mesh in = "
<< runTime.cpuTimeIncrement() << " s" << endl;
// Check patches and faceZones are synchronised
mesh.boundaryMesh().checkParallelSync(true);
meshRefinement::checkCoupledFaceZones(mesh);
@ -87,8 +86,10 @@ int main(int argc, char *argv[])
= cvMeshDict.subDict("meshQualityControls");
Info<< "Checking initial mesh ..." << endl;
Info<< "Checking mesh ..." << endl;
faceSet wrongFaces(mesh, "wrongFaces", mesh.nFaces()/100);
motionSmoother::checkMesh(false, mesh, meshQualityDict, wrongFaces);
const label nInitErrors = returnReduce
@ -117,6 +118,5 @@ int main(int argc, char *argv[])
Info<< "End\n" << endl;
return 0;
}

View File

@ -15,13 +15,23 @@ backgroundMeshDecomposition/backgroundMeshDecomposition.C
cellSizeControlSurfaces/cellSizeControlSurfaces.C
cellSiseFunctions = cellSizeControlSurfaces/cellSizeFunction
$(cellSiseFunctions)/cellSizeFunction/cellSizeFunction.C
$(cellSiseFunctions)/uniform/uniform.C
$(cellSiseFunctions)/uniformDistance/uniformDistance.C
$(cellSiseFunctions)/linearDistance/linearDistance.C
$(cellSiseFunctions)/surfaceOffsetLinearDistance/surfaceOffsetLinearDistance.C
$(cellSiseFunctions)/linearSpatial/linearSpatial.C
cellSizeFunctions = cellSizeControlSurfaces/cellSizeFunction
$(cellSizeFunctions)/cellSizeFunction/cellSizeFunction.C
$(cellSizeFunctions)/uniform/uniform.C
$(cellSizeFunctions)/uniformDistance/uniformDistance.C
$(cellSizeFunctions)/linearDistance/linearDistance.C
$(cellSizeFunctions)/surfaceOffsetLinearDistance/surfaceOffsetLinearDistance.C
$(cellSizeFunctions)/linearSpatial/linearSpatial.C
surfaceCellSizeFunctions = cellSizeControlSurfaces/surfaceCellSizeFunction
$(surfaceCellSizeFunctions)/surfaceCellSizeFunction/surfaceCellSizeFunction.C
$(surfaceCellSizeFunctions)/uniformValue/uniformValue.C
$(surfaceCellSizeFunctions)/nonUniformField/nonUniformField.C
cellSizeCalculationType = $(surfaceCellSizeFunctions)/cellSizeCalculationType
$(cellSizeCalculationType)/cellSizeCalculationType/cellSizeCalculationType.C
$(cellSizeCalculationType)/fieldFromFile/fieldFromFile.C
$(cellSizeCalculationType)/automatic/automatic.C
initialPointsMethod/initialPointsMethod/initialPointsMethod.C
initialPointsMethod/uniformGrid/uniformGrid.C

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -337,5 +337,21 @@ Foam::scalarField Foam::cellSizeControlSurfaces::cellSize
}
void Foam::cellSizeControlSurfaces::setCellSizes
(
const pointField& pts
)
{
if (cellSizeFunctions_.size())
{
forAll(cellSizeFunctions_, i)
{
cellSizeFunction& cSF = cellSizeFunctions_[i];
cSF.setCellSize(pts);
}
}
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -133,6 +133,11 @@ public:
//- Return the cell size at the given locations
scalarField cellSize(const pointField& pts) const;
// Edit
//- Set the cell sizes for each point
void setCellSizes(const pointField& pts);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,18 +30,15 @@ License
namespace Foam
{
defineTypeNameAndDebug(cellSizeFunction, 0);
defineRunTimeSelectionTable(cellSizeFunction, dictionary);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(cellSizeFunction, 0);
defineRunTimeSelectionTable(cellSizeFunction, dictionary);
scalar cellSizeFunction::snapToSurfaceTol_ = 1e-10;
scalar cellSizeFunction::snapToSurfaceTol_ = 1e-10;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
cellSizeFunction::cellSizeFunction
Foam::cellSizeFunction::cellSizeFunction
(
const word& type,
const dictionary& cellSizeFunctionDict,
@ -50,6 +47,14 @@ cellSizeFunction::cellSizeFunction
:
dictionary(cellSizeFunctionDict),
surface_(surface),
surfaceCellSizeFunction_
(
surfaceCellSizeFunction::New
(
cellSizeFunctionDict,
surface
)
),
coeffsDict_(subDict(type + "Coeffs")),
sideMode_(),
priority_(readLabel(cellSizeFunctionDict.lookup("priority")))
@ -94,7 +99,7 @@ cellSizeFunction::cellSizeFunction
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
autoPtr<cellSizeFunction> cellSizeFunction::New
Foam::autoPtr<Foam::cellSizeFunction> Foam::cellSizeFunction::New
(
const dictionary& cellSizeFunctionDict,
const searchableSurface& surface
@ -134,12 +139,8 @@ autoPtr<cellSizeFunction> cellSizeFunction::New
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
cellSizeFunction::~cellSizeFunction()
Foam::cellSizeFunction::~cellSizeFunction()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -41,6 +41,7 @@ SourceFiles
#include "dictionary.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "surfaceCellSizeFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -85,6 +86,11 @@ protected:
// relates to
const searchableSurface& surface_;
//- Cell size at the surface
scalarField surfaceCellSize_;
autoPtr<surfaceCellSizeFunction> surfaceCellSizeFunction_;
//- Method details dictionary
dictionary coeffsDict_;
@ -170,6 +176,18 @@ public:
const point& pt,
scalar& size
) const = 0;
virtual bool setCellSize
(
const pointField& pts
)
{
WarningIn("cellSizeFunction::setCellSize(const pointField&)")
<< "Not overloaded."
<< endl;
return false;
}
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,6 +25,8 @@ License
#include "linearDistance.H"
#include "addToRunTimeSelectionTable.H"
#include "triSurfaceMesh.H"
#include "triSurfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -46,29 +48,37 @@ linearDistance::linearDistance
)
:
cellSizeFunction(typeName, initialPointsDict, surface),
surfaceCellSize_(readScalar(coeffsDict().lookup("surfaceCellSize"))),
distanceCellSize_(readScalar(coeffsDict().lookup("distanceCellSize"))),
distance_(readScalar(coeffsDict().lookup("distance"))),
distanceSqr_(sqr(distance_)),
gradient_((distanceCellSize_ - surfaceCellSize_)/distance_)
distanceSqr_(sqr(distance_))
{}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
scalar linearDistance::sizeFunction(scalar d) const
scalar linearDistance::sizeFunction
(
const point& pt,
scalar d,
label index
) const
{
return gradient_*d + surfaceCellSize_;
const scalar interpolatedSize
= surfaceCellSizeFunction_().interpolate(pt, index);
scalar gradient
= (distanceCellSize_ - interpolatedSize)
/distance_;
scalar size = gradient*d + interpolatedSize;
return size;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool linearDistance::cellSize
(
const point& pt,
scalar& size
) const
bool linearDistance::cellSize(const point& pt, scalar& size) const
{
size = 0;
@ -85,18 +95,23 @@ bool linearDistance::cellSize
if (hitInfo.hit())
{
const point& hitPt = hitInfo.hitPoint();
const label hitIndex = hitInfo.index();
const scalar dist = mag(pt - hitPt);
if (sideMode_ == rmBothsides)
{
size = sizeFunction(mag(pt - hitInfo.hitPoint()));
size = sizeFunction(hitPt, dist, hitIndex);
return true;
}
// If the nearest point is essentially on the surface, do not do a
// getVolumeType calculation, as it will be prone to error.
if (mag(pt - hitInfo.hitPoint()) < snapToSurfaceTol_)
if (dist < snapToSurfaceTol_)
{
size = sizeFunction(0);
size = sizeFunction(hitPt, 0, hitIndex);
return true;
}
@ -114,7 +129,7 @@ bool linearDistance::cellSize
&& vTL[0] == searchableSurface::INSIDE
)
{
size = sizeFunction(mag(pt - hitInfo.hitPoint()));
size = sizeFunction(hitPt, dist, hitIndex);
functionApplied = true;
}
@ -124,7 +139,7 @@ bool linearDistance::cellSize
&& vTL[0] == searchableSurface::OUTSIDE
)
{
size = sizeFunction(mag(pt - hitInfo.hitPoint()));
size = sizeFunction(hitPt, dist, hitIndex);
functionApplied = true;
}
@ -136,6 +151,48 @@ bool linearDistance::cellSize
}
bool linearDistance::setCellSize(const pointField& pts)
{
labelHashSet surfaceAlreadyHit(surfaceCellSize_.size());
forAll(pts, ptI)
{
const Foam::point& pt = pts[ptI];
List<pointIndexHit> hits;
surface_.findNearest
(
pointField(1, pt),
scalarField(1, distanceSqr_),
hits
);
const label surfHitI = hits[0].index();
if
(
hits[0].hit()
&& !surfaceAlreadyHit.found(surfHitI)
)
{
// Halving cell size is arbitrary
surfaceCellSizeFunction_().refineSurfaceSize(surfHitI);
surfaceAlreadyHit.insert(surfHitI);
}
}
// Force recalculation of the interpolation
if (!pts.empty())
{
surfaceCellSizeFunction_().recalculateInterpolation();
}
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,9 +54,6 @@ private:
// Private data
//- cell size at the surface
scalar surfaceCellSize_;
//- cell size at distance_ from the surface
scalar distanceCellSize_;
@ -66,14 +63,11 @@ private:
//- distance squared
scalar distanceSqr_;
//- storing gradient for linear function
scalar gradient_;
// Private Member Functions
//- Calculate the cell size as a function of the given distance
scalar sizeFunction(scalar d) const;
scalar sizeFunction(const point& pt, scalar d, label index) const;
public:
@ -107,6 +101,12 @@ public:
const point& pt,
scalar& size
) const;
//- Adapt local cell size. Return true if anything changed.
virtual bool setCellSize
(
const pointField& pts
);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -50,13 +50,10 @@ surfaceOffsetLinearDistance::surfaceOffsetLinearDistance
)
:
cellSizeFunction(typeName, initialPointsDict, surface),
surfaceCellSize_(readScalar(coeffsDict().lookup("surfaceCellSize"))),
distanceCellSize_(readScalar(coeffsDict().lookup("distanceCellSize"))),
surfaceOffset_(readScalar(coeffsDict().lookup("surfaceOffset"))),
totalDistance_(),
totalDistanceSqr_(),
gradient_(),
intercept_()
totalDistanceSqr_()
{
if
(
@ -111,25 +108,33 @@ surfaceOffsetLinearDistance::surfaceOffsetLinearDistance
}
totalDistanceSqr_ = sqr(totalDistance_);
gradient_ =
(distanceCellSize_ - surfaceCellSize_)
/(totalDistance_ - surfaceOffset_);
intercept_ = surfaceCellSize_ - gradient_*surfaceOffset_;
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
scalar surfaceOffsetLinearDistance::sizeFunction(scalar d) const
scalar surfaceOffsetLinearDistance::sizeFunction
(
const point& pt,
scalar d,
label index
) const
{
const scalar interpolatedSize
= surfaceCellSizeFunction_().interpolate(pt, index);
if (d <= surfaceOffset_)
{
return surfaceCellSize_;
return interpolatedSize;
}
return gradient_*d + intercept_;
scalar gradient =
(distanceCellSize_ - interpolatedSize)
/(totalDistance_ - surfaceOffset_);
scalar intercept = interpolatedSize - gradient*surfaceOffset_;
return gradient*d + intercept;
}
@ -156,9 +161,14 @@ bool surfaceOffsetLinearDistance::cellSize
if (hitInfo.hit())
{
const point& hitPt = hitInfo.hitPoint();
const label hitIndex = hitInfo.index();
const scalar dist = mag(pt - hitPt);
if (sideMode_ == rmBothsides)
{
size = sizeFunction(mag(pt - hitInfo.hitPoint()));
size = sizeFunction(hitPt, dist, hitIndex);
return true;
}
@ -167,7 +177,7 @@ bool surfaceOffsetLinearDistance::cellSize
// getVolumeType calculation, as it will be prone to error.
if (mag(pt - hitInfo.hitPoint()) < snapToSurfaceTol_)
{
size = sizeFunction(0);
size = sizeFunction(hitPt, 0, hitIndex);
return true;
}
@ -185,7 +195,7 @@ bool surfaceOffsetLinearDistance::cellSize
&& vTL[0] == searchableSurface::INSIDE
)
{
size = sizeFunction(mag(pt - hitInfo.hitPoint()));
size = sizeFunction(hitPt, dist, hitIndex);
functionApplied = true;
}
@ -195,7 +205,7 @@ bool surfaceOffsetLinearDistance::cellSize
&& vTL[0] == searchableSurface::OUTSIDE
)
{
size = sizeFunction(mag(pt - hitInfo.hitPoint()));
size = sizeFunction(hitPt, dist, hitIndex);
functionApplied = true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,9 +54,6 @@ private:
// Private data
//- cell size at the surface
scalar surfaceCellSize_;
//- cell size at distance_ from the surface
scalar distanceCellSize_;
@ -70,17 +67,11 @@ private:
//- totalDistance squared
scalar totalDistanceSqr_;
//- storing gradient for linear function
scalar gradient_;
//- storing intercept for linear function
scalar intercept_;
// Private Member Functions
//- Calculate the cell size as a function of the given distance
scalar sizeFunction(scalar d) const;
scalar sizeFunction(const point& pt, scalar d, label index) const;
public:

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -44,8 +44,7 @@ uniform::uniform
const searchableSurface& surface
)
:
cellSizeFunction(typeName, initialPointsDict, surface),
cellSize_(readScalar(coeffsDict().lookup("cellSize")))
cellSizeFunction(typeName, initialPointsDict, surface)
{}
@ -57,64 +56,115 @@ bool uniform::cellSize
scalar& size
) const
{
if (sideMode_ == rmBothsides)
{
size = cellSize_;
return true;
}
size = 0;
List<pointIndexHit> hits;
surface_.findNearest
(
pointField(1, pt),
scalarField(1, sqr(snapToSurfaceTol_)),
scalarField(1, sqr(GREAT)),
hits
);
const pointIndexHit& hitInfo = hits[0];
// If the nearest point is essentially on the surface, do not do a
// getVolumeType calculation, as it will be prone to error.
if (hitInfo.hit())
{
size = cellSize_;
const point& hitPt = hitInfo.hitPoint();
const label index = hitInfo.index();
return true;
if (sideMode_ == rmBothsides)
{
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
return true;
}
size = 0;
List<pointIndexHit> closeToSurfaceHits;
surface_.findNearest
(
pointField(1, pt),
scalarField(1, sqr(snapToSurfaceTol_)),
closeToSurfaceHits
);
const pointIndexHit& closeToSurface = closeToSurfaceHits[0];
// If the nearest point is essentially on the surface, do not do a
// getVolumeType calculation, as it will be prone to error.
if (closeToSurface.hit())
{
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
return true;
}
pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL(1);
surface_.getVolumeType(ptF, vTL);
bool functionApplied = false;
if
(
sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE
)
{
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
functionApplied = true;
}
else if
(
sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE
)
{
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
functionApplied = true;
}
return functionApplied;
}
pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL(1);
return false;
}
surface_.getVolumeType(ptF, vTL);
bool functionApplied = false;
bool uniform::setCellSize
(
const pointField& pts
)
{
// labelHashSet surfaceAlreadyHit(cellSize_.size());
//
// forAll(pts, ptI)
// {
// const Foam::point& pt = pts[ptI];
//
// List<pointIndexHit> hits;
//
// surface_.findNearest
// (
// pointField(1, pt),
// scalarField(1, sqr(GREAT)),
// hits
// );
//
// if (hits[0].hit() && !surfaceAlreadyHit.found(hits[0].index()))
// {
// surfaceCellSizeFunction_().refineCellSize(hits[0].index());
//
// surfaceAlreadyHit.insert(hits[0].index());
// }
// }
if
(
sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE
)
{
size = cellSize_;
functionApplied = true;
}
else if
(
sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE
)
{
size = cellSize_;
functionApplied = true;
}
return functionApplied;
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,9 +54,6 @@ private:
// Private data
//- Cell size
scalar cellSize_;
public:
@ -89,6 +86,12 @@ public:
const point& pt,
scalar& size
) const;
//- Adapt local cell size. Return true if anything changed.
virtual bool setCellSize
(
const pointField& pts
);
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,6 +25,7 @@ License
#include "uniformDistance.H"
#include "addToRunTimeSelectionTable.H"
#include "dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -45,7 +46,6 @@ uniformDistance::uniformDistance
)
:
cellSizeFunction(typeName, initialPointsDict, surface),
cellSize_(readScalar(coeffsDict().lookup("cellSize"))),
distance_(readScalar(coeffsDict().lookup("distance"))),
distanceSqr_(sqr(distance_))
{}
@ -76,7 +76,7 @@ bool uniformDistance::cellSize
{
if (sideMode_ == rmBothsides)
{
size = cellSize_;
size = surfaceCellSizeFunction_().surfaceSize(hitInfo.index());
return true;
}
@ -85,7 +85,7 @@ bool uniformDistance::cellSize
// getVolumeType calculation, as it will be prone to error.
if (mag(pt - hitInfo.hitPoint()) < snapToSurfaceTol_)
{
size = cellSize_;
size = surfaceCellSizeFunction_().surfaceSize(hitInfo.index());
return true;
}
@ -103,7 +103,7 @@ bool uniformDistance::cellSize
&& vTL[0] == searchableSurface::INSIDE
)
{
size = cellSize_;
size = surfaceCellSizeFunction_().surfaceSize(hitInfo.index());
functionApplied = true;
}
@ -113,7 +113,7 @@ bool uniformDistance::cellSize
&& vTL[0] == searchableSurface::OUTSIDE
)
{
size = cellSize_;
size = surfaceCellSizeFunction_().surfaceSize(hitInfo.index());
functionApplied = true;
}
@ -125,6 +125,38 @@ bool uniformDistance::cellSize
}
bool uniformDistance::setCellSize
(
const pointField& pts
)
{
labelHashSet surfaceAlreadyHit(surface_.size());
forAll(pts, ptI)
{
const Foam::point& pt = pts[ptI];
List<pointIndexHit> hits;
surface_.findNearest
(
pointField(1, pt),
scalarField(1, distanceSqr_),
hits
);
if (hits[0].hit() && !surfaceAlreadyHit.found(hits[0].index()))
{
surfaceCellSizeFunction_().refineSurfaceSize(hits[0].index());
surfaceAlreadyHit.insert(hits[0].index());
}
}
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,9 +54,6 @@ private:
// Private data
//- Cell size
scalar cellSize_;
//- Distance
scalar distance_;
@ -95,6 +92,12 @@ public:
const point& pt,
scalar& size
) const;
//- Adapt local cell size. Return true if anything changed.
virtual bool setCellSize
(
const pointField& pts
);
};

View File

@ -0,0 +1,213 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "automatic.H"
#include "addToRunTimeSelectionTable.H"
#include "triSurfaceMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(automatic, 0);
addToRunTimeSelectionTable(cellSizeCalculationType, automatic, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::automatic::automatic
(
const dictionary& cellSizeCalcTypeDict,
const triSurfaceMesh& surface
)
:
cellSizeCalculationType(typeName, cellSizeCalcTypeDict, surface),
coeffsDict_(cellSizeCalcTypeDict.subDict(typeName + "Coeffs")),
surface_(surface),
surfaceName_(surface.searchableSurface::name()),
readCurvature_(Switch(coeffsDict_.lookup("curvature"))),
curvatureFile_(coeffsDict_.lookup("curvatureFile")),
readFeatureProximity_(Switch(coeffsDict_.lookup("featureProximity"))),
featureProximityFile_(coeffsDict_.lookup("featureProximityFile")),
readInternalCloseness_(Switch(coeffsDict_.lookup("internalCloseness"))),
internalClosenessFile_(coeffsDict_.lookup("internalClosenessFile")),
curvatureCellSizeFactor_
(
readScalar(coeffsDict_.lookup("curvatureCellSizeFactor"))
),
maximumCellSize_
(
readScalar(coeffsDict_.lookup("maximumCellSize"))
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::triSurfaceScalarField Foam::automatic::load()
{
Info<< indent << "Calculating cell size on surface: "
<< surfaceName_ << endl;
triSurfaceScalarField surfaceCellSize
(
IOobject
(
surfaceName_ + ".cellSize",
surface_.searchableSurface::time().constant(),
"triSurface",
surface_.searchableSurface::time(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
surface_,
dimLength,
scalarField(surface_.size(), maximumCellSize_)
);
if (readCurvature_)
{
Info<< indent << "Reading curvature: " << curvatureFile_ << endl;
triSurfacePointScalarField curvature
(
IOobject
(
curvatureFile_,
surface_.searchableSurface::time().constant(),
"triSurface",
surface_.searchableSurface::time(),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
surface_,
dimLength,
true
);
const List<labelledTri>& localFaces = surface_.localFaces();
const labelList& meshPoints = surface_.meshPoints();
forAll(surfaceCellSize, fI)
{
const labelList& facePoints = localFaces[fI].triFaceFace();
scalar interpolatedCurvatureToFace = 0.0;
forAll(facePoints, fpI)
{
interpolatedCurvatureToFace
+= curvature[meshPoints[facePoints[fpI]]];
}
interpolatedCurvatureToFace /= facePoints.size();
surfaceCellSize[fI] =
min
(
1.0
/max
(
(1.0/curvatureCellSizeFactor_)
*interpolatedCurvatureToFace,
1.0/maximumCellSize_
),
surfaceCellSize[fI]
);
}
}
if (readInternalCloseness_)
{
Info<< indent << "Reading internal closeness: "
<< internalClosenessFile_ << endl;
triSurfaceScalarField internalCloseness
(
IOobject
(
internalClosenessFile_,
surface_.searchableSurface::time().constant(),
"triSurface",
surface_.searchableSurface::time(),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
surface_,
dimLength,
true
);
forAll(surfaceCellSize, fI)
{
surfaceCellSize[fI] =
min
(
internalCloseness[fI],
surfaceCellSize[fI]
);
}
}
if (readFeatureProximity_)
{
Info<< indent << "Reading feature proximity: "
<< featureProximityFile_ << endl;
triSurfaceScalarField featureProximity
(
IOobject
(
featureProximityFile_,
surface_.searchableSurface::time().constant(),
"triSurface",
surface_.searchableSurface::time(),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
surface_,
dimLength,
true
);
forAll(surfaceCellSize, fI)
{
surfaceCellSize[fI] =
min
(
featureProximity[fI],
surfaceCellSize[fI]
);
}
}
surfaceCellSize.write();
return surfaceCellSize;
}
// ************************************************************************* //

View File

@ -0,0 +1,124 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::automatic
Description
SourceFiles
automatic.C
\*---------------------------------------------------------------------------*/
#ifndef automatic_H
#define automatic_H
#include "cellSizeCalculationType.H"
#include "triSurfaceFields.H"
#include "PrimitivePatchInterpolation.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class triSurfaceMesh;
/*---------------------------------------------------------------------------*\
Class automatic Declaration
\*---------------------------------------------------------------------------*/
class automatic
:
public cellSizeCalculationType
{
private:
// Private data
//- Dictionary of coefficients for automatic cell sizing
const dictionary& coeffsDict_;
//- Reference to the triSurfaceMesh
const triSurfaceMesh& surface_;
//- Name of the surface. Used to write the cell size field
const word surfaceName_;
const Switch readCurvature_;
const word curvatureFile_;
const Switch readFeatureProximity_;
const word featureProximityFile_;
const Switch readInternalCloseness_;
const word internalClosenessFile_;
//- The curvature values are multiplied by the inverse of this value to
// get the cell size
const scalar curvatureCellSizeFactor_;
//- The maximum allowable sell size
const scalar maximumCellSize_;
public:
//- Runtime type information
TypeName("automatic");
// Constructors
//- Construct from components
automatic
(
const dictionary& cellSizeCalcTypeDict,
const triSurfaceMesh& surface
);
//- Destructor
virtual ~automatic()
{}
// Member Functions
//- Load the cell size field
virtual triSurfaceScalarField load();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,97 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "cellSizeCalculationType.H"
#include "addToRunTimeSelectionTable.H"
#include "triSurfaceMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cellSizeCalculationType, 0);
defineRunTimeSelectionTable(cellSizeCalculationType, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cellSizeCalculationType::cellSizeCalculationType
(
const word& type,
const dictionary& cellSizeCalculationTypeDict,
const triSurfaceMesh& surface
)
:
cellSizeCalculationTypeDict_(cellSizeCalculationTypeDict)
{}
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::cellSizeCalculationType> Foam::cellSizeCalculationType::New
(
const dictionary& cellSizeCalculationTypeDict,
const triSurfaceMesh& surface
)
{
word cellSizeCalculationTypeTypeName
(
cellSizeCalculationTypeDict.lookup("cellSizeCalculationType")
);
Info<< " Selecting cellSizeCalculationType "
<< cellSizeCalculationTypeTypeName << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(cellSizeCalculationTypeTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"cellSizeCalculationType::New(dictionary&, "
"const conformalVoronoiMesh&, const searchableSurface&)"
) << "Unknown cellSizeCalculationType type "
<< cellSizeCalculationTypeTypeName
<< endl << endl
<< "Valid cellSizeCalculationType types are :" << endl
<< dictionaryConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<cellSizeCalculationType>
(
cstrIter()(cellSizeCalculationTypeDict, surface)
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cellSizeCalculationType::~cellSizeCalculationType()
{}
// ************************************************************************* //

View File

@ -0,0 +1,134 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::cellSizeCalculationType
Description
Abstract base class for specifying target cell sizes
SourceFiles
cellSizeCalculationType.C
\*---------------------------------------------------------------------------*/
#ifndef cellSizeCalculationType_H
#define cellSizeCalculationType_H
#include "searchableSurface.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "triSurfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class triSurfaceMesh;
/*---------------------------------------------------------------------------*\
Class cellSizeCalculationType Declaration
\*---------------------------------------------------------------------------*/
class cellSizeCalculationType
{
protected:
const dictionary& cellSizeCalculationTypeDict_;
private:
// Private Member Functions
//- Disallow default bitwise copy construct
cellSizeCalculationType(const cellSizeCalculationType&);
//- Disallow default bitwise assignment
void operator=(const cellSizeCalculationType&);
public:
//- Runtime type information
TypeName("cellSizeCalculationType");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
cellSizeCalculationType,
dictionary,
(
const dictionary& cellSizeCalculationTypeDict,
const triSurfaceMesh& surface
),
(cellSizeCalculationTypeDict, surface)
);
// Constructors
//- Construct from components
cellSizeCalculationType
(
const word& type,
const dictionary& cellSizeCalculationTypeDict,
const triSurfaceMesh& surface
);
// Selectors
//- Return a reference to the selected cellSizeCalculationType
static autoPtr<cellSizeCalculationType> New
(
const dictionary& cellSizeCalculationTypeDict,
const triSurfaceMesh& surface
);
//- Destructor
virtual ~cellSizeCalculationType();
// Member Functions
//- Load the cell size
virtual triSurfaceScalarField load() = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,88 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "fieldFromFile.H"
#include "addToRunTimeSelectionTable.H"
#include "triSurfaceMesh.H"
#include "triSurfaceFields.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(fieldFromFile, 0);
addToRunTimeSelectionTable
(
cellSizeCalculationType,
fieldFromFile,
dictionary
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldFromFile::fieldFromFile
(
const dictionary& cellSizeCalcTypeDict,
const triSurfaceMesh& surface
)
:
cellSizeCalculationType(typeName, cellSizeCalcTypeDict, surface),
surface_(surface),
fileName_
(
cellSizeCalcTypeDict.subDict(typeName + "Coeffs").lookup("fieldFile")
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::triSurfaceScalarField Foam::fieldFromFile::load()
{
Info<< "Loading: " << fileName_ << endl;
triSurfaceScalarField surfaceCellSize
(
IOobject
(
fileName_,
surface_.searchableSurface::time().constant(),
"triSurface",
surface_.searchableSurface::time(),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
surface_,
dimLength,
true
);
return surfaceCellSize;
}
// ************************************************************************* //

View File

@ -0,0 +1,105 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fieldFromFile
Description
SourceFiles
fieldFromFile.C
\*---------------------------------------------------------------------------*/
#ifndef fieldFromFile_H
#define fieldFromFile_H
#include "cellSizeCalculationType.H"
#include "triSurfaceFields.H"
#include "PrimitivePatchInterpolation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class triSurfaceMesh;
/*---------------------------------------------------------------------------*\
Class fieldFromFile Declaration
\*---------------------------------------------------------------------------*/
class fieldFromFile
:
public cellSizeCalculationType
{
private:
// Private data
//- Reference to the triSurfaceMesh
const triSurfaceMesh& surface_;
//- Name of the triSurfaceScalarField file to load in. Must be in
// constant/triSurface
const word fileName_;
public:
//- Runtime type information
TypeName("fieldFromFile");
// Constructors
//- Construct from components
fieldFromFile
(
const dictionary& cellSizeCalcTypeDict,
const triSurfaceMesh& surface
);
//- Destructor
virtual ~fieldFromFile()
{}
// Member Functions
//- Load the cell size field
virtual triSurfaceScalarField load();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,167 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "nonUniformField.H"
#include "triSurfaceMesh.H"
#include "searchableSurface.H"
#include "addToRunTimeSelectionTable.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(nonUniformField, 0);
addToRunTimeSelectionTable
(
surfaceCellSizeFunction,
nonUniformField,
dictionary
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::nonUniformField::nonUniformField
(
const dictionary& cellSizeFunctionDict,
const searchableSurface& surface
)
:
surfaceCellSizeFunction(typeName, cellSizeFunctionDict, surface),
surfaceTriMesh_(refCast<const triSurfaceMesh>(surface)),
surfaceCellSize_
(
IOobject
(
"surfaceCellSize.cellSize",
surface.time().constant(),
"triSurface",
surface.time(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
surfaceTriMesh_,
dimLength,
false
),
cellSizeCalculationType_
(
cellSizeCalculationType::New(coeffsDict(), surfaceTriMesh_)
),
pointCellSize_(),
patch_()
{
Info<< incrIndent << incrIndent;
surfaceCellSize_ = cellSizeCalculationType_().load();
Info<< decrIndent;
Info<< indent << "Cell size field statistics:" << nl
<< indent << " Minimum: " << min(surfaceCellSize_).value() << nl
<< indent << " Average: " << average(surfaceCellSize_).value() << nl
<< indent << " Maximum: " << max(surfaceCellSize_).value() << endl;
Info<< decrIndent;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::scalar& Foam::nonUniformField::surfaceSize(const label index) const
{
return surfaceCellSize_[index];
}
const Foam::scalar& Foam::nonUniformField::refineSurfaceSize(const label index)
{
surfaceCellSize_[index] *= refinementFactor_;
return surfaceCellSize_[index];
}
Foam::scalar Foam::nonUniformField::interpolate
(
const point& pt,
const label index
) const
{
if (patch_.empty())
{
recalculateInterpolation();
}
const face& faceHitByPt = surfaceTriMesh_.triSurface::operator[](index);
const pointField& pts = surfaceTriMesh_.points();
const Map<label>& pMap = surfaceTriMesh_.meshPointMap();
triPointRef tri
(
pts[faceHitByPt[0]],
pts[faceHitByPt[1]],
pts[faceHitByPt[2]]
);
scalarList bary(3, 0.0);
tri.barycentric(pt, bary);
return pointCellSize_()[pMap[faceHitByPt[0]]]*bary[0]
+ pointCellSize_()[pMap[faceHitByPt[1]]]*bary[1]
+ pointCellSize_()[pMap[faceHitByPt[2]]]*bary[2];
}
void Foam::nonUniformField::recalculateInterpolation() const
{
patch_.reset(new primitivePatchInterpolation(surfaceTriMesh_));
pointCellSize_.reset
(
new triSurfacePointScalarField
(
IOobject
(
"pointCellSize.cellSize",
surfaceTriMesh_.searchableSurface::time().constant(),
"triSurface",
surfaceTriMesh_.searchableSurface::time(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
surfaceTriMesh_,
dimLength,
patch_().faceToPointInterpolate(surfaceCellSize_)
)
);
}
// ************************************************************************* //

View File

@ -0,0 +1,123 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::nonUniformField
Description
SourceFiles
nonUniformField.C
\*---------------------------------------------------------------------------*/
#ifndef nonUniformField_H
#define nonUniformField_H
#include "triSurfaceFields.H"
#include "PrimitivePatchInterpolation.H"
#include "surfaceCellSizeFunction.H"
#include "cellSizeCalculationType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class triSurfaceMesh;
class searchableSurface;
/*---------------------------------------------------------------------------*\
Class nonUniformField Declaration
\*---------------------------------------------------------------------------*/
class nonUniformField
:
public surfaceCellSizeFunction
{
protected:
// Private typedef
typedef PrimitivePatchInterpolation
<
PrimitivePatch<labelledTri, List, pointField, point>
> primitivePatchInterpolation;
// Private data
const triSurfaceMesh& surfaceTriMesh_;
triSurfaceScalarField surfaceCellSize_;
autoPtr<cellSizeCalculationType> cellSizeCalculationType_;
mutable autoPtr<triSurfacePointScalarField> pointCellSize_;
mutable autoPtr<primitivePatchInterpolation> patch_;
public:
//- Runtime type information
TypeName("nonUniformField");
// Constructors
//- Construct from components
nonUniformField
(
const dictionary& cellSizeFunctionDict,
const searchableSurface& surface
);
//- Destructor
virtual ~nonUniformField()
{}
// Member Functions
virtual const scalar& surfaceSize(const label index) const;
virtual const scalar& refineSurfaceSize(const label index);
virtual scalar interpolate(const point& pt, const label index) const;
virtual void recalculateInterpolation() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,99 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "surfaceCellSizeFunction.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(surfaceCellSizeFunction, 0);
defineRunTimeSelectionTable(surfaceCellSizeFunction, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceCellSizeFunction::surfaceCellSizeFunction
(
const word& type,
const dictionary& surfaceCellSizeFunctionDict,
const searchableSurface& surface
)
:
dictionary(surfaceCellSizeFunctionDict),
surface_(surface),
coeffsDict_(subDict(type + "Coeffs")),
refinementFactor_(readScalar(lookup("refinementFactor")))
{}
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::surfaceCellSizeFunction> Foam::surfaceCellSizeFunction::New
(
const dictionary& surfaceCellSizeFunctionDict,
const searchableSurface& surface
)
{
word surfaceCellSizeFunctionTypeName
(
surfaceCellSizeFunctionDict.lookup("surfaceCellSizeFunction")
);
Info<< " Selecting surfaceCellSizeFunction "
<< surfaceCellSizeFunctionTypeName << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(surfaceCellSizeFunctionTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"surfaceCellSizeFunction::New(dictionary&, "
"const conformalVoronoiMesh&, const searchableSurface&)"
) << "Unknown surfaceCellSizeFunction type "
<< surfaceCellSizeFunctionTypeName
<< endl << endl
<< "Valid surfaceCellSizeFunction types are :" << endl
<< dictionaryConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<surfaceCellSizeFunction>
(
cstrIter()(surfaceCellSizeFunctionDict, surface)
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceCellSizeFunction::~surfaceCellSizeFunction()
{}
// ************************************************************************* //

View File

@ -0,0 +1,159 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::surfaceCellSizeFunction
Description
Abstract base class for specifying target cell sizes
SourceFiles
surfaceCellSizeFunction.C
\*---------------------------------------------------------------------------*/
#ifndef surfaceCellSizeFunction_H
#define surfaceCellSizeFunction_H
#include "searchableSurface.H"
#include "dictionary.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class surfaceCellSizeFunction Declaration
\*---------------------------------------------------------------------------*/
class surfaceCellSizeFunction
:
public dictionary
{
protected:
// Protected data
//- Reference to the searchableSurface that surfaceCellSizeFunction
// relates to
const searchableSurface& surface_;
const dictionary coeffsDict_;
//- If cell resizing is allowed, this is the factor of the old cell size
// to get the new cell size
scalar refinementFactor_;
private:
// Private Member Functions
//- Disallow default bitwise copy construct
surfaceCellSizeFunction(const surfaceCellSizeFunction&);
//- Disallow default bitwise assignment
void operator=(const surfaceCellSizeFunction&);
public:
//- Runtime type information
TypeName("surfaceCellSizeFunction");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
surfaceCellSizeFunction,
dictionary,
(
const dictionary& surfaceCellSizeFunctionDict,
const searchableSurface& surface
),
(surfaceCellSizeFunctionDict, surface)
);
// Constructors
//- Construct from components
surfaceCellSizeFunction
(
const word& type,
const dictionary& surfaceCellSizeFunctionDict,
const searchableSurface& surface
);
// Selectors
//- Return a reference to the selected surfaceCellSizeFunction
static autoPtr<surfaceCellSizeFunction> New
(
const dictionary& surfaceCellSizeFunctionDict,
const searchableSurface& surface
);
//- Destructor
virtual ~surfaceCellSizeFunction();
// Member Functions
//- Const access to the details dictionary
inline const dictionary& coeffsDict() const
{
return coeffsDict_;
}
virtual const scalar& surfaceSize(const label index) const = 0;
virtual const scalar& refineSurfaceSize(const label index) = 0;
virtual scalar interpolate
(
const point& pt,
const label index
) const = 0;
virtual void recalculateInterpolation() const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,86 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "uniformValue.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(uniformValue, 0);
addToRunTimeSelectionTable
(
surfaceCellSizeFunction,
uniformValue,
dictionary
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::uniformValue::uniformValue
(
const dictionary& cellSizeFunctionDict,
const searchableSurface& surface
)
:
surfaceCellSizeFunction(typeName, cellSizeFunctionDict, surface),
surfaceCellSize_(readScalar(coeffsDict().lookup("surfaceCellSize")))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::scalar& Foam::uniformValue::surfaceSize(const label index) const
{
return surfaceCellSize_;
}
const Foam::scalar& Foam::uniformValue::refineSurfaceSize(const label index)
{
surfaceCellSize_ *= refinementFactor_;
return surfaceCellSize_;
}
Foam::scalar Foam::uniformValue::interpolate
(
const point& pt,
const label index
) const
{
return surfaceCellSize_;
}
void Foam::uniformValue::recalculateInterpolation() const
{}
// ************************************************************************* //

View File

@ -0,0 +1,105 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::uniformValue
Description
SourceFiles
uniformValue.C
\*---------------------------------------------------------------------------*/
#ifndef uniformValue_H
#define uniformValue_H
#include "surfaceCellSizeFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class uniformValue Declaration
\*---------------------------------------------------------------------------*/
class uniformValue
:
public surfaceCellSizeFunction
{
private:
// Private data
scalar surfaceCellSize_;
public:
//- Runtime type information
TypeName("uniformValue");
// Constructors
//- Construct from components
uniformValue
(
const dictionary& cellSizeFunctionDict,
const searchableSurface& surface
);
//- Destructor
virtual ~uniformValue()
{}
// Member Functions
virtual const scalar& surfaceSize(const label index) const;
virtual const scalar& refineSurfaceSize(const label index);
virtual scalar interpolate
(
const point& pt,
const label index
) const;
virtual void recalculateInterpolation() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -817,6 +817,8 @@ void Foam::conformalVoronoiMesh::storeSizesAndAlignments
label i = 0;
checkCellSizing();
for
(
List<Point>::const_iterator pit = storePts.begin();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -911,6 +911,17 @@ private:
const HashSet<labelPair, labelPair::Hash<> >& deferredCollapseFaces
) const;
//- Check whether the cell sizes are fine enough. Creates a polyMesh.
void checkCellSizing();
//- Find all cells with a patch face that is not near the surface. The
// allowed offset is the fraction of the target cell size.
labelHashSet findOffsetPatchFaces
(
const polyMesh& mesh,
const scalar allowedOffset
) const;
//- Create a polyMesh and check its quality, reports which
// elements damage the mesh quality, allowing backtracking.
labelHashSet checkPolyMeshQuality(const pointField& pts) const;
@ -1005,6 +1016,9 @@ private:
const labelList& procNeighbours
) const;
//- Create a polyMesh from points.
autoPtr<polyMesh> createPolyMeshFromPoints(const pointField& pts) const;
//- Rotate the faces on processor patches if necessary
void reorderProcessorPatches
(
@ -1193,7 +1207,7 @@ public:
//- Find the cellSet of the boundary cells which have points that
// protrude out of the surface beyond a tolerance.
void findRemainingProtrusionSet(const fvMesh& mesh) const;
labelHashSet findRemainingProtrusionSet(const polyMesh& mesh) const;
void writeProcessorInterface
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,6 +26,7 @@ License
#include "conformalVoronoiMesh.H"
#include "motionSmoother.H"
#include "backgroundMeshDecomposition.H"
#include "polyMeshGeometry.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
@ -1552,7 +1553,8 @@ void Foam::conformalVoronoiMesh::deferredCollapseFaceSet
}
Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality
Foam::autoPtr<Foam::polyMesh>
Foam::conformalVoronoiMesh::createPolyMeshFromPoints
(
const pointField& pts
) const
@ -1592,62 +1594,67 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality
labelList cellToDelaunayVertex(removeUnusedCells(owner, neighbour));
cellCentres = pointField(cellCentres, cellToDelaunayVertex);
polyMesh pMesh
autoPtr<polyMesh> meshPtr
(
IOobject
new polyMesh
(
"cvMesh_temporary",
runTime_.timeName(),
runTime_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
xferCopy(pts),
xferMove(faces),
xferMove(owner),
xferMove(neighbour)
IOobject
(
"cvMesh_temporary",
runTime_.timeName(),
runTime_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
xferCopy(pts),
xferMove(faces),
xferMove(owner),
xferMove(neighbour)
)
);
polyMesh& pMesh = meshPtr();
List<polyPatch*> patches(patchStarts.size());
label nValidPatches = 0;
forAll(patches, p)
{
if (patchTypes[p] == processorPolyPatch::typeName)
{
// Do not create empty processor patches
if (patchTypes[p] == processorPolyPatch::typeName)
{
// Do not create empty processor patches
if (patchSizes[p] > 0)
{
patches[nValidPatches] = new processorPolyPatch
(
patchNames[p],
patchSizes[p],
patchStarts[p],
nValidPatches,
pMesh.boundaryMesh(),
Pstream::myProcNo(),
procNeighbours[p]
);
if (patchSizes[p] > 0)
{
patches[nValidPatches] = new processorPolyPatch
(
patchNames[p],
patchSizes[p],
patchStarts[p],
nValidPatches,
pMesh.boundaryMesh(),
Pstream::myProcNo(),
procNeighbours[p]
);
nValidPatches++;
}
}
else
{
patches[nValidPatches] = polyPatch::New
(
patchTypes[p],
patchNames[p],
patchSizes[p],
patchStarts[p],
nValidPatches,
pMesh.boundaryMesh()
).ptr();
nValidPatches++;
}
}
else
{
patches[nValidPatches] = polyPatch::New
(
patchTypes[p],
patchNames[p],
patchSizes[p],
patchStarts[p],
nValidPatches,
pMesh.boundaryMesh()
).ptr();
nValidPatches++;
}
nValidPatches++;
}
}
patches.setSize(nValidPatches);
@ -1672,6 +1679,199 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality
// pMesh.overrideCellCentres(cellCentres);
return meshPtr;
}
void Foam::conformalVoronoiMesh::checkCellSizing()
{
Info<< "Checking cell sizes..."<< endl;
timeCheck("Start of Cell Sizing");
PackedBoolList boundaryPts(number_of_cells(), false);
pointField ptsField;
indexDualVertices(ptsField, boundaryPts);
// Merge close dual vertices.
mergeCloseDualVertices(ptsField, boundaryPts);
autoPtr<polyMesh> meshPtr = createPolyMeshFromPoints(ptsField);
const polyMesh& pMesh = meshPtr();
//pMesh.write();
// Find cells with poor quality
DynamicList<label> checkFaces(identity(pMesh.nFaces()));
labelHashSet wrongFaces(pMesh.nFaces()/100);
Info<< "Running checkMesh on mesh with " << pMesh.nCells()
<< " cells "<< endl;
const dictionary& dict
= cvMeshControls().cvMeshDict().subDict("meshQualityControls");
const scalar maxNonOrtho = readScalar(dict.lookup("maxNonOrtho", true));
label nWrongFaces = 0;
if (maxNonOrtho < 180.0 - SMALL)
{
polyMeshGeometry::checkFaceDotProduct
(
false,
maxNonOrtho,
pMesh,
pMesh.cellCentres(),
pMesh.faceAreas(),
checkFaces,
List<labelPair>(),
&wrongFaces
);
label nNonOrthogonal = returnReduce(wrongFaces.size(), sumOp<label>());
Info<< " non-orthogonality > " << maxNonOrtho
<< " degrees : " << nNonOrthogonal << endl;
nWrongFaces += nNonOrthogonal;
}
labelHashSet protrudingCells = findOffsetPatchFaces(pMesh, 0.25);
label nProtrudingCells = protrudingCells.size();
Info<< " protruding/intruding cells : " << nProtrudingCells << endl;
nWrongFaces += nProtrudingCells;
// motionSmoother::checkMesh
// (
// false,
// pMesh,
// cvMeshControls().cvMeshDict().subDict("meshQualityControls"),
// checkFaces,
// wrongFaces
// );
Info<< " Found total of " << nWrongFaces << " bad faces" << endl;
{
labelHashSet cellsToResizeMap(pMesh.nFaces()/100);
// Find cells that are attached to the faces in wrongFaces.
forAllConstIter(labelHashSet, wrongFaces, iter)
{
const label faceOwner = pMesh.faceOwner()[iter.key()];
const label faceNeighbour = pMesh.faceNeighbour()[iter.key()];
if (!cellsToResizeMap.found(faceOwner))
{
cellsToResizeMap.insert(faceOwner);
}
if (!cellsToResizeMap.found(faceNeighbour))
{
cellsToResizeMap.insert(faceNeighbour);
}
}
cellsToResizeMap += protrudingCells;
pointField cellsToResize(cellsToResizeMap.size());
label count = 0;
for (label cellI = 0; cellI < pMesh.nCells(); ++cellI)
{
if (cellsToResizeMap.found(cellI))
{
cellsToResize[count++] = pMesh.cellCentres()[cellI];
}
}
Info<< " Automatically re-sizing " << cellsToResize.size()
<< " cells that are attached to the bad faces: DISABLED" << endl;
//cellSizeControl_.setCellSizes(cellsToResize);
}
timeCheck("End of Cell Sizing");
Info<< "Finished checking cell sizes"<< endl;
}
Foam::labelHashSet Foam::conformalVoronoiMesh::findOffsetPatchFaces
(
const polyMesh& mesh,
const scalar allowedOffset
) const
{
timeCheck("Start findRemainingProtrusionSet");
const polyBoundaryMesh& patches = mesh.boundaryMesh();
cellSet offsetBoundaryCells
(
mesh,
"cvMesh_protrudingCells",
mesh.nCells()/1000
);
forAll(patches, patchI)
{
const polyPatch& patch = patches[patchI];
const faceList& localFaces = patch.localFaces();
const pointField& localPoints = patch.localPoints();
const labelList& fCell = patch.faceCells();
forAll(localFaces, pLFI)
{
const face& f = localFaces[pLFI];
const Foam::point& faceCentre = f.centre(localPoints);
const scalar targetSize = targetCellSize(faceCentre);
pointIndexHit pHit;
label surfHit = -1;
geometryToConformTo_.findSurfaceNearest
(
faceCentre,
sqr(targetSize),
pHit,
surfHit
);
if
(
pHit.hit()
&& (mag(pHit.hitPoint() - faceCentre) > allowedOffset*targetSize)
)
{
offsetBoundaryCells.insert(fCell[pLFI]);
}
}
}
offsetBoundaryCells.write();
return offsetBoundaryCells;
}
Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality
(
const pointField& pts
) const
{
autoPtr<polyMesh> meshPtr = createPolyMeshFromPoints(pts);
polyMesh& pMesh = meshPtr();
timeCheck("polyMesh created, checking quality");
labelHashSet wrongFaces(pMesh.nFaces()/100);
@ -2264,10 +2464,6 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
}
}
}
Pout<< "Patch Names: " << patchNames << endl;
Pout<< "Patch Sizes: " << patchSizes << endl;
Pout<< "Proc Neighbours: " << procNeighbours << endl;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -1072,9 +1072,9 @@ void Foam::conformalVoronoiMesh::writeCellCentres
}
void Foam::conformalVoronoiMesh::findRemainingProtrusionSet
Foam::labelHashSet Foam::conformalVoronoiMesh::findRemainingProtrusionSet
(
const fvMesh& mesh
const polyMesh& mesh
) const
{
timeCheck("Start findRemainingProtrusionSet");
@ -1129,7 +1129,7 @@ void Foam::conformalVoronoiMesh::findRemainingProtrusionSet
reduce(protrudingCellsSize, sumOp<label>());
if (protrudingCellsSize > 0)
if (cvMeshControls().objOutput() && protrudingCellsSize > 0)
{
Info<< nl << "Found " << protrudingCellsSize
<< " cells protruding from the surface, writing cellSet "
@ -1138,6 +1138,8 @@ void Foam::conformalVoronoiMesh::findRemainingProtrusionSet
protrudingCells.write();
}
return protrudingCells;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License