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
|
/*************************************************************************
* Copyright (C) 2009-2012 by Franck Lominé *
* franck.lomine@insa-rennes.fr *
* *
* This program is free software; it is licensed under the terms of the *
* GNU General Public License v2 or later. See file LICENSE for details. *
* *
*************************************************************************/
#ifdef LBM_ENGINE
#include "LBMnode.hpp"
#include "LBMbody.hpp"
#include "LBMlink.hpp"
namespace yade { // Cannot have #include directive inside.
YADE_PLUGIN((LBMnode)(LBMlink)(LBMbody));
LBMnode::~LBMnode() {};
void LBMnode::MixteBC(string lbmodel, Real density, Vector3r U, string where)
{
Real rhoVx = density * U.x();
Real rhoVy = density * U.y();
if (!strcmp(lbmodel.c_str(), "d2q9")) {
if (!strcmp(where.c_str(), "Xm")) {
f[1] = f[3] + (2. / 3.) * rhoVx;
f[5] = f[7] - 0.5 * (f[2] - f[4]) + (1. / 6.) * rhoVx + 0.5 * rhoVy;
f[8] = f[6] + 0.5 * (f[2] - f[4]) + (1. / 6.) * rhoVx - 0.5 * rhoVy;
} else if (!strcmp(where.c_str(), "Xp")) {
f[3] = f[1] - (2. / 3.) * rhoVx;
f[7] = f[5] + 0.5 * (f[2] - f[4]) - (1. / 6.) * rhoVx - 0.5 * rhoVy;
f[6] = f[8] - 0.5 * (f[2] - f[4]) - (1. / 6.) * rhoVx + 0.5 * rhoVy;
} else if (!strcmp(where.c_str(), "Ym")) {
f[2] = f[4] + (2. / 3.) * rhoVy;
f[5] = f[7] - 0.5 * (f[1] - f[3]) + 0.5 * rhoVx + (1. / 6.) * rhoVy;
f[6] = f[8] + 0.5 * (f[1] - f[3]) - 0.5 * rhoVx + (1. / 6.) * rhoVy;
} else if (!strcmp(where.c_str(), "Yp")) {
f[4] = f[2] - (2. / 3.) * rhoVy;
f[7] = f[5] + 0.5 * (f[1] - f[3]) - 0.5 * rhoVx - (1. / 6.) * rhoVy;
f[8] = f[6] - 0.5 * (f[1] - f[3]) + 0.5 * rhoVx - (1. / 6.) * rhoVy;
} else if (!strcmp(where.c_str(), "XmYmZp")) {
f[1] = f[3] + (2. / 3.) * rhoVx;
f[2] = f[4] + (2. / 3.) * rhoVy;
f[5] = f[7] + (1. / 6.) * density * (U.x() + U.y());
f[6] = 0.5 * (density * (1. - U.x() - (2. / 3.) * U.y()) - f[0] - 2. * (f[3] + f[4] + f[7]));
f[8] = 0.5 * (density * (1. - (2. / 3.) * U.x() - U.y()) - f[0] - 2. * (f[3] + f[4] + f[7]));
} else if (!strcmp(where.c_str(), "XmYpZp")) {
f[1] = f[3] + (2. / 3.) * rhoVx;
f[4] = f[2] - (2. / 3.) * rhoVy;
f[5] = 0.5 * (density * (1. - (2. / 3.) * U.x() + U.y()) - f[0] - 2. * (f[2] + f[3] + f[6]));
f[7] = 0.5 * (density * (1. - U.x() + (2. / 3.) * U.y()) - f[0] - 2. * (f[2] + f[3] + f[6]));
f[8] = f[6] + (1. / 6.) * density * (U.x() - U.y());
} else if (!strcmp(where.c_str(), "XpYmZp")) {
f[2] = f[4] + (2. / 3.) * rhoVy;
f[3] = f[1] - (2. / 3.) * rhoVx;
f[5] = 0.5 * (density * (1. + U.x() - (2. / 3.) * U.y()) - f[0] - 2. * (f[1] + f[4] + f[8]));
f[6] = f[8] - (1. / 6.) * density * (U.x() - U.y());
f[7] = 0.5 * (density * (1. + (2. / 3.) * U.x() - U.y()) - f[0] - 2. * (f[1] + f[4] + f[8]));
} else if (!strcmp(where.c_str(), "XpYpZp")) {
f[3] = f[1] - (2. / 3.) * rhoVx;
f[4] = f[2] - (2. / 3.) * rhoVy;
f[6] = 0.5 * (density * (1. + (2. / 3.) * U.x() + U.y()) - f[0] - 2. * (f[1] + f[2] + f[5]));
f[7] = f[5] - (1. / 6.) * density * (U.x() + U.y());
f[8] = 0.5 * (density * (1. + U.x() + (2. / 3.) * U.y()) - f[0] - 2. * (f[1] + f[2] + f[5]));
} else {
exit(-1);
}
} else {
exit(-1);
}
return;
}
bool LBMnode::checkIsNewObstacle()
{
if (isObstacle) {
if (!wasObstacle) {
isNewObstacle = true;
wasObstacle = true;
} else {
isNewObstacle = false;
wasObstacle = true;
}
return (isNewObstacle);
} else
return (false);
}
bool LBMnode::checkIsNewFluid()
{
if (!isObstacle) {
if (wasObstacle) {
isNewFluid = true;
wasObstacle = false;
} else {
isNewFluid = false;
wasObstacle = false;
}
return (isNewFluid);
} else
return (false);
}
void LBMnode::DispatchBoundaryConditions(int SizeNx, int SizeNy, int /*SizeNz*/)
{
applyBC = false;
applyXmBC = false;
applyYmXmBC = false;
applyYpXmBC = false;
applyXpBC = false;
applyYmXpBC = false;
applyYpXpBC = false;
applyYpBC = false;
applyYmBC = false;
if ((i == 0) && (j > 0) && (j < SizeNy - 1)) {
applyXmBC = true;
applyBC = true;
}
if ((i == 0) && (j == 0)) {
applyYmXmBC = true;
applyBC = true;
}
if ((i == 0) && (j == SizeNy - 1)) {
applyYpXmBC = true;
applyBC = true;
}
if ((i == SizeNx - 1) && (j > 0) && (j < SizeNy - 1)) {
applyXpBC = true;
applyBC = true;
}
if ((i == SizeNx - 1) && (j == 0)) {
applyYmXpBC = true;
applyBC = true;
}
if ((i == SizeNx - 1) && (j == SizeNy - 1)) {
applyYpXpBC = true;
applyBC = true;
}
if ((i > 0) && (i < SizeNx - 1) && (j == 0)) {
applyYmBC = true;
applyBC = true;
}
if ((i > 0) && (i < SizeNx - 1) && (j == SizeNy - 1)) {
applyYpBC = true;
applyBC = true;
}
return;
}
void LBMnode::SetCellIndexesAndPosition(int indI, int indJ, int indK)
{
i = indI;
j = indJ;
k = indK;
posb = Vector3r((Real)indI, (Real)indJ, (Real)indK);
return;
}
} // namespace yade
#endif //LBM_ENGINE
|