LCOV - code coverage report
Current view: top level - src/actions - ComposeTimeStepperAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 23 26 88.5 %
Date: 2025-07-17 01:28:37 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "ComposeTimeStepperAction.h"
      11             : #include "TimeStepper.h"
      12             : #include "FEProblemBase.h"
      13             : #include "CompositionDT.h"
      14             : #include "Factory.h"
      15             : #include "MooseApp.h"
      16             : #include "Transient.h"
      17             : 
      18             : registerMooseAction("MooseApp", ComposeTimeStepperAction, "compose_time_stepper");
      19             : 
      20             : InputParameters
      21       62146 : ComposeTimeStepperAction::validParams()
      22             : {
      23       62146 :   InputParameters params = Action::validParams();
      24             : 
      25       62146 :   params += CompositionDT::compositionDTParams();
      26             : 
      27       62146 :   params.addClassDescription(
      28             :       "Add the composition time stepper if multiple time steppers have been created.");
      29             : 
      30       62146 :   return params;
      31           0 : }
      32             : 
      33       61934 : ComposeTimeStepperAction::ComposeTimeStepperAction(const InputParameters & params) : Action(params)
      34             : {
      35       61934 : }
      36             : 
      37             : void
      38       57154 : ComposeTimeStepperAction::act()
      39             : {
      40             :   // Get all of the timesteppers that have been added so far
      41       57154 :   std::vector<const TimeStepper *> timesteppers;
      42       57154 :   _problem->theWarehouse().query().condition<AttribSystem>("TimeStepper").queryInto(timesteppers);
      43             : 
      44       58316 :   for (const auto ts : timesteppers)
      45        1162 :     if (dynamic_cast<const CompositionDT *>(ts))
      46           0 :       ts->mooseError(
      47           0 :           "You cannot construct a ", ts->type(), "; this object is for internal use only");
      48             : 
      49             :   // The user added multiple timesteppers in [TimeSteppers] block, so
      50             :   // create a composition timestepper to compute final time step size
      51       57154 :   if (timesteppers.size() > 1)
      52             :   {
      53         100 :     const auto final_timestepper = "CompositionDT";
      54         100 :     auto new_params = _factory.getValidParams(final_timestepper);
      55             : 
      56             :     // Apply all custom parameters to CompositionDT that are
      57             :     // provided in Executioner/TimeSteppers/*
      58         300 :     for (const auto & param_name_value : CompositionDT::compositionDTParams())
      59         200 :       if (isParamValid(param_name_value.first))
      60         200 :         new_params.applyParameter(_pars, param_name_value.first);
      61             : 
      62         100 :     TransientBase * transient = dynamic_cast<TransientBase *>(_app.getExecutioner());
      63             :     mooseAssert(transient, "The transient executioner does not exist");
      64         100 :     new_params.set<TransientBase *>("_executioner") = transient;
      65             : 
      66         100 :     _problem->addObject<TimeStepper>(
      67             :         final_timestepper, final_timestepper, new_params, /* threaded = */ false);
      68          96 :   }
      69       57150 : }

Generated by: LCOV version 1.14