/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
Class
Foam::autoLayerDriver
Description
All to do with adding layers
SourceFiles
autoLayerDriver.C
autoLayerDriverShrink.C
\*---------------------------------------------------------------------------*/
#ifndef autoLayerDriver_H
#define autoLayerDriver_H
#include "meshRefinement.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class removePoints;
class pointSet;
class motionSmoother;
class addPatchCellLayer;
class pointData;
class faceSet;
class layerParameters;
/*---------------------------------------------------------------------------*\
Class autoLayerDriver Declaration
\*---------------------------------------------------------------------------*/
class autoLayerDriver
{
// Static data members
//- Extrusion controls
enum extrudeMode
{
NOEXTRUDE, /*!< Do not extrude. No layers added. */
EXTRUDE, /*!< Extrude */
EXTRUDEREMOVE /*!< Extrude but afterwards remove added */
/*!< faces locally */
};
// Private classes
//- Combine operator class to combine normal with other normal.
class nomalsCombine
{
public:
void operator()(vector& x, const vector& y) const
{
if (y != point::max)
{
if (x == point::max)
{
x = y;
}
else
{
x *= (x&y);
}
}
}
};
// Private data
//- Mesh+surface
meshRefinement& meshRefiner_;
//- From surface region to patch
const labelList globalToMasterPatch_;
//- From surface region to patch
const labelList globalToSlavePatch_;
// Private Member Functions
// Layers
//- For debugging: Dump displacement to .obj files
static void dumpDisplacement
(
const fileName&,
const indirectPrimitivePatch&,
const vectorField&,
const List&
);
//- Average point wise data to face wise
static tmp avgPointData
(
const indirectPrimitivePatch&,
const scalarField& pointFld
);
//- Check that primitivePatch is not multiply connected.
// Collect non-manifold points in pointSet.
static void checkManifold
(
const indirectPrimitivePatch&,
pointSet& nonManifoldPoints
);
//- Check that mesh outside is not multiply connected.
void checkMeshManifold() const;
// Static extrusion setup
//- Unset extrusion on point. Returns true if anything unset.
static bool unmarkExtrusion
(
const label patchPointI,
pointField& patchDisp,
labelList& patchNLayers,
List& extrudeStatus
);
//- Unset extrusion on face. Returns true if anything unset.
static bool unmarkExtrusion
(
const face& localFace,
pointField& patchDisp,
labelList& patchNLayers,
List& extrudeStatus
);
//- No extrusion at non-manifold points.
void handleNonManifolds
(
const indirectPrimitivePatch& pp,
const labelList& meshEdges,
const labelListList& edgeGlobalFaces,
pointField& patchDisp,
labelList& patchNLayers,
List& extrudeStatus
) const;
//- No extrusion on feature edges. Assumes non-manifold
// edges already handled.
void handleFeatureAngle
(
const indirectPrimitivePatch& pp,
const labelList& meshEdges,
const scalar minCos,
pointField& patchDisp,
labelList& patchNLayers,
List& extrudeStatus
) const;
//- No extrusion on warped faces
void handleWarpedFaces
(
const indirectPrimitivePatch& pp,
const scalar faceRatio,
const scalar edge0Len,
const labelList& cellLevel,
pointField& patchDisp,
labelList& patchNLayers,
List& extrudeStatus
) const;
//- Determine the number of layers per point from the number of
// layers per surface.
void setNumLayers
(
const labelList& patchToNLayers,
const labelList& patchIDs,
const indirectPrimitivePatch& pp,
pointField& patchDisp,
labelList& patchNLayers,
List& extrudeStatus,
label& nIdealAddedCells
) const;
//- Helper function to make a pointVectorField with correct
// bcs for layer addition:
// - numLayers > 0 : fixedValue
// - numLayers == 0 : fixedValue (always zero)
// - processor : calculated (so free to move)
// - cyclic/wedge/symmetry : slip
// - other : slip
static tmp makeLayerDisplacementField
(
const pointMesh& pMesh,
const labelList& numLayers
);
//- Grow no-extrusion layer.
void growNoExtrusion
(
const indirectPrimitivePatch& pp,
pointField& patchDisp,
labelList& patchNLayers,
List& extrudeStatus
) const;
//- See what patches boundaryedges should be extruded into
void determineSidePatches
(
const globalIndex& globalFaces,
const labelListList& edgeGlobalFaces,
const indirectPrimitivePatch& pp,
labelList& sidePatchID
);
//- Calculate pointwise wanted and minimum thickness.
// thickness: wanted thickness
// minthickness: when to give up and not extrude
// Gets per patch parameters and determine pp pointwise
// parameters.
void calculateLayerThickness
(
const indirectPrimitivePatch& pp,
const labelList& patchIDs,
const layerParameters& layerParams,
const labelList& cellLevel,
const labelList& patchNLayers,
const scalar edge0Len,
scalarField& thickness,
scalarField& minThickness,
scalarField& expansionRatio
) const;
// Extrusion execution
//- Synchronize displacement among coupled patches.
void syncPatchDisplacement
(
const indirectPrimitivePatch& pp,
const scalarField& minThickness,
pointField& patchDisp,
labelList& patchNLayers,
List& extrudeStatus
) const;
//- Get nearest point on surface to snap to
void getPatchDisplacement
(
const motionSmoother& meshMover,
const scalarField& thickness,
const scalarField& minThickness,
pointField& patchDisp,
labelList& patchNLayers,
List& extrudeStatus
) const;
//- for truncateDisplacement: find strings of edges
bool sameEdgeNeighbour
(
const labelListList& globalEdgeFaces,
const label myGlobalFaceI,
const label nbrGlobFaceI,
const label edgeI
) const;
//- for truncateDisplacement: find strings of edges
void getVertexString
(
const indirectPrimitivePatch& pp,
const labelListList& globalEdgeFaces,
const label faceI,
const label edgeI,
const label myGlobFaceI,
const label nbrGlobFaceI,
DynamicList