$treeview $search $mathjax
Palabos  Version 1.1
$projectbrief
$projectbrief
$searchbox

boundaryDynamics.hh

Go to the documentation of this file.
00001 /* This file is part of the Palabos library.
00002  *
00003  * Copyright (C) 2011 FlowKit Sarl
00004  * Avenue de Chailly 23
00005  * 1012 Lausanne, Switzerland
00006  * E-mail contact: contact@flowkit.com
00007  *
00008  * The most recent release of Palabos can be downloaded at 
00009  * <http://www.palabos.org/>
00010  *
00011  * The library Palabos is free software: you can redistribute it and/or
00012  * modify it under the terms of the GNU Affero General Public License as
00013  * published by the Free Software Foundation, either version 3 of the
00014  * License, or (at your option) any later version.
00015  *
00016  * The library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Affero General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Affero General Public License
00022  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00023 */
00024 
00029 #ifndef BOUNDARY_DYNAMICS_HH
00030 #define BOUNDARY_DYNAMICS_HH
00031 
00032 #include "boundaryCondition/boundaryDynamics.h"
00033 #include "core/cell.h"
00034 #include "core/dynamicsIdentifiers.h"
00035 #include "latticeBoltzmann/indexTemplates.h"
00036 #include "latticeBoltzmann/externalFieldAccess.h"
00037 
00038 namespace plb {
00039 
00040 /* *************** Class BoundaryCompositeDynamics *********************** */
00041 
00042 template<typename T, template<typename U> class Descriptor>
00043 int BoundaryCompositeDynamics<T,Descriptor>::id =
00044     meta::registerCompositeDynamics<T,Descriptor, BoundaryCompositeDynamics<T,Descriptor> >("Boundary_Composite");
00045 
00046 template<typename T, template<typename U> class Descriptor>
00047 BoundaryCompositeDynamics<T,Descriptor>::BoundaryCompositeDynamics(Dynamics<T,Descriptor>* baseDynamics_,
00048                                                                    bool automaticPrepareCollision_)
00049     : PreparePopulationsDynamics<T,Descriptor>(baseDynamics_,automaticPrepareCollision_)
00050 { }
00051 
00052 template<typename T, template<typename U> class Descriptor>
00053 void BoundaryCompositeDynamics<T,Descriptor>::unserialize(HierarchicUnserializer& unserializer)
00054 {
00055     PreparePopulationsDynamics<T,Descriptor>::unserialize(unserializer);
00056 }
00057 
00058 template<typename T, template<typename U> class Descriptor>
00059 void BoundaryCompositeDynamics<T,Descriptor>::serialize(HierarchicSerializer& serializer) const
00060 {
00061     PreparePopulationsDynamics<T,Descriptor>::serialize(serializer);
00062 }
00063 
00064 template<typename T, template<typename U> class Descriptor>
00065 BoundaryCompositeDynamics<T,Descriptor>* BoundaryCompositeDynamics<T,Descriptor>::clone() const
00066 {
00067     return new BoundaryCompositeDynamics<T,Descriptor>(*this);
00068 }
00069 
00070 template<typename T, template<typename U> class Descriptor>
00071 int BoundaryCompositeDynamics<T,Descriptor>::getId() const {
00072     return id;
00073 }
00074 
00075 template<typename T, template<typename U> class Descriptor>
00076 bool BoundaryCompositeDynamics<T,Descriptor>::isBoundary() const {
00077     return true;
00078 }
00079 
00080 template<typename T, template<typename U> class Descriptor>
00081 T BoundaryCompositeDynamics<T,Descriptor>::computeDensity(Cell<T,Descriptor> const& cell) const {
00082     Cell<T,Descriptor> tmpCell(cell);
00083     this -> completePopulations(tmpCell);
00084     return this->getBaseDynamics().computeDensity(tmpCell);
00085 }
00086 
00087 template<typename T, template<typename U> class Descriptor>
00088 T BoundaryCompositeDynamics<T,Descriptor>::computePressure(Cell<T,Descriptor> const& cell) const {
00089     Cell<T,Descriptor> tmpCell(cell);
00090     this -> completePopulations(tmpCell);
00091     return this->getBaseDynamics().computePressure(tmpCell);
00092 }
00093 
00094 template<typename T, template<typename U> class Descriptor>
00095 void BoundaryCompositeDynamics<T,Descriptor>::computeVelocity(Cell<T,Descriptor> const& cell,
00096                                                               Array<T,Descriptor<T>::d>& velocity ) const
00097 {
00098     Cell<T,Descriptor> tmpCell(cell);
00099     this -> completePopulations(tmpCell);
00100     this->getBaseDynamics().computeVelocity(tmpCell, velocity);
00101 }
00102 
00103 template<typename T, template<typename U> class Descriptor>
00104 T BoundaryCompositeDynamics<T,Descriptor>::computeTemperature(Cell<T,Descriptor> const& cell) const {
00105     Cell<T,Descriptor> tmpCell(cell);
00106     this -> completePopulations(tmpCell);
00107     return this->getBaseDynamics().computeTemperature(tmpCell);
00108 }
00109 
00110 template<typename T, template<typename U> class Descriptor>
00111 void BoundaryCompositeDynamics<T,Descriptor>::computeDeviatoricStress (
00112         Cell<T,Descriptor> const& cell, Array<T,SymmetricTensor<T,Descriptor>::n>& PiNeq ) const
00113 {
00114     Cell<T,Descriptor> tmpCell(cell);
00115     this -> completePopulations(tmpCell);
00116     return this->getBaseDynamics().computeDeviatoricStress(tmpCell, PiNeq);
00117 }
00118 
00119 template<typename T, template<typename U> class Descriptor>
00120 void BoundaryCompositeDynamics<T,Descriptor>::computeHeatFlux(Cell<T,Descriptor> const& cell,
00121                                                               Array<T,Descriptor<T>::d>& q ) const
00122 {
00123     Cell<T,Descriptor> tmpCell(cell);
00124     this -> completePopulations(tmpCell);
00125     this->getBaseDynamics().computeHeatFlux(tmpCell, q);
00126 }
00127 
00128 template<typename T, template<typename U> class Descriptor>
00129 void BoundaryCompositeDynamics<T,Descriptor>::computeMoment (
00130         Cell<T,Descriptor> const& cell, plint momentId, T* moment ) const
00131 {
00132     Cell<T,Descriptor> tmpCell(cell);
00133     this -> completePopulations(tmpCell);
00134     this->getBaseDynamics().computeMoment(tmpCell, momentId, moment);
00135 }
00136 
00137 template<typename T, template<typename U> class Descriptor>
00138 T BoundaryCompositeDynamics<T,Descriptor>::computeRhoBar(Cell<T,Descriptor> const& cell) const
00139 {
00140     Cell<T,Descriptor> tmpCell(cell);
00141     this -> completePopulations(tmpCell);
00142     return this->getBaseDynamics().computeRhoBar(tmpCell);
00143 }
00144 
00145 template<typename T, template<typename U> class Descriptor>
00146 void BoundaryCompositeDynamics<T,Descriptor>::computeRhoBarJ (
00147         Cell<T,Descriptor> const& cell, T& rhoBar, Array<T,Descriptor<T>::d>& j ) const
00148 {
00149     Cell<T,Descriptor> tmpCell(cell);
00150     this -> completePopulations(tmpCell);
00151     this->getBaseDynamics().computeRhoBarJ(tmpCell, rhoBar, j);
00152 }
00153 
00154 template<typename T, template<typename U> class Descriptor>
00155 void BoundaryCompositeDynamics<T,Descriptor>::computeRhoBarJPiNeq (
00156         Cell<T,Descriptor> const& cell, T& rhoBar, Array<T,Descriptor<T>::d>& j,
00157         Array<T,SymmetricTensor<T,Descriptor>::n>& PiNeq ) const
00158 {
00159     Cell<T,Descriptor> tmpCell(cell);
00160     this -> completePopulations(tmpCell);
00161     this->getBaseDynamics().computeRhoBarJPiNeq(tmpCell, rhoBar, j, PiNeq);
00162 }
00163 
00164 template<typename T, template<typename U> class Descriptor>
00165 T BoundaryCompositeDynamics<T,Descriptor>::computeEbar(Cell<T,Descriptor> const& cell) const {
00166     Cell<T,Descriptor> tmpCell(cell);
00167     this -> completePopulations(tmpCell);
00168     return this->getBaseDynamics().computeEbar(tmpCell);
00169 }
00170 
00176 template<typename T, template<typename U> class Descriptor>
00177 void BoundaryCompositeDynamics<T,Descriptor>::completePopulations(Cell<T,Descriptor>& cell) const
00178 { }
00179 
00180 
00181 /* *************** Class StoreDensityDynamics *********************** */
00182 
00183 template<typename T, template<typename U> class Descriptor>
00184 int StoreDensityDynamics<T,Descriptor>::id =
00185     meta::registerGeneralDynamics<T,Descriptor, StoreDensityDynamics<T,Descriptor> >("Boundary_StoreDensity");
00186 
00187 template<typename T, template<typename U> class Descriptor>
00188 StoreDensityDynamics<T,Descriptor>::StoreDensityDynamics(Dynamics<T,Descriptor>* baseDynamics_,
00189                                                          bool automaticPrepareCollision_ )
00190     : BoundaryCompositeDynamics<T,Descriptor>(baseDynamics_,automaticPrepareCollision_)
00191 {
00192     rhoBar = Descriptor<T>::rhoBar((T)1);
00193 }
00194 
00195 template<typename T, template<typename U> class Descriptor>
00196 StoreDensityDynamics<T,Descriptor>::StoreDensityDynamics(HierarchicUnserializer& unserializer)
00197     : BoundaryCompositeDynamics<T,Descriptor>(0,false)
00198 {
00199     unserialize(unserializer);
00200 }
00201 
00202 template<typename T, template<typename U> class Descriptor>
00203 StoreDensityDynamics<T,Descriptor>* StoreDensityDynamics<T,Descriptor>::clone() const
00204 {
00205     return new StoreDensityDynamics<T,Descriptor>(*this);
00206 }
00207  
00208 template<typename T, template<typename U> class Descriptor>
00209 int StoreDensityDynamics<T,Descriptor>::getId() const {
00210     return id;
00211 }
00212 
00213 template<typename T, template<typename U> class Descriptor>
00214 void StoreDensityDynamics<T,Descriptor>::unserialize(HierarchicUnserializer& unserializer)
00215 {
00216     unserializer.readValue(rhoBar);
00217     BoundaryCompositeDynamics<T,Descriptor>::unserialize(unserializer);
00218 }
00219 
00220 template<typename T, template<typename U> class Descriptor>
00221 void StoreDensityDynamics<T,Descriptor>::serialize(HierarchicSerializer& serializer) const
00222 {
00223     serializer.addValue(rhoBar);
00224     BoundaryCompositeDynamics<T,Descriptor>::serialize(serializer);
00225 }
00226 
00227 template<typename T, template<typename U> class Descriptor>
00228 T StoreDensityDynamics<T,Descriptor>::computeDensity(Cell<T,Descriptor> const& cell) const
00229 {
00230     return Descriptor<T>::fullRho(rhoBar);
00231 }
00232 
00233 template<typename T, template<typename U> class Descriptor>
00234 void StoreDensityDynamics<T,Descriptor>::defineDensity (
00235         Cell <T,Descriptor>& cell, T rho_ )
00236 {
00237     rhoBar = Descriptor<T>::rhoBar(rho_);
00238 }
00239 
00240 template<typename T, template<typename U> class Descriptor>
00241 T StoreDensityDynamics<T,Descriptor>::computeRhoBar(Cell<T,Descriptor> const& cell) const
00242 {
00243     return rhoBar;
00244 }
00245 
00246 template<typename T, template<typename U> class Descriptor>
00247 void StoreDensityDynamics<T,Descriptor>::computeRhoBarJ (
00248         Cell<T,Descriptor> const& cell, T& rhoBar_, Array<T,Descriptor<T>::d>& j) const
00249 {
00250     BoundaryCompositeDynamics<T,Descriptor>::computeRhoBarJ(cell, rhoBar_, j);
00251     rhoBar_ = rhoBar;
00252 }
00253 
00254 
00255 /* *************** Class StoreVelocityDynamics *********************** */
00256 
00257 template<typename T, template<typename U> class Descriptor>
00258 int StoreVelocityDynamics<T,Descriptor>::id =
00259     meta::registerGeneralDynamics<T,Descriptor, StoreVelocityDynamics<T,Descriptor> >("Boundary_StoreVelocity");
00260 
00261 template<typename T, template<typename U> class Descriptor>
00262 StoreVelocityDynamics<T,Descriptor>::StoreVelocityDynamics( Dynamics<T,Descriptor>* baseDynamics_,
00263                                                             bool automaticPrepareCollision_ )
00264     : BoundaryCompositeDynamics<T,Descriptor>(baseDynamics_,automaticPrepareCollision_)
00265 {
00266     velocity.resetToZero();
00267 }
00268 
00269 template<typename T, template<typename U> class Descriptor>
00270 StoreVelocityDynamics<T,Descriptor>::StoreVelocityDynamics(HierarchicUnserializer& unserializer)
00271     : BoundaryCompositeDynamics<T,Descriptor>(0,false)
00272 {
00273     unserialize(unserializer);
00274 }
00275 
00276 template<typename T, template<typename U> class Descriptor>
00277 StoreVelocityDynamics<T,Descriptor>* StoreVelocityDynamics<T,Descriptor>::clone() const
00278 {
00279     return new StoreVelocityDynamics<T,Descriptor>(*this);
00280 }
00281  
00282 template<typename T, template<typename U> class Descriptor>
00283 int StoreVelocityDynamics<T,Descriptor>::getId() const {
00284     return id;
00285 }
00286 
00287 template<typename T, template<typename U> class Descriptor>
00288 void StoreVelocityDynamics<T,Descriptor>::unserialize(HierarchicUnserializer& unserializer)
00289 {
00290     PLB_PRECONDITION( unserializer.getId() == this->getId() );
00291     for (plint iDim=0; iDim<Descriptor<T>::d; ++iDim) {
00292         unserializer.readValue(velocity[iDim]);
00293     }
00294     BoundaryCompositeDynamics<T,Descriptor>::unserialize(unserializer);
00295 }
00296 
00297 template<typename T, template<typename U> class Descriptor>
00298 void StoreVelocityDynamics<T,Descriptor>::serialize(HierarchicSerializer& serializer) const
00299 {
00300     for (plint iDim=0; iDim<Descriptor<T>::d; ++iDim) {
00301         serializer.addValue(velocity[iDim]);
00302     }
00303     BoundaryCompositeDynamics<T,Descriptor>::serialize(serializer);
00304 }
00305 
00306 template<typename T, template<typename U> class Descriptor>
00307 void StoreVelocityDynamics<T,Descriptor>::computeVelocity (
00308         Cell<T,Descriptor> const& cell, Array<T,Descriptor<T>::d>& velocity_ ) const
00309 {
00310     for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00311         velocity_[iD] = velocity[iD];
00312     }
00313 }
00314 
00315 template<typename T, template<typename U> class Descriptor>
00316 void StoreVelocityDynamics<T,Descriptor>::defineVelocity (
00317         Cell<T,Descriptor>& cell, Array<T,Descriptor<T>::d> const& velocity_ )
00318 {
00319     for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00320         velocity[iD] = velocity_[iD];
00321     }
00322 }
00323 
00324 template<typename T, template<typename U> class Descriptor>
00325 T StoreVelocityDynamics<T,Descriptor>::computeRhoBar(Cell<T,Descriptor> const& cell) const {
00326     T rho = this->computeDensity(cell);
00327     return Descriptor<T>::rhoBar(rho);
00328 }
00329 
00330 template<typename T, template<typename U> class Descriptor>
00331 void StoreVelocityDynamics<T,Descriptor>::computeRhoBarJ (
00332         Cell<T,Descriptor> const& cell,
00333         T& rhoBar_, Array<T,Descriptor<T>::d>& j) const
00334 {
00335     T rho = this->computeDensity(cell);
00336     rhoBar_ = Descriptor<T>::rhoBar(rho);
00337     for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00338         // Use the formula uLB = uP - 1/2 g. If there is no external force,
00339         //   the force term automatically evaluates to zero.
00340         j[iD] = rho * (velocity[iD] - 0.5*getExternalForceComponent(cell,iD));
00341     }
00342 }
00343 
00344 
00345 /* *************** Class StoreDensityAndVelocityDynamics ************* */
00346 
00347 template<typename T, template<typename U> class Descriptor>
00348 int StoreDensityAndVelocityDynamics<T,Descriptor>::id =
00349     meta::registerGeneralDynamics<T,Descriptor, StoreDensityAndVelocityDynamics<T,Descriptor> >("Boundary_StoreDensityAndVelocity");
00350 
00351 template<typename T, template<typename U> class Descriptor>
00352 StoreDensityAndVelocityDynamics<T,Descriptor>::StoreDensityAndVelocityDynamics (
00353         Dynamics<T,Descriptor>* baseDynamics_, bool automaticPrepareCollision_ )
00354     : BoundaryCompositeDynamics<T,Descriptor>(baseDynamics_, automaticPrepareCollision_)
00355 {
00356     rhoBar = Descriptor<T>::rhoBar((T)1);
00357     velocity.resetToZero();
00358 }
00359 
00360 template<typename T, template<typename U> class Descriptor>
00361 StoreDensityAndVelocityDynamics<T,Descriptor>::StoreDensityAndVelocityDynamics(HierarchicUnserializer& unserializer)
00362     : BoundaryCompositeDynamics<T,Descriptor>(0,false)
00363 {
00364     unserialize(unserializer);
00365 }
00366 
00367 template<typename T, template<typename U> class Descriptor>
00368 StoreDensityAndVelocityDynamics<T,Descriptor>* StoreDensityAndVelocityDynamics<T,Descriptor>::clone() const
00369 {
00370     return new StoreDensityAndVelocityDynamics<T,Descriptor>(*this);
00371 }
00372  
00373 template<typename T, template<typename U> class Descriptor>
00374 int StoreDensityAndVelocityDynamics<T,Descriptor>::getId() const {
00375     return id;
00376 }
00377 
00378 template<typename T, template<typename U> class Descriptor>
00379 void StoreDensityAndVelocityDynamics<T,Descriptor>::unserialize(HierarchicUnserializer& unserializer)
00380 {
00381     PLB_PRECONDITION( unserializer.getId() == this->getId() );
00382     unserializer.readValue(rhoBar);
00383     for (plint iDim=0; iDim<Descriptor<T>::d; ++iDim) {
00384         unserializer.readValue(velocity[iDim]);
00385     }
00386     BoundaryCompositeDynamics<T,Descriptor>::unserialize(unserializer);
00387 }
00388 
00389 template<typename T, template<typename U> class Descriptor>
00390 void StoreDensityAndVelocityDynamics<T,Descriptor>::serialize(HierarchicSerializer& serializer) const
00391 {
00392     serializer.addValue(rhoBar);
00393     for (plint iDim=0; iDim<Descriptor<T>::d; ++iDim) {
00394         serializer.addValue(velocity[iDim]);
00395     }
00396     BoundaryCompositeDynamics<T,Descriptor>::serialize(serializer);
00397 }
00398 
00399 template<typename T, template<typename U> class Descriptor>
00400 T StoreDensityAndVelocityDynamics<T,Descriptor>::computeDensity (
00401         Cell<T,Descriptor> const& cell) const 
00402 {
00403     return Descriptor<T>::fullRho(rhoBar);
00404 }
00405 
00406 template<typename T, template<typename U> class Descriptor>
00407 void StoreDensityAndVelocityDynamics<T,Descriptor>::computeVelocity (
00408         Cell<T,Descriptor> const& cell,
00409         Array<T,Descriptor<T>::d>& velocity_ ) const
00410 {
00411     if (this->velIsJ()) {
00412         for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00413             velocity_[iD] = Descriptor<T>::fullRho(rhoBar)*velocity[iD];
00414         }
00415     }
00416     else {
00417         for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00418             velocity_[iD] = velocity[iD];
00419         }
00420     }
00421 }
00422 
00423 template<typename T, template<typename U> class Descriptor>
00424 void StoreDensityAndVelocityDynamics<T,Descriptor>::defineDensity (
00425         Cell<T,Descriptor>& cell, T rho_)
00426 {
00427     rhoBar = Descriptor<T>::rhoBar(rho_);
00428 }
00429 
00430 template<typename T, template<typename U> class Descriptor>
00431 void StoreDensityAndVelocityDynamics<T,Descriptor>::defineVelocity (
00432         Cell<T,Descriptor>& cell,
00433         Array<T,Descriptor<T>::d> const& velocity_ ) 
00434 {
00435     for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00436         velocity[iD] = velocity_[iD];
00437     }
00438 }
00439 
00440 template<typename T, template<typename U> class Descriptor>
00441 T StoreDensityAndVelocityDynamics<T,Descriptor>::computeRhoBar(Cell<T,Descriptor> const& cell) const {
00442     return rhoBar;
00443 }
00444 
00445 template<typename T, template<typename U> class Descriptor>
00446 void StoreDensityAndVelocityDynamics<T,Descriptor>::computeRhoBarJ (
00447         Cell<T,Descriptor> const& cell,
00448         T& rhoBar_, Array<T,Descriptor<T>::d>& j) const
00449 {
00450     rhoBar_ = rhoBar;
00451     T rho = Descriptor<T>::fullRho(rhoBar);
00452     for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00453         // Use the formula uLB = uP - 1/2 g. If there is no external force,
00454         //   the force term automatically evaluates to zero.
00455         j[iD] = rho * (velocity[iD] - 0.5*getExternalForceComponent(cell,iD));
00456     }
00457 }
00458 
00459 
00460 /* *************** Class StoreTemperatureAndVelocityDynamics ************* */
00461 
00462 template<typename T, template<typename U> class Descriptor>
00463 int StoreTemperatureAndVelocityDynamics<T,Descriptor>::id =
00464     meta::registerGeneralDynamics<T,Descriptor, StoreTemperatureAndVelocityDynamics<T,Descriptor> >
00465                                         ("Boundary_StoreTemperatureAndVelocity");
00466 
00467 template<typename T, template<typename U> class Descriptor>
00468 StoreTemperatureAndVelocityDynamics<T,Descriptor>::StoreTemperatureAndVelocityDynamics (
00469         Dynamics<T,Descriptor>* baseDynamics_, bool automaticPrepareCollision_ )
00470     : BoundaryCompositeDynamics<T,Descriptor>(baseDynamics_, automaticPrepareCollision_)
00471 {
00472     thetaBar = T();
00473     velocity.resetToZero();
00474 }
00475 
00476 template<typename T, template<typename U> class Descriptor>
00477 StoreTemperatureAndVelocityDynamics<T,Descriptor>::StoreTemperatureAndVelocityDynamics(HierarchicUnserializer& unserializer)
00478     : BoundaryCompositeDynamics<T,Descriptor>(0,false)
00479 {
00480     unserialize(unserializer);
00481 }
00482 
00483 template<typename T, template<typename U> class Descriptor>
00484 StoreTemperatureAndVelocityDynamics<T,Descriptor>* StoreTemperatureAndVelocityDynamics<T,Descriptor>::clone() const {
00485     return new StoreTemperatureAndVelocityDynamics<T,Descriptor>(*this);
00486 }
00487  
00488 template<typename T, template<typename U> class Descriptor>
00489 int StoreTemperatureAndVelocityDynamics<T,Descriptor>::getId() const {
00490     return id;
00491 }
00492 
00493 template<typename T, template<typename U> class Descriptor>
00494 void StoreTemperatureAndVelocityDynamics<T,Descriptor>::unserialize(HierarchicUnserializer& unserializer)
00495 {
00496     PLB_PRECONDITION( unserializer.getId() == this->getId() );
00497     unserializer.readValue(thetaBar);
00498     for (plint iDim=0; iDim<Descriptor<T>::d; ++iDim) {
00499         unserializer.readValue(velocity[iDim]);
00500     }
00501     BoundaryCompositeDynamics<T,Descriptor>::unserialize(unserializer);
00502 }
00503 
00504 template<typename T, template<typename U> class Descriptor>
00505 void StoreTemperatureAndVelocityDynamics<T,Descriptor>::serialize(HierarchicSerializer& serializer) const
00506 {
00507     serializer.addValue(thetaBar);
00508     for (plint iDim=0; iDim<Descriptor<T>::d; ++iDim) {
00509         serializer.addValue(velocity[iDim]);
00510     }
00511     BoundaryCompositeDynamics<T,Descriptor>::serialize(serializer);
00512 }
00513 
00514 template<typename T, template<typename U> class Descriptor>
00515 void StoreTemperatureAndVelocityDynamics<T,Descriptor>::computeVelocity(
00516         Cell<T,Descriptor> const& cell, Array<T,Descriptor<T>::d>& velocity_ ) const
00517 {
00518     for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00519         velocity_[iD] = velocity[iD];
00520     }
00521 }
00522 
00523 template<typename T, template<typename U> class Descriptor>
00524 T StoreTemperatureAndVelocityDynamics<T,Descriptor>::computeTemperature (
00525         Cell<T,Descriptor> const& cell) const
00526 {
00527     return (thetaBar + (T)1)*Descriptor<T>::cs2;
00528 }
00529 
00530 template<typename T, template<typename U> class Descriptor>
00531 void StoreTemperatureAndVelocityDynamics<T,Descriptor>::defineVelocity (
00532         Cell<T,Descriptor>& cell, Array<T,Descriptor<T>::d> const& velocity_ )
00533 {
00534     for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00535         velocity[iD] = velocity_[iD];
00536     }
00537 }
00538 
00539 template<typename T, template<typename U> class Descriptor>
00540 void StoreTemperatureAndVelocityDynamics<T,Descriptor>::defineTemperature (
00541         Cell<T,Descriptor>& cell, T theta_ )
00542 {
00543     thetaBar = theta_* Descriptor<T>::invCs2 - (T)1;
00544 }
00545 
00546 template<typename T, template<typename U> class Descriptor>
00547 T StoreTemperatureAndVelocityDynamics<T,Descriptor>::computeRhoBar(Cell<T,Descriptor> const& cell) const {
00548     T rho = this->computeDensity(cell);
00549     return Descriptor<T>::rhoBar(rho);
00550 }
00551 
00552 template<typename T, template<typename U> class Descriptor>
00553 void StoreTemperatureAndVelocityDynamics<T,Descriptor>::computeRhoBarJ (
00554         Cell<T,Descriptor> const& cell,
00555         T& rhoBar_, Array<T,Descriptor<T>::d>& j) const
00556 {
00557     T rho = this->computeDensity(cell);
00558     rhoBar_ = Descriptor<T>::rhoBar(rho);
00559     for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00560         // Use the formula uLB = uP - 1/2 g. If there is no external force,
00561         //   the force term automatically evaluates to zero.
00562         j[iD] = rho * (velocity[iD] - 0.5*getExternalForceComponent(cell,iD));
00563     }
00564 }
00565 
00566 
00567 /* *************** Class VelocityDirichletBoundaryDynamics ************* */
00568 
00569 template<typename T, template<typename U> class Descriptor,
00570          int direction, int orientation>
00571 int VelocityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::id =
00572     meta::registerGeneralDynamics<T,Descriptor, VelocityDirichletBoundaryDynamics<T,Descriptor,direction,orientation> >
00573             ( std::string("Boundary_VelocityDirichlet_")+util::val2str(direction) +
00574               std::string("_")+util::val2str(orientation) );
00575 
00576 template<typename T, template<typename U> class Descriptor,
00577          int direction, int orientation>
00578 VelocityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::
00579     VelocityDirichletBoundaryDynamics(Dynamics<T,Descriptor>* baseDynamics_, bool automaticPrepareCollision_)
00580         : StoreVelocityDynamics<T,Descriptor>(baseDynamics_, automaticPrepareCollision_)
00581 { }
00582 
00583 template<typename T, template<typename U> class Descriptor,
00584          int direction, int orientation>
00585 VelocityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::
00586     VelocityDirichletBoundaryDynamics(HierarchicUnserializer& unserializer)
00587         : StoreVelocityDynamics<T,Descriptor>(0, false)
00588 {
00589     this->unserialize(unserializer);
00590 }
00591 
00592 template<typename T, template<typename U> class Descriptor,
00593          int direction, int orientation>
00594 VelocityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>*
00595     VelocityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::clone() const
00596 {
00597     return new VelocityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>(*this);
00598 }
00599  
00600 template<typename T, template<typename U> class Descriptor,
00601          int direction, int orientation>
00602 int VelocityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::getId() const {
00603     return id;
00604 }
00605 
00606 template<typename T, template<typename U> class Descriptor,
00607          int direction, int orientation>
00608 void VelocityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::serialize(HierarchicSerializer& serializer) const
00609 {
00610     StoreVelocityDynamics<T,Descriptor>::serialize(serializer);
00611 }
00612 
00613 template<typename T, template<typename U> class Descriptor,
00614          int direction, int orientation>
00615 void VelocityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::unserialize(HierarchicUnserializer& unserializer)
00616 {
00617     StoreVelocityDynamics<T,Descriptor>::unserialize(unserializer);
00618 }
00619 
00620 template<typename T, template<typename U> class Descriptor,
00621          int direction, int orientation>
00622 T VelocityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::
00623     computeRhoBar(Cell<T,Descriptor> const& cell) const 
00624 {
00625     std::vector<plint> const& onWallIndices
00626         = indexTemplates::subIndex<Descriptor<T>, direction, 0>();
00627 
00628     std::vector<plint> const& normalIndices
00629         = indexTemplates::subIndex<Descriptor<T>, direction, orientation>();
00630 
00631     T rhoOnWall = T();
00632     for (pluint fIndex=0; fIndex<onWallIndices.size(); ++fIndex) {
00633         rhoOnWall += cell[onWallIndices[fIndex]];
00634     }
00635 
00636     T rhoNormal = T();
00637     for (pluint fIndex=0; fIndex<normalIndices.size(); ++fIndex) {
00638         rhoNormal += cell[normalIndices[fIndex]];
00639     }
00640 
00641     T velNormal = (T)orientation * (
00642                     this->velocity[direction]-0.5*getExternalForceComponent(cell,direction) );
00643     if (this->velIsJ()) {
00644         T rhoBar = (T)2*rhoNormal+rhoOnWall-velNormal;
00645         return rhoBar;
00646     }
00647     else {
00648         T rhoBar =((T)2*rhoNormal+rhoOnWall-Descriptor<T>::SkordosFactor()*velNormal)
00649                       / ((T)1+velNormal);
00650         return rhoBar;
00651     }
00652 }
00653 
00654 
00655 template<typename T, template<typename U> class Descriptor,
00656          int direction, int orientation>
00657 T VelocityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::
00658     computeDensity(Cell<T,Descriptor> const& cell) const 
00659 {
00660     return Descriptor<T>::fullRho(computeRhoBar(cell));
00661 }
00662 
00663 template<typename T, template<typename U> class Descriptor,
00664          int direction, int orientation>
00665 void VelocityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::computeRhoBarJ (
00666         Cell<T,Descriptor> const& cell,
00667         T& rhoBar_, Array<T,Descriptor<T>::d>& j) const
00668 {
00669     rhoBar_ = computeRhoBar(cell);
00670     T rho = Descriptor<T>::fullRho(rhoBar_);
00671     if (this->velIsJ()) {
00672         for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00673             // Use the formula uLB = uP - 1/2 g. If there is no external force,
00674             //   the force term automatically evaluates to zero.
00675             j[iD] = this->velocity[iD] - 0.5*getExternalForceComponent(cell,iD);
00676         }
00677     }
00678     else {
00679         for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00680             // Use the formula uLB = uP - 1/2 g. If there is no external force,
00681             //   the force term automatically evaluates to zero.
00682             j[iD] = rho * (this->velocity[iD] - 0.5*getExternalForceComponent(cell,iD));
00683         }
00684     }
00685 }
00686 
00687 
00688 /* *************** Class DensityDirichletBoundaryDynamics ************* */
00689 
00690 template<typename T, template<typename U> class Descriptor,
00691          int direction, int orientation>
00692 int DensityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::id =
00693     meta::registerGeneralDynamics<T,Descriptor, DensityDirichletBoundaryDynamics<T,Descriptor,direction,orientation> > (
00694             std::string("Boundary_DensityDirichlet_")+util::val2str(direction) +
00695             std::string("_")+util::val2str(orientation) );
00696 
00697 template<typename T, template<typename U> class Descriptor,
00698          int direction, int orientation>
00699 DensityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::
00700     DensityDirichletBoundaryDynamics(Dynamics<T,Descriptor>* baseDynamics_, bool automaticPrepareCollision_)
00701         : StoreDensityDynamics<T,Descriptor>(baseDynamics_, automaticPrepareCollision_)
00702 { }
00703 
00704 template<typename T, template<typename U> class Descriptor,
00705          int direction, int orientation>
00706 DensityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::
00707     DensityDirichletBoundaryDynamics(HierarchicUnserializer& unserializer)
00708         : StoreDensityDynamics<T,Descriptor>(0, false)
00709 {
00710     this->unserialize(unserializer);
00711 }
00712 
00713 template<typename T, template<typename U> class Descriptor,
00714          int direction, int orientation>
00715 DensityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>*
00716     DensityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::clone() const
00717 {
00718     return new DensityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>(*this);
00719 }
00720  
00721 template<typename T, template<typename U> class Descriptor,
00722          int direction, int orientation>
00723 int DensityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::getId() const {
00724     return id;
00725 }
00726 
00727 template<typename T, template<typename U> class Descriptor,
00728          int direction, int orientation>
00729 void DensityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::serialize(HierarchicSerializer& serializer) const
00730 {
00731     StoreDensityDynamics<T,Descriptor>::serialize(serializer);
00732 }
00733 
00734 template<typename T, template<typename U> class Descriptor,
00735          int direction, int orientation>
00736 void DensityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::unserialize(HierarchicUnserializer& unserializer)
00737 {
00738     StoreDensityDynamics<T,Descriptor>::unserialize(unserializer);
00739 }
00740 
00741 template<typename T, template<typename U> class Descriptor,
00742          int direction, int orientation>
00743 void DensityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::
00744     computeJ( Cell<T,Descriptor> const& cell,
00745               Array<T,Descriptor<T>::d>& j_ ) const
00746 {
00747     // All velocity components parallel to the wall are zero by definition.
00748     for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00749         j_[iD] = T();
00750     }
00751     T rhoBar = this -> rhoBar;
00752 
00753     std::vector<plint> const& onWallIndices
00754         = indexTemplates::subIndex<Descriptor<T>, direction, 0>();
00755 
00756     std::vector<plint> const& normalIndices
00757         = indexTemplates::subIndex<Descriptor<T>, direction, orientation>();
00758 
00759     T rhoOnWall = T();
00760     for (pluint fIndex=0; fIndex<onWallIndices.size(); ++fIndex) {
00761         rhoOnWall += cell[onWallIndices[fIndex]];
00762     }
00763 
00764     T rhoNormal = T();
00765     for (pluint fIndex=0; fIndex<normalIndices.size(); ++fIndex) {
00766         rhoNormal += cell[normalIndices[fIndex]];
00767     }
00768 
00769     j_[direction] = (T)orientation*((T)2*rhoNormal+rhoOnWall-rhoBar);
00770 }
00771 
00772 template<typename T, template<typename U> class Descriptor,
00773          int direction, int orientation>
00774 void DensityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::
00775     computeVelocity( Cell<T,Descriptor> const& cell,
00776                      Array<T,Descriptor<T>::d>& velocity_ ) const
00777 {
00778     this->computeJ(cell, velocity_);
00779     if (this->velIsJ()) {
00780         for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00781             // Use the formula uLB = uP - 1/2 g. If there is no external force,
00782             //   the force term automatically evaluates to zero.
00783             velocity_[iD] += 0.5*getExternalForceComponent(cell,iD);
00784         }
00785     }
00786     else {
00787         T invRho = Descriptor<T>::invRho(this->rhoBar);
00788         for (int iD=0; iD<Descriptor<T>::d; ++iD) {
00789             // Use the formula uLB = uP - 1/2 g. If there is no external force,
00790             //   the force term automatically evaluates to zero.
00791             velocity_[iD] *= invRho;
00792             velocity_[iD] += 0.5*getExternalForceComponent(cell,iD);
00793         }
00794     }
00795 }
00796 
00797 template<typename T, template<typename U> class Descriptor,
00798          int direction, int orientation>
00799 void DensityDirichletBoundaryDynamics<T,Descriptor,direction,orientation>::computeRhoBarJ (
00800         Cell<T,Descriptor> const& cell,
00801         T& rhoBar_, Array<T,Descriptor<T>::d>& j) const
00802 {
00803     rhoBar_ = this->rhoBar;
00804     this->computeJ(cell, j);
00805 }
00806 
00807 }  // namespace plb
00808 
00809 #endif  // BOUNDARY_DYNAMICS_HH