Adding lookup of coefficients to cvControls and calling functions for cell sizes

when required, rather than looking up from dictionary every time.

Added relaxationModel and faceAreaWeightModel runTime selectable models.
This commit is contained in:
graham
2009-04-28 21:20:19 +01:00
parent b7b6dd7d4a
commit 202db17dcc
16 changed files with 1328 additions and 247 deletions

View File

@ -11,4 +11,10 @@ initialPointsMethod/initialPointsMethod/initialPointsMethod.C
initialPointsMethod/uniformGrid/uniformGrid.C
initialPointsMethod/pointFile/pointFile.C
relaxationModel/relaxationModel/relaxationModel.C
relaxationModel/adaptiveLinear/adaptiveLinear.C
faceAreaWeightModel/faceAreaWeightModel/faceAreaWeightModel.C
faceAreaWeightModel/piecewiseLinearRamp/piecewiseLinearRamp.C
LIB = $(FOAM_LIBBIN)/libconformalVoronoiMesh

View File

@ -26,11 +26,211 @@ License
#include "conformalVoronoiMesh.H"
#include "initialPointsMethod.H"
#include "relaxationModel.H"
#include "faceAreaWeightModel.H"
#include "uint.H"
#include "ulong.H"
#include "surfaceFeatures.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::conformalVoronoiMesh::conformalVoronoiMesh
(
const Time& runTime,
const IOdictionary& cvMeshDict
)
:
HTriangulation(),
runTime_(runTime),
allGeometry_
(
IOobject
(
"cvSearchableSurfacesDirectory",
runTime_.constant(),
"triSurface",
runTime_,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
cvMeshDict.subDict("geometry")
),
geometryToConformTo_
(
*this,
allGeometry_,
cvMeshDict.subDict("surfaceConformation")
),
cvMeshControls_(*this, cvMeshDict),
startOfInternalPoints_(0),
startOfSurfacePointPairs_(0),
initialPointsMethod_
(
initialPointsMethod::New
(
cvMeshDict.subDict("initialPoints"),
*this
)
),
relaxationModel_
(
relaxationModel::New
(
cvMeshDict.subDict("motionControl"),
*this
)
),
faceAreaWeightModel_
(
faceAreaWeightModel::New
(
cvMeshDict.subDict("motionControl"),
*this
)
)
{
timeCheck();
conformToFeaturePoints();
timeCheck();
insertInitialPoints();
timeCheck();
conformToSurface();
timeCheck();
writePoints("allPoints.obj", false);
timeCheck();
writeMesh();
timeCheck();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::conformalVoronoiMesh::~conformalVoronoiMesh()
{}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::conformalVoronoiMesh::insertSurfacePointPairs
(
const List<scalar>& surfacePpDist,
const List<point>& surfacePoints,
const List<vector>& surfaceNormals,
const fileName fName
)
{
if
(
surfacePpDist.size() != surfacePoints.size()
|| surfacePpDist.size() != surfaceNormals.size()
)
{
FatalErrorIn("Foam::conformalVoronoiMesh::insertPointPairs")
<< "surfacePpDist, surfacePoints and surfaceNormals are not "
<< "the same size. Sizes"
<< surfacePpDist.size() << ' '
<< surfacePoints.size() << ' '
<< surfaceNormals.size()
<< exit(FatalError);
}
forAll(surfacePoints, p)
{
insertPointPair
(
surfacePpDist[p],
surfacePoints[p],
surfaceNormals[p]
);
}
if (fName != fileName::null)
{
writePoints(fName, surfacePoints);
}
}
void Foam::conformalVoronoiMesh::conformToFeaturePoints()
{
Info<< nl << "Conforming to feature points" << endl;
insertConvexFeaturesPoints();
insertConcaveFeaturePoints();
insertMixedFeaturePoints();
Info<< " Conforming to " << "XXX" << " feature locations" << nl
<< " Inserting " << "YYY" << " points" << endl;
}
void Foam::conformalVoronoiMesh::insertConvexFeaturesPoints()
{
}
void Foam::conformalVoronoiMesh::insertConcaveFeaturePoints()
{
}
void Foam::conformalVoronoiMesh::insertMixedFeaturePoints()
{
}
void Foam::conformalVoronoiMesh::reinsertFeaturePoints()
{
}
void Foam::conformalVoronoiMesh::insertInitialPoints()
{
startOfInternalPoints_ = number_of_vertices();
label nVert = startOfInternalPoints_;
Info<< nl << "Inserting initial points" << endl;
std::vector<Point> initialPoints = initialPointsMethod_->initialPoints();
Info<< " " << initialPoints.size() << " points to insert..." << endl;
// using the range insert (faster than inserting points one by one)
insert(initialPoints.begin(), initialPoints.end());
Info<< " " << number_of_vertices() - startOfInternalPoints_
<< " points inserted" << endl;
for
(
Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
++vit
)
{
if (vit->uninitialised())
{
vit->index() = nVert++;
}
}
writePoints("initialPoints.obj", true);
}
bool Foam::conformalVoronoiMesh::dualCellSurfaceIntersection
(
@ -109,31 +309,10 @@ void Foam::conformalVoronoiMesh::calcDualMesh
points.setSize(number_of_cells());
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Looking up details from a dictionary, in future the will be available
// from a controls class.
// Looking up minEdgeLenSqr with a dummy point, in future will be available
// as a local value to be looked up in-place.
const dictionary& cvMeshDict( cvMeshControls_.cvMeshDict());
scalar defaultCellSize
(
readScalar
(
cvMeshDict.subDict("motionControl").lookup("defaultCellSize")
)
);
scalar minimumEdgeLengthCoeff
(
readScalar
(
cvMeshDict.subDict("polyMeshFiltering").lookup
(
"minimumEdgeLengthCoeff"
)
)
);
scalar minEdgeLenSqr = sqr(defaultCellSize*minimumEdgeLengthCoeff);
scalar minEdgeLenSqr = sqr(minimumEdgeLength(vector::zero));
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -732,173 +911,6 @@ void Foam::conformalVoronoiMesh::calcDualMesh
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::conformalVoronoiMesh::conformalVoronoiMesh
(
const Time& runTime,
const IOdictionary& cvMeshDict
)
:
HTriangulation(),
runTime_(runTime),
allGeometry_
(
IOobject
(
"cvSearchableSurfacesDirectory",
runTime_.constant(),
"triSurface",
runTime_,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
cvMeshDict.subDict("geometry")
),
geometryToConformTo_
(
*this,
allGeometry_,
cvMeshDict.subDict("surfaceConformation")
),
cvMeshControls_(*this, cvMeshDict),
startOfInternalPoints_(0),
startOfSurfacePointPairs_(0),
initialPointsMethod_
(
initialPointsMethod::New
(
cvMeshDict.subDict("initialPoints"),
*this
)
)
{
timeCheck();
conformToFeaturePoints();
timeCheck();
insertInitialPoints();
timeCheck();
conformToSurface();
timeCheck();
writePoints("allPoints.obj", false);
timeCheck();
writeMesh();
timeCheck();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::conformalVoronoiMesh::~conformalVoronoiMesh()
{}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
void Foam::conformalVoronoiMesh::timeCheck() const
{
Info<< nl << "--- [ " << runTime_.elapsedCpuTime() << "s, delta "
<< runTime_.cpuTimeIncrement()<< "s ] --- " << endl;
}
void Foam::conformalVoronoiMesh::insertSurfacePointPairs
(
const List<scalar>& surfacePpDist,
const List<point>& surfacePoints,
const List<vector>& surfaceNormals,
const fileName fName
)
{
if
(
surfacePpDist.size() != surfacePoints.size()
|| surfacePpDist.size() != surfaceNormals.size()
)
{
FatalErrorIn("Foam::conformalVoronoiMesh::insertPointPairs")
<< "surfacePpDist, surfacePoints and surfaceNormals are not "
<< "the same size. Sizes"
<< surfacePpDist.size() << ' '
<< surfacePoints.size() << ' '
<< surfaceNormals.size()
<< exit(FatalError);
}
forAll(surfacePoints, p)
{
insertPointPair
(
surfacePpDist[p],
surfacePoints[p],
surfaceNormals[p]
);
}
if (fName != fileName::null)
{
writePoints(fName, surfacePoints);
}
}
void Foam::conformalVoronoiMesh::conformToFeaturePoints()
{
Info<< nl << "Conforming to feature points" << endl;
Info<< " Conforming to " << "XXX" << " feature locations" << nl
<< " Inserting " << "YYY" << " points" << endl;
}
void Foam::conformalVoronoiMesh::reinsertFeaturePoints()
{
}
void Foam::conformalVoronoiMesh::insertInitialPoints()
{
startOfInternalPoints_ = number_of_vertices();
label nVert = startOfInternalPoints_;
Info<< nl << "Inserting initial points" << endl;
std::vector<Point> initialPoints = initialPointsMethod_->initialPoints();
Info<< " " << initialPoints.size() << " points to insert..." << endl;
// using the range insert (faster than inserting points one by one)
insert(initialPoints.begin(), initialPoints.end());
Info<< " " << number_of_vertices() - startOfInternalPoints_
<< " points inserted" << endl;
for
(
Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
++vit
)
{
if (vit->uninitialised())
{
vit->index() = nVert++;
}
}
writePoints("initialPoints.obj", true);
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::conformalVoronoiMesh::conformToSurface()
@ -907,44 +919,6 @@ void Foam::conformalVoronoiMesh::conformToSurface()
startOfSurfacePointPairs_ = number_of_vertices();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Looking up details from a dictionary, in future the will be available
// from a controls class.
const dictionary& cvMeshDict( cvMeshControls_.cvMeshDict());
scalar defaultCellSize
(
readScalar
(
cvMeshDict.subDict("motionControl").lookup("defaultCellSize")
)
);
scalar surfDepthCoeff
(
readScalar
(
cvMeshDict.subDict("surfaceConformation").lookup
(
"surfacePointSearchDepthCoeff"
)
)
);
scalar ppDistCoeff
(
readScalar
(
cvMeshDict.subDict("surfaceConformation").lookup
(
"pointPairDistanceCoeff"
)
)
);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Surface protrusion conformation
label nIterations = 1;
@ -952,6 +926,7 @@ void Foam::conformalVoronoiMesh::conformToSurface()
for(label iterationNo = 0; iterationNo < nIterations; iterationNo++)
{
DynamicList<scalar> surfacePpDist;
DynamicList<scalar> surfaceSearchDistSqr;
DynamicList<point> surfacePoints;
DynamicList<vector> surfaceNormals;
@ -966,11 +941,7 @@ void Foam::conformalVoronoiMesh::conformToSurface()
if (vit->internalPoint())
{
point vert(topoint(vit->point()));
// TODO Need to have a function to recover the local cell size,
// use the defaultCellSize for the moment
scalar searchDistanceSqr = sqr(defaultCellSize*surfDepthCoeff);
scalar searchDistanceSqr = surfaceSearchDistanceSqr(vert);
pointIndexHit pHit;
vector normal;
@ -992,7 +963,8 @@ void Foam::conformalVoronoiMesh::conformToSurface()
// edge, shift it to being an edge control point
// instead, this will prevent "pits" forming.
surfacePpDist.append(defaultCellSize*ppDistCoeff);
surfacePpDist.append(pointPairDistance(vert));
surfaceSearchDistSqr.append(searchDistanceSqr);
surfacePoints.append(pHit.hitPoint());
surfaceNormals.append(normal);
}
@ -1020,11 +992,7 @@ void Foam::conformalVoronoiMesh::conformToSurface()
geometryToConformTo_.findEdgeNearest
(
pointField(surfacePoints),
scalarField
(
surfacePoints.size(),
sqr(defaultCellSize*surfDepthCoeff)
)
scalarField(surfaceSearchDistSqr)
);
// After the surface conformation points are added, any points that are

View File

@ -62,6 +62,10 @@ namespace Foam
// Forward declaration of classes
class initialPointsMethod;
class relaxationModel;
class faceAreaWeightModel;
/*---------------------------------------------------------------------------*\
Class conformalVoronoiMesh Declaration
@ -99,10 +103,32 @@ class conformalVoronoiMesh
//- Method for inserting initial points. Runtime selectable.
autoPtr<initialPointsMethod> initialPointsMethod_;
//- Relaxation coefficient model. Runtime selectable
autoPtr<relaxationModel> relaxationModel_;
//- Face area weight function. Runtime selectable.
autoPtr<faceAreaWeightModel> faceAreaWeightModel_;
// Private Member Functions
//- Write the elapsedCpuTime
void timeCheck() const;
inline void timeCheck() const;
//- Return the local target cell size at the given location
inline scalar targetCellSize(const point& pt) const;
//- Return the local point pair separation at the given location
inline scalar pointPairDistance(const point& pt) const;
//- Return the square of the local surface search distance
inline scalar surfaceSearchDistanceSqr(const point& pt) const;
//- Return the local minimum allowed dual edge length
inline scalar minimumEdgeLength(const point& pt) const;
//- Return the required alignment directions at the given location
inline tensor requiredAlignment(const point& pt) const;
//- Insert point and return it's index
inline label insertPoint
@ -136,6 +162,15 @@ class conformalVoronoiMesh
//- Insert point groups at the feature points.
void conformToFeaturePoints();
//- Insert point groups at convex feature points
void insertConvexFeaturesPoints();
//- Insert point groups at concave feature points
void insertConcaveFeaturePoints();
//- Insert point groups at mixed feature points
void insertMixedFeaturePoints();
//- Reinsert stored feature point defining points.
void reinsertFeaturePoints();

View File

@ -28,6 +28,59 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline void Foam::conformalVoronoiMesh::timeCheck() const
{
Info<< nl << "--- [ " << runTime_.elapsedCpuTime() << "s, delta "
<< runTime_.cpuTimeIncrement()<< "s ] --- " << endl;
}
inline Foam::scalar Foam::conformalVoronoiMesh::targetCellSize
(
const point& pt
) const
{
return cvMeshControls_.defaultCellSize();
}
inline Foam::scalar Foam::conformalVoronoiMesh::pointPairDistance
(
const point& pt
) const
{
return targetCellSize(pt)*cvMeshControls_.pointPairDistanceCoeff();
}
inline Foam::scalar Foam::conformalVoronoiMesh::surfaceSearchDistanceSqr
(
const point& pt
) const
{
return sqr(targetCellSize(pt)*cvMeshControls_.surfaceSearchDistanceCoeff());
}
inline Foam::scalar Foam::conformalVoronoiMesh::minimumEdgeLength
(
const point& pt
) const
{
return targetCellSize(pt)*cvMeshControls_.minimumEdgeLengthCoeff();
}
inline Foam::tensor Foam::conformalVoronoiMesh::requiredAlignment
(
const point& pt
) const
{
Info<< "STILL TO IMPLEMENT requiredAlignment." << endl;
return I;
}
inline Foam::label Foam::conformalVoronoiMesh::insertPoint
(
const point& p,

View File

@ -38,7 +38,70 @@ Foam::cvControls::cvControls
cvMesh_(cvMesh),
cvMeshDict_(cvMeshDict)
{
Info<< nl << "Reading " << cvMeshDict_.name() << endl;
// Surface conformation controls
const dictionary& surfDict(cvMeshDict_.subDict("surfaceConformation"));
pointPairDistanceCoeff_ = readScalar
(
surfDict.lookup("pointPairDistanceCoeff")
);
surfaceSearchDistanceCoeff_ = readScalar
(
surfDict.lookup("surfaceSearchDistanceCoeff")
);
maxQuadAngle_= readScalar
(
surfDict.lookup("maxQuadAngle")
);
// Motion control controls
const dictionary& motionDict(cvMeshDict_.subDict("motionControl"));
defaultCellSize_ = readScalar
(
motionDict.lookup("defaultCellSize")
);
const dictionary& insertionDict
(
motionDict.subDict("pointInsertionCriteria")
);
cellCentreInsertionDistCoeff_ = readScalar
(
insertionDict.lookup("cellCentreDistCoeff")
);
faceAreaRatioCoeff_ = readScalar
(
insertionDict.lookup("faceAreaRatioCoeff")
);
alignmentAcceptanceAngle_ = readScalar
(
insertionDict.lookup("alignmentAcceptanceAngle")
);
const dictionary& removalDict
(
motionDict.subDict("pointRemovalCriteria")
);
cellCentreRemovalDistCoeff_ = readScalar
(
removalDict.lookup("cellCentreDistCoeff")
);
// polyMesh filtering controls
const dictionary& filteringDict(cvMeshDict_.subDict("polyMeshFiltering"));
minimumEdgeLengthCoeff_ = readScalar
(
filteringDict.lookup("minimumEdgeLengthCoeff")
);
}

View File

@ -46,7 +46,6 @@ namespace Foam
// Forward declaration of classes
class conformalVoronoiMesh;
/*---------------------------------------------------------------------------*\
Class cvControls Declaration
\*---------------------------------------------------------------------------*/
@ -61,6 +60,45 @@ class cvControls
//- Reference to the cvMeshDict
const IOdictionary& cvMeshDict_;
// Surface conformation controls
//- Point pair spacing coefficient - fraction of the local target
// cell size
scalar pointPairDistanceCoeff_;
//- Surface search distance coefficient - faction of the local
// target cell size
scalar surfaceSearchDistanceCoeff_;
//- Maximum quadrant angle allowed at a concave edge before
// additional "mitering" lines are added
scalar maxQuadAngle_;
// Motion control controls
// Storing the default cell size value for the moment until a method for
// storing the spatially resolved size requirement is implemented
scalar defaultCellSize_;
// Point insertion criteria
scalar cellCentreInsertionDistCoeff_;
scalar faceAreaRatioCoeff_;
scalar alignmentAcceptanceAngle_;
// Point removal criteria
scalar cellCentreRemovalDistCoeff_;
// polyMesh filtering controls
//- Minimum edge length allowed in the polyMesh, anything shorter will
// be filtered - fraction of the local target cell size
scalar minimumEdgeLengthCoeff_;
public:
// Constructors
@ -80,9 +118,21 @@ public:
// Access
// Return the cvMeshDict
//- Return the cvMeshDict
inline const IOdictionary& cvMeshDict() const;
//- Return the defaultCellSize
inline scalar defaultCellSize() const;
//- Return the pointPairDistanceCoeff
inline scalar pointPairDistanceCoeff() const;
//- Return the surfaceSearchDistanceCoeff
inline scalar surfaceSearchDistanceCoeff() const;
//- Return the minimumEdgeLengthCoeff
inline scalar minimumEdgeLengthCoeff() const;
};

View File

@ -33,6 +33,30 @@ inline const Foam::IOdictionary& Foam::cvControls::cvMeshDict() const
return cvMeshDict_;
}
inline Foam::scalar Foam::cvControls::defaultCellSize() const
{
return defaultCellSize_;
}
inline Foam::scalar Foam::cvControls::pointPairDistanceCoeff() const
{
return pointPairDistanceCoeff_;
}
inline Foam::scalar Foam::cvControls::surfaceSearchDistanceCoeff() const
{
return surfaceSearchDistanceCoeff_;
}
inline Foam::scalar Foam::cvControls::minimumEdgeLengthCoeff() const
{
return minimumEdgeLengthCoeff_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,107 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "faceAreaWeightModel.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(faceAreaWeightModel, 0);
defineRunTimeSelectionTable(faceAreaWeightModel, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
faceAreaWeightModel::faceAreaWeightModel
(
const word& type,
const dictionary& relaxationDict,
const conformalVoronoiMesh& cvMesh
)
:
dictionary(relaxationDict),
cvMesh_(cvMesh),
coeffDict_(subDict(type + "Coeffs"))
{}
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
autoPtr<faceAreaWeightModel> faceAreaWeightModel::New
(
const dictionary& relaxationDict,
const conformalVoronoiMesh& cvMesh
)
{
word faceAreaWeightModelTypeName
(
relaxationDict.lookup("faceAreaWeightModel")
);
Info<< nl << "Selecting faceAreaWeightModel "
<< faceAreaWeightModelTypeName << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(faceAreaWeightModelTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"faceAreaWeightModel::New(const dictionary&, "
"const conformalVoronoiMesh&)"
) << "Unknown faceAreaWeightModel type "
<< faceAreaWeightModelTypeName
<< endl << endl
<< "Valid faceAreaWeightModel types are :" << endl
<< dictionaryConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<faceAreaWeightModel>(cstrIter()(relaxationDict, cvMesh));
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
faceAreaWeightModel::~faceAreaWeightModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,150 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::faceAreaWeightModel
Description
Abstract base class for providing faceAreaWeight values to the cell motion
controller based on an argument faceAreaFraction value, typically the ratio
of the area of the face in question to the area of a square face with a side
length of the local target cell size.
SourceFiles
faceAreaWeightModel.C
\*---------------------------------------------------------------------------*/
#ifndef faceAreaWeightModel_H
#define faceAreaWeightModel_H
#include "point.H"
#include "conformalVoronoiMesh.H"
#include "dictionary.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faceAreaWeightModel Declaration
\*---------------------------------------------------------------------------*/
class faceAreaWeightModel
:
public dictionary
{
protected:
// Protected data
//- Reference to the conformalVoronoiMesh holding this cvControls object
const conformalVoronoiMesh& cvMesh_;
//- Method coeffs dictionary
dictionary coeffDict_;
private:
// Private Member Functions
//- Disallow default bitwise copy construct
faceAreaWeightModel(const faceAreaWeightModel&);
//- Disallow default bitwise assignment
void operator=(const faceAreaWeightModel&);
public:
//- Runtime type information
TypeName("faceAreaWeightModel");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
faceAreaWeightModel,
dictionary,
(
const dictionary& faceAreaWeightDict,
const conformalVoronoiMesh& cvMesh
),
(faceAreaWeightDict, cvMesh)
);
// Constructors
//- Construct from components
faceAreaWeightModel
(
const word& type,
const dictionary& faceAreaWeightDict,
const conformalVoronoiMesh& cvMesh
);
// Selectors
//- Return a reference to the selected faceAreaWeightModel
static autoPtr<faceAreaWeightModel> New
(
const dictionary& faceAreaWeightDict,
const conformalVoronoiMesh& cvMesh
);
//- Destructor
virtual ~faceAreaWeightModel();
// Member Functions
//- Const access to the coeffs dictionary
const dictionary& coeffDict() const
{
return coeffDict_;
}
//- Return the current faceAreaWeight coefficient
virtual scalar faceAreaWeight(scalar faceAreaFraction) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,77 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "piecewiseLinearRamp.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(piecewiseLinearRamp, 0);
addToRunTimeSelectionTable(faceAreaWeightModel, piecewiseLinearRamp, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
piecewiseLinearRamp::piecewiseLinearRamp
(
const dictionary& faceAreaWeightDict,
const conformalVoronoiMesh& cvMesh
)
:
faceAreaWeightModel(typeName, faceAreaWeightDict, cvMesh),
lAF_(readScalar(coeffDict().lookup("lowerAreaFraction"))),
uAF_(readScalar(coeffDict().lookup("upperAreaFraction")))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
scalar piecewiseLinearRamp::faceAreaWeight(scalar faceAreaFraction) const
{
if (faceAreaFraction < lAF_)
{
return 0;
}
else if (faceAreaFraction < uAF_)
{
return faceAreaFraction/((uAF_ - lAF_)) - 1/((uAF_/lAF_) - 1);
}
else
{
return 1;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,100 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::piecewiseLinearRamp
Description
A linear ramp between 0 and 1 with definable start and end points.
SourceFiles
piecewiseLinearRamp.C
\*---------------------------------------------------------------------------*/
#ifndef piecewiseLinearRamp_H
#define piecewiseLinearRamp_H
#include "faceAreaWeightModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class piecewiseLinearRamp Declaration
\*---------------------------------------------------------------------------*/
class piecewiseLinearRamp
:
public faceAreaWeightModel
{
private:
// Private data
//- Face area fraction below which a weight of 0 is returned
scalar lAF_;
//- Face area fraction above which a which of 1 is returned
scalar uAF_;
public:
//- Runtime type information
TypeName("piecewiseLinearRamp");
// Constructors
//- Construct from components
piecewiseLinearRamp
(
const dictionary& faceAreaWeightDict,
const conformalVoronoiMesh& cvMesh
);
//- Destructor
virtual ~piecewiseLinearRamp()
{}
// Member Functions
//- Return the faceAreaWeight
virtual scalar faceAreaWeight(scalar faceAreaFraction) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -83,8 +83,8 @@ autoPtr<initialPointsMethod> initialPointsMethod::New
{
FatalErrorIn
(
"initialPointsMethod::New(const volVectorField&, "
"const surfaceScalarField&, transportModel&)"
"initialPointsMethod::New(dictionary&, "
"const conformalVoronoiMesh&)"
) << "Unknown initialPointsMethod type "
<< initialPointsMethodTypeName
<< endl << endl

View File

@ -0,0 +1,82 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "adaptiveLinear.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(adaptiveLinear, 0);
addToRunTimeSelectionTable(relaxationModel, adaptiveLinear, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
adaptiveLinear::adaptiveLinear
(
const dictionary& relaxationDict,
const conformalVoronoiMesh& cvMesh
)
:
relaxationModel(typeName, relaxationDict, cvMesh),
relaxationStart_(readScalar(coeffDict().lookup("relaxationStart"))),
relaxationEnd_(readScalar(coeffDict().lookup("relaxationEnd"))),
lastTimeValue_(cvMesh_.time().timeOutputValue()),
relaxation_(relaxationStart_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
scalar adaptiveLinear::relaxation()
{
if (cvMesh_.time().timeOutputValue() > lastTimeValue_)
{
relaxation_ -= (relaxation_ - relaxationEnd_)
/max
(
(
cvMesh_.time().endTime().value()
- cvMesh_.time().timeOutputValue()
)
/cvMesh_.time().deltaT().value(),
1
);
}
return relaxation_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,111 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::adaptiveLinear
Description
Produces a linear ramp which adapts its gradient to changes in
endTime and deltaT to always arrive at the relaxationEnd value at the end of
the run
SourceFiles
adaptiveLinear.C
\*---------------------------------------------------------------------------*/
#ifndef adaptiveLinear_H
#define adaptiveLinear_H
#include "relaxationModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class adaptiveLinear Declaration
\*---------------------------------------------------------------------------*/
class adaptiveLinear
:
public relaxationModel
{
private:
// Private data
//- Relaxation coefficient at the start of the iteration sequence.
scalar relaxationStart_;
//- Relaxation coefficient at the end of the iteration sequence.
scalar relaxationEnd_;
//- Store the time when the last request was made for relaxation,
// prevents multiple calls to relaxation in a timestep from
// incrementing the value
scalar lastTimeValue_;
//- Current relaxation value
scalar relaxation_;
public:
//- Runtime type information
TypeName("adaptiveLinear");
// Constructors
//- Construct from components
adaptiveLinear
(
const dictionary& relaxationDict,
const conformalVoronoiMesh& cvMesh
);
//- Destructor
virtual ~adaptiveLinear()
{}
// Member Functions
//- Return the current relaxation coefficient
virtual scalar relaxation();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,107 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "relaxationModel.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(relaxationModel, 0);
defineRunTimeSelectionTable(relaxationModel, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
relaxationModel::relaxationModel
(
const word& type,
const dictionary& relaxationDict,
const conformalVoronoiMesh& cvMesh
)
:
dictionary(relaxationDict),
cvMesh_(cvMesh),
coeffDict_(subDict(type + "Coeffs"))
{}
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
autoPtr<relaxationModel> relaxationModel::New
(
const dictionary& relaxationDict,
const conformalVoronoiMesh& cvMesh
)
{
word relaxationModelTypeName
(
relaxationDict.lookup("relaxationModel")
);
Info<< nl << "Selecting relaxationModel "
<< relaxationModelTypeName << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(relaxationModelTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"relaxationModel::New(const dictionary&, "
"const conformalVoronoiMesh&)"
) << "Unknown relaxationModel type "
<< relaxationModelTypeName
<< endl << endl
<< "Valid relaxationModel types are :" << endl
<< dictionaryConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<relaxationModel>(cstrIter()(relaxationDict, cvMesh));
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
relaxationModel::~relaxationModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,148 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::relaxationModel
Description
Abstract base class for providing relaxation values to the cell motion
controller
SourceFiles
relaxationModel.C
\*---------------------------------------------------------------------------*/
#ifndef relaxationModel_H
#define relaxationModel_H
#include "point.H"
#include "conformalVoronoiMesh.H"
#include "dictionary.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class relaxationModel Declaration
\*---------------------------------------------------------------------------*/
class relaxationModel
:
public dictionary
{
protected:
// Protected data
//- Reference to the conformalVoronoiMesh holding this cvControls object
const conformalVoronoiMesh& cvMesh_;
//- Method coeffs dictionary
dictionary coeffDict_;
private:
// Private Member Functions
//- Disallow default bitwise copy construct
relaxationModel(const relaxationModel&);
//- Disallow default bitwise assignment
void operator=(const relaxationModel&);
public:
//- Runtime type information
TypeName("relaxationModel");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
relaxationModel,
dictionary,
(
const dictionary& relaxationDict,
const conformalVoronoiMesh& cvMesh
),
(relaxationDict, cvMesh)
);
// Constructors
//- Construct from components
relaxationModel
(
const word& type,
const dictionary& relaxationDict,
const conformalVoronoiMesh& cvMesh
);
// Selectors
//- Return a reference to the selected relaxationModel
static autoPtr<relaxationModel> New
(
const dictionary& relaxationDict,
const conformalVoronoiMesh& cvMesh
);
//- Destructor
virtual ~relaxationModel();
// Member Functions
//- Const access to the coeffs dictionary
const dictionary& coeffDict() const
{
return coeffDict_;
}
//- Return the current relaxation coefficient
virtual scalar relaxation() = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //