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 "THMCreateMeshAction.h" 11 : #include "THMMesh.h" 12 : #include "FEProblemBase.h" 13 : #include "CreateProblemAction.h" 14 : #include "Factory.h" 15 : #include "MooseApp.h" 16 : #include "ActionWarehouse.h" 17 : 18 : registerMooseAction("ThermalHydraulicsApp", THMCreateMeshAction, "setup_mesh"); 19 : registerMooseAction("ThermalHydraulicsApp", THMCreateMeshAction, "uniform_refine_mesh"); 20 : 21 : InputParameters 22 3904 : THMCreateMeshAction::validParams() 23 : { 24 3904 : InputParameters params = Action::validParams(); 25 3904 : params.addClassDescription("Action that creates an empty mesh (in case one was not already " 26 : "created) and also builds THMProblem (same)."); 27 3904 : return params; 28 0 : } 29 : 30 3904 : THMCreateMeshAction::THMCreateMeshAction(const InputParameters & params) : Action(params) {} 31 : 32 : void 33 7804 : THMCreateMeshAction::act() 34 : { 35 7804 : if (_current_task == "setup_mesh") 36 : { 37 3904 : if (!_mesh) 38 : { 39 3759 : const std::string class_name = "THMMesh"; 40 3759 : InputParameters params = _factory.getValidParams(class_name); 41 7518 : params.set<MooseEnum>("dim") = "3"; 42 3759 : params.set<unsigned int>("patch_size") = 1; 43 : // We need to go through the Factory to create the THMMesh so 44 : // that its params object is properly added to the Warehouse. 45 3759 : _mesh = _factory.create<THMMesh>(class_name, "THM:mesh", params); 46 3759 : } 47 : 48 3904 : if (!_mesh->hasMeshBase()) 49 3904 : _mesh->setMeshBase(_mesh->buildMeshBaseObject()); 50 : 51 3904 : if (!_problem) 52 : { 53 3904 : const std::string class_name = "THMProblem"; 54 3904 : InputParameters params = _factory.getValidParams(class_name); 55 3904 : _app.builder().extractParams("", params); // extract global params 56 : // apply common parameters of the object held by CreateProblemAction to honor user inputs in 57 : // [Problem] 58 3904 : auto p = _awh.getActionByTask<CreateProblemAction>("create_problem"); 59 3904 : if (p) 60 291 : params.applyParameters(p->getObjectParams()); 61 3904 : params.set<MooseMesh *>("mesh") = _mesh.get(); 62 3904 : params.set<bool>("use_nonlinear") = _app.useNonlinear(); 63 3904 : _problem = _factory.create<FEProblemBase>(class_name, "THM:problem", params); 64 3904 : } 65 : } 66 3900 : else if (_current_task == "uniform_refine_mesh") 67 : { 68 7800 : if (_app.isParamSetByUser("refinements")) 69 : { 70 16 : auto level = _app.getParam<unsigned int>("refinements"); 71 8 : _mesh->setUniformRefineLevel(level, false); 72 : } 73 : } 74 7804 : }