faceSet.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "argList.H"
00031 #include "Time.H"
00032 #include "polyMesh.H"
00033 #include "topoSetSource.H"
00034 #include "faceSet.H"
00035
00036 using namespace Foam;
00037
00038
00039
00040
00041 void backup
00042 (
00043 const polyMesh& mesh,
00044 const word& fromName,
00045 const topoSet& fromSet,
00046 const word& toName
00047 )
00048 {
00049 Info<< "Backing up " << fromName << " into " << toName << endl;
00050
00051 topoSet backupSet(mesh, toName, fromSet);
00052
00053 backupSet.write();
00054 }
00055
00056
00057
00058 void backup
00059 (
00060 const polyMesh& mesh,
00061 const word& fromName,
00062 const word& toName
00063 )
00064 {
00065 topoSet fromSet(mesh, fromName, IOobject::READ_IF_PRESENT);
00066
00067 backup(mesh, fromName, fromSet, toName);
00068 }
00069
00070
00071
00072
00073 int main(int argc, char *argv[])
00074 {
00075 # include "setRootCase.H"
00076 # include "createTime.H"
00077 # include "createPolyMesh.H"
00078
00079 Info<< "Reading faceSetDict\n" << endl;
00080
00081 IOdictionary faceSetDict
00082 (
00083 IOobject
00084 (
00085 "faceSetDict",
00086 runTime.system(),
00087 mesh,
00088 IOobject::MUST_READ,
00089 IOobject::NO_WRITE
00090 )
00091 );
00092
00093
00094 word setName(faceSetDict.lookup("name"));
00095
00096 word actionName(faceSetDict.lookup("action"));
00097
00098 topoSetSource::setAction action = topoSetSource::toAction(actionName);
00099
00100
00101
00102 PtrList<topoSetSource> topoSetSources
00103 (
00104 faceSetDict.lookup("topoSetSources"),
00105 topoSetSource::iNew(mesh)
00106 );
00107
00108
00109
00110 autoPtr<topoSet> currentSetPtr(NULL);
00111 IOobject::readOption r;
00112
00113 if ((action == topoSetSource::NEW) || (action == topoSetSource::CLEAR))
00114 {
00115 r = IOobject::NO_READ;
00116
00117 backup(mesh, setName, setName + "_old");
00118
00119 currentSetPtr.reset
00120 (
00121 new faceSet
00122 (
00123 mesh,
00124 setName,
00125 mesh.nFaces()/10+1
00126 )
00127 );
00128 }
00129 else
00130 {
00131 r = IOobject::MUST_READ;
00132
00133 currentSetPtr.reset
00134 (
00135 new faceSet
00136 (
00137 mesh,
00138 setName,
00139 r
00140 )
00141 );
00142 }
00143
00144 topoSet& currentSet = currentSetPtr();
00145
00146 Info<< "Set:" << currentSet.name()
00147 << " Size:" << currentSet.size()
00148 << " Action:" << actionName
00149 << endl;
00150
00151 if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST))
00152 {
00153
00154 backup(mesh, setName, currentSet, setName + "_old");
00155 }
00156
00157 if (action == topoSetSource::CLEAR)
00158 {
00159
00160 }
00161 else if (action == topoSetSource::INVERT)
00162 {
00163 currentSet.invert(currentSet.maxSize(mesh));
00164 }
00165 else if (action == topoSetSource::LIST)
00166 {
00167 currentSet.writeDebug(Info, mesh, 100);
00168 Info<< endl;
00169 }
00170 else if (action == topoSetSource::SUBSET)
00171 {
00172
00173 forAll(topoSetSources, topoSetSourceI)
00174 {
00175
00176 topoSet oldSet(mesh, currentSet.name() + "_old2", currentSet);
00177
00178 currentSet.clear();
00179
00180 topoSetSources[topoSetSourceI].applyToSet
00181 (
00182 topoSetSource::NEW,
00183 currentSet
00184 );
00185
00186
00187 currentSet.subset(oldSet);
00188 }
00189 }
00190 else
00191 {
00192
00193 forAll(topoSetSources, topoSetSourceI)
00194 {
00195 topoSetSources[topoSetSourceI].applyToSet(action, currentSet);
00196 }
00197 }
00198
00199
00200 if (action != topoSetSource::LIST)
00201 {
00202
00203
00204
00205 currentSet.sync(mesh);
00206
00207 Info<< "Writing " << currentSet.name()
00208 << " (size " << currentSet.size() << ") to "
00209 << currentSet.instance()/currentSet.local()
00210 /currentSet.name()
00211 << endl << endl;
00212
00213 currentSet.write();
00214 }
00215
00216 Info << nl << "End" << endl;
00217
00218 return 0;
00219 }
00220
00221
00222
Copyright © 2000-2009 OpenCFD Ltd