/usr/include/palabos/complexDynamics/asinariModel.hh is in libplb-dev 1.5~r1+repack1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | /* This file is part of the Palabos library.
*
* Copyright (C) 2011-2015 FlowKit Sarl
* Route d'Oron 2
* 1010 Lausanne, Switzerland
* E-mail contact: contact@flowkit.com
*
* The most recent release of Palabos can be downloaded at
* <http://www.palabos.org/>
*
* The library Palabos is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* The library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/** \file
* Implementation of the LW-ACM model by Pietro Asinari and others -- generic implementation.
*/
#ifndef ASINARI_MODEL_HH
#define ASINARI_MODEL_HH
#include "complexDynamics/asinariModel.h"
#include "core/cell.h"
#include "core/dynamicsIdentifiers.h"
#include "latticeBoltzmann/dynamicsTemplates.h"
#include "latticeBoltzmann/momentTemplates.h"
#include "latticeBoltzmann/externalForceTemplates.h"
#include "latticeBoltzmann/offEquilibriumTemplates.h"
#include "core/latticeStatistics.h"
#include "complexDynamics/asinariTemplates.h"
#include "finiteDifference/fdStencils1D.h"
#include <algorithm>
#include <limits>
namespace plb {
/* *************** Class AsinariDynamics *********************************************** */
template<typename T, template<typename U> class Descriptor>
int AsinariDynamics<T,Descriptor>::id =
meta::registerOneParamDynamics<T,Descriptor,AsinariDynamics<T,Descriptor> >("Asinari");
/** \param omega_ relaxation parameter, related to the dynamic viscosity
*/
template<typename T, template<typename U> class Descriptor>
AsinariDynamics<T,Descriptor>::AsinariDynamics(T omega_ )
: IsoThermalBulkDynamics<T,Descriptor>(omega_)
{
computePrefactor();
}
template<typename T, template<typename U> class Descriptor>
AsinariDynamics<T,Descriptor>* AsinariDynamics<T,Descriptor>::clone() const {
return new AsinariDynamics<T,Descriptor>(*this);
}
template<typename T, template<typename U> class Descriptor>
int AsinariDynamics<T,Descriptor>::getId() const {
return id;
}
template<typename T, template<typename U> class Descriptor>
void AsinariDynamics<T,Descriptor>::setOmega(T omega_) {
IsoThermalBulkDynamics<T,Descriptor>::setOmega(omega_);
computePrefactor();
}
template<typename T, template<typename U> class Descriptor>
void AsinariDynamics<T,Descriptor>::collide (
Cell<T,Descriptor>& cell,
BlockStatistics& statistics )
{
typedef Descriptor<T> D;
static const int rhoBarOfs = D::ExternalField::rhoBarBeginsAt;
static const int jOfs = D::ExternalField::jBeginsAt;
typedef asinariTemplates<T,Descriptor> asi;
T rhoBar;
Array<T,Descriptor<T>::d> j;
momentTemplates<T,Descriptor>::get_rhoBar_j(cell, rhoBar, j);
*(cell.getExternal(rhoBarOfs)) = rhoBar;
j.to_cArray(cell.getExternal(jOfs));
T invRho = D::invRho(rhoBar);
T jSqr = normSqr(j);
T uSqr = asi::bgk_collision_stage1(cell, rhoBar, invRho, j, jSqr, prefactor);
if (cell.takesStatistics()) {
gatherStatistics(statistics, rhoBar, uSqr);
}
}
template<typename T, template<typename U> class Descriptor>
void AsinariDynamics<T,Descriptor>::collideExternal (
Cell<T,Descriptor>& cell, T rhoBar,
Array<T,Descriptor<T>::d> const& j, T thetaBar, BlockStatistics& statistics )
{
typedef Descriptor<T> D;
static const int rhoBarOfs = D::ExternalField::rhoBarBeginsAt;
static const int jOfs = D::ExternalField::jBeginsAt;
typedef asinariTemplates<T,Descriptor> asi;
*(cell.getExternal(rhoBarOfs)) = rhoBar;
j.to_cArray(cell.getExternal(jOfs));
T invRho = D::invRho(rhoBar);
T jSqr = normSqr(j);
T uSqr = asi::bgk_collision_stage1(cell, rhoBar, invRho, j, jSqr, prefactor);
if (cell.takesStatistics()) {
gatherStatistics(statistics, rhoBar, uSqr);
}
}
template<typename T, template<typename U> class Descriptor>
T AsinariDynamics<T,Descriptor>::computeEquilibrium (
plint iPop, T rhoBar, Array<T,Descriptor<T>::d> const& j, T jSqr, T thetaBar) const
{
T invRho = Descriptor<T>::invRho(rhoBar);
return dynamicsTemplates<T,Descriptor>::bgk_ma2_equilibrium(iPop, rhoBar, invRho, j, jSqr);
}
template<typename T, template<typename U> class Descriptor>
void AsinariDynamics<T,Descriptor>::computePrefactor() {
T omega = this->getOmega();
prefactor = (T)2*(omega-(T)1)/omega;
}
template<typename T, template<typename U> class Descriptor>
T AsinariDynamics<T,Descriptor>::getParameter(plint whichParameter) const {
if(whichParameter==1000) {
return prefactor;
}
else {
return IsoThermalBulkDynamics<T,Descriptor>::getParameter(whichParameter);
}
}
/* *************** Class IncAsinariDynamics *********************************************** */
template<typename T, template<typename U> class Descriptor>
int IncAsinariDynamics<T,Descriptor>::id =
meta::registerOneParamDynamics<T,Descriptor,IncAsinariDynamics<T,Descriptor> >("Asinari_Incompressible");
/** \param omega_ relaxation parameter, related to the dynamic viscosity
*/
template<typename T, template<typename U> class Descriptor>
IncAsinariDynamics<T,Descriptor>::IncAsinariDynamics(T omega_ )
: IsoThermalBulkDynamics<T,Descriptor>(omega_)
{
computePrefactor();
}
template<typename T, template<typename U> class Descriptor>
IncAsinariDynamics<T,Descriptor>* IncAsinariDynamics<T,Descriptor>::clone() const {
return new IncAsinariDynamics<T,Descriptor>(*this);
}
template<typename T, template<typename U> class Descriptor>
int IncAsinariDynamics<T,Descriptor>::getId() const {
return id;
}
template<typename T, template<typename U> class Descriptor>
void IncAsinariDynamics<T,Descriptor>::setOmega(T omega_) {
IsoThermalBulkDynamics<T,Descriptor>::setOmega(omega_);
computePrefactor();
}
template<typename T, template<typename U> class Descriptor>
void IncAsinariDynamics<T,Descriptor>::computeVelocity (
Cell<T,Descriptor> const& cell, Array<T,Descriptor<T>::d>& u ) const
{
T dummyRhoBar;
this->computeRhoBarJ(cell, dummyRhoBar, u);
}
template<typename T, template<typename U> class Descriptor>
void IncAsinariDynamics<T,Descriptor>::computeRhoBarJPiNeq (
Cell<T,Descriptor> const& cell, T& rhoBar,
Array<T,Descriptor<T>::d>& j, Array<T,SymmetricTensor<T,Descriptor>::n>& PiNeq ) const
{
// Incompressible: rho0=1.
T invRho0 = (T)1.0;
momentTemplates<T,Descriptor>::compute_rhoBar_j_PiNeq(cell, rhoBar, j, PiNeq, invRho0);
}
template<typename T, template<typename U> class Descriptor>
void IncAsinariDynamics<T,Descriptor>::collide (
Cell<T,Descriptor>& cell,
BlockStatistics& statistics )
{
typedef Descriptor<T> D;
static const int rhoBarOfs = D::ExternalField::rhoBarBeginsAt;
static const int jOfs = D::ExternalField::jBeginsAt;
typedef asinariTemplates<T,Descriptor> asi;
T rhoBar;
Array<T,Descriptor<T>::d> j;
momentTemplates<T,Descriptor>::get_rhoBar_j(cell, rhoBar, j);
*(cell.getExternal(rhoBarOfs)) = rhoBar;
j.to_cArray(cell.getExternal(jOfs));
// For the incompressible BGK dynamics, the "1/rho" pre-factor of
// the O(Ma^2) term is unity.
T invRho = (T)1;
T jSqr = normSqr(j);
T uSqr = asi::bgk_collision_stage1(cell, rhoBar, invRho, j, jSqr, prefactor);
if (cell.takesStatistics()) {
gatherStatistics(statistics, rhoBar, uSqr);
}
}
template<typename T, template<typename U> class Descriptor>
void IncAsinariDynamics<T,Descriptor>::collideExternal (
Cell<T,Descriptor>& cell, T rhoBar,
Array<T,Descriptor<T>::d> const& j, T thetaBar, BlockStatistics& statistics )
{
typedef Descriptor<T> D;
static const int rhoBarOfs = D::ExternalField::rhoBarBeginsAt;
static const int jOfs = D::ExternalField::jBeginsAt;
typedef asinariTemplates<T,Descriptor> asi;
*(cell.getExternal(rhoBarOfs)) = rhoBar;
j.to_cArray(cell.getExternal(jOfs));
// For the incompressible BGK dynamics, the "1/rho" pre-factor of
// the O(Ma^2) term is unity.
T invRho = (T)1;
T jSqr = normSqr(j);
T uSqr = asi::bgk_collision_stage1(cell, rhoBar, invRho, j, jSqr, prefactor);
if (cell.takesStatistics()) {
gatherStatistics(statistics, rhoBar, uSqr);
}
}
template<typename T, template<typename U> class Descriptor>
T IncAsinariDynamics<T,Descriptor>::computeEquilibrium (
plint iPop, T rhoBar, Array<T,Descriptor<T>::d> const& j, T jSqr, T thetaBar) const
{
// For the incompressible BGK dynamics, the "1/rho" pre-factor of
// the O(Ma^2) term is unity.
T invRho = (T)1;
return dynamicsTemplates<T,Descriptor>::bgk_ma2_equilibrium(iPop, rhoBar, invRho, j, jSqr);
}
template<typename T, template<typename U> class Descriptor>
void IncAsinariDynamics<T,Descriptor>::computePrefactor() {
T omega = this->getOmega();
prefactor = (T)2*(omega-(T)1)/omega;
}
template<typename T, template<typename U> class Descriptor>
T IncAsinariDynamics<T,Descriptor>::getParameter(plint whichParameter) const {
if(whichParameter==1000) {
return prefactor;
}
else {
return IsoThermalBulkDynamics<T,Descriptor>::getParameter(whichParameter);
}
}
template<typename T, template<typename U> class Descriptor>
bool IncAsinariDynamics<T,Descriptor>::velIsJ() const {
return true;
}
/* ************* Class AsinariPostCollide3D ******************* */
template<typename T, template<typename U> class Descriptor>
void AsinariPostCollide3D<T,Descriptor>::process(Box3D domain, BlockLattice3D<T,Descriptor>& lattice)
{
typedef Descriptor<T> D;
typedef asinariTemplates<T,Descriptor> asi;
static const int jOfs = D::ExternalField::jBeginsAt;
static const int bounceBackID = BounceBack<T,Descriptor>().getId();
for (plint iX=domain.x0; iX<=domain.x1; ++iX) {
for (plint iY=domain.y0; iY<=domain.y1; ++iY) {
for (plint iZ=domain.z0; iZ<=domain.z1; ++iZ) {
Cell<T,Descriptor>& cell = lattice.get(iX,iY,iZ);
if (cell.getDynamics().getId() != bounceBackID) {
T prefactor = cell.getDynamics().getParameter(1000);
Array<T,3> j;
j.from_cArray(cell.getExternal(jOfs));
asi::bgk_collision_stage3(cell, j, prefactor);
}
}
}
}
}
/* ************* Class AsinariPostCollide2D ******************* */
template<typename T, template<typename U> class Descriptor>
void AsinariPostCollide2D<T,Descriptor>::process(Box2D domain, BlockLattice2D<T,Descriptor>& lattice)
{
typedef Descriptor<T> D;
typedef asinariTemplates<T,Descriptor> asi;
static const int jOfs = D::ExternalField::jBeginsAt;
static const int bounceBackID = BounceBack<T,Descriptor>().getId();
for (plint iX=domain.x0; iX<=domain.x1; ++iX) {
for (plint iY=domain.y0; iY<=domain.y1; ++iY) {
Cell<T,Descriptor>& cell = lattice.get(iX,iY);
if (cell.getDynamics().getId() != bounceBackID) {
T prefactor = cell.getDynamics().getParameter(1000);
Array<T,2> j;
j.from_cArray(cell.getExternal(jOfs));
asi::bgk_collision_stage3(cell, j, prefactor);
}
}
}
}
} // namespace plb
#endif // ASINARI_MODEL_HH
|