LCOV - code coverage report
Current view: top level - src/stencils - LBMD3Q19.C (source / functions) Hit Total Coverage
Test: idaholab/swift: #92 (25e020) with base b3cd84 Lines: 0 32 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 "LBMD3Q19.h"
      10             : 
      11             : registerMooseObject("SwiftApp", LBMD3Q19);
      12             : 
      13             : InputParameters
      14           0 : LBMD3Q19::validParams()
      15             : {
      16           0 :   InputParameters params = LatticeBoltzmannStencilBase::validParams();
      17           0 :   params.addClassDescription("LBMD3Q19 Stencil object.");
      18           0 :   return params;
      19           0 : }
      20             : 
      21           0 : LBMD3Q19::LBMD3Q19(const InputParameters & parameters) : LatticeBoltzmannStencilBase(parameters)
      22             : {
      23           0 :   _q = 19;
      24             :   // LBMD3Q19 lattice
      25           0 :   _ex = torch::tensor({0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 1, 1, -1, -1, 1, 1, -1, -1},
      26           0 :                       MooseTensor::intTensorOptions());
      27           0 :   _ey = torch::tensor({0, 0, 0, 1, -1, 0, 0, 1, 1, -1, -1, 0, 0, 0, 0, 1, -1, 1, -1},
      28           0 :                       MooseTensor::intTensorOptions());
      29           0 :   _ez = torch::tensor({0, 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0},
      30           0 :                       MooseTensor::intTensorOptions());
      31           0 :   _weights = torch::tensor(
      32             :       {
      33             :           1.0 / 3.0,  1.0 / 18.0, 1.0 / 18.0, 1.0 / 18.0, 1.0 / 18.0, 1.0 / 18.0, 1.0 / 18.0,
      34             :           1.0 / 36.0, 1.0 / 36.0, 1.0 / 36.0, 1.0 / 36.0, 1.0 / 36.0, 1.0 / 36.0, 1.0 / 36.0,
      35             :           1.0 / 36.0, 1.0 / 36.0, 1.0 / 36.0, 1.0 / 36.0, 1.0 / 36.0,
      36             :       },
      37           0 :       MooseTensor::floatTensorOptions());
      38             : 
      39           0 :   _op = torch::tensor({0, 2, 1, 4, 3, 6, 5, 10, 9, 8, 7, 14, 13, 12, 11, 18, 17, 16, 15},
      40           0 :                       MooseTensor::intTensorOptions());
      41             :   // transformation matrix
      42           0 :   _M = torch::tensor(
      43             :       {{1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.},
      44             :        {-30., -11., -11., -11., -11., -11., -11., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8., 8.},
      45             :        {12., -4., -4., -4., -4., -4., -4., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.},
      46             :        {0., 1., -1., 0., 0., 0., 0., 1., -1., 1., -1., 1., -1., 1., -1., 0., 0., 0., 0.},
      47             :        {0., -4., 4., 0., 0., 0., 0., 1., -1., 1., -1., 1., -1., 1., -1., 0., 0., 0., 0.},
      48             :        {0., 0., 0., 1., -1., 0., 0., 1., 1., -1., -1., 0., 0., 0., 0., 1., -1., 1., -1.},
      49             :        {0., 0., 0., -4., 4., 0., 0., 1., 1., -1., -1., 0., 0., 0., 0., 1., -1., 1., -1.},
      50             :        {0., 0., 0., 0., 0., 1., -1., 0., 0., 0., 0., 1., 1., -1., -1., 1., 1., -1., -1.},
      51             :        {0., 0., 0., 0., 0., -4., 4., 0., 0., 0., 0., 1., 1., -1., -1., 1., 1., -1., -1.},
      52             :        {0., 2., 2., -1., -1., -1., -1., 1., 1., 1., 1., 1., 1., 1., 1., -2., -2., -2., -2.},
      53             :        {0., -4., -4., 2., 2., 2., 2., 1., 1., 1., 1., 1., 1., 1., 1., -2., -2., -2., -2.},
      54             :        {0., 0., 0., 1., 1., -1., -1., 1., 1., 1., 1., -1., -1., -1., -1., 0., 0., 0., 0.},
      55             :        {0., 0., 0., -2., -2., 2., 2., 1., 1., 1., 1., -1., -1., -1., -1., 0., 0., 0., 0.},
      56             :        {0., 0., 0., 0., 0., 0., 0., 1., -1., -1., 1., 0., 0., 0., 0., 0., 0., 0., 0.},
      57             :        {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., -1., -1., 1.},
      58             :        {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., -1., -1., 1., 0., 0., 0., 0.},
      59             :        {0., 0., 0., 0., 0., 0., 0., 1., -1., 1., -1., -1., 1., -1., 1., 0., 0., 0., 0.},
      60             :        {0., 0., 0., 0., 0., 0., 0., -1., -1., 1., 1., 0., 0., 0., 0., 1., -1., 1., -1.},
      61             :        {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 1., -1., -1., -1., -1., 1., 1.}},
      62           0 :       MooseTensor::floatTensorOptions());
      63             : 
      64           0 :   _M_inv = at::linalg_inv(_M);
      65             : 
      66             :   // relaxation matrix
      67           0 :   _S = torch::diag(torch::tensor({1. / 1.,
      68             :                                   1. / 1.19,
      69             :                                   1. / 1.4,
      70             :                                   1. / 1.4,
      71             :                                   1. / 1.0000,
      72             :                                   1. / 1.,
      73             :                                   1. / 1.0000,
      74             :                                   1. / 1.,
      75             :                                   1. / 1.0000,
      76             :                                   1. / 1.0000,
      77             :                                   1. / 1.4,
      78             :                                   1. / 1.000,
      79             :                                   1. / 1.4,
      80             :                                   1. / 1.000,
      81             :                                   1. / 1.000,
      82             :                                   1. / 1.000,
      83             :                                   1. / 1.98,
      84             :                                   1. / 1.98,
      85             :                                   1. / 1.98},
      86           0 :                                  MooseTensor::floatTensorOptions()));
      87             : 
      88             :   // indices where relaxation parameter related to kinematic viscosity (i.e. shear stress) is
      89             :   // located
      90           0 :   _id_kinematic_visc = torch::tensor({9, 11, 13, 14, 15}, MooseTensor::intTensorOptions());
      91             :   /**
      92             :    * incoming unknown distribution functions at every face
      93             :    * the opposite faces can be determined using _op vector
      94             :    * E.g. the opposite of _top[0] is _bottom[0] = _op[top[0]]
      95             :    */
      96           0 :   _left = torch::tensor({5, 11, 12, 15, 16}, MooseTensor::intTensorOptions()); // x dir; x = 0
      97           0 :   _right = _op.index({_left});                                                 // x dir; x = nx-1
      98           0 :   _bottom = torch::tensor({3, 7, 8, 15, 17}, MooseTensor::intTensorOptions()); // y dir; y = 0
      99           0 :   _top = _op.index({_bottom});                                                 // y dir; x = ny-1
     100           0 :   _front = torch::tensor({1, 7, 9, 11, 13}, MooseTensor::intTensorOptions());  // z dir ; z = 0
     101           0 :   _back = _op.index({_front});                                                 // z dir; z = nz-1
     102             : 
     103           0 :   _neutral_x = torch::tensor(
     104             :       {
     105             :           0,
     106             :           1,
     107             :           2,
     108             :           3,
     109             :           4,
     110             :           7,
     111             :           8,
     112             :           9,
     113             :           10,
     114             :       },
     115           0 :       MooseTensor::intTensorOptions());
     116           0 : }

Generated by: LCOV version 1.14