mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Converted all cellSet/faceSet/pointSet to topoSet.
This commit is contained in:
@ -1,4 +0,0 @@
|
||||
cellSet.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/cellSet
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools
|
||||
@ -1,196 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 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/>.
|
||||
|
||||
Description
|
||||
Selects a cell set through a dictionary.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "topoSetSource.H"
|
||||
#include "cellSet.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createPolyMesh.H"
|
||||
|
||||
Info<< "Reading cellSetDict\n" << endl;
|
||||
|
||||
IOdictionary cellSetDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"cellSetDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const word setName(cellSetDict.lookup("name"));
|
||||
const word actionName(cellSetDict.lookup("action"));
|
||||
|
||||
topoSetSource::setAction action = topoSetSource::toAction(actionName);
|
||||
|
||||
|
||||
// Create topoSetSources
|
||||
PtrList<topoSetSource> topoSetSources
|
||||
(
|
||||
cellSetDict.lookup("topoSetSources"),
|
||||
topoSetSource::iNew(mesh)
|
||||
);
|
||||
|
||||
|
||||
// Load set to work
|
||||
autoPtr<topoSet> currentSetPtr(NULL);
|
||||
IOobject::readOption r;
|
||||
|
||||
if ((action == topoSetSource::NEW) || (action == topoSetSource::CLEAR))
|
||||
{
|
||||
r = IOobject::NO_READ;
|
||||
|
||||
currentSetPtr.reset
|
||||
(
|
||||
new cellSet
|
||||
(
|
||||
mesh,
|
||||
setName,
|
||||
mesh.nCells()/10+1 // Reasonable size estimate.
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = IOobject::MUST_READ;
|
||||
|
||||
currentSetPtr.reset
|
||||
(
|
||||
new cellSet
|
||||
(
|
||||
mesh,
|
||||
setName,
|
||||
r
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
topoSet& currentSet = currentSetPtr();
|
||||
|
||||
Info<< "Set:" << currentSet.name()
|
||||
<< " Size:" << currentSet.size()
|
||||
<< " Action:" << actionName
|
||||
<< endl;
|
||||
|
||||
if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST))
|
||||
{
|
||||
// currentSet has been read so can make copy.
|
||||
//backup(mesh, setName, currentSet, setName + "_old");
|
||||
}
|
||||
|
||||
if (action == topoSetSource::CLEAR)
|
||||
{
|
||||
// Already handled above by not reading
|
||||
}
|
||||
else if (action == topoSetSource::INVERT)
|
||||
{
|
||||
currentSet.invert(currentSet.maxSize(mesh));
|
||||
}
|
||||
else if (action == topoSetSource::LIST)
|
||||
{
|
||||
currentSet.writeDebug(Info, mesh, 100);
|
||||
Info<< endl;
|
||||
}
|
||||
else if (action == topoSetSource::SUBSET)
|
||||
{
|
||||
// Apply topoSetSources to it to handle new/add/delete
|
||||
forAll(topoSetSources, topoSetSourceI)
|
||||
{
|
||||
// Backup current set.
|
||||
autoPtr<topoSet> oldSet
|
||||
(
|
||||
topoSet::New
|
||||
(
|
||||
currentSet.type(),
|
||||
mesh,
|
||||
currentSet.name() + "_old2",
|
||||
currentSet
|
||||
)
|
||||
);
|
||||
|
||||
currentSet.clear();
|
||||
|
||||
topoSetSources[topoSetSourceI].applyToSet
|
||||
(
|
||||
topoSetSource::NEW,
|
||||
currentSet
|
||||
);
|
||||
|
||||
// Combine new value of currentSet with old one.
|
||||
currentSet.subset(oldSet);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Apply topoSetSources to it to handle new/add/delete
|
||||
forAll(topoSetSources, topoSetSourceI)
|
||||
{
|
||||
topoSetSources[topoSetSourceI].applyToSet(action, currentSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (action != topoSetSource::LIST)
|
||||
{
|
||||
// Set has changed.
|
||||
|
||||
// Sync across coupled patches.
|
||||
currentSet.sync(mesh);
|
||||
|
||||
Info<< "Writing " << currentSet.name()
|
||||
<< " (size " << currentSet.size() << ") to "
|
||||
<< currentSet.instance()/currentSet.local()
|
||||
/currentSet.name()
|
||||
<< endl << endl;
|
||||
|
||||
currentSet.write();
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,149 +0,0 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.6 |
|
||||
| \\ / A nd | Web: http://www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object cellSetDict;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Name of set to operate on
|
||||
name c0;
|
||||
|
||||
// One of clear/new/invert/add/delete|subset/list
|
||||
action new;
|
||||
|
||||
// Actions to apply to cellSet. These are all the topoSetSource's ending
|
||||
// in ..ToCell (see the meshTools library).
|
||||
|
||||
topoSetSources
|
||||
(
|
||||
// Select by explicitly providing cell labels
|
||||
labelToCell
|
||||
{
|
||||
value (12 13 56); // labels of cells
|
||||
}
|
||||
|
||||
// Copy elements from cellSet
|
||||
cellToCell
|
||||
{
|
||||
set c1;
|
||||
}
|
||||
|
||||
// Cells in cell zone
|
||||
zoneToCell
|
||||
{
|
||||
name ".*Zone"; // Name of cellZone, regular expressions allowed
|
||||
}
|
||||
|
||||
// Cells on master or slave side of faceZone
|
||||
faceZoneToCell
|
||||
{
|
||||
name ".*Zone"; // Name of faceZone, regular expressions allowed
|
||||
option master; // master/slave
|
||||
}
|
||||
|
||||
// Select based on faceSet
|
||||
faceToCell
|
||||
{
|
||||
set f0; // Name of faceSet
|
||||
|
||||
//option neighbour; // cell with neighbour in faceSet
|
||||
//option owner; // ,, owner
|
||||
option any; // cell with any face in faceSet
|
||||
//option all; // cell with all faces in faceSet
|
||||
}
|
||||
|
||||
// Select based on pointSet
|
||||
pointToCell
|
||||
{
|
||||
set p0;
|
||||
option any; // cell with any point in pointSet
|
||||
//option all; // cell with all points in pointSet
|
||||
}
|
||||
|
||||
// Select based on cellShape
|
||||
shapeToCell
|
||||
{
|
||||
type hex; // hex/wedge/prism/pyr/tet/tetWedge/splitHex
|
||||
}
|
||||
|
||||
// Cells with cell centre within box
|
||||
boxToCell
|
||||
{
|
||||
box (0 0 0) (1 1 1);
|
||||
}
|
||||
|
||||
// Cells with cell centre within box
|
||||
// Is skewed, rotated box. Given as origin and three spanning vectors.
|
||||
rotatedBoxToCell
|
||||
{
|
||||
origin (0.2 0.2 -10);
|
||||
i (0.2 0.2 0);
|
||||
j (-0.2 0.2 0);
|
||||
k (10 10 10);
|
||||
}
|
||||
|
||||
// Cells with centre within cylinder
|
||||
cylinderToCell
|
||||
{
|
||||
p1 (0.2 0.2 -10); // start point on cylinder axis
|
||||
p2 (0.2 0.2 0); // end point on cylinder axis
|
||||
radius 5.0;
|
||||
}
|
||||
|
||||
// Cells with centre within sphere
|
||||
sphereToCell
|
||||
{
|
||||
centre (0.2 0.2 -10);
|
||||
radius 5.0;
|
||||
}
|
||||
|
||||
// Cells with cellCentre nearest to coordinates
|
||||
nearestToCell
|
||||
{
|
||||
points ((0 0 0) (1 1 1)(2 2 2));
|
||||
}
|
||||
|
||||
// Select based on surface
|
||||
surfaceToCell
|
||||
{
|
||||
file "www.avl.com-geometry.stl";
|
||||
outsidePoints ((-99 -99 -59)); // definition of outside
|
||||
includeCut false; // cells cut by surface
|
||||
includeInside false; // cells not on outside of surf
|
||||
includeOutside false; // cells on outside of surf
|
||||
nearDistance -1; // cells with centre near surf
|
||||
// (set to -1 if not used)
|
||||
curvature 0.9; // cells within nearDistance
|
||||
// and near surf curvature
|
||||
// (set to -100 if not used)
|
||||
}
|
||||
|
||||
// values of field within certain range
|
||||
fieldToCell
|
||||
{
|
||||
fieldName U; // Note: uses mag(U) since volVectorField
|
||||
min 0.1;
|
||||
max 0.5;
|
||||
}
|
||||
|
||||
// Mesh region (non-face connected part of (subset of)mesh)
|
||||
regionToCell
|
||||
{
|
||||
set c0; // name of cellSet giving mesh subset
|
||||
insidePoint (1 2 3); // point inside region to select
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,4 +0,0 @@
|
||||
faceSet.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/faceSet
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools
|
||||
@ -1,196 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 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/>.
|
||||
|
||||
Description
|
||||
Selects a face set through a dictionary.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "topoSetSource.H"
|
||||
#include "faceSet.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createPolyMesh.H"
|
||||
|
||||
Info<< "Reading faceSetDict\n" << endl;
|
||||
|
||||
IOdictionary faceSetDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faceSetDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const word setName(faceSetDict.lookup("name"));
|
||||
const word actionName(faceSetDict.lookup("action"));
|
||||
|
||||
topoSetSource::setAction action = topoSetSource::toAction(actionName);
|
||||
|
||||
|
||||
// Create topoSetSources
|
||||
PtrList<topoSetSource> topoSetSources
|
||||
(
|
||||
faceSetDict.lookup("topoSetSources"),
|
||||
topoSetSource::iNew(mesh)
|
||||
);
|
||||
|
||||
|
||||
// Load set to work
|
||||
autoPtr<topoSet> currentSetPtr(NULL);
|
||||
IOobject::readOption r;
|
||||
|
||||
if ((action == topoSetSource::NEW) || (action == topoSetSource::CLEAR))
|
||||
{
|
||||
r = IOobject::NO_READ;
|
||||
|
||||
currentSetPtr.reset
|
||||
(
|
||||
new faceSet
|
||||
(
|
||||
mesh,
|
||||
setName,
|
||||
mesh.nFaces()/10+1 // Reasonable size estimate.
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = IOobject::MUST_READ;
|
||||
|
||||
currentSetPtr.reset
|
||||
(
|
||||
new faceSet
|
||||
(
|
||||
mesh,
|
||||
setName,
|
||||
r
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
topoSet& currentSet = currentSetPtr();
|
||||
|
||||
Info<< "Set:" << currentSet.name()
|
||||
<< " Size:" << currentSet.size()
|
||||
<< " Action:" << actionName
|
||||
<< endl;
|
||||
|
||||
if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST))
|
||||
{
|
||||
// currentSet has been read so can make copy.
|
||||
//backup(mesh, setName, currentSet, setName + "_old");
|
||||
}
|
||||
|
||||
if (action == topoSetSource::CLEAR)
|
||||
{
|
||||
// Already handled above by not reading
|
||||
}
|
||||
else if (action == topoSetSource::INVERT)
|
||||
{
|
||||
currentSet.invert(currentSet.maxSize(mesh));
|
||||
}
|
||||
else if (action == topoSetSource::LIST)
|
||||
{
|
||||
currentSet.writeDebug(Info, mesh, 100);
|
||||
Info<< endl;
|
||||
}
|
||||
else if (action == topoSetSource::SUBSET)
|
||||
{
|
||||
// Apply topoSetSources to it to handle new/add/delete
|
||||
forAll(topoSetSources, topoSetSourceI)
|
||||
{
|
||||
// Backup current set.
|
||||
autoPtr<topoSet> oldSet
|
||||
(
|
||||
topoSet::New
|
||||
(
|
||||
currentSet.type(),
|
||||
mesh,
|
||||
currentSet.name() + "_old2",
|
||||
currentSet
|
||||
)
|
||||
);
|
||||
|
||||
currentSet.clear();
|
||||
|
||||
topoSetSources[topoSetSourceI].applyToSet
|
||||
(
|
||||
topoSetSource::NEW,
|
||||
currentSet
|
||||
);
|
||||
|
||||
// Combine new value of currentSet with old one.
|
||||
currentSet.subset(oldSet);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Apply topoSetSources to it to handle new/add/delete
|
||||
forAll(topoSetSources, topoSetSourceI)
|
||||
{
|
||||
topoSetSources[topoSetSourceI].applyToSet(action, currentSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (action != topoSetSource::LIST)
|
||||
{
|
||||
// Set has changed.
|
||||
|
||||
// Sync across coupled patches.
|
||||
currentSet.sync(mesh);
|
||||
|
||||
Info<< "Writing " << currentSet.name()
|
||||
<< " (size " << currentSet.size() << ") to "
|
||||
<< currentSet.instance()/currentSet.local()
|
||||
/currentSet.name()
|
||||
<< endl << endl;
|
||||
|
||||
currentSet.write();
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,82 +0,0 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.6 |
|
||||
| \\ / A nd | Web: http://www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object faceSetDict;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Name of set to operate on
|
||||
name f0;
|
||||
|
||||
// One of clear/new/invert/add/delete|subset/list
|
||||
action new;
|
||||
|
||||
// Actions to apply to pointSet. These are all the topoSetSource's ending
|
||||
// in ..ToFace (see the meshTools library).
|
||||
topoSetSources
|
||||
(
|
||||
// Copy elements from faceSet
|
||||
faceToFace
|
||||
{
|
||||
set f1;
|
||||
}
|
||||
|
||||
// Select based on cellSet
|
||||
cellToFace
|
||||
{
|
||||
set c0;
|
||||
option all; // All faces of cells
|
||||
//option both; // Only faces whose owner&neighbour are in cellSet
|
||||
}
|
||||
|
||||
// Select based on pointSet
|
||||
pointToFace
|
||||
{
|
||||
set p0;
|
||||
option any; // Faces using any point in pointSet
|
||||
//option all // Faces with all points in pointSet
|
||||
}
|
||||
|
||||
// Select by explicitly providing face labels
|
||||
labelToFace
|
||||
{
|
||||
value (12 13 56); // labels of faces
|
||||
}
|
||||
|
||||
// All faces of patch
|
||||
patchToFace
|
||||
{
|
||||
name ".*Wall"; // Name of patch, regular expressions allowed
|
||||
}
|
||||
|
||||
// All faces of faceZone
|
||||
zoneToFace
|
||||
{
|
||||
name ".*Zone1"; // Name of faceZone, regular expressions allowed
|
||||
}
|
||||
|
||||
// Faces with face centre within box
|
||||
boxToFace
|
||||
{
|
||||
box (0 0 0) (1 1 1);
|
||||
}
|
||||
|
||||
// Faces with normal to within certain angle aligned with vector.
|
||||
normalToFace
|
||||
{
|
||||
normal (0 0 1); // Vector
|
||||
cos 0.01; // Tolerance (max cos of angle)
|
||||
}
|
||||
);
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,4 +0,0 @@
|
||||
pointSet.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/pointSet
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lmeshTools
|
||||
@ -1,196 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 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/>.
|
||||
|
||||
Description
|
||||
Selects a point set through a dictionary.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "topoSetSource.H"
|
||||
#include "pointSet.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createPolyMesh.H"
|
||||
|
||||
Info<< "Reading pointSetDict\n" << endl;
|
||||
|
||||
IOdictionary pointSetDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pointSetDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
const word setName(pointSetDict.lookup("name"));
|
||||
const word actionName(pointSetDict.lookup("action"));
|
||||
|
||||
topoSetSource::setAction action = topoSetSource::toAction(actionName);
|
||||
|
||||
|
||||
// Create topoSetSources
|
||||
PtrList<topoSetSource> topoSetSources
|
||||
(
|
||||
pointSetDict.lookup("topoSetSources"),
|
||||
topoSetSource::iNew(mesh)
|
||||
);
|
||||
|
||||
|
||||
// Load set to work
|
||||
autoPtr<topoSet> currentSetPtr(NULL);
|
||||
IOobject::readOption r;
|
||||
|
||||
if ((action == topoSetSource::NEW) || (action == topoSetSource::CLEAR))
|
||||
{
|
||||
r = IOobject::NO_READ;
|
||||
|
||||
currentSetPtr.reset
|
||||
(
|
||||
new pointSet
|
||||
(
|
||||
mesh,
|
||||
setName,
|
||||
mesh.nPoints()/10+1 // Reasonable size estimate.
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = IOobject::MUST_READ;
|
||||
|
||||
currentSetPtr.reset
|
||||
(
|
||||
new pointSet
|
||||
(
|
||||
mesh,
|
||||
setName,
|
||||
r
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
topoSet& currentSet = currentSetPtr();
|
||||
|
||||
Info<< "Set:" << currentSet.name()
|
||||
<< " Size:" << currentSet.size()
|
||||
<< " Action:" << actionName
|
||||
<< endl;
|
||||
|
||||
if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST))
|
||||
{
|
||||
// currentSet has been read so can make copy.
|
||||
//backup(mesh, setName, currentSet, setName + "_old");
|
||||
}
|
||||
|
||||
if (action == topoSetSource::CLEAR)
|
||||
{
|
||||
// Already handled above by not reading
|
||||
}
|
||||
else if (action == topoSetSource::INVERT)
|
||||
{
|
||||
currentSet.invert(currentSet.maxSize(mesh));
|
||||
}
|
||||
else if (action == topoSetSource::LIST)
|
||||
{
|
||||
currentSet.writeDebug(Info, mesh, 100);
|
||||
Info<< endl;
|
||||
}
|
||||
else if (action == topoSetSource::SUBSET)
|
||||
{
|
||||
// Apply topoSetSources to it to handle new/add/delete
|
||||
forAll(topoSetSources, topoSetSourceI)
|
||||
{
|
||||
// Backup current set.
|
||||
autoPtr<topoSet> oldSet
|
||||
(
|
||||
topoSet::New
|
||||
(
|
||||
currentSet.type(),
|
||||
mesh,
|
||||
currentSet.name() + "_old2",
|
||||
currentSet
|
||||
)
|
||||
);
|
||||
|
||||
currentSet.clear();
|
||||
|
||||
topoSetSources[topoSetSourceI].applyToSet
|
||||
(
|
||||
topoSetSource::NEW,
|
||||
currentSet
|
||||
);
|
||||
|
||||
// Combine new value of currentSet with old one.
|
||||
currentSet.subset(oldSet);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Apply topoSetSources to it to handle new/add/delete
|
||||
forAll(topoSetSources, topoSetSourceI)
|
||||
{
|
||||
topoSetSources[topoSetSourceI].applyToSet(action, currentSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (action != topoSetSource::LIST)
|
||||
{
|
||||
// Set has changed.
|
||||
|
||||
// Sync across coupled patches.
|
||||
currentSet.sync(mesh);
|
||||
|
||||
Info<< "Writing " << currentSet.name()
|
||||
<< " (size " << currentSet.size() << ") to "
|
||||
<< currentSet.instance()/currentSet.local()
|
||||
/currentSet.name()
|
||||
<< endl << endl;
|
||||
|
||||
currentSet.write();
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,84 +0,0 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.6 |
|
||||
| \\ / A nd | Web: http://www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object pointSetDict;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Name of set to operate on
|
||||
name p0;
|
||||
|
||||
// One of clear/new/invert/add/delete|subset/list
|
||||
action new;
|
||||
|
||||
// Actions to apply to pointSet. These are all the topoSetSource's ending
|
||||
// in ..ToPoint (see the meshTools library).
|
||||
topoSetSources
|
||||
(
|
||||
// Copy elements from pointSet
|
||||
pointToPoint
|
||||
{
|
||||
set p1;
|
||||
}
|
||||
|
||||
// Select based on cellSet
|
||||
cellToPoint
|
||||
{
|
||||
set c0;
|
||||
option all; // all points of cell
|
||||
}
|
||||
|
||||
// Select based on faceSet
|
||||
faceToPoint
|
||||
{
|
||||
set f0; // name of faceSet
|
||||
option all; // all points of face
|
||||
}
|
||||
|
||||
// Select by explicitly providing point labels
|
||||
labelToPoint
|
||||
{
|
||||
value (12 13 56); // labels of points
|
||||
}
|
||||
|
||||
// All points in pointzone
|
||||
zoneToPoint
|
||||
{
|
||||
name ".*Zone"; // name of pointZone, regular expressions allowed
|
||||
}
|
||||
|
||||
// Points nearest to coordinates
|
||||
nearestToPoint
|
||||
{
|
||||
points ((0 0 0) (1 1 1));
|
||||
}
|
||||
|
||||
// Points with coordinate within box
|
||||
boxToPoint
|
||||
{
|
||||
box (0 0 0) (1 1 1);
|
||||
}
|
||||
|
||||
// Select based on surface
|
||||
surfaceToPoint
|
||||
{
|
||||
file "www.avl.com-geometry.stl";
|
||||
nearDistance 0.1; // points near to surface
|
||||
includeInside false; // points on inside of surface
|
||||
// (requires closed surface with consistent
|
||||
// normals)
|
||||
includeOutside false; // ,, outside ,,
|
||||
}
|
||||
);
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -167,6 +167,7 @@ int main(int argc, char *argv[])
|
||||
case topoSetSource::INVERT:
|
||||
Info<< " Inverting set" << endl;
|
||||
currentSet().invert(currentSet().maxSize(mesh));
|
||||
currentSet().write();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user