LCOV - code coverage report
Current view: top level - src/tensor_solver - ForwardEulerSolver.C (source / functions) Hit Total Coverage
Test: idaholab/swift: #92 (25e020) with base b3cd84 Lines: 22 23 95.7 %
Date: 2025-09-10 17:10:32 Functions: 3 3 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 "ForwardEulerSolver.h"
      10             : #include "TensorProblem.h"
      11             : #include "DomainAction.h"
      12             : 
      13             : registerMooseObject("SwiftApp", ForwardEulerSolver);
      14             : 
      15             : InputParameters
      16          64 : ForwardEulerSolver::validParams()
      17             : {
      18          64 :   InputParameters params = ExplicitSolverBase::validParams();
      19          64 :   params.addClassDescription("Semi-implicit time integration solver.");
      20         128 :   params.addParam<unsigned int>("substeps", 1, "semi-implicit substeps per time step.");
      21          64 :   return params;
      22           0 : }
      23             : 
      24          32 : ForwardEulerSolver::ForwardEulerSolver(const InputParameters & parameters)
      25             :   : ExplicitSolverBase(parameters),
      26          32 :     _substeps(getParam<unsigned int>("substeps")),
      27          32 :     _sub_dt(_tensor_problem.subDt()),
      28          64 :     _sub_time(_tensor_problem.subTime())
      29             : {
      30          32 : }
      31             : 
      32             : void
      33         568 : ForwardEulerSolver::computeBuffer()
      34             : {
      35             :   torch::Tensor ubar;
      36         568 :   _sub_dt = _dt / _substeps;
      37             : 
      38             :   // subcycles
      39       28648 :   for (const auto substep : make_range(_substeps))
      40             :   {
      41             :     // re-evaluate the solve compute
      42       28080 :     _compute->computeBuffer();
      43       28080 :     forwardBuffers();
      44             : 
      45             :     // integrate all variables
      46       56160 :     for (auto & [u, reciprocal_buffer, time_derivative_reciprocal] : _variables)
      47             :     {
      48       56160 :       ubar = reciprocal_buffer + _sub_dt * time_derivative_reciprocal;
      49             : 
      50       56160 :       u = _domain.ifft(ubar);
      51             :     }
      52             : 
      53       28080 :     if (substep < _substeps - 1)
      54       27512 :       _tensor_problem.advanceState();
      55             : 
      56             :     // increment substep time
      57       28080 :     _sub_time += _sub_dt;
      58             :   }
      59         568 : }

Generated by: LCOV version 1.14