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

offLatticeBoundaryProfiles3D.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 
00025 #ifndef OFF_LATTICE_BOUNDARY_PROFILES_3D_HH
00026 #define OFF_LATTICE_BOUNDARY_PROFILES_3D_HH
00027 
00028 #include "core/globalDefs.h"
00029 #include "offLattice/offLatticeBoundaryProfiles3D.h"
00030 
00031 namespace plb {
00032 
00033 template<typename T>
00034 struct DefaultWallProfile3D<T, Array<T,3> > {
00035     BoundaryProfile3D<T,Array<T,3> >* generate() {
00036         return new NoSlipProfile3D<T>();
00037     }
00038 };
00039 
00040 template<typename T>
00041 struct DefaultWallProfile3D<T, Array<T,2> > {
00042     BoundaryProfile3D<T, Array<T,2> >* generate() {
00043         return new ScalarNeumannProfile3D<T>();
00044     }
00045 };
00046 
00047 
00048 /********** NoSlipProfile3D ********************************************/
00049 
00050 template<typename T>
00051 void NoSlipProfile3D<T>::setNormal(Array<T,3> const& normal_)
00052 { }
00053 
00054 template<typename T>
00055 void NoSlipProfile3D<T>::defineCircularShape(Array<T,3> const& center_, T radius_)
00056 { }
00057 
00058 template<typename T>
00059 void NoSlipProfile3D<T>::getData (
00060         Array<T,3> const& pos, plint id, AtomicBlock3D const* argument,
00061         Array<T,3>& data, OffBoundary::Type& bdType ) const
00062 {
00063     data.resetToZero();
00064     bdType = OffBoundary::dirichlet;
00065 }
00066 
00067 template<typename T>
00068 NoSlipProfile3D<T>* 
00069     NoSlipProfile3D<T>::clone() const
00070 {
00071     return new NoSlipProfile3D<T>(*this);
00072 }
00073 
00074 
00075 /********** FreeSlipProfile3D ********************************************/
00076 
00077 template<typename T>
00078 void FreeSlipProfile3D<T>::setNormal(Array<T,3> const& normal_)
00079 { }
00080 
00081 template<typename T>
00082 void FreeSlipProfile3D<T>::defineCircularShape(Array<T,3> const& center_, T radius_)
00083 { }
00084 
00085 template<typename T>
00086 void FreeSlipProfile3D<T>::getData (
00087         Array<T,3> const& pos, plint id, AtomicBlock3D const* argument,
00088         Array<T,3>& data, OffBoundary::Type& bdType ) const
00089 {
00090     data.resetToZero();
00091     bdType = OffBoundary::freeSlip;
00092 }
00093 
00094 template<typename T>
00095 FreeSlipProfile3D<T>* 
00096     FreeSlipProfile3D<T>::clone() const
00097 {
00098     return new FreeSlipProfile3D<T>(*this);
00099 }
00100 
00101 
00102 /********** PoiseuilleProfile3D ********************************************/
00103 
00104 template<typename T>
00105 PoiseuilleProfile3D<T>::PoiseuilleProfile3D(T uAverage_)
00106     : uAverage(uAverage_),
00107       normal(T(),T(),T()),
00108       center(T(),T(),T()),
00109       radius((T)1)
00110 { }
00111 
00112 template<typename T>
00113 void PoiseuilleProfile3D<T>::setNormal(Array<T,3> const& normal_) {
00114     normal = normal_;
00115 }
00116 
00117 template<typename T>
00118 void PoiseuilleProfile3D<T>::defineCircularShape(Array<T,3> const& center_, T radius_)
00119 {
00120     center = center_;
00121     radius = radius_;
00122 }
00123 
00124 template<typename T>
00125 void PoiseuilleProfile3D<T>::getData (
00126         Array<T,3> const& pos, plint id, AtomicBlock3D const* argument,
00127         Array<T,3>& data, OffBoundary::Type& bdType ) const
00128 {
00129     bdType = OffBoundary::dirichlet;
00130     Array<T,3> radial = pos-center;
00131     T r = norm(radial) / radius;
00132     if (r<=(T)1.) {
00133         data = 2*uAverage*(1-r*r)*(-normal);
00134     }
00135     else {
00136         data.resetToZero();
00137     }
00138 }
00139 
00140 template<typename T>
00141 PoiseuilleProfile3D<T>*
00142     PoiseuilleProfile3D<T>::clone() const
00143 {
00144     return new PoiseuilleProfile3D<T>(*this);
00145 }
00146 
00147 
00148 /********** IncreasingPoiseuilleProfile3D ********************************************/
00149 
00150 template< typename T, template<typename U> class Descriptor>
00151 IncreasingPoiseuilleProfile3D<T,Descriptor>::IncreasingPoiseuilleProfile3D (
00152         T uAverage_, plint maxT_ )
00153     : uAverage(uAverage_),
00154       maxT(maxT_),
00155       normal(T(),T(),T()),
00156       center(T(),T(),T()),
00157       radius((T)1)
00158 { }
00159 
00160 template< typename T, template<typename U> class Descriptor>
00161 void IncreasingPoiseuilleProfile3D<T,Descriptor>::setNormal(Array<T,3> const& normal_) {
00162     normal = normal_;
00163 }
00164 
00165 template< typename T, template<typename U> class Descriptor>
00166 void IncreasingPoiseuilleProfile3D<T,Descriptor>::defineCircularShape (
00167         Array<T,3> const& center_, T radius_ )
00168 {
00169     center = center_;
00170     radius = radius_;
00171 }
00172 
00173 template< typename T, template<typename U> class Descriptor>
00174 void IncreasingPoiseuilleProfile3D<T,Descriptor>::getData (
00175         Array<T,3> const& pos, plint id, AtomicBlock3D const* argument,
00176         Array<T,3>& data, OffBoundary::Type& bdType ) const
00177 {
00178     bdType = OffBoundary::dirichlet;
00179     BlockLattice3D<T,Descriptor> const* lattice =
00180         dynamic_cast<BlockLattice3D<T,Descriptor> const* >(argument);
00181     plint t = lattice->getTimeCounter().getTime();
00182     T signal=T();
00183     if (t<maxT) {
00184         signal = (T)0.5*((T)1+tanh((T)6/(T)maxT*((T)t-(T)maxT/(T)2)));
00185     }
00186     else {
00187         signal = (T)1;
00188     }
00189     Array<T,3> radial = pos-center;
00190     T r = norm(radial) / radius;
00191     if (r<=(T)1.) {
00192         data = signal*2*uAverage*(1-r*r)*(-normal);
00193     }
00194     else {
00195         data.resetToZero();
00196     }
00197 }
00198 
00199 template< typename T, template<typename U> class Descriptor>
00200 IncreasingPoiseuilleProfile3D<T,Descriptor>*
00201     IncreasingPoiseuilleProfile3D<T,Descriptor>::clone() const
00202 {
00203     return new IncreasingPoiseuilleProfile3D<T,Descriptor>(*this);
00204 }
00205 
00206 
00207 /********** OscillatingPoiseuilleProfile3D ********************************************/
00208 
00209 template< typename T, template<typename U> class Descriptor>
00210 OscillatingPoiseuilleProfile3D<T,Descriptor>::OscillatingPoiseuilleProfile3D (
00211         T minUave_, T maxUave_, T period_ )
00212     : minUave(minUave_),
00213       maxUave(maxUave_),
00214       period(period_),
00215       normal(T(),T(),T()),
00216       center(T(),T(),T()),
00217       radius((T)1)
00218 { }
00219 
00220 template< typename T, template<typename U> class Descriptor>
00221 void OscillatingPoiseuilleProfile3D<T,Descriptor>::setNormal(Array<T,3> const& normal_)
00222 {
00223     normal = normal_;
00224 }
00225 
00226 template< typename T, template<typename U> class Descriptor>
00227 void OscillatingPoiseuilleProfile3D<T,Descriptor>::defineCircularShape (
00228         Array<T,3> const& center_, T radius_ )
00229 {
00230     center = center_;
00231     radius = radius_;
00232 }
00233 
00234 template< typename T, template<typename U> class Descriptor>
00235 void OscillatingPoiseuilleProfile3D<T,Descriptor>::getData (
00236         Array<T,3> const& pos, plint id, AtomicBlock3D const* argument,
00237         Array<T,3>& data, OffBoundary::Type& bdType ) const
00238 {
00239     bdType = OffBoundary::dirichlet;
00240     static const T pi = 4.*atan(1.);
00241     BlockLattice3D<T,Descriptor> const* lattice =
00242         dynamic_cast<BlockLattice3D<T,Descriptor> const* >(argument);
00243     PLB_ASSERT(lattice);
00244     T t = (T) lattice->getTimeCounter().getTime();
00245     T signal = (sin(2.*pi*t/period)+1.)*0.5;
00246 
00247     Array<T,3> radial = pos-center;
00248     T r = norm(radial) / radius;
00249     if (r<=(T)1.) {
00250         data = ( minUave+(maxUave-minUave)*signal* 2*(1-r*r) ) * (-normal);
00251     }
00252     else {
00253         data.resetToZero();
00254     }
00255 }
00256 
00257 template< typename T, template<typename U> class Descriptor>
00258 OscillatingPoiseuilleProfile3D<T,Descriptor>*
00259     OscillatingPoiseuilleProfile3D<T,Descriptor>::clone() const
00260 {
00261     return new OscillatingPoiseuilleProfile3D<T,Descriptor>(*this);
00262 }
00263 
00264 
00265 /********** ConstantVelocityProfile3D ********************************************/
00266 
00267 template<typename T>
00268 ConstantVelocityProfile3D<T>::ConstantVelocityProfile3D(Array<T,3> const& u_)
00269     : u(u_)
00270 { }
00271 
00272 template<typename T>
00273 void ConstantVelocityProfile3D<T>::setNormal(Array<T,3> const& normal_)
00274 { }
00275 
00276 template<typename T>
00277 void ConstantVelocityProfile3D<T>::defineCircularShape(Array<T,3> const& center_, T radius_)
00278 { }
00279 
00280 template<typename T>
00281 void ConstantVelocityProfile3D<T>::getData (
00282         Array<T,3> const& pos, plint id, AtomicBlock3D const* argument,
00283         Array<T,3>& data, OffBoundary::Type& bdType ) const
00284 {
00285     bdType = OffBoundary::dirichlet;
00286     data = u;
00287 }
00288 
00289 template<typename T>
00290 ConstantVelocityProfile3D<T>*
00291     ConstantVelocityProfile3D<T>::clone() const
00292 {
00293     return new ConstantVelocityProfile3D<T>(*this);
00294 }
00295 
00296 
00297 /********** VelocityPlugProfile3D ********************************************/
00298 
00299 template<typename T>
00300 VelocityPlugProfile3D<T>::VelocityPlugProfile3D(T uMax_)
00301     : uMax(uMax_),
00302       normal(T(),T(),T())
00303 { }
00304 
00305 template<typename T>
00306 void VelocityPlugProfile3D<T>::setNormal(Array<T,3> const& normal_) {
00307     normal = normal_;
00308 }
00309 
00310 template<typename T>
00311 void VelocityPlugProfile3D<T>::defineCircularShape(Array<T,3> const& center_, T radius_)
00312 { }
00313 
00314 template<typename T>
00315 void VelocityPlugProfile3D<T>::getData (
00316         Array<T,3> const& pos, plint id, AtomicBlock3D const* argument,
00317         Array<T,3>& data, OffBoundary::Type& bdType ) const
00318 {
00319     bdType = OffBoundary::dirichlet;
00320     data = -uMax*normal;
00321 }
00322 
00323 template<typename T>
00324 VelocityPlugProfile3D<T>*
00325     VelocityPlugProfile3D<T>::clone() const
00326 {
00327     return new VelocityPlugProfile3D<T>(*this);
00328 }
00329 
00330 
00331 /********** NeumannBoundaryProfile3D ******************************************/
00332 
00333 template<typename T>
00334 void NeumannBoundaryProfile3D<T>::setNormal(Array<T,3> const& normal_)
00335 {
00336     normal = normal_;
00337 }
00338 
00339 template<typename T>
00340 void NeumannBoundaryProfile3D<T>::defineCircularShape (
00341         Array<T,3> const& center_, T radius_ )
00342 { }
00343 
00344 template<typename T>
00345 void NeumannBoundaryProfile3D<T>::getData (
00346         Array<T,3> const& pos, plint id, AtomicBlock3D const* argument,
00347         Array<T,3>& data, OffBoundary::Type& bdType ) const
00348 {
00349     bdType = OffBoundary::neumann;
00350     // In a Neumann condition, the velocity will need to be
00351     //   computed in the actual off-lattice boundary algorithm.
00352     //   Nothing to be done here.
00353     data.resetToZero();
00354 }
00355 
00356 template<typename T>
00357 NeumannBoundaryProfile3D<T>* 
00358     NeumannBoundaryProfile3D<T>::clone() const
00359 {
00360     return new NeumannBoundaryProfile3D<T>(*this);
00361 }
00362 
00363 
00364 /********** DensityNeumannBoundaryProfile3D ******************************************/
00365 
00366 template<typename T>
00367 DensityNeumannBoundaryProfile3D<T>::DensityNeumannBoundaryProfile3D(T rho_)
00368     : rho(rho_)
00369 { }
00370 
00371 template<typename T>
00372 void DensityNeumannBoundaryProfile3D<T>::setNormal(Array<T,3> const& normal_)
00373 {
00374     normal = normal_;
00375 }
00376 
00377 template<typename T>
00378 void DensityNeumannBoundaryProfile3D<T>::defineCircularShape (
00379         Array<T,3> const& center_, T radius_ )
00380 { }
00381 
00382 template<typename T>
00383 void DensityNeumannBoundaryProfile3D<T>::getData (
00384         Array<T,3> const& pos, plint id, AtomicBlock3D const* argument,
00385         Array<T,3>& data, OffBoundary::Type& bdType ) const
00386 {
00387     bdType = OffBoundary::densityNeumann;
00388     // In a Neumann condition, the velocity will need to be
00389     //   computed in the actual off-lattice boundary algorithm.
00390     //   Nothing to be done here.
00391     data.resetToZero();
00392     data[0] = rho;
00393 }
00394 
00395 template<typename T>
00396 DensityNeumannBoundaryProfile3D<T>* 
00397     DensityNeumannBoundaryProfile3D<T>::clone() const
00398 {
00399     return new DensityNeumannBoundaryProfile3D<T>(*this);
00400 }
00401 
00402 /********** ScalarDirichletProfile3D ******************************************/
00403 
00404 template<typename T>
00405 ScalarDirichletProfile3D<T>::ScalarDirichletProfile3D(T value_)
00406     : value(value_)
00407 { }
00408 
00409 template<typename T>
00410 void ScalarDirichletProfile3D<T>::setNormal(Array<T,3> const& normal_)
00411 { }
00412 
00413 template<typename T>
00414 void ScalarDirichletProfile3D<T>::defineCircularShape (
00415         Array<T,3> const& center_, T radius_ )
00416 { }
00417 
00418 template<typename T>
00419 void ScalarDirichletProfile3D<T>::getData (
00420         Array<T,3> const& pos, plint id, AtomicBlock3D const* argument,
00421         Array<T,2>& data, OffBoundary::Type& bdType ) const
00422 {
00423     bdType = OffBoundary::dirichlet;
00424     data[0] = value;
00425     data[1] = T();  // Second argument is not used here.
00426 }
00427 
00428 template<typename T>
00429 ScalarDirichletProfile3D<T>* 
00430     ScalarDirichletProfile3D<T>::clone() const
00431 {
00432     return new ScalarDirichletProfile3D<T>(*this);
00433 }
00434 
00435 
00436 /********** ScalarNeumannProfile3D ******************************************/
00437 
00438 template<typename T>
00439 void ScalarNeumannProfile3D<T>::setNormal(Array<T,3> const& normal_)
00440 {
00441     normal = normal_;
00442 }
00443 
00444 template<typename T>
00445 void ScalarNeumannProfile3D<T>::defineCircularShape (
00446         Array<T,3> const& center_, T radius_ )
00447 { }
00448 
00449 template<typename T>
00450 void ScalarNeumannProfile3D<T>::getData (
00451         Array<T,3> const& pos, plint id, AtomicBlock3D const* argument,
00452         Array<T,2>& data, OffBoundary::Type& bdType ) const
00453 {
00454     bdType = OffBoundary::neumann;
00455     // Neumann means zero-gradient, the two arguments are unused.
00456     data[0] = T();
00457     data[1] = T();
00458 }
00459 
00460 template<typename T>
00461 ScalarNeumannProfile3D<T>* 
00462     ScalarNeumannProfile3D<T>::clone() const
00463 {
00464     return new ScalarNeumannProfile3D<T>(*this);
00465 }
00466 
00467 
00468 
00469 /********** ScalarFluxProfile3D ******************************************/
00470 
00471 template<typename T>
00472 ScalarFluxProfile3D<T>::ScalarFluxProfile3D(T gradVal_)
00473     : gradVal(gradVal_)
00474 { }
00475 
00476 template<typename T>
00477 void ScalarFluxProfile3D<T>::setNormal(Array<T,3> const& normal_)
00478 {
00479     normal = normal_;
00480 }
00481 
00482 template<typename T>
00483 void ScalarFluxProfile3D<T>::defineCircularShape (
00484         Array<T,3> const& center_, T radius_ )
00485 { }
00486 
00487 template<typename T>
00488 void ScalarFluxProfile3D<T>::getData (
00489         Array<T,3> const& pos, plint id, AtomicBlock3D const* argument,
00490         Array<T,2>& data, OffBoundary::Type& bdType ) const
00491 {
00492     bdType = OffBoundary::flux;
00493     data[0] = gradVal;
00494     data[1] = T();
00495 }
00496 
00497 template<typename T>
00498 ScalarFluxProfile3D<T>* 
00499     ScalarFluxProfile3D<T>::clone() const
00500 {
00501     return new ScalarFluxProfile3D<T>(*this);
00502 }
00503 
00504 
00505 
00506 /********** ScalarIsolationProfile3D ******************************************/
00507 
00508 template<typename T>
00509 ScalarIsolationProfile3D<T>::ScalarIsolationProfile3D(T asymptoticRho_, T kappa_)
00510     : asymptoticRho(asymptoticRho_),
00511       kappa(kappa_)
00512 { }
00513 
00514 template<typename T>
00515 void ScalarIsolationProfile3D<T>::setNormal(Array<T,3> const& normal_)
00516 {
00517     normal = normal_;
00518 }
00519 
00520 template<typename T>
00521 void ScalarIsolationProfile3D<T>::defineCircularShape (
00522         Array<T,3> const& center_, T radius_ )
00523 { }
00524 
00525 template<typename T>
00526 void ScalarIsolationProfile3D<T>::getData (
00527         Array<T,3> const& pos, plint id, AtomicBlock3D const* argument,
00528         Array<T,2>& data, OffBoundary::Type& bdType ) const
00529 {
00530     bdType = OffBoundary::isolation;
00531     data[0] = asymptoticRho;
00532     data[1] = kappa;
00533 }
00534 
00535 template<typename T>
00536 ScalarIsolationProfile3D<T>* 
00537     ScalarIsolationProfile3D<T>::clone() const
00538 {
00539     return new ScalarIsolationProfile3D<T>(*this);
00540 }
00541 
00542 }  // namespace plb
00543 
00544 #endif  // OFF_LATTICE_BOUNDARY_PROFILES_3D_HH