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