allow -overwrite in snappyHexMesh

This commit is contained in:
mattijs
2009-06-09 14:02:10 +01:00
parent 92172c5d21
commit 2d9ea72b6a
11 changed files with 180 additions and 58 deletions

View File

@ -96,7 +96,7 @@ void writeMesh
const fvMesh& mesh = meshRefiner.mesh(); const fvMesh& mesh = meshRefiner.mesh();
meshRefiner.printMeshInfo(debug, msg); meshRefiner.printMeshInfo(debug, msg);
Info<< "Writing mesh to time " << mesh.time().timeName() << endl; Info<< "Writing mesh to time " << meshRefiner.timeName() << endl;
meshRefiner.write(meshRefinement::MESH|meshRefinement::SCALARLEVELS, ""); meshRefiner.write(meshRefinement::MESH|meshRefinement::SCALARLEVELS, "");
if (debug & meshRefinement::OBJINTERSECTIONS) if (debug & meshRefinement::OBJINTERSECTIONS)
@ -104,7 +104,7 @@ void writeMesh
meshRefiner.write meshRefiner.write
( (
meshRefinement::OBJINTERSECTIONS, meshRefinement::OBJINTERSECTIONS,
mesh.time().path()/mesh.time().timeName() mesh.time().path()/meshRefiner.timeName()
); );
} }
Info<< "Written mesh in = " Info<< "Written mesh in = "
@ -115,6 +115,7 @@ void writeMesh
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::validOptions.insert("overwrite", "");
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
runTime.functionObjects().off(); runTime.functionObjects().off();
@ -123,6 +124,9 @@ int main(int argc, char *argv[])
Info<< "Read mesh in = " Info<< "Read mesh in = "
<< runTime.cpuTimeIncrement() << " s" << endl; << runTime.cpuTimeIncrement() << " s" << endl;
const bool overwrite = args.optionFound("overwrite");
// Check patches and faceZones are synchronised // Check patches and faceZones are synchronised
mesh.boundaryMesh().checkParallelSync(true); mesh.boundaryMesh().checkParallelSync(true);
meshRefinement::checkCoupledFaceZones(mesh); meshRefinement::checkCoupledFaceZones(mesh);
@ -256,6 +260,7 @@ int main(int argc, char *argv[])
( (
mesh, mesh,
mergeDist, // tolerance used in sorting coordinates mergeDist, // tolerance used in sorting coordinates
overwrite, // overwrite mesh files?
surfaces, // for surface intersection refinement surfaces, // for surface intersection refinement
shells // for volume (inside/outside) refinement shells // for volume (inside/outside) refinement
); );
@ -268,7 +273,7 @@ int main(int argc, char *argv[])
meshRefiner.write meshRefiner.write
( (
debug&meshRefinement::OBJINTERSECTIONS, debug&meshRefinement::OBJINTERSECTIONS,
mesh.time().path()/mesh.time().timeName() mesh.time().path()/meshRefiner.timeName()
); );
@ -369,6 +374,11 @@ int main(int argc, char *argv[])
// Refinement parameters // Refinement parameters
refinementParameters refineParams(refineDict); refinementParameters refineParams(refineDict);
if (!overwrite)
{
const_cast<Time&>(mesh.time())++;
}
refineDriver.doRefine(refineDict, refineParams, wantSnap, motionDict); refineDriver.doRefine(refineDict, refineParams, wantSnap, motionDict);
writeMesh writeMesh
@ -390,6 +400,11 @@ int main(int argc, char *argv[])
// Snap parameters // Snap parameters
snapParameters snapParams(snapDict); snapParameters snapParams(snapDict);
if (!overwrite)
{
const_cast<Time&>(mesh.time())++;
}
snapDriver.doSnap(snapDict, motionDict, snapParams); snapDriver.doSnap(snapDict, motionDict, snapParams);
writeMesh writeMesh
@ -407,6 +422,11 @@ int main(int argc, char *argv[])
// Layer addition parameters // Layer addition parameters
layerParameters layerParams(layerDict, mesh.boundaryMesh()); layerParameters layerParams(layerDict, mesh.boundaryMesh());
if (!overwrite)
{
const_cast<Time&>(mesh.time())++;
}
layerDriver.doLayers layerDriver.doLayers
( (
layerDict, layerDict,

View File

@ -148,6 +148,7 @@ Foam::scalar Foam::autoHexMeshDriver::getMergeDistance(const scalar mergeTol)
Foam::autoHexMeshDriver::autoHexMeshDriver Foam::autoHexMeshDriver::autoHexMeshDriver
( (
fvMesh& mesh, fvMesh& mesh,
const bool overwrite,
const dictionary& dict, const dictionary& dict,
const dictionary& decomposeDict const dictionary& decomposeDict
) )
@ -308,6 +309,7 @@ Foam::autoHexMeshDriver::autoHexMeshDriver
( (
mesh, mesh,
mergeDist_, // tolerance used in sorting coordinates mergeDist_, // tolerance used in sorting coordinates
overwrite,
surfaces(), surfaces(),
shells() shells()
) )
@ -321,7 +323,7 @@ Foam::autoHexMeshDriver::autoHexMeshDriver
meshRefinerPtr_().write meshRefinerPtr_().write
( (
debug_&meshRefinement::OBJINTERSECTIONS, debug_&meshRefinement::OBJINTERSECTIONS,
mesh_.time().path()/mesh_.time().timeName() mesh_.time().path()/meshRefinerPtr_().timeName()
); );
} }
@ -447,7 +449,7 @@ void Foam::autoHexMeshDriver::writeMesh(const string& msg) const
const meshRefinement& meshRefiner = meshRefinerPtr_(); const meshRefinement& meshRefiner = meshRefinerPtr_();
meshRefiner.printMeshInfo(debug_, msg); meshRefiner.printMeshInfo(debug_, msg);
Info<< "Writing mesh to time " << mesh_.time().timeName() << endl; Info<< "Writing mesh to time " << meshRefiner.timeName() << endl;
meshRefiner.write(meshRefinement::MESH|meshRefinement::SCALARLEVELS, ""); meshRefiner.write(meshRefinement::MESH|meshRefinement::SCALARLEVELS, "");
if (debug_ & meshRefinement::OBJINTERSECTIONS) if (debug_ & meshRefinement::OBJINTERSECTIONS)
@ -455,7 +457,7 @@ void Foam::autoHexMeshDriver::writeMesh(const string& msg) const
meshRefiner.write meshRefiner.write
( (
meshRefinement::OBJINTERSECTIONS, meshRefinement::OBJINTERSECTIONS,
mesh_.time().path()/mesh_.time().timeName() mesh_.time().path()/meshRefiner.timeName()
); );
} }
Info<< "Written mesh in = " Info<< "Written mesh in = "

View File

@ -174,6 +174,7 @@ public:
autoHexMeshDriver autoHexMeshDriver
( (
fvMesh& mesh, fvMesh& mesh,
const bool overwrite,
const dictionary& meshDict, const dictionary& meshDict,
const dictionary& decomposeDict const dictionary& decomposeDict
); );

View File

@ -159,12 +159,16 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
mesh.clearOut(); mesh.clearOut();
} }
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
faceCombiner.updateMesh(map); faceCombiner.updateMesh(map);
meshRefiner_.updateMesh(map, labelList(0)); meshRefiner_.updateMesh(map, labelList(0));
for (label iteration = 0; iteration < 100; iteration++) for (label iteration = 0; iteration < 100; iteration++)
{ {
Info<< nl Info<< nl
@ -313,6 +317,11 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
mesh.clearOut(); mesh.clearOut();
} }
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
faceCombiner.updateMesh(map); faceCombiner.updateMesh(map);
// Renumber restore maps // Renumber restore maps
@ -336,7 +345,7 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
if (debug) if (debug)
{ {
Pout<< "Writing merged-faces mesh to time " Pout<< "Writing merged-faces mesh to time "
<< mesh.time().timeName() << nl << endl; << meshRefiner_.timeName() << nl << endl;
mesh.write(); mesh.write();
} }
} }
@ -380,6 +389,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoLayerDriver::doRemovePoints
mesh.clearOut(); mesh.clearOut();
} }
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
pointRemover.updateMesh(map); pointRemover.updateMesh(map);
meshRefiner_.updateMesh(map, labelList(0)); meshRefiner_.updateMesh(map, labelList(0));
@ -433,6 +447,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoLayerDriver::doRestorePoints
mesh.clearOut(); mesh.clearOut();
} }
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
pointRemover.updateMesh(map); pointRemover.updateMesh(map);
meshRefiner_.updateMesh(map, labelList(0)); meshRefiner_.updateMesh(map, labelList(0));
@ -656,7 +675,7 @@ Foam::label Foam::autoLayerDriver::mergeEdgesUndo
if (debug) if (debug)
{ {
Pout<< "Writing merged-edges mesh to time " Pout<< "Writing merged-edges mesh to time "
<< mesh.time().timeName() << nl << endl; << meshRefiner_.timeName() << nl << endl;
mesh.write(); mesh.write();
} }
} }
@ -2724,7 +2743,7 @@ void Foam::autoLayerDriver::addLayers
IOobject IOobject
( (
"pointMedialDist", "pointMedialDist",
mesh.time().timeName(), meshRefiner_.timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
@ -2739,7 +2758,7 @@ void Foam::autoLayerDriver::addLayers
IOobject IOobject
( (
"dispVec", "dispVec",
mesh.time().timeName(), meshRefiner_.timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
@ -2754,7 +2773,7 @@ void Foam::autoLayerDriver::addLayers
IOobject IOobject
( (
"medialRatio", "medialRatio",
mesh.time().timeName(), meshRefiner_.timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
@ -2906,7 +2925,7 @@ void Foam::autoLayerDriver::addLayers
); );
const_cast<Time&>(mesh.time())++; const_cast<Time&>(mesh.time())++;
Info<< "Writing shrunk mesh to " << mesh.time().timeName() << endl; Info<< "Writing shrunk mesh to " << meshRefiner_.timeName() << endl;
// See comment in autoSnapDriver why we should not remove meshPhi // See comment in autoSnapDriver why we should not remove meshPhi
// using mesh.clearPout(). // using mesh.clearPout().
@ -3007,6 +3026,11 @@ void Foam::autoLayerDriver::addLayers
//?neccesary? Update fields //?neccesary? Update fields
newMesh.updateMesh(map); newMesh.updateMesh(map);
if (meshRefiner_.overwrite())
{
newMesh.setInstance(meshRefiner_.oldInstance());
}
// Update numbering on addLayer: // Update numbering on addLayer:
// - cell/point labels to be newMesh. // - cell/point labels to be newMesh.
// - patchFaces to remain in oldMesh order. // - patchFaces to remain in oldMesh order.
@ -3029,7 +3053,7 @@ void Foam::autoLayerDriver::addLayers
if (debug) if (debug)
{ {
Info<< "Writing layer mesh to " << mesh.time().timeName() << endl; Info<< "Writing layer mesh to " << meshRefiner_.timeName() << endl;
newMesh.write(); newMesh.write();
cellSet addedCellSet cellSet addedCellSet
( (
@ -3108,6 +3132,11 @@ void Foam::autoLayerDriver::addLayers
mesh.clearOut(); mesh.clearOut();
} }
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
meshRefiner_.updateMesh(map, labelList(0)); meshRefiner_.updateMesh(map, labelList(0));
@ -3176,8 +3205,6 @@ void Foam::autoLayerDriver::doLayers
<< "----------------------------------" << nl << "----------------------------------" << nl
<< endl; << endl;
const_cast<Time&>(mesh.time())++;
Info<< "Using mesh parameters " << motionDict << nl << endl; Info<< "Using mesh parameters " << motionDict << nl << endl;
// Merge coplanar boundary faces // Merge coplanar boundary faces

View File

@ -344,8 +344,8 @@ void Foam::autoRefineDriver::removeInsideCells
if (debug) if (debug)
{ {
Pout<< "Writing subsetted mesh to time " Pout<< "Writing subsetted mesh to time "
<< mesh.time().timeName() << '.' << endl; << meshRefiner_.timeName() << '.' << endl;
meshRefiner_.write(debug, mesh.time().path()/mesh.time().timeName()); meshRefiner_.write(debug, mesh.time().path()/meshRefiner_.timeName());
Pout<< "Dumped mesh in = " Pout<< "Dumped mesh in = "
<< mesh.time().cpuTimeIncrement() << " s\n" << nl << endl; << mesh.time().cpuTimeIncrement() << " s\n" << nl << endl;
} }
@ -561,11 +561,11 @@ void Foam::autoRefineDriver::zonify
if (debug) if (debug)
{ {
Pout<< "Writing zoned mesh to time " Pout<< "Writing zoned mesh to time "
<< mesh.time().timeName() << '.' << endl; << meshRefiner_.timeName() << '.' << endl;
meshRefiner_.write meshRefiner_.write
( (
debug, debug,
mesh.time().path()/mesh.time().timeName() mesh.time().path()/meshRefiner_.timeName()
); );
} }
@ -653,8 +653,8 @@ void Foam::autoRefineDriver::splitAndMergeBaffles
if (debug) if (debug)
{ {
Pout<< "Writing handleProblemCells mesh to time " Pout<< "Writing handleProblemCells mesh to time "
<< mesh.time().timeName() << '.' << endl; << meshRefiner_.timeName() << '.' << endl;
meshRefiner_.write(debug, mesh.time().path()/mesh.time().timeName()); meshRefiner_.write(debug, mesh.time().path()/meshRefiner_.timeName());
} }
} }
@ -712,9 +712,6 @@ void Foam::autoRefineDriver::doRefine
const fvMesh& mesh = meshRefiner_.mesh(); const fvMesh& mesh = meshRefiner_.mesh();
const_cast<Time&>(mesh.time())++;
// Check that all the keep points are inside the mesh. // Check that all the keep points are inside the mesh.
refineParams.findCells(mesh); refineParams.findCells(mesh);

View File

@ -557,7 +557,7 @@ Foam::tmp<Foam::scalarField> Foam::autoSnapDriver::edgePatchDist
// IOobject // IOobject
// ( // (
// "pointDist", // "pointDist",
// mesh.DB().timeName(), // meshRefiner_.timeName(),
// mesh.DB(), // mesh.DB(),
// IOobject::NO_READ, // IOobject::NO_READ,
// IOobject::AUTO_WRITE // IOobject::AUTO_WRITE
@ -580,7 +580,7 @@ Foam::tmp<Foam::scalarField> Foam::autoSnapDriver::edgePatchDist
// pointDist[pointI] /= mesh.pointEdges()[pointI].size(); // pointDist[pointI] /= mesh.pointEdges()[pointI].size();
// } // }
// Info<< "Writing patch distance to " << pointDist.name() // Info<< "Writing patch distance to " << pointDist.name()
// << " at time " << mesh.DB().timeName() << endl; // << " at time " << meshRefiner_.timeName() << endl;
// //
// pointDist.write(); // pointDist.write();
//} //}
@ -750,7 +750,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoSnapDriver::createZoneBaffles
{ {
const_cast<Time&>(mesh.time())++; const_cast<Time&>(mesh.time())++;
Pout<< "Writing baffled mesh to time " Pout<< "Writing baffled mesh to time "
<< mesh.time().timeName() << endl; << meshRefiner_.timeName() << endl;
mesh.write(); mesh.write();
} }
} }
@ -899,7 +899,7 @@ void Foam::autoSnapDriver::preSmoothPatch
if (debug) if (debug)
{ {
const_cast<Time&>(mesh.time())++; const_cast<Time&>(mesh.time())++;
Pout<< "Writing patch smoothed mesh to time " << mesh.time().timeName() Pout<< "Writing patch smoothed mesh to time " << meshRefiner_.timeName()
<< endl; << endl;
mesh.write(); mesh.write();
@ -1193,7 +1193,7 @@ void Foam::autoSnapDriver::smoothDisplacement
if (debug) if (debug)
{ {
const_cast<Time&>(mesh.time())++; const_cast<Time&>(mesh.time())++;
Pout<< "Writing smoothed mesh to time " << mesh.time().timeName() Pout<< "Writing smoothed mesh to time " << meshRefiner_.timeName()
<< endl; << endl;
// Moving mesh creates meshPhi. Can be cleared out by a mesh.clearOut // Moving mesh creates meshPhi. Can be cleared out by a mesh.clearOut
@ -1255,7 +1255,7 @@ void Foam::autoSnapDriver::scaleMesh
if (debug) if (debug)
{ {
const_cast<Time&>(mesh.time())++; const_cast<Time&>(mesh.time())++;
Pout<< "Writing scaled mesh to time " << mesh.time().timeName() Pout<< "Writing scaled mesh to time " << meshRefiner_.timeName()
<< endl; << endl;
mesh.write(); mesh.write();
@ -1447,8 +1447,6 @@ void Foam::autoSnapDriver::doSnap
<< "--------------" << nl << "--------------" << nl
<< endl; << endl;
const_cast<Time&>(mesh.time())++;
// Get the labels of added patches. // Get the labels of added patches.
labelList adaptPatchIDs(meshRefiner_.meshedPatches()); labelList adaptPatchIDs(meshRefiner_.meshedPatches());

View File

@ -465,6 +465,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::doRemoveCells
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite_)
{
mesh_.setInstance(oldInstance_);
}
// Update local mesh data // Update local mesh data
cellRemover.updateMesh(map); cellRemover.updateMesh(map);
@ -817,12 +822,15 @@ Foam::meshRefinement::meshRefinement
( (
fvMesh& mesh, fvMesh& mesh,
const scalar mergeDistance, const scalar mergeDistance,
const bool overwrite,
const refinementSurfaces& surfaces, const refinementSurfaces& surfaces,
const shellSurfaces& shells const shellSurfaces& shells
) )
: :
mesh_(mesh), mesh_(mesh),
mergeDistance_(mergeDistance), mergeDistance_(mergeDistance),
overwrite_(overwrite),
oldInstance_(mesh.pointsInstance()),
surfaces_(surfaces), surfaces_(surfaces),
shells_(shells), shells_(shells),
meshCutter_ meshCutter_
@ -1199,8 +1207,6 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
// Helper function to get intersected faces // Helper function to get intersected faces
Foam::labelList Foam::meshRefinement::intersectedFaces() const Foam::labelList Foam::meshRefinement::intersectedFaces() const
{ {
// Mark all faces that will become baffles
label nBoundaryFaces = 0; label nBoundaryFaces = 0;
forAll(surfaceIndex_, faceI) forAll(surfaceIndex_, faceI)
@ -1226,9 +1232,7 @@ Foam::labelList Foam::meshRefinement::intersectedFaces() const
// Helper function to get points used by faces // Helper function to get points used by faces
Foam::labelList Foam::meshRefinement::intersectedPoints Foam::labelList Foam::meshRefinement::intersectedPoints() const
(
) const
{ {
const faceList& faces = mesh_.faces(); const faceList& faces = mesh_.faces();
@ -1384,7 +1388,7 @@ Foam::tmp<Foam::pointVectorField> Foam::meshRefinement::makeDisplacementField
IOobject IOobject
( (
"pointDisplacement", "pointDisplacement",
mesh.time().timeName(), mesh.time().timeName(), //timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
@ -2059,6 +2063,20 @@ void Foam::meshRefinement::printMeshInfo(const bool debug, const string& msg)
} }
//- Return either time().constant() or oldInstance
Foam::word Foam::meshRefinement::timeName() const
{
if (overwrite_ && mesh_.time().timeIndex() == 0)
{
return oldInstance_;
}
else
{
return mesh_.time().timeName();
}
}
void Foam::meshRefinement::dumpRefinementLevel() const void Foam::meshRefinement::dumpRefinementLevel() const
{ {
volScalarField volRefLevel volScalarField volRefLevel
@ -2066,7 +2084,7 @@ void Foam::meshRefinement::dumpRefinementLevel() const
IOobject IOobject
( (
"cellLevel", "cellLevel",
mesh_.time().timeName(), timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE, IOobject::AUTO_WRITE,
@ -2093,7 +2111,7 @@ void Foam::meshRefinement::dumpRefinementLevel() const
IOobject IOobject
( (
"pointLevel", "pointLevel",
mesh_.time().timeName(), timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,

View File

@ -110,6 +110,12 @@ private:
//- tolerance used for sorting coordinates (used in 'less' routine) //- tolerance used for sorting coordinates (used in 'less' routine)
const scalar mergeDistance_; const scalar mergeDistance_;
//- overwrite the mesh?
const bool overwrite_;
//- Instance of mesh upon construction. Used when in overwrite_ mode.
const word oldInstance_;
//- All surface-intersection interaction //- All surface-intersection interaction
const refinementSurfaces& surfaces_; const refinementSurfaces& surfaces_;
@ -167,9 +173,6 @@ private:
//- Find any intersection of surface. Store in surfaceIndex_. //- Find any intersection of surface. Store in surfaceIndex_.
void updateIntersections(const labelList& changedFaces); void updateIntersections(const labelList& changedFaces);
//- Set instance of all local IOobjects
void setInstance(const fileName&);
//- Remove cells. Put exposedFaces into exposedPatchIDs. //- Remove cells. Put exposedFaces into exposedPatchIDs.
autoPtr<mapPolyMesh> doRemoveCells autoPtr<mapPolyMesh> doRemoveCells
( (
@ -478,6 +481,7 @@ public:
( (
fvMesh& mesh, fvMesh& mesh,
const scalar mergeDistance, const scalar mergeDistance,
const bool overwrite,
const refinementSurfaces&, const refinementSurfaces&,
const shellSurfaces& const shellSurfaces&
); );
@ -502,6 +506,18 @@ public:
return mergeDistance_; return mergeDistance_;
} }
//- Overwrite the mesh?
bool overwrite() const
{
return overwrite_;
}
//- (points)instance of mesh upon construction
const word& oldInstance() const
{
return oldInstance_;
}
//- reference to surface search engines //- reference to surface search engines
const refinementSurfaces& surfaces() const const refinementSurfaces& surfaces() const
{ {
@ -768,6 +784,13 @@ public:
//- Print some mesh stats. //- Print some mesh stats.
void printMeshInfo(const bool, const string&) const; void printMeshInfo(const bool, const string&) const;
//- Replacement for Time::timeName() : return oldInstance (if
// overwrite_)
word timeName() const;
//- Set instance of all local IOobjects
void setInstance(const fileName&);
//- Write mesh and all data //- Write mesh and all data
bool write() const; bool write() const;

View File

@ -226,7 +226,13 @@ void Foam::meshRefinement::getBafflePatches
label vertI = 0; label vertI = 0;
if (debug&OBJINTERSECTIONS) if (debug&OBJINTERSECTIONS)
{ {
str.reset(new OFstream(mesh_.time().timePath()/"intersections.obj")); str.reset
(
new OFstream
(
mesh_.time().path()/timeName()/"intersections.obj"
)
);
Pout<< "getBafflePatches : Writing surface intersections to file " Pout<< "getBafflePatches : Writing surface intersections to file "
<< str().name() << nl << endl; << str().name() << nl << endl;
@ -461,6 +467,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::createBaffles
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
//- Redo the intersections on the newly create baffle faces. Note that //- Redo the intersections on the newly create baffle faces. Note that
// this changes also the cell centre positions. // this changes also the cell centre positions.
faceSet baffledFacesSet(mesh_, "baffledFacesSet", 2*nBaffles); faceSet baffledFacesSet(mesh_, "baffledFacesSet", 2*nBaffles);
@ -820,6 +831,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::mergeBaffles
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
// Update intersections. Recalculate intersections on merged faces since // Update intersections. Recalculate intersections on merged faces since
// this seems to give problems? Note: should not be nessecary since // this seems to give problems? Note: should not be nessecary since
// baffles preserve intersections from when they were created. // baffles preserve intersections from when they were created.
@ -1482,7 +1498,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
if (debug) if (debug)
{ {
Pout<< "Writing baffled mesh to time " << mesh_.time().timeName() Pout<< "Writing baffled mesh to time " << timeName()
<< endl; << endl;
write(debug, runTime.path()/"baffles"); write(debug, runTime.path()/"baffles");
Pout<< "Dumped debug data in = " Pout<< "Dumped debug data in = "
@ -1565,7 +1581,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
if (debug) if (debug)
{ {
Pout<< "Writing extra baffled mesh to time " Pout<< "Writing extra baffled mesh to time "
<< mesh_.time().timeName() << endl; << timeName() << endl;
write(debug, runTime.path()/"extraBaffles"); write(debug, runTime.path()/"extraBaffles");
Pout<< "Dumped debug data in = " Pout<< "Dumped debug data in = "
<< runTime.cpuTimeIncrement() << " s\n" << nl << endl; << runTime.cpuTimeIncrement() << " s\n" << nl << endl;
@ -1600,9 +1616,9 @@ void Foam::meshRefinement::baffleAndSplitMesh
if (debug) if (debug)
{ {
Pout<< "Writing subsetted mesh to time " << mesh_.time().timeName() Pout<< "Writing subsetted mesh to time " << timeName()
<< endl; << endl;
write(debug, runTime.timePath()); write(debug, runTime.path()/timeName());
Pout<< "Dumped debug data in = " Pout<< "Dumped debug data in = "
<< runTime.cpuTimeIncrement() << " s\n" << nl << endl; << runTime.cpuTimeIncrement() << " s\n" << nl << endl;
} }
@ -1994,6 +2010,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::dupNonManifoldPoints()
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
// Update intersections. Is mapping only (no faces created, positions stay // Update intersections. Is mapping only (no faces created, positions stay
// same) so no need to recalculate intersections. // same) so no need to recalculate intersections.
updateMesh(map, labelList(0)); updateMesh(map, labelList(0));
@ -2425,6 +2446,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
// None of the faces has changed, only the zones. Still... // None of the faces has changed, only the zones. Still...
updateMesh(map, labelList()); updateMesh(map, labelList());

View File

@ -29,10 +29,6 @@ License
#include "polyTopoChange.H" #include "polyTopoChange.H"
#include "removePoints.H" #include "removePoints.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Merge faces that are in-line. // Merge faces that are in-line.
@ -108,6 +104,11 @@ Foam::label Foam::meshRefinement::mergePatchFaces
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
faceCombiner.updateMesh(map); faceCombiner.updateMesh(map);
// Get the kept faces that need to be recalculated. // Get the kept faces that need to be recalculated.
@ -203,6 +204,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::mergeEdges
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
pointRemover.updateMesh(map); pointRemover.updateMesh(map);
// Get the kept faces that need to be recalculated. // Get the kept faces that need to be recalculated.

View File

@ -1232,6 +1232,11 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::refine
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
// Update intersection info // Update intersection info
updateMesh(map, getChangedFaces(map, cellsToRefine)); updateMesh(map, getChangedFaces(map, cellsToRefine));
@ -1256,12 +1261,12 @@ Foam::meshRefinement::refineAndBalance
if (debug) if (debug)
{ {
Pout<< "Writing refined but unbalanced " << msg Pout<< "Writing refined but unbalanced " << msg
<< " mesh to time " << mesh_.time().timeName() << endl; << " mesh to time " << timeName() << endl;
write write
( (
debug, debug,
mesh_.time().path() mesh_.time().path()
/mesh_.time().timeName() /timeName()
); );
Pout<< "Dumped debug data in = " Pout<< "Dumped debug data in = "
<< mesh_.time().cpuTimeIncrement() << " s" << endl; << mesh_.time().cpuTimeIncrement() << " s" << endl;
@ -1299,12 +1304,11 @@ Foam::meshRefinement::refineAndBalance
if (debug) if (debug)
{ {
Pout<< "Writing balanced " << msg Pout<< "Writing balanced " << msg
<< " mesh to time " << mesh_.time().timeName() << endl; << " mesh to time " << timeName() << endl;
write write
( (
debug, debug,
mesh_.time().path() mesh_.time().path()/timeName()
/mesh_.time().timeName()
); );
Pout<< "Dumped debug data in = " Pout<< "Dumped debug data in = "
<< mesh_.time().cpuTimeIncrement() << " s" << endl; << mesh_.time().cpuTimeIncrement() << " s" << endl;