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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #include <OpenFOAM/argList.H>
00062 #include <OpenFOAM/Time.H>
00063 #include <dynamicMesh/polyTopoChange.H>
00064 #include <meshTools/faceSet.H>
00065 #include <dynamicMesh/removeFaces.H>
00066 #include <OpenFOAM/ReadFields.H>
00067 #include <finiteVolume/volFields.H>
00068 #include <finiteVolume/surfaceFields.H>
00069
00070 using namespace Foam;
00071
00072
00073
00074
00075
00076 int main(int argc, char *argv[])
00077 {
00078 Foam::argList::validOptions.insert("overwrite", "");
00079 Foam::argList::validArgs.append("faceSet");
00080
00081 # include <OpenFOAM/setRootCase.H>
00082 # include <OpenFOAM/createTime.H>
00083 runTime.functionObjects().off();
00084 # include <OpenFOAM/createMesh.H>
00085 const word oldInstance = mesh.pointsInstance();
00086
00087 bool overwrite = args.optionFound("overwrite");
00088
00089 word setName(args.additionalArgs()[0]);
00090
00091
00092 faceSet candidateSet(mesh, setName);
00093
00094 Pout<< "Read " << candidateSet.size() << " faces to remove" << nl
00095 << endl;
00096
00097
00098 labelList candidates(candidateSet.toc());
00099
00100
00101 removeFaces faceRemover(mesh, 2);
00102
00103
00104 labelList cellRegion;
00105 labelList cellRegionMaster;
00106 labelList facesToRemove;
00107
00108 faceRemover.compatibleRemoves
00109 (
00110 candidates,
00111 cellRegion,
00112 cellRegionMaster,
00113 facesToRemove
00114 );
00115
00116 {
00117 faceSet compatibleRemoves(mesh, "compatibleRemoves", facesToRemove);
00118
00119 Pout<< "Original faces to be removed:" << candidateSet.size() << nl
00120 << "New faces to be removed:" << compatibleRemoves.size() << nl
00121 << endl;
00122
00123 Pout<< "Writing new faces to be removed to faceSet "
00124 << compatibleRemoves.instance()
00125 /compatibleRemoves.local()
00126 /compatibleRemoves.name()
00127 << endl;
00128
00129 compatibleRemoves.write();
00130 }
00131
00132
00133
00134 IOobjectList objects(mesh, runTime.timeName());
00135
00136
00137 PtrList<volScalarField> vsFlds;
00138 ReadFields(mesh, objects, vsFlds);
00139
00140 PtrList<volVectorField> vvFlds;
00141 ReadFields(mesh, objects, vvFlds);
00142
00143 PtrList<volSphericalTensorField> vstFlds;
00144 ReadFields(mesh, objects, vstFlds);
00145
00146 PtrList<volSymmTensorField> vsymtFlds;
00147 ReadFields(mesh, objects, vsymtFlds);
00148
00149 PtrList<volTensorField> vtFlds;
00150 ReadFields(mesh, objects, vtFlds);
00151
00152
00153 PtrList<surfaceScalarField> ssFlds;
00154 ReadFields(mesh, objects, ssFlds);
00155
00156 PtrList<surfaceVectorField> svFlds;
00157 ReadFields(mesh, objects, svFlds);
00158
00159 PtrList<surfaceSphericalTensorField> sstFlds;
00160 ReadFields(mesh, objects, sstFlds);
00161
00162 PtrList<surfaceSymmTensorField> ssymtFlds;
00163 ReadFields(mesh, objects, ssymtFlds);
00164
00165 PtrList<surfaceTensorField> stFlds;
00166 ReadFields(mesh, objects, stFlds);
00167
00168
00169
00170 polyTopoChange meshMod(mesh);
00171
00172
00173 faceRemover.setRefinement
00174 (
00175 facesToRemove,
00176 cellRegion,
00177 cellRegionMaster,
00178 meshMod
00179 );
00180
00181 autoPtr<mapPolyMesh> morphMap = meshMod.changeMesh(mesh, false);
00182
00183 mesh.updateMesh(morphMap);
00184
00185
00186 if (morphMap().hasMotionPoints())
00187 {
00188 mesh.movePoints(morphMap().preMotionPoints());
00189 }
00190
00191
00192 faceRemover.updateMesh(morphMap);
00193
00194 if (!overwrite)
00195 {
00196 runTime++;
00197 }
00198 else
00199 {
00200 mesh.setInstance(oldInstance);
00201 }
00202
00203
00204 Pout<< "Writing mesh to time " << runTime.timeName() << endl;
00205 mesh.write();
00206
00207 Pout<< "End\n" << endl;
00208
00209 return 0;
00210 }
00211
00212
00213