| 1 |
/************************************************************************* |
| 2 |
* Copyright (C) 2009-2012 by Franck Lominé * |
| 3 |
* [email protected] * |
| 4 |
* * |
| 5 |
* This program is free software; it is licensed under the terms of the * |
| 6 |
* GNU General Public License v2 or later. See file LICENSE for details. * |
| 7 |
* * |
| 8 |
*************************************************************************/ |
| 9 |
#ifdef LBM_ENGINE |
| 10 |
|
| 11 |
#include "LBMnode.hpp" |
| 12 |
#include "LBMbody.hpp" |
| 13 |
#include "LBMlink.hpp" |
| 14 |
|
| 15 |
namespace yade { // Cannot have #include directive inside. |
| 16 |
|
| 17 |
YADE_PLUGIN((LBMnode)(LBMlink)(LBMbody)); |
| 18 |
LBMnode::~LBMnode() {}; |
| 19 |
|
| 20 |
|
| 21 |
void LBMnode::MixteBC(string lbmodel, Real density, Vector3r U, string where) |
| 22 |
{ |
| 23 |
Real rhoVx = density * U.x(); |
| 24 |
Real rhoVy = density * U.y(); |
| 25 |
if (!strcmp(lbmodel.c_str(), "d2q9")) { |
| 26 |
if (!strcmp(where.c_str(), "Xm")) { |
| 27 |
f[1] = f[3] + (2. / 3.) * rhoVx; |
| 28 |
f[5] = f[7] - 0.5 * (f[2] - f[4]) + (1. / 6.) * rhoVx + 0.5 * rhoVy; |
| 29 |
f[8] = f[6] + 0.5 * (f[2] - f[4]) + (1. / 6.) * rhoVx - 0.5 * rhoVy; |
| 30 |
} else if (!strcmp(where.c_str(), "Xp")) { |
| 31 |
f[3] = f[1] - (2. / 3.) * rhoVx; |
| 32 |
f[7] = f[5] + 0.5 * (f[2] - f[4]) - (1. / 6.) * rhoVx - 0.5 * rhoVy; |
| 33 |
f[6] = f[8] - 0.5 * (f[2] - f[4]) - (1. / 6.) * rhoVx + 0.5 * rhoVy; |
| 34 |
} else if (!strcmp(where.c_str(), "Ym")) { |
| 35 |
f[2] = f[4] + (2. / 3.) * rhoVy; |
| 36 |
f[5] = f[7] - 0.5 * (f[1] - f[3]) + 0.5 * rhoVx + (1. / 6.) * rhoVy; |
| 37 |
f[6] = f[8] + 0.5 * (f[1] - f[3]) - 0.5 * rhoVx + (1. / 6.) * rhoVy; |
| 38 |
} else if (!strcmp(where.c_str(), "Yp")) { |
| 39 |
f[4] = f[2] - (2. / 3.) * rhoVy; |
| 40 |
f[7] = f[5] + 0.5 * (f[1] - f[3]) - 0.5 * rhoVx - (1. / 6.) * rhoVy; |
| 41 |
f[8] = f[6] - 0.5 * (f[1] - f[3]) + 0.5 * rhoVx - (1. / 6.) * rhoVy; |
| 42 |
} else if (!strcmp(where.c_str(), "XmYmZp")) { |
| 43 |
f[1] = f[3] + (2. / 3.) * rhoVx; |
| 44 |
f[2] = f[4] + (2. / 3.) * rhoVy; |
| 45 |
f[5] = f[7] + (1. / 6.) * density * (U.x() + U.y()); |
| 46 |
f[6] = 0.5 * (density * (1. - U.x() - (2. / 3.) * U.y()) - f[0] - 2. * (f[3] + f[4] + f[7])); |
| 47 |
f[8] = 0.5 * (density * (1. - (2. / 3.) * U.x() - U.y()) - f[0] - 2. * (f[3] + f[4] + f[7])); |
| 48 |
} else if (!strcmp(where.c_str(), "XmYpZp")) { |
| 49 |
f[1] = f[3] + (2. / 3.) * rhoVx; |
| 50 |
f[4] = f[2] - (2. / 3.) * rhoVy; |
| 51 |
f[5] = 0.5 * (density * (1. - (2. / 3.) * U.x() + U.y()) - f[0] - 2. * (f[2] + f[3] + f[6])); |
| 52 |
f[7] = 0.5 * (density * (1. - U.x() + (2. / 3.) * U.y()) - f[0] - 2. * (f[2] + f[3] + f[6])); |
| 53 |
f[8] = f[6] + (1. / 6.) * density * (U.x() - U.y()); |
| 54 |
} else if (!strcmp(where.c_str(), "XpYmZp")) { |
| 55 |
f[2] = f[4] + (2. / 3.) * rhoVy; |
| 56 |
f[3] = f[1] - (2. / 3.) * rhoVx; |
| 57 |
f[5] = 0.5 * (density * (1. + U.x() - (2. / 3.) * U.y()) - f[0] - 2. * (f[1] + f[4] + f[8])); |
| 58 |
f[6] = f[8] - (1. / 6.) * density * (U.x() - U.y()); |
| 59 |
f[7] = 0.5 * (density * (1. + (2. / 3.) * U.x() - U.y()) - f[0] - 2. * (f[1] + f[4] + f[8])); |
| 60 |
} else if (!strcmp(where.c_str(), "XpYpZp")) { |
| 61 |
f[3] = f[1] - (2. / 3.) * rhoVx; |
| 62 |
f[4] = f[2] - (2. / 3.) * rhoVy; |
| 63 |
f[6] = 0.5 * (density * (1. + (2. / 3.) * U.x() + U.y()) - f[0] - 2. * (f[1] + f[2] + f[5])); |
| 64 |
f[7] = f[5] - (1. / 6.) * density * (U.x() + U.y()); |
| 65 |
f[8] = 0.5 * (density * (1. + U.x() + (2. / 3.) * U.y()) - f[0] - 2. * (f[1] + f[2] + f[5])); |
| 66 |
} else { |
| 67 |
exit(-1); |
| 68 |
} |
| 69 |
} else { |
| 70 |
exit(-1); |
| 71 |
} |
| 72 |
return; |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
bool LBMnode::checkIsNewObstacle() |
| 77 |
{ |
| 78 |
if (isObstacle) { |
| 79 |
if (!wasObstacle) { |
| 80 |
isNewObstacle = true; |
| 81 |
wasObstacle = true; |
| 82 |
} else { |
| 83 |
isNewObstacle = false; |
| 84 |
wasObstacle = true; |
| 85 |
} |
| 86 |
return (isNewObstacle); |
| 87 |
} else |
| 88 |
return (false); |
| 89 |
} |
| 90 |
|
| 91 |
bool LBMnode::checkIsNewFluid() |
| 92 |
{ |
| 93 |
if (!isObstacle) { |
| 94 |
if (wasObstacle) { |
| 95 |
isNewFluid = true; |
| 96 |
wasObstacle = false; |
| 97 |
} else { |
| 98 |
isNewFluid = false; |
| 99 |
wasObstacle = false; |
| 100 |
} |
| 101 |
return (isNewFluid); |
| 102 |
} else |
| 103 |
return (false); |
| 104 |
} |
| 105 |
|
| 106 |
void LBMnode::DispatchBoundaryConditions(int SizeNx, int SizeNy, int /*SizeNz*/) |
| 107 |
{ |
| 108 |
applyBC = false; |
| 109 |
applyXmBC = false; |
| 110 |
applyYmXmBC = false; |
| 111 |
applyYpXmBC = false; |
| 112 |
applyXpBC = false; |
| 113 |
applyYmXpBC = false; |
| 114 |
applyYpXpBC = false; |
| 115 |
applyYpBC = false; |
| 116 |
applyYmBC = false; |
| 117 |
if ((i == 0) && (j > 0) && (j < SizeNy - 1)) { |
| 118 |
applyXmBC = true; |
| 119 |
applyBC = true; |
| 120 |
} |
| 121 |
if ((i == 0) && (j == 0)) { |
| 122 |
applyYmXmBC = true; |
| 123 |
applyBC = true; |
| 124 |
} |
| 125 |
if ((i == 0) && (j == SizeNy - 1)) { |
| 126 |
applyYpXmBC = true; |
| 127 |
applyBC = true; |
| 128 |
} |
| 129 |
if ((i == SizeNx - 1) && (j > 0) && (j < SizeNy - 1)) { |
| 130 |
applyXpBC = true; |
| 131 |
applyBC = true; |
| 132 |
} |
| 133 |
if ((i == SizeNx - 1) && (j == 0)) { |
| 134 |
applyYmXpBC = true; |
| 135 |
applyBC = true; |
| 136 |
} |
| 137 |
if ((i == SizeNx - 1) && (j == SizeNy - 1)) { |
| 138 |
applyYpXpBC = true; |
| 139 |
applyBC = true; |
| 140 |
} |
| 141 |
if ((i > 0) && (i < SizeNx - 1) && (j == 0)) { |
| 142 |
applyYmBC = true; |
| 143 |
applyBC = true; |
| 144 |
} |
| 145 |
if ((i > 0) && (i < SizeNx - 1) && (j == SizeNy - 1)) { |
| 146 |
applyYpBC = true; |
| 147 |
applyBC = true; |
| 148 |
} |
| 149 |
return; |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
void LBMnode::SetCellIndexesAndPosition(int indI, int indJ, int indK) |
| 154 |
{ |
| 155 |
i = indI; |
| 156 |
j = indJ; |
| 157 |
k = indK; |
| 158 |
posb = Vector3r((Real)indI, (Real)indJ, (Real)indK); |
| 159 |
return; |
| 160 |
} |
| 161 |
|
| 162 |
} // namespace yade |
| 163 |
|
| 164 |
#endif //LBM_ENGINE |