1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM 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 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Selects a face set through a dictionary.
28 \*---------------------------------------------------------------------------*/
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"
78 Info<< "Reading mesh for time = " << runTime.value() << endl;
80 Info<< "Create mesh\n" << endl;
85 polyMesh::defaultRegion,
91 Info<< "Reading faceSetDict\n" << endl;
93 IOdictionary faceSetDict
106 word setName(faceSetDict.lookup("name"));
108 word actionName(faceSetDict.lookup("action"));
110 topoSetSource::setAction action = topoSetSource::toAction(actionName);
113 // Create topoSetSources
114 PtrList<topoSetSource> topoSetSources
116 faceSetDict.lookup("topoSetSources"),
117 topoSetSource::iNew(mesh)
122 autoPtr<topoSet> currentSetPtr(NULL);
123 IOobject::readOption r;
125 if ((action == topoSetSource::NEW) || (action == topoSetSource::CLEAR))
127 r = IOobject::NO_READ;
129 backup(mesh, setName, setName + "_old");
137 mesh.nFaces()/10+1 // Reasonable size estimate.
143 r = IOobject::MUST_READ;
156 topoSet& currentSet = currentSetPtr();
158 Info<< "Set:" << currentSet.name()
159 << " Size:" << currentSet.size()
160 << " Action:" << actionName
163 if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST))
165 // currentSet has been read so can make copy.
166 backup(mesh, setName, currentSet, setName + "_old");
169 if (action == topoSetSource::CLEAR)
171 // Already handled above by not reading
173 else if (action == topoSetSource::INVERT)
175 currentSet.invert(currentSet.maxSize(mesh));
177 else if (action == topoSetSource::LIST)
179 currentSet.writeDebug(Info, mesh, 100);
182 else if (action == topoSetSource::SUBSET)
184 // Apply topoSetSources to it to handle new/add/delete
185 forAll(topoSetSources, topoSetSourceI)
187 // Backup current set.
188 topoSet oldSet(mesh, currentSet.name() + "_old2", currentSet);
192 topoSetSources[topoSetSourceI].applyToSet
198 // Combine new value of currentSet with old one.
199 currentSet.subset(oldSet);
204 // Apply topoSetSources to it to handle new/add/delete
205 forAll(topoSetSources, topoSetSourceI)
207 topoSetSources[topoSetSourceI].applyToSet(action, currentSet);
212 if (action != topoSetSource::LIST)
216 // Sync across coupled patches.
217 currentSet.sync(mesh);
219 Info<< "Writing " << currentSet.name()
220 << " (size " << currentSet.size() << ") to "
221 << currentSet.instance()/currentSet.local()
228 Info << nl << "End" << endl;
234 // ************************************************************************* //