Base b3cd84 | Head #92 25e020 | ||||
---|---|---|---|---|---|
Total | Total | +/- | New | ||
Rate | 36.85% | 37.16% | +0.31% | 0.00% | |
Hits | 1985 | 1985 | - | 0 | |
Misses | 3402 | 3357 | -45 | 101 |
Filename | Stmts | Miss | Cover |
---|---|---|---|
src/tensor_computes/LBMFixedFirstOrderBC.C | -22 | -22 | +100.00% |
src/tensor_computes/LBMFixedZerothOrderBC.C | -23 | -23 | +100.00% |
TOTAL | -45 | -45 | +0.31% |
code
code
code
+
17 18 19 20 + 21 22 23 |
registerMooseObject("SwiftApp", LBMFixedFirstOrderBC); InputParameters LBMFixedFirstOrderBC::validParams() { InputParameters params = LBMBoundaryCondition::validParams(); params.addClassDescription("LBMFixedFirstOrderBC object"); |
27 28 29 30 + 31 32 33 |
return params; } LBMFixedFirstOrderBC::LBMFixedFirstOrderBC(const InputParameters & parameters) : LBMBoundaryCondition(parameters), _f(getInputBufferByName(getParam<TensorInputBufferName>("f"))), _grid_size(_lb_problem.getGridSize()), |
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 |
} void LBMFixedFirstOrderBC::frontBoundary() { if (_domain.getDim() == 2) mooseError("There is no front boundary in 2 dimensions."); else mooseError("Front boundary is not implemented, but it can be replaced by any other boundary by " "rotating the domain."); } void LBMFixedFirstOrderBC::backBoundary() { if (_domain.getDim() == 2) mooseError("There is no back boundary in 2 dimensions."); else mooseError("Back boundary is not implemented, but it can be replaced by any other boundary by " "rotating the domain."); } void LBMFixedFirstOrderBC::leftBoundaryD2Q9() { Real deltaU = 0.0; torch::Tensor u_x_perturbed = torch::zeros({_grid_size[1], 1}, MooseTensor::floatTensorOptions()); |
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 |
} void LBMFixedFirstOrderBC::leftBoundary() { if (_stencil._q == 9) leftBoundaryD2Q9(); // higher order specialization for D2Q9 else { torch::Tensor density = 1.0 / (1.0 - _value) * (torch::sum(_f.index({0, Slice(), Slice(), -_stencil._neutral_x}), -1) + 2 * torch::sum(_f.index({0, Slice(), Slice(), _stencil._right}), -1)); _u.index_put_({0, Slice(), Slice(), _stencil._left[0]}, _f.index({0, Slice(), Slice(), _stencil._right[0]}) + 2.0 * _stencil._weights[_stencil._left[0]] / _lb_problem._cs2 * _value * density); for (unsigned int i = 1; i < _stencil._left.size(0); i++) { _u.index_put_({0, Slice(), Slice(), _stencil._left[i]}, _f.index({0, Slice(), Slice(), _stencil._right[i]}) + 2.0 * _stencil._weights[_stencil._left[i]] / _lb_problem._cs2 * _value * density); } } } void LBMFixedFirstOrderBC::rightBoundaryD2Q9() { torch::Tensor density = 1.0 / (1.0 + _value) * (_f.index({_grid_size[0] - 1, Slice(), Slice(), 0}) + |
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 |
} void LBMFixedFirstOrderBC::rightBoundary() { if (_stencil._q == 9) rightBoundaryD2Q9(); // higher order specialization for D2Q9 else { torch::Tensor density = 1.0 / (1.0 + _value) * (torch::sum(_f.index({_grid_size[0] - 1, Slice(), Slice(), -_stencil._neutral_x}), -1) + 2 * torch::sum(_f.index({_grid_size[0] - 1, Slice(), Slice(), _stencil._left}), -1)); _u.index_put_({_grid_size[0] - 1, Slice(), Slice(), _stencil._right[0]}, _f.index({_grid_size[0] - 1, Slice(), Slice(), _stencil._left[0]}) - 2.0 * _stencil._weights[_stencil._right[0]] / _lb_problem._cs2 * _value * density); for (unsigned int i = 1; i < _stencil._right.size(0); i++) { _u.index_put_({_grid_size[0] - 1, Slice(), Slice(), _stencil._right[i]}, _f.index({_grid_size[0] - 1, Slice(), Slice(), _stencil._left[i]}) - 2.0 * _stencil._weights[_stencil._right[i]] / _lb_problem._cs2 * _value * density); } } } void LBMFixedFirstOrderBC::bottomBoundaryD2Q9() { torch::Tensor density = 1.0 / (1.0 - _value) * |
211 212 213 214 + 215 216 + 217 + 218 219 + 220 221 222 223 224 + 225 226 227 |
} void LBMFixedFirstOrderBC::bottomBoundary() { if (_stencil._q == 9) bottomBoundaryD2Q9(); else mooseError("Bottom boundary is not implemented, but it can be replaced by another boundary by " "rotating the domain."); } void LBMFixedFirstOrderBC::topBoundaryD2Q9() { torch::Tensor density = 1.0 / (1.0 + _value) * (_f.index({Slice(), _grid_size[1] - 1, Slice(), 0}) + |
251 252 253 254 + 255 256 + 257 + 258 259 + 260 261 262 263 264 + 265 266 267 |
} void LBMFixedFirstOrderBC::topBoundary() { if (_stencil._q == 9) topBoundaryD2Q9(); else mooseError("Top boundary is not implemented, but it can be replaced by another boundary by " "rotating the domain."); } void LBMFixedFirstOrderBC::computeBuffer() { _u = _u.clone(); switch (_boundary) |
291 292 293 294 + |
mooseError("Undefined boundary names"); } _lb_problem.maskedFillSolids(_u, 0); } |
15 16 17 18 + 19 20 21 |
registerMooseObject("SwiftApp", LBMFixedZerothOrderBC); InputParameters LBMFixedZerothOrderBC::validParams() { InputParameters params = LBMBoundaryCondition::validParams(); params.addClassDescription("LBMFixedZerothOrderBC object"); |
24 25 26 27 + 28 29 30 |
return params; } LBMFixedZerothOrderBC::LBMFixedZerothOrderBC(const InputParameters & parameters) : LBMBoundaryCondition(parameters), _f(getInputBufferByName(getParam<TensorInputBufferName>("f"))), _grid_size(_lb_problem.getGridSize()), |
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 |
} void LBMFixedZerothOrderBC::frontBoundary() { if (_domain.getDim() == 2) mooseError("There is no front boundary in 2 dimensions."); else mooseError("Front boundary is not implemented, but it can be replaced by any other boundary by " "rotating the domain."); } void LBMFixedZerothOrderBC::backBoundary() { if (_domain.getDim() == 2) mooseError("There is no back boundary in 2 dimensions."); else mooseError("Back boundary is not implemented, but it can be replaced by any other boundary by " "rotating the domain."); } void LBMFixedZerothOrderBC::leftBoundaryD2Q9() { torch::Tensor velocity = 1.0 - (_f.index({0, Slice(), Slice(), 0}) + _f.index({0, Slice(), Slice(), 2}) + |
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 |
} void LBMFixedZerothOrderBC::leftBoundary() { if (_stencil._q == 9) leftBoundaryD2Q9(); else { torch::Tensor velocity = 1.0 - (torch::sum(_f.index({0, Slice(), Slice(), -_stencil._neutral_x}), -1) + 2 * torch::sum(_f.index({0, Slice(), Slice(), _stencil._right}), -1)) / _value; _u.index_put_({0, Slice(), Slice(), _stencil._left[0]}, _f.index({0, Slice(), Slice(), _stencil._right[0]}) + 2.0 * _stencil._weights[_stencil._left[0]] / _lb_problem._cs2 * _value * velocity); for (unsigned int i = 1; i < _stencil._left.size(0); i++) { _u.index_put_({0, Slice(), Slice(), _stencil._left[i]}, _f.index({0, Slice(), Slice(), _stencil._right[i]}) + 2.0 * _stencil._weights[_stencil._left[i]] / _lb_problem._cs2 * _value * velocity); } } } void LBMFixedZerothOrderBC::rightBoundaryD2Q9() { torch::Tensor velocity = (_f.index({_grid_size[0] - 1, Slice(), Slice(), 0}) + _f.index({_grid_size[0] - 1, Slice(), Slice(), 2}) + |
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 |
} void LBMFixedZerothOrderBC::rightBoundary() { if (_stencil._q == 9) rightBoundaryD2Q9(); else { torch::Tensor velocity = (torch::sum(_f.index({_grid_size[0] - 1, Slice(), Slice(), -_stencil._neutral_x}), -1) + 2 * torch::sum(_f.index({_grid_size[0] - 1, Slice(), Slice(), _stencil._left}), -1)) / _value - 1.0; _u.index_put_({_grid_size[0] - 1, Slice(), Slice(), _stencil._right[0]}, _f.index({_grid_size[0] - 1, Slice(), Slice(), _stencil._left[0]}) - 2.0 * _stencil._weights[_stencil._right[0]] / _lb_problem._cs2 * _value * velocity); for (unsigned int i = 1; i < _stencil._right.size(0); i++) { _u.index_put_({_grid_size[0] - 1, Slice(), Slice(), _stencil._right[i]}, _f.index({_grid_size[0] - 1, Slice(), Slice(), _stencil._left[i]}) - 2.0 * _stencil._weights[_stencil._right[i]] / _lb_problem._cs2 * _value * velocity); } } } void LBMFixedZerothOrderBC::bottomBoundaryD2Q9() { torch::Tensor velocity = 1.0 - (_f.index({Slice(), 0, Slice(), 0}) + _f.index({Slice(), 0, Slice(), 1}) + |
195 196 197 198 + 199 200 201 + 202 + 203 204 + 205 206 207 208 209 + 210 211 212 |
} void LBMFixedZerothOrderBC::bottomBoundary() { // TBD if (_stencil._q == 9) bottomBoundaryD2Q9(); else mooseError("Bottom boundary is not implemented, but it can be replaced by any other boundary " "by rotating the domain"); } void LBMFixedZerothOrderBC::topBoundaryD2Q9() { torch::Tensor velocity = (_f.index({Slice(), _grid_size[1] - 1, Slice(), 0}) + _f.index({Slice(), _grid_size[1] - 1, Slice(), 1}) + |
237 238 239 240 + 241 242 243 + 244 + 245 246 + 247 248 249 250 251 + 252 253 254 |
} void LBMFixedZerothOrderBC::topBoundary() { // TBD if (_stencil._q == 9) topBoundaryD2Q9(); else mooseError("Top boundary is not implemented, but it can be replaced by any other boundary by " "rotating the domain"); } void LBMFixedZerothOrderBC::computeBuffer() { switch (_boundary) { |
277 278 279 280 + |
mooseError("Undefined boundary names"); } _lb_problem.maskedFillSolids(_u, 0); } |