Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
henry
2009-06-09 12:13:17 +01:00
37 changed files with 1461 additions and 197 deletions

View File

@ -292,6 +292,40 @@ Foam::autoHexMeshDriver::autoHexMeshDriver
meshRefinement::checkCoupledFaceZones(mesh_);
// Refinement engine
// ~~~~~~~~~~~~~~~~~
{
Info<< nl
<< "Determining initial surface intersections" << nl
<< "-----------------------------------------" << nl
<< endl;
// Main refinement engine
meshRefinerPtr_.reset
(
new meshRefinement
(
mesh,
mergeDist_, // tolerance used in sorting coordinates
surfaces(),
shells()
)
);
Info<< "Calculated surface intersections in = "
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
// Some stats
meshRefinerPtr_().printMeshInfo(debug_, "Initial mesh");
meshRefinerPtr_().write
(
debug_&meshRefinement::OBJINTERSECTIONS,
mesh_.time().path()/mesh_.time().timeName()
);
}
// Add all the surface regions as patches
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -319,9 +353,8 @@ Foam::autoHexMeshDriver::autoHexMeshDriver
forAll(regNames, i)
{
label patchI = meshRefinement::addPatch
label patchI = meshRefinerPtr_().addMeshedPatch
(
mesh,
regNames[i],
wallPolyPatch::typeName
);
@ -404,40 +437,6 @@ Foam::autoHexMeshDriver::autoHexMeshDriver
// Mesh distribution engine (uses tolerance to reconstruct meshes)
distributorPtr_.reset(new fvMeshDistribute(mesh_, mergeDist_));
}
// Refinement engine
// ~~~~~~~~~~~~~~~~~
{
Info<< nl
<< "Determining initial surface intersections" << nl
<< "-----------------------------------------" << nl
<< endl;
// Main refinement engine
meshRefinerPtr_.reset
(
new meshRefinement
(
mesh,
mergeDist_, // tolerance used in sorting coordinates
surfaces(),
shells()
)
);
Info<< "Calculated surface intersections in = "
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
// Some stats
meshRefinerPtr_().printMeshInfo(debug_, "Initial mesh");
meshRefinerPtr_().write
(
debug_&meshRefinement::OBJINTERSECTIONS,
mesh_.time().path()/mesh_.time().timeName()
);
}
}
@ -522,11 +521,7 @@ void Foam::autoHexMeshDriver::doMesh()
const dictionary& shrinkDict = dict_.subDict("shrinkDict");
PtrList<dictionary> surfaceDicts(dict_.lookup("surfaces"));
autoLayerDriver layerDriver
(
meshRefinerPtr_(),
globalToPatch_
);
autoLayerDriver layerDriver(meshRefinerPtr_());
// Get all the layer specific params
layerParameters layerParams

View File

@ -75,7 +75,7 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
labelHashSet boundaryCells(mesh.nFaces()-mesh.nInternalFaces());
{
labelList patchIDs(meshRefinement::addedPatches(globalToPatch_));
labelList patchIDs(meshRefiner_.meshedPatches());
const polyBoundaryMesh& patches = mesh.boundaryMesh();
@ -2446,14 +2446,9 @@ void Foam::autoLayerDriver::getLayerCellsFaces
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::autoLayerDriver::autoLayerDriver
(
meshRefinement& meshRefiner,
const labelList& globalToPatch
)
Foam::autoLayerDriver::autoLayerDriver(meshRefinement& meshRefiner)
:
meshRefiner_(meshRefiner),
globalToPatch_(globalToPatch)
meshRefiner_(meshRefiner)
{}

View File

@ -101,9 +101,6 @@ class autoLayerDriver
//- Mesh+surface
meshRefinement& meshRefiner_;
//- From surface region to patch
const labelList globalToPatch_;
// Private Member Functions
@ -509,11 +506,7 @@ public:
// Constructors
//- Construct from components
autoLayerDriver
(
meshRefinement& meshRefiner,
const labelList& globalToPatch
);
autoLayerDriver(meshRefinement& meshRefiner);
// Member Functions

View File

@ -680,7 +680,7 @@ void Foam::autoRefineDriver::mergePatchFaces
(
Foam::cos(45*mathematicalConstant::pi/180.0),
Foam::cos(45*mathematicalConstant::pi/180.0),
meshRefinement::addedPatches(globalToPatch_)
meshRefiner_.meshedPatches()
);
if (debug)

View File

@ -830,35 +830,6 @@ Foam::scalarField Foam::autoSnapDriver::calcSnapDistance
}
//// Invert globalToPatch_ to get the patches related to surfaces.
//Foam::labelList Foam::autoSnapDriver::getSurfacePatches() const
//{
// // Set of patches originating from surface
// labelHashSet surfacePatchSet(globalToPatch_.size());
//
// forAll(globalToPatch_, i)
// {
// if (globalToPatch_[i] != -1)
// {
// surfacePatchSet.insert(globalToPatch_[i]);
// }
// }
//
// const fvMesh& mesh = meshRefiner_.mesh();
//
// DynamicList<label> surfacePatches(surfacePatchSet.size());
//
// for (label patchI = 0; patchI < mesh.boundaryMesh().size(); patchI++)
// {
// if (surfacePatchSet.found(patchI))
// {
// surfacePatches.append(patchI);
// }
// }
// return surfacePatches.shrink();
//}
void Foam::autoSnapDriver::preSmoothPatch
(
const snapParameters& snapParams,
@ -1479,7 +1450,7 @@ void Foam::autoSnapDriver::doSnap
const_cast<Time&>(mesh.time())++;
// Get the labels of added patches.
labelList adaptPatchIDs(meshRefinement::addedPatches(globalToPatch_));
labelList adaptPatchIDs(meshRefiner_.meshedPatches());
// Create baffles (pairs of faces that share the same points)
// Baffles stored as owner and neighbour face that have been created.

View File

@ -170,9 +170,6 @@ public:
const indirectPrimitivePatch&
) const;
////- Get patches generated for surfaces.
//labelList getSurfacePatches() const;
//- Smooth the mesh (patch and internal) to increase visibility
// of surface points (on castellated mesh) w.r.t. surface.
void preSmoothPatch

View File

@ -84,12 +84,15 @@ void Foam::meshRefinement::calcNeighbourData
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
labelHashSet addedPatchIDSet(meshedPatches());
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
const unallocLabelList& faceCells = pp.faceCells();
const vectorField::subField faceCentres = pp.faceCentres();
const vectorField::subField faceAreas = pp.faceAreas();
label bFaceI = pp.start()-mesh_.nInternalFaces();
@ -102,6 +105,36 @@ void Foam::meshRefinement::calcNeighbourData
bFaceI++;
}
}
else if (addedPatchIDSet.found(patchI))
{
// Face was introduced from cell-cell intersection. Try to
// reconstruct other side cell(centre). Three possibilities:
// - cells same size.
// - preserved cell smaller. Not handled.
// - preserved cell larger.
forAll(faceCells, i)
{
// Extrapolate the face centre.
vector fn = faceAreas[i];
fn /= mag(fn)+VSMALL;
label own = faceCells[i];
label ownLevel = cellLevel[own];
label faceLevel = meshCutter_.getAnchorLevel(pp.start()+i);
// Normal distance from face centre to cell centre
scalar d = ((faceCentres[i] - cellCentres[own]) & fn);
if (faceLevel > ownLevel)
{
// Other cell more refined. Adjust normal distance
d *= 0.5;
}
neiLevel[bFaceI] = cellLevel[ownLevel];
// Calculate other cell centre by extrapolation
neiCc[bFaceI] = faceCentres[i] + d*fn;
bFaceI++;
}
}
else
{
forAll(faceCells, i)
@ -1195,7 +1228,6 @@ Foam::labelList Foam::meshRefinement::intersectedFaces() const
// Helper function to get points used by faces
Foam::labelList Foam::meshRefinement::intersectedPoints
(
// const labelList& globalToPatch
) const
{
const faceList& faces = mesh_.faces();
@ -1221,9 +1253,10 @@ Foam::labelList Foam::meshRefinement::intersectedPoints
}
//// Insert all meshed patches.
//forAll(globalToPatch, i)
//labelList adaptPatchIDs(meshedPatches());
//forAll(adaptPatchIDs, i)
//{
// label patchI = globalToPatch[i];
// label patchI = adaptPatchIDs[i];
//
// if (patchI != -1)
// {
@ -1262,27 +1295,6 @@ Foam::labelList Foam::meshRefinement::intersectedPoints
}
Foam::labelList Foam::meshRefinement::addedPatches
(
const labelList& globalToPatch
)
{
labelList patchIDs(globalToPatch.size());
label addedI = 0;
forAll(globalToPatch, i)
{
if (globalToPatch[i] != -1)
{
patchIDs[addedI++] = globalToPatch[i];
}
}
patchIDs.setSize(addedI);
return patchIDs;
}
//- Create patch from set of patches
Foam::autoPtr<Foam::indirectPrimitivePatch> Foam::meshRefinement::makePatch
(
@ -1653,6 +1665,53 @@ Foam::label Foam::meshRefinement::addPatch
}
Foam::label Foam::meshRefinement::addMeshedPatch
(
const word& name,
const word& type
)
{
label meshedI = findIndex(meshedPatches_, name);
if (meshedI != -1)
{
// Already there. Get corresponding polypatch
return mesh_.boundaryMesh().findPatchID(name);
}
else
{
// Add patch
label patchI = addPatch(mesh_, name, type);
// Store
label sz = meshedPatches_.size();
meshedPatches_.setSize(sz+1);
meshedPatches_[sz] = name;
return patchI;
}
}
Foam::labelList Foam::meshRefinement::meshedPatches() const
{
labelList patchIDs(meshedPatches_.size());
forAll(meshedPatches_, i)
{
patchIDs[i] = mesh_.boundaryMesh().findPatchID(meshedPatches_[i]);
if (patchIDs[i] == -1)
{
FatalErrorIn("meshRefinement::meshedPatches() const")
<< "Problem : did not find patch " << meshedPatches_[i]
<< abort(FatalError);
}
}
return patchIDs;
}
Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMeshRegions
(
const point& keepPoint

View File

@ -125,6 +125,10 @@ private:
//- user supplied face based data.
List<Tuple2<mapType, labelList> > userFaceData_;
//- Meshed patches - are treated differently. Stored as wordList since
// order changes.
wordList meshedPatches_;
// Private Member Functions
@ -400,12 +404,11 @@ private:
const labelList& globalToPatch
) const;
//- Initial test of marking faces using geometric information.
labelList markFacesOnProblemCellsGeometric
(
const dictionary& motionDict,
const labelList& globalToPatch
) const;
////- Initial test of marking faces using geometric information.
//labelList markFacesOnProblemCellsGeometric
//(
// const dictionary& motionDict
//) const;
// Baffle merging
@ -578,9 +581,6 @@ public:
//- Get points on surfaces with intersection and boundary faces.
labelList intersectedPoints() const;
//- Get added patches (inverse of globalToPatch)
static labelList addedPatches(const labelList& globalToPatch);
//- Create patch from set of patches
static autoPtr<indirectPrimitivePatch> makePatch
(
@ -688,9 +688,16 @@ public:
// Other topo changes
//- Helper function to add patch to mesh
//- Helper:add patch to mesh. Update all registered fields.
// Use addMeshedPatch to add patches originating from surfaces.
static label addPatch(fvMesh&, const word& name, const word& type);
//- Add patch originating from meshing. Update meshedPatches_.
label addMeshedPatch(const word& name, const word& type);
//- Get patchIDs for patches added in addMeshedPatch.
labelList meshedPatches() const;
//- Split mesh. Keep part containing point.
autoPtr<mapPolyMesh> splitMeshRegions(const point& keepPoint);
@ -699,7 +706,11 @@ public:
//- Update for external change to mesh. changedFaces are in new mesh
// face labels.
void updateMesh(const mapPolyMesh&, const labelList& changedFaces);
void updateMesh
(
const mapPolyMesh&,
const labelList& changedFaces
);
// Restoring : is where other processes delete and reinsert data.

View File

@ -1511,11 +1511,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
perpendicularAngle,
globalToPatch
)
//markFacesOnProblemCellsGeometric
//(
// motionDict,
// globalToPatch
//)
//markFacesOnProblemCellsGeometric(motionDict)
);
Info<< "Analyzed problem cells in = "
<< runTime.cpuTimeIncrement() << " s\n" << nl << endl;
@ -1665,7 +1661,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
// Split off (with optional buffer layers) unreachable areas of mesh.
Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
(
const label nBufferLayers,
const labelList& globalToPatch,

View File

@ -136,15 +136,13 @@ Foam::Map<Foam::label> Foam::meshRefinement::findEdgeConnectedProblemCells
const labelList& globalToPatch
) const
{
labelList adaptPatchIDs(meshRefinement::addedPatches(globalToPatch));
// Construct addressing engine.
// Construct addressing engine from all patches added for meshing.
autoPtr<indirectPrimitivePatch> ppPtr
(
meshRefinement::makePatch
(
mesh_,
adaptPatchIDs
meshedPatches()
)
);
const indirectPrimitivePatch& pp = ppPtr();
@ -386,11 +384,6 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
const labelList& pointLevel = meshCutter_.pointLevel();
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
// Swap neighbouring cell centres and cell level
labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
calcNeighbourData(neiLevel, neiCc);
// Per internal face (boundary faces not used) the patch that the
// baffle should get (or -1)
labelList facePatch(mesh_.nFaces(), -1);
@ -403,7 +396,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
// Fill boundary data. All elements on meshed patches get marked.
// Get the labels of added patches.
labelList adaptPatchIDs(meshRefinement::addedPatches(globalToPatch));
labelList adaptPatchIDs(meshedPatches());
forAll(adaptPatchIDs, i)
{
@ -427,6 +420,12 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
}
}
// Swap neighbouring cell centres and cell level
labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
calcNeighbourData(neiLevel, neiCc);
// Count of faces marked for baffling
label nBaffleFaces = 0;
@ -961,20 +960,16 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
//// test to find nearest surface and checks which faces would get squashed.
//Foam::labelList Foam::meshRefinement::markFacesOnProblemCellsGeometric
//(
// const dictionary& motionDict,
// const labelList& globalToPatch
// const dictionary& motionDict
//) const
//{
// // Get the labels of added patches.
// labelList adaptPatchIDs(meshRefinement::addedPatches(globalToPatch));
//
// // Construct addressing engine.
// autoPtr<indirectPrimitivePatch> ppPtr
// (
// meshRefinement::makePatch
// (
// mesh_,
// adaptPatchIDs
// meshedPatches()
// )
// );
// const indirectPrimitivePatch& pp = ppPtr();

View File

@ -185,8 +185,6 @@ class hexRef8
const bool searchForward,
const label wantedLevel
) const;
//- Gets level such that the face has four points <= level.
label getAnchorLevel(const label faceI) const;
////- Print levels of list of points.
//void printLevels(Ostream&, const labelList&) const;
@ -370,6 +368,9 @@ public:
// Refinement
//- Gets level such that the face has four points <= level.
label getAnchorLevel(const label faceI) const;
//- Given valid mesh and current cell level and proposed
// cells to refine calculate any clashes (due to 2:1) and return
// ok list of cells to refine.

View File

@ -44,6 +44,7 @@ License
#include "leastSquaresVectors.H"
#include "CentredFitData.H"
#include "linearFitPolynomial.H"
#include "quadraticFitPolynomial.H"
#include "quadraticLinearFitPolynomial.H"
#include "skewCorrectionVectors.H"
@ -92,11 +93,12 @@ void Foam::fvMesh::clearGeom()
// Things geometry dependent that are not updated.
volPointInterpolation::Delete(*this);
extendedLeastSquaresVectors::Delete(*this);
extendedLeastSquaresVectors::Delete(*this);
leastSquaresVectors::Delete(*this);
CentredFitData<linearFitPolynomial>::Delete(*this);
CentredFitData<quadraticFitPolynomial>::Delete(*this);
CentredFitData<quadraticLinearFitPolynomial>::Delete(*this);
skewCorrectionVectors::Delete(*this);
quadraticFitSnGradData::Delete(*this);
}
@ -108,16 +110,18 @@ void Foam::fvMesh::clearAddressing()
volPointInterpolation::Delete(*this);
extendedLeastSquaresVectors::Delete(*this);
extendedLeastSquaresVectors::Delete(*this);
leastSquaresVectors::Delete(*this);
CentredFitData<linearFitPolynomial>::Delete(*this);
CentredFitData<quadraticFitPolynomial>::Delete(*this);
CentredFitData<quadraticLinearFitPolynomial>::Delete(*this);
skewCorrectionVectors::Delete(*this);
quadraticFitSnGradData::Delete(*this);
centredCECCellToFaceStencilObject::Delete(*this);
centredCFCCellToFaceStencilObject::Delete(*this);
centredCPCCellToFaceStencilObject::Delete(*this);
centredFECCellToFaceStencilObject::Delete(*this);
// Is this geometry related - cells distorting to upwind direction?
upwindCECCellToFaceStencilObject::Delete(*this);
upwindCFCCellToFaceStencilObject::Delete(*this);
upwindCPCCellToFaceStencilObject::Delete(*this);
@ -597,8 +601,10 @@ Foam::tmp<Foam::scalarField> Foam::fvMesh::movePoints(const pointField& p)
MeshObjectMovePoints<extendedLeastSquaresVectors>(*this);
MeshObjectMovePoints<leastSquaresVectors>(*this);
MeshObjectMovePoints<CentredFitData<linearFitPolynomial> >(*this);
MeshObjectMovePoints<CentredFitData<quadraticFitPolynomial> >(*this);
MeshObjectMovePoints<CentredFitData<quadraticLinearFitPolynomial> >(*this);
MeshObjectMovePoints<skewCorrectionVectors>(*this);
MeshObjectMovePoints<quadraticFitSnGradData>(*this);
return tsweptVols;
}