LCOV - code coverage report
Current view: top level - src/tensor_computes - ReciprocalAllenCahn.C (source / functions) Hit Total Coverage
Test: idaholab/swift: #92 (25e020) with base b3cd84 Lines: 23 24 95.8 %
Date: 2025-09-10 17:10:32 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : 
       2             : /**********************************************************************/
       3             : /*                    DO NOT MODIFY THIS HEADER                       */
       4             : /*             Swift, a Fourier spectral solver for MOOSE             */
       5             : /*                                                                    */
       6             : /*            Copyright 2024 Battelle Energy Alliance, LLC            */
       7             : /*                        ALL RIGHTS RESERVED                         */
       8             : /**********************************************************************/
       9             : 
      10             : #include "ReciprocalAllenCahn.h"
      11             : #include "SwiftUtils.h"
      12             : #include <torch/torch.h>
      13             : 
      14             : registerMooseObject("SwiftApp", ReciprocalAllenCahn);
      15             : 
      16             : InputParameters
      17           8 : ReciprocalAllenCahn::validParams()
      18             : {
      19           8 :   InputParameters params = TensorOperator::validParams();
      20           8 :   params.addClassDescription("Calculates the Allen-Cahn bulk driving force masked using psi.");
      21          16 :   params.addRequiredParam<TensorInputBufferName>("dF_chem_deta", "Driving force buffer name");
      22          16 :   params.addRequiredParam<TensorInputBufferName>("L", "Allen-Cahn mobility buffer name");
      23          16 :   params.addRequiredParam<TensorInputBufferName>("psi", "Variable to impose Neumann BC.");
      24          16 :   params.addParam<bool>("always_update_psi", false, "Set to true if the BC changes .");
      25           8 :   return params;
      26           0 : }
      27             : 
      28           4 : ReciprocalAllenCahn::ReciprocalAllenCahn(const InputParameters & parameters)
      29             :   : TensorOperator(parameters),
      30           4 :     _dF_chem_deta(getInputBuffer("dF_chem_deta")),
      31           4 :     _L(getInputBuffer("L")),
      32           4 :     _imag(torch::tensor(c10::complex<double>(0.0, 1.0), MooseTensor::complexFloatTensorOptions())),
      33           4 :     _psi(getInputBuffer("psi")),
      34           4 :     _update_psi(true),
      35          12 :     _always_update_psi(getParam<bool>("always_update_psi"))
      36             : {
      37           4 : }
      38             : 
      39             : void
      40       40000 : ReciprocalAllenCahn::computeBuffer()
      41             : {
      42       40000 :   if (_update_psi || _always_update_psi)
      43             :   {
      44           8 :     _psi_thresh = _psi > 0.0;
      45           4 :     _update_psi = false;
      46             :   }
      47             : 
      48      120000 :   auto rate = torch::where(_psi_thresh, -1 * _L * _dF_chem_deta, 0.0);
      49       80000 :   _u = _domain.fft(rate);
      50       40000 : }

Generated by: LCOV version 1.14