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 : #pragma once 11 : 12 : #include "MooseObjectAction.h" 13 : 14 : #include "libmesh/fe_type.h" 15 : 16 : /** 17 : * Adds nonlinear variable 18 : */ 19 : class AddVariableAction : public MooseObjectAction 20 : { 21 : public: 22 : static InputParameters validParams(); 23 : 24 : AddVariableAction(const InputParameters & params); 25 : 26 : virtual void act() override; 27 : 28 : /** 29 : * Get the possible variable families 30 : * @return MooseEnum with the possible variable families (e.g., LAGRANGE) 31 : */ 32 : static MooseEnum getNonlinearVariableFamilies(); 33 : 34 : /** 35 : * Get the possible variable orders 36 : * @return MooseEnum with the possible variable orders (e.g., SECOND) 37 : */ 38 : static MooseEnum getNonlinearVariableOrders(); 39 : 40 : /** 41 : * determine the FEType by examining family and order in the provided parameters 42 : */ 43 : static libMesh::FEType feType(const InputParameters & params); 44 : 45 : /** 46 : * DEPRECATED: Use variableType instead 47 : */ 48 : static std::string 49 : determineType(const libMesh::FEType & fe_type, unsigned int components, bool is_fv = false); 50 : 51 : /** 52 : * Determines a variable type 53 : * @param fe_type The FE type 54 : * @param is_fv Whether or not the variable is use for finite volume 55 : * @param is_array Whether or not the variable is an array variable 56 : */ 57 : static std::string variableType(const libMesh::FEType & fe_type, 58 : const bool is_fv = false, 59 : const bool is_array = false); 60 : 61 : protected: 62 : /** 63 : * Initialize the action's member variables 64 : */ 65 : virtual void init(); 66 : 67 : /** 68 : * Adds a nonlinear variable to the system. 69 : * 70 : * @param var_name The name of the variable. 71 : */ 72 : void addVariable(const std::string & var_name); 73 : 74 : /** 75 : * Return the name of the nonlinear variable to be created 76 : */ 77 126679 : virtual std::string varName() const { return _name; } 78 : 79 : /** 80 : * Create the action to generate the InitialCondition object 81 : * 82 : * If the user supplies a value for 'initial_condition' in the input file this 83 : * method will create the proper InitialCondition object. 84 : */ 85 : void createInitialConditionAction(const std::vector<Real> & value); 86 : 87 : /** 88 : * Get the block ids from the input parameters 89 : * @return A set of block ids defined in the input 90 : */ 91 : std::set<SubdomainID> getSubdomainIDs(); 92 : 93 : /// FEType for the variable being created 94 : libMesh::FEType _fe_type; 95 : 96 : /// True if the variable being created is a scalar 97 : bool _scalar_var; 98 : 99 : /// True if the variable being created is finite volume 100 : bool _fv_var; 101 : 102 : /// Number of components for an array variable 103 : unsigned int _components; 104 : 105 : std::function<void(FEProblemBase &, const std::string &, const std::string &, InputParameters &)> 106 : _problem_add_var_method; 107 : };