LCOV - code coverage report
Current view: top level - src/tensor_solver - LBMStream.C (source / functions) Hit Total Coverage
Test: idaholab/swift: #92 (25e020) with base b3cd84 Lines: 0 31 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 "LBMStream.h"
      10             : #include "LatticeBoltzmannProblem.h"
      11             : #include "LatticeBoltzmannStencilBase.h"
      12             : 
      13             : using namespace torch::indexing;
      14             : 
      15             : registerMooseObject("SwiftApp", LBMStream);
      16             : 
      17             : InputParameters
      18           0 : LBMStream::validParams()
      19             : {
      20           0 :   InputParameters params = TensorSolver::validParams();
      21           0 :   params.addClassDescription("LBM Streaming operation.");
      22           0 :   params.addParam<std::vector<TensorOutputBufferName>>(
      23             :       "buffer", {}, "The buffer this solver is writing to");
      24             : 
      25           0 :   params.addParam<std::vector<TensorInputBufferName>>("f_old", {}, "Old time step distribution");
      26           0 :   return params;
      27           0 : }
      28             : 
      29           0 : LBMStream::LBMStream(const InputParameters & parameters)
      30             :   : TensorSolver(parameters),
      31           0 :     _lb_problem(dynamic_cast<LatticeBoltzmannProblem &>(_tensor_problem)),
      32           0 :     _stencil(_lb_problem.getStencil())
      33             : {
      34             :   std::vector<TensorOutputBufferName> output_buffer_names =
      35           0 :       getParam<std::vector<TensorOutputBufferName>>("buffer");
      36             : 
      37             :   std::vector<TensorInputBufferName> input_buffer_names =
      38           0 :       getParam<std::vector<TensorInputBufferName>>("f_old");
      39             : 
      40             :   const auto n = output_buffer_names.size();
      41             : 
      42           0 :   if (input_buffer_names.size() != n || output_buffer_names.size() != n)
      43           0 :     paramError("buffer", "Must have the same number of entries as 'f_old'");
      44             : 
      45           0 :   for (const auto i : make_range(n))
      46           0 :     _variables.push_back(Variable{getOutputBufferByName(output_buffer_names[i]),
      47           0 :                                   getBufferOldByName(input_buffer_names[i], 1)});
      48           0 : }
      49             : 
      50             : void
      51           0 : LBMStream::computeBuffer()
      52             : {
      53           0 :   const auto n_old = _variables[0]._f_old.size();
      54           0 :   if (n_old != 0)
      55             :   {
      56           0 :     for (auto & [u, f_old] : _variables)
      57             :     {
      58             :       // do not overwrite previous
      59           0 :       u = u.clone();
      60           0 :       for (int i = 0; i < _stencil._q; i++)
      61             :       {
      62           0 :         u.index_put_({Slice(), Slice(), Slice(), i},
      63           0 :                      torch::roll(f_old[0].index({Slice(), Slice(), Slice(), i}),
      64             :                                  /* shifts = */
      65           0 :                                  {_stencil._ex[i].item<int64_t>(),
      66           0 :                                   _stencil._ey[i].item<int64_t>(),
      67           0 :                                   _stencil._ez[i].item<int64_t>()},
      68             :                                  /* dims = */
      69             :                                  {0, 1, 2}));
      70             :       }
      71           0 :       _lb_problem.maskedFillSolids(u, 0);
      72             :     }
      73             :   }
      74           0 : }

Generated by: LCOV version 1.14