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 "linearValveFvMesh.H"
00028 #include "Time.H"
00029 #include "slidingInterface.H"
00030 #include "mapPolyMesh.H"
00031 #include "polyTopoChange.H"
00032 #include "addToRunTimeSelectionTable.H"
00033
00034
00035
00036 namespace Foam
00037 {
00038 defineTypeNameAndDebug(linearValveFvMesh, 0);
00039
00040 addToRunTimeSelectionTable(topoChangerFvMesh, linearValveFvMesh, IOobject);
00041 }
00042
00043
00044
00045
00046 void Foam::linearValveFvMesh::addZonesAndModifiers()
00047 {
00048
00049
00050 if
00051 (
00052 pointZones().size()
00053 || faceZones().size()
00054 || cellZones().size()
00055 || topoChanger_.size()
00056 )
00057 {
00058 Info<< "void linearValveFvMesh::addZonesAndModifiers() : "
00059 << "Zones and modifiers already present. Skipping."
00060 << endl;
00061
00062 return;
00063 }
00064
00065 Info<< "Time = " << time().timeName() << endl
00066 << "Adding zones and modifiers to the mesh" << endl;
00067
00068
00069 List<pointZone*> pz(1);
00070
00071
00072
00073 pz[0] = new pointZone
00074 (
00075 "cutPointZone",
00076 labelList(0),
00077 0,
00078 pointZones()
00079 );
00080
00081
00082
00083
00084 List<faceZone*> fz(3);
00085
00086
00087 const word innerSliderName(motionDict_.subDict("slider").lookup("inside"));
00088 const polyPatch& innerSlider =
00089 boundaryMesh()[boundaryMesh().findPatchID(innerSliderName)];
00090
00091 labelList isf(innerSlider.size());
00092
00093 forAll (isf, i)
00094 {
00095 isf[i] = innerSlider.start() + i;
00096 }
00097
00098 fz[0] = new faceZone
00099 (
00100 "insideSliderZone",
00101 isf,
00102 boolList(innerSlider.size(), false),
00103 0,
00104 faceZones()
00105 );
00106
00107
00108 const word outerSliderName(motionDict_.subDict("slider").lookup("outside"));
00109 const polyPatch& outerSlider =
00110 boundaryMesh()[boundaryMesh().findPatchID(outerSliderName)];
00111
00112 labelList osf(outerSlider.size());
00113
00114 forAll (osf, i)
00115 {
00116 osf[i] = outerSlider.start() + i;
00117 }
00118
00119 fz[1] = new faceZone
00120 (
00121 "outsideSliderZone",
00122 osf,
00123 boolList(outerSlider.size(), false),
00124 1,
00125 faceZones()
00126 );
00127
00128
00129 fz[2] = new faceZone
00130 (
00131 "cutFaceZone",
00132 labelList(0),
00133 boolList(0, false),
00134 2,
00135 faceZones()
00136 );
00137
00138 List<cellZone*> cz(0);
00139
00140 Info << "Adding point, face and cell zones" << endl;
00141 addZones(pz, fz, cz);
00142
00143
00144 Info << "Adding topology modifiers" << endl;
00145 topoChanger_.setSize(1);
00146 topoChanger_.set
00147 (
00148 0,
00149 new slidingInterface
00150 (
00151 "mixerSlider",
00152 0,
00153 topoChanger_,
00154 outerSliderName + "Zone",
00155 innerSliderName + "Zone",
00156 "cutPointZone",
00157 "cutFaceZone",
00158 outerSliderName,
00159 innerSliderName,
00160 slidingInterface::INTEGRAL,
00161 true
00162 )
00163 );
00164 topoChanger_.writeOpt() = IOobject::AUTO_WRITE;
00165
00166
00167 write();
00168 }
00169
00170
00171 void Foam::linearValveFvMesh::makeSlidersDead()
00172 {
00173 const polyTopoChanger& topoChanges = topoChanger_;
00174
00175
00176 forAll (topoChanges, modI)
00177 {
00178 if (typeid(topoChanges[modI]) == typeid(slidingInterface))
00179 {
00180 topoChanges[modI].disable();
00181 }
00182 else
00183 {
00184 FatalErrorIn("void Foam::linearValveFvMesh::makeSlidersDead()")
00185 << "Don't know what to do with mesh modifier "
00186 << modI << " of type " << topoChanges[modI].type()
00187 << abort(FatalError);
00188 }
00189 }
00190 }
00191
00192
00193 void Foam::linearValveFvMesh::makeSlidersLive()
00194 {
00195 const polyTopoChanger& topoChanges = topoChanger_;
00196
00197
00198 forAll (topoChanges, modI)
00199 {
00200 if (typeid(topoChanges[modI]) == typeid(slidingInterface))
00201 {
00202 topoChanges[modI].enable();
00203 }
00204 else
00205 {
00206 FatalErrorIn("void Foam::linearValveFvMesh::makeLayersLive()")
00207 << "Don't know what to do with mesh modifier "
00208 << modI << " of type " << topoChanges[modI].type()
00209 << abort(FatalError);
00210 }
00211 }
00212 }
00213
00214
00215 bool Foam::linearValveFvMesh::attached() const
00216 {
00217 const polyTopoChanger& topoChanges = topoChanger_;
00218
00219 bool result = false;
00220
00221 forAll (topoChanges, modI)
00222 {
00223 if (typeid(topoChanges[modI]) == typeid(slidingInterface))
00224 {
00225 result =
00226 result
00227 || refCast<const slidingInterface>(topoChanges[modI]).attached();
00228 }
00229 }
00230
00231
00232 forAll (topoChanges, modI)
00233 {
00234 if (typeid(topoChanges[modI]) == typeid(slidingInterface))
00235 {
00236 if
00237 (
00238 result
00239 != refCast<const slidingInterface>(topoChanges[modI]).attached()
00240 )
00241 {
00242 FatalErrorIn("bool linearValveFvMesh::attached() const")
00243 << "Slider " << modI << " named " << topoChanges[modI].name()
00244 << " out of sync: Should be" << result
00245 << abort(FatalError);
00246 }
00247 }
00248 }
00249
00250 if (result)
00251 {
00252 Info << "linearValveFvMesh: attached!" << endl;
00253 }
00254 else
00255 {
00256 Info << "linearValveFvMesh: detached!" << endl;
00257 }
00258
00259 return result;
00260 }
00261
00262
00263
00264
00265
00266 Foam::linearValveFvMesh::linearValveFvMesh(const IOobject& io)
00267 :
00268 topoChangerFvMesh(io),
00269 motionDict_
00270 (
00271 IOdictionary
00272 (
00273 IOobject
00274 (
00275 "dynamicMeshDict",
00276 time().constant(),
00277 *this,
00278 IOobject::MUST_READ,
00279 IOobject::NO_WRITE
00280 )
00281 ).subDict(typeName + "Coeffs")
00282 ),
00283 msPtr_(motionSolver::New(*this))
00284 {
00285 addZonesAndModifiers();
00286 }
00287
00288
00289
00290
00291 Foam::linearValveFvMesh::~linearValveFvMesh()
00292 {}
00293
00294
00295
00296
00297 void Foam::linearValveFvMesh::update()
00298 {
00299
00300 if (attached())
00301 {
00302 Info << "Decoupling sliding interfaces" << endl;
00303 makeSlidersLive();
00304
00305
00306 resetMorph();
00307 setMorphTimeIndex(3*time().timeIndex());
00308 updateMesh();
00309
00310 msPtr_->updateMesh();
00311 }
00312 else
00313 {
00314 Info << "Sliding interfaces decoupled" << endl;
00315 }
00316
00317
00318 makeSlidersDead();
00319
00320
00321 resetMorph();
00322 setMorphTimeIndex(3*time().timeIndex() + 1);
00323 updateMesh();
00324
00325 msPtr_->updateMesh();
00326
00327 if (topoChangeMap.valid())
00328 {
00329 if (topoChangeMap().hasMotionPoints())
00330 {
00331 Info << "Topology change; executing pre-motion" << endl;
00332 movePoints(topoChangeMap().preMotionPoints());
00333 }
00334 }
00335
00336
00337 msPtr_->solve();
00338
00339 movePoints(msPtr_->curPoints());
00340
00341
00342 Info << "Coupling sliding interfaces" << endl;
00343 makeSlidersLive();
00344 resetMorph();
00345 setMorphTimeIndex(3*time().timeIndex() + 2);
00346 updateMesh();
00347
00348 Info << "Moving points post slider attach" << endl;
00349
00350 msPtr_->updateMesh();
00351
00352 Info << "Sliding interfaces coupled: " << attached() << endl;
00353 }
00354
00355
00356