Merge branch 'master' into cvm

Conflicts:
	applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C
This commit is contained in:
graham
2011-04-07 14:17:08 +01:00
321 changed files with 50704 additions and 1776 deletions

View File

@ -2,11 +2,11 @@
// checkTimeOptions.H
// ~~~~~~~~~~~~~~~~~~
Foam::label startTime = 0;
Foam::label endTime = Times.size();
Foam::label startTime = 0;
Foam::label endTime = Times.size();
// unless -constant is present, skip startTime if it is "constant"
# include "checkConstantOption.H"
#include "checkConstantOption.H"
// check -time and -latestTime options
# include "checkTimeOption.H"
#include "checkTimeOption.H"

View File

@ -24,9 +24,10 @@ License
\*---------------------------------------------------------------------------*/
#include "primitiveMesh.H"
#include "indexedOctree.H"
#include "treeDataCell.H"
#include "demandDrivenData.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::primitiveMesh::printAllocated() const

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -51,7 +51,6 @@ void Foam::ignitionSite::findIgnitionCells(const fvMesh& mesh)
cellVolumes_[0] = vols[ignCell];
scalar minDist = GREAT;
label nearestCell = 0;
label nIgnCells = 1;
forAll(centres, celli)
@ -60,7 +59,6 @@ void Foam::ignitionSite::findIgnitionCells(const fvMesh& mesh)
if (dist < minDist)
{
nearestCell = celli;
minDist = dist;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -445,6 +445,13 @@ void Foam::porousZone::writeDict(Ostream& os, bool subDict) const
dictPtr->write(os);
}
// thermalModel
if (const dictionary* dictPtr = dict_.subDictPtr("thermalModel"))
{
os << indent << "thermalModel";
dictPtr->write(os);
}
os << decrIndent << indent << token::END_BLOCK << endl;
}

View File

@ -39,8 +39,10 @@ correction
{
const fvMesh& mesh = this->mesh();
GeometricField<Type, pointPatchField, pointMesh> pvf =
volPointInterpolation::New(mesh).interpolate(vf);
GeometricField<Type, pointPatchField, pointMesh> pvf
(
volPointInterpolation::New(mesh).interpolate(vf)
);
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr =
linearInterpolate(vf);

View File

@ -651,8 +651,6 @@ void Foam::InteractionLists<ParticleType>::findExtendedProcBbsInRange
{
List<label> permutationIndices(nTrans, 0);
vector s = vector::zero;
if (nTrans == 0 && procI != Pstream::myProcNo())
{
treeBoundBox extendedReferredProcBb = allExtendedProcBbs[procI];

View File

@ -32,6 +32,8 @@ Foam::label Foam::particle::particleCount_ = 0;
const Foam::scalar Foam::particle::trackingCorrectionTol = 1e-5;
const Foam::scalar Foam::particle::lambdaDistanceToleranceCoeff = 1e3*SMALL;
namespace Foam
{
defineTypeNameAndDebug(particle, 0);

View File

@ -164,7 +164,8 @@ protected:
DynamicList<label>& faceList,
const tetPointRef& tet,
const FixedList<vector, 4>& tetAreas,
const FixedList<label, 4>& tetPlaneBasePtIs
const FixedList<label, 4>& tetPlaneBasePtIs,
const scalar tol
) const;
//- Find the lambda value for the line to-from across the
@ -178,7 +179,8 @@ protected:
const label tetPlaneBasePtI,
const label cellI,
const label tetFaceI,
const label tetPtI
const label tetPtI,
const scalar tol
) const;
//- Find the lambda value for a moving tri face
@ -191,7 +193,8 @@ protected:
const label tetPlaneBasePtI,
const label cellI,
const label tetFaceI,
const label tetPtI
const label tetPtI,
const scalar tol
) const;
//- Modify the tet owner data by crossing triI
@ -291,6 +294,10 @@ public:
// 'rescue' it from a tracking problem
static const scalar trackingCorrectionTol;
//- Fraction of the cell volume to use in determining tolerance values
// for the denominator and numerator of lambda
static const scalar lambdaDistanceToleranceCoeff;
// Constructors

View File

@ -34,7 +34,8 @@ inline void Foam::particle::findTris
DynamicList<label>& faceList,
const tetPointRef& tet,
const FixedList<vector, 4>& tetAreas,
const FixedList<label, 4>& tetPlaneBasePtIs
const FixedList<label, 4>& tetPlaneBasePtIs,
const scalar tol
) const
{
faceList.clear();
@ -52,7 +53,8 @@ inline void Foam::particle::findTris
tetPlaneBasePtIs[i],
cellI_,
tetFaceI_,
tetPtI_
tetPtI_,
tol
);
if ((lambda > 0.0) && (lambda < 1.0))
@ -72,7 +74,8 @@ inline Foam::scalar Foam::particle::tetLambda
const label tetPlaneBasePtI,
const label cellI,
const label tetFaceI,
const label tetPtI
const label tetPtI,
const scalar tol
) const
{
const pointField& pPts = mesh_.points();
@ -88,7 +91,8 @@ inline Foam::scalar Foam::particle::tetLambda
tetPlaneBasePtI,
cellI,
tetFaceI,
tetPtI
tetPtI,
tol
);
}
@ -97,12 +101,17 @@ inline Foam::scalar Foam::particle::tetLambda
scalar lambdaNumerator = (base - from) & n;
scalar lambdaDenominator = (to - from) & n;
if (mag(lambdaDenominator) < SMALL)
// n carries the area of the tet faces, so the dot product with a
// delta-length has the units of volume. Comparing the component of each
// delta-length in the direction of n times the face area to a fraction of
// the cell volume.
if (mag(lambdaDenominator) < tol)
{
if (mag(lambdaNumerator) < SMALL)
if (mag(lambdaNumerator) < tol)
{
// Track starts on the face, and is potentially
// parallel to it. +-SMALL/+-SMALL is not a good
// parallel to it. +-tol/+-tol is not a good
// comparison, return 0.0, in anticipation of tet
// centre correction.
@ -110,10 +119,11 @@ inline Foam::scalar Foam::particle::tetLambda
}
else
{
if (mag((to - from)) < SMALL)
if (mag((to - from)) < tol/mag(n))
{
// Zero length track, not along the face, face
// cannot be crossed.
// 'Zero' length track (compared to the tolerance, which is
// based on the cell volume, divided by the tet face area), not
// along the face, face cannot be crossed.
return GREAT;
}
@ -139,7 +149,8 @@ inline Foam::scalar Foam::particle::movingTetLambda
const label tetPlaneBasePtI,
const label cellI,
const label tetFaceI,
const label tetPtI
const label tetPtI,
const scalar tol
) const
{
const pointField& pPts = mesh_.points();
@ -291,12 +302,12 @@ inline Foam::scalar Foam::particle::movingTetLambda
}
if (mag(lambdaDenominator) < SMALL)
if (mag(lambdaDenominator) < tol)
{
if (mag(lambdaNumerator) < SMALL)
if (mag(lambdaNumerator) < tol)
{
// Track starts on the face, and is potentially
// parallel to it. +-SMALL)/+-SMALL is not a good
// parallel to it. +-tol)/+-tol is not a good
// comparison, return 0.0, in anticipation of tet
// centre correction.
@ -304,7 +315,7 @@ inline Foam::scalar Foam::particle::movingTetLambda
}
else
{
if (mag((to - from)) < SMALL)
if (mag((to - from)) < tol/mag(n))
{
// Zero length track, not along the face, face
// cannot be crossed.

View File

@ -30,6 +30,7 @@ License
#include "symmetryPolyPatch.H"
#include "wallPolyPatch.H"
#include "wedgePolyPatch.H"
#include "meshTools.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -285,6 +286,11 @@ Foam::scalar Foam::particle::trackToFace
// be a different tet to the one that the particle occupies.
tetIndices faceHitTetIs;
// What tolerance is appropriate the minimum lambda numerator and
// denominator for tracking in this cell.
scalar lambdaDistanceTolerance =
lambdaDistanceToleranceCoeff*mesh_.cellVolumes()[cellI_];
do
{
if (triI != -1)
@ -370,7 +376,15 @@ Foam::scalar Foam::particle::trackToFace
tetPlaneBasePtIs[2] = basePtI;
tetPlaneBasePtIs[3] = basePtI;
findTris(endPosition, tris, tet, tetAreas, tetPlaneBasePtIs);
findTris
(
endPosition,
tris,
tet,
tetAreas,
tetPlaneBasePtIs,
lambdaDistanceTolerance
);
// Reset variables for new track
triI = -1;
@ -414,7 +428,8 @@ Foam::scalar Foam::particle::trackToFace
tetPlaneBasePtIs[tI],
cellI_,
tetFaceI_,
tetPtI_
tetPtI_,
lambdaDistanceTolerance
);
if (lam < lambdaMin)
@ -463,7 +478,7 @@ Foam::scalar Foam::particle::trackToFace
// << origId_ << " " << origProc_<< nl
// << "# face: " << tetFaceI_ << nl
// << "# tetPtI: " << tetPtI_ << nl
// << "# tetBasePtI: " << mesh.tetBasePtIs()[tetFaceI_] << nl
// << "# tetBasePtI: " << mesh_.tetBasePtIs()[tetFaceI_] << nl
// << "# tet.mag(): " << tet.mag() << nl
// << "# tet.quality(): " << tet.quality()
// << endl;
@ -703,6 +718,9 @@ void Foam::particle::hitWallFaces
const Foam::cell& thisCell = mesh_.cells()[cellI_];
scalar lambdaDistanceTolerance =
lambdaDistanceToleranceCoeff*mesh_.cellVolumes()[cellI_];
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
forAll(thisCell, cFI)
@ -754,7 +772,8 @@ void Foam::particle::hitWallFaces
f[tetIs.faceBasePt()],
cellI_,
fI,
tetIs.tetPt()
tetIs.tetPt(),
lambdaDistanceTolerance
);
if ((tetClambda <= 0.0) || (tetClambda >= 1.0))
@ -780,7 +799,8 @@ void Foam::particle::hitWallFaces
f[tetIs.faceBasePt()],
cellI_,
fI,
tetIs.tetPt()
tetIs.tetPt(),
lambdaDistanceTolerance
);
pointHit hitInfo(vector::zero);

View File

@ -440,7 +440,6 @@ void Foam::parcel::updateParcelProperties
scalar oldhv = fuels.hl(pg, T(), X());
scalar Np = N(oldDensity);
scalar newDensity = oldDensity;
scalar newMass = oldMass;
scalar newhg = oldhg;
scalar newhv = oldhv;
@ -460,7 +459,6 @@ void Foam::parcel::updateParcelProperties
// first time
if (n > 1)
{
newDensity = fuels.rho(pg, Tnew, X());
newMass = m();
newhg = 0.0;
scalarField Ynew(fuels.Y(X()));

View File

@ -112,11 +112,10 @@ void Foam::LISA::atomizeParcel
vector uDir = p.U()/mag(p.U());
scalar uGas = mag(vel & uDir);
vector Ug = uGas*uDir;
// Might be the relative velocity between Liquid and Gas, but using the
// absolute velocity of the parcel as suggested by the authors
// scalar U = mag(p.Urel(vel));
// scalar U = mag(p.Urel(vel));
scalar U = mag(p.U());
p.ct() += deltaT;

View File

@ -118,9 +118,6 @@ void Foam::SHF::breakupParcel
scalar reLiquid = p.Re(rhoLiquid, vel, muLiquid);
scalar ohnesorge = sqrt(weLiquid)/(reLiquid + VSMALL);
vector acceleration = p.Urel(vel)/p.tMom();
vector trajectory = p.U()/mag(p.U());
vector vRel = p.Urel(vel);
scalar weGasCorr = weGas/(1.0 + weCorrCoeff_*ohnesorge);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -246,9 +246,6 @@ void Foam::blobsSwirlInjector::calculateHX
)
);
scalar hOLD = -100.0;
scalar xOLD = -100.0;
label i;
for (i=0; i<20; i++)
@ -267,10 +264,6 @@ void Foam::blobsSwirlInjector::calculateHX
);
x_ = sqr(1.0 - 2.0*h_/injectorDiameter);
hOLD = h_;
xOLD = x_;
}
x_ = sqr(1.0 - 2.0*h_/injectorDiameter);

View File

@ -607,11 +607,16 @@ void Foam::InjectionModel<CloudType>::inject(TrackData& td)
pPtr->rho()
);
// Add the new parcel
td.cloud().addParticle(pPtr);
massAdded += pPtr->nParticle()*pPtr->mass();
parcelsAdded++;
if (pPtr->move(td, dt))
{
td.cloud().addParticle(pPtr);
massAdded += pPtr->nParticle()*pPtr->mass();
parcelsAdded++;
}
else
{
delete pPtr;
}
}
}
}

View File

@ -163,13 +163,14 @@ void Foam::NonInertialFrameForce<CloudType>::cacheFields(const bool store)
)
)
{
uniformDimensionedVectorField omegaDot = this->mesh().template
uniformDimensionedVectorField centreOfRotation =
this->mesh().template
lookupObject<uniformDimensionedVectorField>
(
centreOfRotationName_
);
centreOfRotation_ = omegaDot.value();
centreOfRotation_ = centreOfRotation.value();
}
}
}
@ -187,7 +188,7 @@ Foam::forceSuSp Foam::NonInertialFrameForce<CloudType>::calcNonCoupled
{
forceSuSp value(vector::zero, 0.0);
const vector& r = p.position() - centreOfRotation_;
const vector r = p.position() - centreOfRotation_;
value.Su() =
mass

View File

@ -4,6 +4,7 @@ autoHexMeshDriver = $(autoHexMesh)/autoHexMeshDriver
$(autoHexMeshDriver)/autoLayerDriver.C
$(autoHexMeshDriver)/autoLayerDriverShrink.C
$(autoHexMeshDriver)/autoSnapDriver.C
$(autoHexMeshDriver)/autoSnapDriverFeature.C
$(autoHexMeshDriver)/autoRefineDriver.C
$(autoHexMeshDriver)/layerParameters/layerParameters.C
@ -16,6 +17,7 @@ $(autoHexMesh)/meshRefinement/meshRefinement.C
$(autoHexMesh)/meshRefinement/meshRefinementMerge.C
$(autoHexMesh)/meshRefinement/meshRefinementProblemCells.C
$(autoHexMesh)/meshRefinement/meshRefinementRefine.C
$(autoHexMesh)/refinementFeatures/refinementFeatures.C
$(autoHexMesh)/refinementSurfaces/refinementSurfaces.C
$(autoHexMesh)/shellSurfaces/shellSurfaces.C
$(autoHexMesh)/trackedParticle/trackedParticle.C

View File

@ -59,622 +59,6 @@ defineTypeNameAndDebug(autoLayerDriver, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
(
const scalar minCos,
const scalar concaveCos,
const dictionary& motionDict
)
{
fvMesh& mesh = meshRefiner_.mesh();
// Patch face merging engine
combineFaces faceCombiner(mesh, true);
// Pick up all candidate cells on boundary
labelHashSet boundaryCells(mesh.nFaces()-mesh.nInternalFaces());
{
labelList patchIDs(meshRefiner_.meshedPatches());
const polyBoundaryMesh& patches = mesh.boundaryMesh();
forAll(patchIDs, i)
{
label patchI = patchIDs[i];
const polyPatch& patch = patches[patchI];
if (!patch.coupled())
{
forAll(patch, i)
{
boundaryCells.insert(mesh.faceOwner()[patch.start()+i]);
}
}
}
}
// Get all sets of faces that can be merged
labelListList allFaceSets
(
faceCombiner.getMergeSets
(
minCos,
concaveCos,
boundaryCells
)
);
label nFaceSets = returnReduce(allFaceSets.size(), sumOp<label>());
Info<< "Merging " << nFaceSets << " sets of faces." << nl << endl;
if (nFaceSets > 0)
{
if (debug)
{
faceSet allSets(mesh, "allFaceSets", allFaceSets.size());
forAll(allFaceSets, setI)
{
forAll(allFaceSets[setI], i)
{
allSets.insert(allFaceSets[setI][i]);
}
}
Pout<< "Writing all faces to be merged to set "
<< allSets.objectPath() << endl;
allSets.instance() = mesh.time().timeName();
allSets.write();
}
// Topology changes container
polyTopoChange meshMod(mesh);
// Merge all faces of a set into the first face of the set.
faceCombiner.setRefinement(allFaceSets, meshMod);
// Experimental: store data for all the points that have been deleted
meshRefiner_.storeData
(
faceCombiner.savedPointLabels(), // points to store
labelList(0), // faces to store
labelList(0) // cells to store
);
// Change the mesh (no inflation)
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false, true);
// Update fields
mesh.updateMesh(map);
// Move mesh (since morphing does not do this)
if (map().hasMotionPoints())
{
mesh.movePoints(map().preMotionPoints());
}
else
{
// Delete mesh volumes.
mesh.clearOut();
}
faceCombiner.updateMesh(map);
meshRefiner_.updateMesh(map, labelList(0));
for (label iteration = 0; iteration < 100; iteration++)
{
Info<< nl
<< "Undo iteration " << iteration << nl
<< "----------------" << endl;
// Check mesh for errors
// ~~~~~~~~~~~~~~~~~~~~~
faceSet errorFaces
(
mesh,
"errorFaces",
mesh.nFaces()-mesh.nInternalFaces()
);
bool hasErrors = motionSmoother::checkMesh
(
false, // report
mesh,
motionDict,
errorFaces
);
//if (checkEdgeConnectivity)
//{
// Info<< "Checking edge-face connectivity (duplicate faces"
// << " or non-consecutive shared vertices)" << endl;
//
// label nOldSize = errorFaces.size();
//
// hasErrors =
// mesh.checkFaceFaces
// (
// false,
// &errorFaces
// )
// || hasErrors;
//
// Info<< "Detected additional "
// << returnReduce
// (
// errorFaces.size() - nOldSize,
// sumOp<label>()
// )
// << " faces with illegal face-face connectivity"
// << endl;
//}
if (!hasErrors)
{
break;
}
if (debug)
{
errorFaces.instance() = mesh.time().timeName();
Pout<< "Writing all faces in error to faceSet "
<< errorFaces.objectPath() << nl << endl;
errorFaces.write();
}
// Check any master cells for using any of the error faces
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DynamicList<label> mastersToRestore(allFaceSets.size());
forAll(allFaceSets, setI)
{
label masterFaceI = faceCombiner.masterFace()[setI];
if (masterFaceI != -1)
{
label masterCellII = mesh.faceOwner()[masterFaceI];
const cell& cFaces = mesh.cells()[masterCellII];
forAll(cFaces, i)
{
if (errorFaces.found(cFaces[i]))
{
mastersToRestore.append(masterFaceI);
break;
}
}
}
}
mastersToRestore.shrink();
label nRestore = returnReduce
(
mastersToRestore.size(),
sumOp<label>()
);
Info<< "Masters that need to be restored:"
<< nRestore << endl;
if (debug)
{
faceSet restoreSet(mesh, "mastersToRestore", mastersToRestore);
restoreSet.instance() = mesh.time().timeName();
Pout<< "Writing all " << mastersToRestore.size()
<< " masterfaces to be restored to set "
<< restoreSet.objectPath() << endl;
restoreSet.write();
}
if (nRestore == 0)
{
break;
}
// Undo
// ~~~~
// Topology changes container
polyTopoChange meshMod(mesh);
// Merge all faces of a set into the first face of the set.
// Experimental:mark all points/faces/cells that have been restored.
Map<label> restoredPoints(0);
Map<label> restoredFaces(0);
Map<label> restoredCells(0);
faceCombiner.setUnrefinement
(
mastersToRestore,
meshMod,
restoredPoints,
restoredFaces,
restoredCells
);
// Change the mesh (no inflation)
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false, true);
// Update fields
mesh.updateMesh(map);
// Move mesh (since morphing does not do this)
if (map().hasMotionPoints())
{
mesh.movePoints(map().preMotionPoints());
}
else
{
// Delete mesh volumes.
mesh.clearOut();
}
faceCombiner.updateMesh(map);
// Renumber restore maps
inplaceMapKey(map().reversePointMap(), restoredPoints);
inplaceMapKey(map().reverseFaceMap(), restoredFaces);
inplaceMapKey(map().reverseCellMap(), restoredCells);
// Experimental:restore all points/face/cells in maps
meshRefiner_.updateMesh
(
map,
labelList(0), // changedFaces
restoredPoints,
restoredFaces,
restoredCells
);
Info<< endl;
}
if (debug)
{
Pout<< "Writing merged-faces mesh to time "
<< meshRefiner_.timeName() << nl << endl;
mesh.write();
}
}
else
{
Info<< "No faces merged ..." << endl;
}
return nFaceSets;
}
// Remove points. pointCanBeDeleted is parallel synchronised.
Foam::autoPtr<Foam::mapPolyMesh> Foam::autoLayerDriver::doRemovePoints
(
removePoints& pointRemover,
const boolList& pointCanBeDeleted
)
{
fvMesh& mesh = meshRefiner_.mesh();
// Topology changes container
polyTopoChange meshMod(mesh);
pointRemover.setRefinement(pointCanBeDeleted, meshMod);
// Change the mesh (no inflation)
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false, true);
// Update fields
mesh.updateMesh(map);
// Move mesh (since morphing does not do this)
if (map().hasMotionPoints())
{
mesh.movePoints(map().preMotionPoints());
}
else
{
// Delete mesh volumes.
mesh.clearOut();
}
pointRemover.updateMesh(map);
meshRefiner_.updateMesh(map, labelList(0));
return map;
}
// Restore faces (which contain removed points)
Foam::autoPtr<Foam::mapPolyMesh> Foam::autoLayerDriver::doRestorePoints
(
removePoints& pointRemover,
const labelList& facesToRestore
)
{
fvMesh& mesh = meshRefiner_.mesh();
// Topology changes container
polyTopoChange meshMod(mesh);
// Determine sets of points and faces to restore
labelList localFaces, localPoints;
pointRemover.getUnrefimentSet
(
facesToRestore,
localFaces,
localPoints
);
// Undo the changes on the faces that are in error.
pointRemover.setUnrefinement
(
localFaces,
localPoints,
meshMod
);
// Change the mesh (no inflation)
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false, true);
// Update fields
mesh.updateMesh(map);
// Move mesh (since morphing does not do this)
if (map().hasMotionPoints())
{
mesh.movePoints(map().preMotionPoints());
}
else
{
// Delete mesh volumes.
mesh.clearOut();
}
pointRemover.updateMesh(map);
meshRefiner_.updateMesh(map, labelList(0));
return map;
}
// Collect all faces that are both in candidateFaces and in the set.
// If coupled face also collects the coupled face.
Foam::labelList Foam::autoLayerDriver::collectFaces
(
const labelList& candidateFaces,
const labelHashSet& set
) const
{
const fvMesh& mesh = meshRefiner_.mesh();
// Has face been selected?
boolList selected(mesh.nFaces(), false);
forAll(candidateFaces, i)
{
label faceI = candidateFaces[i];
if (set.found(faceI))
{
selected[faceI] = true;
}
}
syncTools::syncFaceList
(
mesh,
selected,
orEqOp<bool>() // combine operator
);
labelList selectedFaces(findIndices(selected, true));
return selectedFaces;
}
// Pick up faces of cells of faces in set.
Foam::labelList Foam::autoLayerDriver::growFaceCellFace
(
const labelHashSet& set
) const
{
const fvMesh& mesh = meshRefiner_.mesh();
boolList selected(mesh.nFaces(), false);
forAllConstIter(faceSet, set, iter)
{
label faceI = iter.key();
label own = mesh.faceOwner()[faceI];
const cell& ownFaces = mesh.cells()[own];
forAll(ownFaces, ownFaceI)
{
selected[ownFaces[ownFaceI]] = true;
}
if (mesh.isInternalFace(faceI))
{
label nbr = mesh.faceNeighbour()[faceI];
const cell& nbrFaces = mesh.cells()[nbr];
forAll(nbrFaces, nbrFaceI)
{
selected[nbrFaces[nbrFaceI]] = true;
}
}
}
syncTools::syncFaceList
(
mesh,
selected,
orEqOp<bool>() // combine operator
);
return findIndices(selected, true);
}
// Remove points not used by any face or points used by only two faces where
// the edges are in line
Foam::label Foam::autoLayerDriver::mergeEdgesUndo
(
const scalar minCos,
const dictionary& motionDict
)
{
fvMesh& mesh = meshRefiner_.mesh();
Info<< nl
<< "Merging all points on surface that" << nl
<< "- are used by only two boundary faces and" << nl
<< "- make an angle with a cosine of more than " << minCos
<< "." << nl << endl;
// Point removal analysis engine with undo
removePoints pointRemover(mesh, true);
// Count usage of points
boolList pointCanBeDeleted;
label nRemove = pointRemover.countPointUsage(minCos, pointCanBeDeleted);
if (nRemove > 0)
{
Info<< "Removing " << nRemove
<< " straight edge points ..." << nl << endl;
// Remove points
// ~~~~~~~~~~~~~
doRemovePoints(pointRemover, pointCanBeDeleted);
for (label iteration = 0; iteration < 100; iteration++)
{
Info<< nl
<< "Undo iteration " << iteration << nl
<< "----------------" << endl;
// Check mesh for errors
// ~~~~~~~~~~~~~~~~~~~~~
faceSet errorFaces
(
mesh,
"errorFaces",
mesh.nFaces()-mesh.nInternalFaces()
);
bool hasErrors = motionSmoother::checkMesh
(
false, // report
mesh,
motionDict,
errorFaces
);
//if (checkEdgeConnectivity)
//{
// Info<< "Checking edge-face connectivity (duplicate faces"
// << " or non-consecutive shared vertices)" << endl;
//
// label nOldSize = errorFaces.size();
//
// hasErrors =
// mesh.checkFaceFaces
// (
// false,
// &errorFaces
// )
// || hasErrors;
//
// Info<< "Detected additional "
// << returnReduce(errorFaces.size()-nOldSize,sumOp<label>())
// << " faces with illegal face-face connectivity"
// << endl;
//}
if (!hasErrors)
{
break;
}
if (debug)
{
errorFaces.instance() = mesh.time().timeName();
Pout<< "**Writing all faces in error to faceSet "
<< errorFaces.objectPath() << nl << endl;
errorFaces.write();
}
labelList masterErrorFaces
(
collectFaces
(
pointRemover.savedFaceLabels(),
errorFaces
)
);
label n = returnReduce(masterErrorFaces.size(), sumOp<label>());
Info<< "Detected " << n
<< " error faces on boundaries that have been merged."
<< " These will be restored to their original faces." << nl
<< endl;
if (n == 0)
{
if (hasErrors)
{
Info<< "Detected "
<< returnReduce(errorFaces.size(), sumOp<label>())
<< " error faces in mesh."
<< " Restoring neighbours of faces in error." << nl
<< endl;
labelList expandedErrorFaces
(
growFaceCellFace
(
errorFaces
)
);
doRestorePoints(pointRemover, expandedErrorFaces);
}
break;
}
doRestorePoints(pointRemover, masterErrorFaces);
}
if (debug)
{
Pout<< "Writing merged-edges mesh to time "
<< meshRefiner_.timeName() << nl << endl;
mesh.write();
}
}
else
{
Info<< "No straight edges simplified and no points removed ..." << endl;
}
return nRemove;
}
// For debugging: Dump displacement to .obj files
void Foam::autoLayerDriver::dumpDisplacement
(
@ -793,7 +177,7 @@ void Foam::autoLayerDriver::checkMeshManifold() const
<< " points where this happens to pointSet "
<< nonManifoldPoints.name() << endl;
nonManifoldPoints.instance() = mesh.time().timeName();
nonManifoldPoints.instance() = meshRefiner_.timeName();
nonManifoldPoints.write();
}
Info<< endl;
@ -1080,7 +464,6 @@ void Foam::autoLayerDriver::handleWarpedFaces
}
//// No extrusion on cells with multiple patch faces. There ususally is a reason
//// why combinePatchFaces hasn't succeeded.
//void Foam::autoLayerDriver::handleMultiplePatchFaces
@ -1133,7 +516,7 @@ void Foam::autoLayerDriver::handleWarpedFaces
//
// if (nMultiPatchCells > 0)
// {
// multiPatchCells.instance() = mesh.time().timeName();
// multiPatchCells.instance() = meshRefiner_.timeName();
// Info<< "Writing " << nMultiPatchCells
// << " cells with multiple (connected) patch faces to cellSet "
// << multiPatchCells.objectPath() << endl;
@ -2547,9 +1930,15 @@ void Foam::autoLayerDriver::mergePatchFacesUndo
<< " (0=straight, 180=fully concave)" << nl
<< endl;
label nChanged = mergePatchFacesUndo(minCos, concaveCos, motionDict);
label nChanged = meshRefiner_.mergePatchFacesUndo
(
minCos,
concaveCos,
meshRefiner_.meshedPatches(),
motionDict
);
nChanged += mergeEdgesUndo(minCos, motionDict);
nChanged += meshRefiner_.mergeEdgesUndo(minCos, motionDict);
}
@ -3191,6 +2580,7 @@ void Foam::autoLayerDriver::addLayers
"addedCells",
findIndices(flaggedCells, true)
);
addedCellSet.instance() = meshRefiner_.timeName();
Info<< "Writing "
<< returnReduce(addedCellSet.size(), sumOp<label>())
<< " added cells to cellSet "
@ -3203,6 +2593,7 @@ void Foam::autoLayerDriver::addLayers
"layerFaces",
findIndices(flaggedCells, true)
);
layerFacesSet.instance() = meshRefiner_.timeName();
Info<< "Writing "
<< returnReduce(layerFacesSet.size(), sumOp<label>())
<< " faces inside added layer to faceSet "
@ -3279,6 +2670,9 @@ void Foam::autoLayerDriver::addLayers
mesh.clearOut();
}
// Reset the instance for if in overwrite mode
mesh.setInstance(meshRefiner_.timeName());
meshRefiner_.updateMesh(map, labelList(0));
@ -3345,6 +2739,7 @@ void Foam::autoLayerDriver::addLayers
// ~~~~~~~~~~
cellSet addedCellSet(mesh, "addedCells", findIndices(flaggedCells, true));
addedCellSet.instance() = meshRefiner_.timeName();
Info<< "Writing "
<< returnReduce(addedCellSet.size(), sumOp<label>())
<< " added cells to cellSet "
@ -3352,6 +2747,7 @@ void Foam::autoLayerDriver::addLayers
addedCellSet.write();
faceSet layerFacesSet(mesh, "layerFaces", findIndices(flaggedFaces, true));
layerFacesSet.instance() = meshRefiner_.timeName();
Info<< "Writing "
<< returnReduce(layerFacesSet.size(), sumOp<label>())
<< " faces inside added layer to faceSet "

View File

@ -105,46 +105,6 @@ class autoLayerDriver
// Private Member Functions
// Face merging
//- Merge patch faces. Undo until no checkMesh errors.
label mergePatchFacesUndo
(
const scalar minCos,
const scalar concaveCos,
const dictionary&
);
//- Remove points.
autoPtr<mapPolyMesh> doRemovePoints
(
removePoints& pointRemover,
const boolList& pointCanBeDeleted
);
//- Restore faces (which contain removed points)
autoPtr<mapPolyMesh> doRestorePoints
(
removePoints& pointRemover,
const labelList& facesToRestore
);
//- Return candidateFaces that are also in set.
labelList collectFaces
(
const labelList& candidateFaces,
const labelHashSet& set
) const;
//- Pick up faces of cells of faces in set.
labelList growFaceCellFace(const labelHashSet&) const;
//- Remove points not used by any face or points used by only
// two faces where the edges are in line
label mergeEdgesUndo(const scalar minCos, const dictionary&);
// Layers
//- For debugging: Dump displacement to .obj files

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,8 +30,8 @@ License
#include "cellSet.H"
#include "syncTools.H"
#include "refinementParameters.H"
#include "featureEdgeMesh.H"
#include "refinementSurfaces.H"
#include "refinementFeatures.H"
#include "shellSurfaces.H"
#include "mapDistributePolyMesh.H"
#include "unitConversion.H"
@ -48,62 +48,6 @@ defineTypeNameAndDebug(autoRefineDriver, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Read explicit feature edges
Foam::label Foam::autoRefineDriver::readFeatureEdges
(
const PtrList<dictionary>& featDicts,
PtrList<featureEdgeMesh>& featureMeshes,
labelList& featureLevels
) const
{
Info<< "Reading external feature lines." << endl;
const fvMesh& mesh = meshRefiner_.mesh();
featureMeshes.setSize(featDicts.size());
featureLevels.setSize(featDicts.size());
forAll(featDicts, i)
{
const dictionary& dict = featDicts[i];
fileName featFileName(dict.lookup("file"));
featureMeshes.set
(
i,
new featureEdgeMesh
(
IOobject
(
featFileName, // name
//mesh.time().findInstance("triSurface", featFileName),
// // instance
mesh.time().constant(), // instance
"triSurface", // local
mesh.time(), // registry
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
)
);
featureMeshes[i].mergePoints(meshRefiner_.mergeDistance());
featureLevels[i] = readLabel(dict.lookup("level"));
Info<< "Refinement level " << featureLevels[i]
<< " for all cells crossed by feature " << featFileName
<< " (" << featureMeshes[i].points().size() << " points, "
<< featureMeshes[i].edges().size() << " edges)." << endl;
}
Info<< "Read feature lines in = "
<< mesh.time().cpuTimeIncrement() << " s" << nl << endl;
return featureMeshes.size();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -128,23 +72,15 @@ Foam::autoRefineDriver::autoRefineDriver
Foam::label Foam::autoRefineDriver::featureEdgeRefine
(
const refinementParameters& refineParams,
const PtrList<dictionary>& featDicts,
const label maxIter,
const label minRefine
)
{
const fvMesh& mesh = meshRefiner_.mesh();
// Read explicit feature edges
PtrList<featureEdgeMesh> featureMeshes;
// Per feature the refinement level
labelList featureLevels;
readFeatureEdges(featDicts, featureMeshes, featureLevels);
label iter = 0;
if (featureMeshes.size() && maxIter > 0)
if (meshRefiner_.features().size() && maxIter > 0)
{
for (; iter < maxIter; iter++)
{
@ -160,9 +96,6 @@ Foam::label Foam::autoRefineDriver::featureEdgeRefine
refineParams.keepPoints()[0], // For now only use one.
refineParams.curvature(),
featureMeshes,
featureLevels,
true, // featureRefinement
false, // internalRefinement
false, // surfaceRefinement
@ -266,8 +199,6 @@ Foam::label Foam::autoRefineDriver::surfaceOnlyRefine
// Only look at surface intersections (minLevel and surface curvature),
// do not do internal refinement (refinementShells)
const PtrList<featureEdgeMesh> dummyFeatures;
labelList candidateCells
(
meshRefiner_.refineCandidates
@ -275,9 +206,6 @@ Foam::label Foam::autoRefineDriver::surfaceOnlyRefine
refineParams.keepPoints()[0],
refineParams.curvature(),
dummyFeatures, // dummy featureMeshes;
labelList(0), // dummy featureLevels;
false, // featureRefinement
false, // internalRefinement
true, // surfaceRefinement
@ -432,8 +360,6 @@ Foam::label Foam::autoRefineDriver::shellRefine
<< "----------------------------" << nl
<< endl;
const PtrList<featureEdgeMesh> dummyFeatures;
labelList candidateCells
(
meshRefiner_.refineCandidates
@ -441,9 +367,6 @@ Foam::label Foam::autoRefineDriver::shellRefine
refineParams.keepPoints()[0],
refineParams.curvature(),
dummyFeatures, // dummy featureMeshes;
labelList(0), // dummy featureLevels;
false, // featureRefinement
true, // internalRefinement
false, // surfaceRefinement
@ -459,7 +382,7 @@ Foam::label Foam::autoRefineDriver::shellRefine
<< " cells to cellSet candidateCellsFromShells." << endl;
cellSet c(mesh, "candidateCellsFromShells", candidateCells);
c.instance() = mesh.time().timeName();
c.instance() = meshRefiner_.timeName();
c.write();
}
@ -677,6 +600,7 @@ void Foam::autoRefineDriver::splitAndMergeBaffles
handleSnapProblems, // remove perp edge connected cells
perpAngle, // perp angle
false, // merge free standing baffles?
//true, // merge free standing baffles?
motionDict,
const_cast<Time&>(mesh.time()),
globalToPatch_,
@ -735,7 +659,8 @@ void Foam::autoRefineDriver::splitAndMergeBaffles
void Foam::autoRefineDriver::mergePatchFaces
(
const refinementParameters& refineParams
const refinementParameters& refineParams,
const dictionary& motionDict
)
{
const fvMesh& mesh = meshRefiner_.mesh();
@ -750,11 +675,12 @@ void Foam::autoRefineDriver::mergePatchFaces
const_cast<Time&>(mesh.time())++;
}
meshRefiner_.mergePatchFaces
meshRefiner_.mergePatchFacesUndo
(
Foam::cos(degToRad(45.0)),
Foam::cos(degToRad(45.0)),
meshRefiner_.meshedPatches()
meshRefiner_.meshedPatches(),
motionDict
);
if (debug)
@ -762,7 +688,7 @@ void Foam::autoRefineDriver::mergePatchFaces
meshRefiner_.checkData();
}
meshRefiner_.mergeEdges(Foam::cos(degToRad(45.0)));
meshRefiner_.mergeEdgesUndo(Foam::cos(degToRad(45.0)), motionDict);
if (debug)
{
@ -789,13 +715,10 @@ void Foam::autoRefineDriver::doRefine
// Check that all the keep points are inside the mesh.
refineParams.findCells(mesh);
PtrList<dictionary> featDicts(refineDict.lookup("features"));
// Refine around feature edges
featureEdgeRefine
(
refineParams,
featDicts,
100, // maxIter
0 // min cells to refine
);
@ -833,7 +756,7 @@ void Foam::autoRefineDriver::doRefine
// Do something about cells with refined faces on the boundary
if (prepareForSnapping)
{
mergePatchFaces(refineParams);
mergePatchFaces(refineParams, motionDict);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,7 +42,6 @@ namespace Foam
{
// Forward declaration of classes
class featureEdgeMesh;
class refinementParameters;
class meshRefinement;
class decompositionMethod;
@ -71,19 +70,10 @@ class autoRefineDriver
// Private Member Functions
//- Read explicit feature edges
label readFeatureEdges
(
const PtrList<dictionary>& featDicts,
PtrList<featureEdgeMesh>& featureMeshes,
labelList& featureLevel
) const;
//- Refine all cells pierced by explicit feature edges
label featureEdgeRefine
(
const refinementParameters& refineParams,
const PtrList<dictionary>& featDicts,
const label maxIter,
const label minRefine
);
@ -130,7 +120,8 @@ class autoRefineDriver
//- Merge refined boundary faces (from exposing coarser cell)
void mergePatchFaces
(
const refinementParameters& refineParams
const refinementParameters& refineParams,
const dictionary& motionDict
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -27,7 +27,6 @@ Description
\*----------------------------------------------------------------------------*/
#include "autoSnapDriver.H"
#include "Time.H"
#include "motionSmoother.H"
#include "polyTopoChange.H"
#include "OFstream.H"
@ -36,13 +35,12 @@ Description
#include "Time.H"
#include "OFstream.H"
#include "mapPolyMesh.H"
#include "motionSmoother.H"
#include "pointEdgePoint.H"
#include "PointEdgeWave.H"
#include "mergePoints.H"
#include "snapParameters.H"
#include "refinementSurfaces.H"
#include "unitConversion.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -509,9 +507,7 @@ void Foam::autoSnapDriver::dumpMove
)
{
// Dump direction of growth into file
Pout<< nl << "Dumping move direction to " << fName << nl
<< "View this Lightwave-OBJ file with e.g. javaview" << nl
<< endl;
Pout<< nl << "Dumping move direction to " << fName << endl;
OFstream nearestStream(fName);
@ -652,8 +648,7 @@ Foam::scalarField Foam::autoSnapDriver::calcSnapDistance
-GREAT // null value
);
tmp<scalarField> tfld = snapParams.snapTol()*maxEdgeLen;
return tfld();
return snapParams.snapTol()*maxEdgeLen;
}
@ -688,6 +683,7 @@ void Foam::autoSnapDriver::preSmoothPatch
// The current mesh is the starting mesh to smooth from.
meshMover.setDisplacement(patchDisp);
meshMover.correct();
scalar oldErrorReduction = -1;
@ -828,7 +824,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
(
unzonedSurfaces,
localPoints,
sqr(4*snapDist), // sqr of attract distance
sqr(snapDist), // sqr of attract distance
hitSurface,
hitInfo
);
@ -880,7 +876,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
(
labelList(1, zoneSurfI),
pointField(localPoints, zonePointIndices),
sqr(4*scalarField(minSnapDist, zonePointIndices)),
sqr(scalarField(minSnapDist, zonePointIndices)),
hitSurface,
hitInfo
);
@ -956,8 +952,8 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
mesh,
pp.meshPoints(),
patchDisp,
minMagEqOp(), // combine op
vector(GREAT, GREAT, GREAT) // null value
minMagSqrEqOp<point>(), // combine op
vector(GREAT, GREAT, GREAT) // null value (note: cannot use VGREAT)
);
@ -990,13 +986,12 @@ void Foam::autoSnapDriver::smoothDisplacement
) const
{
const fvMesh& mesh = meshRefiner_.mesh();
const pointMesh& pMesh = meshMover.pMesh();
const indirectPrimitivePatch& pp = meshMover.patch();
Info<< "Smoothing displacement ..." << endl;
// Set edge diffusivity as inverse of distance to patch
scalarField edgeGamma(1.0/(edgePatchDist(pMesh, pp) + SMALL));
scalarField edgeGamma(1.0/(edgePatchDist(meshMover.pMesh(), pp) + SMALL));
//scalarField edgeGamma(mesh.nEdges(), 1.0);
//scalarField edgeGamma(wallGamma(mesh, pp, 10, 1));
@ -1010,7 +1005,6 @@ void Foam::autoSnapDriver::smoothDisplacement
Info<< "Iteration " << iter << endl;
}
pointVectorField oldDisp(disp);
meshMover.smooth(oldDisp, edgeGamma, disp);
}
Info<< "Displacement smoothed in = "
@ -1045,7 +1039,7 @@ void Foam::autoSnapDriver::smoothDisplacement
}
void Foam::autoSnapDriver::scaleMesh
bool Foam::autoSnapDriver::scaleMesh
(
const snapParameters& snapParams,
const label nInitErrors,
@ -1061,6 +1055,8 @@ void Foam::autoSnapDriver::scaleMesh
scalar oldErrorReduction = -1;
bool meshOk = false;
Info<< "Moving mesh ..." << endl;
for (label iter = 0; iter < 2*snapParams.nSnap(); iter++)
{
@ -1072,10 +1068,11 @@ void Foam::autoSnapDriver::scaleMesh
oldErrorReduction = meshMover.setErrorReduction(0.0);
}
if (meshMover.scaleMesh(checkFaces, baffles, true, nInitErrors))
meshOk = meshMover.scaleMesh(checkFaces, baffles, true, nInitErrors);
if (meshOk)
{
Info<< "Successfully moved mesh" << endl;
break;
}
if (debug)
@ -1098,6 +1095,8 @@ void Foam::autoSnapDriver::scaleMesh
}
Info<< "Moved mesh in = "
<< mesh.time().cpuTimeIncrement() << " s\n" << nl << endl;
return meshOk;
}
@ -1191,7 +1190,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoSnapDriver::repatchToSurface
(
unzonedSurfaces,
localFaceCentres,
sqr(4*faceSnapDist), // sqr of attract distance
sqr(faceSnapDist), // sqr of attract distance
hitSurface,
hitRegion
);
@ -1260,6 +1259,7 @@ void Foam::autoSnapDriver::doSnap
(
const dictionary& snapDict,
const dictionary& motionDict,
const scalar featureCos,
const snapParameters& snapParams
)
{
@ -1278,6 +1278,21 @@ void Foam::autoSnapDriver::doSnap
List<labelPair> baffles;
meshRefiner_.createZoneBaffles(globalToPatch_, baffles);
bool doFeatures = false;
label nFeatIter = 1;
if (snapParams.nFeatureSnap() > 0)
{
doFeatures = true;
nFeatIter = snapParams.nFeatureSnap();
Info<< "Snapping to features in " << nFeatIter
<< " iterations ..." << endl;
}
bool meshOk = false;
{
autoPtr<indirectPrimitivePatch> ppPtr
(
@ -1287,10 +1302,9 @@ void Foam::autoSnapDriver::doSnap
adaptPatchIDs
)
);
indirectPrimitivePatch& pp = ppPtr();
// Distance to attract to nearest feature on surface
const scalarField snapDist(calcSnapDistance(snapParams, pp));
const scalarField snapDist(calcSnapDistance(snapParams, ppPtr()));
// Construct iterative mesh mover.
@ -1302,7 +1316,7 @@ void Foam::autoSnapDriver::doSnap
motionSmoother meshMover
(
mesh,
pp,
ppPtr(),
adaptPatchIDs,
meshRefinement::makeDisplacementField(pMesh, adaptPatchIDs),
motionDict
@ -1330,19 +1344,97 @@ void Foam::autoSnapDriver::doSnap
// Pre-smooth patch vertices (so before determining nearest)
preSmoothPatch(snapParams, nInitErrors, baffles, meshMover);
// Calculate displacement at every patch point. Insert into
// meshMover.
calcNearestSurface(snapDist, meshMover);
if (debug)
{
Pout<< "Writing patch smoothed mesh to time "
<< meshRefiner_.timeName() << '.' << endl;
meshRefiner_.write
(
debug,
mesh.time().path()/meshRefiner_.timeName()
);
Pout<< "Dumped mesh in = "
<< mesh.time().cpuTimeIncrement() << " s\n" << nl << endl;
}
//// Get smoothly varying internal displacement field.
//- 2009-12-16 : was not found to be beneficial. Keeping internal
// fields fixed slightly increases skewness (on boundary)
// but lowers non-orthogonality quite a bit (e.g. 65->59 degrees).
// Maybe if better smoother?
//smoothDisplacement(snapParams, meshMover);
// Apply internal displacement to mesh.
scaleMesh(snapParams, nInitErrors, baffles, meshMover);
for (label iter = 0; iter < nFeatIter; iter++)
{
Info<< nl
<< "Morph iteration " << iter << nl
<< "-----------------" << endl;
// Calculate displacement at every patch point. Insert into
// meshMover.
vectorField disp = calcNearestSurface(snapDist, meshMover);
// Override displacement with feature edge attempt
if (doFeatures)
{
disp = calcNearestSurfaceFeature
(
iter,
featureCos,
scalar(iter+1)/nFeatIter,
snapDist,
disp,
meshMover
);
}
if (debug&meshRefinement::OBJINTERSECTIONS)
{
dumpMove
(
mesh.time().path()
/ "patchDisplacement_" + name(iter) + ".obj",
ppPtr().localPoints(),
ppPtr().localPoints() + disp
);
}
// Get smoothly varying internal displacement field.
smoothDisplacement(snapParams, meshMover);
// Apply internal displacement to mesh.
meshOk = scaleMesh
(
snapParams,
nInitErrors,
baffles,
meshMover
);
if (!meshOk)
{
Info<< "Did not succesfully snap mesh. Giving up."
<< nl << endl;
// Use current mesh as base mesh
meshMover.correct();
break;
}
if (debug)
{
const_cast<Time&>(mesh.time())++;
Pout<< "Writing scaled mesh to time "
<< meshRefiner_.timeName() << endl;
meshRefiner_.write
(
debug,
mesh.time().path()/meshRefiner_.timeName()
);
Pout<< "Writing displacement field ..." << endl;
meshMover.displacement().write();
tmp<pointScalarField> magDisp(mag(meshMover.displacement()));
magDisp().write();
}
// Use current mesh as base mesh
meshMover.correct();
}
}
// Merge any introduced baffles.
@ -1350,6 +1442,34 @@ void Foam::autoSnapDriver::doSnap
// Repatch faces according to nearest.
repatchToSurface(snapParams, adaptPatchIDs);
// Repatching might have caused faces to be on same patch and hence
// mergeable so try again to merge coplanar faces
label nChanged = meshRefiner_.mergePatchFacesUndo
(
featureCos, // minCos
featureCos, // concaveCos
meshRefiner_.meshedPatches(),
motionDict
);
nChanged += meshRefiner_.mergeEdgesUndo
(
featureCos,
motionDict
);
if (nChanged > 0 && debug)
{
const_cast<Time&>(mesh.time())++;
Pout<< "Writing patchFace merged mesh to time "
<< meshRefiner_.timeName() << endl;
meshRefiner_.write
(
debug,
mesh.time().path()/meshRefiner_.timeName()
);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,6 +29,7 @@ Description
SourceFiles
autoSnapDriver.C
autoSnapDriverFeature.C
\*---------------------------------------------------------------------------*/
@ -45,6 +46,7 @@ namespace Foam
// Forward declaration of classes
class motionSmoother;
class snapParameters;
class pointConstraint;
/*---------------------------------------------------------------------------*\
Class autoSnapDriver Declaration
@ -52,23 +54,6 @@ class snapParameters;
class autoSnapDriver
{
// Private classes
//- Combine operator class for equalizing displacements.
class minMagEqOp
{
public:
void operator()(vector& x, const vector& y) const
{
if (magSqr(y) < magSqr(x))
{
x = y;
}
}
};
// Private data
//- Mesh+surface
@ -124,6 +109,174 @@ class autoSnapDriver
const vectorField&
);
// Feature line snapping
void smoothAndConstrain
(
const indirectPrimitivePatch& pp,
const List<pointConstraint>& constraints,
vectorField& disp
) const;
void calcNearest
(
const pointField& points,
vectorField& disp,
vectorField& surfaceNormal
) const;
void calcNearestFace
(
const label iter,
const indirectPrimitivePatch& pp,
vectorField& faceDisp,
vectorField& faceSurfaceNormal,
vectorField& faceRotation
) const;
void interpolateFaceToPoint
(
const label iter,
const indirectPrimitivePatch& pp,
const vectorField& faceSurfaceNormal,
const vectorField& faceDisp,
const vectorField& faceRotation,
vectorField& patchDisp,
vectorField& patchRotationDisp
) const;
void correctAttraction
(
const DynamicList<point>& surfacePoints,
const DynamicList<label>& surfaceCount,
const point& edgePt,
const vector& edgeNormal, // normalised normal
const point& pt,
vector& edgeOffset // offset from pt to point on edge
) const;
void binFeatureFace
(
const label iter,
const scalar featureCos,
const indirectPrimitivePatch& pp,
const scalar snapDist,
const point& fc,
const vector& faceSurfaceNormal,
const vector& faceDisp,
DynamicList<point>& surfacePoints,
DynamicList<vector>& surfaceNormals,
DynamicList<label>& surfaceCount
) const;
void binFeatureFaces
(
const label iter,
const scalar featureCos,
const indirectPrimitivePatch& pp,
const scalarField& snapDist,
const label pointI,
const List<List<point> >& pointFaceNormals,
const List<List<point> >& pointFaceDisp,
const List<List<point> >& pointFaceCentres,
DynamicList<point>& surfacePoints,
DynamicList<vector>& surfaceNormals,
DynamicList<label>& surfaceCount
) const;
void featureAttractionUsingReconstruction
(
const label iter,
const scalar featureCos,
const indirectPrimitivePatch& pp,
const scalarField& snapDist,
const List<List<point> >& pointFaceNormals,
const List<List<point> >& pointFaceDisp,
const List<List<point> >& pointFaceCentres,
vectorField& patchAttraction,
List<pointConstraint>& patchConstraints
) const;
void determineAllFeatures
(
const label iter,
const scalar featureCos,
const indirectPrimitivePatch&,
const scalarField&,
const List<List<point> >& pointFaceNormals,
const List<List<point> >& pointFaceDisp,
const List<List<point> >& pointFaceCentres,
List<labelList>& pointAttractor,
List<List<pointConstraint> >& pointConstraints,
// Feature-edge to pp point
List<List<DynamicList<point> > >& edgeAttractors,
List<List<DynamicList<pointConstraint> > >& edgeConstraints,
vectorField& patchAttraction,
List<pointConstraint>& patchConstraints
) const;
void determineFeatures
(
const label iter,
const scalar featureCos,
const indirectPrimitivePatch&,
const scalarField&,
const List<List<point> >& pointFaceNormals,
const List<List<point> >& pointFaceDisp,
const List<List<point> >& pointFaceCentres,
List<labelList>& pointAttractor,
List<List<pointConstraint> >& pointConstraints,
// Feature-edge to pp point
List<List<DynamicList<point> > >& edgeAttractors,
List<List<DynamicList<pointConstraint> > >& edgeConstraints,
vectorField& patchAttraction,
List<pointConstraint>& patchConstraints
) const;
void featureAttractionUsingFeatureEdges
(
const label iter,
const scalar featureCos,
const indirectPrimitivePatch& pp,
const scalarField& snapDist,
const List<List<point> >& pointFaceNormals,
const List<List<point> >& pointFaceDisp,
const List<List<point> >& pointFaceCentres,
vectorField& patchAttraction,
List<pointConstraint>& patchConstraints
) const;
void preventFaceSqueeze
(
const label iter,
const scalar featureCos,
const indirectPrimitivePatch& pp,
const scalarField& snapDist,
vectorField& patchAttraction,
List<pointConstraint>& patchConstraints
) const;
vectorField calcNearestSurfaceFeature
(
const label iter,
const scalar featureCos,
const scalar featureAttract,
const scalarField& snapDist,
const vectorField& nearestDisp,
motionSmoother& meshMover
) const;
//- Disallow default bitwise copy construct
autoSnapDriver(const autoSnapDriver&);
@ -188,6 +341,7 @@ public:
motionSmoother& meshMover
) const;
//- Smooth the displacement field to the internal.
void smoothDisplacement
(
@ -196,8 +350,9 @@ public:
) const;
//- Do the hard work: move the mesh according to displacement,
// locally relax the displacement.
void scaleMesh
// locally relax the displacement. Return true if ended up with
// correct mesh, false if not.
bool scaleMesh
(
const snapParameters& snapParams,
const label nInitErrors,
@ -212,11 +367,11 @@ public:
const labelList& adaptPatchIDs
);
void doSnap
(
const dictionary& snapDict,
const dictionary& motionDict,
const scalar featureCos,
const snapParameters& snapParams
);

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -27,23 +27,14 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::snapParameters::snapParameters(const dictionary& dict, const label dummy)
:
nSmoothPatch_(readLabel(dict.lookup("nSmoothPatch"))),
snapTol_(readScalar(dict.lookup("snapTol"))),
nSmoothDispl_(readLabel(dict.lookup("nSmoothDispl"))),
nSnap_(readLabel(dict.lookup("nSnap")))
{}
// Construct from dictionary
Foam::snapParameters::snapParameters(const dictionary& dict)
:
nSmoothPatch_(readLabel(dict.lookup("nSmoothPatch"))),
snapTol_(readScalar(dict.lookup("tolerance"))),
nSmoothDispl_(readLabel(dict.lookup("nSolveIter"))),
nSnap_(readLabel(dict.lookup("nRelaxIter")))
nSnap_(readLabel(dict.lookup("nRelaxIter"))),
nFeatureSnap_(dict.lookupOrDefault("nFeatureSnapIter", -1))
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -61,6 +61,8 @@ class snapParameters
const label nSnap_;
const label nFeatureSnap_;
// Private Member Functions
@ -75,10 +77,7 @@ public:
// Constructors
//- Construct from dictionary - old syntax
snapParameters(const dictionary& dict, const label dummy);
//- Construct from dictionary - new syntax
//- Construct from dictionary
snapParameters(const dictionary& dict);
@ -114,6 +113,12 @@ public:
{
return nSnap_;
}
label nFeatureSnap() const
{
return nFeatureSnap_;
}
};

View File

@ -31,6 +31,7 @@ License
#include "Time.H"
#include "refinementHistory.H"
#include "refinementSurfaces.H"
#include "refinementFeatures.H"
#include "decompositionMethod.H"
#include "regionSplit.H"
#include "fvMeshDistribute.H"
@ -497,6 +498,10 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::doRemoveCells
mesh_.clearOut();
}
// Reset the instance for if in overwrite mode
mesh_.setInstance(timeName());
setInstance(mesh_.facesInstance());
// Update local mesh data
cellRemover.updateMesh(map);
@ -857,6 +862,7 @@ Foam::meshRefinement::meshRefinement
const scalar mergeDistance,
const bool overwrite,
const refinementSurfaces& surfaces,
const refinementFeatures& features,
const shellSurfaces& shells
)
:
@ -865,6 +871,7 @@ Foam::meshRefinement::meshRefinement
overwrite_(overwrite),
oldInstance_(mesh.pointsInstance()),
surfaces_(surfaces),
features_(features),
shells_(shells),
meshCutter_
(
@ -1271,6 +1278,10 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
// Update numbering of meshRefiner
distribute(map);
// Set correct instance (for if overwrite)
mesh_.setInstance(timeName());
setInstance(mesh_.facesInstance());
}
return map;
}
@ -1449,6 +1460,8 @@ Foam::tmp<Foam::pointVectorField> Foam::meshRefinement::makeDisplacementField
}
}
// Note: time().timeName() instead of meshRefinement::timeName() since
// postprocessable field.
tmp<pointVectorField> tfld
(
new pointVectorField
@ -1456,7 +1469,7 @@ Foam::tmp<Foam::pointVectorField> Foam::meshRefinement::makeDisplacementField
IOobject
(
"pointDisplacement",
mesh.time().timeName(), //timeName(),
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
@ -1930,10 +1943,6 @@ void Foam::meshRefinement::distribute(const mapDistributePolyMesh& map)
pointMap.clear();
}
}
// If necessary reset the instance
mesh_.setInstance(timeName());
setInstance(mesh_.facesInstance());
}
@ -2059,10 +2068,6 @@ void Foam::meshRefinement::updateMesh
data.transfer(newFaceData);
}
}
// If necessary reset the instance
mesh_.setInstance(timeName());
setInstance(mesh_.facesInstance());
}
@ -2118,12 +2123,32 @@ void Foam::meshRefinement::printMeshInfo(const bool debug, const string& msg)
<< " points(local):" << mesh_.nPoints()
<< endl;
}
else
{
PackedBoolList isMasterFace(syncTools::getMasterFaces(mesh_));
label nMasterFaces = 0;
forAll(isMasterFace, i)
{
if (isMasterFace[i])
{
nMasterFaces++;
}
}
PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh_));
label nMasterPoints = 0;
forAll(isMasterPoint, i)
{
if (isMasterPoint[i])
{
nMasterPoints++;
}
}
Info<< msg.c_str()
<< " : cells:" << pData.nTotalCells()
<< " faces:" << pData.nTotalFaces()
<< " points:" << pData.nTotalPoints()
<< " faces:" << returnReduce(nMasterFaces, sumOp<label>())
<< " points:" << returnReduce(nMasterPoints, sumOp<label>())
<< endl;
}
@ -2168,12 +2193,14 @@ Foam::word Foam::meshRefinement::timeName() const
void Foam::meshRefinement::dumpRefinementLevel() const
{
// Note: use time().timeName(), not meshRefinement::timeName()
// so as to dump the fields to 0, not to constant.
volScalarField volRefLevel
(
IOobject
(
"cellLevel",
mesh_.time().timeName(),// Dump to current time, not to mesh inst
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
@ -2201,7 +2228,7 @@ void Foam::meshRefinement::dumpRefinementLevel() const
IOobject
(
"pointLevel",
mesh_.time().timeName(),// Dump to current time, not to mesh inst
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,

View File

@ -62,13 +62,14 @@ class fvMesh;
class mapDistributePolyMesh;
class decompositionMethod;
class refinementSurfaces;
class refinementFeatures;
class shellSurfaces;
class removeCells;
class featureEdgeMesh;
class fvMeshDistribute;
class searchableSurface;
class regionSplit;
class globalIndex;
class removePoints;
/*---------------------------------------------------------------------------*\
Class meshRefinement Declaration
@ -118,6 +119,9 @@ private:
//- All surface-intersection interaction
const refinementSurfaces& surfaces_;
//- All feature-edge interaction
const refinementFeatures& features_;
//- All shell-refinement interaction
const shellSurfaces& shells_;
@ -260,8 +264,6 @@ private:
label markFeatureRefinement
(
const point& keepPoint,
const PtrList<featureEdgeMesh>& featureMeshes,
const labelList& featureLevels,
const label nAllowRefine,
labelList& refineCell,
@ -415,12 +417,6 @@ private:
const labelList& globalToPatch
) const;
////- Initial test of marking faces using geometric information.
//labelList markFacesOnProblemCellsGeometric
//(
// const dictionary& motionDict
//) const;
// Baffle merging
@ -501,6 +497,7 @@ public:
const scalar mergeDistance,
const bool overwrite,
const refinementSurfaces&,
const refinementFeatures&,
const shellSurfaces&
);
@ -542,6 +539,12 @@ public:
return surfaces_;
}
//- reference to feature edge mesh
const refinementFeatures& features() const
{
return features_;
}
//- reference to refinement shells (regions)
const shellSurfaces& shells() const
{
@ -648,9 +651,6 @@ public:
const point& keepPoint,
const scalar curvature,
const PtrList<featureEdgeMesh>& featureMeshes,
const labelList& featureLevels,
const bool featureRefinement,
const bool internalRefinement,
const bool surfaceRefinement,
@ -803,19 +803,45 @@ public:
const Map<label>& cellsToRestore
);
// Merging coplanar faces and edges
//- Merge faces on the same patch (usually from exposing refinement)
// Returns global number of faces merged.
label mergePatchFaces
(
const scalar minCos,
const scalar concaveCos,
const labelList& patchIDs
);
label mergePatchFacesUndo
(
const scalar minCos,
const scalar concaveCos,
const labelList& patchIDs,
const dictionary& motionDict
);
//- Remove points not used by any face or points used
// by only two faces where the edges are in line
autoPtr<mapPolyMesh> mergeEdges(const scalar minCos);
autoPtr<mapPolyMesh> doRemovePoints
(
removePoints& pointRemover,
const boolList& pointCanBeDeleted
);
autoPtr<mapPolyMesh> doRestorePoints
(
removePoints& pointRemover,
const labelList& facesToRestore
);
labelList collectFaces
(
const labelList& candidateFaces,
const labelHashSet& set
) const;
// Pick up faces of cells of faces in set.
labelList growFaceCellFace
(
const labelHashSet& set
) const;
label mergeEdgesUndo
(
const scalar minCos,
const dictionary& motionDict
);
// Debug/IO

View File

@ -524,6 +524,10 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::createBaffles
mesh_.clearOut();
}
// Reset the instance for if in overwrite mode
mesh_.setInstance(timeName());
//- Redo the intersections on the newly create baffle faces. Note that
// this changes also the cell centre positions.
faceSet baffledFacesSet(mesh_, "baffledFacesSet", 2*nBaffles);
@ -644,7 +648,7 @@ Foam::List<Foam::labelPair> Foam::meshRefinement::getDuplicateFaces
}
Pout<< "Writing duplicate faces (baffles) to faceSet "
<< duplicateFaceSet.name() << nl << endl;
duplicateFaceSet.instance() = mesh_.time().timeName();
duplicateFaceSet.instance() = timeName();
duplicateFaceSet.write();
}
@ -724,9 +728,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::createZoneBaffles
if (debug)
{
const_cast<Time&>(mesh_.time())++;
Pout<< "Writing baffled mesh to time "
<< mesh_.time().timeName() << endl;
mesh_.write();
Pout<< "Writing zone-baffled mesh to time " << timeName()
<< endl;
write(debug, mesh_.time().path()/"baffles");
}
}
Info<< "Created " << nZoneFaces << " baffles in = "
@ -746,14 +750,6 @@ Foam::List<Foam::labelPair> Foam::meshRefinement::filterDuplicateFaces
const List<labelPair>& couples
) const
{
// Construct addressing engine for all duplicate faces (only one
// for each pair)
// Duplicate faces in mesh labels (first face of each pair only)
// (reused later on to mark off filtered couples. see below)
labelList duplicateFaces(couples.size());
// All duplicate faces on edge of the patch are to be merged.
// So we count for all edges of duplicate faces how many duplicate
// faces use them.
@ -824,7 +820,8 @@ Foam::List<Foam::labelPair> Foam::meshRefinement::filterDuplicateFaces
// Baffles which are not next to other boundaries and baffles will have
// value 2*1000000+2*1
// nBafflesPerEdge value 2*1000000+2*1 (from 2 boundary faces which are
// both baffle faces)
List<labelPair> filteredCouples(couples.size());
label filterI = 0;
@ -967,6 +964,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::mergeBaffles
mesh_.clearOut();
}
// Reset the instance for if in overwrite mode
mesh_.setInstance(timeName());
// Update intersections. Recalculate intersections on merged faces since
// this seems to give problems? Note: should not be nessecary since
// baffles preserve intersections from when they were created.
@ -1789,7 +1789,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
problemTopo.insert(faceI);
}
}
problemTopo.instance() = mesh_.time().timeName();
problemTopo.instance() = timeName();
Pout<< "Dumping " << problemTopo.size()
<< " problem faces to " << problemTopo.objectPath() << endl;
problemTopo.write();
@ -2246,6 +2246,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::dupNonManifoldPoints()
mesh_.clearOut();
}
// Reset the instance for if in overwrite mode
mesh_.setInstance(timeName());
// Update intersections. Is mapping only (no faces created, positions stay
// same) so no need to recalculate intersections.
updateMesh(map, labelList(0));
@ -2782,6 +2785,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
mesh_.clearOut();
}
// Reset the instance for if in overwrite mode
mesh_.setInstance(timeName());
// Print some stats (note: zones are synchronised)
if (mesh_.cellZones().size() > 0)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -27,42 +27,258 @@ License
#include "combineFaces.H"
#include "polyTopoChange.H"
#include "removePoints.H"
#include "faceSet.H"
#include "Time.H"
#include "motionSmoother.H"
#include "syncTools.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Merge faces that are in-line.
Foam::label Foam::meshRefinement::mergePatchFaces
//// Merge faces that are in-line.
//Foam::label Foam::meshRefinement::mergePatchFaces
//(
// const scalar minCos,
// const scalar concaveCos,
// const labelList& patchIDs
//)
//{
// // Patch face merging engine
// combineFaces faceCombiner(mesh_);
//
// const polyBoundaryMesh& patches = mesh_.boundaryMesh();
//
// // Pick up all candidate cells on boundary
// labelHashSet boundaryCells(mesh_.nFaces()-mesh_.nInternalFaces());
//
// forAll(patchIDs, i)
// {
// label patchI = patchIDs[i];
//
// const polyPatch& patch = patches[patchI];
//
// if (!patch.coupled())
// {
// forAll(patch, i)
// {
// boundaryCells.insert(mesh_.faceOwner()[patch.start()+i]);
// }
// }
// }
//
// // Get all sets of faces that can be merged
// labelListList mergeSets
// (
// faceCombiner.getMergeSets
// (
// minCos,
// concaveCos,
// boundaryCells
// )
// );
//
// label nFaceSets = returnReduce(mergeSets.size(), sumOp<label>());
//
// Info<< "mergePatchFaces : Merging " << nFaceSets
// << " sets of faces." << endl;
//
// if (nFaceSets > 0)
// {
// // Topology changes container
// polyTopoChange meshMod(mesh_);
//
// // Merge all faces of a set into the first face of the set. Remove
// // unused points.
// faceCombiner.setRefinement(mergeSets, meshMod);
//
// // Change the mesh (no inflation)
// autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh_, false, true);
//
// // Update fields
// mesh_.updateMesh(map);
//
// // Move mesh (since morphing does not do this)
// if (map().hasMotionPoints())
// {
// mesh_.movePoints(map().preMotionPoints());
// }
// else
// {
// // Delete mesh volumes. No other way to do this?
// mesh_.clearOut();
// }
//
//
// // Reset the instance for if in overwrite mode
// mesh_.setInstance(timeName());
//
// faceCombiner.updateMesh(map);
//
// // Get the kept faces that need to be recalculated.
// // Merging two boundary faces might shift the cell centre
// // (unless the faces are absolutely planar)
// labelHashSet retestFaces(6*mergeSets.size());
//
// forAll(mergeSets, setI)
// {
// label oldMasterI = mergeSets[setI][0];
//
// label faceI = map().reverseFaceMap()[oldMasterI];
//
// // faceI is always uncoupled boundary face
// const cell& cFaces = mesh_.cells()[mesh_.faceOwner()[faceI]];
//
// forAll(cFaces, i)
// {
// retestFaces.insert(cFaces[i]);
// }
// }
// updateMesh(map, retestFaces.toc());
// }
//
//
// return nFaceSets;
//}
//
//
//// Remove points not used by any face or points used by only two faces where
//// the edges are in line
//Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::mergeEdges
//(
// const scalar minCos
//)
//{
// // Point removal analysis engine
// removePoints pointRemover(mesh_);
//
// // Count usage of points
// boolList pointCanBeDeleted;
// label nRemove = pointRemover.countPointUsage(minCos, pointCanBeDeleted);
//
// Info<< "Removing " << nRemove
// << " straight edge points." << endl;
//
// autoPtr<mapPolyMesh> map;
//
// if (nRemove > 0)
// {
// // Save my local faces that will change. These changed faces might
// // cause a shift in the cell centre which needs to be retested.
// // Have to do this before changing mesh since point will be removed.
// labelHashSet retestOldFaces(nRemove / Pstream::nProcs());
//
// {
// const faceList& faces = mesh_.faces();
//
// forAll(faces, faceI)
// {
// const face& f = faces[faceI];
//
// forAll(f, fp)
// {
// if (pointCanBeDeleted[f[fp]])
// {
// retestOldFaces.insert(faceI);
// break;
// }
// }
// }
// }
//
// // Topology changes container
// polyTopoChange meshMod(mesh_);
//
// pointRemover.setRefinement(pointCanBeDeleted, meshMod);
//
// // Change the mesh (no inflation)
// map = meshMod.changeMesh(mesh_, false, true);
//
// // Update fields
// mesh_.updateMesh(map);
//
// // Move mesh (since morphing does not do this)
// if (map().hasMotionPoints())
// {
// mesh_.movePoints(map().preMotionPoints());
// }
// else
// {
// // Delete mesh volumes. No other way to do this?
// mesh_.clearOut();
// }
//
// // Reset the instance for if in overwrite mode
// mesh_.setInstance(timeName());
//
// pointRemover.updateMesh(map);
//
// // Get the kept faces that need to be recalculated.
// labelHashSet retestFaces(6*retestOldFaces.size());
//
// const cellList& cells = mesh_.cells();
//
// forAllConstIter(labelHashSet, retestOldFaces, iter)
// {
// label faceI = map().reverseFaceMap()[iter.key()];
//
// const cell& ownFaces = cells[mesh_.faceOwner()[faceI]];
//
// forAll(ownFaces, i)
// {
// retestFaces.insert(ownFaces[i]);
// }
//
// if (mesh_.isInternalFace(faceI))
// {
// const cell& neiFaces = cells[mesh_.faceNeighbour()[faceI]];
//
// forAll(neiFaces, i)
// {
// retestFaces.insert(neiFaces[i]);
// }
// }
// }
// updateMesh(map, retestFaces.toc());
// }
//
// return map;
//}
Foam::label Foam::meshRefinement::mergePatchFacesUndo
(
const scalar minCos,
const scalar concaveCos,
const labelList& patchIDs
const labelList& patchIDs,
const dictionary& motionDict
)
{
// Patch face merging engine
combineFaces faceCombiner(mesh_);
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
combineFaces faceCombiner(mesh_, true);
// Pick up all candidate cells on boundary
labelHashSet boundaryCells(mesh_.nFaces()-mesh_.nInternalFaces());
forAll(patchIDs, i)
{
label patchI = patchIDs[i];
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
const polyPatch& patch = patches[patchI];
if (!patch.coupled())
forAll(patchIDs, i)
{
forAll(patch, i)
label patchI = patchIDs[i];
const polyPatch& patch = patches[patchI];
if (!patch.coupled())
{
boundaryCells.insert(mesh_.faceOwner()[patch.start()+i]);
forAll(patch, i)
{
boundaryCells.insert(mesh_.faceOwner()[patch.start()+i]);
}
}
}
}
// Get all sets of faces that can be merged
labelListList mergeSets
labelListList allFaceSets
(
faceCombiner.getMergeSets
(
@ -72,19 +288,44 @@ Foam::label Foam::meshRefinement::mergePatchFaces
)
);
label nFaceSets = returnReduce(mergeSets.size(), sumOp<label>());
label nFaceSets = returnReduce(allFaceSets.size(), sumOp<label>());
Info<< "mergePatchFaces : Merging " << nFaceSets
<< " sets of faces." << endl;
Info<< "Merging " << nFaceSets << " sets of faces." << nl << endl;
if (nFaceSets > 0)
{
if (debug)
{
faceSet allSets(mesh_, "allFaceSets", allFaceSets.size());
forAll(allFaceSets, setI)
{
forAll(allFaceSets[setI], i)
{
allSets.insert(allFaceSets[setI][i]);
}
}
Pout<< "Writing all faces to be merged to set "
<< allSets.objectPath() << endl;
allSets.instance() = timeName();
allSets.write();
const_cast<Time&>(mesh_.time())++;
}
// Topology changes container
polyTopoChange meshMod(mesh_);
// Merge all faces of a set into the first face of the set. Remove
// unused points.
faceCombiner.setRefinement(mergeSets, meshMod);
// Merge all faces of a set into the first face of the set.
faceCombiner.setRefinement(allFaceSets, meshMod);
// Experimental: store data for all the points that have been deleted
storeData
(
faceCombiner.savedPointLabels(), // points to store
labelList(0), // faces to store
labelList(0) // cells to store
);
// Change the mesh (no inflation)
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh_, false, true);
@ -99,138 +340,538 @@ Foam::label Foam::meshRefinement::mergePatchFaces
}
else
{
// Delete mesh volumes. No other way to do this?
// Delete mesh volumes.
mesh_.clearOut();
}
// Reset the instance for if in overwrite mode
mesh_.setInstance(timeName());
faceCombiner.updateMesh(map);
// Get the kept faces that need to be recalculated.
// Merging two boundary faces might shift the cell centre
// (unless the faces are absolutely planar)
labelHashSet retestFaces(6*mergeSets.size());
updateMesh(map, labelList(0));
forAll(mergeSets, setI)
if (debug)
{
label oldMasterI = mergeSets[setI][0];
label faceI = map().reverseFaceMap()[oldMasterI];
// faceI is always uncoupled boundary face
const cell& cFaces = mesh_.cells()[mesh_.faceOwner()[faceI]];
forAll(cFaces, i)
{
retestFaces.insert(cFaces[i]);
}
Pout<< "Writing initial merged-faces mesh to time "
<< timeName() << nl << endl;
write();
}
updateMesh(map, retestFaces.toc());
}
for (label iteration = 0; iteration < 100; iteration++)
{
Info<< nl
<< "Undo iteration " << iteration << nl
<< "----------------" << endl;
// Check mesh for errors
// ~~~~~~~~~~~~~~~~~~~~~
faceSet errorFaces
(
mesh_,
"errorFaces",
mesh_.nFaces()-mesh_.nInternalFaces()
);
bool hasErrors = motionSmoother::checkMesh
(
false, // report
mesh_,
motionDict,
errorFaces
);
//if (checkEdgeConnectivity)
//{
// Info<< "Checking edge-face connectivity (duplicate faces"
// << " or non-consecutive shared vertices)" << endl;
//
// label nOldSize = errorFaces.size();
//
// hasErrors =
// mesh_.checkFaceFaces
// (
// false,
// &errorFaces
// )
// || hasErrors;
//
// Info<< "Detected additional "
// << returnReduce
// (
// errorFaces.size() - nOldSize,
// sumOp<label>()
// )
// << " faces with illegal face-face connectivity"
// << endl;
//}
if (!hasErrors)
{
break;
}
if (debug)
{
errorFaces.instance() = timeName();
Pout<< "Writing all faces in error to faceSet "
<< errorFaces.objectPath() << nl << endl;
errorFaces.write();
}
// Check any master cells for using any of the error faces
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DynamicList<label> mastersToRestore(allFaceSets.size());
forAll(allFaceSets, setI)
{
label masterFaceI = faceCombiner.masterFace()[setI];
if (masterFaceI != -1)
{
label masterCellII = mesh_.faceOwner()[masterFaceI];
const cell& cFaces = mesh_.cells()[masterCellII];
forAll(cFaces, i)
{
if (errorFaces.found(cFaces[i]))
{
mastersToRestore.append(masterFaceI);
break;
}
}
}
}
mastersToRestore.shrink();
label nRestore = returnReduce
(
mastersToRestore.size(),
sumOp<label>()
);
Info<< "Masters that need to be restored:"
<< nRestore << endl;
if (debug)
{
faceSet restoreSet(mesh_, "mastersToRestore", mastersToRestore);
restoreSet.instance() = timeName();
Pout<< "Writing all " << mastersToRestore.size()
<< " masterfaces to be restored to set "
<< restoreSet.objectPath() << endl;
restoreSet.write();
}
if (nRestore == 0)
{
break;
}
// Undo
// ~~~~
if (debug)
{
const_cast<Time&>(mesh_.time())++;
}
// Topology changes container
polyTopoChange meshMod(mesh_);
// Merge all faces of a set into the first face of the set.
// Experimental:mark all points/faces/cells that have been restored.
Map<label> restoredPoints(0);
Map<label> restoredFaces(0);
Map<label> restoredCells(0);
faceCombiner.setUnrefinement
(
mastersToRestore,
meshMod,
restoredPoints,
restoredFaces,
restoredCells
);
// Change the mesh (no inflation)
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh_, false, true);
// Update fields
mesh_.updateMesh(map);
// Move mesh (since morphing does not do this)
if (map().hasMotionPoints())
{
mesh_.movePoints(map().preMotionPoints());
}
else
{
// Delete mesh volumes.
mesh_.clearOut();
}
// Reset the instance for if in overwrite mode
mesh_.setInstance(timeName());
faceCombiner.updateMesh(map);
// Renumber restore maps
inplaceMapKey(map().reversePointMap(), restoredPoints);
inplaceMapKey(map().reverseFaceMap(), restoredFaces);
inplaceMapKey(map().reverseCellMap(), restoredCells);
// Experimental:restore all points/face/cells in maps
updateMesh
(
map,
labelList(0), // changedFaces
restoredPoints,
restoredFaces,
restoredCells
);
if (debug)
{
Pout<< "Writing merged-faces mesh to time "
<< timeName() << nl << endl;
write();
}
Info<< endl;
}
}
else
{
Info<< "No faces merged ..." << endl;
}
return nFaceSets;
}
// Remove points not used by any face or points used by only two faces where
// the edges are in line
Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::mergeEdges
// Remove points. pointCanBeDeleted is parallel synchronised.
Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::doRemovePoints
(
const scalar minCos
removePoints& pointRemover,
const boolList& pointCanBeDeleted
)
{
// Point removal analysis engine
removePoints pointRemover(mesh_);
// Topology changes container
polyTopoChange meshMod(mesh_);
// Count usage of points
boolList pointCanBeDeleted;
label nRemove = pointRemover.countPointUsage(minCos, pointCanBeDeleted);
pointRemover.setRefinement(pointCanBeDeleted, meshMod);
Info<< "Removing " << nRemove
<< " straight edge points." << endl;
// Change the mesh (no inflation)
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh_, false, true);
autoPtr<mapPolyMesh> map;
// Update fields
mesh_.updateMesh(map);
if (nRemove > 0)
// Move mesh (since morphing does not do this)
if (map().hasMotionPoints())
{
// Save my local faces that will change. These changed faces might
// cause a shift in the cell centre which needs to be retested.
// Have to do this before changing mesh since point will be removed.
labelHashSet retestOldFaces(nRemove / Pstream::nProcs());
{
const faceList& faces = mesh_.faces();
forAll(faces, faceI)
{
const face& f = faces[faceI];
forAll(f, fp)
{
if (pointCanBeDeleted[f[fp]])
{
retestOldFaces.insert(faceI);
break;
}
}
}
}
// Topology changes container
polyTopoChange meshMod(mesh_);
pointRemover.setRefinement(pointCanBeDeleted, meshMod);
// Change the mesh (no inflation)
map = meshMod.changeMesh(mesh_, false, true);
// Update fields
mesh_.updateMesh(map);
// Move mesh (since morphing does not do this)
if (map().hasMotionPoints())
{
mesh_.movePoints(map().preMotionPoints());
}
else
{
// Delete mesh volumes. No other way to do this?
mesh_.clearOut();
}
pointRemover.updateMesh(map);
// Get the kept faces that need to be recalculated.
labelHashSet retestFaces(6*retestOldFaces.size());
const cellList& cells = mesh_.cells();
forAllConstIter(labelHashSet, retestOldFaces, iter)
{
label faceI = map().reverseFaceMap()[iter.key()];
const cell& ownFaces = cells[mesh_.faceOwner()[faceI]];
forAll(ownFaces, i)
{
retestFaces.insert(ownFaces[i]);
}
if (mesh_.isInternalFace(faceI))
{
const cell& neiFaces = cells[mesh_.faceNeighbour()[faceI]];
forAll(neiFaces, i)
{
retestFaces.insert(neiFaces[i]);
}
}
}
updateMesh(map, retestFaces.toc());
mesh_.movePoints(map().preMotionPoints());
}
else
{
// Delete mesh volumes.
mesh_.clearOut();
}
// Reset the instance for if in overwrite mode
mesh_.setInstance(timeName());
pointRemover.updateMesh(map);
updateMesh(map, labelList(0));
return map;
}
// Restore faces (which contain removed points)
Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::doRestorePoints
(
removePoints& pointRemover,
const labelList& facesToRestore
)
{
// Topology changes container
polyTopoChange meshMod(mesh_);
// Determine sets of points and faces to restore
labelList localFaces, localPoints;
pointRemover.getUnrefimentSet
(
facesToRestore,
localFaces,
localPoints
);
// Undo the changes on the faces that are in error.
pointRemover.setUnrefinement
(
localFaces,
localPoints,
meshMod
);
// Change the mesh (no inflation)
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh_, false, true);
// Update fields
mesh_.updateMesh(map);
// Move mesh (since morphing does not do this)
if (map().hasMotionPoints())
{
mesh_.movePoints(map().preMotionPoints());
}
else
{
// Delete mesh volumes.
mesh_.clearOut();
}
// Reset the instance for if in overwrite mode
mesh_.setInstance(timeName());
pointRemover.updateMesh(map);
updateMesh(map, labelList(0));
return map;
}
// Collect all faces that are both in candidateFaces and in the set.
// If coupled face also collects the coupled face.
Foam::labelList Foam::meshRefinement::collectFaces
(
const labelList& candidateFaces,
const labelHashSet& set
) const
{
// Has face been selected?
boolList selected(mesh_.nFaces(), false);
forAll(candidateFaces, i)
{
label faceI = candidateFaces[i];
if (set.found(faceI))
{
selected[faceI] = true;
}
}
syncTools::syncFaceList
(
mesh_,
selected,
orEqOp<bool>() // combine operator
);
labelList selectedFaces(findIndices(selected, true));
return selectedFaces;
}
// Pick up faces of cells of faces in set.
Foam::labelList Foam::meshRefinement::growFaceCellFace
(
const labelHashSet& set
) const
{
boolList selected(mesh_.nFaces(), false);
forAllConstIter(faceSet, set, iter)
{
label faceI = iter.key();
label own = mesh_.faceOwner()[faceI];
const cell& ownFaces = mesh_.cells()[own];
forAll(ownFaces, ownFaceI)
{
selected[ownFaces[ownFaceI]] = true;
}
if (mesh_.isInternalFace(faceI))
{
label nbr = mesh_.faceNeighbour()[faceI];
const cell& nbrFaces = mesh_.cells()[nbr];
forAll(nbrFaces, nbrFaceI)
{
selected[nbrFaces[nbrFaceI]] = true;
}
}
}
syncTools::syncFaceList
(
mesh_,
selected,
orEqOp<bool>() // combine operator
);
return findIndices(selected, true);
}
// Remove points not used by any face or points used by only two faces where
// the edges are in line
Foam::label Foam::meshRefinement::mergeEdgesUndo
(
const scalar minCos,
const dictionary& motionDict
)
{
Info<< nl
<< "Merging all points on surface that" << nl
<< "- are used by only two boundary faces and" << nl
<< "- make an angle with a cosine of more than " << minCos
<< "." << nl << endl;
// Point removal analysis engine with undo
removePoints pointRemover(mesh_, true);
// Count usage of points
boolList pointCanBeDeleted;
label nRemove = pointRemover.countPointUsage(minCos, pointCanBeDeleted);
if (nRemove > 0)
{
Info<< "Removing " << nRemove
<< " straight edge points ..." << nl << endl;
// Remove points
// ~~~~~~~~~~~~~
doRemovePoints(pointRemover, pointCanBeDeleted);
for (label iteration = 0; iteration < 100; iteration++)
{
Info<< nl
<< "Undo iteration " << iteration << nl
<< "----------------" << endl;
// Check mesh for errors
// ~~~~~~~~~~~~~~~~~~~~~
faceSet errorFaces
(
mesh_,
"errorFaces",
mesh_.nFaces()-mesh_.nInternalFaces()
);
bool hasErrors = motionSmoother::checkMesh
(
false, // report
mesh_,
motionDict,
errorFaces
);
//if (checkEdgeConnectivity)
//{
// Info<< "Checking edge-face connectivity (duplicate faces"
// << " or non-consecutive shared vertices)" << endl;
//
// label nOldSize = errorFaces.size();
//
// hasErrors =
// mesh_.checkFaceFaces
// (
// false,
// &errorFaces
// )
// || hasErrors;
//
// Info<< "Detected additional "
// << returnReduce(errorFaces.size()-nOldSize,sumOp<label>())
// << " faces with illegal face-face connectivity"
// << endl;
//}
if (!hasErrors)
{
break;
}
if (debug)
{
errorFaces.instance() = timeName();
Pout<< "**Writing all faces in error to faceSet "
<< errorFaces.objectPath() << nl << endl;
errorFaces.write();
}
labelList masterErrorFaces
(
collectFaces
(
pointRemover.savedFaceLabels(),
errorFaces
)
);
label n = returnReduce(masterErrorFaces.size(), sumOp<label>());
Info<< "Detected " << n
<< " error faces on boundaries that have been merged."
<< " These will be restored to their original faces." << nl
<< endl;
if (n == 0)
{
if (hasErrors)
{
Info<< "Detected "
<< returnReduce(errorFaces.size(), sumOp<label>())
<< " error faces in mesh."
<< " Restoring neighbours of faces in error." << nl
<< endl;
labelList expandedErrorFaces
(
growFaceCellFace
(
errorFaces
)
);
doRestorePoints(pointRemover, expandedErrorFaces);
}
break;
}
doRestorePoints(pointRemover, masterErrorFaces);
}
if (debug)
{
const_cast<Time&>(mesh_.time())++;
Pout<< "Writing merged-edges mesh to time "
<< timeName() << nl << endl;
write();
}
}
else
{
Info<< "No straight edges simplified and no points removed ..." << endl;
}
return nRemove;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -202,7 +202,7 @@ Foam::Map<Foam::label> Foam::meshRefinement::findEdgeConnectedProblemCells
if (debug)
{
faceSet fSet(mesh_, "edgeConnectedFaces", candidateFaces);
fSet.instance() = mesh_.time().timeName();
fSet.instance() = timeName();
Pout<< "Writing " << fSet.size()
<< " with problematic topology to faceSet "
<< fSet.objectPath() << endl;
@ -265,7 +265,7 @@ Foam::Map<Foam::label> Foam::meshRefinement::findEdgeConnectedProblemCells
if (debug)
{
perpFaces.instance() = mesh_.time().timeName();
perpFaces.instance() = timeName();
Pout<< "Writing " << perpFaces.size()
<< " faces that are perpendicular to the surface to set "
<< perpFaces.objectPath() << endl;
@ -427,6 +427,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
// Count of faces marked for baffling
label nBaffleFaces = 0;
PackedBoolList isMasterFace(syncTools::getMasterFaces(mesh_));
// Count of faces not baffled since would not cause a collapse
label nPrevented = 0;
@ -483,7 +484,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
if (debug)
{
cellSet problemCellSet(mesh_, "problemCells", problemCells.toc());
problemCellSet.instance() = mesh_.time().timeName();
problemCellSet.instance() = timeName();
Pout<< "Writing " << problemCellSet.size()
<< " cells that are edge connected to coarser cell to set "
<< problemCellSet.objectPath() << endl;
@ -918,7 +919,10 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
else
{
facePatch[faceI] = getBafflePatch(facePatch, faceI);
nBaffleFaces++;
if (isMasterFace[faceI])
{
nBaffleFaces++;
}
// Do NOT update boundary data since this would grow
// blocked faces across gaps.

View File

@ -28,6 +28,7 @@ License
#include "syncTools.H"
#include "Time.H"
#include "refinementSurfaces.H"
#include "refinementFeatures.H"
#include "shellSurfaces.H"
#include "faceSet.H"
#include "decompositionMethod.H"
@ -53,6 +54,11 @@ Foam::labelList Foam::meshRefinement::getChangedFaces
const polyMesh& mesh = map.mesh();
labelList changedFaces;
// For reporting: number of masterFaces changed
label nMasterChanged = 0;
PackedBoolList isMasterFace(syncTools::getMasterFaces(mesh));
{
// Mark any face on a cell which has been added or changed
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -182,36 +188,26 @@ Foam::labelList Foam::meshRefinement::getChangedFaces
// Now we have in changedFace marked all affected faces. Pack.
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label nChanged = 0;
changedFaces = findIndices(changedFace, true);
// Count changed master faces.
nMasterChanged = 0;
forAll(changedFace, faceI)
{
if (changedFace[faceI])
if (changedFace[faceI] && isMasterFace[faceI])
{
nChanged++;
nMasterChanged++;
}
}
changedFaces.setSize(nChanged);
nChanged = 0;
forAll(changedFace, faceI)
{
if (changedFace[faceI])
{
changedFaces[nChanged++] = faceI;
}
}
}
label nChangedFaces = changedFaces.size();
reduce(nChangedFaces, sumOp<label>());
if (debug)
{
Pout<< "getChangedFaces : Detected "
<< " local:" << changedFaces.size()
<< " global:" << nChangedFaces
<< " global:" << returnReduce(nMasterChanged, sumOp<label>())
<< " changed faces out of " << mesh.globalData().nTotalFaces()
<< endl;
@ -252,8 +248,6 @@ bool Foam::meshRefinement::markForRefine
Foam::label Foam::meshRefinement::markFeatureRefinement
(
const point& keepPoint,
const PtrList<featureEdgeMesh>& featureMeshes,
const labelList& featureLevels,
const label nAllowRefine,
labelList& refineCell,
@ -287,9 +281,11 @@ Foam::label Foam::meshRefinement::markFeatureRefinement
if (cellI != -1)
{
forAll(featureMeshes, featI)
forAll(features_, featI)
{
const featureEdgeMesh& featureMesh = featureMeshes[featI];
const featureEdgeMesh& featureMesh = features_[featI];
const label featureLevel = features_.levels()[featI];
const labelListList& pointEdges = featureMesh.pointEdges();
forAll(pointEdges, pointI)
@ -315,7 +311,7 @@ Foam::label Foam::meshRefinement::markFeatureRefinement
tetFaceI,
tetPtI,
featureMesh.points()[pointI], // endpos
featureLevels[featI], // level
featureLevel, // level
featI, // featureMesh
pointI // end point
)
@ -339,11 +335,11 @@ Foam::label Foam::meshRefinement::markFeatureRefinement
maxFeatureLevel = -1;
// Whether edge has been visited.
List<PackedBoolList> featureEdgeVisited(featureMeshes.size());
List<PackedBoolList> featureEdgeVisited(features_.size());
forAll(featureMeshes, featI)
forAll(features_, featI)
{
featureEdgeVisited[featI].setSize(featureMeshes[featI].edges().size());
featureEdgeVisited[featI].setSize(features_[featI].edges().size());
featureEdgeVisited[featI] = 0u;
}
@ -359,7 +355,7 @@ Foam::label Foam::meshRefinement::markFeatureRefinement
label featI = tp.i();
label pointI = tp.j();
const featureEdgeMesh& featureMesh = featureMeshes[featI];
const featureEdgeMesh& featureMesh = features_[featI];
const labelList& pEdges = featureMesh.pointEdges()[pointI];
// Particle now at pointI. Check connected edges to see which one
@ -1068,9 +1064,6 @@ Foam::labelList Foam::meshRefinement::refineCandidates
const point& keepPoint,
const scalar curvature,
const PtrList<featureEdgeMesh>& featureMeshes,
const labelList& featureLevels,
const bool featureRefinement,
const bool internalRefinement,
const bool surfaceRefinement,
@ -1134,8 +1127,6 @@ Foam::labelList Foam::meshRefinement::refineCandidates
label nFeatures = markFeatureRefinement
(
keepPoint,
featureMeshes,
featureLevels,
nAllowRefine,
refineCell,
@ -1251,6 +1242,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::refine
mesh_.clearOut();
}
// Reset the instance for if in overwrite mode
mesh_.setInstance(timeName());
// Update intersection info
updateMesh(map, getChangedFaces(map, cellsToRefine));

View File

@ -0,0 +1,233 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "refinementFeatures.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::refinementFeatures::refinementFeatures
(
const objectRegistry& io,
const PtrList<dictionary>& featDicts
)
:
PtrList<featureEdgeMesh>(featDicts.size()),
levels_(featDicts.size()),
edgeTrees_(featDicts.size()),
pointTrees_(featDicts.size())
{
// Read features
forAll(featDicts, i)
{
const dictionary& dict = featDicts[i];
fileName featFileName(dict.lookup("file"));
set
(
i,
new featureEdgeMesh
(
IOobject
(
featFileName, // name
io.time().constant(), // instance
"triSurface", // local
io.time(), // registry
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
)
);
const featureEdgeMesh& eMesh = operator[](i);
//eMesh.mergePoints(meshRefiner_.mergeDistance());
levels_[i] = readLabel(dict.lookup("level"));
Info<< "Refinement level " << levels_[i]
<< " for all cells crossed by feature " << featFileName
<< " (" << eMesh.points().size() << " points, "
<< eMesh.edges().size() << " edges)." << endl;
}
// Search engines
forAll(*this, i)
{
const featureEdgeMesh& eMesh = operator[](i);
const pointField& points = eMesh.points();
const edgeList& edges = eMesh.edges();
// Calculate bb of all points
const treeBoundBox bb(points);
edgeTrees_.set
(
i,
new indexedOctree<treeDataEdge>
(
treeDataEdge
(
false, // do not cache bb
edges,
points,
identity(edges.size())
),
bb, // overall search domain
8, // maxLevel
10, // leafsize
3.0 // duplicity
)
);
// Detect feature points from edges.
const labelListList& pointEdges = eMesh.pointEdges();
DynamicList<label> featurePoints;
forAll(pointEdges, pointI)
{
if (pointEdges[pointI].size() > 2)
{
featurePoints.append(pointI);
}
}
Info<< "Detected " << featurePoints.size()
<< " featurePoints out of " << points.size() << endl;
pointTrees_.set
(
i,
new indexedOctree<treeDataPoint>
(
treeDataPoint(points, featurePoints),
bb, // overall search domain
8, // maxLevel
10, // leafsize
3.0 // duplicity
)
);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::refinementFeatures::findNearestEdge
(
const pointField& samples,
const scalarField& nearestDistSqr,
labelList& nearFeature,
List<pointIndexHit>& nearInfo
) const
{
nearFeature.setSize(samples.size());
nearFeature = -1;
nearInfo.setSize(samples.size());
forAll(edgeTrees_, featI)
{
const indexedOctree<treeDataEdge>& tree = edgeTrees_[featI];
forAll(samples, sampleI)
{
const point& sample = samples[sampleI];
scalar distSqr;
if (nearInfo[sampleI].hit())
{
distSqr = magSqr(nearInfo[sampleI].hitPoint()-sample);
}
else
{
distSqr = nearestDistSqr[sampleI];
}
pointIndexHit info = tree.findNearest(sample, distSqr);
if (info.hit())
{
nearInfo[sampleI] = info;
nearFeature[sampleI] = featI;
}
}
}
}
void Foam::refinementFeatures::findNearestPoint
(
const pointField& samples,
const scalarField& nearestDistSqr,
labelList& nearFeature,
labelList& nearIndex
) const
{
nearFeature.setSize(samples.size());
nearFeature = -1;
nearIndex.setSize(samples.size());
nearIndex = -1;
forAll(pointTrees_, featI)
{
const indexedOctree<treeDataPoint>& tree = pointTrees_[featI];
forAll(samples, sampleI)
{
const point& sample = samples[sampleI];
scalar distSqr;
if (nearFeature[sampleI] != -1)
{
label nearFeatI = nearFeature[sampleI];
const indexedOctree<treeDataPoint>& nearTree =
pointTrees_[nearFeatI];
label featPointI =
nearTree.shapes().pointLabels()[nearIndex[sampleI]];
const point& featPt =
operator[](nearFeatI).points()[featPointI];
distSqr = magSqr(featPt-sample);
}
else
{
distSqr = nearestDistSqr[sampleI];
}
pointIndexHit info = tree.findNearest(sample, distSqr);
if (info.hit())
{
nearFeature[sampleI] = featI;
nearIndex[sampleI] = info.index();
}
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,139 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::refinementFeatures
Description
Encapsulates queries for features.
SourceFiles
refinementFeatures.C
\*---------------------------------------------------------------------------*/
#ifndef refinementFeatures_H
#define refinementFeatures_H
#include "featureEdgeMesh.H"
#include "indexedOctree.H"
#include "treeDataEdge.H"
#include "treeDataPoint.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class refinementFeatures Declaration
\*---------------------------------------------------------------------------*/
class refinementFeatures
:
public PtrList<featureEdgeMesh>
{
private:
// Private data
//- Refinement levels
labelList levels_;
//- Edge
PtrList<indexedOctree<treeDataEdge> > edgeTrees_;
//- Features points
PtrList<indexedOctree<treeDataPoint> > pointTrees_;
// Private Member Functions
public:
// Constructors
//- Construct from components
refinementFeatures
(
const objectRegistry& io,
const PtrList<dictionary>& featDicts
);
// Member Functions
// Access
const labelList& levels() const
{
return levels_;
}
const PtrList<indexedOctree<treeDataEdge> >& edgeTrees() const
{
return edgeTrees_;
}
const PtrList<indexedOctree<treeDataPoint> >& pointTrees() const
{
return pointTrees_;
}
// Query
//- Find nearest point on nearest feature edge
void findNearestEdge
(
const pointField& samples,
const scalarField& nearestDistSqr,
labelList& nearFeature,
List<pointIndexHit>& nearInfo
) const;
//- Find nearest feature point. Is an index into feature points
// which itself is an index into the edgeMesh points.
// So the point index is
// pointTrees()[nearFeature].shapes().pointLabels()[nearIndex]
// Wip.
void findNearestPoint
(
const pointField& samples,
const scalarField& nearestDistSqr,
labelList& nearFeature,
labelList& nearIndex
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -225,8 +225,6 @@ void Foam::blockMesh::calcMergeInfo()
}
bool found = false;
// N-squared point search over all points of all faces of
// master block over all point of all faces of slave block
forAll(blockPfaceFaces, blockPfaceFaceLabel)
@ -240,8 +238,6 @@ void Foam::blockMesh::calcMergeInfo()
forAll(blockPfaceFacePoints, blockPfaceFacePointLabel)
{
found = false;
forAll(blockNfaceFaces, blockNfaceFaceLabel)
{
const labelList& blockNfaceFacePoints
@ -261,7 +257,6 @@ void Foam::blockMesh::calcMergeInfo()
)
{
// Found a new pair
found = true;
cp[blockPfaceFacePointLabel] =
blockNfaceFacePoints[blockNfaceFacePointLabel];
@ -332,7 +327,6 @@ void Foam::blockMesh::calcMergeInfo()
const labelListList& curPairs = glueMergePairs[blockFaceLabel];
bool foundFace = false;
label blockPfaceLabel;
for
(
@ -347,14 +341,12 @@ void Foam::blockMesh::calcMergeInfo()
== blockInternalFaces[blockFaceLabel]
)
{
foundFace = true;
break;
}
}
// FIXME? - there seems to be some logic missing here
foundFace = false;
label blockNfaceLabel;
for
(
@ -369,7 +361,6 @@ void Foam::blockMesh::calcMergeInfo()
== blockInternalFaces[blockFaceLabel]
)
{
foundFace = true;
break;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -281,7 +281,7 @@ void Foam::cellClassification::markCells
// Use linear search for points.
label cellI = queryMesh.findCell(outsidePts[outsidePtI], -1, false);
if (cellI == -1)
if (returnReduce(cellI, maxOp<label>()) == -1)
{
FatalErrorIn
(
@ -293,13 +293,16 @@ void Foam::cellClassification::markCells
<< exit(FatalError);
}
cellInfoList[cellI] = cellInfo(cellClassification::OUTSIDE);
// Mark faces of cellI
const labelList& myFaces = mesh_.cells()[cellI];
forAll(myFaces, myFaceI)
if (cellI >= 0)
{
outsideFacesMap.insert(myFaces[myFaceI]);
cellInfoList[cellI] = cellInfo(cellClassification::OUTSIDE);
// Mark faces of cellI
const labelList& myFaces = mesh_.cells()[cellI];
forAll(myFaces, myFaceI)
{
outsideFacesMap.insert(myFaces[myFaceI]);
}
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -55,12 +55,9 @@ Foam::topoSetSource::addToUsageTable Foam::nearestToCell::usage_
void Foam::nearestToCell::combine(topoSet& set, const bool add) const
{
// Construct search engine withouth tet decomposition.
meshSearch queryMesh(mesh_, false);
forAll(points_, pointI)
{
addOrDelete(set, queryMesh.findNearestCell(points_[pointI]), add);
addOrDelete(set, mesh_.findNearestCell(points_[pointI]), add);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -175,7 +175,8 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
const point& outsidePoint = outsidePoints_[outsideI];
// Find cell point is in. Linear search.
if (queryMesh.findCell(outsidePoint, -1, false) == -1)
label cellI = queryMesh.findCell(outsidePoint, -1, false);
if (returnReduce(cellI, maxOp<label>()) == -1)
{
FatalErrorIn("surfaceToCell::combine(topoSet&, const bool)")
<< "outsidePoint " << outsidePoint

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -140,7 +140,7 @@ void faceSet::sync(const polyMesh& mesh)
}
reduce(nAdded, sumOp<label>());
if (nAdded > 0)
if (debug && nAdded > 0)
{
Info<< "Added an additional " << nAdded
<< " faces on coupled patches. "

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -237,27 +237,6 @@ void Foam::surfaceSets::getSurfaceSets
// Construct search engine on mesh
meshSearch queryMesh(mesh, true);
// Check all 'outside' points
forAll(outsidePts, outsideI)
{
const point& outsidePoint = outsidePts[outsideI];
// Find cell point is in. Linear search.
if (queryMesh.findCell(outsidePoint, -1, false) == -1)
{
FatalErrorIn
(
"surfaceSets::getSurfaceSets"
"(const polyMesh&, const fileName&, const triSurface&"
", const triSurfaceSearch&, const pointField&"
", labelHashSet&, labelHashSet&, labelHashSet&)"
) << "outsidePoint " << outsidePoint
<< " is not inside any cell"
<< exit(FatalError);
}
}
// Cut faces with surface and classify cells
cellClassification cellType
(

View File

@ -2958,7 +2958,6 @@ char *timestring ( void )
# define TIME_SIZE 29
const struct tm *tm;
size_t len;
time_t now;
char *s;
@ -2967,7 +2966,7 @@ char *timestring ( void )
s = new char[TIME_SIZE];
len = strftime ( s, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm );
strftime ( s, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm );
return s;
# undef TIME_SIZE

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -83,20 +83,15 @@ Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::restrain
) const
{
vector refDir = rotationTensor(vector(1, 0 ,0), axis_) & vector(0, 1, 0);
vector oldDir = refQ_ & refDir;
vector newDir = motion.orientation() & refDir;
if (mag(oldDir & axis_) > 0.95 || mag(newDir & axis_) > 0.95)
{
// Directions getting close to the axis, change reference
refDir = rotationTensor(vector(1, 0 ,0), axis_) & vector(0, 0, 1);
vector oldDir = refQ_ & refDir;
vector newDir = motion.orientation() & refDir;
oldDir = refQ_ & refDir;
newDir = motion.orientation() & refDir;
}
// Removing any axis component from oldDir and newDir and normalising

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -87,7 +87,6 @@ Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::restrain
vector refDir = rotationTensor(vector(1, 0 ,0), axis_) & vector(0, 1, 0);
vector oldDir = refQ_ & refDir;
vector newDir = motion.orientation() & refDir;
if (mag(oldDir & axis_) > 0.95 || mag(newDir & axis_) > 0.95)
@ -96,9 +95,8 @@ Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::restrain
refDir = rotationTensor(vector(1, 0 ,0), axis_) & vector(0, 0, 1);
vector oldDir = refQ_ & refDir;
vector newDir = motion.orientation() & refDir;
oldDir = refQ_ & refDir;
newDir = motion.orientation() & refDir;
}
// Removing any axis component from oldDir and newDir and normalising

View File

@ -114,6 +114,8 @@ void Foam::regionModels::regionModel1D::initialise()
boundaryFaceCells_[localPyrolysisFaceI].transfer(cellIDs);
localPyrolysisFaceI++;
nLayers_ = nCells;
}
}
@ -266,6 +268,7 @@ Foam::regionModels::regionModel1D::regionModel1D(const fvMesh& mesh)
boundaryFaceFaces_(),
boundaryFaceCells_(),
boundaryFaceOppositeFace_(),
nLayers_(0),
nMagSfPtr_(NULL),
moveMesh_(false)
{}
@ -283,6 +286,7 @@ Foam::regionModels::regionModel1D::regionModel1D
boundaryFaceFaces_(regionMesh().nCells()),
boundaryFaceCells_(regionMesh().nCells()),
boundaryFaceOppositeFace_(regionMesh().nCells()),
nLayers_(0),
nMagSfPtr_(NULL),
moveMesh_(true)
{

View File

@ -88,6 +88,9 @@ protected:
//- Global boundary face IDs oppossite coupled patch
labelList boundaryFaceOppositeFace_;
//- Number of layers in the region
label nLayers_;
// Geometry
@ -115,7 +118,7 @@ protected:
public:
//- Runtime type information
TypeName("regionModel");
TypeName("regionModel1D");
// Constructors
@ -152,6 +155,9 @@ public:
//- Return the global boundary face IDs oppossite coupled patch
inline const labelList& boundaryFaceOppositeFace() const;
//- Return the number of layers in the region
inline label nLayers() const;
// Geometry

View File

@ -49,6 +49,12 @@ Foam::regionModels::regionModel1D::boundaryFaceOppositeFace() const
}
inline Foam::label Foam::regionModels::regionModel1D::nLayers() const
{
return nLayers_;
}
inline const Foam::surfaceScalarField&
Foam::regionModels::regionModel1D::nMagSf() const
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -46,15 +46,14 @@ Foam::sampledPatch::sampledPatch
(
const word& name,
const polyMesh& mesh,
const word& patchName,
const wordReList& patchNames,
const bool triangulate
)
:
sampledSurface(name, mesh),
patchName_(patchName),
patchNames_(patchNames),
triangulate_(triangulate),
needsUpdate_(true),
patchFaceLabels_(0)
needsUpdate_(true)
{}
@ -66,10 +65,9 @@ Foam::sampledPatch::sampledPatch
)
:
sampledSurface(name, mesh, dict),
patchName_(dict.lookup("patchName")),
patchNames_(dict.lookup("patches")),
triangulate_(dict.lookupOrDefault("triangulate", false)),
needsUpdate_(true),
patchFaceLabels_(0)
needsUpdate_(true)
{}
@ -81,6 +79,20 @@ Foam::sampledPatch::~sampledPatch()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelList& Foam::sampledPatch::patchIDs() const
{
if (patchIDs_.empty())
{
patchIDs_ = mesh().boundaryMesh().patchSet
(
patchNames_,
false
).sortedToc();
}
return patchIDs_;
}
bool Foam::sampledPatch::needsUpdate() const
{
return needsUpdate_;
@ -97,7 +109,10 @@ bool Foam::sampledPatch::expire()
sampledSurface::clearGeom();
MeshStorage::clear();
patchIDs_.clear();
patchIndex_.clear();
patchFaceLabels_.clear();
patchStart_.clear();
needsUpdate_ = true;
return true;
@ -111,31 +126,67 @@ bool Foam::sampledPatch::update()
return false;
}
const label patchI = mesh().boundaryMesh().findPatchID(patchName_);
if (patchI != -1)
label sz = 0;
forAll(patchIDs(), i)
{
const polyPatch& p = mesh().boundaryMesh()[patchI];
this->storedPoints() = p.localPoints();
this->storedFaces() = p.localFaces();
label patchI = patchIDs()[i];
const polyPatch& pp = mesh().boundaryMesh()[patchI];
// an identity map
patchFaceLabels_.setSize(faces().size());
forAll(patchFaceLabels_, i)
if (isA<emptyPolyPatch>(pp))
{
patchFaceLabels_[i] = i;
FatalErrorIn("sampledPatch::update()")
<< "Cannot sample an empty patch. Patch " << pp.name()
<< exit(FatalError);
}
// triangulate uses remapFaces()
// - this is somewhat less efficient since it recopies the faces
// that we just created, but we probably don't want to do this
// too often anyhow.
if (triangulate_)
sz += pp.size();
}
// For every face (or triangle) the originating patch and local face in the
// patch.
patchIndex_.setSize(sz);
patchFaceLabels_.setSize(sz);
patchStart_.setSize(patchIDs().size());
labelList meshFaceLabels(sz);
sz = 0;
forAll(patchIDs(), i)
{
label patchI = patchIDs()[i];
patchStart_[i] = sz;
const polyPatch& pp = mesh().boundaryMesh()[patchI];
forAll(pp, j)
{
MeshStorage::triangulate();
patchIndex_[sz] = i;
patchFaceLabels_[sz] = j;
meshFaceLabels[sz] = pp.start()+j;
sz++;
}
}
indirectPrimitivePatch allPatches
(
IndirectList<face>(mesh().faces(), meshFaceLabels),
mesh().points()
);
this->storedPoints() = allPatches.localPoints();
this->storedFaces() = allPatches.localFaces();
// triangulate uses remapFaces()
// - this is somewhat less efficient since it recopies the faces
// that we just created, but we probably don't want to do this
// too often anyhow.
if (triangulate_)
{
MeshStorage::triangulate();
}
if (debug)
{
print(Pout);
@ -148,10 +199,7 @@ bool Foam::sampledPatch::update()
// remap action on triangulation
void Foam::sampledPatch::remapFaces
(
const labelUList& faceMap
)
void Foam::sampledPatch::remapFaces(const labelUList& faceMap)
{
// recalculate the cells cut
if (&faceMap && faceMap.size())
@ -161,11 +209,27 @@ void Foam::sampledPatch::remapFaces
(
UIndirectList<label>(patchFaceLabels_, faceMap)
);
patchIndex_ = labelList
(
UIndirectList<label>(patchIndex_, faceMap)
);
// Redo patchStart.
if (patchIndex_.size() > 0)
{
patchStart_[patchIndex_[0]] = 0;
for (label i = 1; i < patchIndex_.size(); i++)
{
if (patchIndex_[i] != patchIndex_[i-1])
{
patchStart_[patchIndex_[i]] = i;
}
}
}
}
}
Foam::tmp<Foam::scalarField> Foam::sampledPatch::sample
(
const volScalarField& vField
@ -257,7 +321,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledPatch::interpolate
void Foam::sampledPatch::print(Ostream& os) const
{
os << "sampledPatch: " << name() << " :"
<< " patch:" << patchName()
<< " patches:" << patchNames()
<< " faces:" << faces().size()
<< " points:" << points().size();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,7 +25,7 @@ Class
Foam::sampledPatch
Description
A sampledSurface on a patch. Non-triangulated by default.
A sampledSurface on patches. Non-triangulated by default.
SourceFiles
sampledPatch.C
@ -57,8 +57,11 @@ class sampledPatch
// Private data
//- Name of patch
const word patchName_;
//- Name of patches
const wordReList patchNames_;
//- Corresponding patchIDs
mutable labelList patchIDs_;
//- Triangulated faces or keep faces as is
bool triangulate_;
@ -66,11 +69,16 @@ class sampledPatch
//- Track if the surface needs an update
mutable bool needsUpdate_;
//- Local patch face labels
//- For every face (or triangle) the originating patch
labelList patchIndex_;
//- For every face (or triangle) the index in the originating patch
labelList patchFaceLabels_;
// Private Member Functions
//- Start indices (in patchFaceLabels_) of patches
labelList patchStart_;
// Private Member Functions
//- sample field on faces
template <class Type>
@ -79,15 +87,34 @@ class sampledPatch
const GeometricField<Type, fvPatchField, volMesh>& vField
) const;
template <class Type>
tmp<Field<Type> >
interpolateField(const interpolation<Type>&) const;
//- remap action on triangulation or cleanup
virtual void remapFaces(const labelUList& faceMap);
protected:
const wordReList& patchNames() const
{
return patchNames_;
}
const labelList& patchIDs() const;
const labelList& patchStart() const
{
return patchStart_;
}
const labelList& patchFaceLabels() const
{
return patchFaceLabels_;
}
public:
//- Runtime type information
@ -101,7 +128,7 @@ public:
(
const word& name,
const polyMesh& mesh,
const word& patchName,
const wordReList& patchNames,
const bool triangulate = false
);
@ -133,21 +160,6 @@ public:
virtual bool update();
const word patchName() const
{
return patchName_;
}
label patchIndex() const
{
return mesh().boundaryMesh().findPatchID(patchName_);
}
const labelList& patchFaceLabels() const
{
return patchFaceLabels_;
}
//- Points of surface
virtual const pointField& points() const
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -37,15 +37,11 @@ Foam::sampledPatch::sampleField
// One value per face
tmp<Field<Type> > tvalues(new Field<Type>(patchFaceLabels_.size()));
Field<Type>& values = tvalues();
if (patchIndex() != -1)
forAll(patchFaceLabels_, i)
{
const Field<Type>& bField = vField.boundaryField()[patchIndex()];
forAll(patchFaceLabels_, elemI)
{
values[elemI] = bField[patchFaceLabels_[elemI]];
}
label patchI = patchIDs_[patchIndex_[i]];
const Field<Type>& bField = vField.boundaryField()[patchI];
values[i] = bField[patchFaceLabels_[i]];
}
return tvalues;
@ -63,34 +59,33 @@ Foam::sampledPatch::interpolateField
tmp<Field<Type> > tvalues(new Field<Type>(points().size()));
Field<Type>& values = tvalues();
if (patchIndex() != -1)
const labelList& own = mesh().faceOwner();
boolList pointDone(points().size(), false);
forAll(faces(), cutFaceI)
{
const polyPatch& patch = mesh().boundaryMesh()[patchIndex()];
const labelList& own = mesh().faceOwner();
label patchI = patchIDs_[patchIndex_[cutFaceI]];
const polyPatch& pp = mesh().boundaryMesh()[patchI];
label patchFaceI = patchFaceLabels()[cutFaceI];
const face& f = faces()[cutFaceI];
boolList pointDone(points().size(), false);
forAll(faces(), cutFaceI)
forAll(f, faceVertI)
{
const face& f = faces()[cutFaceI];
label pointI = f[faceVertI];
forAll(f, faceVertI)
if (!pointDone[pointI])
{
label pointI = f[faceVertI];
label faceI = patchFaceI + pp.start();
label cellI = own[faceI];
if (!pointDone[pointI])
{
label faceI = patchFaceLabels()[cutFaceI] + patch.start();
label cellI = own[faceI];
values[pointI] = interpolator.interpolate
(
points()[pointI],
cellI,
faceI
);
pointDone[pointI] = true;
}
values[pointI] = interpolator.interpolate
(
points()[pointI],
cellI,
faceI
);
pointDone[pointI] = true;
}
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -56,15 +56,27 @@ Foam::sampledPatchInternalField::sampledPatchInternalField
)
:
sampledPatch(name, mesh, dict),
directMappedPatchBase
(
mesh.boundaryMesh()[sampledPatch::patchIndex()],
mesh.name(), // sampleRegion
directMappedPatchBase::NEARESTCELL, // sampleMode
word::null, // samplePatch
-readScalar(dict.lookup("distance"))
)
{}
mappers_(patchIDs().size())
{
const scalar distance = readScalar(dict.lookup("distance"));
forAll(patchIDs(), i)
{
label patchI = patchIDs()[i];
mappers_.set
(
i,
new directMappedPatchBase
(
mesh.boundaryMesh()[patchI],
mesh.name(), // sampleRegion
directMappedPatchBase::NEARESTCELL, // sampleMode
word::null, // samplePatch
-distance // sample inside my domain
)
);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -167,7 +179,7 @@ Foam::tmp<Foam::tensorField> Foam::sampledPatchInternalField::interpolate
void Foam::sampledPatchInternalField::print(Ostream& os) const
{
os << "sampledPatchInternalField: " << name() << " :"
<< " patch:" << patchName()
<< " patches:" << patchNames()
<< " faces:" << faces().size()
<< " points:" << points().size();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,9 +54,13 @@ namespace Foam
class sampledPatchInternalField
:
public sampledPatch,
public directMappedPatchBase
public sampledPatch
{
// Private data
//- Mapping engines
PtrList<directMappedPatchBase> mappers_;
// Private Member Functions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,20 +36,27 @@ Foam::sampledPatchInternalField::sampleField
const GeometricField<Type, fvPatchField, volMesh>& vField
) const
{
const mapDistribute& distMap = map();
// One value per face
tmp<Field<Type> > tvalues(new Field<Type>(patchFaceLabels().size()));
Field<Type>& values = tvalues();
if (patchIndex() != -1)
forAll(patchStart(), i)
{
// Get patchface wise data by sampling internal field
Field<Type> interpVals = vField.internalField();
distMap.distribute(interpVals);
mappers_[i].map().distribute(interpVals);
forAll(patchFaceLabels(), elemI)
// Store at correct position in values
label end =
(
i < patchStart().size()-1
? patchStart()[i+1]
: patchFaceLabels().size()
);
for (label triI = patchStart()[i]; triI < end; triI++)
{
values[elemI] = interpVals[patchFaceLabels()[elemI]];
values[triI] = interpVals[patchFaceLabels()[triI]];
}
}
@ -64,19 +71,24 @@ Foam::sampledPatchInternalField::interpolateField
const interpolation<Type>& interpolator
) const
{
// One value per vertex
label sz = 0;
forAll(patchIDs(), i)
{
sz += mesh().boundaryMesh()[patchIDs()[i]].size();
}
if (patchIndex() != -1)
Field<Type> allPatchVals(sz);
sz = 0;
forAll(patchIDs(), i)
{
// See directMappedFixedValueFvPatchField
const mapDistribute& distMap = map();
const polyPatch& pp = mesh().boundaryMesh()[patchIndex()];
const mapDistribute& distMap = mappers_[i].map();
// Send back sample points to processor that holds the cell.
// Mark cells with point::max so we know which ones we need
// to interpolate (since expensive).
vectorField samples(samplePoints());
vectorField samples(mappers_[i].samplePoints());
distMap.reverseDistribute(mesh().nCells(), point::max, samples);
Field<Type> patchVals(mesh().nCells());
@ -96,18 +108,35 @@ Foam::sampledPatchInternalField::interpolateField
distMap.distribute(patchVals);
// Now patchVals holds the interpolated data in patch face order.
// Interpolate to points. Note: points are patch.localPoints() so
// can use standard interpolation
// Collect.
SubList<Type>(allPatchVals, patchVals.size(), sz).assign(patchVals);
sz += patchVals.size();
}
return PrimitivePatchInterpolation<primitivePatch>
(
pp
).faceToPointInterpolate(patchVals);
}
else
// Interpolate to points. Reconstruct the patch of all faces to aid
// interpolation.
labelList meshFaceLabels(allPatchVals.size());
sz = 0;
forAll(patchIDs(), i)
{
return tmp<Field<Type> >(new Field<Type>(points().size()));
const polyPatch& pp = mesh().boundaryMesh()[patchIDs()[i]];
forAll(pp, i)
{
meshFaceLabels[sz++] = pp.start()+i;
}
}
indirectPrimitivePatch allPatches
(
IndirectList<face>(mesh().faces(), meshFaceLabels),
mesh().points()
);
return PrimitivePatchInterpolation<indirectPrimitivePatch>
(
allPatches
).faceToPointInterpolate(allPatchVals);
}

View File

@ -197,7 +197,7 @@ Foam::scalar Foam::radiation::radiativeIntensityRay::correct()
1.0/constant::mathematical::pi*omega_
*(
k*blackBody_.bLambda(lambdaI)
+ absorptionEmission_.ECont(lambdaI)
+ absorptionEmission_.ECont(lambdaI)/4
)
);

View File

@ -102,7 +102,6 @@ Foam::radiation::viewFactor::viewFactor(const volScalarField& T)
iterCounter_(0),
pivotIndices_(0)
{
const polyBoundaryMesh& coarsePatches = coarseMesh_.boundaryMesh();
const volScalarField::GeometricBoundaryField& Qrp = Qr_.boundaryField();
@ -116,7 +115,7 @@ Foam::radiation::viewFactor::viewFactor(const volScalarField& T)
{
selectedPatches_[count] = QrPatchI.patch().index();
nLocalCoarseFaces_ += coarsePatches[patchI].size();
count ++;
count++;
}
}
@ -124,8 +123,8 @@ Foam::radiation::viewFactor::viewFactor(const volScalarField& T)
if (debug)
{
Pout << "SelectedPatches:" << selectedPatches_ << endl;
Pout << "Number of coarse faces:" << nLocalCoarseFaces_ << endl;
Pout<< "Selected patches:" << selectedPatches_ << endl;
Pout<< "Number of coarse faces:" << nLocalCoarseFaces_ << endl;
}
totalNCoarseFaces_ = nLocalCoarseFaces_;
@ -133,7 +132,7 @@ Foam::radiation::viewFactor::viewFactor(const volScalarField& T)
if (Pstream::master())
{
Info << "Total number of clusters : " << totalNCoarseFaces_ << endl;
Info<< "Total number of clusters : " << totalNCoarseFaces_ << endl;
}
labelListIOList subMap
@ -228,7 +227,7 @@ Foam::radiation::viewFactor::viewFactor(const volScalarField& T)
new scalarSquareMatrix(totalNCoarseFaces_, totalNCoarseFaces_, 0.0)
);
Info << "Insert elemets in the matrix.." << endl;
Info<< "Insert elements in the matrix..." << endl;
for (label procI = 0; procI < Pstream::nProcs(); procI++)
{
@ -244,19 +243,19 @@ Foam::radiation::viewFactor::viewFactor(const volScalarField& T)
bool smoothing = readBool(coeffs_.lookup("smoothing"));
if(smoothing)
if (smoothing)
{
Info << "Smoothing the matrix..." << endl;
Info<< "Smoothing the matrix..." << endl;
for(label i=0; i<totalNCoarseFaces_; i++)
for (label i=0; i<totalNCoarseFaces_; i++)
{
scalar sumF = 0.0;
for(label j=0; j<totalNCoarseFaces_; j++)
for (label j=0; j<totalNCoarseFaces_; j++)
{
sumF += Fmatrix_()[i][j];
}
scalar delta = 1.0 - sumF;
for(label j=0; j<totalNCoarseFaces_; j++)
for (label j=0; j<totalNCoarseFaces_; j++)
{
Fmatrix_()[i][j] *= (1.0 - delta/(sumF + 0.001));
}
@ -342,7 +341,7 @@ void Foam::radiation::viewFactor::calculate()
DynamicList<scalar> localCoarseEave(nLocalCoarseFaces_);
DynamicList<scalar> localCoarseHoave(nLocalCoarseFaces_);
forAll (selectedPatches_, i)
forAll(selectedPatches_, i)
{
label patchID = selectedPatches_[i];
@ -364,7 +363,7 @@ void Foam::radiation::viewFactor::calculate()
const labelList& coarsePatchFace = coarseMesh_.patchFaceMap()[patchID];
const labelList& agglom = finalAgglom_[patchID];
label nAgglom = max(agglom)+1;
label nAgglom = max(agglom) + 1;
labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
@ -413,7 +412,7 @@ void Foam::radiation::viewFactor::calculate()
labelList localGlobalIds(nLocalCoarseFaces_);
for (label k = 0; k < nLocalCoarseFaces_; k++)
for(label k = 0; k < nLocalCoarseFaces_; k++)
{
localGlobalIds[k] = globalNumbering.toGlobal(Pstream::myProcNo(), k);
}
@ -479,14 +478,14 @@ void Foam::radiation::viewFactor::calculate()
}
}
Info<< "\nSolving view factor equations.." << endl;
Info<< "\nSolving view factor equations..." << endl;
// Negative coming into the fluid
LUsolve(C, q);
}
else //Constant emissivity
{
// Initial iter calculates CLU and chaches it
if(iterCounter_ == 0)
if (iterCounter_ == 0)
{
for (label i=0; i<totalNCoarseFaces_; i++)
{
@ -503,7 +502,7 @@ void Foam::radiation::viewFactor::calculate()
}
}
}
Info<< "\nDecomposing C matrix.." << endl;
Info<< "\nDecomposing C matrix..." << endl;
LUDecompose(CLU_(), pivotIndices_);
}
@ -538,7 +537,7 @@ void Foam::radiation::viewFactor::calculate()
label globCoarseId = 0;
forAll (selectedPatches_, i)
forAll(selectedPatches_, i)
{
const label patchID = selectedPatches_[i];
scalarField& Qrp = Qr_.boundaryField()[patchID];
@ -575,9 +574,9 @@ void Foam::radiation::viewFactor::calculate()
const scalarField& Qrp = Qr_.boundaryField()[patchID];
const scalarField& magSf = mesh_.magSf().boundaryField()[patchID];
scalar heatFlux = gSum(Qrp*magSf);
Info << "Total heat flux at patch: "
<< patchID << " "
<< heatFlux << " [W]" << endl;
Info<< "Total heat flux at patch: "
<< patchID << " "
<< heatFlux << " [W]" << endl;
}
}
@ -616,13 +615,13 @@ Foam::tmp<Foam::volScalarField> Foam::radiation::viewFactor::Rp() const
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
Foam::radiation::viewFactor::Ru() const
{
tmp<DimensionedField<scalar, volMesh> > tRu
return tmp<DimensionedField<scalar, volMesh> >
(
new DimensionedField<scalar, volMesh>
(
IOobject
(
"tRu",
"Ru",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
@ -633,8 +632,6 @@ Foam::radiation::viewFactor::Ru() const
dimensionedScalar("zero", dimMass/dimLength/pow3(dimTime), 0.0)
)
);
return tRu;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,6 @@ License
\*---------------------------------------------------------------------------*/
inline const Foam::volScalarField& Foam::radiation::viewFactor::Qr() const
{
return Qr_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -51,8 +51,8 @@ namespace porousMedia
Foam::porousMedia::fixedTemperature::fixedTemperature(const porousZone& pZone)
:
thermalModel(pZone, typeName),
T_(readScalar(coeffDict_.lookup("T")))
thermalModel(pZone),
T_(readScalar(thermalCoeffs_.lookup("T")))
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,7 +33,6 @@ Description
#define fixedTemperature_H
#include "thermalModel.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -81,7 +80,7 @@ public:
//- Add the thermal source to the enthalpy equation
virtual void addEnthalpySource
(
const basicThermo& thermo,
const basicThermo&,
const volScalarField& rho,
fvScalarMatrix& hEqn
) const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,7 +33,6 @@ Description
#define noThermalModel_H
#include "thermalModel.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,7 +72,7 @@ public:
//- Add the thermal source to the enthalpy equation
virtual void addEnthalpySource
(
const basicThermo& thermo,
const basicThermo&,
const volScalarField& rho,
fvScalarMatrix& hEqn
) const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,18 +42,18 @@ namespace porousMedia
Foam::porousMedia::thermalModel::thermalModel(const porousZone& pZone)
:
pZone_(pZone),
coeffDict_(dictionary::null)
thermalCoeffs_(pZone.dict().subDictPtr("thermalModel"))
{}
Foam::porousMedia::thermalModel::thermalModel
(
const porousZone& pZone,
const word& modelType
const dictionary& thermalCoeffs
)
:
pZone_(pZone),
coeffDict_(pZone_.dict().subDict(modelType + "Coeffs"))
thermalCoeffs_(thermalCoeffs)
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -63,8 +63,8 @@ protected:
//- Reference to the porous zone
const porousZone& pZone_;
//- Sub-model coefficients dictionary
const dictionary coeffDict_;
//- Thermal model coefficients dictionary
const dictionary thermalCoeffs_;
public:
@ -87,11 +87,11 @@ public:
// Constructors
//- Construct null from porous zone
//- Construct from porous zone, coefficients from "thermalModel" entry
thermalModel(const porousZone&);
//- Construct from porous zone and model type name
thermalModel(const porousZone&, const word& modelType);
//- Construct from porous zone and thermal model coefficients
thermalModel(const porousZone&, const dictionary& thermalCoeffs);
//- Destructor
@ -107,7 +107,7 @@ public:
//- Add the thermal source to the enthalpy equation
virtual void addEnthalpySource
(
const basicThermo& thermo,
const basicThermo&,
const volScalarField& rho,
fvScalarMatrix& hEqn
) const = 0;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -33,7 +33,13 @@ Foam::porousMedia::thermalModel::New
const porousZone& pZone
)
{
const word modelType(pZone.dict().lookup("thermalModel"));
// a missing thermalModel is the same as type "none"
word modelType("none");
if (const dictionary* dictPtr = pZone.dict().subDictPtr("thermalModel"))
{
dictPtr->lookup("type") >> modelType;
}
Info<< "Selecting thermalModel " << modelType << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -51,7 +51,10 @@ void Foam::thermalPorousZone::addEnthalpySource
fvScalarMatrix& hEqn
) const
{
model_->addEnthalpySource(thermo, rho, hEqn);
if (model_.valid())
{
model_->addEnthalpySource(thermo, rho, hEqn);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -127,7 +127,7 @@ public:
//- Add the thermal source to the enthalpy equation
void addEnthalpySource
(
const basicThermo& thermo,
const basicThermo&,
const volScalarField& rho,
fvScalarMatrix& hEqn
) const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,7 +32,8 @@ Description
thermalPorousZone.
The input file \c constant/thermalPorousZone is implemented as
IOPtrList\<thermalPorousZone\> and contains the following type of data:
IOPtrList\<thermalPorousZone\> (but written as a dictionary)
and contains the following type of data:
\verbatim
1
@ -94,7 +95,7 @@ public:
//- Add the thermal source to the enthalpy equation
void addEnthalpySource
(
const basicThermo& thermo,
const basicThermo&,
const volScalarField& rho,
fvScalarMatrix& hEqn
) const;