cvMesh: Relocated the conformalVoronoiMesh library and localised all uses of CGAL

Removed unused dependencies on CGAL
This commit is contained in:
Henry
2011-07-22 14:12:08 +01:00
parent 8417b828d6
commit 5f9e3a04f0
71 changed files with 32 additions and 594 deletions

View File

@ -5,6 +5,5 @@ set -x
wmake $makeType autoMesh
wmake $makeType blockMesh
wmake $makeType conformalVoronoiMesh
# ----------------------------------------------------------------- end-of-file

View File

@ -1,39 +0,0 @@
#include CGAL_FILES
conformalVoronoiMesh/conformalVoronoiMesh.C
conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C
conformalVoronoiMesh/conformalVoronoiMeshIO.C
conformalVoronoiMesh/conformalVoronoiMeshFeaturePointSpecialisations.C
cvControls/cvControls.C
conformationSurfaces/conformationSurfaces.C
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
initialPointsMethod/initialPointsMethod/initialPointsMethod.C
initialPointsMethod/uniformGrid/uniformGrid.C
initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C
initialPointsMethod/faceCentredCubic/faceCentredCubic.C
initialPointsMethod/pointFile/pointFile.C
initialPointsMethod/autoDensity/autoDensity.C
relaxationModel/relaxationModel/relaxationModel.C
relaxationModel/adaptiveLinear/adaptiveLinear.C
relaxationModel/rampHoldFall/rampHoldFall.C
faceAreaWeightModel/faceAreaWeightModel/faceAreaWeightModel.C
faceAreaWeightModel/piecewiseLinearRamp/piecewiseLinearRamp.C
LIB = $(FOAM_LIBBIN)/libconformalVoronoiMesh

View File

@ -1,24 +0,0 @@
EXE_DEBUG = -DFULLDEBUG -g -O0
EXE_FROUNDING_MATH = -frounding-math
EXE_NDEBUG = -DNDEBUG
include $(GENERAL_RULES)/CGAL
FFLAGS = -DCGAL_FILES='"${CGAL_ARCH_PATH}/share/files"'
EXE_INC = \
${EXE_FROUNDING_MATH} \
${EXE_NDEBUG} \
${CGAL_INC} \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
EXE_LIBS = \
-lmeshTools \
-ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lscotchDecomp \
-ledgeMesh \
-ltriSurface \
-ldynamicMesh

View File

@ -1,309 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 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::backgroundMeshDecomposition
Description
Store a background polyMesh to use for the decomposition of space and
queries for parallel conformalVoronoiMesh.
The requirements are:
+ To have a decomposition of space which can quickly interrogate an
arbitrary location from any processor to reliably and unambiguously
determine which processor owns the space that the point is in, i.e. as
the vertices move, or need inserted as part of the surface conformation,
send them to the correct proc.
+ To be able to be dynamically built, refined and redistributed to other
procs the partitioning as the meshing progresses to balance the load.
+ To be able to query whether a sphere (the circumsphere of a Delaunay tet)
overlaps any part of the space defined by the structure, and whether a
ray (Voronoi edge) penetrates any part of the space defined by the
structure, this is what determines if points get referred to a processor.
SourceFiles
backgroundMeshDecompositionI.H
backgroundMeshDecomposition.C
\*---------------------------------------------------------------------------*/
#ifndef backgroundMeshDecomposition_H
#define backgroundMeshDecomposition_H
#include "conformalVoronoiMesh.H"
#include "fvMesh.H"
#include "hexRef8.H"
#include "cellSet.H"
#include "meshTools.H"
#include "polyTopoChange.H"
#include "mapPolyMesh.H"
#include "decompositionMethod.H"
#include "fvMeshDistribute.H"
#include "removeCells.H"
#include "mapDistributePolyMesh.H"
#include "globalIndex.H"
#include "treeBoundBox.H"
#include "primitivePatch.H"
#include "face.H"
#include "labelList.H"
#include "pointField.H"
#include "indexedOctree.H"
#include "treeDataPrimitivePatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef treeDataPrimitivePatch<face, List, const pointField, point>
treeDataBPatch;
typedef PrimitivePatch<face, List, const pointField, point> bPatch;
/*---------------------------------------------------------------------------*\
Class backgroundMeshDecomposition Declaration
\*---------------------------------------------------------------------------*/
class backgroundMeshDecomposition
{
// Private data
//- Method details dictionary
dictionary coeffsDict_;
//- Reference to the conformalVoronoiMesh holding this object
const conformalVoronoiMesh& cvMesh_;
//- Mesh stored on for this processor, specifiying the domain that it
// is responsible for.
fvMesh mesh_;
//- Refinement object
hexRef8 meshCutter_;
//- Patch containing an independent representation of the surface of the
// mesh of this processor
autoPtr<bPatch> boundaryFacesPtr_;
//- Search tree for the boundaryFaces_ patch
autoPtr<indexedOctree<treeDataBPatch> > bFTreePtr_;
//- The bounds of all background meshes on all processors
treeBoundBoxList allBackgroundMeshBounds_;
//- The overall bounds of all of the background meshes, used to test if
// a point that is not found on any processor is in the domain at all
treeBoundBox globalBackgroundBounds_;
//- Decomposition dictionary
IOdictionary decomposeDict_;
//- Decomposition method
autoPtr<decompositionMethod> decomposerPtr_;
//- merge distance required by fvMeshDistribute
scalar mergeDist_;
//- Scale of a cell span vs cell size used to decide to refine a cell
scalar spanScale_;
//- Smallest minimum cell size allowed, i.e. to avoid high initial
// refinement of areas of small size
scalar minCellSizeLimit_;
//- Minimum normal level of refinement
label minLevels_;
//- How fine should the initial sample of the volume a box be to
// investigate the local cell size
label volRes_;
//- Allowed factor above the average cell weight before a background
// cell needs to be split
scalar maxCellWeightCoeff_;
// Private Member Functions
void initialRefinement();
//- Print details of the decomposed mesh
void printMeshData(const polyMesh& mesh) const;
//- Estimate the number of vertices that will be in this cell, returns
// true if the cell is to be split because of the density ratio inside
// it
bool refineCell
(
label cellI,
label volType,
scalar& weightEstimate
) const;
//- Select cells for refinement at the surface of the geometry to be
// meshed
labelList selectRefinementCells
(
labelList& volumeStatus,
volScalarField& cellWeights
) const;
//- Build the surface patch and search tree
void buildPatchAndTree();
//- Disallow default bitwise copy construct
backgroundMeshDecomposition(const backgroundMeshDecomposition&);
//- Disallow default bitwise assignment
void operator=(const backgroundMeshDecomposition&);
public:
//- Runtime type information
ClassName("backgroundMeshDecomposition");
// Constructors
//- Construct from components
backgroundMeshDecomposition
(
const dictionary& coeffsDict,
const conformalVoronoiMesh& cvMesh
);
//- Destructor
~backgroundMeshDecomposition();
// Member Functions
//- Build a mapDistribute for the supplied destination processor data
static autoPtr<mapDistribute> buildMap(const List<label>& toProc);
//- Redistribute the background mesh based on a supplied weight field,
// returning a map to use to redistribute vertices.
autoPtr<mapDistributePolyMesh> distribute
(
volScalarField& cellWeights,
List<DynamicList<point> >& cellVertices,
List<DynamicList<label> >& cellVertexIndices,
List<DynamicList<label> >& cellVertexTypes
);
//- Distribute supplied the points to the appropriate processor
autoPtr<mapDistribute> distributePoints(List<point>& points) const;
//- Is the given position inside the domain of this decomposition
bool positionOnThisProcessor(const point& pt) const;
//- Are the given positions inside the domain of this decomposition
boolList positionOnThisProcessor(const List<point>& pts) const;
//- Does the given box overlap the faces of the bounday of this
// processor
bool overlapsThisProcessor(const treeBoundBox& box) const;
//- Does the given sphere overlap the faces of the bounday of this
// processor
bool overlapsThisProcessor
(
const point& centre,
scalar radiusSqr
) const;
//- Find nearest intersection of line between start and end, (exposing
// underlying indexedOctree)
pointIndexHit findLine
(
const point& start,
const point& end
) const;
//- Find any intersection of line between start and end, (exposing
// underlying indexedOctree)
pointIndexHit findLineAny
(
const point& start,
const point& end
) const;
//- What processor is the given position on?
labelList processorPosition(const List<point>& pts) const;
//- What is the nearest processor to the given position?
labelList processorNearestPosition(const List<point>& pts) const;
//- Which processors are intersected by the line segment, returns all
// processors whose boundary patch is intersected by the sphere. By
// default this does not return the processor that the query is
// launched from, it is assumed that the point is on that processor.
// The index data member of the pointIndexHit is replaced with the
// processor index.
List<List<pointIndexHit> > intersectsProcessors
(
const List<point>& starts,
const List<point>& ends,
bool includeOwnProcessor = false
) const;
//- Which processors overlap the given sphere, returns all processors
// whose boundary patch is touched by the sphere or whom the sphere is
// inside. By default this does not return the processor that the
// query is launched from, it is assumed that the point is on that
// processor.
labelListList overlapsProcessors
(
const List<point>& centres,
const List<scalar>& radiusSqrs,
bool includeOwnProcessor = false
) const;
// Access
//- Return access to the underlying mesh
inline const fvMesh& mesh() const;
//- Return the boundBox of this processor
inline const treeBoundBox& procBounds() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "backgroundMeshDecompositionI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,39 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::fvMesh& Foam::backgroundMeshDecomposition::mesh() const
{
return mesh_;
}
const Foam::treeBoundBox& Foam::backgroundMeshDecomposition::procBounds() const
{
return allBackgroundMeshBounds_[Pstream::myProcNo()];
}
// ************************************************************************* //

View File

@ -1,343 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "cellSizeControlSurfaces.H"
#include "conformalVoronoiMesh.H"
#include "cellSizeFunction.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cellSizeControlSurfaces, 0);
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
bool Foam::cellSizeControlSurfaces::evalCellSizeFunctions
(
const point& pt,
scalar& minSize
) const
{
bool anyFunctionFound = false;
// // Regions requesting with the same priority take the average
// scalar sizeAccumulator = 0;
// scalar numberOfFunctions = 0;
// label previousPriority = defaultPriority_;
// if (cellSizeFunctions_.size())
// {
// previousPriority =
// cellSizeFunctions_[cellSizeFunctions_.size() - 1].priority();
// forAll(cellSizeFunctions_, i)
// {
// const cellSizeFunction& cSF = cellSizeFunctions_[i];
// if (cSF.priority() < previousPriority && numberOfFunctions > 0)
// {
// return sizeAccumulator/numberOfFunctions;
// }
// scalar sizeI;
// if (cSF.cellSize(pt, sizeI))
// {
// anyFunctionFound = true;
// previousPriority = cSF.priority();
// sizeAccumulator += sizeI;
// numberOfFunctions++;
// }
// }
// }
// if (previousPriority == defaultPriority_ || numberOfFunctions == 0)
// {
// sizeAccumulator += defaultCellSize_;
// numberOfFunctions++;
// }
// minSize = sizeAccumulator/numberOfFunctions;
// return anyFunctionFound;
// Regions requesting with the same priority take the smallest
if (cellSizeFunctions_.size())
{
// Initialise to the last (lowest) priority
label previousPriority = cellSizeFunctions_.last().priority();
forAll(cellSizeFunctions_, i)
{
const cellSizeFunction& cSF = cellSizeFunctions_[i];
if (debug)
{
Info<< "size function "
<< allGeometry_.names()[surfaces_[i]]
<< " priority " << cSF.priority()
<< endl;
}
if (cSF.priority() < previousPriority)
{
return minSize;
}
scalar sizeI;
if (cSF.cellSize(pt, sizeI))
{
anyFunctionFound = true;
if (cSF.priority() == previousPriority)
{
if (sizeI < minSize)
{
minSize = sizeI;
}
}
else
{
minSize = sizeI;
}
if (debug)
{
Info<< "sizeI " << sizeI << " minSize " << minSize << endl;
}
previousPriority = cSF.priority();
}
}
}
return anyFunctionFound;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cellSizeControlSurfaces::cellSizeControlSurfaces
(
const conformalVoronoiMesh& cvMesh,
const searchableSurfaces& allGeometry,
const dictionary& motionControlDict
)
:
cvMesh_(cvMesh),
allGeometry_(allGeometry),
surfaces_(),
cellSizeFunctions_(),
defaultCellSize_(readScalar(motionControlDict.lookup("defaultCellSize"))),
defaultPriority_
(
motionControlDict.lookupOrDefault<label>("defaultPriority", 0)
)
{
const dictionary& surfacesDict
(
motionControlDict.subDict("cellSizeControlGeometry")
);
Info<< nl << "Reading cellSizeControlGeometry" << endl;
surfaces_.setSize(surfacesDict.size());
cellSizeFunctions_.setSize(surfacesDict.size());
labelList priorities(surfacesDict.size());
label surfI = 0;
forAllConstIter(dictionary, surfacesDict, iter)
{
const dictionary& surfaceSubDict
(
surfacesDict.subDict(iter().keyword())
);
// If the "surface" keyword is not found in the dictionary, assume that
// the name of the dictionary is the surface. Distinction required to
// allow the same surface to be used multiple times to supply multiple
// cellSizeFunctions
word surfaceName = surfaceSubDict.lookupOrDefault<word>
(
"surface",
iter().keyword()
);
surfaces_[surfI] = allGeometry_.findSurfaceID(surfaceName);
if (surfaces_[surfI] < 0)
{
FatalErrorIn
(
"Foam::cellSizeControlSurfaces::cellSizeControlSurfaces"
) << "No surface " << surfaceName << " found. "
<< "Valid geometry is " << nl << allGeometry_.names()
<< exit(FatalError);
}
const searchableSurface& surface = allGeometry_[surfaces_[surfI]];
Info<< nl << " " << iter().keyword() << nl
<< " surface: " << surfaceName << endl;
cellSizeFunctions_.set
(
surfI,
cellSizeFunction::New
(
surfaceSubDict,
cvMesh,
surface
)
);
priorities[surfI] = cellSizeFunctions_[surfI].priority();
surfI++;
}
// Sort cellSizeFunctions_ and surfaces_ by priority. Cut off any surfaces
// where priority < defaultPriority_
labelList sortedIndices;
sortedOrder(priorities, sortedIndices);
sortedIndices = invert(sortedIndices.size(), sortedIndices);
// Reverse the sort order
sortedIndices = (sortedIndices.size() - 1) - sortedIndices;
inplaceReorder(sortedIndices, surfaces_);
inplaceReorder(sortedIndices, priorities);
cellSizeFunctions_.reorder(sortedIndices);
forAll(priorities, surfI)
{
if (priorities[surfI] < defaultPriority_)
{
WarningIn("cellSizeControlSurfaces::cellSizeControlSurfaces")
<< "Priority of " << priorities[surfI]
<< " is less than defaultPriority " << defaultPriority_
<< ". All cellSizeFunctions with priorities lower than default "
<< "will be ignored."
<< endl;
surfaces_.setSize(surfI);
cellSizeFunctions_.setSize(surfI);
break;
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cellSizeControlSurfaces::~cellSizeControlSurfaces()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::scalar Foam::cellSizeControlSurfaces::cellSize
(
const point& pt
) const
{
scalar size = defaultCellSize_;
bool anyFunctionFound = evalCellSizeFunctions(pt, size);
if (!anyFunctionFound)
{
// Check if the point in question was actually inside the domain, if
// not, then it may be falling back to an inappropriate default size.
if (cvMesh_.geometryToConformTo().outside(pt))
{
pointIndexHit surfHit;
label hitSurface;
cvMesh_.geometryToConformTo().findSurfaceNearest
(
pt,
sqr(GREAT),
surfHit,
hitSurface
);
if (!surfHit.hit())
{
FatalErrorIn
(
"Foam::scalar Foam::cellSizeControlSurfaces::cellSize"
"("
"const point& pt"
") const"
)
<< "Point " << pt << " did not find a nearest surface point"
<< nl << exit(FatalError) << endl;
}
}
}
return size;
}
Foam::scalarField Foam::cellSizeControlSurfaces::cellSize
(
const pointField& pts
) const
{
scalarField cellSizes(pts.size());
forAll(pts, i)
{
cellSizes[i] = cellSize(pts[i]);
}
return cellSizes;
}
// ************************************************************************* //

View File

@ -1,151 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::cellSizeControlSurfaces
Description
SourceFiles
cellSizeControlSurfacesI.H
cellSizeControlSurfaces.C
\*---------------------------------------------------------------------------*/
#ifndef cellSizeControlSurfaces_H
#define cellSizeControlSurfaces_H
#include "searchableSurfaces.H"
#include "searchableSurfacesQueries.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class conformalVoronoiMesh;
class cellSizeFunction;
/*---------------------------------------------------------------------------*\
Class cellSizeControlSurfaces Declaration
\*---------------------------------------------------------------------------*/
class cellSizeControlSurfaces
{
// Private data
//- Reference to the conformalVoronoiMesh holding this object
const conformalVoronoiMesh& cvMesh_;
//- Reference to the searchableSurfaces object holding all geometry data
const searchableSurfaces& allGeometry_;
//- Indices of surfaces in allGeometry that are to be conformed to
labelList surfaces_;
//- A list of all of the cellSizeFunction objects
PtrList<cellSizeFunction> cellSizeFunctions_;
//- Regions where no cell size function is specified use defaultCellSize
scalar defaultCellSize_;
//- Assigning a priority to all requests for cell sizes, the highest
// overrules
label defaultPriority_;
// Private Member Functions
//- Evaluate the cell size functions, returning a bool stating if a
// function was found or not
bool evalCellSizeFunctions
(
const point& pt,
scalar& minSize
) const;
//- Disallow default bitwise copy construct
cellSizeControlSurfaces(const cellSizeControlSurfaces&);
//- Disallow default bitwise assignment
void operator=(const cellSizeControlSurfaces&);
public:
//- Runtime type information
ClassName("cellSizeControlSurfaces");
// Constructors
//- Construct from dictionary and references to conformalVoronoiMesh and
// searchableSurfaces
cellSizeControlSurfaces
(
const conformalVoronoiMesh& cvMesh,
const searchableSurfaces& allGeometry,
const dictionary& motionControlDict
);
//- Destructor
~cellSizeControlSurfaces();
// Member Functions
// Access
//- Return reference to the searchableSurfaces object containing all
// of the geometry
inline const searchableSurfaces& geometry() const;
//- Return the surface indices
inline const labelList& surfaces() const;
// Query
//- Return the cell size at the given location
scalar cellSize(const point& pt) const;
//- Return the cell size at the given locations
scalarField cellSize(const pointField& pts) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "cellSizeControlSurfacesI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,40 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::searchableSurfaces& Foam::cellSizeControlSurfaces::geometry() const
{
return allGeometry_;
}
const Foam::labelList& Foam::cellSizeControlSurfaces::surfaces() const
{
return surfaces_;
}
// ************************************************************************* //

View File

@ -1,148 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "cellSizeFunction.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(cellSizeFunction, 0);
defineRunTimeSelectionTable(cellSizeFunction, dictionary);
scalar cellSizeFunction::snapToSurfaceTol_ = 1e-10;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
cellSizeFunction::cellSizeFunction
(
const word& type,
const dictionary& cellSizeFunctionDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
)
:
dictionary(cellSizeFunctionDict),
cvMesh_(cvMesh),
surface_(surface),
coeffsDict_(subDict(type + "Coeffs")),
sideMode_(),
priority_(readLabel(cellSizeFunctionDict.lookup("priority")))
{
word mode = cellSizeFunctionDict.lookup("mode");
if (surface_.hasVolumeType())
{
if (mode == "inside")
{
sideMode_ = smInside;
}
else if (mode == "outside")
{
sideMode_ = smOutside;
}
else if (mode == "bothSides")
{
sideMode_ = rmBothsides;
}
else
{
FatalErrorIn("cellSizeFunction::cellSizeFunction")
<< "Unknown mode, expected: inside, outside or bothSides" << nl
<< exit(FatalError);
}
}
else
{
if (mode != "bothSides")
{
WarningIn("cellSizeFunction::cellSizeFunction")
<< "surface does not support volumeType, defaulting mode to "
<< "bothSides."
<< endl;
}
sideMode_ = rmBothsides;
}
}
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
autoPtr<cellSizeFunction> cellSizeFunction::New
(
const dictionary& cellSizeFunctionDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
)
{
word cellSizeFunctionTypeName
(
cellSizeFunctionDict.lookup("cellSizeFunction")
);
Info<< " Selecting cellSizeFunction " << cellSizeFunctionTypeName
<< endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(cellSizeFunctionTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"cellSizeFunction::New(dictionary&, "
"const conformalVoronoiMesh&, const searchableSurface&)"
) << "Unknown cellSizeFunction type "
<< cellSizeFunctionTypeName
<< endl << endl
<< "Valid cellSizeFunction types are :" << endl
<< dictionaryConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<cellSizeFunction>
(
cstrIter()(cellSizeFunctionDict, cvMesh, surface)
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
cellSizeFunction::~cellSizeFunction()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,190 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::cellSizeFunction
Description
Abstract base class for specifying target cell sizes
SourceFiles
cellSizeFunction.C
\*---------------------------------------------------------------------------*/
#ifndef cellSizeFunction_H
#define cellSizeFunction_H
#include "point.H"
#include "conformalVoronoiMesh.H"
#include "searchableSurface.H"
#include "dictionary.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cellSizeFunction Declaration
\*---------------------------------------------------------------------------*/
class cellSizeFunction
:
public dictionary
{
public:
//- Runtime type information
TypeName("cellSizeFunction");
//- Surface side mode
enum sideMode
{
smInside, // Control inside the surface
smOutside, // Control outside the surface
rmBothsides // Control on both sides of a surface
};
protected:
// Static data
//- Point closeness tolerance to a surface where the function "snaps" to
// including the surface
static scalar snapToSurfaceTol_;
// Protected data
//- Reference to the conformalVoronoiMesh holding this cvs object
const conformalVoronoiMesh& cvMesh_;
//- Reference to the searchableSurface that cellSizeFunction
// relates to
const searchableSurface& surface_;
//- Method details dictionary
dictionary coeffsDict_;
//- Mode of size specification, i.e. inside, outside or bothSides
sideMode sideMode_;
//- Priority of this cellSizeFunction
label priority_;
private:
// Private Member Functions
//- Disallow default bitwise copy construct
cellSizeFunction(const cellSizeFunction&);
//- Disallow default bitwise assignment
void operator=(const cellSizeFunction&);
public:
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
cellSizeFunction,
dictionary,
(
const dictionary& cellSizeFunctionDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
),
(cellSizeFunctionDict, cvMesh, surface)
);
// Constructors
//- Construct from components
cellSizeFunction
(
const word& type,
const dictionary& cellSizeFunctionDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
);
// Selectors
//- Return a reference to the selected cellSizeFunction
static autoPtr<cellSizeFunction> New
(
const dictionary& cellSizeFunctionDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
);
//- Destructor
virtual ~cellSizeFunction();
// Member Functions
//- Const access to the details dictionary
inline const dictionary& coeffsDict() const
{
return coeffsDict_;
}
inline label priority() const
{
return priority_;
}
//- Modify scalar argument to the cell size specified by function.
// Return a boolean specifying if the function was used, i.e. false if
// the point was not in range of the surface for a spatially varying
// size.
virtual bool cellSize
(
const point& pt,
scalar& size
) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,144 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "linearDistance.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(linearDistance, 0);
addToRunTimeSelectionTable(cellSizeFunction, linearDistance, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
linearDistance::linearDistance
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
)
:
cellSizeFunction(typeName, initialPointsDict, cvMesh, surface),
surfaceCellSize_(readScalar(coeffsDict().lookup("surfaceCellSize"))),
distanceCellSize_(readScalar(coeffsDict().lookup("distanceCellSize"))),
distance_(readScalar(coeffsDict().lookup("distance"))),
distanceSqr_(sqr(distance_)),
gradient_((distanceCellSize_ - surfaceCellSize_)/distance_)
{}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
scalar linearDistance::sizeFunction(scalar d) const
{
return gradient_*d + surfaceCellSize_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool linearDistance::cellSize
(
const point& pt,
scalar& size
) const
{
size = 0;
List<pointIndexHit> hits;
surface_.findNearest
(
pointField(1, pt),
scalarField(1, distanceSqr_),
hits
);
const pointIndexHit& hitInfo = hits[0];
if (hitInfo.hit())
{
if (sideMode_ == rmBothsides)
{
size = sizeFunction(mag(pt - hitInfo.hitPoint()));
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_)
{
size = sizeFunction(0);
return true;
}
pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL;
surface_.getVolumeType(ptF, vTL);
bool functionApplied = false;
if
(
sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE
)
{
size = sizeFunction(mag(pt - hitInfo.hitPoint()));
functionApplied = true;
}
else if
(
sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE
)
{
size = sizeFunction(mag(pt - hitInfo.hitPoint()));
functionApplied = true;
}
return functionApplied;
}
return false;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,122 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::linearDistance
Description
SourceFiles
linearDistance.C
\*---------------------------------------------------------------------------*/
#ifndef linearDistance_H
#define linearDistance_H
#include "cellSizeFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class linearDistance Declaration
\*---------------------------------------------------------------------------*/
class linearDistance
:
public cellSizeFunction
{
private:
// Private data
//- cell size at the surface
scalar surfaceCellSize_;
//- cell size at distance_ from the surface
scalar distanceCellSize_;
//- distance from the surface to control over
scalar distance_;
//- 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;
public:
//- Runtime type information
TypeName("linearDistance");
// Constructors
//- Construct from components
linearDistance
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
);
//- Destructor
virtual ~linearDistance()
{}
// Member Functions
//- Modify scalar argument to the cell size specified by function.
// Return a boolean specifying if the function was used, i.e. false if
// the point was not in range of the surface for a spatially varying
// size.
virtual bool cellSize
(
const point& pt,
scalar& size
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,143 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "linearSpatial.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(linearSpatial, 0);
addToRunTimeSelectionTable(cellSizeFunction, linearSpatial, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
linearSpatial::linearSpatial
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
)
:
cellSizeFunction(typeName, initialPointsDict, cvMesh, surface),
referencePoint_(coeffsDict().lookup("referencePoint")),
referenceCellSize_(readScalar(coeffsDict().lookup("referenceCellSize"))),
direction_(coeffsDict().lookup("direction")),
cellSizeGradient_(readScalar(coeffsDict().lookup("cellSizeGradient")))
{
direction_ /= mag(direction_);
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
scalar linearSpatial::sizeFunction(const point& pt) const
{
return
referenceCellSize_
+ ((pt - referencePoint_) & direction_)*cellSizeGradient_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool linearSpatial::cellSize
(
const point& pt,
scalar& size
) const
{
if (sideMode_ == rmBothsides)
{
size = sizeFunction(pt);
return true;
}
size = 0;
List<pointIndexHit> hits;
surface_.findNearest
(
pointField(1, pt),
scalarField(1, sqr(snapToSurfaceTol_)),
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 = sizeFunction(pt);
return true;
}
pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL;
surface_.getVolumeType(ptF, vTL);
bool functionApplied = false;
if
(
sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE
)
{
size = sizeFunction(pt);
functionApplied = true;
}
else if
(
sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE
)
{
size = sizeFunction(pt);
functionApplied = true;
}
return functionApplied;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,120 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::linearSpatial
Description
SourceFiles
linearSpatial.C
\*---------------------------------------------------------------------------*/
#ifndef linearSpatial_H
#define linearSpatial_H
#include "cellSizeFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class linearSpatial Declaration
\*---------------------------------------------------------------------------*/
class linearSpatial
:
public cellSizeFunction
{
private:
// Private data
//- Reference point for spatial size grading
point referencePoint_;
//- Cell size at reference point
scalar referenceCellSize_;
//- Direction of cell size grading, stored as unit vector, may be
// supplied with any magnitude
vector direction_;
//- Gradient of cell size change in direction of direction_
scalar cellSizeGradient_;
// Private Member Functions
//- Calculate the cell size as a function of the given position
scalar sizeFunction(const point& pt) const;
public:
//- Runtime type information
TypeName("linearSpatial");
// Constructors
//- Construct from components
linearSpatial
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
);
//- Destructor
virtual ~linearSpatial()
{}
// Member Functions
//- Modify scalar argument to the cell size specified by function.
// Return a boolean specifying if the function was used, i.e. false if
// the point was not in range of the surface for a spatially varying
// size.
virtual bool cellSize
(
const point& pt,
scalar& size
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,215 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "surfaceOffsetLinearDistance.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(surfaceOffsetLinearDistance, 0);
addToRunTimeSelectionTable
(
cellSizeFunction,
surfaceOffsetLinearDistance,
dictionary
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
surfaceOffsetLinearDistance::surfaceOffsetLinearDistance
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
)
:
cellSizeFunction(typeName, initialPointsDict, cvMesh, surface),
surfaceCellSize_(readScalar(coeffsDict().lookup("surfaceCellSize"))),
distanceCellSize_(readScalar(coeffsDict().lookup("distanceCellSize"))),
surfaceOffset_(readScalar(coeffsDict().lookup("surfaceOffset"))),
totalDistance_(),
totalDistanceSqr_(),
gradient_(),
intercept_()
{
if
(
coeffsDict().found("totalDistance")
|| coeffsDict().found("linearDistance")
)
{
if
(
coeffsDict().found("totalDistance")
&& coeffsDict().found("linearDistance")
)
{
FatalErrorIn
(
"surfaceOffsetLinearDistance::surfaceOffsetLinearDistance"
"("
"const dictionary& initialPointsDict, "
"const conformalVoronoiMesh& cvMesh, "
"const searchableSurface& surface"
")"
)
<< "totalDistance and linearDistance found, "
<< "specify one or other, not both."
<< nl << exit(FatalError) << endl;
}
if (coeffsDict().found("totalDistance"))
{
totalDistance_ = readScalar(coeffsDict().lookup("totalDistance"));
}
else
{
totalDistance_ =
readScalar(coeffsDict().lookup("linearDistance"))
+ surfaceOffset_;
}
}
else
{
FatalErrorIn
(
"surfaceOffsetLinearDistance::surfaceOffsetLinearDistance"
"("
"const dictionary& initialPointsDict, "
"const conformalVoronoiMesh& cvMesh, "
"const searchableSurface& surface"
")"
)
<< "totalDistance or linearDistance not found."
<< nl << exit(FatalError) << endl;
}
totalDistanceSqr_ = sqr(totalDistance_);
gradient_ =
(distanceCellSize_ - surfaceCellSize_)
/(totalDistance_ - surfaceOffset_);
intercept_ = surfaceCellSize_ - gradient_*surfaceOffset_;
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
scalar surfaceOffsetLinearDistance::sizeFunction(scalar d) const
{
if (d <= surfaceOffset_)
{
return surfaceCellSize_;
}
return gradient_*d + intercept_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool surfaceOffsetLinearDistance::cellSize
(
const point& pt,
scalar& size
) const
{
size = 0;
List<pointIndexHit> hits;
surface_.findNearest
(
pointField(1, pt),
scalarField(1, totalDistanceSqr_),
hits
);
const pointIndexHit& hitInfo = hits[0];
if (hitInfo.hit())
{
if (sideMode_ == rmBothsides)
{
size = sizeFunction(mag(pt - hitInfo.hitPoint()));
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_)
{
size = sizeFunction(0);
return true;
}
pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL;
surface_.getVolumeType(ptF, vTL);
bool functionApplied = false;
if
(
sideMode_ == smInside
&& vTL[0] == searchableSurface::INSIDE
)
{
size = sizeFunction(mag(pt - hitInfo.hitPoint()));
functionApplied = true;
}
else if
(
sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE
)
{
size = sizeFunction(mag(pt - hitInfo.hitPoint()));
functionApplied = true;
}
return functionApplied;
}
return false;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,129 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::surfaceOffsetLinearDistance
Description
SourceFiles
surfaceOffsetLinearDistance.C
\*---------------------------------------------------------------------------*/
#ifndef surfaceOffsetLinearDistance_H
#define surfaceOffsetLinearDistance_H
#include "cellSizeFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class surfaceOffsetLinearDistance Declaration
\*---------------------------------------------------------------------------*/
class surfaceOffsetLinearDistance
:
public cellSizeFunction
{
private:
// Private data
//- cell size at the surface
scalar surfaceCellSize_;
//- cell size at distance_ from the surface
scalar distanceCellSize_;
//- Offset distance from surface for constant size portion
scalar surfaceOffset_;
//- Total distance from the surface to control over (distance +
// surfaceOffset)
scalar totalDistance_;
//- 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;
public:
//- Runtime type information
TypeName("surfaceOffsetLinearDistance");
// Constructors
//- Construct from components
surfaceOffsetLinearDistance
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
);
//- Destructor
virtual ~surfaceOffsetLinearDistance()
{}
// Member Functions
//- Modify scalar argument to the cell size specified by function.
// Return a boolean specifying if the function was used, i.e. false if
// the point was not in range of the surface for a spatially varying
// size.
virtual bool cellSize
(
const point& pt,
scalar& size
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,126 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "uniform.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(uniform, 0);
addToRunTimeSelectionTable(cellSizeFunction, uniform, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
uniform::uniform
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
)
:
cellSizeFunction(typeName, initialPointsDict, cvMesh, surface),
cellSize_(readScalar(coeffsDict().lookup("cellSize")))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool uniform::cellSize
(
const point& pt,
scalar& size
) const
{
if (sideMode_ == rmBothsides)
{
size = cellSize_;
return true;
}
size = 0;
List<pointIndexHit> hits;
surface_.findNearest
(
pointField(1, pt),
scalarField(1, sqr(snapToSurfaceTol_)),
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_;
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 = cellSize_;
functionApplied = true;
}
else if
(
sideMode_ == smOutside
&& vTL[0] == searchableSurface::OUTSIDE
)
{
size = cellSize_;
functionApplied = true;
}
return functionApplied;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,104 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::uniform
Description
SourceFiles
uniform.C
\*---------------------------------------------------------------------------*/
#ifndef uniform_H
#define uniform_H
#include "cellSizeFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class uniform Declaration
\*---------------------------------------------------------------------------*/
class uniform
:
public cellSizeFunction
{
private:
// Private data
//- Cell size
scalar cellSize_;
public:
//- Runtime type information
TypeName("uniform");
// Constructors
//- Construct from components
uniform
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
);
//- Destructor
virtual ~uniform()
{}
// Member Functions
//- Modify scalar argument to the cell size specified by function.
// Return a boolean specifying if the function was used, i.e. false if
// the point was not in range of the surface for a spatially varying
// size.
virtual bool cellSize
(
const point& pt,
scalar& size
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,133 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "uniformDistance.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(uniformDistance, 0);
addToRunTimeSelectionTable(cellSizeFunction, uniformDistance, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
uniformDistance::uniformDistance
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
)
:
cellSizeFunction(typeName, initialPointsDict, cvMesh, surface),
cellSize_(readScalar(coeffsDict().lookup("cellSize"))),
distance_(readScalar(coeffsDict().lookup("distance"))),
distanceSqr_(sqr(distance_))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool uniformDistance::cellSize
(
const point& pt,
scalar& size
) const
{
size = 0;
List<pointIndexHit> hits;
surface_.findNearest
(
pointField(1, pt),
scalarField(1, distanceSqr_),
hits
);
const pointIndexHit& hitInfo = hits[0];
if (hitInfo.hit())
{
if (sideMode_ == rmBothsides)
{
size = cellSize_;
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_)
{
size = cellSize_;
return true;
}
pointField ptF(1, pt);
List<searchableSurface::volumeType> vTL;
surface_.getVolumeType(ptF, vTL);
bool functionApplied = false;
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 false;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,110 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::uniformDistance
Description
SourceFiles
uniformDistance.C
\*---------------------------------------------------------------------------*/
#ifndef uniformDistance_H
#define uniformDistance_H
#include "cellSizeFunction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class uniformDistance Declaration
\*---------------------------------------------------------------------------*/
class uniformDistance
:
public cellSizeFunction
{
private:
// Private data
//- Cell size
scalar cellSize_;
//- Distance
scalar distance_;
//- Distance squared
scalar distanceSqr_;
public:
//- Runtime type information
TypeName("uniformDistance");
// Constructors
//- Construct from components
uniformDistance
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh,
const searchableSurface& surface
);
//- Destructor
virtual ~uniformDistance()
{}
// Member Functions
//- Modify scalar argument to the cell size specified by function.
// Return a boolean specifying if the function was used, i.e. false if
// the point was not in range of the surface for a spatially varying
// size.
virtual bool cellSize
(
const point& pt,
scalar& size
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,79 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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/>.
As a special exception, you have permission to link this program with the
CGAL library and distribute executables, as long as you follow the
requirements of the GNU GPL in regard to all of the software in the
executable aside from CGAL.
Typedefs
CGALTriangulation3Ddefs
Description
CGAL data structures used for 3D Delaunay meshing.
Define CGAL_INEXACT to use Exact_predicates_inexact_constructions kernel
otherwise the more robust but much less efficient
Exact_predicates_exact_constructions will be used.
\*---------------------------------------------------------------------------*/
#ifndef CGALTriangulation3Ddefs_H
#define CGALTriangulation3Ddefs_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "CGAL/Delaunay_triangulation_3.h"
#include "indexedVertex.H"
#include "indexedCell.H"
#ifdef CGAL_INEXACT
// Fast kernel using a double as the storage type but the triangulation may
// fail. Adding robust circumcentre traits
#include "CGAL/Exact_predicates_inexact_constructions_kernel.h"
#include <CGAL/Robust_circumcenter_traits_3.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel inexactK;
typedef CGAL::Robust_circumcenter_traits_3<inexactK> K;
#else
// Very robust but expensive kernel
#include "CGAL/Exact_predicates_exact_constructions_kernel.h"
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
#endif
typedef CGAL::indexedVertex<K> Vb;
typedef CGAL::indexedCell<K> Cb;
typedef CGAL::Triangulation_data_structure_3<Vb, Cb> Tds;
typedef CGAL::Delaunay_triangulation_3<K, Tds, CGAL::Fast_location> Delaunay;
typedef Delaunay::Vertex_handle Vertex_handle;
typedef Delaunay::Cell_handle Cell_handle;
typedef Delaunay::Point Point;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,365 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "conformalVoronoiMesh.H"
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
bool Foam::conformalVoronoiMesh::createSpecialisedFeaturePoint
(
const extendedFeatureEdgeMesh& feMesh,
label ptI,
DynamicList<Foam::point>& pts,
DynamicList<label>& indices,
DynamicList<label>& types
)
{
const labelList& pEds(feMesh.pointEdges()[ptI]);
if (pEds.size() != 3)
{
// Only three edge specialisations available
return false;
}
label nExternal = 0;
label nInternal = 0;
label nFlat = 0;
label nOpen = 0;
label nMultiple = 0;
List<extendedFeatureEdgeMesh::edgeStatus> allEdStat(pEds.size());
forAll(pEds, i)
{
label edgeI = pEds[i];
extendedFeatureEdgeMesh::edgeStatus& eS = allEdStat[i];
eS = feMesh.getEdgeStatus(edgeI);
switch (eS)
{
case extendedFeatureEdgeMesh::EXTERNAL:
{
nExternal++;
break;
}
case extendedFeatureEdgeMesh::INTERNAL:
{
nInternal++;
break;
}
case extendedFeatureEdgeMesh::FLAT:
{
nFlat++;
break;
}
case extendedFeatureEdgeMesh::OPEN:
{
nOpen++;
break;
}
case extendedFeatureEdgeMesh::MULTIPLE:
{
nMultiple++;
break;
}
case extendedFeatureEdgeMesh::NONE:
{
break;
}
}
}
if (nExternal == 2 && nInternal == 1)
{
// if (!positionOnThisProc(pt))
// {
// continue;
// }
// Info<< "nExternal == 2 && nInternal == 1" << endl;
// const Foam::point& featPt = feMesh.points()[ptI];
// scalar ppDist = pointPairDistance(featPt);
// const vectorField& normals = feMesh.normals();
// const labelListList& edgeNormals = feMesh.edgeNormals();
// label concaveEdgeI = pEds
// [
// findIndex(allEdStat, extendedFeatureEdgeMesh::INTERNAL)
// ];
// // // Find which planes are joined to the concave edge
// // List<label> concaveEdgePlanes(2,label(-1));
// // label concaveEdgeI = concaveEdges[0];
// // // Pick up the two faces adjacent to the concave feature edge
// // const labelList& eFaces = qSurf_.edgeFaces()[concaveEdgeI];
// // label faceA = eFaces[0];
// // vector nA = qSurf_.faceNormals()[faceA];
// // scalar maxNormalDotProduct = -SMALL;
// // forAll(uniquePlaneNormals, uPN)
// // {
// // scalar normalDotProduct = nA & uniquePlaneNormals[uPN];
// // if (normalDotProduct > maxNormalDotProduct)
// // {
// // maxNormalDotProduct = normalDotProduct;
// // concaveEdgePlanes[0] = uPN;
// // }
// // }
// // label faceB = eFaces[1];
// // vector nB = qSurf_.faceNormals()[faceB];
// // maxNormalDotProduct = -SMALL;
// // forAll(uniquePlaneNormals, uPN)
// // {
// // scalar normalDotProduct = nB & uniquePlaneNormals[uPN];
// // if (normalDotProduct > maxNormalDotProduct)
// // {
// // maxNormalDotProduct = normalDotProduct;
// // concaveEdgePlanes[1] = uPN;
// // }
// // }
// // const vector& concaveEdgePlaneANormal =
// // uniquePlaneNormals[concaveEdgePlanes[0]];
// // const vector& concaveEdgePlaneBNormal =
// // uniquePlaneNormals[concaveEdgePlanes[1]];
// // label convexEdgesPlaneI;
// // if (findIndex(concaveEdgePlanes, 0) == -1)
// // {
// // convexEdgesPlaneI = 0;
// // }
// // else if (findIndex(concaveEdgePlanes, 1) == -1)
// // {
// // convexEdgesPlaneI = 1;
// // }
// // else
// // {
// // convexEdgesPlaneI = 2;
// // }
// // const vector& convexEdgesPlaneNormal =
// // uniquePlaneNormals[convexEdgesPlaneI];
// // const edge& concaveEdge = edges[concaveEdgeI];
// // // Check direction of edge, if the feature point is at the end()
// // // the reverse direction.
// // scalar edgeDirection = 1.0;
// // if (ptI == concaveEdge.end())
// // {
// // edgeDirection *= -1.0;
// // }
// const vector& concaveEdgePlaneANormal =
// normals[edgeNormals[concaveEdgeI][0]];
// const vector& concaveEdgePlaneBNormal =
// normals[edgeNormals[concaveEdgeI][1]];
// // Intersect planes parallel to the concave edge planes offset
// // by ppDist and the plane defined by featPt and the edge
// // vector.
// plane planeA
// (
// featPt + ppDist*concaveEdgePlaneANormal,
// concaveEdgePlaneANormal
// );
// plane planeB
// (
// featPt + ppDist*concaveEdgePlaneBNormal,
// concaveEdgePlaneBNormal
// );
// const vector& concaveEdgeDir = feMesh.edgeDirection
// (
// concaveEdgeI,
// ptI
// );
// Foam::point concaveEdgeLocalFeatPt = featPt + ppDist*concaveEdgeDir;
// // Finding the nearest point on the intersecting line to the
// // edge point. Floating point errors often encountered using
// // planePlaneIntersect
// plane planeF(concaveEdgeLocalFeatPt, concaveEdgeDir);
// Foam::point concaveEdgeExternalPt = planeF.planePlaneIntersect
// (
// planeA,
// planeB
// );
// label concaveEdgeExternalPtI = number_of_vertices() + 4;
// // Redefine planes to be on the feature surfaces to project
// // through
// planeA = plane(featPt, concaveEdgePlaneANormal);
// planeB = plane(featPt, concaveEdgePlaneBNormal);
// Foam::point internalPtA =
// concaveEdgeExternalPt
// - 2*planeA.distance(concaveEdgeExternalPt)
// *concaveEdgePlaneANormal;
// label internalPtAI = insertPoint
// (
// internalPtA,
// concaveEdgeExternalPtI
// );
// Foam::point internalPtB =
// concaveEdgeExternalPt
// - 2*planeB.distance(concaveEdgeExternalPt)
// *concaveEdgePlaneBNormal;
// label internalPtBI = insertPoint
// (
// internalPtB,
// concaveEdgeExternalPtI
// );
// // TEMPORARY VARIABLE TO TEST
// vector convexEdgesPlaneNormal = -concaveEdgeDir;
// plane planeC(featPt, convexEdgesPlaneNormal);
// Foam::point externalPtD =
// internalPtA
// + 2*planeC.distance(internalPtA)*convexEdgesPlaneNormal;
// insertPoint(externalPtD, internalPtAI);
// Foam::point externalPtE =
// internalPtB
// + 2*planeC.distance(internalPtB)*convexEdgesPlaneNormal;
// insertPoint(externalPtE, internalPtBI);
// insertPoint(concaveEdgeExternalPt, internalPtAI);
// Info<< nl << "# featPt " << endl;
// meshTools::writeOBJ(Info, featPt);
// Info<< "# internalPtA" << endl;
// meshTools::writeOBJ(Info, internalPtA);
// Info<< "# internalPtB" << endl;
// meshTools::writeOBJ(Info, internalPtB);
// Info<< "# externalPtD" << endl;
// meshTools::writeOBJ(Info, externalPtD);
// Info<< "# externalPtE" << endl;
// meshTools::writeOBJ(Info, externalPtE);
// scalar totalAngle = radToDeg
// (
// constant::mathematical::pi +
// acos(mag(concaveEdgePlaneANormal & concaveEdgePlaneBNormal))
// );
// if (totalAngle > cvMeshControls().maxQuadAngle())
// {
// // Add additional mitering points
// scalar angleSign = 1.0;
// if
// (
// geometryToConformTo_.outside
// (
// featPt - convexEdgesPlaneNormal*ppDist
// )
// )
// {
// angleSign = -1.0;
// }
// scalar phi =
// angleSign*acos(concaveEdgeDir & -convexEdgesPlaneNormal);
// scalar guard =
// (
// 1 + sin(phi)*ppDist/mag
// (
// concaveEdgeLocalFeatPt - concaveEdgeExternalPt
// )
// )/cos(phi) - 1;
// Foam::point internalPtF =
// concaveEdgeExternalPt
// + (2 + guard)*(concaveEdgeLocalFeatPt - concaveEdgeExternalPt);
// label internalPtFI =
// insertPoint(internalPtF, number_of_vertices() + 1);
// Foam::point externalPtG =
// internalPtF
// + 2*planeC.distance(internalPtF) * convexEdgesPlaneNormal;
// insertPoint(externalPtG, internalPtFI);
// }
// return true;
return false;
}
else if (nExternal == 1 && nInternal == 2)
{
// Info<< "nExternal == 1 && nInternal == 2" << endl;
return false;
}
return false;
}
// ************************************************************************* //

View File

@ -1,505 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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/>.
As a special exception, you have permission to link this program with the
CGAL library and distribute executables, as long as you follow the
requirements of the GNU GPL in regard to all of the software in the
executable aside from CGAL.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline Foam::scalar Foam::conformalVoronoiMesh::targetCellSize
(
const Foam::point& pt
) const
{
return cellSizeControl().cellSize(pt);
}
inline Foam::scalar Foam::conformalVoronoiMesh::averageCellSize
(
const Vertex_handle& vA,
const Vertex_handle& vB
) const
{
// Arithmetic mean
// return 0.5*(vA->targetCellSize() + vB->targetCellSize());
// Geometric mean
return sqrt(vA->targetCellSize()*vB->targetCellSize());
// Harmonic mean
// return
// 2.0*(vA->targetCellSize()*vB->targetCellSize())
// /(vA->targetCellSize() + vB->targetCellSize());
}
inline Foam::scalar Foam::conformalVoronoiMesh::averageAnyCellSize
(
const Vertex_handle& vA,
const Vertex_handle& vB
) const
{
if
(
!vA->internalOrBoundaryPoint()
&& !vB->internalOrBoundaryPoint()
)
{
// There are no internalOrBoundaryPoints available, determine
// size from scratch
// Geometric mean
return sqrt
(
targetCellSize(topoint(vA->point()))
*targetCellSize(topoint(vB->point()))
);
}
else if (!vB->internalOrBoundaryPoint())
{
return vA->targetCellSize();
}
else if (!vA->internalOrBoundaryPoint())
{
return vB->targetCellSize();
}
return averageCellSize(vA, vB);
}
inline Foam::scalar Foam::conformalVoronoiMesh::averageAnyCellSize
(
const Delaunay::Finite_facets_iterator& fit
) const
{
// Geometric mean
scalar sizeProduct = 1;
label nProducts = 0;
const Cell_handle c(fit->first);
const int oppositeVertex = fit->second;
for (label i = 0; i < 3; i++)
{
Vertex_handle v = c->vertex(vertex_triple_index(oppositeVertex, i));
if (v->internalOrBoundaryPoint())
{
sizeProduct *= v->targetCellSize();
nProducts++;
}
}
if (nProducts < 1)
{
// There are no internalOrBoundaryPoints available, determine
// size from scratch
for (label i = 0; i < 3; i++)
{
Vertex_handle v = c->vertex(vertex_triple_index(oppositeVertex, i));
sizeProduct *= targetCellSize(topoint(v->point()));
}
nProducts = 3;
}
return pow(sizeProduct, (1.0/nProducts));
}
inline Foam::scalar Foam::conformalVoronoiMesh::pointPairDistance
(
const Foam::point& pt
) const
{
return targetCellSize(pt)*cvMeshControls().pointPairDistanceCoeff();
}
inline Foam::scalar Foam::conformalVoronoiMesh::mixedFeaturePointDistance
(
const Foam::point& pt
) const
{
return
pointPairDistance(pt)
*cvMeshControls().mixedFeaturePointPPDistanceCoeff();
}
inline Foam::scalar Foam::conformalVoronoiMesh::featurePointExclusionDistanceSqr
(
const Foam::point& pt
) const
{
return
sqr
(
targetCellSize(pt)
*cvMeshControls().featurePointExclusionDistanceCoeff()
);
}
inline Foam::scalar Foam::conformalVoronoiMesh::featureEdgeExclusionDistanceSqr
(
const Foam::point& pt
) const
{
return
sqr
(
targetCellSize(pt)
*cvMeshControls().featureEdgeExclusionDistanceCoeff()
);
}
inline Foam::scalar Foam::conformalVoronoiMesh::surfaceSearchDistanceSqr
(
const Foam::point& pt
) const
{
return
sqr(targetCellSize(pt)*cvMeshControls().surfaceSearchDistanceCoeff());
}
inline Foam::scalar Foam::conformalVoronoiMesh::maxSurfaceProtrusion
(
const Foam::point& pt
) const
{
return targetCellSize(pt)*cvMeshControls().maxSurfaceProtrusionCoeff();
}
inline Foam::label Foam::conformalVoronoiMesh::insertPoint
(
const Foam::point& p,
const label type
)
{
return insertPoint(toPoint(p), type);
}
inline Foam::label Foam::conformalVoronoiMesh::insertPoint
(
const Point& P,
const label type
)
{
uint nVert = number_of_vertices();
Vertex_handle vh = insert(P);
if (nVert == number_of_vertices())
{
Pout << "Failed to insert point " << topoint(P) << endl;
}
else
{
vh->index() = nVert;
vh->type() = type;
}
return vh->index();
}
inline void Foam::conformalVoronoiMesh::insertPoint
(
const Foam::point& p,
const label index,
const label type
)
{
insertPoint(toPoint(p), index, type);
}
inline void Foam::conformalVoronoiMesh::insertPoint
(
const Point& P,
const label index,
const label type
)
{
uint nVert = number_of_vertices();
Vertex_handle vh = insert(P);
if (nVert == number_of_vertices())
{
Pout << "Failed to insert point " << topoint(P) << endl;
}
else
{
vh->index() = index;
vh->type() = type;
}
}
inline void Foam::conformalVoronoiMesh::insertPointPair
(
const scalar ppDist,
const Foam::point& surfPt,
const vector& n
)
{
Pout<< "insertPointPair is depricated, "
<< " it does not check parallel insertion." << endl;
vector ppDistn = ppDist*n;
label master = insertPoint
(
surfPt - ppDistn,
number_of_vertices() + 1
);
insertPoint(surfPt + ppDistn, master);
}
inline void Foam::conformalVoronoiMesh::createPointPair
(
const scalar ppDist,
const Foam::point& surfPt,
const vector& n,
DynamicList<Foam::point>& pts,
DynamicList<label>& indices,
DynamicList<label>& types
)
{
vector ppDistn = ppDist*n;
// Result when the points are eventually inserted.
// Add number_of_vertices() at insertion of first vertex to all numbers:
// pt index type
// surfPt - ppDistn 0 1
// surfPt + ppDistn 1 0
// Master, index = number_of_vertices(), type = number_of_vertices() + 1
pts.append(surfPt - ppDistn);
indices.append(0);
types.append(1);
// Slave, index = number_of_vertices()(new) + 1, type = index of master.
// This will be inserted after the master, so number_of_vertices() will
// have increased
pts.append(surfPt + ppDistn);
indices.append(0);
types.append(-1);
}
inline bool Foam::conformalVoronoiMesh::isBoundaryDualFace
(
const Delaunay::Finite_edges_iterator& eit
) const
{
Cell_handle c = eit->first;
Vertex_handle vA = c->vertex(eit->second);
Vertex_handle vB = c->vertex(eit->third);
// A dual face on the boundary will result from one Dv inside and
// one outside
return
(
(
vA->internalOrBoundaryPoint()
|| vB->internalOrBoundaryPoint()
)
&& (
!vA->internalOrBoundaryPoint()
|| !vB->internalOrBoundaryPoint()
)
);
}
inline Foam::List<Foam::label> Foam::conformalVoronoiMesh::processorsAttached
(
const Delaunay::Finite_facets_iterator& fit
) const
{
DynamicList<label> procsAttached(8);
const Cell_handle c1(fit->first);
const int oppositeVertex = fit->second;
const Cell_handle c2(c1->neighbor(oppositeVertex));
FixedList<label, 4> c1Procs(c1->processorsAttached());
FixedList<label, 4> c2Procs(c2->processorsAttached());
forAll(c1Procs, aPI)
{
if (findIndex(procsAttached, c1Procs[aPI] == -1))
{
procsAttached.append(c1Procs[aPI]);
}
if (findIndex(procsAttached, c2Procs[aPI] == -1))
{
procsAttached.append(c2Procs[aPI]);
}
}
return List<label>(procsAttached);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
#ifdef CGAL_INEXACT
inline Foam::conformalVoronoiMesh::pointFromPoint
Foam::conformalVoronoiMesh::topoint
(
const Point& P
) const
{
return reinterpret_cast<pointFromPoint>(P);
}
inline Foam::conformalVoronoiMesh::PointFrompoint
Foam::conformalVoronoiMesh::toPoint
(
const Foam::point& p
) const
{
return reinterpret_cast<PointFrompoint>(p);
}
#else
inline Foam::conformalVoronoiMesh::pointFromPoint
Foam::conformalVoronoiMesh::topoint
(
const Point& P
) const
{
return Foam::point
(
CGAL::to_double(P.x()),
CGAL::to_double(P.y()),
CGAL::to_double(P.z())
);
}
inline Foam::conformalVoronoiMesh::PointFrompoint
Foam::conformalVoronoiMesh::toPoint
(
const Foam::point& p
) const
{
return Point(p.x(), p.y(), p.z());
}
#endif
inline Foam::conformalVoronoiMesh::CGALVector
Foam::conformalVoronoiMesh::toCGALVector(const Foam::vector& v) const
{
return CGALVector(v.x(), v.y(), v.z());
}
inline const Foam::Time& Foam::conformalVoronoiMesh::time() const
{
return runTime_;
}
inline Foam::Random& Foam::conformalVoronoiMesh::rndGen() const
{
return rndGen_;
}
inline const Foam::searchableSurfaces&
Foam::conformalVoronoiMesh::allGeometry() const
{
return allGeometry_;
}
inline const Foam::conformationSurfaces&
Foam::conformalVoronoiMesh::geometryToConformTo() const
{
return geometryToConformTo_;
}
inline const Foam::backgroundMeshDecomposition&
Foam::conformalVoronoiMesh::decomposition() const
{
if (!Pstream::parRun())
{
FatalErrorIn
(
"inline const Foam::backgroundMeshDecomposition& "
"Foam::conformalVoronoiMesh::decomposition() const"
)
<< "The backgroundMeshDecomposition cannot be asked for in serial."
<< exit(FatalError) << endl;
}
return decomposition_();
}
inline const Foam::cellSizeControlSurfaces&
Foam::conformalVoronoiMesh::cellSizeControl() const
{
return cellSizeControl_;
}
inline const Foam::cvControls&
Foam::conformalVoronoiMesh::cvMeshControls() const
{
return cvMeshControls_;
}
// ************************************************************************* //

View File

@ -1,877 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "conformalVoronoiMesh.H"
#include "IOstreams.H"
#include "OFstream.H"
#include "pointMesh.H"
#include "pointFields.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::conformalVoronoiMesh::timeCheck
(
const string& description
) const
{
if (cvMeshControls().timeChecks())
{
Info<< nl << "--- [ cpuTime "
<< runTime_.elapsedCpuTime() << " s, "
<< "delta " << runTime_.cpuTimeIncrement()<< " s";
if (description != word::null)
{
Info<< ", " << description << " ";
}
else
{
Info<< " ";
}
Info<< "] --- " << endl;
memInfo m;
if (m.valid())
{
label mSize = m.size();
label mPeak = m.peak();
label mRss = m.rss();
if (Pstream::parRun())
{
labelList allMSize(Pstream::nProcs());
labelList allMPeak(Pstream::nProcs());
labelList allMRss(Pstream::nProcs());
allMSize[Pstream::myProcNo()] = mSize;
allMPeak[Pstream::myProcNo()] = mPeak;
allMRss[Pstream::myProcNo()] = mRss;
Pstream::gatherList(allMSize);
Pstream::gatherList(allMPeak);
Pstream::gatherList(allMRss);
Info<< "--- [ "
<< "mem (kB) " << tab
<< "size" << tab
<< "peak" << tab
<< "rss"
<< " ] --- " << endl;
forAll(allMSize, procI)
{
Info<< "--- [ "
<< procI << " " << tab
<< allMSize[procI] << tab
<< allMPeak[procI] << tab
<< allMRss[procI]
<< " ] --- " << endl;
}
Info<< "--- [ "
<< "sum " << tab
<< sum(allMSize) << tab
<< sum(allMPeak) << tab
<< sum(allMRss)
<< " ] --- " << endl;
}
else
{
Info<< "--- [ "
<< "mem size " << mSize << " kB, "
<< "mem peak " << mPeak << " kB, "
<< "mem rss " << mRss << " kB"
<< " ] --- " << endl;
}
}
}
}
void Foam::conformalVoronoiMesh::drawDelaunayCell
(
Ostream& os,
const Cell_handle& c,
label offset
) const
{
// Supply offset as tet number
offset *= 5;
os << "# cell index: " << label(c->cellIndex()) << endl;
os << "# circumradius "
<< mag(topoint(dual(c)) - topoint(c->vertex(0)->point()))
<< endl;
for (int i = 0; i < 4; i++)
{
os << "# index type: "
<< label(c->vertex(i)->index()) << " "
<< label(c->vertex(i)->type()) << endl;
meshTools::writeOBJ(os, topoint(c->vertex(i)->point()));
}
os << "f " << 1 + offset << " " << 3 + offset << " " << 2 + offset << nl
<< "f " << 2 + offset << " " << 3 + offset << " " << 4 + offset << nl
<< "f " << 1 + offset << " " << 4 + offset << " " << 3 + offset << nl
<< "f " << 1 + offset << " " << 2 + offset << " " << 4 + offset << endl;
os << "# cicumcentre " << endl;
meshTools::writeOBJ(os, topoint(dual(c)));
os << "l " << 1 + offset << " " << 5 + offset << endl;
}
void Foam::conformalVoronoiMesh::writePoints
(
const fileName& fName,
bool internalOnly
) const
{
OFstream str(runTime_.path()/fName);
Pout<< nl << "Writing points to " << str.name() << endl;
for
(
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
++vit
)
{
if (!internalOnly || vit->internalOrBoundaryPoint())
{
meshTools::writeOBJ(str, topoint(vit->point()));
}
}
}
void Foam::conformalVoronoiMesh::writePoints
(
const fileName& fName,
const List<Foam::point>& points
) const
{
if (points.size())
{
OFstream str(runTime_.path()/fName);
Pout<< nl << "Writing " << points.size() << " points from pointList to "
<< str.name() << endl;
forAll(points, p)
{
meshTools::writeOBJ(str, points[p]);
}
}
}
void Foam::conformalVoronoiMesh::writeInternalDelaunayVertices
(
const fileName& instance
) const
{
pointField internalDelaunayVertices(number_of_vertices());
label vertI = 0;
for
(
Delaunay::Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
++vit
)
{
if (vit->internalPoint())
{
internalDelaunayVertices[vertI++] = topoint(vit->point());
}
}
internalDelaunayVertices.setSize(vertI);
pointIOField internalDVs
(
IOobject
(
"internalDelaunayVertices",
instance,
runTime_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
internalDelaunayVertices
);
Info<< nl
<< "Writing " << internalDVs.name()
<< " to " << internalDVs.instance()
<< endl;
internalDVs.write();
}
void Foam::conformalVoronoiMesh::writeMesh
(
const fileName& instance,
bool filterFaces
)
{
writeInternalDelaunayVertices(instance);
// Per cell the Delaunay vertex
labelList cellToDelaunayVertex;
// Per patch, per face the Delaunay vertex
labelListList patchToDelaunayVertex;
// Per patch the start of the dual faces
labelList dualPatchStarts;
{
pointField points;
faceList faces;
labelList owner;
labelList neighbour;
wordList patchTypes;
wordList patchNames;
labelList patchSizes;
labelList procNeighbours;
pointField cellCentres;
calcDualMesh
(
points,
faces,
owner,
neighbour,
patchTypes,
patchNames,
patchSizes,
dualPatchStarts,
procNeighbours,
cellCentres,
cellToDelaunayVertex,
patchToDelaunayVertex,
filterFaces
);
Info<< nl << "Writing polyMesh to " << instance << endl;
writeMesh
(
Foam::polyMesh::defaultRegion,
instance,
points,
faces,
owner,
neighbour,
patchTypes,
patchNames,
patchSizes,
dualPatchStarts,
procNeighbours,
cellCentres
);
}
if (cvMeshControls().writeTetDualMesh())
{
// Determine map from Delaunay vertex to Dual mesh
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// From all Delaunay vertices to cell (positive index)
// or patch face (negative index)
labelList vertexToDualAddressing(number_of_vertices(), 0);
forAll(cellToDelaunayVertex, cellI)
{
label vertI = cellToDelaunayVertex[cellI];
if (vertexToDualAddressing[vertI] != 0)
{
FatalErrorIn("conformalVoronoiMesh::writeMesh(..)")
<< "Delaunay vertex " << vertI
<< " from cell " << cellI
<< " is already mapped to "
<< vertexToDualAddressing[vertI]
<< exit(FatalError);
}
vertexToDualAddressing[vertI] = cellI+1;
}
forAll(patchToDelaunayVertex, patchI)
{
const labelList& patchVertices = patchToDelaunayVertex[patchI];
forAll(patchVertices, i)
{
label vertI = patchVertices[i];
if (vertexToDualAddressing[vertI] > 0)
{
FatalErrorIn("conformalVoronoiMesh::writeMesh(..)")
<< "Delaunay vertex " << vertI
<< " from patch " << patchI
<< " local index " << i
<< " is already mapped to cell "
<< vertexToDualAddressing[vertI]-1
<< exit(FatalError);
}
// Vertex might be used by multiple faces. Which one to
// use? For now last one wins.
label dualFaceI = dualPatchStarts[patchI]+i;
vertexToDualAddressing[vertI] = -dualFaceI-1;
}
}
// Calculate tet mesh addressing
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pointField points;
// From tet point back to Delaunay vertex index
labelList pointToDelaunayVertex;
faceList faces;
labelList owner;
labelList neighbour;
wordList patchTypes;
wordList patchNames;
labelList patchSizes;
labelList patchStarts;
pointField cellCentres;
calcTetMesh
(
points,
pointToDelaunayVertex,
faces,
owner,
neighbour,
patchTypes,
patchNames,
patchSizes,
patchStarts
);
// Calculate map from tet points to dual mesh cells/patch faces
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
labelIOList pointDualAddressing
(
IOobject
(
"pointDualAddressing",
instance,
"tetDualMesh"/polyMesh::meshSubDir,
runTime_,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
false
),
UIndirectList<label>
(
vertexToDualAddressing,
pointToDelaunayVertex
)()
);
label pointI = findIndex(pointDualAddressing, -1);
if (pointI != -1)
{
WarningIn
(
"conformalVoronoiMesh::writeMesh\n"
"(\n"
" const fileName& instance,\n"
" bool filterFaces\n"
")\n"
) << "Delaunay vertex " << pointI
<< " does not have a corresponding dual cell." << endl;
}
Info<< "Writing map from tetDualMesh points to Voronoi mesh to "
<< pointDualAddressing.objectPath() << endl;
pointDualAddressing.write();
// Write tet points corresponding to the Voronoi cell/face centre
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
// Read Voronoi mesh
fvMesh mesh
(
IOobject
(
Foam::polyMesh::defaultRegion,
instance,
runTime_,
IOobject::MUST_READ
)
);
pointIOField dualPoints
(
IOobject
(
"dualPoints",
instance,
"tetDualMesh"/polyMesh::meshSubDir,
runTime_,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
false
),
points
);
forAll(pointDualAddressing, pointI)
{
label index = pointDualAddressing[pointI];
if (index > 0)
{
label cellI = index-1;
dualPoints[pointI] = mesh.cellCentres()[cellI];
}
else if (index < 0)
{
label faceI = -index-1;
if (faceI >= mesh.nInternalFaces())
{
dualPoints[pointI] = mesh.faceCentres()[faceI];
}
}
}
Info<< "Writing new tetDualMesh points mapped onto Voronoi mesh to "
<< dualPoints.objectPath() << endl
<< "Replace the polyMesh/points with these." << endl;
dualPoints.write();
}
labelList procNeighbours(patchNames.size(), -1);
Info<< nl << "Writing tetDualMesh to " << instance << endl;
writeMesh
(
"tetDualMesh",
instance,
points,
faces,
owner,
neighbour,
patchTypes,
patchNames,
patchSizes,
patchStarts,
procNeighbours,
cellCentres
);
}
}
void Foam::conformalVoronoiMesh::writeMesh
(
const word& meshName,
const fileName& instance,
pointField& points,
faceList& faces,
labelList& owner,
labelList& neighbour,
const wordList& patchTypes,
const wordList& patchNames,
const labelList& patchSizes,
const labelList& patchStarts,
const labelList& procNeighbours,
const pointField& cellCentres
) const
{
if (cvMeshControls().objOutput())
{
writeObjMesh(points, faces, word(meshName + ".obj"));
}
fvMesh mesh
(
IOobject
(
meshName,
instance,
runTime_,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
xferMove(points),
xferMove(faces),
xferMove(owner),
xferMove(neighbour)
);
List<polyPatch*> patches(patchStarts.size());
label nValidPatches = 0;
forAll(patches, p)
{
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,
mesh.boundaryMesh(),
Pstream::myProcNo(),
procNeighbours[p]
);
nValidPatches++;
}
}
else
{
patches[nValidPatches] = polyPatch::New
(
patchTypes[p],
patchNames[p],
patchSizes[p],
patchStarts[p],
nValidPatches,
mesh.boundaryMesh()
).ptr();
nValidPatches++;
}
}
patches.setSize(nValidPatches);
mesh.addFvPatches(patches);
if (!mesh.write())
{
FatalErrorIn("Foam::conformalVoronoiMesh::writeMesh(..)")
<< "Failed writing polyMesh."
<< exit(FatalError);
}
// pointIOField cellCs
// (
// IOobject
// (
// "cellCentres",
// mesh.pointsInstance(),
// polyMesh::meshSubDir,
// mesh,
// IOobject::NO_READ,
// IOobject::AUTO_WRITE
// ),
// cellCentres
// );
// Info<< nl
// << "Writing " << cellCs.name()
// << " to " << cellCs.instance()
// << endl;
// cellCs.write();
writeCellSizes(mesh);
findRemainingProtrusionSet(mesh);
}
void Foam::conformalVoronoiMesh::writeObjMesh
(
const pointField& points,
const faceList& faces,
const fileName& fName
) const
{
OFstream str(runTime_.path()/fName);
Pout<< nl << "Writing points and faces to " << str.name() << endl;
forAll(points, p)
{
meshTools::writeOBJ(str, points[p]);
}
forAll(faces, f)
{
str<< 'f';
const face& fP = faces[f];
forAll(fP, p)
{
str<< ' ' << fP[p] + 1;
}
str<< nl;
}
}
void Foam::conformalVoronoiMesh::writeCellSizes
(
const fvMesh& mesh
) const
{
{
timeCheck("Start writeCellSizes");
Info<< nl << "Create targetCellSize volScalarField" << endl;
volScalarField targetCellSize
(
IOobject
(
"targetCellSize",
mesh.polyMesh::instance(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("cellSize", dimLength, 0),
zeroGradientFvPatchScalarField::typeName
);
scalarField& cellSize = targetCellSize.internalField();
const vectorField& C = mesh.cellCentres();
forAll(cellSize, i)
{
cellSize[i] = cellSizeControl().cellSize(C[i]);
}
// Info<< nl << "Create targetCellVolume volScalarField" << endl;
// volScalarField targetCellVolume
// (
// IOobject
// (
// "targetCellVolume",
// mesh.polyMesh::instance(),
// mesh,
// IOobject::NO_READ,
// IOobject::AUTO_WRITE
// ),
// mesh,
// dimensionedScalar("cellVolume", dimLength, 0),
// zeroGradientFvPatchScalarField::typeName
// );
// targetCellVolume.internalField() = pow3(cellSize);
// Info<< nl << "Create actualCellVolume volScalarField" << endl;
// volScalarField actualCellVolume
// (
// IOobject
// (
// "actualCellVolume",
// mesh.polyMesh::instance(),
// mesh,
// IOobject::NO_READ,
// IOobject::AUTO_WRITE
// ),
// mesh,
// dimensionedScalar("cellVolume", dimVolume, 0),
// zeroGradientFvPatchScalarField::typeName
// );
// actualCellVolume.internalField() = mesh.cellVolumes();
// Info<< nl << "Create equivalentCellSize volScalarField" << endl;
// volScalarField equivalentCellSize
// (
// IOobject
// (
// "equivalentCellSize",
// mesh.polyMesh::instance(),
// mesh,
// IOobject::NO_READ,
// IOobject::AUTO_WRITE
// ),
// mesh,
// dimensionedScalar("cellSize", dimLength, 0),
// zeroGradientFvPatchScalarField::typeName
// );
// equivalentCellSize.internalField() = pow
// (
// actualCellVolume.internalField(),
// 1.0/3.0
// );
targetCellSize.correctBoundaryConditions();
// targetCellVolume.correctBoundaryConditions();
// actualCellVolume.correctBoundaryConditions();
// equivalentCellSize.correctBoundaryConditions();
targetCellSize.write();
// targetCellVolume.write();
// actualCellVolume.write();
// equivalentCellSize.write();
}
// {
// polyMesh tetMesh
// (
// IOobject
// (
// "tetDualMesh",
// runTime_.constant(),
// runTime_,
// IOobject::MUST_READ
// )
// );
// pointMesh ptMesh(tetMesh);
// pointScalarField ptTargetCellSize
// (
// IOobject
// (
// "ptTargetCellSize",
// runTime_.timeName(),
// tetMesh,
// IOobject::NO_READ,
// IOobject::AUTO_WRITE
// ),
// ptMesh,
// dimensionedScalar("ptTargetCellSize", dimLength, 0),
// pointPatchVectorField::calculatedType()
// );
// scalarField& cellSize = ptTargetCellSize.internalField();
// const vectorField& P = tetMesh.points();
// forAll(cellSize, i)
// {
// cellSize[i] = cellSizeControl().cellSize(P[i]);
// }
// ptTargetCellSize.write();
// }
}
void Foam::conformalVoronoiMesh::findRemainingProtrusionSet
(
const fvMesh& mesh
) const
{
timeCheck("Start findRemainingProtrusionSet");
const polyBoundaryMesh& patches = mesh.boundaryMesh();
labelHashSet protrudingBoundaryPoints;
forAll(patches, patchI)
{
const polyPatch& patch = patches[patchI];
forAll(patch.localPoints(), pLPI)
{
label meshPtI = patch.meshPoints()[pLPI];
const Foam::point& pt = patch.localPoints()[pLPI];
if
(
geometryToConformTo_.wellOutside
(
pt,
sqr(targetCellSize(pt))
)
)
{
protrudingBoundaryPoints.insert(meshPtI);
}
}
}
cellSet protrudingCells
(
mesh,
"cvMesh_remainingProtrusions",
mesh.nCells()/1000
);
forAllConstIter(labelHashSet, protrudingBoundaryPoints, iter)
{
const label pointI = iter.key();
const labelList& pCells = mesh.pointCells()[pointI];
forAll(pCells, pCI)
{
protrudingCells.insert(pCells[pCI]);
}
}
label protrudingCellsSize = protrudingCells.size();
reduce(protrudingCellsSize, sumOp<label>());
if (protrudingCellsSize > 0)
{
Info<< nl << "Found " << protrudingCellsSize
<< " cells protruding from the surface, writing cellSet "
<< protrudingCells.name()
<< endl;
protrudingCells.write();
}
}
// ************************************************************************* //

View File

@ -1,55 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 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/>.
As a special exception, you have permission to link this program with the
CGAL library and distribute executables, as long as you follow the
requirements of the GNU GPL in regard to all of the software in the
executable aside from CGAL.
\*---------------------------------------------------------------------------*/
#include "indexedCell.H"
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
template<class Gt, class Cb>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const InfoProxy<CGAL::indexedCell<Gt, Cb> >& p
)
{
const CGAL::indexedCell<Gt, Cb>& iv = p.t_;
os << "Cell : index:" << iv.index_ << " filterCount:" << iv.filterCount_
<< nl;
os << " " << iv.vertex(0)->info();
os << " " << iv.vertex(1)->info();
os << " " << iv.vertex(2)->info();
os << " " << iv.vertex(3)->info();
return os;
}
// ************************************************************************* //

View File

@ -1,398 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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/>.
As a special exception, you have permission to link this program with the
CGAL library and distribute executables, as long as you follow the
requirements of the GNU GPL in regard to all of the software in the
executable aside from CGAL.
Class
indexedCell
Description
An indexed form of CGAL::Triangulation_cell_base_3<K> used to keep
track of the Delaunay cells (tets) in the tessellation.
\*---------------------------------------------------------------------------*/
#ifndef indexedCell_H
#define indexedCell_H
#include <CGAL/Triangulation_3.h>
#include <CGAL/Triangulation_cell_base_with_circumcenter_3.h>
#include "indexedVertex.H"
#include "List.H"
#include "globalIndex.H"
#include "Pstream.H"
#include "Swap.H"
#include "InfoProxy.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace CGAL
{
template<class Gt, class Cb> class indexedCell;
}
namespace Foam
{
class Ostream;
template<class Gt, class Cb> Ostream& operator<<
(
Ostream&,
const Foam::InfoProxy<CGAL::indexedCell<Gt, Cb> >&
);
}
namespace CGAL
{
/*---------------------------------------------------------------------------*\
Class indexedCell Declaration
\*---------------------------------------------------------------------------*/
template
<
class Gt,
class Cb=CGAL::Triangulation_cell_base_with_circumcenter_3<Gt>
>
class indexedCell
:
public Cb
{
// Private data
//- The index for this Delaunay tetrahedral cell. Type information is
//- also carried:
// ctFar : the dual point of this cell does not form part of the
// internal or boundary of the dual mesh
// >=0 : the (local) index of an internal or boundary dual point,
// not on a processor face
// < 0 && > ctFar : the (global) index of a dual point on a processor
// face
int index_;
//- The number of times that this Delaunay cell has been limited
// during filtering
int filterCount_;
public:
enum cellTypes
{
ctFar = INT_MIN
};
typedef typename Cb::Vertex_handle Vertex_handle;
typedef typename Cb::Cell_handle Cell_handle;
template < typename TDS2 >
struct Rebind_TDS
{
typedef typename Cb::template Rebind_TDS<TDS2>::Other Cb2;
typedef indexedCell<Gt, Cb2> Other;
};
indexedCell()
:
Cb(),
index_(ctFar),
filterCount_(0)
{}
indexedCell
(
Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, Vertex_handle v3
)
:
Cb(v0, v1, v2, v3),
index_(ctFar),
filterCount_(0)
{}
indexedCell
(
Vertex_handle v0,
Vertex_handle v1,
Vertex_handle v2,
Vertex_handle v3,
Cell_handle n0,
Cell_handle n1,
Cell_handle n2,
Cell_handle n3
)
:
Cb(v0, v1, v2, v3, n0, n1, n2, n3),
index_(ctFar),
filterCount_(0)
{}
int& cellIndex()
{
return index_;
}
int cellIndex() const
{
return index_;
}
inline bool farCell() const
{
return index_ == ctFar;
}
inline int& filterCount()
{
return filterCount_;
}
inline int filterCount() const
{
return filterCount_;
}
//- Is the Delaunay cell real, i.e. any real vertex
inline bool real() const
{
return
(
this->vertex(0)->real()
|| this->vertex(1)->real()
|| this->vertex(2)->real()
|| this->vertex(3)->real()
);
}
//- Does the Dual vertex form part of a processor patch
inline bool parallelDualVertex() const
{
return
(
this->vertex(0)->referred()
|| this->vertex(1)->referred()
|| this->vertex(2)->referred()
|| this->vertex(3)->referred()
);
}
//- Does the Dual vertex form part of a processor patch
inline Foam::label dualVertexMasterProc() const
{
if (!parallelDualVertex())
{
return -1;
}
// The master processor is the lowest numbered of the four on this tet.
int masterProc = Foam::Pstream::nProcs() + 1;
for (int i = 0; i < 4; i++)
{
if (this->vertex(i)->referred())
{
masterProc = min(masterProc, this->vertex(i)->procIndex());
}
else
{
masterProc = min(masterProc, Foam::Pstream::myProcNo());
}
}
return masterProc;
}
inline Foam::FixedList<Foam::label, 4> processorsAttached() const
{
if (!parallelDualVertex())
{
return Foam::FixedList<Foam::label, 4>(Foam::Pstream::myProcNo());
}
Foam::FixedList<Foam::label, 4> procsAttached
(
Foam::Pstream::myProcNo()
);
for (int i = 0; i < 4; i++)
{
if (this->vertex(i)->referred())
{
procsAttached[i] = this->vertex(i)->procIndex();
}
}
return procsAttached;
}
// Using the globalIndex object, return a list of four (sorted) global
// Delaunay vertex indices that uniquely identify this tet in parallel
inline Foam::FixedList<Foam::label, 4> vertexGlobalIndices
(
const Foam::globalIndex& globalDelaunayVertexIndices
) const
{
// tetVertexGlobalIndices
Foam::FixedList<Foam::label, 4> tVGI(-1);
for (int i = 0; i < 4; i++)
{
Vertex_handle v = this->vertex(i);
// Finding the global index of each Delaunay vertex
if (v->referred())
{
// Referred vertices may have negative indices
tVGI[i] = globalDelaunayVertexIndices.toGlobal
(
v->procIndex(),
Foam::mag(v->index())
);
}
else
{
tVGI[i] = globalDelaunayVertexIndices.toGlobal
(
Foam::Pstream::myProcNo(),
v->index()
);
}
}
// bubble sort
for (int i = 0; i < tVGI.size(); i++)
{
for (int j = tVGI.size() - 1 ; j > i; j--)
{
if (tVGI[j - 1] > tVGI[j])
{
Foam::Swap(tVGI[j - 1], tVGI[j]);
}
}
}
return tVGI;
}
// Is the Delaunay cell part of the final dual mesh, i.e. any vertex form
// part of the internal or boundary definition
inline bool internalOrBoundaryDualVertex() const
{
return
(
this->vertex(0)->internalOrBoundaryPoint()
|| this->vertex(1)->internalOrBoundaryPoint()
|| this->vertex(2)->internalOrBoundaryPoint()
|| this->vertex(3)->internalOrBoundaryPoint()
);
}
// Is the Delaunay cell real or referred (or mixed), i.e. all vertices form
// part of the real or referred internal or boundary definition
inline bool anyInternalOrBoundaryDualVertex() const
{
return
(
this->vertex(0)->anyInternalOrBoundaryPoint()
|| this->vertex(1)->anyInternalOrBoundaryPoint()
|| this->vertex(2)->anyInternalOrBoundaryPoint()
|| this->vertex(3)->anyInternalOrBoundaryPoint()
);
}
// A dual vertex on the boundary will result from a Delaunay cell with
// least one Delaunay vertex outside and at least one inside
inline bool boundaryDualVertex() const
{
return
(
(
this->vertex(0)->internalOrBoundaryPoint()
|| this->vertex(1)->internalOrBoundaryPoint()
|| this->vertex(2)->internalOrBoundaryPoint()
|| this->vertex(3)->internalOrBoundaryPoint()
)
&& (
!this->vertex(0)->internalOrBoundaryPoint()
|| !this->vertex(1)->internalOrBoundaryPoint()
|| !this->vertex(2)->internalOrBoundaryPoint()
|| !this->vertex(3)->internalOrBoundaryPoint()
)
);
}
// Info
//- Return info proxy.
// Used to print indexedCell information to a stream
Foam::InfoProxy<indexedCell<Gt, Cb> > info() const
{
return *this;
}
friend Foam::Ostream& Foam::operator<< <Gt, Cb>
(
Foam::Ostream&,
const Foam::InfoProxy<indexedCell<Gt, Cb> >&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace CGAL
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "indexedCell.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,116 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 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/>.
As a special exception, you have permission to link this program with the
CGAL library and distribute executables, as long as you follow the
requirements of the GNU GPL in regard to all of the software in the
executable aside from CGAL.
\*---------------------------------------------------------------------------*/
#include "indexedVertex.H"
//#include "conformalVoronoiMesh.H"
#include "point.H"
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
template<class Gt, class Vb>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const InfoProxy<CGAL::indexedVertex<Gt, Vb> >& p
)
{
const CGAL::indexedVertex<Gt, Vb>& iv = p.t_;
if (iv.type_ == CGAL::indexedVertex<Gt, Vb>::vtNearBoundary)
{
os << "internal near boundary point" << nl;
}
else if (iv.type_ == CGAL::indexedVertex<Gt, Vb>::vtInternal)
{
os << "internal point" << nl;
}
else if (iv.type_ == CGAL::indexedVertex<Gt, Vb>::vtFar)
{
os << "far point" << nl;
}
else if (iv.type_ > CGAL::indexedVertex<Gt, Vb>::vtFar && iv.type_ < 0)
{
if (iv.index_ >= 0)
{
os << "referred (master) point from processor " << iv.procIndex()
<< nl;
}
else
{
os << "referred (slave) point from processor " << iv.procIndex()
<< nl;
}
}
else if (iv.type_ >= 0)
{
if (iv.ppMaster())
{
os << "master of point pair. paired up with point " << iv.index_
<< nl;
}
else if (iv.ppSlave())
{
os << "slave of point pair. paired up with point " << iv.index_
<< nl;
}
else
{
FatalErrorIn
(
"operator<<"
"(Ostream&, const InfoProxy<CGAL::indexedVertex<Gt, Vb> >&)"
) << "unhandled type " << iv.type_ << " index " << iv.index_
<< abort(FatalError);
}
}
else
{
FatalErrorIn
(
"operator<<"
"(Ostream&, const InfoProxy<CGAL::indexedVertex<Gt, Vb> >&)"
) << "unhandled type " << iv.type_ << " index " << iv.index_
<< abort(FatalError);
}
const Foam::point pos
(
CGAL::to_double(iv.point().x()),
CGAL::to_double(iv.point().y()),
CGAL::to_double(iv.point().z())
);
os << " type:" << iv.type_ << " index:" << iv.index_
<< " at:" << pos << nl;
return os;
}
// ************************************************************************* //

View File

@ -1,425 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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/>.
As a special exception, you have permission to link this program with the
CGAL library and distribute executables, as long as you follow the
requirements of the GNU GPL in regard to all of the software in the
executable aside from CGAL.
Class
indexedVertex
Description
An indexed form of CGAL::Triangulation_vertex_base_3<K> used to keep
track of the Delaunay vertices in the tessellation.
\*---------------------------------------------------------------------------*/
#ifndef indexedVertex_H
#define indexedVertex_H
#include <CGAL/Triangulation_3.h>
#include "tensor.H"
#include "InfoProxy.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace CGAL
{
template<class Gt, class Vb> class indexedVertex;
}
namespace Foam
{
class Ostream;
template<class Gt, class Vb> Ostream& operator<<
(
Ostream&,
const Foam::InfoProxy<CGAL::indexedVertex<Gt, Vb> >&
);
}
namespace CGAL
{
/*---------------------------------------------------------------------------*\
Class indexedVertex Declaration
\*---------------------------------------------------------------------------*/
template<class Gt, class Vb=CGAL::Triangulation_vertex_base_3<Gt> >
class indexedVertex
:
public Vb
{
// Private data
//- The index for this Delaunay vertex. For referred vertices, the
// index is negative for vertices that are the outer (slave) of point
// pairs
int index_;
//- type of pair-point :
// vtNearBoundary : internal near boundary point.
// vtInternal : internal point.
// vtFar : far-point.
// > vtFar, < 0 : referred point from processor -(type_ + 1)
// >= 0 : part of point-pair. Index of other point.
// Lowest numbered is inside one (master).
int type_;
// Required alignment of the dual cell of this vertex
Foam::tensor alignment_;
// Target size of the dual cell of this vertex
Foam::scalar targetCellSize_;
public:
enum vertexTypes
{
vtNearBoundary = INT_MIN,
vtInternal = INT_MIN + 1,
vtFar = INT_MIN + 2
};
typedef typename Vb::Vertex_handle Vertex_handle;
typedef typename Vb::Cell_handle Cell_handle;
typedef typename Vb::Point Point;
template<typename TDS2>
struct Rebind_TDS
{
typedef typename Vb::template Rebind_TDS<TDS2>::Other Vb2;
typedef indexedVertex<Gt,Vb2> Other;
};
indexedVertex()
:
Vb(),
index_(vtInternal),
type_(vtInternal),
alignment_(),
targetCellSize_(0.0)
{}
indexedVertex(const Point& p)
:
Vb(p),
index_(vtInternal),
type_(vtInternal),
alignment_(),
targetCellSize_(0.0)
{}
indexedVertex(const Point& p, int index, int type)
:
Vb(p),
index_(index),
type_(type),
alignment_(),
targetCellSize_(0.0)
{}
indexedVertex(const Point& p, Cell_handle f)
:
Vb(f, p),
index_(vtInternal),
type_(vtInternal),
alignment_(),
targetCellSize_(0.0)
{}
indexedVertex(Cell_handle f)
:
Vb(f),
index_(vtInternal),
type_(vtInternal),
alignment_(),
targetCellSize_(0.0)
{}
int& index()
{
return index_;
}
int index() const
{
return index_;
}
int& type()
{
return type_;
}
int type() const
{
return type_;
}
inline Foam::tensor& alignment()
{
return alignment_;
}
inline const Foam::tensor& alignment() const
{
return alignment_;
}
inline Foam::scalar& targetCellSize()
{
return targetCellSize_;
}
inline Foam::scalar targetCellSize() const
{
return targetCellSize_;
}
inline bool uninitialised() const
{
return type_ == vtInternal && index_ == vtInternal;
}
//- Is point a far-point
inline bool farPoint() const
{
return type_ == vtFar;
}
//- Is point internal, i.e. not on boundary
inline bool internalPoint() const
{
return internalPoint(type_);
}
//- Is point internal, i.e. not on boundary, external query.
inline static bool internalPoint(int type)
{
return type <= vtInternal;
}
// is this a referred vertex
inline bool referred() const
{
return (type_ < 0 && type_ > vtFar);
}
// is this a referred internal or boundary vertex
inline bool referredInternalOrBoundaryPoint() const
{
return referred() && index_ >= 0;
}
// is this a referred external (pair slave) vertex
inline bool referredExternal() const
{
return referred() && index_ < 0;
}
// is this a "real" point on this processor, i.e. is it internal or part of
// the boundary description, and not a "far" or "referred" point
inline bool real() const
{
return internalPoint() || pairPoint();
}
// For referred vertices, what is the original processor index
inline int procIndex() const
{
if (referred())
{
return -(type_ + 1);
}
else
{
return -1;
}
}
inline static int encodeProcIndex(int procI)
{
return -(procI + 1);
}
//- Set the point to be internal
inline void setInternal()
{
type_ = vtInternal;
}
//- Is point internal and near the boundary
inline bool nearBoundary() const
{
return type_ == vtNearBoundary;
}
//- Set the point to be near the boundary
inline void setNearBoundary()
{
type_ = vtNearBoundary;
}
//- Either master or slave of pointPair.
inline bool pairPoint() const
{
return type_ >= 0;
}
//- Master of a pointPair is the lowest numbered one.
inline bool ppMaster() const
{
return ppMaster(index_, type_);
}
//- Master of a pointPair is the lowest numbered one, external query.
inline static bool ppMaster(int index, int type)
{
if (index >= 0 && type > index)
{
return true;
}
return false;
}
//- Slave of a pointPair is the highest numbered one.
inline bool ppSlave() const
{
if (type_ >= 0 && type_ < index_)
{
return true;
}
else
{
return false;
}
}
//- Either original internal point or master of pointPair.
inline bool internalOrBoundaryPoint() const
{
return internalOrBoundaryPoint(index_, type_);
}
//- Either original internal point or master of pointPair, external query.
inline static bool internalOrBoundaryPoint(int index, int type)
{
return internalPoint(type) || ppMaster(index, type);
}
//- Is point near the boundary or part of the boundary definition
inline bool nearOrOnBoundary() const
{
return pairPoint() || nearBoundary();
}
//- Either a real or referred internal or boundary point
inline bool anyInternalOrBoundaryPoint() const
{
return internalOrBoundaryPoint() || referredInternalOrBoundaryPoint();
}
// inline void operator=(const Delaunay::Finite_vertices_iterator vit)
// {
// Vb::operator=indexedVertex(vit->point());
// this->index_ = vit->index();
// this->type_ = vit->type();
// }
// Info
//- Return info proxy.
// Used to print indexedVertex information to a stream
Foam::InfoProxy<indexedVertex<Gt, Vb> > info() const
{
return *this;
}
friend Foam::Ostream& Foam::operator<< <Gt, Vb>
(
Foam::Ostream&,
const Foam::InfoProxy<indexedVertex<Gt, Vb> >&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace CGAL
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "indexedVertex.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,819 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "conformationSurfaces.H"
#include "conformalVoronoiMesh.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::conformationSurfaces::conformationSurfaces
(
const conformalVoronoiMesh& cvMesh,
const searchableSurfaces& allGeometry,
const dictionary& surfaceConformationDict
)
:
cvMesh_(cvMesh),
allGeometry_(allGeometry),
features_(),
locationInMesh_(surfaceConformationDict.lookup("locationInMesh")),
surfaces_(),
allGeometryToSurfaces_(),
baffleSurfaces_(),
patchNames_(0),
patchOffsets_(),
globalBounds_(),
referenceVolumeTypes_(0)
{
const dictionary& surfacesDict
(
surfaceConformationDict.subDict("geometryToConformTo")
);
const dictionary& additionalFeaturesDict
(
surfaceConformationDict.subDict("additionalFeatures")
);
Info<< nl << "Reading geometryToConformTo" << endl;
surfaces_.setSize(surfacesDict.size(), -1);
allGeometryToSurfaces_.setSize(allGeometry_.size(), -1);
baffleSurfaces_.setSize(surfacesDict.size(), false);
// Features may be attached to host surfaces or independent
features_.setSize(surfacesDict.size() + additionalFeaturesDict.size());
label featureI = 0;
patchOffsets_.setSize(surfacesDict.size(), -1);
label surfI = 0;
forAllConstIter(dictionary, surfacesDict, iter)
{
word surfaceName = iter().keyword();
surfaces_[surfI] = allGeometry_.findSurfaceID(surfaceName);
allGeometryToSurfaces_[surfaces_[surfI]] = surfI;
if (surfaces_[surfI] < 0)
{
FatalErrorIn("Foam::conformationSurfaces::conformationSurfaces")
<< "No surface " << iter().keyword() << " found. "
<< "Valid geometry is " << nl << allGeometry_.names()
<< exit(FatalError);
}
Info<< nl << " " << iter().keyword() << endl;
patchOffsets_[surfI] = patchNames_.size();
patchNames_.append(allGeometry.regionNames()[surfaces_[surfI]]);
const dictionary& surfaceSubDict(surfacesDict.subDict(surfaceName));
baffleSurfaces_[surfI] = Switch
(
surfaceSubDict.lookupOrDefault("baffleSurface", false)
);
if (!baffleSurfaces_[surfI])
{
if (!allGeometry_[surfaces_[surfI]].hasVolumeType())
{
WarningIn("conformationSurfaces::conformationSurfaces(..)")
<< "Non-baffle surface "
<< allGeometry_[surfaces_[surfI]].name()
<< " does not allow inside/outside queries."
<< " This usually is an error." << endl;
}
}
word featureMethod = surfaceSubDict.lookupOrDefault
(
"featureMethod",
word("none")
);
if (featureMethod == "extendedFeatureEdgeMesh")
{
fileName feMeshName
(
surfaceSubDict.lookup("extendedFeatureEdgeMesh")
);
Info<< " features: " << feMeshName<< endl;
features_.set
(
featureI++,
new extendedFeatureEdgeMesh
(
IOobject
(
feMeshName,
cvMesh_.time().constant(),
"extendedFeatureEdgeMesh",
cvMesh_.time(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
}
else if (featureMethod == "extractFeatures")
{
notImplemented
(
"conformationSurfaces::conformationSurfaces, "
"else if (featureMethod == \"extractFeatures\")"
);
}
else if (featureMethod == "none")
{
// Currently nothing to do
}
else
{
FatalErrorIn("Foam::conformationSurfaces::conformationSurfaces")
<< "No valid featureMethod found for surface " << surfaceName
<< nl << "Use \"extendedFeatureEdgeMesh\" "
<< "or \"extractFeatures\"."
<< exit(FatalError);
}
surfI++;
}
if (!additionalFeaturesDict.empty())
{
Info<< nl << "Reading additionalFeatures" << endl;
}
forAllConstIter(dictionary, additionalFeaturesDict, iter)
{
word featureName = iter().keyword();
Info<< nl << " " << iter().keyword() << endl;
const dictionary& featureSubDict
(
additionalFeaturesDict.subDict(featureName)
);
word featureMethod = featureSubDict.lookupOrDefault
(
"featureMethod",
word("none")
);
if (featureMethod == "extendedFeatureEdgeMesh")
{
fileName feMeshName
(
featureSubDict.lookup("extendedFeatureEdgeMesh")
);
Info<< " features: " << feMeshName << endl;
features_.set
(
featureI++,
new extendedFeatureEdgeMesh
(
IOobject
(
feMeshName,
cvMesh_.time().constant(),
"extendedFeatureEdgeMesh",
cvMesh_.time(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
);
}
}
// Remove unnecessary space from the features list
features_.setSize(featureI);
globalBounds_ = treeBoundBox
(
searchableSurfacesQueries::bounds(allGeometry_, surfaces_)
);
// Extend the global bounds to stop the bound box sitting on the surfaces
// to be conformed to
globalBounds_ = globalBounds_.extend(cvMesh_.rndGen(), 1e-4);
// Look at all surfaces at determine whether the locationInMesh point is
// inside or outside each, to establish a signature for the domain to be
// meshed.
referenceVolumeTypes_.setSize
(
surfaces_.size(),
searchableSurface::UNKNOWN
);
Info<< endl
<< "Testing for locationInMesh " << locationInMesh_ << endl;
forAll(surfaces_, s)
{
const searchableSurface& surface(allGeometry_[surfaces_[s]]);
if (surface.hasVolumeType())
{
pointField pts(1, locationInMesh_);
List<searchableSurface::volumeType> vTypes
(
pts.size(),
searchableSurface::UNKNOWN
);
surface.getVolumeType(pts, vTypes);
referenceVolumeTypes_[s] = vTypes[0];
Info<< " is "
<< searchableSurface::volumeTypeNames[referenceVolumeTypes_[s]]
<< " surface " << surface.name()
<< endl;
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::conformationSurfaces::~conformationSurfaces()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::conformationSurfaces::overlaps(const treeBoundBox& bb) const
{
forAll(surfaces_, s)
{
if (allGeometry_[surfaces_[s]].overlaps(bb))
{
return true;
}
}
return false;
}
Foam::Field<bool> Foam::conformationSurfaces::inside
(
const pointField& samplePts
) const
{
return wellInside(samplePts, scalarField(samplePts.size(), 0.0));
}
bool Foam::conformationSurfaces::inside
(
const point& samplePt
) const
{
return wellInside(pointField(1, samplePt), scalarField(1, 0))[0];
}
Foam::Field<bool> Foam::conformationSurfaces::outside
(
const pointField& samplePts
) const
{
return wellOutside(samplePts, scalarField(samplePts.size(), 0.0));
}
bool Foam::conformationSurfaces::outside
(
const point& samplePt
) const
{
return !inside(samplePt);
}
Foam::Field<bool> Foam::conformationSurfaces::wellInOutSide
(
const pointField& samplePts,
const scalarField& testDistSqr,
bool testForInside
) const
{
List<List<searchableSurface::volumeType> > surfaceVolumeTests
(
surfaces_.size(),
List<searchableSurface::volumeType>
(
samplePts.size(),
searchableSurface::UNKNOWN
)
);
// Get lists for the volumeTypes for each sample wrt each surface
forAll(surfaces_, s)
{
const searchableSurface& surface(allGeometry_[surfaces_[s]]);
if (surface.hasVolumeType())
{
surface.getVolumeType(samplePts, surfaceVolumeTests[s]);
}
}
// Compare the volumeType result for each point wrt to each surface with the
// reference value and if the points are inside the surface by a given
// distanceSquared
// Assume that the point is wellInside until demonstrated otherwise.
Field<bool> inOutSidePoint(samplePts.size(), testForInside);
//Check if the points are inside the surface by the given distance squared
labelList hitSurfaces;
List<pointIndexHit> hitInfo;
searchableSurfacesQueries::findNearest
(
allGeometry_,
surfaces_,
samplePts,
testDistSqr,
hitSurfaces,
hitInfo
);
forAll(samplePts, i)
{
const pointIndexHit& pHit = hitInfo[i];
if (pHit.hit())
{
// If the point is within range of the surface, then it can't be
// well (in|out)side
inOutSidePoint[i] = false;
continue;
}
forAll(surfaces_, s)
{
// If one of the pattern tests is failed, then the point cannot be
// inside, therefore, if this is a testForInside = true call, the
// result is false. If this is a testForInside = false call, then
// the result is true.
if (surfaceVolumeTests[s][i] != referenceVolumeTypes_[s])
{
inOutSidePoint[i] = !testForInside;
break;
}
}
}
return inOutSidePoint;
}
Foam::Field<bool> Foam::conformationSurfaces::wellInside
(
const pointField& samplePts,
const scalarField& testDistSqr
) const
{
return wellInOutSide(samplePts, testDistSqr, true);
}
bool Foam::conformationSurfaces::wellInside
(
const point& samplePt,
scalar testDistSqr
) const
{
return wellInside(pointField(1, samplePt), scalarField(1, testDistSqr))[0];
}
Foam::Field<bool> Foam::conformationSurfaces::wellOutside
(
const pointField& samplePts,
const scalarField& testDistSqr
) const
{
return wellInOutSide(samplePts, testDistSqr, false);
}
bool Foam::conformationSurfaces::wellOutside
(
const point& samplePt,
scalar testDistSqr
) const
{
return wellOutside(pointField(1, samplePt), scalarField(1, testDistSqr))[0];
}
bool Foam::conformationSurfaces::findSurfaceAnyIntersection
(
const point& start,
const point& end
) const
{
labelList hitSurfaces;
List<pointIndexHit> hitInfo;
searchableSurfacesQueries::findAnyIntersection
(
allGeometry_,
surfaces_,
pointField(1, start),
pointField(1, end),
hitSurfaces,
hitInfo
);
return hitInfo[0].hit();
}
void Foam::conformationSurfaces::findSurfaceAnyIntersection
(
const point& start,
const point& end,
pointIndexHit& surfHit,
label& hitSurface
) const
{
labelList hitSurfaces;
List<pointIndexHit> hitInfo;
searchableSurfacesQueries::findAnyIntersection
(
allGeometry_,
surfaces_,
pointField(1, start),
pointField(1, end),
hitSurfaces,
hitInfo
);
surfHit = hitInfo[0];
if (surfHit.hit())
{
// hitSurfaces has returned the index of the entry in surfaces_ that was
// found, not the index of the surface in allGeometry_, translating this
// to allGeometry_
hitSurface = surfaces_[hitSurfaces[0]];
}
}
void Foam::conformationSurfaces::findSurfaceNearestIntersection
(
const point& start,
const point& end,
pointIndexHit& surfHit,
label& hitSurface
) const
{
labelList hitSurfacesStart;
List<pointIndexHit> hitInfoStart;
labelList hitSurfacesEnd;
List<pointIndexHit> hitInfoEnd;
searchableSurfacesQueries::findNearestIntersection
(
allGeometry_,
surfaces_,
pointField(1, start),
pointField(1, end),
hitSurfacesStart,
hitInfoStart,
hitSurfacesEnd,
hitInfoEnd
);
surfHit = hitInfoStart[0];
if (surfHit.hit())
{
// hitSurfaces has returned the index of the entry in surfaces_ that was
// found, not the index of the surface in allGeometry_, translating this
// to allGeometry_
hitSurface = surfaces_[hitSurfacesStart[0]];
}
}
void Foam::conformationSurfaces::findSurfaceNearest
(
const point& sample,
scalar nearestDistSqr,
pointIndexHit& surfHit,
label& hitSurface
) const
{
labelList hitSurfaces;
List<pointIndexHit> surfaceHits;
searchableSurfacesQueries::findNearest
(
allGeometry_,
surfaces_,
pointField(1, sample),
scalarField(1, nearestDistSqr),
hitSurfaces,
surfaceHits
);
surfHit = surfaceHits[0];
if (surfHit.hit())
{
// hitSurfaces has returned the index of the entry in surfaces_ that was
// found, not the index of the surface in allGeometry_, translating this
// to allGeometry_
hitSurface = surfaces_[hitSurfaces[0]];
}
}
void Foam::conformationSurfaces::findSurfaceNearest
(
const pointField& samples,
const scalarField& nearestDistSqr,
List<pointIndexHit>& surfaceHits,
labelList& hitSurfaces
) const
{
searchableSurfacesQueries::findNearest
(
allGeometry_,
surfaces_,
samples,
nearestDistSqr,
hitSurfaces,
surfaceHits
);
forAll(surfaceHits, i)
{
if (surfaceHits[i].hit())
{
// hitSurfaces has returned the index of the entry in surfaces_ that
// was found, not the index of the surface in allGeometry_,
// translating this to the surface in allGeometry_.
hitSurfaces[i] = surfaces_[hitSurfaces[i]];
}
}
}
void Foam::conformationSurfaces::findEdgeNearest
(
const point& sample,
scalar nearestDistSqr,
pointIndexHit& edgeHit,
label& featureHit
) const
{
pointField samples(1, sample);
scalarField nearestDistsSqr(1, nearestDistSqr);
List<pointIndexHit> edgeHits;
labelList featuresHit;
findEdgeNearest
(
samples,
nearestDistsSqr,
edgeHits,
featuresHit
);
edgeHit = edgeHits[0];
featureHit = featuresHit[0];
}
void Foam::conformationSurfaces::findEdgeNearest
(
const pointField& samples,
const scalarField& nearestDistsSqr,
List<pointIndexHit>& edgeHits,
labelList& featuresHit
) const
{
// Initialise
featuresHit.setSize(samples.size());
featuresHit = -1;
edgeHits.setSize(samples.size());
// Work arrays
scalarField minDistSqr(nearestDistsSqr);
List<pointIndexHit> hitInfo(samples.size());
forAll(features_, testI)
{
features_[testI].nearestFeatureEdge
(
samples,
minDistSqr,
hitInfo
);
// Update minDistSqr and arguments
forAll(hitInfo, pointI)
{
if (hitInfo[pointI].hit())
{
minDistSqr[pointI] = magSqr
(
hitInfo[pointI].hitPoint()
- samples[pointI]
);
edgeHits[pointI] = hitInfo[pointI];
featuresHit[pointI] = testI;
}
}
}
}
void Foam::conformationSurfaces::findEdgeNearestByType
(
const point& sample,
scalar nearestDistSqr,
List<pointIndexHit>& edgeHits,
List<label>& featuresHit
) const
{
// Initialise
featuresHit.setSize(extendedFeatureEdgeMesh::nEdgeTypes);
featuresHit = -1;
edgeHits.setSize(extendedFeatureEdgeMesh::nEdgeTypes);
// Work arrays
scalarField minDistSqr(extendedFeatureEdgeMesh::nEdgeTypes, nearestDistSqr);
List<pointIndexHit> hitInfo(extendedFeatureEdgeMesh::nEdgeTypes);
forAll(features_, testI)
{
features_[testI].nearestFeatureEdgeByType
(
sample,
minDistSqr,
hitInfo
);
// Update minDistSqr and arguments
forAll(hitInfo, typeI)
{
if (hitInfo[typeI].hit())
{
minDistSqr[typeI] = magSqr(hitInfo[typeI].hitPoint() - sample);
edgeHits[typeI] = hitInfo[typeI];
featuresHit[typeI] = testI;
}
}
}
}
void Foam::conformationSurfaces::writeFeatureObj(const fileName& prefix) const
{
OFstream ftStr(cvMesh_.time().path()/prefix + "_allFeatures.obj");
Pout<< nl << "Writing all features to " << ftStr.name() << endl;
label verti = 0;
forAll(features_, i)
{
const extendedFeatureEdgeMesh& fEM(features_[i]);
const pointField pts(fEM.points());
const edgeList eds(fEM.edges());
ftStr << "g " << fEM.name() << endl;
forAll(eds, j)
{
const edge& e = eds[j];
meshTools::writeOBJ(ftStr, pts[e[0]]); verti++;
meshTools::writeOBJ(ftStr, pts[e[1]]); verti++;
ftStr << "l " << verti-1 << ' ' << verti << endl;
}
}
}
Foam::label Foam::conformationSurfaces::findPatch
(
const point& ptA,
const point& ptB
) const
{
pointIndexHit surfHit;
label hitSurface;
findSurfaceAnyIntersection(ptA, ptB, surfHit, hitSurface);
if (!surfHit.hit())
{
return -1;
}
labelList surfLocalRegion;
allGeometry_[hitSurface].getRegion
(
List<pointIndexHit>(1, surfHit),
surfLocalRegion
);
return
surfLocalRegion[0] + patchOffsets_[allGeometryToSurfaces_[hitSurface]];
}
Foam::label Foam::conformationSurfaces::findPatch(const point& pt) const
{
pointIndexHit surfHit;
label hitSurface;
findSurfaceNearest
(
pt,
sqr(GREAT),
surfHit,
hitSurface
);
if (!surfHit.hit())
{
return -1;
}
labelList surfLocalRegion;
allGeometry_[hitSurface].getRegion
(
List<pointIndexHit>(1, surfHit),
surfLocalRegion
);
return
surfLocalRegion[0] + patchOffsets_[allGeometryToSurfaces_[hitSurface]];
}
// ************************************************************************* //

View File

@ -1,303 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::conformationSurfaces
Description
SourceFiles
conformationSurfacesI.H
conformationSurfaces.C
\*---------------------------------------------------------------------------*/
#ifndef conformationSurfaces_H
#define conformationSurfaces_H
#include "searchableSurfaces.H"
#include "searchableSurfacesQueries.H"
#include "extendedFeatureEdgeMesh.H"
#include "boolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class conformalVoronoiMesh;
/*---------------------------------------------------------------------------*\
Class conformationSurfaces Declaration
\*---------------------------------------------------------------------------*/
class conformationSurfaces
{
// Private data
//- Reference to the conformalVoronoiMesh holding this object
const conformalVoronoiMesh& cvMesh_;
//- Reference to the searchableSurfaces object holding all geometry data
const searchableSurfaces& allGeometry_;
//- A list of extendedFeatureEdgeMesh
PtrList<extendedFeatureEdgeMesh> features_;
//- The location in the mesh that specifies which portion of surfaces is
// to be meshed.
point locationInMesh_;
//- Indices of surfaces in allGeometry that are to be conformed to
labelList surfaces_;
//- Reverse mapping, which entry in surfaces corresponds to the surface
// in allGeometry specified by the list index. -1 for a surface that
// isn't used.
labelList allGeometryToSurfaces_;
//- A boolean value for each surface to be conformed to specifying if it
// is to be treated as a baffle
boolList baffleSurfaces_;
//- A flat list of all of the names of the patches from all of the
// surfaces to be reproduced in the meshed geometry
List<word> patchNames_;
//- The offset between the patch indices of the individual surface and
// the entry in the overall patch list
labelList patchOffsets_;
//- The overall boundBox of all of the surfaces to be conformed to
treeBoundBox globalBounds_;
//- The pattern/signature of volumeTypes representing a point in the
// domain to be meshed
List<searchableSurface::volumeType> referenceVolumeTypes_;
// Private Member Functions
//- Disallow default bitwise copy construct
conformationSurfaces(const conformationSurfaces&);
//- Disallow default bitwise assignment
void operator=(const conformationSurfaces&);
public:
// Constructors
//- Construct from dictionary and references to conformalVoronoiMesh and
// searchableSurfaces
conformationSurfaces
(
const conformalVoronoiMesh& cvMesh,
const searchableSurfaces& allGeometry,
const dictionary& surfaceConformationDict
);
//- Destructor
~conformationSurfaces();
// Member Functions
// Access
//- Return reference to the searchableSurfaces object containing all
// of the geometry
inline const searchableSurfaces& geometry() const;
//- Return the object holding the feature points and edges
inline const PtrList<extendedFeatureEdgeMesh>& features() const;
//- Return the surface indices
inline const labelList& surfaces() const;
//- Return the patch names
inline const List<word>& patchNames() const;
//- Return the global bounds
inline const treeBoundBox& globalBounds() const;
// Query
//- Check if the supplied bound box overlaps any part of any of
// the surfaces
bool overlaps(const treeBoundBox& bb) const;
//- Check if points are inside surfaces to conform to
Field<bool> inside(const pointField& samplePts) const;
//- Check if point is inside surfaces to conform to
bool inside(const point& samplePt) const;
//- Check if points are outside surfaces to conform to
Field<bool> outside(const pointField& samplePts) const;
//- Check if point is outside surfaces to conform to
bool outside(const point& samplePt) const;
//- Check if point is closer to the surfaces to conform to than
// testDistSqr, in which case return false, otherwise assess in or
// outside and erturn a result depending on the testForInside flag
Field<bool> wellInOutSide
(
const pointField& samplePts,
const scalarField& testDistSqr,
bool testForInside
) const;
//- Check if point is inside surfaces to conform to by at least
// testDistSqr
Field<bool> wellInside
(
const pointField& samplePts,
const scalarField& testDistSqr
) const;
bool wellInside
(
const point& samplePt,
scalar testDistSqr
) const;
//- Check if point is outside surfaces to conform to by at least
// testDistSqr
Field<bool> wellOutside
(
const pointField& samplePts,
const scalarField& testDistSqr
) const;
bool wellOutside
(
const point& samplePt,
scalar testDistSqr
) const;
// Finding if the line joining start and end intersects the surface
bool findSurfaceAnyIntersection
(
const point& start,
const point& end
) const;
//- Finding if the line joining start and end intersects the surface
// and returning the hit and surface information
void findSurfaceAnyIntersection
(
const point& start,
const point& end,
pointIndexHit& surfHit,
label& hitSurface
) const;
//- Finding the nearestIntersection of the surface to start
void findSurfaceNearestIntersection
(
const point& start,
const point& end,
pointIndexHit& surfHit,
label& hitSurface
) const;
//- Find the nearest point to the sample and return it to the
// pointIndexHit
void findSurfaceNearest
(
const point& sample,
scalar nearestDistSqr,
pointIndexHit& surfHit,
label& hitSurface
) const;
void findSurfaceNearest
(
const pointField& samples,
const scalarField& nearestDistSqr,
List<pointIndexHit>& hitInfo,
labelList& hitSurfaces
) const;
//- Find the nearest point on any feature edge
void findEdgeNearest
(
const point& sample,
scalar nearestDistSqr,
pointIndexHit& edgeHit,
label& featureHit
) const;
void findEdgeNearest
(
const pointField& samples,
const scalarField& nearestDistsSqr,
List<pointIndexHit>& edgeHits,
labelList& featuresHit
) const;
//- Find the nearest point on each type of feature edge
void findEdgeNearestByType
(
const point& sample,
scalar nearestDistSqr,
List<pointIndexHit>& edgeHit,
List<label>& featureHit
) const;
//- Find which patch is intersected by the line from one point to
// another
label findPatch(const point& ptA, const point& ptB) const;
//- Find which patch is closest to the point
label findPatch(const point& pt) const;
// Write
//- Write all components of all the extendedFeatureEdgeMeshes as
// an obj file
void writeFeatureObj(const fileName& prefix) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "conformationSurfacesI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,59 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::searchableSurfaces& Foam::conformationSurfaces::geometry() const
{
return allGeometry_;
}
const Foam::PtrList<Foam::extendedFeatureEdgeMesh>&
Foam::conformationSurfaces::features() const
{
return features_;
}
const Foam::labelList& Foam::conformationSurfaces::surfaces() const
{
return surfaces_;
}
const Foam::List<Foam::word>& Foam::conformationSurfaces::patchNames() const
{
return patchNames_;
}
const Foam::treeBoundBox& Foam::conformationSurfaces::globalBounds() const
{
return globalBounds_;
}
// ************************************************************************* //

View File

@ -1,520 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "cvControls.H"
#include "conformalVoronoiMesh.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cvControls::cvControls
(
const conformalVoronoiMesh& cvMesh,
const dictionary& cvMeshDict
)
:
cvMesh_(cvMesh),
cvMeshDict_(cvMeshDict)
{
// Surface conformation controls
const dictionary& surfDict(cvMeshDict_.subDict("surfaceConformation"));
pointPairDistanceCoeff_ = readScalar
(
surfDict.lookup("pointPairDistanceCoeff")
);
mixedFeaturePointPPDistanceCoeff_ = readScalar
(
surfDict.lookup("mixedFeaturePointPPDistanceCoeff")
);
featurePointExclusionDistanceCoeff_ = readScalar
(
surfDict.lookup("featurePointExclusionDistanceCoeff")
);
featureEdgeExclusionDistanceCoeff_ = readScalar
(
surfDict.lookup("featureEdgeExclusionDistanceCoeff")
);
surfaceSearchDistanceCoeff_ = readScalar
(
surfDict.lookup("surfaceSearchDistanceCoeff")
);
maxSurfaceProtrusionCoeff_ = readScalar
(
surfDict.lookup("maxSurfaceProtrusionCoeff")
);
maxQuadAngle_ = readScalar(surfDict.lookup("maxQuadAngle"));
surfaceConformationRebuildFrequency_ = max
(
1,
readLabel(surfDict.lookup("surfaceConformationRebuildFrequency"))
);
// Controls for coarse surface conformation
const dictionary& coarseDict
(
surfDict.subDict("coarseConformationControls")
);
const dictionary& coarseInitialDict
(
coarseDict.subDict("initial")
);
const dictionary& coarseIterationDict
(
coarseDict.subDict("iteration")
);
edgeSearchDistCoeffSqr_coarse_initial_ = sqr
(
readScalar
(
coarseInitialDict.lookup("edgeSearchDistCoeff")
)
);
edgeSearchDistCoeffSqr_coarse_iteration_ = sqr
(
readScalar
(
coarseIterationDict.lookup("edgeSearchDistCoeff")
)
);
surfacePtReplaceDistCoeffSqr_coarse_initial_ = sqr
(
readScalar
(
coarseInitialDict.lookup("surfacePtReplaceDistCoeff")
)
);
surfacePtReplaceDistCoeffSqr_coarse_iteration_ = sqr
(
readScalar
(
coarseIterationDict.lookup("surfacePtReplaceDistCoeff")
)
);
maxConformationIterations_coarse_ = readLabel
(
coarseDict.lookup("maxIterations")
);
iterationToInitialHitRatioLimit_coarse_ = readScalar
(
coarseDict.lookup("iterationToInitialHitRatioLimit")
);
// Controls for fine surface conformation
const dictionary& fineDict
(
surfDict.subDict("fineConformationControls")
);
const dictionary& fineInitialDict
(
fineDict.subDict("initial")
);
const dictionary& fineIterationDict
(
fineDict.subDict("iteration")
);
edgeSearchDistCoeffSqr_fine_initial_ = sqr
(
readScalar
(
fineInitialDict.lookup("edgeSearchDistCoeff")
)
);
edgeSearchDistCoeffSqr_fine_iteration_ = sqr
(
readScalar
(
fineIterationDict.lookup("edgeSearchDistCoeff")
)
);
surfacePtReplaceDistCoeffSqr_fine_initial_ = sqr
(
readScalar
(
fineInitialDict.lookup("surfacePtReplaceDistCoeff")
)
);
surfacePtReplaceDistCoeffSqr_fine_iteration_ = sqr
(
readScalar
(
fineIterationDict.lookup("surfacePtReplaceDistCoeff")
)
);
maxConformationIterations_fine_ = readLabel
(
fineDict.lookup("maxIterations")
);
iterationToInitialHitRatioLimit_fine_ = readScalar
(
fineDict.lookup("iterationToInitialHitRatioLimit")
);
// Motion control controls
const dictionary& motionDict(cvMeshDict_.subDict("motionControl"));
objOutput_ = Switch(motionDict.lookupOrDefault<Switch>("objOutput", false));
timeChecks_ = Switch
(
motionDict.lookupOrDefault<Switch>("timeChecks", false)
);
if (Pstream::parRun())
{
maxLoadUnbalance_ = readScalar(motionDict.lookup("maxLoadUnbalance"));
}
else
{
maxLoadUnbalance_ = -1;
}
alignmentSearchSpokes_ = readLabel
(
motionDict.lookup("alignmentSearchSpokes")
);
cosAlignmentAcceptanceAngle_ = cos
(
degToRad(readScalar(motionDict.lookup("alignmentAcceptanceAngle")))
);
sizeAndAlignmentRebuildFrequency_ = max
(
1,
readLabel(motionDict.lookup("sizeAndAlignmentRebuildFrequency"))
);
// Point removal criteria
const dictionary& insertionDict
(
motionDict.subDict("pointInsertionCriteria")
);
insertionDistCoeff_ = readScalar
(
insertionDict.lookup("cellCentreDistCoeff")
);
faceAreaRatioCoeff_ = readScalar
(
insertionDict.lookup("faceAreaRatioCoeff")
);
cosInsertionAcceptanceAngle_ = cos
(
degToRad(readScalar(insertionDict.lookup("acceptanceAngle")))
);
// Point removal criteria
const dictionary& removalDict
(
motionDict.subDict("pointRemovalCriteria")
);
removalDistCoeff_ = readScalar
(
removalDict.lookup("cellCentreDistCoeff")
);
// polyMesh filtering controls
const dictionary& filteringDict(cvMeshDict_.subDict("polyMeshFiltering"));
writeTetDualMesh_ = Switch(filteringDict.lookup("writeTetDualMesh"));
filterSizeCoeff_ = readScalar
(
filteringDict.lookup("filterSizeCoeff")
);
mergeClosenessCoeff_ = readScalar
(
filteringDict.lookup("mergeClosenessCoeff")
);
continueFilteringOnBadInitialPolyMesh_ = Switch
(
filteringDict.lookupOrDefault<Switch>
(
"continueFilteringOnBadInitialPolyMesh",
false
)
);
filterErrorReductionCoeff_ = readScalar
(
filteringDict.lookup("filterErrorReductionCoeff")
);
filterCountSkipThreshold_ = readLabel
(
filteringDict.lookup("filterCountSkipThreshold")
);
maxCollapseIterations_ = readLabel
(
filteringDict.lookup("maxCollapseIterations")
);
maxConsecutiveEqualFaceSets_ = readLabel
(
filteringDict.lookup("maxConsecutiveEqualFaceSets")
);
surfaceStepFaceAngle_ = readScalar
(
filteringDict.lookup("surfaceStepFaceAngle")
);
edgeCollapseGuardFraction_ = readScalar
(
filteringDict.lookup("edgeCollapseGuardFraction")
);
maxCollapseFaceToPointSideLengthCoeff_ = readScalar
(
filteringDict.lookup("maxCollapseFaceToPointSideLengthCoeff")
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::cvControls::edgeSearchDistCoeffSqrInitial
(
int reconfMode
) const
{
if (reconfMode == conformalVoronoiMesh::rmCoarse)
{
return edgeSearchDistCoeffSqr_coarse_initial_;
}
else if (reconfMode == conformalVoronoiMesh::rmFine)
{
return edgeSearchDistCoeffSqr_fine_initial_;
}
else
{
FatalErrorIn
(
"Foam::cvControls::edgeSearchDistCoeffSqrInitial"
"("
"int reconfMode"
") const"
) << "Unknown reconformationMode " << reconfMode
<< exit(FatalError);
}
return 0;
}
Foam::scalar Foam::cvControls::edgeSearchDistCoeffSqrIteration
(
int reconfMode
) const
{
if (reconfMode == conformalVoronoiMesh::rmCoarse)
{
return edgeSearchDistCoeffSqr_coarse_iteration_;
}
else if (reconfMode == conformalVoronoiMesh::rmFine)
{
return edgeSearchDistCoeffSqr_fine_iteration_;
}
else
{
FatalErrorIn
(
"Foam::cvControls::edgeSearchDistCoeffSqrIteration"
"("
"int reconfMode"
") const"
) << "Unknown reconformationMode " << reconfMode
<< exit(FatalError);
}
return 0;
}
Foam::scalar Foam::cvControls::surfacePtReplaceDistCoeffSqrInitial
(
int reconfMode
) const
{
if (reconfMode == conformalVoronoiMesh::rmCoarse)
{
return surfacePtReplaceDistCoeffSqr_coarse_initial_;
}
else if (reconfMode == conformalVoronoiMesh::rmFine)
{
return surfacePtReplaceDistCoeffSqr_fine_initial_;
}
else
{
FatalErrorIn
(
"Foam::cvControls::surfacePtReplaceDistCoeffSqrInitial"
"("
"int reconfMode"
") const"
) << "Unknown reconformationMode " << reconfMode
<< exit(FatalError);
}
return 0;
}
Foam::scalar Foam::cvControls::surfacePtReplaceDistCoeffSqrIteration
(
int reconfMode
) const
{
if (reconfMode == conformalVoronoiMesh::rmCoarse)
{
return surfacePtReplaceDistCoeffSqr_coarse_iteration_;
}
else if (reconfMode == conformalVoronoiMesh::rmFine)
{
return surfacePtReplaceDistCoeffSqr_fine_iteration_;
}
else
{
FatalErrorIn
(
"Foam::cvControls::surfacePtReplaceDistCoeffSqrIteration"
"("
"int reconfMode"
") const"
) << "Unknown reconformationMode " << reconfMode
<< exit(FatalError);
}
return 0;
}
Foam::label Foam::cvControls::maxConformationIterations
(
int reconfMode
) const
{
if (reconfMode == conformalVoronoiMesh::rmCoarse)
{
return maxConformationIterations_coarse_;
}
else if (reconfMode == conformalVoronoiMesh::rmFine)
{
return maxConformationIterations_fine_;
}
else
{
FatalErrorIn
(
"Foam::cvControls::maxConformationIterations"
"("
"int reconfMode"
") const"
) << "Unknown reconformationMode " << reconfMode
<< exit(FatalError);
}
return 0;
}
Foam::scalar Foam::cvControls::iterationToInitialHitRatioLimit
(
int reconfMode
) const
{
if (reconfMode == conformalVoronoiMesh::rmCoarse)
{
return iterationToInitialHitRatioLimit_coarse_;
}
else if (reconfMode == conformalVoronoiMesh::rmFine)
{
return iterationToInitialHitRatioLimit_fine_;
}
else
{
FatalErrorIn
(
"Foam::cvControls::iterationToInitialHitRatioLimit"
"("
"int reconfMode"
") const"
) << "Unknown reconformationMode " << reconfMode
<< exit(FatalError);
}
return 0;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cvControls::~cvControls()
{}
// ************************************************************************* //

View File

@ -1,439 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::cvControls
Description
Controls for the conformalVoronoiMesh mesh generator
SourceFiles
cvControls.C
\*---------------------------------------------------------------------------*/
#ifndef cvControls_H
#define cvControls_H
#include "dictionary.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class conformalVoronoiMesh;
/*---------------------------------------------------------------------------*\
Class cvControls Declaration
\*---------------------------------------------------------------------------*/
class cvControls
{
// Private data
//- Reference to the conformalVoronoiMesh holding this cvControls object
const conformalVoronoiMesh& cvMesh_;
//- Reference to the cvMeshDict
const dictionary& cvMeshDict_;
// Surface conformation controls
//- Point pair spacing coefficient - fraction of the local target
// cell size
scalar pointPairDistanceCoeff_;
//- Distance along feature edge to place mixed feature point
// conformation groups - to be multiple of pointPairDistanceCoeff_.
scalar mixedFeaturePointPPDistanceCoeff_;
//- Distance to a feature point within which surface and edge
// conformation points are excluded - fraction of the local target
// cell size
scalar featurePointExclusionDistanceCoeff_;
//- Distance to an existing feature edge conformation location
// within which other edge conformation location are excluded -
// fraction of the local target cell size
scalar featureEdgeExclusionDistanceCoeff_;
//- Surface search distance coefficient - fraction of the local
// target cell size
scalar surfaceSearchDistanceCoeff_;
//- Maximum allowable protrusion through the surface before
// conformation points are added - fraction of the local target
// cell size
scalar maxSurfaceProtrusionCoeff_;
//- Maximum quadrant angle allowed at a concave edge before
// additional "mitering" lines are added
scalar maxQuadAngle_;
//- Now often to rebuild the surface conformation
label surfaceConformationRebuildFrequency_;
// Controls for coarse surface conformation
//- Distance to search for feature edges near to
// surface protrusions - fraction of the local target
// cell size. Coarse conformation, initial protrusion
// tests.
scalar edgeSearchDistCoeffSqr_coarse_initial_;
//- Distance to search for feature edges near to
// surface protrusions - fraction of the local target
// cell size. Coarse conformation, iteration
// protrusion tests.
scalar edgeSearchDistCoeffSqr_coarse_iteration_;
//- Proximity to a feature edge where a surface hit is
// not created, only the edge conformation is created
// - fraction of the local target cell size. Coarse
// conformation, initial protrusion tests.
scalar surfacePtReplaceDistCoeffSqr_coarse_initial_;
//- Proximity to a feature edge where a surface hit is
// not created, only the edge conformation is created
// - fraction of the local target cell size. Coarse
// conformation, iteration protrusion tests.
scalar surfacePtReplaceDistCoeffSqr_coarse_iteration_;
//- Maximum allowed number coarse surface conformation
// iterations.
label maxConformationIterations_coarse_;
//- Termination criterion for coarse surface
// conformation iterations. When the number of
// surface protrusions drops below this ratio of the
// initial number of protrusions.
scalar iterationToInitialHitRatioLimit_coarse_;
// Controls for fine surface conformation
//- Distance to search for feature edges near to
// surface protrusions - fraction of the local target
// cell size. Fine conformation, initial protrusion
// tests.
scalar edgeSearchDistCoeffSqr_fine_initial_;
//- Distance to search for feature edges near to
// surface protrusions - fraction of the local target
// cell size. Fine conformation, iteration protrusion
// tests.
scalar edgeSearchDistCoeffSqr_fine_iteration_;
//- Proximity to a feature edge where a surface hit is
// not created, only the edge conformation is created
// - fraction of the local target cell size. Fine
// conformation, initial protrusion tests.
scalar surfacePtReplaceDistCoeffSqr_fine_initial_;
//- Proximity to a feature edge where a surface hit is
// not created, only the edge conformation is created
// - fraction of the local target cell size. Fine
// conformation, iteration protrusion tests.
scalar surfacePtReplaceDistCoeffSqr_fine_iteration_;
//- Maximum allowed number fine surface conformation
// iterations.
label maxConformationIterations_fine_;
//- Termination criterion for fine surface conformation
// iterations. When the number of surface protrusions
// drops below this ratio of the initial number of
// protrusions.
scalar iterationToInitialHitRatioLimit_fine_;
// Motion control controls
//- Switch to control the output of obj files for debug
Switch objOutput_;
//- Switch to control the reporting of detailed timeChecks
Switch timeChecks_;
//- Allowed relative load unbalance
scalar maxLoadUnbalance_;
//- Number of "spokes" to use to search for secondary alignment
// direction
label alignmentSearchSpokes_;
//- cosine of angle of alignment with required direction within which a
// face will be accepted for rotation
scalar cosAlignmentAcceptanceAngle_;
//- Now often to re-store the size and alignment data
label sizeAndAlignmentRebuildFrequency_;
// Point insertion criteria
//- Length between Delaunay vertices above which a new Dv should be
// inserted - fraction of the local target cell size
scalar insertionDistCoeff_;
//- Minimum dual face area corresponding to long Delaunay edge where
// a new Dv is to be inserted - fraction of the local target cell
// size
scalar faceAreaRatioCoeff_;
//- cosine of the angle of alignment with the required direction
// within which a long De will be accepted for a new Dv insertion
scalar cosInsertionAcceptanceAngle_;
// Point removal criteria
//- Length between Delaunay vertices below which a Dv should be
// removed - fraction of the local target cell size
scalar removalDistCoeff_;
// polyMesh filtering controls
//- Write tet mesh at output time (it always writes the Voronoi)
Switch writeTetDualMesh_;
//- Upper limit on the size of faces to be filtered from,
// fraction of the local target cell size
scalar filterSizeCoeff_;
//- Upper limit on how close two dual vertices can be before
// being merged, fraction of the local target cell size
scalar mergeClosenessCoeff_;
//- If the mesh quality criteria cannot be satisfied, continue
// with filtering anyway?
Switch continueFilteringOnBadInitialPolyMesh_;
//- When a face is "bad", what fraction should the filterSizeCoeff_ be
// reduced by. Recursive, so for a filterCount value of fC, the
// filterSizeCoeff is reduced by pow(filterErrorReductionCoeff_, fC)
scalar filterErrorReductionCoeff_;
//- Maximum number of filterCount applications before a face
// is not attempted to be filtered
label filterCountSkipThreshold_;
//- Maximum number of permissible iterations of the face collapse
// algorithm. The value to choose will be related the maximum number
// of points on a face that is to be collapsed and how many faces
// around it need to be collapsed.
label maxCollapseIterations_;
//- Maximum number of times an to allow an equal faceSet to be
// returned from the face quality assessment before stopping iterations
// to break an infinitie loop.
label maxConsecutiveEqualFaceSets_;
//- The maximum allowed angle between a boundary face normal and the
// local surface normal before face will be aggressively collapsed
scalar surfaceStepFaceAngle_;
//- Defining how close to the midpoint (M) of the projected
// vertices line a projected vertex (X) can be before making
// an edge collapse invalid
//
// X---X-g----------------M----X-----------g----X--X
//
// Only allow a collapse if all projected vertices are
// outwith edgeCollapseGuardFraction (g) of the distance form
// the face centre to the furthest vertex in the considered
// direction
scalar edgeCollapseGuardFraction_;
//- The maximum allowed length of the longest edge of a face
// to enable a face to be collapsed to a point, fraction of
// the local target cell size
scalar maxCollapseFaceToPointSideLengthCoeff_;
// Private Member Functions
//- Disallow default bitwise copy construct
cvControls(const cvControls&);
//- Disallow default bitwise assignment
void operator=(const cvControls&);
public:
// Constructors
//- Construct from references to conformalVoronoiMesh and dictionary
cvControls
(
const conformalVoronoiMesh& cvMesh,
const dictionary& cvMeshDict
);
//- Destructor
~cvControls();
// Member Functions
// Access
//- Return the cvMeshDict
inline const dictionary& cvMeshDict() const;
//- Return the pointPairDistanceCoeff
inline scalar pointPairDistanceCoeff() const;
//- Return the mixedFeaturePointPPDistanceCoeff
inline scalar mixedFeaturePointPPDistanceCoeff() const;
//- Return the featurePointExclusionDistanceCoeff
inline scalar featurePointExclusionDistanceCoeff() const;
//- Return the featureEdgeExclusionDistanceCoeff
inline scalar featureEdgeExclusionDistanceCoeff() const;
//- Return the surfaceSearchDistanceCoeff
inline scalar surfaceSearchDistanceCoeff() const;
//- Return the maxSurfaceProtrusionCoeff
inline scalar maxSurfaceProtrusionCoeff() const;
//- Return the maxQuadAngle
inline scalar maxQuadAngle() const;
//- Return the surfaceConformationRebuildFrequency
inline label surfaceConformationRebuildFrequency() const;
//- Return the edgeSearchDistCoeffSqr for initial
// conformation for the given reconformationMode.
scalar edgeSearchDistCoeffSqrInitial(int reconfMode) const;
//- Return the edgeSearchDistCoeffSqr for conformation
// iterations for the given reconformationMode.
scalar edgeSearchDistCoeffSqrIteration(int reconfMode) const;
//- Return the surfacePtReplaceDistCoeffSqr for initial
// conformation for the given reconformationMode.
scalar surfacePtReplaceDistCoeffSqrInitial(int reconfMode) const;
//- Return the surfacePtReplaceDistCoeffSqr for
// conformation iterations for the given
// reconformationMode.
scalar surfacePtReplaceDistCoeffSqrIteration(int reconfMode) const;
//- Return the maxConformationIterations for the given
// reconformationMode.
label maxConformationIterations(int reconfMode) const;
//- Return the iterationToInitialHitRatioLimit for the
// given reconformationMode.
scalar iterationToInitialHitRatioLimit(int reconfMode) const;
//- Return the objOutput Switch
inline Switch objOutput() const;
//- Return the timeChecks Switch
inline Switch timeChecks() const;
//- Return the maxLoadUnbalance
inline scalar maxLoadUnbalance() const;
//- Return the number of alignmentSearchSpokes to use
inline label alignmentSearchSpokes() const;
//- Return the cosAlignmentAcceptanceAngle
inline scalar cosAlignmentAcceptanceAngle() const;
//- Return the sizeAndAlignmentRebuildFrequency
inline label sizeAndAlignmentRebuildFrequency() const;
//- Return the insertionDistCoeff
inline scalar insertionDistCoeff() const;
//- Return the faceAreaRatioCoeff
inline scalar faceAreaRatioCoeff() const;
//- Return the cosInsertionAcceptanceAngle
inline scalar cosInsertionAcceptanceAngle() const;
//- Return removalDistCoeff
inline scalar removalDistCoeff() const;
//- Write tetMesh at output time
inline Switch writeTetDualMesh() const;
//- Return the filterSizeCoeff
inline scalar filterSizeCoeff() const;
//- Return the mergeClosenessCoeff
inline scalar mergeClosenessCoeff() const;
//- Return the continueFilteringOnBadInitialPolyMesh Switch
inline Switch continueFilteringOnBadInitialPolyMesh() const;
//- Return the filterErrorReductionCoeff
inline scalar filterErrorReductionCoeff() const;
//- Return the maxCollapseIterations
inline label maxCollapseIterations() const;
//- Return the maxConsecutiveEqualFaceSets
inline label maxConsecutiveEqualFaceSets() const;
//- Return the filterCountSkipThreshold
inline label filterCountSkipThreshold() const;
//- Return the maxCollapseIterations
inline label minCollapseFaces() const;
//- Return the surfaceStepFaceAngle
inline scalar surfaceStepFaceAngle() const;
//- Return the edgeCollapseGuardFraction
inline scalar edgeCollapseGuardFraction() const;
//- Return the maxCollapseFaceToPointSideLengthCoeff
inline scalar maxCollapseFaceToPointSideLengthCoeff() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "cvControlsI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,210 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::dictionary& Foam::cvControls::cvMeshDict() const
{
return cvMeshDict_;
}
inline Foam::scalar Foam::cvControls::pointPairDistanceCoeff() const
{
return pointPairDistanceCoeff_;
}
inline Foam::scalar Foam::cvControls::mixedFeaturePointPPDistanceCoeff() const
{
return mixedFeaturePointPPDistanceCoeff_;
}
inline Foam::scalar Foam::cvControls::featurePointExclusionDistanceCoeff() const
{
return featurePointExclusionDistanceCoeff_;
}
inline Foam::scalar Foam::cvControls::featureEdgeExclusionDistanceCoeff() const
{
return featureEdgeExclusionDistanceCoeff_;
}
inline Foam::scalar Foam::cvControls::surfaceSearchDistanceCoeff() const
{
return surfaceSearchDistanceCoeff_;
}
inline Foam::scalar Foam::cvControls::maxSurfaceProtrusionCoeff() const
{
return maxSurfaceProtrusionCoeff_;
}
inline Foam::scalar Foam::cvControls::maxQuadAngle() const
{
return maxQuadAngle_;
}
inline Foam::label Foam::cvControls::surfaceConformationRebuildFrequency() const
{
return surfaceConformationRebuildFrequency_;
}
inline Foam::Switch Foam::cvControls::objOutput() const
{
return objOutput_;
}
inline Foam::Switch Foam::cvControls::timeChecks() const
{
return timeChecks_;
}
inline Foam::scalar Foam::cvControls::maxLoadUnbalance() const
{
return maxLoadUnbalance_;
}
inline Foam::label Foam::cvControls::alignmentSearchSpokes() const
{
return alignmentSearchSpokes_;
}
inline Foam::scalar Foam::cvControls::cosAlignmentAcceptanceAngle() const
{
return cosAlignmentAcceptanceAngle_;
}
inline Foam::label Foam::cvControls::sizeAndAlignmentRebuildFrequency() const
{
return sizeAndAlignmentRebuildFrequency_;
}
inline Foam::scalar Foam::cvControls::insertionDistCoeff() const
{
return insertionDistCoeff_;
}
inline Foam::scalar Foam::cvControls::faceAreaRatioCoeff() const
{
return faceAreaRatioCoeff_;
}
inline Foam::scalar Foam::cvControls::cosInsertionAcceptanceAngle() const
{
return cosInsertionAcceptanceAngle_;
}
inline Foam::scalar Foam::cvControls::removalDistCoeff() const
{
return removalDistCoeff_;
}
inline Foam::Switch Foam::cvControls::writeTetDualMesh() const
{
return writeTetDualMesh_;
}
inline Foam::scalar Foam::cvControls::filterSizeCoeff() const
{
return filterSizeCoeff_;
}
inline Foam::scalar Foam::cvControls::mergeClosenessCoeff() const
{
return mergeClosenessCoeff_;
}
inline Foam::Switch
Foam::cvControls::continueFilteringOnBadInitialPolyMesh() const
{
return continueFilteringOnBadInitialPolyMesh_;
}
inline Foam::scalar Foam::cvControls::filterErrorReductionCoeff() const
{
return filterErrorReductionCoeff_;
}
inline Foam::label Foam::cvControls::filterCountSkipThreshold() const
{
return filterCountSkipThreshold_;
}
inline Foam::label Foam::cvControls::maxCollapseIterations() const
{
return maxCollapseIterations_;
}
inline Foam::label Foam::cvControls::maxConsecutiveEqualFaceSets() const
{
return maxConsecutiveEqualFaceSets_;
}
inline Foam::scalar Foam::cvControls::surfaceStepFaceAngle() const
{
return surfaceStepFaceAngle_;
}
inline Foam::scalar Foam::cvControls::edgeCollapseGuardFraction() const
{
return edgeCollapseGuardFraction_;
}
inline Foam::scalar
Foam::cvControls::maxCollapseFaceToPointSideLengthCoeff() const
{
return maxCollapseFaceToPointSideLengthCoeff_;
}
// ************************************************************************* //

View File

@ -1,102 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "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()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,149 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::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

@ -1,81 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "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_)) - lAF_/(uAF_ - lAF_);
}
else
{
return 1;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,99 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::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

@ -1,945 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "autoDensity.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(autoDensity, 0);
addToRunTimeSelectionTable
(
initialPointsMethod,
autoDensity,
dictionary
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::autoDensity::writeOBJ
(
const treeBoundBox& bb,
fileName name
) const
{
OFstream str(cvMesh_.time().path()/name + ".obj");
Pout<< "Writing " << str.name() << endl;
pointField bbPoints(bb.points());
forAll(bbPoints, i)
{
meshTools::writeOBJ(str, bbPoints[i]);
}
forAll(treeBoundBox::edges, i)
{
const edge& e = treeBoundBox::edges[i];
str << "l " << e[0] + 1 << ' ' << e[1] + 1 << nl;
}
}
bool Foam::autoDensity::combinedOverlaps(const treeBoundBox& box) const
{
if (Pstream::parRun())
{
return
cvMesh_.decomposition().overlapsThisProcessor(box)
|| cvMesh_.geometryToConformTo().overlaps(box);
}
return cvMesh_.geometryToConformTo().overlaps(box);
}
bool Foam::autoDensity::combinedInside(const point& p) const
{
if (Pstream::parRun())
{
return
cvMesh_.decomposition().positionOnThisProcessor(p)
&& cvMesh_.geometryToConformTo().inside(p);
}
return cvMesh_.geometryToConformTo().inside(p);
}
Foam::Field<bool> Foam::autoDensity::combinedWellInside
(
const pointField& pts,
const scalarField& sizes
) const
{
if (!Pstream::parRun())
{
return cvMesh_.geometryToConformTo().wellInside
(
pts,
minimumSurfaceDistanceCoeffSqr_*sqr(sizes)
);
}
Field<bool> inside(pts.size(), true);
// Perform AND operation between testing the surfaces and the previous
// field, i.e the parallel result, or in serial, with true.
Field<bool> insideA
(
cvMesh_.geometryToConformTo().wellInside
(
pts,
minimumSurfaceDistanceCoeffSqr_*sqr(sizes)
)
);
Field<bool> insideB(cvMesh_.decomposition().positionOnThisProcessor(pts));
// inside = insideA && insideB;
// Pout<< insideA << nl << insideB << endl;
forAll(inside, i)
{
// if (inside[i] != (insideA[i] && insideB[i]))
// {
// Pout<< i << " not equal " << " "
// << pts[i] << " " << sizes[i] << " "
// << insideA[i] << " "
// << insideB[i] << " "
// << inside[i]
// << endl;
// }
inside[i] = (insideA[i] && insideB[i]);
}
return inside;
}
bool Foam::autoDensity::combinedWellInside
(
const point& p,
scalar size
) const
{
bool inside = true;
if (Pstream::parRun())
{
inside = cvMesh_.decomposition().positionOnThisProcessor(p);
}
// Perform AND operation between testing the surfaces and the previous
// result, i.e the parallel result, or in serial, with true.
inside =
inside
&& cvMesh_.geometryToConformTo().wellInside
(
p,
minimumSurfaceDistanceCoeffSqr_*sqr(size)
);
return inside;
}
void Foam::autoDensity::recurseAndFill
(
std::list<Vb::Point>& initialPoints,
const treeBoundBox& bb,
label levelLimit,
word recursionName
) const
{
for (direction i = 0; i < 8; i++)
{
treeBoundBox subBB = bb.subBbox(i);
word newName = recursionName + "_" + Foam::name(i);
if (debug)
{
cvMesh_.timeCheck(newName);
}
if (combinedOverlaps(subBB))
{
if (levelLimit > 0)
{
recurseAndFill
(
initialPoints,
subBB,
levelLimit - 1,
newName
);
}
else
{
if (debug)
{
writeOBJ
(
subBB,
word(newName + "_overlap")
);
Pout<< newName + "_overlap " << subBB << endl;
}
if (!fillBox(initialPoints, subBB, true))
{
recurseAndFill
(
initialPoints,
subBB,
levelLimit - 1,
newName
);
}
}
}
else if (combinedInside(subBB.midpoint()))
{
if (debug)
{
writeOBJ
(
subBB,
newName + "_inside"
);
Pout<< newName + "_inside " << subBB << endl;
}
if (!fillBox(initialPoints, subBB, false))
{
recurseAndFill
(
initialPoints,
subBB,
levelLimit - 1,
newName
);
}
}
else
{
if (debug)
{
writeOBJ
(
subBB,
newName + "_outside"
);
}
}
}
}
bool Foam::autoDensity::fillBox
(
std::list<Vb::Point>& initialPoints,
const treeBoundBox& bb,
bool overlapping
) const
{
const conformationSurfaces& geometry(cvMesh_.geometryToConformTo());
Random& rnd = cvMesh_.rndGen();
unsigned int initialSize = initialPoints.size();
scalar maxCellSize = -GREAT;
scalar minCellSize = GREAT;
scalar maxDensity = 1/pow3(minCellSize);
scalar volumeAdded = 0.0;
const point& min = bb.min();
vector span = bb.span();
scalar totalVolume = bb.volume();
label trialPoints = 0;
bool wellInside = false;
if (!overlapping)
{
// Check the nearest point on the surface to the box, if it is far
// enough away, then the surface sampling of the box can be skipped.
// Checking if the nearest piece of surface is at least 1.5*bb.span away
// from the bb.midpoint.
pointIndexHit surfHit;
label hitSurface;
geometry.findSurfaceNearest
(
bb.midpoint(),
2.25*magSqr(span),
surfHit,
hitSurface
);
if (!surfHit.hit())
{
if (debug)
{
Pout<< "box wellInside, no need to sample surface." << endl;
}
wellInside = true;
}
}
if (!overlapping && !wellInside)
{
// If this is an inside box then then it is possible to fill points very
// close to the boundary, to prevent this, check the corners and sides
// of the box so ensure that they are "wellInside". If not, set as an
// overlapping box.
pointField corners(bb.points());
scalarField cornerSizes = cvMesh_.cellSizeControl().cellSize(corners);
Field<bool> insideCorners = combinedWellInside(corners, cornerSizes);
// Pout<< corners << nl << cornerSizes << nl << insideCorners << endl;
forAll(insideCorners, i)
{
// Use the sizes to improve the min/max cell size estimate
scalar s = cornerSizes[i];
if (s > maxCellSize)
{
maxCellSize = s;
}
if (s < minCellSize)
{
minCellSize = max(s, minCellSizeLimit_);
}
if (maxCellSize/minCellSize > maxSizeRatio_)
{
if (debug)
{
Pout<< "Abort fill at corner sample stage,"
<< " minCellSize " << minCellSize
<< " maxCellSize " << maxCellSize
<< " maxSizeRatio " << maxCellSize/minCellSize
<< endl;
}
return false;
}
if (!insideCorners[i])
{
// If one or more corners is not "wellInside", then treat this
// as an overlapping box.
if (debug)
{
Pout<< "Inside box found to have some non-wellInside "
<< "corners, using overlapping fill."
<< endl;
}
overlapping = true;
break;
}
}
if (!overlapping)
{
vector delta = span/(surfRes_ - 1);
label nLine = 6*(surfRes_ - 2);
pointField linePoints(nLine, vector::zero);
scalarField lineSizes(nLine, 0.0);
for (label i = 0; i < surfRes_; i++)
{
label lPI = 0;
for (label j = 1; j < surfRes_ - 1 ; j++)
{
linePoints[lPI++] =
min
+ vector(0, delta.y()*i, delta.z()*j);
linePoints[lPI++] =
min
+ vector
(
delta.x()*(surfRes_ - 1),
delta.y()*i,
delta.z()*j
);
linePoints[lPI++] =
min
+ vector(delta.x()*j, 0, delta.z()*i);
linePoints[lPI++] =
min
+ vector
(
delta.x()*j,
delta.y()*(surfRes_ - 1),
delta.z()*i
);
linePoints[lPI++] =
min
+ vector(delta.x()*i, delta.y()*j, 0);
linePoints[lPI++] =
min
+ vector
(
delta.x()*i,
delta.y()*j,
delta.z()*(surfRes_ - 1)
);
}
lineSizes = cvMesh_.cellSizeControl().cellSize(linePoints);
Field<bool> insideLines = combinedWellInside
(
linePoints,
lineSizes
);
forAll(insideLines, i)
{
// Use the sizes to improve the min/max cell size estimate
scalar s = lineSizes[i];
if (s > maxCellSize)
{
maxCellSize = s;
}
if (s < minCellSize)
{
minCellSize = max(s, minCellSizeLimit_);
}
if (maxCellSize/minCellSize > maxSizeRatio_)
{
if (debug)
{
Pout<< "Abort fill at surface sample stage, "
<< " minCellSize " << minCellSize
<< " maxCellSize " << maxCellSize
<< " maxSizeRatio " << maxCellSize/minCellSize
<< endl;
}
return false;
}
if (!insideLines[i])
{
// If one or more surface points is not "wellInside",
// then treat this as an overlapping box.
overlapping = true;
if (debug)
{
Pout<< "Inside box found to have some non-"
<< "wellInside surface points, using "
<< "overlapping fill."
<< endl;
}
break;
}
}
}
}
}
if (overlapping)
{
// Sample the box to find an estimate of the min size, and a volume
// estimate when overlapping == true.
pointField samplePoints
(
volRes_*volRes_*volRes_,
vector::zero
);
vector delta = span/volRes_;
label pI = 0;
for (label i = 0; i < volRes_; i++)
{
for (label j = 0; j < volRes_; j++)
{
for (label k = 0; k < volRes_; k++)
{
// Perturb the points to avoid creating degenerate positions
// in the Delaunay tessellation.
samplePoints[pI++] =
min
+ vector
(
delta.x()*(i + 0.5 + 0.1*(rnd.scalar01() - 0.5)),
delta.y()*(j + 0.5 + 0.1*(rnd.scalar01() - 0.5)),
delta.z()*(k + 0.5 + 0.1*(rnd.scalar01() - 0.5))
);
}
}
}
// Randomise the order of the points to (potentially) improve the speed
// of assessing the density ratio, and prevent a box being filled from a
// corner when only some these points are required.
shuffle(samplePoints);
scalarField sampleSizes = cvMesh_.cellSizeControl().cellSize
(
samplePoints
);
Field<bool> insidePoints = combinedWellInside
(
samplePoints,
sampleSizes
);
label nInside = 0;
forAll(insidePoints, i)
{
if (insidePoints[i])
{
nInside++;
scalar s = sampleSizes[i];
if (s > maxCellSize)
{
maxCellSize = s;
}
if (s < minCellSize)
{
minCellSize = max(s, minCellSizeLimit_);
}
if (maxCellSize/minCellSize > maxSizeRatio_)
{
if (debug)
{
Pout<< "Abort fill at sample stage,"
<< " minCellSize " << minCellSize
<< " maxCellSize " << maxCellSize
<< " maxSizeRatio " << maxCellSize/minCellSize
<< endl;
}
return false;
}
}
}
if (nInside == 0)
{
if (debug)
{
Pout<< "No sample points found inside box" << endl;
}
return true;
}
if (debug)
{
Pout<< scalar(nInside)/scalar(samplePoints.size())
<< " full overlapping box" << endl;
}
totalVolume *= scalar(nInside)/scalar(samplePoints.size());
if (debug)
{
Pout<< "Total volume to fill = " << totalVolume << endl;
}
// Using the sampledPoints as the first test locations as they are
// randomly shuffled, but unfiormly sampling space and have wellInside
// and size data already
maxDensity = 1/pow3(max(minCellSize, SMALL));
forAll(insidePoints, i)
{
if (insidePoints[i])
{
trialPoints++;
point p = samplePoints[i];
scalar localSize = sampleSizes[i];
scalar localDensity = 1/pow3(localSize);
// No need to look at max/min cell size here, already handled
// by sampling
// Accept possible placements proportional to the relative
// local density
// TODO - is there a lot of cost in the 1/density calc? Could
// assess on
// (1/maxDensity)/(1/localDensity) = minVolume/localVolume
if (localDensity/maxDensity > rnd.scalar01())
{
scalar localVolume = 1/localDensity;
if (volumeAdded + localVolume > totalVolume)
{
// Add the final box with a probability of to the ratio
// of the remaining volume to the volume to be added,
// i.e. insert a box of volume 0.5 into a remaining
// volume of 0.1 20% of the time.
scalar addProbability =
(totalVolume - volumeAdded)/localVolume;
scalar r = rnd.scalar01();
if (debug)
{
Pout<< "totalVolume " << totalVolume << nl
<< "volumeAdded " << volumeAdded << nl
<< "localVolume " << localVolume << nl
<< "addProbability " << addProbability << nl
<< "random " << r
<< endl;
}
if (addProbability > r)
{
// Place this volume before finishing filling this
// box
// Pout<< "Final volume probability break accept"
// << endl;
initialPoints.push_back
(
Vb::Point(p.x(), p.y(), p.z())
);
volumeAdded += localVolume;
}
break;
}
initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z()));
volumeAdded += localVolume;
}
}
}
}
if (volumeAdded < totalVolume)
{
if (debug)
{
Pout<< "Adding random points, remaining volume "
<< totalVolume - volumeAdded
<< endl;
}
maxDensity = 1/pow3(max(minCellSize, SMALL));
while (true)
{
trialPoints++;
point p = min + cmptMultiply(span, rnd.vector01());
scalar localSize = cvMesh_.cellSizeControl().cellSize(p);
bool insidePoint = false;
if (!overlapping)
{
insidePoint = true;
}
else
{
// Determine if the point is "wellInside" the domain
insidePoint = combinedWellInside(p, localSize);
}
if (insidePoint)
{
if (localSize > maxCellSize)
{
maxCellSize = localSize;
}
if (localSize < minCellSize)
{
minCellSize = max(localSize, minCellSizeLimit_);
localSize = minCellSize;
// 1/(minimum cell size)^3, gives the maximum permissible
// point density
maxDensity = 1/pow3(max(minCellSize, SMALL));
}
if (maxCellSize/minCellSize > maxSizeRatio_)
{
if (debug)
{
Pout<< "Abort fill at random fill stage,"
<< " minCellSize " << minCellSize
<< " maxCellSize " << maxCellSize
<< " maxSizeRatio " << maxCellSize/minCellSize
<< endl;
}
// Discard any points already filled into this box by
// setting size of initialPoints back to its starting value
initialPoints.resize(initialSize);
return false;
}
scalar localDensity = 1/pow3(max(localSize, SMALL));
// Accept possible placements proportional to the relative local
// density
if (localDensity/maxDensity > rnd.scalar01())
{
scalar localVolume = 1/localDensity;
if (volumeAdded + localVolume > totalVolume)
{
// Add the final box with a probability of to the ratio
// of the remaining volume to the volume to be added,
// i.e. insert a box of volume 0.5 into a remaining
// volume of 0.1 20% of the time.
scalar addProbability =
(totalVolume - volumeAdded)/localVolume;
scalar r = rnd.scalar01();
if (debug)
{
Pout<< "totalVolume " << totalVolume << nl
<< "volumeAdded " << volumeAdded << nl
<< "localVolume " << localVolume << nl
<< "addProbability " << addProbability << nl
<< "random " << r
<< endl;
}
if (addProbability > r)
{
// Place this volume before finishing filling this
// box
// Pout<< "Final volume probability break accept"
// << endl;
initialPoints.push_back
(
Vb::Point(p.x(), p.y(), p.z())
);
volumeAdded += localVolume;
}
break;
}
initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z()));
volumeAdded += localVolume;
}
}
}
}
globalTrialPoints_ += trialPoints;
if (debug)
{
Pout<< trialPoints
<< " locations queried, " << initialPoints.size() - initialSize
<< " points placed, ("
<< scalar(initialPoints.size() - initialSize)
/scalar(max(trialPoints, 1))
<< " success rate)." << nl
<< "minCellSize " << minCellSize
<< ", maxCellSize " << maxCellSize
<< ", ratio " << maxCellSize/minCellSize
<< nl << endl;
}
return true;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
autoDensity::autoDensity
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
)
:
initialPointsMethod(typeName, initialPointsDict, cvMesh),
globalTrialPoints_(0),
minCellSizeLimit_
(
detailsDict().lookupOrDefault<scalar>("minCellSizeLimit", 0.0)
),
minLevels_(readLabel(detailsDict().lookup("minLevels"))),
maxSizeRatio_(readScalar(detailsDict().lookup("maxSizeRatio"))),
volRes_(readLabel(detailsDict().lookup("sampleResolution"))),
surfRes_
(
detailsDict().lookupOrDefault<label>("surfaceSampleResolution", volRes_)
)
{
if (maxSizeRatio_ <= 1.0)
{
maxSizeRatio_ = 2.0;
WarningIn
(
"autoDensity::autoDensity"
"("
"const dictionary& initialPointsDict,"
"const conformalVoronoiMesh& cvMesh"
")"
)
<< "The maxSizeRatio must be greater than one to be sensible, "
<< "setting to " << maxSizeRatio_
<< endl;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
std::list<Vb::Point> autoDensity::initialPoints() const
{
treeBoundBox hierBB;
// Pick up the bounds of this processor, or the whole geometry, depending
// on whether this is a parallel run.
if (Pstream::parRun())
{
hierBB = cvMesh_.decomposition().procBounds();
}
else
{
// Extend the global box to move it off large plane surfaces
hierBB = cvMesh_.geometryToConformTo().globalBounds().extend
(
cvMesh_.rndGen(),
1e-6
);
}
std::list<Vb::Point> initialPoints;
Info<< nl << " " << typeName << endl;
if (debug)
{
Pout<< " Filling box " << hierBB << endl;
}
recurseAndFill
(
initialPoints,
hierBB,
minLevels_ - 1,
"recursionBox"
);
label nInitialPoints = initialPoints.size();
if (Pstream::parRun())
{
reduce(nInitialPoints, sumOp<label>());
reduce(globalTrialPoints_, sumOp<label>());
}
Info<< " " << nInitialPoints << " points placed" << nl
<< " " << globalTrialPoints_ << " locations queried" << nl
<< " "
<< scalar(nInitialPoints)/scalar(max(globalTrialPoints_, 1))
<< " success rate"
<< endl;
return initialPoints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,171 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::autoDensity
Description
Choose random points inside the domain and place them with a probability
proportional to the target density of points.
SourceFiles
autoDensity.C
\*---------------------------------------------------------------------------*/
#ifndef autoDensity_H
#define autoDensity_H
#include "initialPointsMethod.H"
#include "treeBoundBox.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class autoDensity Declaration
\*---------------------------------------------------------------------------*/
class autoDensity
:
public initialPointsMethod
{
private:
// Private data
//- Trial points attempted to be placed in all boxes
mutable label globalTrialPoints_;
//- Smallest minimum cell size allowed, i.e. to avoid high initial
// population of areas of small size
scalar minCellSizeLimit_;
//- Minimum normal level of recursion, can be more if a high density
// ratio is detected
label minLevels_;
//- Maximum allowed ratio of cell size in a box
scalar maxSizeRatio_;
//- How fine should the initial sample of the volume a box be to
// investigate its cell sizes and volume fraction
label volRes_;
//- How fine should the initial sample of the surface of a box be to
// investigate if it is near to a the geometry.
label surfRes_;
// Private Member Functions
//- Check if the given box overlaps the geometry or, in parallel, the
// backgroundMeshDecomposition
bool combinedOverlaps(const treeBoundBox& box) const;
//- Check if the given point is inside the geometry and, in parallel,
// the backgroundMeshDecomposition
bool combinedInside(const point& p) const;
//- Check if the given points are wellInside the geometry and, in
// parallel, inside the backgroundMeshDecomposition
Field<bool> combinedWellInside
(
const pointField& pts,
const scalarField& sizes
) const;
//- Check if the given points are wellInside the geometry and, in
// parallel, inside the backgroundMeshDecomposition
bool combinedWellInside
(
const point& p,
scalar size
) const;
//- Write boundBox as obj
void writeOBJ
(
const treeBoundBox& bb,
fileName name
) const;
//- Descend into octants of the supplied bound box
void recurseAndFill
(
std::list<Vb::Point>& initialPoints,
const treeBoundBox& bb,
label levelLimit,
word recursionName
) const;
//- Fill the given box, optionally filling surface overlapping boxes.
// Returns true if the fill is successful, false if it is to be aborted
// in favour of further recursion.
bool fillBox
(
std::list<Vb::Point>& initialPoints,
const treeBoundBox& bb,
bool overlapping
) const;
public:
//- Runtime type information
TypeName("autoDensity");
// Constructors
//- Construct from components
autoDensity
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
);
//- Destructor
virtual ~autoDensity()
{}
// Member Functions
//- Return the initial points for the conformalVoronoiMesh
virtual std::list<Vb::Point> initialPoints() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,194 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "bodyCentredCubic.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(bodyCentredCubic, 0);
addToRunTimeSelectionTable(initialPointsMethod, bodyCentredCubic, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
bodyCentredCubic::bodyCentredCubic
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
)
:
initialPointsMethod(typeName, initialPointsDict, cvMesh),
initialCellSize_(readScalar(detailsDict().lookup("initialCellSize"))),
randomiseInitialGrid_(detailsDict().lookup("randomiseInitialGrid")),
randomPerturbationCoeff_
(
readScalar(detailsDict().lookup("randomPerturbationCoeff"))
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
std::list<Vb::Point> bodyCentredCubic::initialPoints() const
{
boundBox bb;
// Pick up the bounds of this processor, or the whole geometry, depending
// on whether this is a parallel run.
if (Pstream::parRun())
{
bb = cvMesh_.decomposition().procBounds();
}
else
{
bb = cvMesh_.geometryToConformTo().globalBounds();
}
scalar x0 = bb.min().x();
scalar xR = bb.max().x() - x0;
label ni = label(xR/initialCellSize_);
scalar y0 = bb.min().y();
scalar yR = bb.max().y() - y0;
label nj = label(yR/initialCellSize_);
scalar z0 = bb.min().z();
scalar zR = bb.max().z() - z0;
label nk = label(zR/initialCellSize_);
vector delta(xR/ni, yR/nj, zR/nk);
delta *= pow((1.0/2.0),-(1.0/3.0));
Random& rndGen = cvMesh_.rndGen();
scalar pert = randomPerturbationCoeff_*cmptMin(delta);
std::list<Vb::Point> initialPoints;
for (label i = 0; i < ni; i++)
{
for (label j = 0; j < nj; j++)
{
// Generating, testing and adding points one line at a time to
// reduce the memory requirement for cases with bounding boxes that
// are very large in comparison to the volume to be filled
label pI = 0;
pointField points(2*nk);
for (label k = 0; k < nk; k++)
{
point pA
(
x0 + i*delta.x(),
y0 + j*delta.y(),
z0 + k*delta.z()
);
point pB = pA + 0.5*delta;
if (randomiseInitialGrid_)
{
pA.x() += pert*(rndGen.scalar01() - 0.5);
pA.y() += pert*(rndGen.scalar01() - 0.5);
pA.z() += pert*(rndGen.scalar01() - 0.5);
}
if (Pstream::parRun())
{
if (cvMesh_.decomposition().positionOnThisProcessor(pA))
{
// Add this point in parallel only if this position is
// on this processor.
points[pI++] = pA;
}
}
else
{
points[pI++] = pA;
}
if (randomiseInitialGrid_)
{
pB.x() += pert*(rndGen.scalar01() - 0.5);
pB.y() += pert*(rndGen.scalar01() - 0.5);
pB.z() += pert*(rndGen.scalar01() - 0.5);
}
if (Pstream::parRun())
{
if (cvMesh_.decomposition().positionOnThisProcessor(pB))
{
// Add this point in parallel only if this position is
// on this processor.
points[pI++] = pB;
}
}
else
{
points[pI++] = pB;
}
}
points.setSize(pI);
Field<bool> insidePoints = cvMesh_.geometryToConformTo().wellInside
(
points,
minimumSurfaceDistanceCoeffSqr_
*sqr
(
cvMesh_.cellSizeControl().cellSize(points)
)
);
forAll(insidePoints, i)
{
if (insidePoints[i])
{
const point& p(points[i]);
initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z()));
}
}
}
}
return initialPoints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,104 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::bodyCentredCubic
Description
Generate a BCC lattice of points inside the surfaces to be
conformed to of the conformalVoronoiMesh
SourceFiles
bodyCentredCubic.C
\*---------------------------------------------------------------------------*/
#ifndef bodyCentredCubic_H
#define bodyCentredCubic_H
#include "initialPointsMethod.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class bodyCentredCubic Declaration
\*---------------------------------------------------------------------------*/
class bodyCentredCubic
:
public initialPointsMethod
{
private:
// Private data
//- The initial cell spacing
scalar initialCellSize_;
//- Should the initial positions be randomised
Switch randomiseInitialGrid_;
//- Randomise the initial positions by fraction of the initialCellSize_
scalar randomPerturbationCoeff_;
public:
//- Runtime type information
TypeName("bodyCentredCubic");
// Constructors
//- Construct from components
bodyCentredCubic
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
);
//- Destructor
virtual ~bodyCentredCubic()
{}
// Member Functions
//- Return the initial points for the conformalVoronoiMesh
virtual std::list<Vb::Point> initialPoints() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,255 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "faceCentredCubic.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(faceCentredCubic, 0);
addToRunTimeSelectionTable(initialPointsMethod, faceCentredCubic, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
faceCentredCubic::faceCentredCubic
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
)
:
initialPointsMethod(typeName, initialPointsDict, cvMesh),
initialCellSize_(readScalar(detailsDict().lookup("initialCellSize"))),
randomiseInitialGrid_(detailsDict().lookup("randomiseInitialGrid")),
randomPerturbationCoeff_
(
readScalar(detailsDict().lookup("randomPerturbationCoeff"))
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
std::list<Vb::Point> faceCentredCubic::initialPoints() const
{
boundBox bb;
// Pick up the bounds of this processor, or the whole geometry, depending
// on whether this is a parallel run.
if (Pstream::parRun())
{
bb = cvMesh_.decomposition().procBounds();
}
else
{
bb = cvMesh_.geometryToConformTo().globalBounds();
}
scalar x0 = bb.min().x();
scalar xR = bb.max().x() - x0;
label ni = label(xR/initialCellSize_);
scalar y0 = bb.min().y();
scalar yR = bb.max().y() - y0;
label nj = label(yR/initialCellSize_);
scalar z0 = bb.min().z();
scalar zR = bb.max().z() - z0;
label nk = label(zR/initialCellSize_);
vector delta(xR/ni, yR/nj, zR/nk);
delta *= pow((1.0/4.0),-(1.0/3.0));
Random& rndGen = cvMesh_.rndGen();
scalar pert = randomPerturbationCoeff_*cmptMin(delta);
std::list<Vb::Point> initialPoints;
for (label i = 0; i < ni; i++)
{
for (label j = 0; j < nj; j++)
{
// Generating, testing and adding points one line at a time to
// reduce the memory requirement for cases with bounding boxes that
// are very large in comparison to the volume to be filled
label pI = 0;
pointField points(4*nk);
for (label k = 0; k < nk; k++)
{
point p
(
x0 + i*delta.x(),
y0 + j*delta.y(),
z0 + k*delta.z()
);
if (randomiseInitialGrid_)
{
p.x() += pert*(rndGen.scalar01() - 0.5);
p.y() += pert*(rndGen.scalar01() - 0.5);
p.z() += pert*(rndGen.scalar01() - 0.5);
}
if (Pstream::parRun())
{
if (cvMesh_.decomposition().positionOnThisProcessor(p))
{
// Add this point in parallel only if this position is
// on this processor.
points[pI++] = p;
}
}
else
{
points[pI++] = p;
}
p = point
(
x0 + i*delta.x(),
y0 + (j + 0.5)*delta.y(),
z0 + (k + 0.5)*delta.z()
);
if (randomiseInitialGrid_)
{
p.x() += pert*(rndGen.scalar01() - 0.5);
p.y() += pert*(rndGen.scalar01() - 0.5);
p.z() += pert*(rndGen.scalar01() - 0.5);
}
if (Pstream::parRun())
{
if (cvMesh_.decomposition().positionOnThisProcessor(p))
{
// Add this point in parallel only if this position is
// on this processor.
points[pI++] = p;
}
}
else
{
points[pI++] = p;
}
p = point
(
x0 + (i + 0.5)*delta.x(),
y0 + j*delta.y(),
z0 + (k + 0.5)*delta.z()
);
if (randomiseInitialGrid_)
{
p.x() += pert*(rndGen.scalar01() - 0.5);
p.y() += pert*(rndGen.scalar01() - 0.5);
p.z() += pert*(rndGen.scalar01() - 0.5);
}
if (Pstream::parRun())
{
if (cvMesh_.decomposition().positionOnThisProcessor(p))
{
// Add this point in parallel only if this position is
// on this processor.
points[pI++] = p;
}
}
else
{
points[pI++] = p;
}
p = point
(
x0 + (i + 0.5)*delta.x(),
y0 + (j + 0.5)*delta.y(),
z0 + k*delta.z()
);
if (randomiseInitialGrid_)
{
p.x() += pert*(rndGen.scalar01() - 0.5);
p.y() += pert*(rndGen.scalar01() - 0.5);
p.z() += pert*(rndGen.scalar01() - 0.5);
}
if (Pstream::parRun())
{
if (cvMesh_.decomposition().positionOnThisProcessor(p))
{
// Add this point in parallel only if this position is
// on this processor.
points[pI++] = p;
}
}
else
{
points[pI++] = p;
}
}
points.setSize(pI);
Field<bool> insidePoints = cvMesh_.geometryToConformTo().wellInside
(
points,
minimumSurfaceDistanceCoeffSqr_
*sqr
(
cvMesh_.cellSizeControl().cellSize(points)
)
);
forAll(insidePoints, i)
{
if (insidePoints[i])
{
const point& p(points[i]);
initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z()));
}
}
}
}
return initialPoints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,104 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::faceCentredCubic
Description
Generate an FCC lattice of points inside the surfaces to be
conformed to of the conformalVoronoiMesh
SourceFiles
faceCentredCubic.C
\*---------------------------------------------------------------------------*/
#ifndef faceCentredCubic_H
#define faceCentredCubic_H
#include "initialPointsMethod.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faceCentredCubic Declaration
\*---------------------------------------------------------------------------*/
class faceCentredCubic
:
public initialPointsMethod
{
private:
// Private data
//- The initial cell spacing
scalar initialCellSize_;
//- Should the initial positions be randomised
Switch randomiseInitialGrid_;
//- Randomise the initial positions by fraction of the initialCellSize_
scalar randomPerturbationCoeff_;
public:
//- Runtime type information
TypeName("faceCentredCubic");
// Constructors
//- Construct from components
faceCentredCubic
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
);
//- Destructor
virtual ~faceCentredCubic()
{}
// Member Functions
//- Return the initial points for the conformalVoronoiMesh
virtual std::list<Vb::Point> initialPoints() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,112 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "initialPointsMethod.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defineTypeNameAndDebug(initialPointsMethod, 0);
defineRunTimeSelectionTable(initialPointsMethod, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
initialPointsMethod::initialPointsMethod
(
const word& type,
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
)
:
dictionary(initialPointsDict),
cvMesh_(cvMesh),
detailsDict_(subDict(type + "Coeffs")),
minimumSurfaceDistanceCoeffSqr_
(
sqr
(
readScalar
(
initialPointsDict.lookup("minimumSurfaceDistanceCoeff")
)
)
)
{}
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
autoPtr<initialPointsMethod> initialPointsMethod::New
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
)
{
word initialPointsMethodTypeName
(
initialPointsDict.lookup("initialPointsMethod")
);
Info<< nl << "Selecting initialPointsMethod "
<< initialPointsMethodTypeName << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(initialPointsMethodTypeName);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"initialPointsMethod::New(dictionary&, "
"const conformalVoronoiMesh&)"
) << "Unknown initialPointsMethod type "
<< initialPointsMethodTypeName
<< endl << endl
<< "Valid initialPointsMethod types are :" << endl
<< dictionaryConstructorTablePtr_->toc()
<< exit(FatalError);
}
return autoPtr<initialPointsMethod>(cstrIter()(initialPointsDict, cvMesh));
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
initialPointsMethod::~initialPointsMethod()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,154 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::initialPointsMethod
Description
Abstract base class for generating initial points for a conformalVoronoiMesh
SourceFiles
initialPointsMethod.C
\*---------------------------------------------------------------------------*/
#ifndef initialPointsMethod_H
#define initialPointsMethod_H
#include "point.H"
#include "conformalVoronoiMesh.H"
#include "backgroundMeshDecomposition.H"
#include "dictionary.H"
#include "Random.H"
#include "Switch.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class initialPointsMethod Declaration
\*---------------------------------------------------------------------------*/
class initialPointsMethod
:
public dictionary
{
protected:
// Protected data
//- Reference to the conformalVoronoiMesh holding this object
const conformalVoronoiMesh& cvMesh_;
//- Method details dictionary
dictionary detailsDict_;
//- Only allow the placement of initial points that are within the
// surfaces to be meshed by minimumSurfaceDistanceCoeff multiplied by
// the local target cell size. Store square of value.
scalar minimumSurfaceDistanceCoeffSqr_;
private:
// Private Member Functions
//- Disallow default bitwise copy construct
initialPointsMethod(const initialPointsMethod&);
//- Disallow default bitwise assignment
void operator=(const initialPointsMethod&);
public:
//- Runtime type information
TypeName("initialPointsMethod");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
initialPointsMethod,
dictionary,
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
),
(initialPointsDict, cvMesh)
);
// Constructors
//- Construct from components
initialPointsMethod
(
const word& type,
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
);
// Selectors
//- Return a reference to the selected initialPointsMethod
static autoPtr<initialPointsMethod> New
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
);
//- Destructor
virtual ~initialPointsMethod();
// Member Functions
//- Const access to the details dictionary
const dictionary& detailsDict() const
{
return detailsDict_;
}
//- Return the initial points for the conformalVoronoiMesh
virtual std::list<Vb::Point> initialPoints() const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,172 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "pointFile.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(pointFile, 0);
addToRunTimeSelectionTable(initialPointsMethod, pointFile, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
pointFile::pointFile
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
)
:
initialPointsMethod(typeName, initialPointsDict, cvMesh),
pointFileName_(detailsDict().lookup("pointFile"))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
std::list<Vb::Point> pointFile::initialPoints() const
{
pointIOField points
(
IOobject
(
pointFileName_.name(),
cvMesh_.time().constant(),
cvMesh_.time(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
Info<< " Inserting points from file " << pointFileName_ << endl;
if (points.empty())
{
FatalErrorIn("std::list<Vb::Point> pointFile::initialPoints() const")
<< "Point file contain no points"
<< exit(FatalError) << endl;
}
if (Pstream::parRun())
{
// Testing filePath to see if the file originated in a processor
// directory, if so, assume that the points in each processor file
// are unique. They are unlikely to belong on the current
// processor as the background mesh is unlikely to be the same.
const bool isParentFile = (points.objectPath() != points.filePath());
if (!isParentFile)
{
cvMesh_.decomposition().distributePoints(points);
}
else
{
// Otherwise, this is assumed to be points covering the whole
// domain, so filter the points to be only those on this processor
boolList procPt(cvMesh_.positionOnThisProc(points));
List<boolList> allProcPt(Pstream::nProcs());
allProcPt[Pstream::myProcNo()] = procPt;
Pstream::gatherList(allProcPt);
Pstream::scatterList(allProcPt);
forAll(procPt, ptI)
{
bool foundAlready = false;
forAll(allProcPt, procI)
{
// If a processor with a lower index has found this point
// to insert already, defer to it and don't insert.
if (foundAlready)
{
allProcPt[procI][ptI] = false;
}
else if (allProcPt[procI][ptI])
{
foundAlready = true;
}
}
}
procPt = allProcPt[Pstream::myProcNo()];
inplaceSubset(procPt, points);
}
}
std::list<Vb::Point> initialPoints;
Field<bool> insidePoints = cvMesh_.geometryToConformTo().wellInside
(
points,
minimumSurfaceDistanceCoeffSqr_
*sqr
(
cvMesh_.cellSizeControl().cellSize(points)
)
);
forAll(insidePoints, i)
{
if (insidePoints[i])
{
const point& p(points[i]);
initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z()));
}
}
label nPointsRejected = points.size() - initialPoints.size();
if (Pstream::parRun())
{
reduce(nPointsRejected, sumOp<label>());
}
if (nPointsRejected)
{
Info<< " " << nPointsRejected << " points rejected from "
<< pointFileName_.name() << endl;
}
return initialPoints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,100 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::pointFile
Description
Inserts points at locations specified in a pointFile into the surfaces to
be conformed to of the conformalVoronoiMesh
SourceFiles
pointFile.C
\*---------------------------------------------------------------------------*/
#ifndef pointFile_H
#define pointFile_H
#include "fileName.H"
#include "pointIOField.H"
#include "initialPointsMethod.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class pointFile Declaration
\*---------------------------------------------------------------------------*/
class pointFile
:
public initialPointsMethod
{
private:
// Private data
//- The initial cell spacing
fileName pointFileName_;
public:
//- Runtime type information
TypeName("pointFile");
// Constructors
//- Construct from components
pointFile
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
);
//- Destructor
virtual ~pointFile()
{}
// Member Functions
//- Return the initial points for the conformalVoronoiMesh
virtual std::list<Vb::Point> initialPoints() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,170 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "uniformGrid.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(uniformGrid, 0);
addToRunTimeSelectionTable(initialPointsMethod, uniformGrid, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
uniformGrid::uniformGrid
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
)
:
initialPointsMethod(typeName, initialPointsDict, cvMesh),
initialCellSize_(readScalar(detailsDict().lookup("initialCellSize"))),
randomiseInitialGrid_(detailsDict().lookup("randomiseInitialGrid")),
randomPerturbationCoeff_
(
readScalar(detailsDict().lookup("randomPerturbationCoeff"))
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
std::list<Vb::Point> uniformGrid::initialPoints() const
{
boundBox bb;
// Pick up the bounds of this processor, or the whole geometry, depending
// on whether this is a parallel run.
if (Pstream::parRun())
{
bb = cvMesh_.decomposition().procBounds();
}
else
{
bb = cvMesh_.geometryToConformTo().globalBounds();
}
scalar x0 = bb.min().x();
scalar xR = bb.max().x() - x0;
label ni = label(xR/initialCellSize_);
scalar y0 = bb.min().y();
scalar yR = bb.max().y() - y0;
label nj = label(yR/initialCellSize_);
scalar z0 = bb.min().z();
scalar zR = bb.max().z() - z0;
label nk = label(zR/initialCellSize_);
vector delta(xR/ni, yR/nj, zR/nk);
delta *= pow((1.0),-(1.0/3.0));
Random& rndGen = cvMesh_.rndGen();
scalar pert = randomPerturbationCoeff_*cmptMin(delta);
std::list<Vb::Point> initialPoints;
for (label i = 0; i < ni; i++)
{
for (label j = 0; j < nj; j++)
{
// Generating, testing and adding points one line at a time to
// reduce the memory requirement for cases with bounding boxes that
// are very large in comparison to the volume to be filled
label pI = 0;
pointField points(nk);
for (label k = 0; k < nk; k++)
{
point p
(
x0 + (i + 0.5)*delta.x(),
y0 + (j + 0.5)*delta.y(),
z0 + (k + 0.5)*delta.z()
);
if (randomiseInitialGrid_)
{
p.x() += pert*(rndGen.scalar01() - 0.5);
p.y() += pert*(rndGen.scalar01() - 0.5);
p.z() += pert*(rndGen.scalar01() - 0.5);
}
if
(
Pstream::parRun()
&& !cvMesh_.decomposition().positionOnThisProcessor(p)
)
{
// Skip this point if, in parallel, this position is not on
// this processor.
continue;
}
points[pI++] = p;
}
points.setSize(pI);
Field<bool> insidePoints = cvMesh_.geometryToConformTo().wellInside
(
points,
minimumSurfaceDistanceCoeffSqr_
*sqr
(
cvMesh_.cellSizeControl().cellSize(points)
)
);
forAll(insidePoints, i)
{
if (insidePoints[i])
{
const point& p(points[i]);
initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z()));
}
}
}
}
return initialPoints;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,104 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::uniformGrid
Description
Generate a uniform grid of points inside the surfaces to be
conformed to of the conformalVoronoiMesh
SourceFiles
uniformGrid.C
\*---------------------------------------------------------------------------*/
#ifndef uniformGrid_H
#define uniformGrid_H
#include "initialPointsMethod.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class uniformGrid Declaration
\*---------------------------------------------------------------------------*/
class uniformGrid
:
public initialPointsMethod
{
private:
// Private data
//- The initial cell spacing
scalar initialCellSize_;
//- Should the initial positions be randomised
Switch randomiseInitialGrid_;
//- Randomise the initial positions by fraction of the initialCellSize_
scalar randomPerturbationCoeff_;
public:
//- Runtime type information
TypeName("uniformGrid");
// Constructors
//- Construct from components
uniformGrid
(
const dictionary& initialPointsDict,
const conformalVoronoiMesh& cvMesh
);
//- Destructor
virtual ~uniformGrid()
{}
// Member Functions
//- Return the initial points for the conformalVoronoiMesh
virtual std::list<Vb::Point> initialPoints() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,87 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "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_)
{
scalar currentRelxation = relaxation_;
relaxation_ -=
(relaxation_ - relaxationEnd_)
/(
(
cvMesh_.time().endTime().value()
- cvMesh_.time().timeOutputValue()
)
/(cvMesh_.time().timeOutputValue() - lastTimeValue_)
+ 1
);
lastTimeValue_ = cvMesh_.time().timeOutputValue();
return currentRelxation;
}
return relaxation_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,110 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::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

@ -1,103 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "rampHoldFall.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(rampHoldFall, 0);
addToRunTimeSelectionTable(relaxationModel, rampHoldFall, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
rampHoldFall::rampHoldFall
(
const dictionary& relaxationDict,
const conformalVoronoiMesh& cvMesh
)
:
relaxationModel(typeName, relaxationDict, cvMesh),
rampStartRelaxation_(readScalar(coeffDict().lookup("rampStartRelaxation"))),
holdRelaxation_(readScalar(coeffDict().lookup("holdRelaxation"))),
fallEndRelaxation_(readScalar(coeffDict().lookup("fallEndRelaxation"))),
rampEndFraction_(readScalar(coeffDict().lookup("rampEndFraction"))),
fallStartFraction_(readScalar(coeffDict().lookup("fallStartFraction"))),
rampGradient_((holdRelaxation_ - rampStartRelaxation_)/(rampEndFraction_)),
fallGradient_
(
(fallEndRelaxation_ - holdRelaxation_)/(1 - fallStartFraction_)
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
scalar rampHoldFall::relaxation()
{
scalar t = cvMesh_.time().timeOutputValue();
scalar tStart = cvMesh_.time().startTime().value();
scalar tEnd = cvMesh_.time().endTime().value();
scalar tSpan = tEnd - tStart;
if (tSpan < VSMALL)
{
return rampStartRelaxation_;
}
if (t - tStart < rampEndFraction_*tSpan)
{
// Ramp
return rampGradient_*((t - tStart)/tSpan) + rampStartRelaxation_;
}
else if (t - tStart > fallStartFraction_*tSpan)
{
// Fall
return
fallGradient_*((t - tStart)/tSpan)
+ fallEndRelaxation_ - fallGradient_;
}
else
{
//Hold
return holdRelaxation_;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,115 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::rampHoldFall
Description
Piecewise linear function with a ramp from a start value to a plateaux
value, holding at this, then a linear fall to an end value.
SourceFiles
rampHoldFall.C
\*---------------------------------------------------------------------------*/
#ifndef rampHoldFall_H
#define rampHoldFall_H
#include "relaxationModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class rampHoldFall Declaration
\*---------------------------------------------------------------------------*/
class rampHoldFall
:
public relaxationModel
{
private:
// Private data
//- Relaxation coefficient at the start of the ramp
scalar rampStartRelaxation_;
//- Relaxation coefficient for the hold portion
scalar holdRelaxation_;
//- Relaxation coefficient at the end of the fall
scalar fallEndRelaxation_;
//- Fraction through the run where the ramp ends and the hold starts
scalar rampEndFraction_;
//- Fraction through the run where the hold ends and the fall starts
scalar fallStartFraction_;
//- Gradient in ramp portion, normalised against time
scalar rampGradient_;
//- Gradient in fall portion, normalised against time
scalar fallGradient_;
public:
//- Runtime type information
TypeName("rampHoldFall");
// Constructors
//- Construct from components
rampHoldFall
(
const dictionary& relaxationDict,
const conformalVoronoiMesh& cvMesh
);
//- Destructor
virtual ~rampHoldFall()
{}
// Member Functions
//- Return the current relaxation coefficient
virtual scalar relaxation();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,102 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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 "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()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,147 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2011 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 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::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
// ************************************************************************* //