surfMeshIO.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 #include "surfMesh.H"
00028 #include "Time.H"
00029
00030
00031
00032 void Foam::surfMesh::setInstance(const fileName& inst)
00033 {
00034 if (debug or true)
00035 {
00036 Info<< "void surfMesh::setInstance(const fileName& inst) : "
00037 << "Resetting file instance to " << inst << endl;
00038 }
00039
00040 instance() = inst;
00041
00042 storedIOPoints().writeOpt() = IOobject::AUTO_WRITE;
00043 storedIOPoints().instance() = inst;
00044
00045 storedIOFaces().writeOpt() = IOobject::AUTO_WRITE;
00046 storedIOFaces().instance() = inst;
00047
00048 storedIOZones().writeOpt() = IOobject::AUTO_WRITE;
00049 storedIOZones().instance() = inst;
00050 }
00051
00052
00053 Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
00054 {
00055 if (debug)
00056 {
00057 Info<< "surfMesh::readUpdateState surfMesh::readUpdate() : "
00058 << "Updating mesh based on saved data." << endl;
00059 }
00060
00061
00062 fileName pointsInst(time().findInstance(meshDir(), "points"));
00063 fileName facesInst(time().findInstance(meshDir(), "faces"));
00064
00065 if (debug)
00066 {
00067 Info<< "Points instance: old = " << pointsInstance()
00068 << " new = " << pointsInst << nl
00069 << "Faces instance: old = " << facesInstance()
00070 << " new = " << facesInst << endl;
00071 }
00072
00073 if (facesInst != facesInstance())
00074 {
00075
00076 if (debug)
00077 {
00078 Info << "Topological change" << endl;
00079 }
00080
00081 clearOut();
00082
00083
00084
00085 setInstance(facesInst);
00086 storedIOPoints().instance() = pointsInst;
00087
00088 storedIOPoints() = pointIOField
00089 (
00090 IOobject
00091 (
00092 "points",
00093 pointsInst,
00094 meshSubDir,
00095 *this,
00096 IOobject::MUST_READ,
00097 IOobject::NO_WRITE,
00098 false
00099 )
00100 );
00101
00102 storedFaces() = faceIOList
00103 (
00104 IOobject
00105 (
00106 "faces",
00107 facesInst,
00108 meshSubDir,
00109 *this,
00110 IOobject::MUST_READ,
00111 IOobject::NO_WRITE,
00112 false
00113 )
00114 );
00115
00116
00117 surfZoneIOList newZones
00118 (
00119 IOobject
00120 (
00121 "surfZones",
00122 facesInst,
00123 meshSubDir,
00124 *this,
00125 IOobject::MUST_READ,
00126 IOobject::NO_WRITE,
00127 false
00128 )
00129 );
00130
00131
00132 bool zonesChanged = false;
00133
00134 surfZoneList& zones = this->storedIOZones();
00135 if (zones.size() != newZones.size())
00136 {
00137 zonesChanged = true;
00138 }
00139 else
00140 {
00141 forAll(zones, zoneI)
00142 {
00143 if (zones[zoneI].name() != newZones[zoneI].name())
00144 {
00145 zonesChanged = true;
00146 break;
00147 }
00148 }
00149 }
00150
00151 zones.transfer(newZones);
00152
00153 if (zonesChanged)
00154 {
00155 WarningIn("surfMesh::readUpdateState surfMesh::readUpdate()")
00156 << "Number of zones has changed. This may have "
00157 << "unexpected consequences. Proceed with care." << endl;
00158
00159 return surfMesh::TOPO_PATCH_CHANGE;
00160 }
00161 else
00162 {
00163 return surfMesh::TOPO_CHANGE;
00164 }
00165
00166 }
00167 else if (pointsInst != pointsInstance())
00168 {
00169
00170 if (debug)
00171 {
00172 Info << "Point motion" << endl;
00173 }
00174
00175 clearGeom();
00176 storedIOPoints().instance() = pointsInst;
00177
00178 storedIOPoints() = pointIOField
00179 (
00180 IOobject
00181 (
00182 "points",
00183 pointsInst,
00184 meshSubDir,
00185 *this,
00186 IOobject::MUST_READ,
00187 IOobject::NO_WRITE,
00188 false
00189 )
00190 );
00191
00192 return surfMesh::POINTS_MOVED;
00193 }
00194 else
00195 {
00196 if (debug)
00197 {
00198 Info << "No change" << endl;
00199 }
00200 }
00201
00202 return surfMesh::UNCHANGED;
00203 }
00204
00205
00206
Copyright © 2000-2009 OpenCFD Ltd