LCOV - code coverage report
Current view: top level - src/tensor_computes - LBMEquilibrium.C (source / functions) Hit Total Coverage
Test: idaholab/swift: #92 (25e020) with base b3cd84 Lines: 0 33 0.0 %
Date: 2025-09-10 17:10:32 Functions: 0 3 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 "LBMEquilibrium.h"
      10             : 
      11             : registerMooseObject("SwiftApp", LBMEquilibrium);
      12             : 
      13             : InputParameters
      14           0 : LBMEquilibrium::validParams()
      15             : {
      16           0 :   InputParameters params = LatticeBoltzmannOperator::validParams();
      17           0 :   params.addClassDescription("Compute LB equilibrium distribution object.");
      18           0 :   params.addRequiredParam<TensorInputBufferName>(
      19             :       "bulk", "LBM bluk macroscpic parameter, e.g density or temperature");
      20           0 :   params.addRequiredParam<TensorInputBufferName>("velocity",
      21             :                                                  "LBM Velocty in x, y and z directions");
      22           0 :   return params;
      23           0 : }
      24             : 
      25           0 : LBMEquilibrium::LBMEquilibrium(const InputParameters & parameters)
      26             :   : LatticeBoltzmannOperator(parameters),
      27           0 :     _rho(getInputBuffer("bulk")),
      28           0 :     _velocity(getInputBuffer("velocity"))
      29             : {
      30           0 : }
      31             : 
      32             : void
      33           0 : LBMEquilibrium::computeBuffer()
      34             : {
      35             :   // prepping
      36           0 :   const unsigned int & dim = _domain.getDim();
      37             : 
      38           0 :   if (_rho.dim() < 3)
      39           0 :     _rho.unsqueeze_(2);
      40             : 
      41           0 :   torch::Tensor rho_unsqueezed = _rho.unsqueeze(3);
      42           0 :   torch::Tensor ux = _velocity.select(3, 0).unsqueeze(3);
      43           0 :   torch::Tensor uy = _velocity.select(3, 1).unsqueeze(3);
      44             :   torch::Tensor uz;
      45             : 
      46           0 :   switch (dim)
      47             :   {
      48           0 :     case 3:
      49           0 :       uz = _velocity.select(3, 2).unsqueeze(3);
      50           0 :       break;
      51             :     case 2:
      52           0 :       uz = torch::zeros_like(rho_unsqueezed, MooseTensor::floatTensorOptions());
      53           0 :       break;
      54           0 :     default:
      55           0 :       mooseError("Unsupported dimensions for buffer _u");
      56             :   }
      57             : 
      58             :   // compute equilibrium
      59             :   torch::Tensor second_order;
      60             :   torch::Tensor third_order;
      61             : 
      62             :   {
      63           0 :     auto edotu = _ex * ux + _ey * uy + _ez * uz;
      64             :     auto edotu_sqr = edotu * edotu;
      65           0 :     auto usqr = ux * ux + uy * uy + uz * uz;
      66           0 :     second_order = edotu / _lb_problem._cs2 + 0.5 * edotu_sqr / _lb_problem._cs4;
      67           0 :     third_order = 0.5 * usqr / _lb_problem._cs2;
      68             :   }
      69             : 
      70           0 :   _u = _w * rho_unsqueezed * (1.0 + second_order - third_order);
      71           0 :   _lb_problem.maskedFillSolids(_u, 0);
      72           0 : }

Generated by: LCOV version 1.14