1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Selects a face set through a dictionary.
27 \*---------------------------------------------------------------------------*/
30 #include "objectRegistry.H"
33 #include "topoSetSource.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 const topoSet& fromSet,
49 Info<< "Backing up " << fromName << " into " << toName << endl;
51 topoSet backupSet(mesh, toName, fromSet);
65 topoSet fromSet(mesh, fromName, IOobject::READ_IF_PRESENT);
67 backup(mesh, fromName, fromSet, toName);
73 int main(int argc, char *argv[])
75 # include "setRootCase.H"
76 # include "createTime.H"
77 # include "createPolyMesh.H"
79 Info<< "Reading faceSetDict\n" << endl;
81 IOdictionary faceSetDict
94 word setName(faceSetDict.lookup("name"));
96 word actionName(faceSetDict.lookup("action"));
98 topoSetSource::setAction action = topoSetSource::toAction(actionName);
101 // Create topoSetSources
102 PtrList<topoSetSource> topoSetSources
104 faceSetDict.lookup("topoSetSources"),
105 topoSetSource::iNew(mesh)
110 autoPtr<topoSet> currentSetPtr(NULL);
111 IOobject::readOption r;
113 if ((action == topoSetSource::NEW) || (action == topoSetSource::CLEAR))
115 r = IOobject::NO_READ;
117 backup(mesh, setName, setName + "_old");
125 mesh.nFaces()/10+1 // Reasonable size estimate.
131 r = IOobject::MUST_READ;
144 topoSet& currentSet = currentSetPtr();
146 Info<< "Set:" << currentSet.name()
147 << " Size:" << currentSet.size()
148 << " Action:" << actionName
151 if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST))
153 // currentSet has been read so can make copy.
154 backup(mesh, setName, currentSet, setName + "_old");
157 if (action == topoSetSource::CLEAR)
159 // Already handled above by not reading
161 else if (action == topoSetSource::INVERT)
163 currentSet.invert(currentSet.maxSize(mesh));
165 else if (action == topoSetSource::LIST)
167 currentSet.writeDebug(Info, mesh, 100);
170 else if (action == topoSetSource::SUBSET)
172 // Apply topoSetSources to it to handle new/add/delete
173 forAll(topoSetSources, topoSetSourceI)
175 // Backup current set.
176 topoSet oldSet(mesh, currentSet.name() + "_old2", currentSet);
180 topoSetSources[topoSetSourceI].applyToSet
186 // Combine new value of currentSet with old one.
187 currentSet.subset(oldSet);
192 // Apply topoSetSources to it to handle new/add/delete
193 forAll(topoSetSources, topoSetSourceI)
195 topoSetSources[topoSetSourceI].applyToSet(action, currentSet);
200 if (action != topoSetSource::LIST)
204 // Sync across coupled patches.
205 currentSet.sync(mesh);
207 Info<< "Writing " << currentSet.name()
208 << " (size " << currentSet.size() << ") to "
209 << currentSet.instance()/currentSet.local()
216 Info << nl << "End" << endl;
222 // ************************************************************************* //