LCOV - code coverage report
Current view: top level - src/actions - CreateProblemAction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #33187 (5aa0b2) with base d7c4bd Lines: 17 19 89.5 %
Date: 2026-06-30 12:18:20 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 "CreateProblemAction.h"
      11             : #include "Factory.h"
      12             : #include "FEProblem.h"
      13             : #include "MooseApp.h"
      14             : 
      15             : registerMooseAction("MooseApp", CreateProblemAction, "create_problem");
      16             : 
      17             : InputParameters
      18       25051 : CreateProblemAction::validParams()
      19             : {
      20       25051 :   InputParameters params = MooseObjectAction::validParams();
      21       50102 :   params.addClassDescription("Add a Problem object to the simulation.");
      22      100204 :   params.addParam<std::string>("type", "FEProblem", "Problem type");
      23       75153 :   params.addParam<std::string>("name", "MOOSE Problem", "The name the problem");
      24       25051 :   return params;
      25           0 : }
      26             : 
      27       24983 : CreateProblemAction::CreateProblemAction(const InputParameters & parameters)
      28       24983 :   : MooseObjectAction(parameters)
      29             : {
      30       24983 : }
      31             : 
      32             : void
      33       24706 : CreateProblemAction::act()
      34             : {
      35             :   // build the problem only if we have mesh
      36       74118 :   if (_mesh.get() != NULL && _pars.isParamSetByUser("type"))
      37             :   {
      38             :     // when this action is built by parser with Problem input block, this action
      39             :     // must act i.e. create a problem. Thus if a problem has been created, it will error out.
      40        4882 :     if (_problem)
      41           0 :       mooseError("Trying to build a problem but problem has already existed");
      42             : 
      43        9764 :     _moose_object_pars.set<MooseMesh *>("mesh") = _mesh.get();
      44        9764 :     _moose_object_pars.set<bool>("use_nonlinear") = _app.useNonlinear();
      45             : 
      46        4882 :     _problem =
      47       14646 :         _factory.create<FEProblemBase>(_type, getParam<std::string>("name"), _moose_object_pars);
      48             :   }
      49       24706 : }

Generated by: LCOV version 1.14