Commit 944c8360 authored by Franjo's avatar Franjo
Browse files

Merge branch 'defect-polyMeshEdgeExtraction' into development

parents 322c67bd 265a9230
# -*- mode: org; -*-
#
#+TITLE: *cfMesh README for version 1.0*
#+TITLE: *cfMesh README*
#+AUTHOR: Franjo Juretic.
#+DATE: May 2014
#+DATE: May 2015
#+LINK: http://www.c-fields.com
#+OPTIONS:
......@@ -18,7 +18,7 @@ cfMesh is a library for mesh generation built on OpenFOAM.
cfMesh is developed and tested on Linux and MS Windows.
* Installation
The binaries can be downloaded from www.c-fields.com
Binaries and the source code can be downloaded from http://sourceforge.net/projects/cfmesh/
* Building from Sources (Optional)
......@@ -37,7 +37,19 @@ cfMesh is a library for mesh generation built on OpenFOAM.
+ cd $FOAM_RUN/tutorials/asmoOctree
+ cartesianMesh
All cases have Allrun and Allclean scripts shoeing the commands which shall be executed.
All cases have Allrun and Allclean scripts guiding you through the meshing process.
* Documentation
http://www.c-fields.com
http://www.c-fields.com and in the userGuide folder.
* List of contributors
Franjo Juretic
Philippose Rajan
Ivor Clifford
Nebojsa Gavrilov
* How to contribute
It you are interested in contributing to cfMesh please send an e-mail at: info@c-fields.com
We gladly accept contributions, whether they are the code, validation data, documentation, promotional material, etc.
cfMesh development process follows the git-flow branching model, described in http://nvie.com/posts/a-successful-git-branching-model/.
......@@ -164,7 +164,7 @@ $(polyMeshGen2DEngine)/polyMeshGen2DEngine.C
$(coordinateModification)/coordinateModification.C
$(coordinateModification)/newCoordinateModification.C
$(coordinateModification)/planeTranslation.C
$(coordinateModification)/planeScaling.C
$(coordinateModification)/boxScaling.C
$(edgeMeshGeometryModification)/edgeMeshGeometryModification.C
......
......@@ -220,12 +220,15 @@ void cartesian2DMeshGenerator::generateMesh()
extractPatches();
}
if( controller_.runCurrentStep("boundaryLayerGeneration") )
if( controller_.runCurrentStep("edgeExtraction") )
{
mapEdgesAndCorners();
optimiseMeshSurface();
}
if( controller_.runCurrentStep("boundaryLayerGeneration") )
{
generateBoundaryLayers();
}
......
......@@ -153,7 +153,12 @@ void cartesianMeshGenerator::refBoundaryLayers()
refLayers.refineLayers();
meshOptimizer(mesh_).untangleBoundaryLayer();
labelLongList pointsInLayer;
refLayers.pointsInBndLayer(pointsInLayer);
meshOptimizer mOpt(mesh_);
mOpt.lockPoints(pointsInLayer);
mOpt.untangleBoundaryLayer();
}
}
......
......@@ -157,12 +157,12 @@ void tetMeshGenerator::optimiseFinalMesh()
optimizer.optimizeSurface(*octreePtr_);
deleteDemandDrivenData(octreePtr_);
optimizer.optimizeMeshFV();
optimizer.optimizeLowQualityFaces();
optimizer.optimizeBoundaryLayer(false);
optimizer.optimizeMeshFV();
optimizer.untangleMeshFV();
deleteDemandDrivenData(octreePtr_);
mesh_.clearAddressingData();
......@@ -214,7 +214,12 @@ void tetMeshGenerator::refBoundaryLayers()
refLayers.refineLayers();
meshOptimizer(mesh_).untangleBoundaryLayer();
labelLongList pointsInLayer;
refLayers.pointsInBndLayer(pointsInLayer);
meshOptimizer opt(mesh_);
opt.lockPoints(pointsInLayer);
opt.untangleBoundaryLayer();
}
}
......
......@@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "planeTranslation.H"
#include "planeScaling.H"
#include "addToRunTimeSelectionTable.H"
#include "boundBox.H"
#include "plane.H"
......@@ -33,38 +33,38 @@ License
namespace Foam
{
defineTypeNameAndDebug(planeTranslation, 0);
defineTypeNameAndDebug(planeScaling, 0);
addToRunTimeSelectionTable
(
coordinateModification,
planeTranslation,
planeScaling,
dictionary
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
planeTranslation::planeTranslation()
planeScaling::planeScaling()
:
coordinateModification(),
origin_(vector::zero),
normal_(1, 1, 1),
translationDistance_(0.0),
scalingDistance_(0.0),
scalingFactor_(1.0)
{}
planeTranslation::planeTranslation
planeScaling::planeScaling
(
const word& name,
const point& origin,
const vector& normal,
const scalar translationDistance,
const scalar scalingDistance,
const scalar scalingFactor
)
:
coordinateModification(),
origin_(origin),
normal_(normal/mag(normal)),
translationDistance_(translationDistance),
scalingDistance_(scalingDistance),
scalingFactor_(scalingFactor)
{
if( scalingFactor_ < SMALL )
......@@ -78,7 +78,7 @@ planeTranslation::planeTranslation
setName(name);
}
planeTranslation::planeTranslation
planeScaling::planeScaling
(
const word& name,
const dictionary& dict
......@@ -91,59 +91,59 @@ planeTranslation::planeTranslation
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
point planeTranslation::origin() const
point planeScaling::origin() const
{
return origin_;
}
void planeTranslation::translateAndModifyObject(const vector& disp)
void planeScaling::translateAndModifyObject(const vector& disp)
{
origin_ += disp;
translationDistance_ /= scalingFactor_;
scalingDistance_ /= scalingFactor_;
}
vector planeTranslation::displacement(const point& p) const
vector planeScaling::displacement(const point& p) const
{
const scalar dist = (p - origin_) & normal_;
const vector translationVec =
normal_ * translationDistance_ * ((1.0/scalingFactor_) - 1.0);
normal_ * scalingDistance_ * ((1.0/scalingFactor_) - 1.0);
const scalar t = dist / translationDistance_;
const scalar t = dist / scalingDistance_;
const scalar tBnd = Foam::max(0.0, Foam::min(1.0, t));
return tBnd * translationVec;
}
vector planeTranslation::backwardDisplacement(const point& p) const
vector planeScaling::backwardDisplacement(const point& p) const
{
const scalar dist = (p - origin_) & normal_;
const vector translationVec =
normal_ * translationDistance_ * (scalingFactor_ - 1.0);
normal_ * scalingDistance_ * (scalingFactor_ - 1.0);
const scalar t = dist / translationDistance_;
const scalar t = dist / scalingDistance_;
const scalar tBnd = Foam::max(0.0, Foam::min(1.0, t));
return tBnd * translationVec;
}
bool planeTranslation::combiningPossible() const
bool planeScaling::combiningPossible() const
{
return true;
}
void planeTranslation::boundingPlanes(PtrList<plane>& pl) const
void planeScaling::boundingPlanes(PtrList<plane>& pl) const
{
if( Foam::mag(scalingFactor_ - 1.0) > VSMALL )
{
pl.setSize(2);
pl.set(0, new plane(origin_, normal_));
pl.set(1, new plane(origin_ + translationDistance_ * normal_, normal_));
pl.set(1, new plane(origin_ + scalingDistance_ * normal_, normal_));
}
else
{
......@@ -153,7 +153,7 @@ void planeTranslation::boundingPlanes(PtrList<plane>& pl) const
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionary planeTranslation::dict(bool ignoreType) const
dictionary planeScaling::dict(bool ignoreType) const
{
dictionary dict;
......@@ -161,22 +161,22 @@ dictionary planeTranslation::dict(bool ignoreType) const
dict.add("origin", origin_);
dict.add("normal", normal_);
dict.add("translationDistance", translationDistance_);
dict.add("scalingDistance", scalingDistance_);
dict.add("scalingFactor", scalingFactor_);
return dict;
}
void planeTranslation::write(Ostream& os) const
void planeScaling::write(Ostream& os) const
{
os << " type: " << type()
<< " origin: " << origin_
<< " normal: " << normal_
<< " translationDistance: " << translationDistance_
<< " scalingDistance: " << scalingDistance_
<< " scalingFactor: " << scalingFactor_;
}
void planeTranslation::writeDict(Ostream& os, bool subDict) const
void planeScaling::writeDict(Ostream& os, bool subDict) const
{
if( subDict )
{
......@@ -191,7 +191,7 @@ void planeTranslation::writeDict(Ostream& os, bool subDict) const
os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl;
os.writeKeyword("normal") << normal_ << token::END_STATEMENT << nl;
os.writeKeyword("translationDistamce") << translationDistance_
os.writeKeyword("scalingDistance") << scalingDistance_
<< token::END_STATEMENT << nl;
os.writeKeyword("scalingFactor") << scalingFactor_
<< token::END_STATEMENT << nl;
......@@ -202,7 +202,7 @@ void planeTranslation::writeDict(Ostream& os, bool subDict) const
}
}
void planeTranslation::operator=(const dictionary& d)
void planeScaling::operator=(const dictionary& d)
{
// allow as embedded sub-dictionary "coordinateSystem"
const dictionary& dict =
......@@ -221,7 +221,7 @@ void planeTranslation::operator=(const dictionary& d)
{
FatalErrorIn
(
"void planeTranslation::operator=(const dictionary& d)"
"void planeScaling::operator=(const dictionary& d)"
) << "Entry origin is not specified!" << exit(FatalError);
origin_ = vector::zero;
......@@ -236,25 +236,25 @@ void planeTranslation::operator=(const dictionary& d)
{
FatalErrorIn
(
"void planeTranslation::operator=(const dictionary& d)"
"void planeScaling::operator=(const dictionary& d)"
) << "Entry lengthX is not specified!" << exit(FatalError);
normal_ = vector(1, 1, 1);
}
// specify translation distance
if( dict.found("translationDistance") )
if( dict.found("scalingDistance") )
{
translationDistance_ = readScalar(dict.lookup("translationDistance"));
scalingDistance_ = readScalar(dict.lookup("scalingDistance"));
}
else
{
FatalErrorIn
(
"void planeTranslation::operator=(const dictionary& d)"
) << "Entry translationDistance is not specified!" << exit(FatalError);
"void planeScaling::operator=(const dictionary& d)"
) << "Entry scalingDistance is not specified!" << exit(FatalError);
translationDistance_ = 0.0;
scalingDistance_ = 0.0;
}
// specify scaling factor
......@@ -266,7 +266,7 @@ void planeTranslation::operator=(const dictionary& d)
{
WarningIn
(
"void planeTranslation::operator=(const dictionary& d)"
"void planeScaling::operator=(const dictionary& d)"
) << "Entry scalingFactor is not specified!" << endl;
scalingFactor_ = 1.0;
......@@ -275,14 +275,14 @@ void planeTranslation::operator=(const dictionary& d)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Ostream& planeTranslation::operator<<(Ostream& os) const
Ostream& planeScaling::operator<<(Ostream& os) const
{
os << "name " << name() << nl;
write(os);
return os;
}
Ostream& operator<<(Ostream& os, const planeTranslation& pt)
Ostream& operator<<(Ostream& os, const planeScaling& pt)
{
return pt.operator<<(os);
}
......
......@@ -22,18 +22,19 @@ License
along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
planeTranslation
planeScaling
Description
Applies translation to points on the positive side of the plane.
Applies scaling to points on the positive side of the plane within
the scaling distance.
SourceFiles
planeTranslation.C
planeScaling.C
\*---------------------------------------------------------------------------*/
#ifndef planeTranslation_H
#define planeTranslation_H
#ifndef planeScaling_H
#define planeScaling_H
#include "coordinateModification.H"
......@@ -43,10 +44,10 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class planeTranslation Declaration
Class planeScaling Declaration
\*---------------------------------------------------------------------------*/
class planeTranslation
class planeScaling
:
public coordinateModification
{
......@@ -57,8 +58,8 @@ class planeTranslation
//- normal vector
vector normal_;
//- translation distance
scalar translationDistance_;
//- scaling distance
scalar scalingDistance_;
//- scaling factor
scalar scalingFactor_;
......@@ -72,35 +73,35 @@ public:
// Constructors
//- Null construct
planeTranslation();
planeScaling();
//- Construct from name, origin, normal, translation distance and scale
planeTranslation
planeScaling
(
const word& name,
const point& original,
const vector& normal,
const scalar translationDistance,
const scalar scalingDistance,
const scalar scalingFactor
);
//- Construct from dictionary
planeTranslation(const word& name, const dictionary& dict);
planeScaling(const word& name, const dictionary& dict);
//- Construct and return a clone
virtual autoPtr<coordinateModification> clone
(
const planeTranslation& pt
const planeScaling& pt
) const
{
return autoPtr<coordinateModification>
(
new planeTranslation
new planeScaling
(
pt.name(),
pt.origin_,
pt.normal_,
pt.translationDistance_,
pt.scalingDistance_,
pt.scalingFactor_
)
);
......@@ -147,7 +148,7 @@ public:
// IOstream Operators
Ostream& operator<<(Ostream&) const;
friend Ostream& operator<<(Ostream&, const planeTranslation&);
friend Ostream& operator<<(Ostream&, const planeScaling&);
};
......
......@@ -1344,6 +1344,8 @@ void extrudeLayer::updateBoundary()
PtrList<boundaryPatch>& boundaries = meshModifier.boundariesAccess();
forAll(boundaries, patchI)
boundaries[patchI].patchType() = patchTypes[patchI];
meshModifier.clearAll();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -1375,6 +1377,8 @@ extrudeLayer::extrudeLayer
updateBoundary();
mesh_.clearAddressingData();
# ifdef DEBUGExtrudeLayer
polyMeshGenChecks::checkMesh(mesh_, true);
# endif
......
......@@ -372,6 +372,36 @@ void refineBoundaryLayers::refineLayers()
Info << "Finished refining boundary layers" << endl;
}
void refineBoundaryLayers::pointsInBndLayer(labelLongList& layerPoints)
{
layerPoints.clear();
boolList pointInLayer(mesh_.points().size(), false);
forAll(newVerticesForSplitEdge_, seI)
{
forAllRow(newVerticesForSplitEdge_, seI, i)
pointInLayer[newVerticesForSplitEdge_(seI, i)] = true;
}
forAll(pointInLayer, pointI)
if( pointInLayer[pointI] )
layerPoints.append(pointI);
}
void refineBoundaryLayers::pointsInBndLayer(const word subsetName)
{
label sId = mesh_.pointSubsetIndex(subsetName);
if( sId < 0 )
sId = mesh_.addPointSubset(subsetName);
forAll(newVerticesForSplitEdge_, seI)
{
forAllRow(newVerticesForSplitEdge_, seI, i)
mesh_.addPointToSubset(sId, newVerticesForSplitEdge_(seI, i));
}
}
void refineBoundaryLayers::readSettings
(
const dictionary& meshDict,
......
......@@ -401,6 +401,13 @@ public:
//- performs refinement based on the given settings
void refineLayers();
// Post information
//- provide the list of points in the boundary layer
void pointsInBndLayer(labelLongList&);
//- create a subset containing points in the boundary layer
void pointsInBndLayer(const word subsetName="pointsInBndLayer");
// Static member functions
//- read the settings from dictionary
static void readSettings(const dictionary&, refineBoundaryLayers&);
......
......@@ -186,7 +186,7 @@ void checkMeshDict::checkLocalRefinementLevel() const
const label nLevels =
readLabel(dict.lookup("additionalRefinementLevels"));
if( nLevels > 0 )
if( nLevels < 0 )
{
WarningIn
(
......
......@@ -64,10 +64,9 @@ inline Foam::FRWGraph<T,width>::FRWGraph
const label s
)
:
data_(static_cast<long long>(s) * width),
data_(s * width),
nRows_(s)
{
}
{}
//- Construct given size
......@@ -78,7 +77,7 @@ inline Foam::FRWGraph<T,width>::FRWGraph
const T& t
)
:
data_(static_cast<long long>(s) * width, t),