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