LCOV - code coverage report
Current view: top level - src/stencils - LBMD2Q9.C (source / functions) Hit Total Coverage
Test: idaholab/swift: #92 (25e020) with base b3cd84 Lines: 0 23 0.0 %
Date: 2025-09-10 17:10:32 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          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 "LBMD2Q9.h"
      10             : 
      11             : registerMooseObject("SwiftApp", LBMD2Q9);
      12             : 
      13             : InputParameters
      14           0 : LBMD2Q9::validParams()
      15             : {
      16           0 :   InputParameters params = LatticeBoltzmannStencilBase::validParams();
      17           0 :   params.addClassDescription("LBMD2Q9 Stencil object.");
      18           0 :   return params;
      19           0 : }
      20             : 
      21           0 : LBMD2Q9::LBMD2Q9(const InputParameters & parameters) : LatticeBoltzmannStencilBase(parameters)
      22             : {
      23           0 :   _q = 9;
      24           0 :   _ex = torch::tensor({0, 1, 0, -1, 0, 1, -1, -1, 1}, MooseTensor::intTensorOptions());
      25           0 :   _ey = torch::tensor({0, 0, 1, 0, -1, 1, 1, -1, -1}, MooseTensor::intTensorOptions());
      26           0 :   _ez = torch::tensor({0, 0, 0, 0, 0, 0, 0, 0, 0}, MooseTensor::intTensorOptions());
      27             : 
      28           0 :   _weights = torch::tensor({4.0 / 9.0,
      29             :                             1.0 / 9.0,
      30             :                             1.0 / 9.0,
      31             :                             1.0 / 9.0,
      32             :                             1.0 / 9.0,
      33             :                             1.0 / 36.0,
      34             :                             1.0 / 36.0,
      35             :                             1.0 / 36.0,
      36             :                             1.0 / 36.0},
      37           0 :                            MooseTensor::floatTensorOptions());
      38             : 
      39           0 :   _op = torch::tensor({0, 3, 4, 1, 2, 7, 8, 5, 6}, MooseTensor::intTensorOptions());
      40             : 
      41             :   // transformation matrix
      42           0 :   _M = torch::tensor({{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0},
      43             :                       {-4.0, -1.0, -1.0, -1.0, -1.0, 2.0, 2.0, 2.0, 2.0},
      44             :                       {4.0, -2.0, -2.0, -2.0, -2.0, 1.0, 1.0, 1.0, 1.0},
      45             :                       {0.0, 1.0, 0.0, -1.0, 0.0, 1.0, -1.0, -1.0, 1.0},
      46             :                       {0.0, -2.0, 0.0, 2.0, 0.0, 1.0, -1.0, -1.0, 1.0},
      47             :                       {0.0, 0.0, 1.0, 0.0, -1.0, 1.0, 1.0, -1.0, -1.0},
      48             :                       {0.0, 0.0, -2.0, 0.0, 2.0, 1.0, 1.0, -1.0, -1.0},
      49             :                       {0.0, 1.0, -1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 0.0},
      50             :                       {0.0, 0.0, 0.0, 0.0, 0.0, 1.0, -1.0, 1.0, -1.0}},
      51           0 :                      MooseTensor::floatTensorOptions());
      52           0 :   _M_inv = at::linalg_inv(_M);
      53             : 
      54             :   // relaxation matrix
      55           0 :   _S = torch::diag(torch::tensor({1.0 / 1.0,     // tau_rho : mass
      56             :                                   1.0 / 1.1,     // tau_e : energy
      57             :                                   1.0 / 1.2,     // tau_epsilon : energy square
      58             :                                   1.0 / 1.0000,  // tau_j : momentum
      59             :                                   1.0 / 1.0000,  // tau_q : slip velocity
      60             :                                   1.0 / 1.0000,  // tau_j : momentum
      61             :                                   1.0 / 1.0000,  // tau_q : slip velocity
      62             :                                   1.0 / 1.0000,  // tau_s : shear viscosity
      63             :                                   1.0 / 1.0000}, // tau_s : shear viscosity
      64           0 :                                  MooseTensor::floatTensorOptions()));
      65             :   // indices where relaxation parameter related to kinematic viscosity (i.e. shear stress) is
      66             :   // located
      67           0 :   _id_kinematic_visc = torch::tensor({7, 8}, MooseTensor::intTensorOptions());
      68             : 
      69             :   /**
      70             :    * incoming unknown distribution functions at every face
      71             :    * the opposite faces can be determined using _op vector
      72             :    * E.g. the opposite of _top[0] is _bottom[0] = _op[top[0]]
      73             :    */
      74           0 :   _left = torch::tensor({1, 5, 8}, MooseTensor::intTensorOptions());   //  x dir;  x = 0
      75           0 :   _bottom = torch::tensor({2, 5, 6}, MooseTensor::intTensorOptions()); // y dir; y = 0
      76             : 
      77             :   //
      78           0 :   _reorder_indices = torch::tensor({6, 2, 5, 3, 0, 1, 7, 4, 8}, MooseTensor::intTensorOptions());
      79           0 : }

Generated by: LCOV version 1.14