Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry
2011-11-16 12:26:51 +00:00
8 changed files with 165 additions and 9 deletions

View File

@ -212,7 +212,7 @@ snapControls
//- Maximum relative distance for points to be attracted by surface. //- Maximum relative distance for points to be attracted by surface.
// True distance is this factor times local maximum edge length. // True distance is this factor times local maximum edge length.
// Note: changed(corrected) w.r.t 17x! (17x used 2* tolerance) // Note: changed(corrected) w.r.t 17x! (17x used 2* tolerance)
tolerance 1.0; tolerance 2.0;
//- Number of mesh displacement relaxation iterations. //- Number of mesh displacement relaxation iterations.
nSolveIter 30; nSolveIter 30;

View File

@ -1018,7 +1018,7 @@ int main(int argc, char *argv[])
is is
); );
if (!ok) if (!ok && batch)
{ {
// Exit with error. // Exit with error.
quit = true; quit = true;

View File

@ -35,6 +35,10 @@ Description
#include "pointSet.H" #include "pointSet.H"
#include "globalMeshData.H" #include "globalMeshData.H"
#include "timeSelector.H" #include "timeSelector.H"
#include "IOobjectList.H"
#include "cellZoneSet.H"
#include "faceZoneSet.H"
#include "pointZoneSet.H"
using namespace Foam; using namespace Foam;
@ -51,6 +55,96 @@ void printMesh(const Time& runTime, const polyMesh& mesh)
} }
template<class ZoneType>
void removeZone
(
ZoneMesh<ZoneType, polyMesh>& zones,
const word& setName
)
{
label zoneID = zones.findZoneID(setName);
if (zoneID != -1)
{
Info<< "Removing zone " << setName << " at index " << zoneID << endl;
// Shuffle to last position
labelList oldToNew(zones.size());
label newI = 0;
forAll(oldToNew, i)
{
if (i != zoneID)
{
oldToNew[i] = newI++;
}
}
oldToNew[zoneID] = newI;
zones.reorder(oldToNew);
// Remove last element
zones.setSize(zones.size()-1);
zones.clearAddressing();
zones.write();
}
}
// Physically remove a set
void removeSet
(
const polyMesh& mesh,
const word& setType,
const word& setName
)
{
// Remove the file
IOobjectList objects
(
mesh,
mesh.time().findInstance
(
polyMesh::meshSubDir/"sets",
word::null,
IOobject::READ_IF_PRESENT,
mesh.facesInstance()
),
polyMesh::meshSubDir/"sets"
);
if (objects.found(setName))
{
// Remove file
fileName object = objects[setName]->objectPath();
Info<< "Removing file " << object << endl;
rm(object);
}
// See if zone
if (setType == cellZoneSet::typeName)
{
removeZone
(
const_cast<cellZoneMesh&>(mesh.cellZones()),
setName
);
}
else if (setType == faceZoneSet::typeName)
{
removeZone
(
const_cast<faceZoneMesh&>(mesh.faceZones()),
setName
);
}
else if (setType == pointZoneSet::typeName)
{
removeZone
(
const_cast<pointZoneMesh&>(mesh.pointZones()),
setName
);
}
}
polyMesh::readUpdateState meshReadUpdate(polyMesh& mesh) polyMesh::readUpdateState meshReadUpdate(polyMesh& mesh)
{ {
polyMesh::readUpdateState stat = mesh.readUpdate(); polyMesh::readUpdateState stat = mesh.readUpdate();
@ -284,6 +378,12 @@ int main(int argc, char *argv[])
currentSet().write(); currentSet().write();
break; break;
case topoSetSource::REMOVE:
Info<< " Removing set" << endl;
removeSet(mesh, setType, setName);
break;
default: default:
WarningIn(args.executable()) WarningIn(args.executable())
<< "Unhandled action " << action << endl; << "Unhandled action " << action << endl;

View File

@ -22,8 +22,15 @@ FoamFile
// type cellSet; // type cellSet;
// //
// // action to perform on set. Two types: // // action to perform on set. Two types:
// // - require no source : clear/invert // // - require no source : clear/invert/remove
// // clear : clears set or zone
// // invert : select all currently non-selected elements
// // remove : removes set or zone
// // - require source : new/add/delete/subset // // - require source : new/add/delete/subset
// // new : create new set or zone from source
// // add : add source to contents
// // delete : deletes source from contents
// // subset : keeps elements both in contents and source
// action new; // action new;
// //
// The source entry varies according to the type of set: // The source entry varies according to the type of set:
@ -329,6 +336,7 @@ FoamFile
// faceSet f0; // name of faceSet // faceSet f0; // name of faceSet
// cellSet c0; // name of cellSet of slave side // cellSet c0; // name of cellSet of slave side
// } // }
//
actions actions
( (

View File

@ -650,6 +650,9 @@ void Foam::addPatchCellLayer::calcSidePatch
// ------------------------------------------------------ // ------------------------------------------------------
const labelListList& edgeFaces = pp.edgeFaces(); const labelListList& edgeFaces = pp.edgeFaces();
DynamicList<label> dynMeshEdgeFaces;
forAll(edgeFaces, edgeI) forAll(edgeFaces, edgeI)
{ {
if (edgeFaces[edgeI].size() == 1 && sidePatchID[edgeI] == -1) if (edgeFaces[edgeI].size() == 1 && sidePatchID[edgeI] == -1)
@ -660,7 +663,11 @@ void Foam::addPatchCellLayer::calcSidePatch
// Pick up any boundary face on this edge and use its properties // Pick up any boundary face on this edge and use its properties
label meshEdgeI = meshEdges[edgeI]; label meshEdgeI = meshEdges[edgeI];
const labelList& meshFaces = mesh.edgeFaces()[meshEdgeI]; const labelList& meshFaces = mesh.edgeFaces
(
meshEdgeI,
dynMeshEdgeFaces
);
forAll(meshFaces, k) forAll(meshFaces, k)
{ {
@ -716,7 +723,11 @@ void Foam::addPatchCellLayer::calcSidePatch
// Pick up any boundary face on this edge and use its properties // Pick up any boundary face on this edge and use its properties
label meshEdgeI = meshEdges[edgeI]; label meshEdgeI = meshEdges[edgeI];
const labelList& meshFaces = mesh.edgeFaces()[meshEdgeI]; const labelList& meshFaces = mesh.edgeFaces
(
meshEdgeI,
dynMeshEdgeFaces
);
forAll(meshFaces, k) forAll(meshFaces, k)
{ {

View File

@ -136,8 +136,21 @@ cellZoneSet::~cellZoneSet()
void cellZoneSet::invert(const label maxLen) void cellZoneSet::invert(const label maxLen)
{ {
// Count
label n = 0; label n = 0;
for (label cellI = 0; cellI < maxLen; cellI++)
{
if (!found(cellI))
{
n++;
}
}
// Fill
addressing_.setSize(n);
n = 0;
for (label cellI = 0; cellI < maxLen; cellI++) for (label cellI = 0; cellI < maxLen; cellI++)
{ {
if (!found(cellI)) if (!found(cellI))
@ -146,7 +159,7 @@ void cellZoneSet::invert(const label maxLen)
n++; n++;
} }
} }
addressing_.setSize(n);
updateSet(); updateSet();
} }

View File

@ -141,8 +141,22 @@ faceZoneSet::~faceZoneSet()
void faceZoneSet::invert(const label maxLen) void faceZoneSet::invert(const label maxLen)
{ {
// Count
label n = 0; label n = 0;
for (label faceI = 0; faceI < maxLen; faceI++)
{
if (!found(faceI))
{
n++;
}
}
// Fill
addressing_.setSize(n);
flipMap_.setSize(n);
n = 0;
for (label faceI = 0; faceI < maxLen; faceI++) for (label faceI = 0; faceI < maxLen; faceI++)
{ {
if (!found(faceI)) if (!found(faceI))
@ -152,8 +166,6 @@ void faceZoneSet::invert(const label maxLen)
n++; n++;
} }
} }
addressing_.setSize(n);
flipMap_.setSize(n);
updateSet(); updateSet();
} }

View File

@ -138,8 +138,21 @@ pointZoneSet::~pointZoneSet()
void pointZoneSet::invert(const label maxLen) void pointZoneSet::invert(const label maxLen)
{ {
// Count
label n = 0; label n = 0;
for (label pointI = 0; pointI < maxLen; pointI++)
{
if (!found(pointI))
{
n++;
}
}
// Fill
addressing_.setSize(n);
n = 0;
for (label pointI = 0; pointI < maxLen; pointI++) for (label pointI = 0; pointI < maxLen; pointI++)
{ {
if (!found(pointI)) if (!found(pointI))
@ -148,7 +161,6 @@ void pointZoneSet::invert(const label maxLen)
n++; n++;
} }
} }
addressing_.setSize(n);
updateSet(); updateSet();
} }