Line data Source code
1 : /**********************************************************************/ 2 : /* DO NOT MODIFY THIS HEADER */ 3 : /* Swift, a Fourier spectral solver for MOOSE */ 4 : /* */ 5 : /* Copyright 2024 Battelle Energy Alliance, LLC */ 6 : /* ALL RIGHTS RESERVED */ 7 : /**********************************************************************/ 8 : 9 : #include "LBMComputeVelocityMagnitude.h" 10 : #include "LatticeBoltzmannProblem.h" 11 : 12 : registerMooseObject("SwiftApp", LBMComputeVelocityMagnitude); 13 : 14 : InputParameters 15 0 : LBMComputeVelocityMagnitude::validParams() 16 : { 17 0 : InputParameters params = LatticeBoltzmannOperator::validParams(); 18 0 : params.addClassDescription("LBMComputeVelocityMagnitude object."); 19 0 : params.addRequiredParam<TensorInputBufferName>("velocity", "LBM velocity"); 20 0 : return params; 21 0 : } 22 : 23 0 : LBMComputeVelocityMagnitude::LBMComputeVelocityMagnitude(const InputParameters & parameters) 24 0 : : LatticeBoltzmannOperator(parameters), _velocity(getInputBuffer("velocity")) 25 : { 26 0 : } 27 : 28 : void 29 0 : LBMComputeVelocityMagnitude::computeBuffer() 30 : { 31 0 : const unsigned int & dim = _domain.getDim(); 32 0 : switch (dim) 33 : { 34 0 : case 2: 35 0 : _u = torch::sqrt(_velocity.select(3, 0).pow(2) + _velocity.select(3, 1).pow(2)); 36 0 : break; 37 0 : case 3: 38 0 : _u = torch::sqrt(_velocity.select(3, 0).pow(2) + _velocity.select(3, 1).pow(2) + 39 0 : _velocity.select(3, 2).pow(2)); 40 0 : break; 41 0 : default: 42 0 : mooseError("Unsupported dimension"); 43 : } 44 0 : _lb_problem.maskedFillSolids(_u, 0); 45 0 : }