LCOV - code coverage report
Current view: top level - src/tensor_buffers - TensorBufferBase.C (source / functions) Hit Total Coverage
Test: idaholab/swift: #92 (25e020) with base b3cd84 Lines: 16 21 76.2 %
Date: 2025-09-10 17:10:32 Functions: 2 4 50.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 "TensorBufferBase.h"
      10             : #include "DomainAction.h"
      11             : #include "TensorProblem.h"
      12             : 
      13             : InputParameters
      14        1214 : TensorBufferBase::validParams()
      15             : {
      16        1214 :   InputParameters params = MooseObject::validParams();
      17        1214 :   params.addClassDescription("Generic TensorBuffer object.");
      18        1214 :   params.registerBase("TensorBuffer");
      19        1214 :   params.registerSystemAttributeName("TensorBuffer");
      20        2428 :   params.addParam<bool>("reciprocal", false, "Is this a reciprocal space tensor?");
      21        2428 :   params.addParam<std::vector<AuxVariableName>>(
      22             :       "map_to_aux_variable", {}, "Sync the given AuxVariable to the buffer contents");
      23        2428 :   params.addParam<std::vector<AuxVariableName>>(
      24             :       "map_from_aux_variable", {}, "Sync the given AuxVariable to the buffer contents");
      25             : 
      26        1214 :   params.addPrivateParam<TensorProblem *>("_tensor_problem", nullptr);
      27             : 
      28        1214 :   return params;
      29           0 : }
      30             : 
      31         874 : TensorBufferBase::TensorBufferBase(const InputParameters & parameters)
      32             :   : MooseObject(parameters),
      33             :     DomainInterface(this),
      34         874 :     _reciprocal(getParam<bool>("reciprocal")),
      35        1748 :     _domain_shape(getParam<bool>("reciprocal") ? _domain.getReciprocalShape() : _domain.getShape()),
      36         874 :     _options(_reciprocal ? MooseTensor::complexFloatTensorOptions()
      37        1748 :                          : MooseTensor::floatTensorOptions())
      38             : {
      39             :   // const auto & map_to_aux_variable =
      40             :   // getParam<std::vector<AuxVariableName>>("map_to_aux_variable"); if (map_to_aux_variable.size() >
      41             :   // 1)
      42             :   //   paramError("mapping to multiple variables is not supported.");
      43             : 
      44             :   // if (!map_to_aux_variable.empty() && !_value_shape_buffer.empty())
      45             :   //   paramError("mapping non-scalar tensors is not supported.");
      46             : 
      47             :   // if (!getParam<std::vector<AuxVariableName>>("map_from_aux_variable").empty())
      48             :   //   paramError("functionality is not yet implemented.");
      49         874 : }
      50             : 
      51             : TensorBufferBase &
      52           0 : TensorBufferBase::operator=(const torch::Tensor & /*rhs*/)
      53             : {
      54             :   // TODO: remove
      55             :   //  if (this != &rhs)
      56             :   //  {
      57             :   //    torch::Tensor::operator=(rhs);
      58             :   //    expand();
      59             :   //  }
      60           0 :   return *this;
      61             : }
      62             : 
      63             : void
      64           0 : TensorBufferBase::expand()
      65             : {
      66             :   // try
      67             :   // {
      68             :   //   this->expand(_shape);
      69             :   // }
      70             :   // catch (const std::exception & e)
      71             :   // {
      72             :   //   mooseError("Assignment of incompatible data to tensor '", MooseBase::name(), "'");
      73             :   // }
      74           0 : }

Generated by: LCOV version 1.14