LCOV - code coverage report
Current view: top level - src/actions - CreateProblemDefaultAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 37 39 94.9 %
Date: 2025-08-08 20:01:16 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 "CreateProblemDefaultAction.h"
      11             : 
      12             : #include "Factory.h"
      13             : #include "FEProblem.h"
      14             : #include "EigenProblem.h"
      15             : #include "MooseApp.h"
      16             : #include "CreateExecutionerAction.h"
      17             : #include "CreateProblemAction.h"
      18             : 
      19             : registerMooseAction("MooseApp", CreateProblemDefaultAction, "create_problem_default");
      20             : registerMooseAction("MooseApp", CreateProblemDefaultAction, "determine_system_type");
      21             : 
      22             : InputParameters
      23       66787 : CreateProblemDefaultAction::validParams()
      24             : {
      25       66787 :   InputParameters params = Action::validParams();
      26       66787 :   params.addPrivateParam<bool>("_solve");
      27       66787 :   return params;
      28           0 : }
      29             : 
      30       66787 : CreateProblemDefaultAction::CreateProblemDefaultAction(const InputParameters & parameters)
      31       66787 :   : Action(parameters)
      32             : {
      33       66787 : }
      34             : 
      35             : void
      36      124676 : CreateProblemDefaultAction::act()
      37             : {
      38      124676 :   if (_current_task == "determine_system_type")
      39             :   {
      40             :     // Determine whether the Executioner is derived from EigenExecutionerBase and
      41             :     // set a flag on MooseApp that can be used during problem construction.
      42       62340 :     bool use_nonlinear = true;
      43       62340 :     bool use_eigenvalue = false;
      44       62340 :     auto p = _awh.getActionByTask<CreateExecutionerAction>("setup_executioner");
      45       62340 :     if (p)
      46             :     {
      47       62304 :       auto & exparams = p->getObjectParams();
      48       62304 :       use_nonlinear = !(exparams.isParamValid("_eigen") && exparams.get<bool>("_eigen"));
      49       62304 :       use_eigenvalue =
      50       62304 :           (exparams.isParamValid("_use_eigen_value") && exparams.get<bool>("_use_eigen_value"));
      51             :     }
      52             : 
      53       62340 :     _app.useNonlinear() = use_nonlinear;
      54       62340 :     _app.useEigenvalue() = use_eigenvalue;
      55       62340 :     return;
      56             :   }
      57             : 
      58             :   // act only if we have mesh
      59       62336 :   if (_mesh.get() != NULL)
      60             :   {
      61             :     // Make sure the problem hasn't already been created elsewhere
      62       62336 :     if (!_problem)
      63             :     {
      64       59032 :       std::string type;
      65       59032 :       if (_app.useEigenvalue())
      66         502 :         type = "EigenProblem";
      67             :       else
      68       58530 :         type = "FEProblem";
      69       59032 :       auto params = _factory.getValidParams(type);
      70             : 
      71             :       // apply common parameters of the object held by CreateProblemAction to honor user inputs in
      72             :       // [Problem]
      73       59032 :       auto p = _awh.getActionByTask<CreateProblemAction>("create_problem");
      74       59032 :       if (p)
      75       19709 :         params.applyParameters(p->getObjectParams());
      76             : 
      77       59032 :       params.set<MooseMesh *>("mesh") = _mesh.get();
      78       59032 :       params.set<bool>("use_nonlinear") = _app.useNonlinear();
      79       59032 :       if (_pars.isParamValid("_solve"))
      80           1 :         params.set<bool>("solve") = getParam<bool>("_solve");
      81             : 
      82       59032 :       _problem = _factory.create<FEProblemBase>(type, "MOOSE Problem", params);
      83       59024 :     }
      84             :     else
      85             :     {
      86             :       // otherwise perform necessary sanity checks
      87        3304 :       if (_app.useEigenvalue() && !(std::dynamic_pointer_cast<EigenProblem>(_problem)))
      88           0 :         mooseError("Problem has to be of a EigenProblem (or derived subclass) type when using "
      89             :                    "eigen executioner");
      90             :     }
      91             :   }
      92             : }

Generated by: LCOV version 1.14