LCOV - code coverage report
Current view: top level - src/tensor_buffers - PlainTensorBuffer.C (source / functions) Hit Total Coverage
Test: idaholab/swift: #92 (25e020) with base b3cd84 Lines: 16 17 94.1 %
Date: 2025-09-10 17:10:32 Functions: 4 4 100.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 "MooseError.h"
      10             : #include "PlainTensorBuffer.h"
      11             : #include "SwiftUtils.h"
      12             : #include "DomainAction.h"
      13             : 
      14             : registerMooseObject("SwiftApp", PlainTensorBuffer);
      15             : 
      16             : InputParameters
      17        1214 : PlainTensorBuffer::validParams()
      18             : {
      19             :   InputParameters params = TensorBuffer<torch::Tensor>::validParams();
      20        2428 :   params.addParam<std::vector<int64_t>>("value_dimensions", {}, "Optional value dimensions");
      21        1214 :   return params;
      22           0 : }
      23             : 
      24         874 : PlainTensorBuffer::PlainTensorBuffer(const InputParameters & parameters)
      25         874 :   : TensorBuffer<torch::Tensor>(parameters)
      26             : {
      27         874 : }
      28             : 
      29             : void
      30         860 : PlainTensorBuffer::init()
      31             : {
      32        2580 :   _u = torch::zeros(_domain.getValueShape(getParam<std::vector<int64_t>>("value_dimensions")),
      33         860 :                     MooseTensor::floatTensorOptions());
      34         860 : }
      35             : 
      36             : void
      37       14384 : PlainTensorBuffer::makeCPUCopy()
      38             : {
      39       14384 :   if (!_u.defined())
      40             :     return;
      41             : 
      42       14384 :   if (_cpu_copy_requested)
      43             :   {
      44        1672 :     if (_u.is_cpu())
      45        2992 :       _u_cpu = _u.clone().contiguous();
      46             :     else
      47         352 :       _u_cpu = _u.cpu().contiguous();
      48             :   }
      49             : }

Generated by: LCOV version 1.14