Commit 72cacc95 authored by mattijs's avatar mattijs
Browse files

added zoneSets

parent 909b5906
......@@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Manipulate a cell/face/point set interactively.
Manipulate a cell/face/point/ set or zone interactively.
\*---------------------------------------------------------------------------*/
......@@ -82,6 +82,7 @@ Istream& selectStream(Istream* is0Ptr, Istream* is1Ptr)
// Copy set
void backup
(
const word& setType,
const polyMesh& mesh,
const word& fromName,
const topoSet& fromSet,
......@@ -92,9 +93,7 @@ void backup
{
Pout<< " Backing up " << fromName << " into " << toName << endl;
topoSet backupSet(mesh, toName, fromSet);
backupSet.write();
topoSet::New(setType, mesh, toName, fromSet)().write();
}
}
......@@ -102,14 +101,21 @@ void backup
// Read and copy set
void backup
(
const word& setType,
const polyMesh& mesh,
const word& fromName,
const word& toName
)
{
topoSet fromSet(mesh, fromName, IOobject::READ_IF_PRESENT);
autoPtr<topoSet> fromSet = topoSet::New
(
setType,
mesh,
fromName,
IOobject::READ_IF_PRESENT
);
backup(mesh, fromName, fromSet, toName);
backup(setType, mesh, fromName, fromSet(), toName);
}
......@@ -241,7 +247,8 @@ void printHelp(Ostream& os)
<< "A set command should be of the following form" << endl
<< endl
<< " cellSet|faceSet|pointSet <setName> <action> <source>"
<< endl << endl
<< endl
<< endl
<< "The <action> is one of" << endl
<< " list - prints the contents of the set" << endl
<< " clear - clears the set" << endl
......@@ -270,6 +277,10 @@ void printHelp(Ostream& os)
<< " cellSet c0 add pointToCell p0 any" << endl
<< "List set:" << endl
<< " cellSet c0 list" << endl
<< endl
<< "Zones can be set from corresponding sets:" << endl
<< " faceZone f0Zone new setToZone f0" << endl
<< " cellZone c0Zone new setToZone c0" << endl
<< endl;
}
......@@ -366,7 +377,7 @@ bool doCommand
{
r = IOobject::NO_READ;
//backup(mesh, setName, setName + "_old");
//backup(setType, mesh, setName, setName + "_old");
currentSetPtr = topoSet::New(setType, mesh, setName, typSize);
}
......@@ -401,7 +412,7 @@ bool doCommand
//if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST))
//{
// // currentSet has been read so can make copy.
// backup(mesh, setName, currentSet, setName + "_old");
// backup(setType, mesh, setName, currentSet, setName + "_old");
//}
switch (action)
......@@ -437,15 +448,18 @@ bool doCommand
);
// Backup current set.
topoSet oldSet
autoPtr<topoSet> oldSet
(
mesh,
currentSet.name() + "_old2",
currentSet
topoSet::New
(
setType,
mesh,
currentSet.name() + "_old2",
currentSet
)
);
currentSet.clear();
currentSet.resize(oldSet.size());
setSource().applyToSet(topoSetSource::NEW, currentSet);
// Combine new value of currentSet with old one.
......@@ -547,7 +561,8 @@ enum commandStatus
{
QUIT, // quit program
INVALID, // token is not a valid set manipulation command
VALID // ,, is a valid ,,
VALIDSETCMD, // ,, is a valid ,,
VALIDZONECMD // ,, is a valid zone ,,
};
......@@ -654,7 +669,16 @@ commandStatus parseType
|| setType == "pointSet"
)
{
return VALID;
return VALIDSETCMD;
}
else if
(
setType == "cellZoneSet"
|| setType == "faceZoneSet"
|| setType == "pointZoneSet"
)
{
return VALIDZONECMD;
}
else
{
......@@ -664,7 +688,7 @@ commandStatus parseType
", IStringStream&)"
) << "Illegal command " << setType << endl
<< "Should be one of 'help', 'list', 'time' or a set type :"
<< " 'cellSet', 'faceSet', 'pointSet'"
<< " 'cellSet', 'faceSet', 'pointSet', 'faceZoneSet'"
<< endl;
return INVALID;
......@@ -682,7 +706,7 @@ commandStatus parseAction(const word& actionName)
{
(void)topoSetSource::toAction(actionName);
stat = VALID;
stat = VALIDSETCMD;
}
catch (Foam::IOerror& fIOErr)
{
......@@ -816,12 +840,12 @@ int main(int argc, char *argv[])
IStringStream is(rawLine + ' ');
// Type: cellSet, faceSet, pointSet
// Type: cellSet, faceSet, pointSet, faceZoneSet
is >> setType;
stat = parseType(runTime, mesh, setType, is);
if (stat == VALID)
if (stat == VALIDSETCMD || stat == VALIDZONECMD)
{
if (is >> setName)
{
......@@ -831,14 +855,13 @@ int main(int argc, char *argv[])
}
}
}
ok = true;
if (stat == QUIT)
{
break;
}
else if (stat == VALID)
else if (stat == VALIDSETCMD || stat == VALIDZONECMD)
{
ok = doCommand(mesh, setType, setName, actionName, writeVTK, is);
}
......
......@@ -71,6 +71,9 @@ $(topoSets)/cellSet.C
$(topoSets)/topoSet.C
$(topoSets)/faceSet.C
$(topoSets)/pointSet.C
$(topoSets)/cellZoneSet.C
$(topoSets)/faceZoneSet.C
$(topoSets)/pointZoneSet.C
sets/topoSetSource/topoSetSource.C
......@@ -113,6 +116,18 @@ $(pointSources)/surfaceToPoint/surfaceToPoint.C
$(pointSources)/zoneToPoint/zoneToPoint.C
$(pointSources)/nearestToPoint/nearestToPoint.C
faceZoneSources = sets/faceZoneSources
$(faceZoneSources)/faceZoneToFaceZone/faceZoneToFaceZone.C
$(faceZoneSources)/setsToFaceZone/setsToFaceZone.C
$(faceZoneSources)/setToFaceZone/setToFaceZone.C
cellZoneSources = sets/cellZoneSources
$(cellZoneSources)/setToCellZone/setToCellZone.C
pointZoneSources = sets/pointZoneSources
$(pointZoneSources)/setToPointZone/setToPointZone.C
surfaceSets/surfaceSets.C
triSurface/orientedSurface/orientedSurface.C
......
......@@ -106,7 +106,7 @@ void Foam::cellToCell::applyToSet
{
if ((action == topoSetSource::ADD) || (action == topoSetSource::NEW))
{
Pout<< " Adding all elements of cellSet " << setName_ << " ..."
Info<< " Adding all elements of cellSet " << setName_ << " ..."
<< endl;
// Load the set
......@@ -116,7 +116,7 @@ void Foam::cellToCell::applyToSet
}
else if (action == topoSetSource::DELETE)
{
Pout<< " Removing all elements of cellSet " << setName_ << " ..."
Info<< " Removing all elements of cellSet " << setName_ << " ..."
<< endl;
// Load the set
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "setToCellZone.H"
#include "polyMesh.H"
#include "cellZoneSet.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(setToCellZone, 0);
addToRunTimeSelectionTable(topoSetSource, setToCellZone, word);
addToRunTimeSelectionTable(topoSetSource, setToCellZone, istream);
}
Foam::topoSetSource::addToUsageTable Foam::setToCellZone::usage_
(
setToCellZone::typeName,
"\n Usage: setToCellZone <cellSet>\n\n"
" Select all cells in the cellSet.\n\n"
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::setToCellZone::setToCellZone
(
const polyMesh& mesh,
const word& setName
)
:
topoSetSource(mesh),
setName_(setName)
{}
// Construct from dictionary
Foam::setToCellZone::setToCellZone
(
const polyMesh& mesh,
const dictionary& dict
)
:
topoSetSource(mesh),
setName_(dict.lookup("set"))
{}
// Construct from Istream
Foam::setToCellZone::setToCellZone
(
const polyMesh& mesh,
Istream& is
)
:
topoSetSource(mesh),
setName_(checkIs(is))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::setToCellZone::~setToCellZone()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::setToCellZone::applyToSet
(
const topoSetSource::setAction action,
topoSet& set
) const
{
if (!isA<cellZoneSet>(set))
{
WarningIn
(
"setToCellZone::applyToSet(const topoSetSource::setAction"
", topoSet"
) << "Operation only allowed on a cellZoneSet." << endl;
}
else
{
cellZoneSet& fzSet = refCast<cellZoneSet>(set);
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Info<< " Adding all cells from cellSet " << setName_
<< " ..." << endl;
// Load the sets
cellSet fSet(mesh_, setName_);
// Start off from copy
DynamicList<label> newAddressing(fzSet.addressing());
forAllConstIter(cellSet, fSet, iter)
{
label cellI = iter.key();
if (!fzSet.found(cellI))
{
newAddressing.append(cellI);
}
}
fzSet.addressing().transfer(newAddressing);
fzSet.updateSet();
}
else if (action == topoSetSource::DELETE)
{
Info<< " Removing all cells from cellSet " << setName_
<< " ..." << endl;
// Load the set
cellSet loadedSet(mesh_, setName_);
// Start off empty
DynamicList<label> newAddressing(fzSet.addressing().size());
forAll(fzSet.addressing(), i)
{
if (!loadedSet.found(fzSet.addressing()[i]))
{
newAddressing.append(fzSet.addressing()[i]);
}
}
fzSet.addressing().transfer(newAddressing);
fzSet.updateSet();
}
}
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::setToCellZone
Description
A topoSetSource to select cells based on usage in a cellSet.
SourceFiles
setToCellZone.C
\*---------------------------------------------------------------------------*/
#ifndef setToCellZone_H
#define setToCellZone_H
#include "topoSetSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class setToCellZone Declaration
\*---------------------------------------------------------------------------*/
class setToCellZone
:
public topoSetSource
{
// Private data
//- Add usage string
static addToUsageTable usage_;
//- Name of set to use
word setName_;
public:
//- Runtime type information
TypeName("setToCellZone");
// Constructors
//- Construct from components
setToCellZone
(
const polyMesh& mesh,
const word& setName
);
//- Construct from dictionary
setToCellZone
(
const polyMesh& mesh,
const dictionary& dict
);
//- Construct from Istream
setToCellZone
(
const polyMesh& mesh,
Istream&
);
// Destructor
virtual ~setToCellZone();
// Member Functions
virtual void applyToSet
(
const topoSetSource::setAction action,
topoSet&
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -217,14 +217,14 @@ void Foam::cellToFace::applyToSet
{
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
{
Pout<< " Adding faces according to cellSet " << setName_
Info<< " Adding faces according to cellSet " << setName_
<< " ..." << endl;
combine(set, true);
}
else if (action == topoSetSource::DELETE)
{
Pout<< " Removing faces according to cellSet " << setName_
Info<< " Removing faces according to cellSet " << setName_
<< " ..." << endl;
combine(set, false);
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "faceZoneToFaceZone.H"
#include "polyMesh.H"
#include "faceZoneSet.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(faceZoneToFaceZone, 0);
addToRunTimeSelectionTable(topoSetSource, faceZoneToFaceZone, word);
addToRunTimeSelectionTable(topoSetSource, faceZoneToFaceZone, istream);
}
Foam::topoSetSource::addToUsageTable Foam::faceZoneToFaceZone::usage_
(
faceZoneToFaceZone::typeName,
"\n Usage: faceZoneToFaceZone <faceZone>\n\n"
" Select all faces in the faceZone\n\n"
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::faceZoneToFaceZone::faceZoneToFaceZone
(
const polyMesh& mesh,
const word& setName
)
:
topoSetSource(mesh),
setName_(setName)
{}
// Construct from dictionary
Foam::faceZoneToFaceZone::faceZoneToFaceZone
(
const polyMesh& mesh,