Merge branch 'master' of /home/dm4/OpenFOAM/repositories/OpenFOAM-dev

This commit is contained in:
william
2014-02-26 16:14:12 +00:00
46 changed files with 6775 additions and 2888 deletions

View File

@ -1121,6 +1121,38 @@ int main(int argc, char *argv[])
); );
// Refinement parameters
const refinementParameters refineParams(refineDict);
// Snap parameters
const snapParameters snapParams(snapDict);
// Add all the cellZones and faceZones
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// 1. cellZones relating to surface (faceZones added later)
const labelList namedSurfaces
(
surfaceZonesInfo::getNamedSurfaces(surfaces.surfZones())
);
labelList surfaceToCellZone = surfaceZonesInfo::addCellZonesToMesh
(
surfaces.surfZones(),
namedSurfaces,
mesh
);
// 2. cellZones relating to locations
refineParams.addCellZonesToMesh(mesh);
// Add all the surface regions as patches // Add all the surface regions as patches
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -1128,6 +1160,8 @@ int main(int argc, char *argv[])
// (faceZone surfaces) // (faceZone surfaces)
labelList globalToMasterPatch; labelList globalToMasterPatch;
labelList globalToSlavePatch; labelList globalToSlavePatch;
{ {
Info<< nl Info<< nl
<< "Adding patches for surface regions" << nl << "Adding patches for surface regions" << nl
@ -1148,6 +1182,7 @@ int main(int argc, char *argv[])
const labelList& surfaceGeometry = surfaces.surfaces(); const labelList& surfaceGeometry = surfaces.surfaces();
const PtrList<dictionary>& surfacePatchInfo = surfaces.patchInfo(); const PtrList<dictionary>& surfacePatchInfo = surfaces.patchInfo();
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
forAll(surfaceGeometry, surfI) forAll(surfaceGeometry, surfI)
{ {
@ -1157,7 +1192,9 @@ int main(int argc, char *argv[])
Info<< surfaces.names()[surfI] << ':' << nl << nl; Info<< surfaces.names()[surfI] << ':' << nl << nl;
if (surfaces.surfZones()[surfI].faceZoneName().empty()) const word& fzName = surfaces.surfZones()[surfI].faceZoneName();
if (fzName.empty())
{ {
// 'Normal' surface // 'Normal' surface
forAll(regNames, i) forAll(regNames, i)
@ -1188,7 +1225,7 @@ int main(int argc, char *argv[])
Info<< setf(ios_base::left) Info<< setf(ios_base::left)
<< setw(6) << patchI << setw(6) << patchI
<< setw(20) << mesh.boundaryMesh()[patchI].type() << setw(20) << pbm[patchI].type()
<< setw(30) << regNames[i] << nl; << setw(30) << regNames[i] << nl;
globalToMasterPatch[globalRegionI] = patchI; globalToMasterPatch[globalRegionI] = patchI;
@ -1228,7 +1265,7 @@ int main(int argc, char *argv[])
Info<< setf(ios_base::left) Info<< setf(ios_base::left)
<< setw(6) << patchI << setw(6) << patchI
<< setw(20) << mesh.boundaryMesh()[patchI].type() << setw(20) << pbm[patchI].type()
<< setw(30) << regNames[i] << nl; << setw(30) << regNames[i] << nl;
globalToMasterPatch[globalRegionI] = patchI; globalToMasterPatch[globalRegionI] = patchI;
@ -1260,12 +1297,27 @@ int main(int argc, char *argv[])
Info<< setf(ios_base::left) Info<< setf(ios_base::left)
<< setw(6) << patchI << setw(6) << patchI
<< setw(20) << mesh.boundaryMesh()[patchI].type() << setw(20) << pbm[patchI].type()
<< setw(30) << slaveName << nl; << setw(30) << slaveName << nl;
globalToSlavePatch[globalRegionI] = patchI; globalToSlavePatch[globalRegionI] = patchI;
} }
} }
// For now: have single faceZone per surface. Use first
// region in surface for patch for zoneing
if (regNames.size())
{
label globalRegionI = surfaces.globalRegion(surfI, 0);
meshRefiner.addFaceZone
(
fzName,
pbm[globalToMasterPatch[globalRegionI]].name(),
pbm[globalToSlavePatch[globalRegionI]].name(),
surfaces.surfZones()[surfI].faceType()
);
}
} }
Info<< nl; Info<< nl;
@ -1275,6 +1327,73 @@ int main(int argc, char *argv[])
} }
// Add all information for all the remaining faceZones
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wordPairHashTable zonesToFaceZone;
forAll(mesh.faceZones(), zoneI)
{
const word& fzName = mesh.faceZones()[zoneI].name();
label mpI, spI;
surfaceZonesInfo::faceZoneType fzType;
bool hasInfo = meshRefiner.getFaceZoneInfo(fzName, mpI, spI, fzType);
if (!hasInfo)
{
// faceZone does not originate from a surface but presumably
// from a cellZone pair instead
string::size_type i = fzName.find("_to_");
if (i != string::npos)
{
word cz0 = fzName.substr(0, i);
word cz1 = fzName.substr(i+4, fzName.size()-i+4);
zonesToFaceZone.insert(Pair<word>(cz0, cz1), fzName);
}
}
}
if (zonesToFaceZone.size())
{
autoRefineDriver::addFaceZones
(
meshRefiner,
refineParams,
zonesToFaceZone
);
}
// Re-do intersections on meshed boundaries since they use an extrapolated
// other side
{
const labelList adaptPatchIDs(meshRefiner.meshedPatches());
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
label nFaces = 0;
forAll(adaptPatchIDs, i)
{
nFaces += pbm[adaptPatchIDs[i]].size();
}
labelList faceLabels(nFaces);
nFaces = 0;
forAll(adaptPatchIDs, i)
{
const polyPatch& pp = pbm[adaptPatchIDs[i]];
forAll(pp, i)
{
faceLabels[nFaces++] = pp.start()+i;
}
}
meshRefiner.updateIntersections(faceLabels);
}
// Parallel // Parallel
// ~~~~~~~~ // ~~~~~~~~
@ -1312,14 +1431,13 @@ int main(int argc, char *argv[])
const Switch wantSnap(meshDict.lookup("snap")); const Switch wantSnap(meshDict.lookup("snap"));
const Switch wantLayers(meshDict.lookup("addLayers")); const Switch wantLayers(meshDict.lookup("addLayers"));
// Refinement parameters const Switch keepHex(meshDict.lookupOrDefault("keepHex", false));
const refinementParameters refineParams(refineDict);
// Snap parameters if (keepHex)
const snapParameters snapParams(snapDict); {
Info<< "Avoiding generating non-(split)hex cells." << nl
// Layer addition parameters << endl;
const layerParameters layerParams(layerDict, mesh.boundaryMesh()); }
if (wantRefine) if (wantRefine)
@ -1348,6 +1466,7 @@ int main(int argc, char *argv[])
refineParams, refineParams,
snapParams, snapParams,
refineParams.handleSnapProblems(), refineParams.handleSnapProblems(),
keepHex, // keepHex
motionDict motionDict
); );
@ -1387,6 +1506,7 @@ int main(int argc, char *argv[])
( (
snapDict, snapDict,
motionDict, motionDict,
!keepHex, // mergePatchFaces
curvature, curvature,
planarAngle, planarAngle,
snapParams snapParams
@ -1408,6 +1528,9 @@ int main(int argc, char *argv[])
{ {
cpuTime timer; cpuTime timer;
// Layer addition parameters
const layerParameters layerParams(layerDict, mesh.boundaryMesh());
autoLayerDriver layerDriver autoLayerDriver layerDriver
( (
meshRefiner, meshRefiner,
@ -1433,6 +1556,7 @@ int main(int argc, char *argv[])
layerDict, layerDict,
motionDict, motionDict,
layerParams, layerParams,
!keepHex, //mergePatchFaces
preBalance, preBalance,
decomposer, decomposer,
distributor distributor

View File

@ -71,6 +71,12 @@ geometry
} }
}; };
// Optional: avoid patch-face merging. Allows mesh to be used for
// refinement/unrefinement
//keepHex true;
// Settings for the castellatedMesh generation. // Settings for the castellatedMesh generation.
castellatedMeshControls castellatedMeshControls
{ {
@ -177,7 +183,7 @@ castellatedMeshControls
// how to select the cells that are in the cellZone // how to select the cells that are in the cellZone
// (inside / outside / specified insidePoint) // (inside / outside / specified insidePoint)
// The orientation of the faceZone is // The orientation of the faceZone is
// - if on cellZone(s) : point out of (maximum) cellZone // - if on cellZone(s) : point out of (minimum) cellZone
// - if freestanding : oriented according to surface // - if freestanding : oriented according to surface
//faceZone sphere; //faceZone sphere;
@ -249,17 +255,70 @@ castellatedMeshControls
// After refinement patches get added for all refinementSurfaces and // After refinement patches get added for all refinementSurfaces and
// all cells intersecting the surfaces get put into these patches. The // all cells intersecting the surfaces get put into these patches. The
// section reachable from the locationInMesh is kept. // section reachable from the location(s)InMesh is kept.
// NOTE: This point should never be on a face, always inside a cell, even // NOTE: This point should never be on a face, always inside a cell, even
// after refinement. // after refinement.
locationInMesh (5 0.28 0.43); //
// There are two different ways of specifying the regions to keep:
// 1. a single locationInMesh. All the 'zoned' surfaces are marked as such
// in the refinementSurfaces with the faceZone and cellZone keywords.
//
// or
//
// 2. multiple locationsInMesh, with per location the name of the cellZone.
// This uses walking to determine zones and automatically creates
// faceZones on the outside of cellZones.
// Whether any faceZones (as specified in the refinementSurfaces)
// are only on the boundary of corresponding cellZones or also allow
// free-standing zone faces and zone faces on boundaries. Not used if
// there are no faceZones.
allowFreeStandingZoneFaces true;
// Ad 1. Specify a single location and how to treat faces inbetween
// cellZones
locationInMesh (5 0.28 0.43);
// Whether any faceZones (as specified in the refinementSurfaces)
// are only on the boundary of corresponding cellZones or also allow
// free-standing zone faces. Not used if there are no faceZones.
allowFreeStandingZoneFaces true;
// 2. Specify multiple locations with optional cellZones for the
// regions. faceZones are automatically constructed from the
// names of the cellZones: <cellZoneA> _to_ <cellZoneB>
// where the cellZoneA is the lowest numbered cellZone (non-cellZone
// cells are in a special region called "none" which is always
// last).
locationsInMesh
(
((-0.09 -0.039 -0.049) bottomAir) // cellZone 0
((-0.09 0.009 -0.049) topAir) // cellZone 1
((-0.09 0.001 -0.049) leftSolid) // cellZone 2
((0.02 0.001 -0.049) rightSolid) // cellZone 3
((-0.001 -0.039 0.0015) heater) // cellZone 4
);
// Per synthesised faceZone name the faceType and type of baffles to
// create
faceZoneControls
{
bottomAir_to_heater
{
// Optional specification of patch type (default is wall). No
// constraint types (cyclic, symmetry) etc. are allowed.
patchInfo
{
type patch;
inGroups (patchPatches);
}
faceType baffle;
}
}
// Optional locations that should not be reachable from
// location(s)InMesh
locationsOutsideMesh ((100 100 100));
// Optional: do not remove cells likely to give snapping problems // Optional: do not remove cells likely to give snapping problems
// handleSnapProblems false; // handleSnapProblems false;
@ -288,6 +347,11 @@ snapControls
// before upon reaching a correct mesh. // before upon reaching a correct mesh.
nRelaxIter 5; nRelaxIter 5;
// (wip) disable snapping to opposite near surfaces (revert to 22x
// behaviour)
// detectNearSurfacesSnap false;
// Feature snapping // Feature snapping
// Number of feature edge snapping iterations. // Number of feature edge snapping iterations.
@ -306,8 +370,28 @@ snapControls
multiRegionFeatureSnap false; multiRegionFeatureSnap false;
// wip: disable snapping to opposite near surfaces (revert to 22x behaviour) //- When to run face splitting (never at first iteration, always
// detectNearSurfacesSnap false; // at last iteration). Is interval. Default -1 (disabled)
//nFaceSplitInterval 5;
// (wip) Optional for explicit feature snapping:
//- Detect baffle edges. Default is true.
//detectBaffles false;
//- Erase attraction close to feature point. Default is false.
//releasePoints true;
//- Walk along feature edges, adding missing ones. Default is true.
//stringFeatures false;
//- If diagonal attraction also attract other face points. Default is
// false
//avoidDiagonal true;
//- When splitting what concave faces to leave intact. Default is 45
// degrees.
//concaveAngle 30;
//- When splitting the minimum area ratio of faces. If face split
// causes ratio of area less than this do not split. Default is 0.3
//minAreaRatio 0.3;
} }
// Settings for the layer addition. // Settings for the layer addition.
@ -348,7 +432,7 @@ addLayersControls
// cannot be above minThickness do not add layer. // cannot be above minThickness do not add layer.
// If relativeSizes this is relative to undistorted size of cell // If relativeSizes this is relative to undistorted size of cell
// outside layer.. // outside layer..
minThickness 0.25; minThickness 0.1;
// Per final patch (so not geometry!) the layer information // Per final patch (so not geometry!) the layer information
@ -395,6 +479,13 @@ addLayersControls
// are perpendicular // are perpendicular
featureAngle 130; featureAngle 130;
// When to merge patch faces. Default is 0.5*featureAngle
//mergePatchFacesAngle 45;
// Do not extrude around sharp edge if not both faces are extruded.
// Default is 0.5*featureAngle. Set to -180 always attempt extrusion
layerTerminationAngle -180;
// Stop layer growth on highly warped cells // Stop layer growth on highly warped cells
maxFaceThicknessRatio 0.5; maxFaceThicknessRatio 0.5;
@ -431,8 +522,10 @@ addLayersControls
// default is 0. // default is 0.
//nSmoothDisplacement 90; //nSmoothDisplacement 90;
// (wip)Optional: do not extrude a point if none of the surrounding points is // (wip)Optional: do not extrude any point where
// not extruded. Default is false. // (false) : all surrounding faces are not fully extruded
// (true) : all surrounding points are not extruded
// Default is false.
//detectExtrusionIsland true; //detectExtrusionIsland true;

View File

@ -2,7 +2,7 @@
# ========= | # ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | # \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation # \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
@ -40,28 +40,46 @@ getApplication()
runApplication() runApplication()
{ {
APP_LOGFILE=''
if [ "$1" = "-l" ]
then
APP_LOGFILE=$2
shift 2
fi
APP_RUN=$1 APP_RUN=$1
APP_NAME=${1##*/} APP_NAME=${1##*/}
shift shift
if [ -f log.$APP_NAME ] APP_LOGFILE=${APP_LOGFILE:="log.$APP_NAME"}
if [ -f $APP_LOGFILE ]
then then
echo "$APP_NAME already run on $PWD: remove log file to re-run" echo "$APP_NAME already run on $PWD: remove log file $APP_LOGFILE to re-run"
else else
echo "Running $APP_RUN on $PWD" echo "Running $APP_RUN on $PWD"
$APP_RUN "$@" > log.$APP_NAME 2>&1 $APP_RUN "$@" > $APP_LOGFILE 2>&1
fi fi
} }
runParallel() runParallel()
{ {
APP_LOGFILE=''
if [ "$1" = "-l" ]
then
APP_LOGFILE=$2
shift 2
fi
APP_RUN=$1 APP_RUN=$1
APP_NAME=${1##*/} APP_NAME=${1##*/}
shift shift
if [ -f log.$APP_NAME ] APP_LOGFILE=${APP_LOGFILE:="log.$APP_NAME"}
if [ -f $APP_LOGFILE ]
then then
echo "$APP_NAME already run on $PWD: remove log file to re-run" echo "$APP_NAME already run on $PWD: remove log file $APP_LOGFILE to re-run"
else else
nProcs=$1 nProcs=$1
shift shift
@ -70,9 +88,9 @@ runParallel()
#if [ "$WM_SCHEDULER" ] #if [ "$WM_SCHEDULER" ]
#then #then
# echo "$PWD: $WM_SCHEDULER -np $nProcs" 1>&2 # echo "$PWD: $WM_SCHEDULER -np $nProcs" 1>&2
# $WM_SCHEDULER -np $nProcs "( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null > log.$APP_NAME 2>&1 )" # $WM_SCHEDULER -np $nProcs "( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null > $APP_LOGFILE 2>&1 )"
#else #else
( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null > log.$APP_NAME 2>&1 ) ( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null > $APP_LOGFILE 2>&1 )
#fi #fi
fi fi
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -109,7 +109,6 @@ private:
const labelList globalToSlavePatch_; const labelList globalToSlavePatch_;
// Private Member Functions // Private Member Functions
// Layers // Layers
@ -371,6 +370,14 @@ private:
const List<extrudeMode>& extrudeStatus const List<extrudeMode>& extrudeStatus
); );
//- After adding to mesh get the new baffles
static List<labelPair> getBafflesOnAddedMesh
(
const polyMesh& mesh,
const labelList& newToOldFaces,
const List<labelPair>& baffles
);
//- Collect layer faces and layer cells into bools //- Collect layer faces and layer cells into bools
// for ease of handling // for ease of handling
static void getLayerCellsFaces static void getLayerCellsFaces
@ -394,6 +401,15 @@ private:
) const; ) const;
//- Write cellSet,faceSet for layers //- Write cellSet,faceSet for layers
bool writeLayerSets
(
const fvMesh& mesh,
const labelList& cellNLayers,
const scalarField& faceRealThickness
) const;
//- Write volFields,cellSet,faceSet for layers depending
// on write level
bool writeLayerData bool writeLayerData
( (
const fvMesh& mesh, const fvMesh& mesh,
@ -596,6 +612,7 @@ public:
const dictionary& shrinkDict, const dictionary& shrinkDict,
const dictionary& motionDict, const dictionary& motionDict,
const layerParameters& layerParams, const layerParameters& layerParams,
const bool mergePatchFaces, // merging patch faces
const bool preBalance, // balance before adding? const bool preBalance, // balance before adding?
decompositionMethod& decomposer, decompositionMethod& decomposer,
fvMeshDistribute& distributor fvMeshDistribute& distributor

View File

@ -37,6 +37,7 @@ License
#include "unitConversion.H" #include "unitConversion.H"
#include "snapParameters.H" #include "snapParameters.H"
#include "localPointRegion.H" #include "localPointRegion.H"
#include "IOmanip.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -94,7 +95,7 @@ Foam::label Foam::autoRefineDriver::featureEdgeRefine
( (
meshRefiner_.refineCandidates meshRefiner_.refineCandidates
( (
refineParams.keepPoints(), refineParams.locationsInMesh(),
refineParams.curvature(), refineParams.curvature(),
refineParams.planarAngle(), refineParams.planarAngle(),
@ -207,7 +208,7 @@ Foam::label Foam::autoRefineDriver::surfaceOnlyRefine
( (
meshRefiner_.refineCandidates meshRefiner_.refineCandidates
( (
refineParams.keepPoints(), refineParams.locationsInMesh(),
refineParams.curvature(), refineParams.curvature(),
refineParams.planarAngle(), refineParams.planarAngle(),
@ -341,7 +342,7 @@ Foam::label Foam::autoRefineDriver::gapOnlyRefine
( (
meshRefiner_.refineCandidates meshRefiner_.refineCandidates
( (
refineParams.keepPoints(), refineParams.locationsInMesh(),
refineParams.curvature(), refineParams.curvature(),
refineParams.planarAngle(), refineParams.planarAngle(),
@ -692,7 +693,9 @@ void Foam::autoRefineDriver::removeInsideCells
nBufferLayers, // nBufferLayers nBufferLayers, // nBufferLayers
globalToMasterPatch_, globalToMasterPatch_,
globalToSlavePatch_, globalToSlavePatch_,
refineParams.keepPoints()[0] refineParams.locationsInMesh(),
refineParams.zonesInMesh(),
refineParams.locationsOutsideMesh()
); );
if (debug&meshRefinement::MESH) if (debug&meshRefinement::MESH)
@ -753,7 +756,7 @@ Foam::label Foam::autoRefineDriver::shellRefine
( (
meshRefiner_.refineCandidates meshRefiner_.refineCandidates
( (
refineParams.keepPoints(), refineParams.locationsInMesh(),
refineParams.curvature(), refineParams.curvature(),
refineParams.planarAngle(), refineParams.planarAngle(),
@ -921,14 +924,17 @@ void Foam::autoRefineDriver::baffleAndSplitMesh
const_cast<Time&>(mesh.time()), const_cast<Time&>(mesh.time()),
globalToMasterPatch_, globalToMasterPatch_,
globalToSlavePatch_, globalToSlavePatch_,
refineParams.keepPoints()[0] refineParams.locationsInMesh(),
refineParams.zonesInMesh(),
refineParams.locationsOutsideMesh()
); );
} }
void Foam::autoRefineDriver::zonify void Foam::autoRefineDriver::zonify
( (
const refinementParameters& refineParams const refinementParameters& refineParams,
wordPairHashTable& zonesToFaceZone
) )
{ {
// Mesh is at its finest. Do zoning // Mesh is at its finest. Do zoning
@ -940,7 +946,11 @@ void Foam::autoRefineDriver::zonify
const labelList namedSurfaces = const labelList namedSurfaces =
surfaceZonesInfo::getNamedSurfaces(meshRefiner_.surfaces().surfZones()); surfaceZonesInfo::getNamedSurfaces(meshRefiner_.surfaces().surfZones());
if (namedSurfaces.size()) if
(
namedSurfaces.size()
|| refineParams.zonesInMesh().size()
)
{ {
Info<< nl Info<< nl
<< "Introducing zones for interfaces" << nl << "Introducing zones for interfaces" << nl
@ -956,8 +966,10 @@ void Foam::autoRefineDriver::zonify
meshRefiner_.zonify meshRefiner_.zonify
( (
refineParams.keepPoints()[0], refineParams.allowFreeStandingZoneFaces(),
refineParams.allowFreeStandingZoneFaces() refineParams.locationsInMesh(),
refineParams.zonesInMesh(),
zonesToFaceZone
); );
if (debug&meshRefinement::MESH) if (debug&meshRefinement::MESH)
@ -1023,7 +1035,9 @@ void Foam::autoRefineDriver::splitAndMergeBaffles
const_cast<Time&>(mesh.time()), const_cast<Time&>(mesh.time()),
globalToMasterPatch_, globalToMasterPatch_,
globalToSlavePatch_, globalToSlavePatch_,
refineParams.keepPoints()[0] refineParams.locationsInMesh(),
refineParams.zonesInMesh(),
refineParams.locationsOutsideMesh()
); );
if (debug) if (debug)
@ -1061,7 +1075,8 @@ void Foam::autoRefineDriver::splitAndMergeBaffles
( (
globalToMasterPatch_, globalToMasterPatch_,
globalToSlavePatch_, globalToSlavePatch_,
refineParams.keepPoints()[0] refineParams.locationsInMesh(),
refineParams.locationsOutsideMesh()
); );
if (debug) if (debug)
@ -1092,8 +1107,82 @@ void Foam::autoRefineDriver::splitAndMergeBaffles
} }
void Foam::autoRefineDriver::addFaceZones
(
meshRefinement& meshRefiner,
const refinementParameters& refineParams,
const wordPairHashTable& zonesToFaceZone
)
{
if (zonesToFaceZone.size())
{
Info<< nl
<< "Adding patches for inter-region zones" << nl
<< "-------------------------------------" << nl
<< endl;
Info<< setf(ios_base::left)
<< setw(6) << "Patch"
<< setw(20) << "Type"
<< setw(30) << "Name"
<< setw(30) << "FaceZone"
<< setw(10) << "FaceType"
<< nl
<< setw(6) << "-----"
<< setw(20) << "----"
<< setw(30) << "----"
<< setw(30) << "--------"
<< setw(10) << "--------"
<< endl;
const polyMesh& mesh = meshRefiner.mesh();
// Add patches for added inter-region faceZones
forAllConstIter(wordPairHashTable, zonesToFaceZone, iter)
{
const Pair<word>& czNames = iter.key();
const word& fzName = iter();
// Get any user-defined faceZone data
surfaceZonesInfo::faceZoneType fzType;
dictionary patchInfo = refineParams.getZoneInfo(fzName, fzType);
const word& masterName = fzName;
//const word slaveName = fzName + "_slave";
const word slaveName = czNames.second() + "_to_" + czNames.first();
label mpI = meshRefiner.addMeshedPatch(masterName, patchInfo);
Info<< setf(ios_base::left)
<< setw(6) << mpI
<< setw(20) << mesh.boundaryMesh()[mpI].type()
<< setw(30) << masterName
<< setw(30) << fzName
<< setw(10) << surfaceZonesInfo::faceZoneTypeNames[fzType]
<< nl;
label slI = meshRefiner.addMeshedPatch(slaveName, patchInfo);
Info<< setf(ios_base::left)
<< setw(6) << slI
<< setw(20) << mesh.boundaryMesh()[slI].type()
<< setw(30) << slaveName
<< setw(30) << fzName
<< setw(10) << surfaceZonesInfo::faceZoneTypeNames[fzType]
<< nl;
meshRefiner.addFaceZone(fzName, masterName, slaveName, fzType);
}
Info<< endl;
}
}
void Foam::autoRefineDriver::mergePatchFaces void Foam::autoRefineDriver::mergePatchFaces
( (
const bool keepHex,
const refinementParameters& refineParams, const refinementParameters& refineParams,
const dictionary& motionDict const dictionary& motionDict
) )
@ -1105,14 +1194,27 @@ void Foam::autoRefineDriver::mergePatchFaces
const fvMesh& mesh = meshRefiner_.mesh(); const fvMesh& mesh = meshRefiner_.mesh();
meshRefiner_.mergePatchFacesUndo if (keepHex)
( {
Foam::cos(degToRad(45.0)), meshRefiner_.mergePatchFaces
Foam::cos(degToRad(45.0)), (
meshRefiner_.meshedPatches(), Foam::cos(degToRad(45.0)),
motionDict, Foam::cos(degToRad(45.0)),
labelList(mesh.nFaces(), -1) 4, // only merge faces split into 4
); meshRefiner_.meshedPatches()
);
}
else
{
meshRefiner_.mergePatchFacesUndo
(
Foam::cos(degToRad(45.0)),
Foam::cos(degToRad(45.0)),
meshRefiner_.meshedPatches(),
motionDict,
labelList(mesh.nFaces(), -1)
);
}
if (debug) if (debug)
{ {
@ -1134,6 +1236,7 @@ void Foam::autoRefineDriver::doRefine
const refinementParameters& refineParams, const refinementParameters& refineParams,
const snapParameters& snapParams, const snapParameters& snapParams,
const bool prepareForSnapping, const bool prepareForSnapping,
const bool keepHex,
const dictionary& motionDict const dictionary& motionDict
) )
{ {
@ -1145,7 +1248,7 @@ void Foam::autoRefineDriver::doRefine
const fvMesh& mesh = meshRefiner_.mesh(); const fvMesh& mesh = meshRefiner_.mesh();
// Check that all the keep points are inside the mesh. // Check that all the keep points are inside the mesh.
refineParams.findCells(mesh); refineParams.findCells(true, mesh, refineParams.locationsInMesh());
// Refine around feature edges // Refine around feature edges
featureEdgeRefine featureEdgeRefine
@ -1206,8 +1309,12 @@ void Foam::autoRefineDriver::doRefine
motionDict motionDict
); );
// Mesh is at its finest. Do optional zoning. // Mesh is at its finest. Do optional zoning (cellZones and faceZones)
zonify(refineParams); wordPairHashTable zonesToFaceZone;
zonify(refineParams, zonesToFaceZone);
// Create pairs of patches for faceZones
addFaceZones(meshRefiner_, refineParams, zonesToFaceZone);
// Pull baffles apart // Pull baffles apart
splitAndMergeBaffles splitAndMergeBaffles
@ -1221,7 +1328,7 @@ void Foam::autoRefineDriver::doRefine
// Do something about cells with refined faces on the boundary // Do something about cells with refined faces on the boundary
if (prepareForSnapping) if (prepareForSnapping)
{ {
mergePatchFaces(refineParams, motionDict); mergePatchFaces(keepHex, refineParams, motionDict);
} }
@ -1232,19 +1339,14 @@ void Foam::autoRefineDriver::doRefine
<< "---------------------" << nl << "---------------------" << nl
<< endl; << endl;
//if (debug)
//{
// const_cast<Time&>(mesh.time())++;
//}
// Do final balancing. Keep zoned faces on one processor since the // Do final balancing. Keep zoned faces on one processor since the
// snap phase will convert them to baffles and this only works for // snap phase will convert them to baffles and this only works for
// internal faces. // internal faces.
meshRefiner_.balance meshRefiner_.balance
( (
true, true, // keepZoneFaces
false, false, // keepBaffles
scalarField(mesh.nCells(), 1), // dummy weights scalarField(mesh.nCells(), 1), // cellWeights
decomposer_, decomposer_,
distributor_ distributor_
); );

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -34,7 +34,8 @@ SourceFiles
#ifndef autoRefineDriver_H #ifndef autoRefineDriver_H
#define autoRefineDriver_H #define autoRefineDriver_H
#include "treeBoundBox.H" #include "wordPairHashTable.H"
#include "labelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -129,7 +130,11 @@ class autoRefineDriver
); );
//- Add zones //- Add zones
void zonify(const refinementParameters& refineParams); void zonify
(
const refinementParameters& refineParams,
wordPairHashTable& zonesToFaceZone
);
void splitAndMergeBaffles void splitAndMergeBaffles
( (
@ -142,11 +147,11 @@ class autoRefineDriver
//- Merge refined boundary faces (from exposing coarser cell) //- Merge refined boundary faces (from exposing coarser cell)
void mergePatchFaces void mergePatchFaces
( (
const bool keepHex,
const refinementParameters& refineParams, const refinementParameters& refineParams,
const dictionary& motionDict const dictionary& motionDict
); );
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
autoRefineDriver(const autoRefineDriver&); autoRefineDriver(const autoRefineDriver&);
@ -182,8 +187,18 @@ public:
const refinementParameters& refineParams, const refinementParameters& refineParams,
const snapParameters& snapParams, const snapParameters& snapParams,
const bool prepareForSnapping, const bool prepareForSnapping,
const bool keepHexOnly,
const dictionary& motionDict const dictionary& motionDict
); );
//- Helper: add faceZones and patches
static void addFaceZones
(
meshRefinement& meshRefiner,
const refinementParameters& refineParams,
const wordPairHashTable& zonesToFaceZone
);
}; };

View File

@ -43,6 +43,7 @@ Description
#include "unitConversion.H" #include "unitConversion.H"
#include "localPointRegion.H" #include "localPointRegion.H"
#include "PatchTools.H" #include "PatchTools.H"
#include "refinementFeatures.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -648,35 +649,6 @@ Foam::autoSnapDriver::autoSnapDriver
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::mapPolyMesh> Foam::autoSnapDriver::mergeZoneBaffles
(
const List<labelPair>& baffles
)
{
labelList zonedSurfaces =
surfaceZonesInfo::getNamedSurfaces(meshRefiner_.surfaces().surfZones());
autoPtr<mapPolyMesh> map;
// No need to sync; all processors will have all same zonedSurfaces.
label nBaffles = returnReduce(baffles.size(), sumOp<label>());
if (zonedSurfaces.size() && nBaffles > 0)
{
// Merge any baffles
Info<< "Converting " << nBaffles << " baffles back into zoned faces ..."
<< endl;
map = meshRefiner_.mergeBaffles(baffles);
Info<< "Converted baffles in = "
<< meshRefiner_.mesh().time().cpuTimeIncrement()
<< " s\n" << nl << endl;
}
return map;
}
Foam::scalarField Foam::autoSnapDriver::calcSnapDistance Foam::scalarField Foam::autoSnapDriver::calcSnapDistance
( (
const fvMesh& mesh, const fvMesh& mesh,
@ -2454,10 +2426,45 @@ void Foam::autoSnapDriver::detectWarpedFaces
} }
Foam::labelList Foam::autoSnapDriver::getInternalOrBaffleDuplicateFace() const
{
const fvMesh& mesh = meshRefiner_.mesh();
labelList internalOrBaffleFaceZones;
{
List<surfaceZonesInfo::faceZoneType> fzTypes(2);
fzTypes[0] = surfaceZonesInfo::INTERNAL;
fzTypes[1] = surfaceZonesInfo::BAFFLE;
internalOrBaffleFaceZones = meshRefiner_.getZones(fzTypes);
}
List<labelPair> baffles
(
meshRefiner_.subsetBaffles
(
mesh,
internalOrBaffleFaceZones,
localPointRegion::findDuplicateFacePairs(mesh)
)
);
labelList faceToDuplicate(mesh.nFaces(), -1);
forAll(baffles, i)
{
const labelPair& p = baffles[i];
faceToDuplicate[p[0]] = p[1];
faceToDuplicate[p[1]] = p[0];
}
return faceToDuplicate;
}
void Foam::autoSnapDriver::doSnap void Foam::autoSnapDriver::doSnap
( (
const dictionary& snapDict, const dictionary& snapDict,
const dictionary& motionDict, const dictionary& motionDict,
const bool mergePatchFaces,
const scalar featureCos, const scalar featureCos,
const scalar planarAngle, const scalar planarAngle,
const snapParameters& snapParams const snapParameters& snapParams
@ -2470,10 +2477,6 @@ void Foam::autoSnapDriver::doSnap
<< "--------------" << nl << "--------------" << nl
<< endl; << endl;
// Get the labels of added patches.
labelList adaptPatchIDs(meshRefiner_.meshedPatches());
// faceZone handling // faceZone handling
// ~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~
// //
@ -2488,223 +2491,55 @@ void Foam::autoSnapDriver::doSnap
// //
// internal // internal
// -------- // --------
// - baffles: contains all faces on faceZone so // - baffles: need to be checked across
// - mesh checks check across baffles
// - they get back merged into internal faces
// - duplicateFace: from face to duplicate face. Contains // - duplicateFace: from face to duplicate face. Contains
// all faces on faceZone to prevents merging patch faces. // all faces on faceZone to prevents merging patch faces.
// //
// baffle // baffle
// ------ // ------
// - baffles: contains no faces on faceZone since need not be merged/checked // - baffles: no need to be checked across
// across
// - duplicateFace: contains all faces on faceZone to prevent // - duplicateFace: contains all faces on faceZone to prevent
// merging patch faces. // merging patch faces.
// //
// boundary // boundary
// -------- // --------
// - baffles: contains no faces on faceZone since need not be merged/checked // - baffles: no need to be checked across. Also points get duplicated
// across // so will no longer be baffles
// - duplicateFace: contains no faces on faceZone since both sides can // - duplicateFace: contains no faces on faceZone since both sides can
// merge faces independently. // merge faces independently.
// Create baffles (pairs of faces that share the same points)
// Baffles stored as owner and neighbour face that have been created. // faceZones of type internal
List<labelPair> baffles; const labelList internalFaceZones
meshRefiner_.createZoneBaffles
( (
globalToMasterPatch_, meshRefiner_.getZones
globalToSlavePatch_, (
baffles List<surfaceZonesInfo::faceZoneType>
(
1,
surfaceZonesInfo::INTERNAL
)
)
); );
// Maintain map from face to baffle face (-1 for non-baffle faces). Used
// later on to prevent patchface merging if faceType=baffle
labelList duplicateFace(mesh.nFaces(), -1);
forAll(baffles, i) // Create baffles (pairs of faces that share the same points)
// Baffles stored as owner and neighbour face that have been created.
{ {
const labelPair& baffle = baffles[i]; List<labelPair> baffles;
duplicateFace[baffle.first()] = baffle.second(); labelList originatingFaceZone;
duplicateFace[baffle.second()] = baffle.first(); meshRefiner_.createZoneBaffles
}
// Selectively 'forget' about the baffles, i.e. not check across them
// or merge across them.
{
const faceZoneMesh& fZones = mesh.faceZones();
const refinementSurfaces& surfaces = meshRefiner_.surfaces();
const PtrList<surfaceZonesInfo>& surfZones = surfaces.surfZones();
// Determine which
// - faces to remove from list of baffles (so not merge)
// - points to duplicate
// Per face if is on faceType 'baffle' or 'boundary'
labelList filterFace(mesh.nFaces(), -1);
label nFilterFaces = 0;
// Per point whether it need to be duplicated
PackedBoolList duplicatePoint(mesh.nPoints());
label nDuplicatePoints = 0;
forAll(surfZones, surfI)
{
const word& faceZoneName = surfZones[surfI].faceZoneName();
if (faceZoneName.size())
{
const surfaceZonesInfo::faceZoneType& faceType =
surfZones[surfI].faceType();
if
(
faceType == surfaceZonesInfo::BAFFLE
|| faceType == surfaceZonesInfo::BOUNDARY
)
{
// Filter out all faces for this zone.
label zoneI = fZones.findZoneID(faceZoneName);
const faceZone& fZone = fZones[zoneI];
forAll(fZone, i)
{
label faceI = fZone[i];
filterFace[faceI] = zoneI;
nFilterFaces++;
}
if (faceType == surfaceZonesInfo::BOUNDARY)
{
forAll(fZone, i)
{
label faceI = fZone[i];
// Allow combining patch faces across this face
duplicateFace[faceI] = -1;
const face& f = mesh.faces()[faceI];
forAll(f, fp)
{
if (!duplicatePoint[f[fp]])
{
duplicatePoint[f[fp]] = 1;
nDuplicatePoints++;
}
}
}
}
Info<< "Surface : " << surfaces.names()[surfI] << nl
<< " faces to become baffle : "
<< returnReduce(nFilterFaces, sumOp<label>()) << nl
<< " points to duplicate : "
<< returnReduce(nDuplicatePoints, sumOp<label>())
<< endl;
}
}
}
// Duplicate points only if all points agree
syncTools::syncPointList
( (
mesh, identity(mesh.faceZones().size()),
duplicatePoint, baffles,
andEqOp<unsigned int>(), // combine op originatingFaceZone
0u // null value
); );
// Mark as duplicate (avoids combining patch faces) if one or both
syncTools::syncFaceList(mesh, duplicateFace, maxEqOp<label>());
// Mark as resulting from baffle/boundary face zone only if both agree
syncTools::syncFaceList(mesh, filterFace, minEqOp<label>());
// Duplicate points
if (returnReduce(nDuplicatePoints, sumOp<label>()) > 0)
{
// Collect all points (recount since syncPointList might have
// increased set)
nDuplicatePoints = 0;
forAll(duplicatePoint, pointI)
{
if (duplicatePoint[pointI])
{
nDuplicatePoints++;
}
}
labelList candidatePoints(nDuplicatePoints);
nDuplicatePoints = 0;
forAll(duplicatePoint, pointI)
{
if (duplicatePoint[pointI])
{
candidatePoints[nDuplicatePoints++] = pointI;
}
}
localPointRegion regionSide(mesh, candidatePoints);
autoPtr<mapPolyMesh> mapPtr = meshRefiner_.dupNonManifoldPoints
(
regionSide
);
meshRefinement::updateList(mapPtr().faceMap(), -1, filterFace);
meshRefinement::updateList(mapPtr().faceMap(), -1, duplicateFace);
// Update baffles and baffle-to-baffle addressing
const labelList& reverseFaceMap = mapPtr().reverseFaceMap();
forAll(baffles, i)
{
labelPair& baffle = baffles[i];
baffle.first() = reverseFaceMap[baffle.first()];
baffle.second() = reverseFaceMap[baffle.second()];
}
if (debug&meshRefinement::MESH)
{
const_cast<Time&>(mesh.time())++;
Pout<< "Writing duplicatedPoints mesh to time "
<< meshRefiner_.timeName()
<< endl;
meshRefiner_.write
(
meshRefinement::debugType(debug),
meshRefinement::writeType
(
meshRefinement::writeLevel()
| meshRefinement::WRITEMESH
),
mesh.time().path()/"duplicatedPoints"
);
}
}
// Forget about baffles in a BAFFLE/BOUNDARY type zone
DynamicList<labelPair> newBaffles(baffles.size());
forAll(baffles, i)
{
const labelPair& baffle = baffles[i];
if
(
filterFace[baffle.first()] == -1
&& filterFace[baffles[i].second()] == -1
)
{
newBaffles.append(baffle);
}
}
if (newBaffles.size() < baffles.size())
{
//Info<< "Splitting baffles into" << nl
// << " internal : " << newBaffles.size() << nl
// << " baffle : " << baffles.size()-newBaffles.size()
// << nl << endl;
baffles.transfer(newBaffles);
}
Info<< endl;
} }
// Duplicate points on faceZones of type boundary
meshRefiner_.dupNonManifoldBoundaryPoints();
bool doFeatures = false; bool doFeatures = false;
label nFeatIter = 1; label nFeatIter = 1;
@ -2720,6 +2555,12 @@ void Foam::autoSnapDriver::doSnap
bool meshOk = false; bool meshOk = false;
// Get the labels of added patches.
labelList adaptPatchIDs(meshRefiner_.meshedPatches());
{ {
autoPtr<indirectPrimitivePatch> ppPtr autoPtr<indirectPrimitivePatch> ppPtr
( (
@ -2732,7 +2573,7 @@ void Foam::autoSnapDriver::doSnap
// Distance to attract to nearest feature on surface // Distance to attract to nearest feature on surface
const scalarField snapDist(calcSnapDistance(mesh, snapParams, ppPtr())); scalarField snapDist(calcSnapDistance(mesh, snapParams, ppPtr()));
// Construct iterative mesh mover. // Construct iterative mesh mover.
@ -2774,13 +2615,27 @@ void Foam::autoSnapDriver::doSnap
Info<< "Checked initial mesh in = " Info<< "Checked initial mesh in = "
<< mesh.time().cpuTimeIncrement() << " s\n" << nl << endl; << mesh.time().cpuTimeIncrement() << " s\n" << nl << endl;
// Extract baffles across internal faceZones (for checking mesh quality
// across
labelPairList internalBaffles
(
meshRefiner_.subsetBaffles
(
mesh,
internalFaceZones,
localPointRegion::findDuplicateFacePairs(mesh)
)
);
// Pre-smooth patch vertices (so before determining nearest) // Pre-smooth patch vertices (so before determining nearest)
preSmoothPatch preSmoothPatch
( (
meshRefiner_, meshRefiner_,
snapParams, snapParams,
nInitErrors, nInitErrors,
baffles, internalBaffles,
meshMoverPtr() meshMoverPtr()
); );
@ -2793,235 +2648,35 @@ void Foam::autoSnapDriver::doSnap
List<pointConstraint> patchConstraints; List<pointConstraint> patchConstraints;
//- Any faces to split
DynamicList<label> splitFaces;
//- Indices in face to split across
DynamicList<labelPair> splits;
for (label iter = 0; iter < nFeatIter; iter++) for (label iter = 0; iter < nFeatIter; iter++)
{ {
//if (doFeatures && (iter == 0 || iter == nFeatIter/2))
//{
// Info<< "Splitting diagonal attractions" << endl;
//
// indirectPrimitivePatch& pp = ppPtr();
// motionSmoother& meshMover = meshMoverPtr();
//
// // Calculate displacement at every patch point. Insert into
// // meshMover.
// // Calculate displacement at every patch point
// pointField nearestPoint;
// vectorField nearestNormal;
//
// if (snapParams.detectNearSurfacesSnap())
// {
// nearestPoint.setSize(pp.nPoints(), vector::max);
// nearestNormal.setSize(pp.nPoints(), vector::zero);
// }
//
// vectorField disp = calcNearestSurface
// (
// meshRefiner_,
// snapDist,
// pp,
// nearestPoint,
// nearestNormal
// );
//
//
// // Override displacement at thin gaps
// if (snapParams.detectNearSurfacesSnap())
// {
// detectNearSurfaces
// (
// Foam::cos(degToRad(planarAngle)),// planar gaps
// pp,
// nearestPoint, // surfacepoint from nearest test
// nearestNormal, // surfacenormal from nearest test
//
// disp
// );
// }
//
// // Override displacement with feature edge attempt
// const label iter = 0;
// calcNearestSurfaceFeature
// (
// snapParams,
// false, // avoidSnapProblems
// iter,
// featureCos,
// scalar(iter+1)/nFeatIter,
// snapDist,
// disp,
// meshMover,
// patchAttraction,
// patchConstraints
// );
//
//
// const labelList& bFaces = ppPtr().addressing();
// DynamicList<label> splitFaces(bFaces.size());
// DynamicList<labelPair> splits(bFaces.size());
//
// forAll(bFaces, faceI)
// {
// const labelPair split
// (
// findDiagonalAttraction
// (
// ppPtr(),
// patchAttraction,
// patchConstraints,
// faceI
// )
// );
//
// if (split != labelPair(-1, -1))
// {
// splitFaces.append(bFaces[faceI]);
// splits.append(split);
// }
// }
//
// Info<< "Splitting "
// << returnReduce(splitFaces.size(), sumOp<label>())
// << " faces along diagonal attractions" << endl;
//
// autoPtr<mapPolyMesh> mapPtr = meshRefiner_.splitFaces
// (
// splitFaces,
// splits
// );
//
// const labelList& faceMap = mapPtr().faceMap();
// meshRefinement::updateList(faceMap, -1, duplicateFace);
// const labelList& reverseFaceMap = mapPtr().reverseFaceMap();
// forAll(baffles, i)
// {
// labelPair& baffle = baffles[i];
// baffle.first() = reverseFaceMap[baffle.first()];
// baffle.second() = reverseFaceMap[baffle.second()];
// }
//
// meshMoverPtr.clear();
// ppPtr.clear();
//
// ppPtr = meshRefinement::makePatch(mesh, adaptPatchIDs);
// meshMoverPtr.reset
// (
// new motionSmoother
// (
// mesh,
// ppPtr(),
// adaptPatchIDs,
// meshRefinement::makeDisplacementField
// (
// pointMesh::New(mesh),
// adaptPatchIDs
// ),
// motionDict
// )
// );
//
// if (debug&meshRefinement::MESH)
// {
// const_cast<Time&>(mesh.time())++;
// Info<< "Writing split diagonal mesh to time "
// << meshRefiner_.timeName() << endl;
// meshRefiner_.write
// (
// meshRefinement::debugType(debug),
// meshRefinement::writeType
// (
// meshRefinement::writeLevel()
// | meshRefinement::WRITEMESH
// ),
// mesh.time().path()/meshRefiner_.timeName()
// );
// }
//}
//else
//if
//(
// doFeatures
// && (iter == 1 || iter == nFeatIter/2+1 || iter == nFeatIter-1)
//)
//{
// Info<< "Splitting warped faces" << endl;
//
// const labelList& bFaces = ppPtr().addressing();
// DynamicList<label> splitFaces(bFaces.size());
// DynamicList<labelPair> splits(bFaces.size());
//
// detectWarpedFaces
// (
// featureCos,
// ppPtr(),
//
// splitFaces,
// splits
// );
//
// Info<< "Splitting "
// << returnReduce(splitFaces.size(), sumOp<label>())
// << " faces along diagonal to avoid warpage" << endl;
//
// autoPtr<mapPolyMesh> mapPtr = meshRefiner_.splitFaces
// (
// splitFaces,
// splits
// );
//
// const labelList& faceMap = mapPtr().faceMap();
// meshRefinement::updateList(faceMap, -1, duplicateFace);
// const labelList& reverseFaceMap = mapPtr().reverseFaceMap();
// forAll(baffles, i)
// {
// labelPair& baffle = baffles[i];
// baffle.first() = reverseFaceMap[baffle.first()];
// baffle.second() = reverseFaceMap[baffle.second()];
// }
//
// meshMoverPtr.clear();
// ppPtr.clear();
//
// ppPtr = meshRefinement::makePatch(mesh, adaptPatchIDs);
// meshMoverPtr.reset
// (
// new motionSmoother
// (
// mesh,
// ppPtr(),
// adaptPatchIDs,
// meshRefinement::makeDisplacementField
// (
// pointMesh::New(mesh),
// adaptPatchIDs
// ),
// motionDict
// )
// );
//
// if (debug&meshRefinement::MESH)
// {
// const_cast<Time&>(mesh.time())++;
// Info<< "Writing split warped mesh to time "
// << meshRefiner_.timeName() << endl;
// meshRefiner_.write
// (
// meshRefinement::debugType(debug),
// meshRefinement::writeType
// (
// meshRefinement::writeLevel()
// | meshRefinement::WRITEMESH
// ),
// mesh.time().path()/meshRefiner_.timeName()
// );
// }
//}
Info<< nl Info<< nl
<< "Morph iteration " << iter << nl << "Morph iteration " << iter << nl
<< "-----------------" << endl; << "-----------------" << endl;
// Splitting iteration?
bool doSplit = false;
if
(
doFeatures
&& snapParams.nFaceSplitInterval() > 0
&& (
(iter == nFeatIter-1)
|| (iter > 0 && (iter%snapParams.nFaceSplitInterval()) == 0)
)
)
{
doSplit = true;
}
indirectPrimitivePatch& pp = ppPtr(); indirectPrimitivePatch& pp = ppPtr();
motionSmoother& meshMover = meshMoverPtr(); motionSmoother& meshMover = meshMoverPtr();
@ -3065,18 +2720,26 @@ void Foam::autoSnapDriver::doSnap
// Override displacement with feature edge attempt // Override displacement with feature edge attempt
if (doFeatures) if (doFeatures)
{ {
splitFaces.clear();
splits.clear();
disp = calcNearestSurfaceFeature disp = calcNearestSurfaceFeature
( (
snapParams, snapParams,
true, // avoidSnapProblems !doSplit, // alignMeshEdges
iter, iter,
featureCos, featureCos,
scalar(iter+1)/nFeatIter, scalar(iter+1)/nFeatIter,
snapDist, snapDist,
disp, disp,
nearestNormal,
meshMover, meshMover,
patchAttraction, patchAttraction,
patchConstraints patchConstraints,
splitFaces,
splits
); );
} }
@ -3108,7 +2771,7 @@ void Foam::autoSnapDriver::doSnap
( (
snapParams, snapParams,
nInitErrors, nInitErrors,
baffles, internalBaffles,
meshMover meshMover
); );
@ -3148,66 +2811,190 @@ void Foam::autoSnapDriver::doSnap
// Use current mesh as base mesh // Use current mesh as base mesh
meshMover.correct(); meshMover.correct();
// See if any faces need splitting
label nTotalSplit = returnReduce(splitFaces.size(), sumOp<label>());
if (nTotalSplit && doSplit)
{
// Filter out baffle faces from faceZones of type
// internal/baffle
labelList duplicateFace(getInternalOrBaffleDuplicateFace());
{
labelList oldSplitFaces(splitFaces.xfer());
List<labelPair> oldSplits(splits.xfer());
forAll(oldSplitFaces, i)
{
if (duplicateFace[oldSplitFaces[i]] == -1)
{
splitFaces.append(oldSplitFaces[i]);
splits.append(oldSplits[i]);
}
}
nTotalSplit = returnReduce
(
splitFaces.size(),
sumOp<label>()
);
}
// Update mesh
meshRefiner_.splitFacesUndo
(
splitFaces,
splits,
motionDict,
duplicateFace,
internalBaffles
);
// Redo meshMover
meshMoverPtr.clear();
ppPtr.clear();
// Update mesh mover
ppPtr = meshRefinement::makePatch(mesh, adaptPatchIDs);
meshMoverPtr.reset
(
new motionSmoother
(
mesh,
ppPtr(),
adaptPatchIDs,
meshRefinement::makeDisplacementField
(
pointMesh::New(mesh),
adaptPatchIDs
),
motionDict
)
);
// Update snapping distance
snapDist = calcSnapDistance(mesh, snapParams, ppPtr());
if (debug&meshRefinement::MESH)
{
const_cast<Time&>(mesh.time())++;
Info<< "Writing split-faces mesh to time "
<< meshRefiner_.timeName() << endl;
meshRefiner_.write
(
meshRefinement::debugType(debug),
meshRefinement::writeType
(
meshRefinement::writeLevel()
| meshRefinement::WRITEMESH
),
mesh.time().path()/meshRefiner_.timeName()
);
}
}
if (debug&meshRefinement::MESH)
{
forAll(internalBaffles, i)
{
const labelPair& p = internalBaffles[i];
const point& fc0 = mesh.faceCentres()[p[0]];
const point& fc1 = mesh.faceCentres()[p[1]];
if (mag(fc0-fc1) > meshRefiner_.mergeDistance())
{
FatalErrorIn("autoSnapDriver::doSnap(..)")
<< "Separated baffles : f0:" << p[0]
<< " centre:" << fc0
<< " f1:" << p[1] << " centre:" << fc1
<< " distance:" << mag(fc0-fc1)
<< exit(FatalError);
}
}
}
} }
} }
// Merge any introduced baffles (from faceZones of faceType 'internal') // Merge any introduced baffles (from faceZones of faceType 'internal')
{ {
autoPtr<mapPolyMesh> mapPtr = mergeZoneBaffles(baffles); autoPtr<mapPolyMesh> mapPtr = meshRefiner_.mergeZoneBaffles
(
true, // internal zones
false // baffle zones
);
if (mapPtr.valid()) if (mapPtr.valid())
{ {
forAll(duplicateFace, faceI) if (debug & meshRefinement::MESH)
{ {
if (duplicateFace[faceI] != -1) const_cast<Time&>(mesh.time())++;
{ Info<< "Writing baffle-merged mesh to time "
duplicateFace[faceI] = mapPtr().reverseFaceMap()[faceI]; << meshRefiner_.timeName() << endl;
} meshRefiner_.write
(
meshRefinement::debugType(debug),
meshRefinement::writeType
(
meshRefinement::writeLevel()
| meshRefinement::WRITEMESH
),
meshRefiner_.timeName()
);
} }
} }
} }
// Repatch faces according to nearest. Do not repatch baffle faces. // Repatch faces according to nearest. Do not repatch baffle faces.
{ {
autoPtr<mapPolyMesh> mapPtr = repatchToSurface labelList duplicateFace(getInternalOrBaffleDuplicateFace());
(
snapParams, repatchToSurface(snapParams, adaptPatchIDs, duplicateFace);
adaptPatchIDs,
duplicateFace
);
meshRefinement::updateList(mapPtr().faceMap(), -1, duplicateFace);
} }
// Repatching might have caused faces to be on same patch and hence if (mergePatchFaces)
// mergeable so try again to merge coplanar faces. Do not merge baffle {
// faces to ensure they both stay the same. labelList duplicateFace(getInternalOrBaffleDuplicateFace());
label nChanged = meshRefiner_.mergePatchFacesUndo
(
featureCos, // minCos
featureCos, // concaveCos
meshRefiner_.meshedPatches(),
motionDict,
duplicateFace // faces not to merge
);
nChanged += meshRefiner_.mergeEdgesUndo(featureCos, motionDict); // Repatching might have caused faces to be on same patch and hence
// mergeable so try again to merge coplanar faces. Do not merge baffle
// faces to ensure they both stay the same.
label nChanged = meshRefiner_.mergePatchFacesUndo
(
featureCos, // minCos
featureCos, // concaveCos
meshRefiner_.meshedPatches(),
motionDict,
duplicateFace // faces not to merge
);
if (nChanged > 0 && debug & meshRefinement::MESH) nChanged += meshRefiner_.mergeEdgesUndo(featureCos, motionDict);
if (nChanged > 0 && debug & meshRefinement::MESH)
{
const_cast<Time&>(mesh.time())++;
Info<< "Writing patchFace merged mesh to time "
<< meshRefiner_.timeName() << endl;
meshRefiner_.write
(
meshRefinement::debugType(debug),
meshRefinement::writeType
(
meshRefinement::writeLevel()
| meshRefinement::WRITEMESH
),
meshRefiner_.timeName()
);
}
}
if (debug & meshRefinement::MESH)
{ {
const_cast<Time&>(mesh.time())++; const_cast<Time&>(mesh.time())++;
Info<< "Writing patchFace merged mesh to time "
<< meshRefiner_.timeName() << endl;
meshRefiner_.write
(
meshRefinement::debugType(debug),
meshRefinement::writeType
(
meshRefinement::writeLevel()
| meshRefinement::WRITEMESH
),
meshRefiner_.timeName()
);
} }
} }

View File

@ -37,6 +37,7 @@ SourceFiles
#define autoSnapDriver_H #define autoSnapDriver_H
#include "meshRefinement.H" #include "meshRefinement.H"
#include "DynamicField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -45,6 +46,7 @@ namespace Foam
// Forward declaration of classes // Forward declaration of classes
class motionSmoother; class motionSmoother;
class refinementParameters;
class snapParameters; class snapParameters;
class pointConstraint; class pointConstraint;
@ -87,18 +89,18 @@ class autoSnapDriver
const List<labelPair>& const List<labelPair>&
); );
//static tmp<pointField> avg static tmp<pointField> avg
//( (
// const indirectPrimitivePatch&, const indirectPrimitivePatch&,
// const pointField& const pointField&
//); );
//- Calculate displacement per patch point. Wip. //- Calculate displacement per patch point. Wip.
//static tmp<pointField> smoothLambdaMuPatchDisplacement static pointField smoothLambdaMuPatchDisplacement
//( (
// const motionSmoother& meshMover, const motionSmoother& meshMover,
// const List<labelPair>& baffles const List<labelPair>& baffles
//); );
//- Check that face zones are synced //- Check that face zones are synced
@ -136,6 +138,10 @@ class autoSnapDriver
DynamicList<labelPair>& splits DynamicList<labelPair>& splits
) const; ) const;
//- Get per face -1 or label of opposite face if on internal/baffle
// faceZone
labelList getInternalOrBaffleDuplicateFace() const;
// Feature line snapping // Feature line snapping
//- Is point on two feature edges that make a largish angle? //- Is point on two feature edges that make a largish angle?
@ -177,8 +183,8 @@ class autoSnapDriver
const scalarField& faceSnapDist, const scalarField& faceSnapDist,
vectorField& faceDisp, vectorField& faceDisp,
vectorField& faceSurfaceNormal, vectorField& faceSurfaceNormal,
labelList& faceSurfaceRegion, labelList& faceSurfaceRegion
vectorField& faceRotation //vectorField& faceRotation
) const; ) const;
void calcNearestFacePointProperties void calcNearestFacePointProperties
( (
@ -253,6 +259,86 @@ class autoSnapDriver
const label faceI const label faceI
) const; ) const;
scalar pyrVol
(
const indirectPrimitivePatch& pp,
const vectorField& featureAttraction,
const face& localF,
const point& cc
) const;
void facePoints
(
const indirectPrimitivePatch& pp,
const vectorField& featureAttraction,
const vectorField& nearestAttraction,
const face& f,
DynamicField<point>& points
) const;
scalar pyrVol
(
const indirectPrimitivePatch& pp,
const vectorField& featureAttraction,
const vectorField& nearestAttraction,
const face& localF,
const point& cc
) const;
Tuple2<point, vector> centreAndNormal
(
const indirectPrimitivePatch& pp,
const vectorField& featureAttraction,
const vectorField& nearestAttraction,
const face& localF
) const;
bool isSplitAlignedWithFeature
(
const scalar featureCos,
const point& newPt0,
const pointConstraint& pc0,
const point& newPt1,
const pointConstraint& pc1
) const;
bool isConcave
(
const point& c0,
const vector& area0,
const point& c1,
const vector& area1,
const scalar concaveCos
) const;
labelPair findDiagonalAttraction
(
const scalar featureCos,
const scalar concaveCos,
const scalar minAreaFraction,
const indirectPrimitivePatch& pp,
const vectorField& patchAttraction,
const List<pointConstraint>& patchConstraints,
const vectorField& nearestAttraction,
const vectorField& nearestNormal,
const label faceI,
DynamicField<point>& points0,
DynamicField<point>& points1
) const;
//- Do all logic on whether to add face cut to diagonal
// attraction
void splitDiagonals
(
const scalar featureCos,
const scalar concaveCos,
const scalar minAreaFraction,
const indirectPrimitivePatch& pp,
const vectorField& nearestAttraction,
const vectorField& nearestNormal,
vectorField& patchAttraction,
List<pointConstraint>& patchConstraints,
DynamicList<label>& splitFaces,
DynamicList<labelPair>& splits
) const;
//- Avoid attraction across face diagonal since would //- Avoid attraction across face diagonal since would
// cause face squeeze // cause face squeeze
void avoidDiagonalAttraction void avoidDiagonalAttraction
@ -264,6 +350,14 @@ class autoSnapDriver
List<pointConstraint>& patchConstraints List<pointConstraint>& patchConstraints
) const; ) const;
//- Write some stats about constraints
void writeStats
(
const indirectPrimitivePatch& pp,
const PackedBoolList& isMasterPoint,
const List<pointConstraint>& patchConstraints
) const;
//- Return hit if on multiple points //- Return hit if on multiple points
pointIndexHit findMultiPatchPoint pointIndexHit findMultiPatchPoint
( (
@ -320,7 +414,6 @@ class autoSnapDriver
void featureAttractionUsingReconstruction void featureAttractionUsingReconstruction
( (
const label iter, const label iter,
const bool avoidSnapProblems,
const scalar featureCos, const scalar featureCos,
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const scalarField& snapDist, const scalarField& snapDist,
@ -450,12 +543,19 @@ class autoSnapDriver
void featureAttractionUsingFeatureEdges void featureAttractionUsingFeatureEdges
( (
const label iter, const label iter,
const bool avoidSnapProblems,
const scalar featureCos,
const bool multiRegionFeatureSnap, const bool multiRegionFeatureSnap,
const bool detectBaffles,
const bool releasePoints,
const bool stringFeatures,
const bool avoidDiagonal,
const scalar featureCos,
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const scalarField& snapDist, const scalarField& snapDist,
const vectorField& nearestDisp, const vectorField& nearestDisp,
const vectorField& nearestNormal,
const List<List<point> >& pointFaceSurfNormals, const List<List<point> >& pointFaceSurfNormals,
const List<List<point> >& pointFaceDisp, const List<List<point> >& pointFaceDisp,
@ -465,12 +565,14 @@ class autoSnapDriver
vectorField& patchAttraction, vectorField& patchAttraction,
List<pointConstraint>& patchConstraints List<pointConstraint>& patchConstraints
) const; ) const;
void preventFaceSqueeze void preventFaceSqueeze
( (
const label iter, const label iter,
const scalar featureCos, const scalar featureCos,
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const scalarField& snapDist, const scalarField& snapDist,
const vectorField& nearestAttraction,
vectorField& patchAttraction, vectorField& patchAttraction,
List<pointConstraint>& patchConstraints List<pointConstraint>& patchConstraints
@ -483,15 +585,19 @@ class autoSnapDriver
vectorField calcNearestSurfaceFeature vectorField calcNearestSurfaceFeature
( (
const snapParameters& snapParams, const snapParameters& snapParams,
const bool avoidSnapProblems, const bool alignMeshEdges,
const label iter, const label iter,
const scalar featureCos, const scalar featureCos,
const scalar featureAttract, const scalar featureAttract,
const scalarField& snapDist, const scalarField& snapDist,
const vectorField& nearestDisp, const vectorField& nearestDisp,
const vectorField& nearestNormal,
motionSmoother& meshMover, motionSmoother& meshMover,
vectorField& patchAttraction, vectorField& patchAttraction,
List<pointConstraint>& patchConstraints List<pointConstraint>& patchConstraints,
DynamicList<label>& splitFaces,
DynamicList<labelPair>& splits
) const; ) const;
@ -622,6 +728,7 @@ public:
( (
const dictionary& snapDict, const dictionary& snapDict,
const dictionary& motionDict, const dictionary& motionDict,
const bool mergePatchFaces,
const scalar featureCos, const scalar featureCos,
const scalar planarAngle, const scalar planarAngle,
const snapParameters& snapParams const snapParameters& snapParams

View File

@ -124,6 +124,14 @@ Foam::layerParameters::layerParameters
readScalar(dict.lookup("minThickness")) readScalar(dict.lookup("minThickness"))
), ),
featureAngle_(readScalar(dict.lookup("featureAngle"))), featureAngle_(readScalar(dict.lookup("featureAngle"))),
mergePatchFacesAngle_
(
dict.lookupOrDefault<scalar>
(
"mergePatchFacesAngle",
0.5*featureAngle_
)
),
concaveAngle_ concaveAngle_
( (
dict.lookupOrDefault("concaveAngle", defaultConcaveAngle) dict.lookupOrDefault("concaveAngle", defaultConcaveAngle)

View File

@ -114,6 +114,8 @@ private:
scalar featureAngle_; scalar featureAngle_;
scalar mergePatchFacesAngle_;
scalar concaveAngle_; scalar concaveAngle_;
label nGrow_; label nGrow_;
@ -247,6 +249,11 @@ public:
return featureAngle_; return featureAngle_;
} }
scalar mergePatchFacesAngle() const
{
return mergePatchFacesAngle_;
}
scalar concaveAngle() const scalar concaveAngle() const
{ {
return concaveAngle_; return concaveAngle_;

View File

@ -27,6 +27,8 @@ License
#include "unitConversion.H" #include "unitConversion.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "globalIndex.H" #include "globalIndex.H"
#include "Tuple2.H"
#include "wallPolyPatch.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -44,7 +46,15 @@ Foam::refinementParameters::refinementParameters(const dictionary& dict)
) )
), ),
nBufferLayers_(readLabel(dict.lookup("nCellsBetweenLevels"))), nBufferLayers_(readLabel(dict.lookup("nCellsBetweenLevels"))),
keepPoints_(pointField(1, dict.lookup("locationInMesh"))), locationsOutsideMesh_
(
dict.lookupOrDefault
(
"locationsOutsideMesh",
pointField(0)
)
),
faceZoneControls_(dict.subOrEmptyDict("faceZoneControls")),
allowFreeStandingZoneFaces_(dict.lookup("allowFreeStandingZoneFaces")), allowFreeStandingZoneFaces_(dict.lookup("allowFreeStandingZoneFaces")),
useTopologicalSnapDetection_ useTopologicalSnapDetection_
( (
@ -56,6 +66,29 @@ Foam::refinementParameters::refinementParameters(const dictionary& dict)
dict.lookupOrDefault<Switch>("handleSnapProblems", true) dict.lookupOrDefault<Switch>("handleSnapProblems", true)
) )
{ {
point locationInMesh;
if (dict.readIfPresent("locationInMesh", locationInMesh))
{
locationsInMesh_.append(locationInMesh);
zonesInMesh_.append("noneIfNotSet");// special name for no cellZone
}
List<Tuple2<point, word> > pointsToZone;
if (dict.readIfPresent("locationsInMesh", pointsToZone))
{
label nZones = locationsInMesh_.size();
locationsInMesh_.setSize(nZones+pointsToZone.size());
zonesInMesh_.setSize(locationsInMesh_.size());
forAll(pointsToZone, i)
{
locationsInMesh_[nZones] = pointsToZone[i].first();
zonesInMesh_[nZones] = pointsToZone[i].second();
nZones++;
}
}
scalar featAngle(readScalar(dict.lookup("resolveFeatureAngle"))); scalar featAngle(readScalar(dict.lookup("resolveFeatureAngle")));
if (featAngle < 0 || featAngle > 180) if (featAngle < 0 || featAngle > 180)
@ -71,8 +104,68 @@ Foam::refinementParameters::refinementParameters(const dictionary& dict)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::labelList Foam::refinementParameters::findCells(const polyMesh& mesh) Foam::dictionary Foam::refinementParameters::getZoneInfo
const (
const word& fzName,
surfaceZonesInfo::faceZoneType& faceType
) const
{
dictionary patchInfo;
patchInfo.add("type", wallPolyPatch::typeName);
faceType = surfaceZonesInfo::INTERNAL;
if (faceZoneControls_.found(fzName))
{
const dictionary& fzDict = faceZoneControls_.subDict(fzName);
if (fzDict.found("patchInfo"))
{
patchInfo = fzDict.subDict("patchInfo");
}
word faceTypeName;
if (fzDict.readIfPresent("faceType", faceTypeName))
{
faceType = surfaceZonesInfo::faceZoneTypeNames[faceTypeName];
}
}
return patchInfo;
}
Foam::labelList Foam::refinementParameters::addCellZonesToMesh
(
polyMesh& mesh
) const
{
labelList zoneIDs(zonesInMesh_.size(), -1);
forAll(zonesInMesh_, i)
{
if
(
zonesInMesh_[i] != word::null
&& zonesInMesh_[i] != "none"
&& zonesInMesh_[i] != "noneIfNotSet"
)
{
zoneIDs[i] = surfaceZonesInfo::addCellZone
(
zonesInMesh_[i], // name
labelList(0), // addressing
mesh
);
}
}
return zoneIDs;
}
Foam::labelList Foam::refinementParameters::findCells
(
const bool checkInsideMesh,
const polyMesh& mesh,
const pointField& locations
)
{ {
// Force calculation of tet-diag decomposition (for use in findCell) // Force calculation of tet-diag decomposition (for use in findCell)
(void)mesh.tetBasePtIs(); (void)mesh.tetBasePtIs();
@ -81,13 +174,13 @@ const
globalIndex globalCells(mesh.nCells()); globalIndex globalCells(mesh.nCells());
// Cell label per point // Cell label per point
labelList cellLabels(keepPoints_.size()); labelList cellLabels(locations.size());
forAll(keepPoints_, i) forAll(locations, i)
{ {
const point& keepPoint = keepPoints_[i]; const point& location = locations[i];
label localCellI = mesh.findCell(keepPoint); label localCellI = mesh.findCell(location);
label globalCellI = -1; label globalCellI = -1;
@ -98,12 +191,13 @@ const
reduce(globalCellI, maxOp<label>()); reduce(globalCellI, maxOp<label>());
if (globalCellI == -1) if (checkInsideMesh && globalCellI == -1)
{ {
FatalErrorIn FatalErrorIn
( (
"refinementParameters::findCells(const polyMesh&) const" "refinementParameters::findCells"
) << "Point " << keepPoint "(const polyMesh&, const pointField&) const"
) << "Point " << location
<< " is not inside the mesh or on a face or edge." << nl << " is not inside the mesh or on a face or edge." << nl
<< "Bounding box of the mesh:" << mesh.bounds() << "Bounding box of the mesh:" << mesh.bounds()
<< exit(FatalError); << exit(FatalError);
@ -113,10 +207,9 @@ const
label procI = globalCells.whichProcID(globalCellI); label procI = globalCells.whichProcID(globalCellI);
label procCellI = globalCells.toLocal(procI, globalCellI); label procCellI = globalCells.toLocal(procI, globalCellI);
Info<< "Found point " << keepPoint << " in cell " << procCellI Info<< "Found point " << location << " in cell " << procCellI
<< " on processor " << procI << endl; << " on processor " << procI << endl;
if (globalCells.isLocal(globalCellI)) if (globalCells.isLocal(globalCellI))
{ {
cellLabels[i] = localCellI; cellLabels[i] = localCellI;
@ -130,4 +223,48 @@ const
} }
Foam::labelList Foam::refinementParameters::zonedLocations
(
const wordList& zonesInMesh
)
{
DynamicList<label> indices(zonesInMesh.size());
forAll(zonesInMesh, i)
{
if
(
zonesInMesh[i] == word::null
|| zonesInMesh[i] != "noneIfNotSet"
)
{
indices.append(i);
}
}
return indices;
}
Foam::labelList Foam::refinementParameters::unzonedLocations
(
const wordList& zonesInMesh
)
{
DynamicList<label> indices(0);
forAll(zonesInMesh, i)
{
if
(
zonesInMesh[i] != word::null
&& zonesInMesh[i] == "noneIfNotSet"
)
{
indices.append(i);
}
}
return indices;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -38,6 +38,8 @@ SourceFiles
#include "dictionary.H" #include "dictionary.H"
#include "pointField.H" #include "pointField.H"
#include "Switch.H" #include "Switch.H"
#include "wordPairHashTable.H"
#include "surfaceZonesInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,8 +75,21 @@ class refinementParameters
//- Number of layers between different refinement levels //- Number of layers between different refinement levels
const label nBufferLayers_; const label nBufferLayers_;
//- Areas to keep
const pointField keepPoints_; // Selection of areas
//- Areas not to keep
const pointField locationsOutsideMesh_;
//- Areas to keep
pointField locationsInMesh_;
//- Region for location
wordList zonesInMesh_;
//- Information on how to handle faces on faceZones
dictionary faceZoneControls_;
//- FaceZone faces allowed which have owner and neighbour in same //- FaceZone faces allowed which have owner and neighbour in same
// cellZone? // cellZone?
@ -147,9 +162,21 @@ public:
} }
//- Areas to keep //- Areas to keep
const pointField& keepPoints() const const pointField& locationsInMesh() const
{ {
return keepPoints_; return locationsInMesh_;
}
//- Per area the zone name
const wordList& zonesInMesh() const
{
return zonesInMesh_;
}
//- Optional points which are checked to be outside the mesh
const pointField& locationsOutsideMesh() const
{
return locationsOutsideMesh_;
} }
//- Are zone faces allowed only inbetween different cell zones //- Are zone faces allowed only inbetween different cell zones
@ -180,8 +207,30 @@ public:
// Other // Other
//- Checks that cells are in mesh. Returns cells they are in. //- Get patchInfo and faceType for faceZone
labelList findCells(const polyMesh&) const; dictionary getZoneInfo
(
const word& fzName,
surfaceZonesInfo::faceZoneType& faceType
) const;
//- Add cellZones to mesh. Return indices of cellZones (or -1)
labelList addCellZonesToMesh(polyMesh&) const;
//- Checks that cells are in mesh. Returns cells (or -1) they
// are in.
static labelList findCells
(
const bool checkInsideMesh,
const polyMesh&,
const pointField& locations
);
//- Extract indices of named locations (so excludes 'keepPoints')
static labelList zonedLocations(const wordList& zonesInMesh);
//- Extract indices of unnamed locations ('keepPoints')
static labelList unzonedLocations(const wordList& zonesInMesh);
}; };

View File

@ -0,0 +1,56 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Typedef
Foam::wordPairHashTable
Description
HashTable of Pair<word>
Typedef
Foam::wordPairHashTable
Description
HashTable of Pair<word>
\*---------------------------------------------------------------------------*/
#ifndef wordPairHashTable_H
#define wordPairHashTable_H
#include "Pair.H"
#include "HashTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef HashTable<word, Pair<word>, typename FixedList<word, 2>::Hash<> >
wordPairHashTable;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -44,7 +44,17 @@ Foam::snapParameters::snapParameters(const dictionary& dict)
detectNearSurfacesSnap_ detectNearSurfacesSnap_
( (
dict.lookupOrDefault("detectNearSurfacesSnap", true) dict.lookupOrDefault("detectNearSurfacesSnap", true)
) ),
detectBaffles_(dict.lookupOrDefault("detectBaffles", true)),
releasePoints_(dict.lookupOrDefault("releasePoints", false)),
stringFeatures_(dict.lookupOrDefault("stringFeatures", true)),
avoidDiagonal_(dict.lookupOrDefault("avoidDiagonal", false)),
nFaceSplitInterval_
(
dict.lookupOrDefault("nFaceSplitInterval", labelMin)
),
concaveAngle_(dict.lookupOrDefault("concaveAngle", 45)),
minAreaRatio_(dict.lookupOrDefault("minAreaRatio", 0.3))
{} {}

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -72,6 +72,24 @@ class snapParameters
const Switch detectNearSurfacesSnap_; const Switch detectNearSurfacesSnap_;
const Switch detectBaffles_;
const Switch releasePoints_;
const Switch stringFeatures_;
const Switch avoidDiagonal_;
//- How often needs face splitting be run
label nFaceSplitInterval_;
//- When is angle too concave too split
scalar concaveAngle_;
//- When is face-split not sufficiently diagonal
scalar minAreaRatio_;
// Private Member Functions // Private Member Functions
@ -123,30 +141,78 @@ public:
return nSnap_; return nSnap_;
} }
label nFeatureSnap() const
{
return nFeatureSnap_;
}
Switch explicitFeatureSnap() const // Surface snapping specific
{
return explicitFeatureSnap_; Switch detectNearSurfacesSnap() const
} {
return detectNearSurfacesSnap_;
}
// Feature edge snapping specific
label nFeatureSnap() const
{
return nFeatureSnap_;
}
Switch explicitFeatureSnap() const
{
return explicitFeatureSnap_;
}
Switch implicitFeatureSnap() const
{
return implicitFeatureSnap_;
}
Switch multiRegionFeatureSnap() const
{
return multiRegionFeatureSnap_;
}
Switch detectBaffles() const
{
return detectBaffles_;
}
Switch releasePoints() const
{
return releasePoints_;
}
Switch stringFeatures() const
{
return stringFeatures_;
}
Switch avoidDiagonal() const
{
return avoidDiagonal_;
}
// Face splitting
label nFaceSplitInterval() const
{
return nFaceSplitInterval_;
}
scalar concaveAngle() const
{
return concaveAngle_;
}
scalar minAreaRatio() const
{
return minAreaRatio_;
}
Switch implicitFeatureSnap() const
{
return implicitFeatureSnap_;
}
Switch multiRegionFeatureSnap() const
{
return multiRegionFeatureSnap_;
}
Switch detectNearSurfacesSnap() const
{
return detectNearSurfacesSnap_;
}
}; };

View File

@ -1203,7 +1203,8 @@ handleFeatureAngleLayerTerminations
//Info<< "Added " //Info<< "Added "
// << returnReduce(nPointCounter-nOldPointCounter, sumOp<label>()) // << returnReduce(nPointCounter-nOldPointCounter, sumOp<label>())
// << " point not to extrude." << endl; // << " point not to extrude due to minCos "
// << minCos << endl;
} }
@ -1225,7 +1226,19 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
const labelListList& pointFaces = pp.pointFaces(); const labelListList& pointFaces = pp.pointFaces();
Info<< typeName << " : Removing isolated regions ..." << endl; Info<< typeName << " : Removing isolated regions ..."
<< indent << "- if partially extruded faces make angle < "
<< Foam::radToDeg(Foam::acos(minCosLayerTermination)) << nl;
if (detectExtrusionIsland)
{
Info<< indent << "- if exclusively surrounded by non-extruded points"
<< nl;
}
else
{
Info<< indent << "- if exclusively surrounded by non-extruded faces"
<< nl;
}
// Keep count of number of points unextruded // Keep count of number of points unextruded
label nPointCounter = 0; label nPointCounter = 0;
@ -1234,19 +1247,21 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
{ {
// Stop layer growth where mesh wraps around edge with a // Stop layer growth where mesh wraps around edge with a
// large feature angle // large feature angle
handleFeatureAngleLayerTerminations if (minCosLayerTermination > -1)
( {
minCosLayerTermination, handleFeatureAngleLayerTerminations
isMasterPoint, (
meshEdges, minCosLayerTermination,
isMasterPoint,
meshEdges,
extrudeStatus, extrudeStatus,
patchDisp, patchDisp,
nPointCounter nPointCounter
); );
syncPatchDisplacement(minThickness, patchDisp, extrudeStatus);
syncPatchDisplacement(minThickness, patchDisp, extrudeStatus);
}
// Detect either: // Detect either:
@ -1708,10 +1723,12 @@ void Foam::medialAxisMeshMover::calculateDisplacement
const scalar featureAngle = readScalar(coeffDict.lookup("featureAngle")); const scalar featureAngle = readScalar(coeffDict.lookup("featureAngle"));
//- Stop layer growth where mesh wraps around sharp edge //- Stop layer growth where mesh wraps around sharp edge
const scalar minCosLayerTermination = Foam::cos scalar layerTerminationAngle = coeffDict.lookupOrDefault<scalar>
( (
degToRad(0.5*featureAngle) "layerTerminationAngle",
0.5*featureAngle
); );
scalar minCosLayerTermination = Foam::cos(degToRad(layerTerminationAngle));
//- Smoothing wanted patch thickness //- Smoothing wanted patch thickness
const label nSmoothPatchThickness = readLabel const label nSmoothPatchThickness = readLabel

File diff suppressed because it is too large Load Diff

View File

@ -51,6 +51,8 @@ SourceFiles
#include "pointFieldsFwd.H" #include "pointFieldsFwd.H"
#include "Tuple2.H" #include "Tuple2.H"
#include "pointIndexHit.H" #include "pointIndexHit.H"
#include "wordPairHashTable.H"
#include "surfaceZonesInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -74,6 +76,7 @@ class localPointRegion;
class snapParameters; class snapParameters;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class meshRefinement Declaration Class meshRefinement Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -190,6 +193,15 @@ private:
// order changes. // order changes.
wordList meshedPatches_; wordList meshedPatches_;
//- FaceZone to master patch name
HashTable<word, word> faceZoneToMasterPatch_;
//- FaceZone to slave patch name
HashTable<word, word> faceZoneToSlavePatch_;
//- FaceZone to method to handle faces
HashTable<surfaceZonesInfo::faceZoneType, word> faceZoneToType_;
// Private Member Functions // Private Member Functions
@ -216,9 +228,6 @@ private:
pointField& neiCc pointField& neiCc
) const; ) const;
//- Find any intersection of surface. Store in surfaceIndex_.
void updateIntersections(const labelList& changedFaces);
//- Remove cells. Put exposedFaces into exposedPatchIDs. //- Remove cells. Put exposedFaces into exposedPatchIDs.
autoPtr<mapPolyMesh> doRemoveCells autoPtr<mapPolyMesh> doRemoveCells
( (
@ -369,10 +378,25 @@ private:
const labelList& globalToSlavePatch const labelList& globalToSlavePatch
) const; ) const;
//- Calculate intersections. Return per face -1 or the global
// surface region
void getIntersections
(
const labelList& surfacesToTest,
const pointField& neiCc,
const labelList& testFaces,
labelList& globalRegion1,
labelList& globalRegion2
) const;
//- Determine patches for baffles //- Determine patches for baffles
void getBafflePatches void getBafflePatches
( (
const labelList& globalToMasterPatch, const labelList& globalToMasterPatch,
const pointField& locationsInMesh,
const wordList& regionsInMesh,
const labelList& neiLevel, const labelList& neiLevel,
const pointField& neiCc, const pointField& neiCc,
labelList& ownPatch, labelList& ownPatch,
@ -494,6 +518,16 @@ private:
labelList& cellToZone labelList& cellToZone
) const; ) const;
//- Finds zone per cell for cells inside region for which name
// is specified.
void findCellZoneInsideWalk
(
const pointField& locationsInMesh,
const wordList& regionsInMesh,
const labelList& blockedFace, // per face -1 or some index >= 0
labelList& cellToZone
) const;
//- Determines cell zone from cell region information. //- Determines cell zone from cell region information.
bool calcRegionToZone bool calcRegionToZone
( (
@ -508,7 +542,7 @@ private:
// marked in namedSurfaceIndex regarded as blocked. // marked in namedSurfaceIndex regarded as blocked.
void findCellZoneTopo void findCellZoneTopo
( (
const point& keepPoint, const pointField& locationsInMesh,
const labelList& namedSurfaceIndex, const labelList& namedSurfaceIndex,
const labelList& surfaceToCellZone, const labelList& surfaceToCellZone,
labelList& cellToZone labelList& cellToZone
@ -520,6 +554,26 @@ private:
labelList& namedSurfaceIndex labelList& namedSurfaceIndex
) const; ) const;
//- Put cells into cellZone, faces into faceZone
void zonify
(
const PackedBoolList& isMasterFace,
const labelList& cellToZone,
const labelList& neiCellZone,
const labelList& faceToZone,
const boolList& meshFlipMap,
polyTopoChange& meshMod
) const;
//- Allocate faceZoneName
void allocateInterRegionFaceZone
(
const label ownZone,
const label neiZone,
wordPairHashTable& zonesToFaceZone,
HashTable<word, labelPair, typename labelPair::Hash<> >&
) const;
//- Remove any loose standing cells //- Remove any loose standing cells
void handleSnapProblems void handleSnapProblems
( (
@ -840,7 +894,9 @@ public:
Time& runTime, Time& runTime,
const labelList& globalToMasterPatch, const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch, const labelList& globalToSlavePatch,
const point& keepPoint const pointField& locationsInMesh,
const wordList& regionsInMesh,
const pointField& locationsOutsideMesh
); );
//- Split off (with optional buffer layers) unreachable areas //- Split off (with optional buffer layers) unreachable areas
@ -850,7 +906,10 @@ public:
const label nBufferLayers, const label nBufferLayers,
const labelList& globalToMasterPatch, const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch, const labelList& globalToSlavePatch,
const point& keepPoint
const pointField& locationsInMesh,
const wordList& regionsInMesh,
const pointField& locationsOutsideMesh
); );
//- Find boundary points that connect to more than one cell //- Find boundary points that connect to more than one cell
@ -861,6 +920,16 @@ public:
// region and split them. // region and split them.
autoPtr<mapPolyMesh> dupNonManifoldPoints(); autoPtr<mapPolyMesh> dupNonManifoldPoints();
//- Find boundary points that are on faceZones of type boundary
// and duplicate them
autoPtr<mapPolyMesh> dupNonManifoldBoundaryPoints();
//- Merge duplicate points
autoPtr<mapPolyMesh> mergePoints
(
const labelList& pointToDuplicate
);
//- Create baffle for every internal face where ownPatch != -1. //- Create baffle for every internal face where ownPatch != -1.
// External faces get repatched according to ownPatch (neiPatch // External faces get repatched according to ownPatch (neiPatch
// should be -1 for these) // should be -1 for these)
@ -870,25 +939,50 @@ public:
const labelList& neiPatch const labelList& neiPatch
); );
//- Create baffles for faces straddling zoned surfaces. Return //- Get zones of given type
// baffles. labelList getZones
autoPtr<mapPolyMesh> createZoneBaffles
( (
const labelList& globalToMasterPatch, const List<surfaceZonesInfo::faceZoneType>& fzTypes
const labelList& globalToSlavePatch, ) const;
List<labelPair>&
//- Subset baffles according to zones
static List<labelPair> subsetBaffles
(
const polyMesh& mesh,
const labelList& zoneIDs,
const List<labelPair>& baffles
); );
//- Merge baffles. Gets pairs of faces. //- Create baffles for faces on faceZones. Return created baffles
// (= pairs of faces) and corresponding faceZone
autoPtr<mapPolyMesh> createZoneBaffles
(
const labelList& zoneIDs,
List<labelPair>& baffles,
labelList& originatingFaceZone
);
//- Merge baffles. Gets pairs of faces
autoPtr<mapPolyMesh> mergeBaffles(const List<labelPair>&); autoPtr<mapPolyMesh> mergeBaffles(const List<labelPair>&);
//- Merge all baffles on faceZones
autoPtr<mapPolyMesh> mergeZoneBaffles
(
const bool doInternalZones,
const bool doBaffleZones
);
//- Put faces/cells into zones according to surface specification. //- Put faces/cells into zones according to surface specification.
// Returns null if no zone surfaces present. Region containing // Returns null if no zone surfaces present. Regions containing
// the keepPoint will not be put into a cellZone. // locationsInMesh/regionsInMesh will be put in corresponding
// cellZone. keepPoints is for backwards compatibility and sets
// all yet unassigned cells to be non-zoned (zone = -1)
autoPtr<mapPolyMesh> zonify autoPtr<mapPolyMesh> zonify
( (
const point& keepPoint, const bool allowFreeStandingZoneFaces,
const bool allowFreeStandingZoneFaces const pointField& locationsInMesh,
const wordList& regionsInMesh,
wordPairHashTable& zonesToFaceZone
); );
@ -913,9 +1007,32 @@ public:
//- Get patchIDs for patches added in addMeshedPatch. //- Get patchIDs for patches added in addMeshedPatch.
labelList meshedPatches() const; labelList meshedPatches() const;
//- Add/lookup faceZone and update information. Return index of
// faceZone
label addFaceZone
(
const word& fzName,
const word& masterPatch,
const word& slavePatch,
const surfaceZonesInfo::faceZoneType& fzType
);
//- Lookup faceZone information. Return false if no information
// for faceZone
bool getFaceZoneInfo
(
const word& fzName,
label& masterPatchID,
label& slavePatchID,
surfaceZonesInfo::faceZoneType& fzType
) const;
//- Select coupled faces that are not collocated //- Select coupled faces that are not collocated
void selectSeparatedCoupledFaces(boolList&) const; void selectSeparatedCoupledFaces(boolList&) const;
//- Find any intersection of surface. Store in surfaceIndex_.
void updateIntersections(const labelList& changedFaces);
//- Find region point is in. Uses optional perturbation to re-test. //- Find region point is in. Uses optional perturbation to re-test.
static label findRegion static label findRegion
( (
@ -925,19 +1042,43 @@ public:
const point& p const point& p
); );
static void findRegions
(
const polyMesh&,
const vector& perturbVec,
const pointField& locationsInMesh,
const pointField& locationsOutsideMesh,
const label nRegions,
labelList& cellRegion
);
//- Split mesh. Keep part containing point. //- Split mesh. Keep part containing point.
autoPtr<mapPolyMesh> splitMeshRegions autoPtr<mapPolyMesh> splitMeshRegions
( (
const labelList& globalToMasterPatch, const labelList& globalToMasterPatch,
const labelList& globalToSlavePatch, const labelList& globalToSlavePatch,
const point& keepPoint const pointField& locationsInMesh,
const pointField& locationsOutsideMesh
); );
//- Split faces into two //- Split faces into two
autoPtr<mapPolyMesh> splitFaces void doSplitFaces
( (
const labelList& splitFaces, const labelList& splitFaces,
const labelPairList& splits const labelPairList& splits,
polyTopoChange& meshMod
) const;
//- Split faces along diagonal. Maintain mesh quality. Return
// total number of faces split.
label splitFacesUndo
(
const labelList& splitFaces,
const labelPairList& splits,
const dictionary& motionDict,
labelList& duplicateFace,
List<labelPair>& baffles
); );
//- Update local numbering for mesh redistribution //- Update local numbering for mesh redistribution
@ -985,6 +1126,16 @@ public:
// Merging coplanar faces and edges // Merging coplanar faces and edges
//- Merge coplanar faces if sets are of size mergeSize
// (usually 4)
label mergePatchFaces
(
const scalar minCos,
const scalar concaveCos,
const label mergeSize,
const labelList& patchIDs
);
//- Merge coplanar faces. preserveFaces is != -1 for faces //- Merge coplanar faces. preserveFaces is != -1 for faces
// to be preserved // to be preserved
label mergePatchFacesUndo label mergePatchFacesUndo

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -34,110 +34,115 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//// Merge faces that are in-line. // Merge faces that are in-line.
//Foam::label Foam::meshRefinement::mergePatchFaces Foam::label Foam::meshRefinement::mergePatchFaces
//( (
// const scalar minCos, const scalar minCos,
// const scalar concaveCos, const scalar concaveCos,
// const labelList& patchIDs const label mergeSize,
//) const labelList& patchIDs
//{ )
// // Patch face merging engine {
// combineFaces faceCombiner(mesh_); // Patch face merging engine
// combineFaces faceCombiner(mesh_, false);
// const polyBoundaryMesh& patches = mesh_.boundaryMesh();
// const polyBoundaryMesh& patches = mesh_.boundaryMesh();
// // Pick up all candidate cells on boundary
// labelHashSet boundaryCells(mesh_.nFaces()-mesh_.nInternalFaces()); // Pick up all candidate cells on boundary
// labelHashSet boundaryCells(mesh_.nFaces()-mesh_.nInternalFaces());
// forAll(patchIDs, i)
// { forAll(patchIDs, i)
// label patchI = patchIDs[i]; {
// label patchI = patchIDs[i];
// const polyPatch& patch = patches[patchI];
// const polyPatch& patch = patches[patchI];
// if (!patch.coupled())
// { if (!patch.coupled())
// forAll(patch, i) {
// { forAll(patch, i)
// boundaryCells.insert(mesh_.faceOwner()[patch.start()+i]); {
// } boundaryCells.insert(mesh_.faceOwner()[patch.start()+i]);
// } }
// } }
// }
// // Get all sets of faces that can be merged
// labelListList mergeSets // Get all sets of faces that can be merged
// ( labelListList mergeSets
// faceCombiner.getMergeSets (
// ( faceCombiner.getMergeSets
// minCos, (
// concaveCos, minCos,
// boundaryCells concaveCos,
// ) boundaryCells
// ); )
// );
// label nFaceSets = returnReduce(mergeSets.size(), sumOp<label>());
// if (mergeSize != -1)
// Info<< "mergePatchFaces : Merging " << nFaceSets {
// << " sets of faces." << endl; // Keep only those that are mergeSize faces
// label compactI = 0;
// if (nFaceSets > 0) forAll(mergeSets, setI)
// { {
// // Topology changes container if (mergeSets[setI].size() == mergeSize)
// polyTopoChange meshMod(mesh_); {
// mergeSets[compactI++] = mergeSets[setI];
// // Merge all faces of a set into the first face of the set. Remove }
// // unused points. }
// faceCombiner.setRefinement(mergeSets, meshMod); mergeSets.setSize(compactI);
// }
// // Change the mesh (no inflation)
// autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh_, false, true);
// label nFaceSets = returnReduce(mergeSets.size(), sumOp<label>());
// // Update fields
// mesh_.updateMesh(map); Info<< "Merging " << nFaceSets << " sets of faces." << nl << endl;
//
// // Move mesh (since morphing does not do this) if (nFaceSets > 0)
// if (map().hasMotionPoints()) {
// { // Topology changes container
// mesh_.movePoints(map().preMotionPoints()); polyTopoChange meshMod(mesh_);
// }
// else // Merge all faces of a set into the first face of the set. Remove
// { // unused points.
// // Delete mesh volumes. No other way to do this? faceCombiner.setRefinement(mergeSets, meshMod);
// mesh_.clearOut();
// } // Change the mesh (no inflation)
// autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh_, false, true);
//
// // Reset the instance for if in overwrite mode // Update fields
// mesh_.setInstance(timeName()); mesh_.updateMesh(map);
//
// faceCombiner.updateMesh(map); // Move mesh (since morphing does not do this)
// if (map().hasMotionPoints())
// // Get the kept faces that need to be recalculated. {
// // Merging two boundary faces might shift the cell centre mesh_.movePoints(map().preMotionPoints());
// // (unless the faces are absolutely planar) }
// labelHashSet retestFaces(6*mergeSets.size()); else
// {
// forAll(mergeSets, setI) // Delete mesh volumes. No other way to do this?
// { mesh_.clearOut();
// label oldMasterI = mergeSets[setI][0]; }
//
// label faceI = map().reverseFaceMap()[oldMasterI]; // Reset the instance for if in overwrite mode
// mesh_.setInstance(timeName());
// // faceI is always uncoupled boundary face
// const cell& cFaces = mesh_.cells()[mesh_.faceOwner()[faceI]]; faceCombiner.updateMesh(map);
//
// forAll(cFaces, i) // Get the kept faces that need to be recalculated.
// { // Merging two boundary faces might shift the cell centre
// retestFaces.insert(cFaces[i]); // (unless the faces are absolutely planar)
// } labelHashSet retestFaces(2*mergeSets.size());
// }
// updateMesh(map, retestFaces.toc()); forAll(mergeSets, setI)
// } {
// label oldMasterI = mergeSets[setI][0];
// retestFaces.insert(map().reverseFaceMap()[oldMasterI]);
// return nFaceSets; }
//} updateMesh(map, growFaceCellFace(retestFaces));
}
return nFaceSets;
}
// //
// //
//// Remove points not used by any face or points used by only two faces where //// Remove points not used by any face or points used by only two faces where

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -341,6 +341,37 @@ Foam::labelList Foam::surfaceZonesInfo::getInsidePointNamedSurfaces
} }
Foam::label Foam::surfaceZonesInfo::addCellZone
(
const word& name,
const labelList& addressing,
polyMesh& mesh
)
{
cellZoneMesh& cellZones = mesh.cellZones();
label zoneI = cellZones.findZoneID(name);
if (zoneI == -1)
{
zoneI = cellZones.size();
cellZones.setSize(zoneI+1);
cellZones.set
(
zoneI,
new cellZone
(
name, // name
addressing, // addressing
zoneI, // index
cellZones // cellZoneMesh
)
);
}
return zoneI;
}
Foam::labelList Foam::surfaceZonesInfo::addCellZonesToMesh Foam::labelList Foam::surfaceZonesInfo::addCellZonesToMesh
( (
const PtrList<surfaceZonesInfo>& surfList, const PtrList<surfaceZonesInfo>& surfList,
@ -350,8 +381,6 @@ Foam::labelList Foam::surfaceZonesInfo::addCellZonesToMesh
{ {
labelList surfaceToCellZone(surfList.size(), -1); labelList surfaceToCellZone(surfList.size(), -1);
cellZoneMesh& cellZones = mesh.cellZones();
forAll(namedSurfaces, i) forAll(namedSurfaces, i)
{ {
label surfI = namedSurfaces[i]; label surfI = namedSurfaces[i];
@ -360,24 +389,12 @@ Foam::labelList Foam::surfaceZonesInfo::addCellZonesToMesh
if (cellZoneName != word::null) if (cellZoneName != word::null)
{ {
label zoneI = cellZones.findZoneID(cellZoneName); label zoneI = addCellZone
(
if (zoneI == -1) cellZoneName,
{ labelList(0), // addressing
zoneI = cellZones.size(); mesh
cellZones.setSize(zoneI+1); );
cellZones.set
(
zoneI,
new cellZone
(
cellZoneName, //name
labelList(0), //addressing
zoneI, //index
cellZones //cellZoneMesh
)
);
}
surfaceToCellZone[surfI] = zoneI; surfaceToCellZone[surfI] = zoneI;
} }
@ -385,7 +402,7 @@ Foam::labelList Foam::surfaceZonesInfo::addCellZonesToMesh
// Check they are synced // Check they are synced
List<wordList> allCellZones(Pstream::nProcs()); List<wordList> allCellZones(Pstream::nProcs());
allCellZones[Pstream::myProcNo()] = cellZones.names(); allCellZones[Pstream::myProcNo()] = mesh.cellZones().names();
Pstream::gatherList(allCellZones); Pstream::gatherList(allCellZones);
Pstream::scatterList(allCellZones); Pstream::scatterList(allCellZones);
@ -409,6 +426,40 @@ Foam::labelList Foam::surfaceZonesInfo::addCellZonesToMesh
} }
Foam::label Foam::surfaceZonesInfo::addFaceZone
(
const word& name,
const labelList& addressing,
const boolList& flipMap,
polyMesh& mesh
)
{
faceZoneMesh& faceZones = mesh.faceZones();
label zoneI = faceZones.findZoneID(name);
if (zoneI == -1)
{
zoneI = faceZones.size();
faceZones.setSize(zoneI+1);
faceZones.set
(
zoneI,
new faceZone
(
name, // name
addressing, // addressing
flipMap, // flipMap
zoneI, // index
faceZones // faceZoneMesh
)
);
}
return zoneI;
}
Foam::labelList Foam::surfaceZonesInfo::addFaceZonesToMesh Foam::labelList Foam::surfaceZonesInfo::addFaceZonesToMesh
( (
const PtrList<surfaceZonesInfo>& surfList, const PtrList<surfaceZonesInfo>& surfList,
@ -426,25 +477,13 @@ Foam::labelList Foam::surfaceZonesInfo::addFaceZonesToMesh
const word& faceZoneName = surfList[surfI].faceZoneName(); const word& faceZoneName = surfList[surfI].faceZoneName();
label zoneI = faceZones.findZoneID(faceZoneName); label zoneI = addFaceZone
(
if (zoneI == -1) faceZoneName, //name
{ labelList(0), //addressing
zoneI = faceZones.size(); boolList(0), //flipmap
faceZones.setSize(zoneI+1); mesh
faceZones.set );
(
zoneI,
new faceZone
(
faceZoneName, //name
labelList(0), //addressing
boolList(0), //flipmap
zoneI, //index
faceZones //faceZoneMesh
)
);
}
surfaceToFaceZone[surfI] = zoneI; surfaceToFaceZone[surfI] = zoneI;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -39,6 +39,7 @@ SourceFiles
#include "word.H" #include "word.H"
#include "PtrList.H" #include "PtrList.H"
#include "labelList.H" #include "labelList.H"
#include "boolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -222,6 +223,13 @@ public:
const PtrList<surfaceZonesInfo>& surfList const PtrList<surfaceZonesInfo>& surfList
); );
static label addCellZone
(
const word& name,
const labelList& addressing,
polyMesh& mesh
);
static labelList addCellZonesToMesh static labelList addCellZonesToMesh
( (
const PtrList<surfaceZonesInfo>& surfList, const PtrList<surfaceZonesInfo>& surfList,
@ -229,6 +237,14 @@ public:
polyMesh& mesh polyMesh& mesh
); );
static label addFaceZone
(
const word& name,
const labelList& addressing,
const boolList& flipMap,
polyMesh& mesh
);
static labelList addFaceZonesToMesh static labelList addFaceZonesToMesh
( (
const PtrList<surfaceZonesInfo>& surfList, const PtrList<surfaceZonesInfo>& surfList,

View File

@ -17,15 +17,11 @@ do
sed "s/XXX/$e/g" constant/transportProperties.template \ sed "s/XXX/$e/g" constant/transportProperties.template \
> constant/transportProperties > constant/transportProperties
runApplication `getApplication` runApplication -l log.boundaryFoam_$e `getApplication`
mv log.boundaryFoam log.boundaryFoam_$e
# extract y+, U+ # extract y+, U+
# note: both must be added to foamLog.db # note: both must be added to foamLog.db
runApplication foamLog log.boundaryFoam_$e runApplication -l log.foamLog_$e foamLog log.boundaryFoam_$e
mv log.foamLog log.foamLog_$e
if [ -e logs/yPlus_0 ] if [ -e logs/yPlus_0 ]
then then

View File

@ -9,45 +9,32 @@ FoamFile
{ {
version 2.0; version 2.0;
format ascii; format ascii;
class polyBoundaryMesh; class volVectorField;
location "constant/polyMesh"; location "0";
object boundary; object U;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
5 dimensions [0 1 -1 0 0 0 0];
(
leftWall internalField uniform (0 0 0);
boundaryField
{
//- Set patchGroups for constraint patches
#include "${WM_PROJECT_DIR}/etc/caseDicts/setConstraintTypes"
wall
{ {
type wall; type uniformFixedValue;
nFaces 50; uniformValue (0 0 0);
startFace 4432;
} }
rightWall upperWall
{ {
type wall; type pressureInletOutletVelocity;
nFaces 50; value uniform (0 0 0);
startFace 4482;
} }
lowerWall }
{
type wall;
nFaces 62;
startFace 4532;
}
atmosphere
{
type patch;
nFaces 46;
startFace 4594;
}
defaultFaces
{
type empty;
inGroups 1(empty);
nFaces 4536;
startFace 4640;
}
)
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,38 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object alpha.water;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0;
boundaryField
{
//- Set patchGroups for constraint patches
#include "${WM_PROJECT_DIR}/etc/caseDicts/setConstraintTypes"
wall
{
type zeroGradient;
}
upperWall
{
type inletOutlet;
inletValue uniform 0;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,46 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p_rgh;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
//- Set patchGroups for constraint patches
#include "${WM_PROJECT_DIR}/etc/caseDicts/setConstraintTypes"
wall
{
type fixedFluxPressure;
phi phiAbs;
value uniform 0;
}
upperWall
{
type totalPressure;
p0 uniform 0;
U U;
phi phi;
rho rho;
psi none;
gamma 1;
value uniform 0;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,15 @@
#!/bin/sh
# Source tutorial clean functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
# remove surface and features
\rm -f constant/triSurface/motorBike.obj.gz > /dev/null 2>&1
\rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1
\rm -f constant/triSurface/motorBike.eMesh > /dev/null 2>&1
rm -rf 0 > /dev/null 2>&1
cleanCase
\rm -f constant/polyMesh/boundary

View File

@ -0,0 +1,15 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
./Allrun.pre
#runApplication `getApplication`
runParallel `getApplication` 5
runApplication reconstructParMesh -latestTime
runApplication reconstructPar -latestTime
# ----------------------------------------------------------------- end-of-file

View File

@ -0,0 +1,27 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
# copy motorbike surface from resources directory
cp $FOAM_TUTORIALS/resources/geometry/motorBike.obj.gz constant/triSurface/
runApplication surfaceFeatureExtract
runApplication blockMesh
#runApplication snappyHexMesh -overwrite
#\rm -f constant/polyMesh/refinementHistory*
# - set the initial fields
#cp -rf 0.org 0
#runApplication setFields
runApplication decomposePar -force -cellDist
runParallel snappyHexMesh 5 -overwrite
ls -d processor* | xargs -i rm -f ./{}/constant/polyMesh/refinementHistory $1
# - set the initial fields
ls -d processor* | xargs -i rm -rf ./{}/0 $1
ls -d processor* | xargs -i cp -r 0.org ./{}/0 $1
runParallel setFields 5

View File

@ -0,0 +1,24 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object RASProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
RASModel kOmegaSST;
turbulence on;
printCoeffs on;
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dynamicFvMesh dynamicRefineFvMesh;
dynamicRefineFvMeshCoeffs
{
// How often to refine
refineInterval 1;
// Field to be refinement on
field alpha.water;
// Refine field inbetween lower..upper
lowerRefineLevel 0.001;
upperRefineLevel 0.999;
// Have slower than 2:1 refinement
nBufferLayers 1;
// Refine cells only up to maxRefinement levels
maxRefinement 3;
// Stop refinement if maxCells reached
maxCells 2000000;
// Flux field and corresponding velocity field. Fluxes on changed
// faces get recalculated by interpolating the velocity. Use 'none'
// on surfaceScalarFields that do not need to be reinterpolated.
correctFluxes
(
(phi none)
(nHatf none)
(rhoPhi none)
(ghf none)
);
// Write the refinement level as a volScalarField
dumpLevel true;
}
// ************************************************************************* //

View File

@ -0,0 +1,22 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class uniformDimensionedVectorField;
location "constant";
object g;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -2 0 0 0 0];
value ( 0 0 -9.81 );
// ************************************************************************* //

View File

@ -0,0 +1,89 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(-1 -0.5 0)
( 3 -0.5 0)
( 3 0.5 0)
(-1 0.5 0)
(-1 -0.5 2)
( 3 -0.5 2)
( 3 0.5 2)
(-1 0.5 2)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (8 2 4) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
walls
{
type wall;
faces
(
(3 7 6 2)
(1 5 4 0)
(0 4 7 3)
(2 6 5 1)
(0 3 2 1)
);
}
// inlet
// {
// type patch;
// faces
// (
// (0 4 7 3)
// );
// }
// outlet
// {
// type patch;
// faces
// (
// (2 6 5 1)
// );
// }
// lowerWall
// {
// type wall;
// faces
// (
// (0 3 2 1)
// );
// }
upperWall
{
type patch;
faces
(
(4 5 6 7)
);
}
);
// ************************************************************************* //

View File

@ -0,0 +1,67 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
phases (water air);
water
{
transportModel Newtonian;
nu nu [ 0 2 -1 0 0 0 0 ] 1e-06;
rho rho [ 1 -3 0 0 0 0 0 ] 1000;
CrossPowerLawCoeffs
{
nu0 nu0 [ 0 2 -1 0 0 0 0 ] 1e-06;
nuInf nuInf [ 0 2 -1 0 0 0 0 ] 1e-06;
m m [ 0 0 1 0 0 0 0 ] 1;
n n [ 0 0 0 0 0 0 0 ] 0;
}
BirdCarreauCoeffs
{
nu0 nu0 [ 0 2 -1 0 0 0 0 ] 0.0142515;
nuInf nuInf [ 0 2 -1 0 0 0 0 ] 1e-06;
k k [ 0 0 1 0 0 0 0 ] 99.6;
n n [ 0 0 0 0 0 0 0 ] 0.1003;
}
}
air
{
transportModel Newtonian;
nu nu [ 0 2 -1 0 0 0 0 ] 1.48e-05;
rho rho [ 1 -3 0 0 0 0 0 ] 1;
CrossPowerLawCoeffs
{
nu0 nu0 [ 0 2 -1 0 0 0 0 ] 1e-06;
nuInf nuInf [ 0 2 -1 0 0 0 0 ] 1e-06;
m m [ 0 0 1 0 0 0 0 ] 1;
n n [ 0 0 0 0 0 0 0 ] 0;
}
BirdCarreauCoeffs
{
nu0 nu0 [ 0 2 -1 0 0 0 0 ] 0.0142515;
nuInf nuInf [ 0 2 -1 0 0 0 0 ] 1e-06;
k k [ 0 0 1 0 0 0 0 ] 99.6;
n n [ 0 0 0 0 0 0 0 ] 0.1003;
}
}
sigma sigma [ 1 0 -2 0 0 0 0 ] 0.07;
// ************************************************************************* //

View File

@ -0,0 +1,4 @@
Directory to house tri-surfaces
The Allrun script copies the surface from the $FOAM_TUTORIALS/resources/geometry
directory

View File

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType laminar;
// ************************************************************************* //

View File

@ -0,0 +1,60 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//DebugSwitches
//{
// dynamicRefineFvMesh 1;
//}
application interDyMFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 2;
deltaT 0.001;
writeControl adjustableRunTime;
writeInterval 0.02;
purgeWrite 0;
writeFormat binary;
writePrecision 6;
writeCompression uncompressed;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
adjustTimeStep yes;
maxCo 0.5;
maxAlphaCo 0.5;
maxDeltaT 1;
// ************************************************************************* //

View File

@ -0,0 +1,42 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 5;
method hierarchical;
// method ptscotch;
simpleCoeffs
{
n (4 1 1);
delta 0.001;
}
hierarchicalCoeffs
{
n (5 1 1);
delta 0.001;
order xyz;
}
manualCoeffs
{
dataFile "cellDecomposition";
}
// ************************************************************************* //

View File

@ -0,0 +1,59 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default Gauss linear;
}
divSchemes
{
div(rhoPhi,U) Gauss upwind;
div(phi,alpha) Gauss vanLeer;
div(phirb,alpha) Gauss linear;
div((muEff*dev(T(grad(U))))) Gauss linear;
}
laplacianSchemes
{
default Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default corrected;
}
fluxRequired
{
default no;
p_rgh;
pcorr;
}
// ************************************************************************* //

View File

@ -0,0 +1,83 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
"alpha.water.*"
{
nAlphaCorr 1;
nAlphaSubCycles 3;
cAlpha 1;
}
p_rgh
{
solver GAMG;
tolerance 1e-7;
relTol 0.01;
smoother DIC;
nPreSweeps 0;
nPostSweeps 2;
nFinestSweeps 2;
cacheAgglomeration false;
nCellsInCoarsestLevel 10;
agglomerator faceAreaPair;
mergeLevels 1;
}
p_rghFinal
{
$p_rgh;
relTol 0;
}
"pcorr.*"
{
$p_rghFinal;
tolerance 0.001;
}
U
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-06;
relTol 0;
nSweeps 1;
}
"(k|B|nuTilda)"
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-08;
relTol 0;
}
}
PIMPLE
{
momentumPredictor no;
nCorrectors 3;
nNonOrthogonalCorrectors 0;
pRefPoint (0.51 0.51 0.51);
pRefValue 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,24 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object meshQualityDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Include defaults parameters from master dictionary
#include "$WM_PROJECT_DIR/etc/caseDicts/meshQualityDict"
//- minFaceWeight (0 -> 0.5)
minFaceWeight 0.02;
// ************************************************************************* //

View File

@ -0,0 +1,38 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object setFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defaultFieldValues
(
volScalarFieldValue alpha.water 0
volVectorFieldValue U ( 0 0 0 )
);
regions
(
boxToCell
{
//box ( -1 -0.5 0 ) ( -0.5 0.5 2 );
box ( -1 -0.5 1.5 ) ( 3 0.5 2 );
fieldValues
(
volScalarFieldValue alpha.water 1
);
}
);
// ************************************************************************* //

View File

@ -0,0 +1,314 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Which of the steps to run
castellatedMesh true;
snap true;
addLayers true;
// Geometry. Definition of all surfaces. All surfaces are of class
// searchableSurface.
// Surfaces are used
// - to specify refinement for any mesh cell intersecting it
// - to specify refinement for any mesh cell inside/outside/near
// - to 'snap' the mesh boundary to the surface
geometry
{
motorBike.obj
{
type triSurfaceMesh;
name motorBike;
}
};
// Optional: avoid patch-face merging. Allows mesh to be used for
// refinement/unrefinement
keepHex true;
// Settings for the castellatedMesh generation.
castellatedMeshControls
{
// Refinement parameters
// ~~~~~~~~~~~~~~~~~~~~~
// If local number of cells is >= maxLocalCells on any processor
// switches from from refinement followed by balancing
// (current method) to (weighted) balancing before refinement.
maxLocalCells 100000;
// Overall cell limit (approximately). Refinement will stop immediately
// upon reaching this number so a refinement level might not complete.
// Note that this is the number of cells before removing the part which
// is not 'visible' from the keepPoint. The final number of cells might
// actually be a lot less.
maxGlobalCells 2000000;
// The surface refinement loop might spend lots of iterations refining just a
// few cells. This setting will cause refinement to stop if <= minimumRefine
// are selected for refinement. Note: it will at least do one iteration
// (unless the number of cells to refine is 0)
minRefinementCells 10;
// Allow a certain level of imbalance during refining
// (since balancing is quite expensive)
// Expressed as fraction of perfect balance (= overall number of cells /
// nProcs). 0=balance always.
maxLoadUnbalance 0.10;
// Number of buffer layers between different levels.
// 1 means normal 2:1 refinement restriction, larger means slower
// refinement.
nCellsBetweenLevels 3;
// Explicit feature edge refinement
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Specifies a level for any cell intersected by its edges.
// This is a featureEdgeMesh, read from constant/triSurface for now.
features
();
// Surface based refinement
// ~~~~~~~~~~~~~~~~~~~~~~~~
// Specifies two levels for every surface. The first is the minimum level,
// every cell intersecting a surface gets refined up to the minimum level.
// The second level is the maximum level. Cells that 'see' multiple
// intersections where the intersections make an
// angle > resolveFeatureAngle get refined up to the maximum level.
refinementSurfaces
{
motorBike
{
// Surface-wise min and max refinement level
level (3 3);
// Optional specification of patch type (default is wall). No
// constraint types (cyclic, symmetry) etc. are allowed.
patchInfo
{
type wall;
inGroups (motorBikeGroup);
}
}
}
// Resolve sharp angles
resolveFeatureAngle 30;
// Region-wise refinement
// ~~~~~~~~~~~~~~~~~~~~~~
// Specifies refinement level for cells in relation to a surface. One of
// three modes
// - distance. 'levels' specifies per distance to the surface the
// wanted refinement level. The distances need to be specified in
// descending order.
// - inside. 'levels' is only one entry and only the level is used. All
// cells inside the surface get refined up to the level. The surface
// needs to be closed for this to be possible.
// - outside. Same but cells outside.
refinementRegions
{
}
// Mesh selection
// ~~~~~~~~~~~~~~
// After refinement patches get added for all refinementSurfaces and
// all cells intersecting the surfaces get put into these patches. The
// section reachable from the locationInMesh is kept.
// NOTE: This point should never be on a face, always inside a cell, even
// after refinement.
locationInMesh (2.991 0.4991 1.991);
// Whether any faceZones (as specified in the refinementSurfaces)
// are only on the boundary of corresponding cellZones or also allow
// free-standing zone faces. Not used if there are no faceZones.
allowFreeStandingZoneFaces true;
}
// Settings for the snapping.
snapControls
{
//- Number of patch smoothing iterations before finding correspondence
// to surface
nSmoothPatch 3;
//- Relative distance for points to be attracted by surface feature point
// or edge. True distance is this factor times local
// maximum edge length.
tolerance 2.0;
//- Number of mesh displacement relaxation iterations.
nSolveIter 30;
//- Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 5;
// Feature snapping
// //- Number of feature edge snapping iterations.
// // Leave out altogether to disable.
// nFeatureSnapIter 10;
//
// //- Detect (geometric only) features by sampling the surface
// // (default=false).
// implicitFeatureSnap false;
//
// //- Use castellatedMeshControls::features (default = true)
// explicitFeatureSnap true;
//
// //- Detect points on multiple surfaces (only for explicitFeatureSnap)
// multiRegionFeatureSnap false;
}
// Settings for the layer addition.
addLayersControls
{
// Are the thickness parameters below relative to the undistorted
// size of the refined cell outside layer (true) or absolute sizes (false).
relativeSizes true;
// Per final patch (so not geometry!) the layer information
layers
{
"motorBike.*"
{
nSurfaceLayers 1;
}
}
// Expansion factor for layer mesh
expansionRatio 1.0;
// Wanted thickness of final added cell layer. If multiple layers
// is the
// thickness of the layer furthest away from the wall.
// Relative to undistorted size of cell outside layer.
// is the thickness of the layer furthest away from the wall.
// See relativeSizes parameter.
finalLayerThickness 0.3;
// Minimum thickness of cell layer. If for any reason layer
// cannot be above minThickness do not add layer.
// Relative to undistorted size of cell outside layer.
minThickness 0.1;
// If points get not extruded do nGrow layers of connected faces that are
// also not grown. This helps convergence of the layer addition process
// close to features.
// Note: changed(corrected) w.r.t 17x! (didn't do anything in 17x)
nGrow 0;
// Advanced settings
// When not to extrude surface. 0 is flat surface, 90 is when two faces
// are perpendicular
featureAngle 60;
// At non-patched sides allow mesh to slip if extrusion direction makes
// angle larger than slipFeatureAngle.
slipFeatureAngle 30;
// Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 3;
// Number of smoothing iterations of surface normals
nSmoothSurfaceNormals 1;
// Number of smoothing iterations of interior mesh movement direction
nSmoothNormals 3;
// Smooth layer thickness over surface patches
nSmoothThickness 10;
// Stop layer growth on highly warped cells
maxFaceThicknessRatio 0.5;
// Reduce layer growth where ratio thickness to medial
// distance is large
maxThicknessToMedialRatio 0.3;
// Angle used to pick up medial axis points
// Note: changed(corrected) w.r.t 17x! 90 degrees corresponds to 130 in 17x.
minMedianAxisAngle 90;
// Create buffer region for new layer terminations
nBufferCellsNoExtrude 0;
// Overall max number of layer addition iterations. The mesher will exit
// if it reaches this number of iterations; possibly with an illegal
// mesh.
nLayerIter 50;
}
// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
#include "meshQualityDict"
// Advanced
//- Number of error distribution iterations
nSmoothScale 4;
//- amount to scale back displacement at error points
errorReduction 0.75;
}
// Advanced
// Write flags
writeFlags
(
layerFields // write volScalarField for layer coverage
);
// Merge tolerance. Is fraction of overall bounding box of initial mesh.
// Note: the write tolerance needs to be higher than this.
mergeTolerance 1e-6;
// ************************************************************************* //

View File

@ -0,0 +1,48 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object surfaceFeatureExtractDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
motorBike.obj
{
// How to obtain raw features (extractFromFile || extractFromSurface)
extractionMethod extractFromSurface;
extractFromSurfaceCoeffs
{
// Mark edges whose adjacent surface normals are at an angle less
// than includedAngle as features
// - 0 : selects no edges
// - 180: selects all edges
includedAngle 150;
}
subsetFeatures
{
// Keep nonManifold edges (edges with >2 connected faces)
nonManifoldEdges no;
// Keep open edges (edges with 1 connected face)
openEdges yes;
}
// Write options
// Write features to obj format for postprocessing
writeObj yes;
}
// ************************************************************************* //