https://mooseframework.inl.gov
BatchMeshGeneratorAction.h
Go to the documentation of this file.
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 // MOOSE includes
13 #include "Action.h"
14 #include "ActionWarehouse.h"
16 
21  public InputParametersChecksUtils<BatchMeshGeneratorAction>
22 {
23 public:
25 
27 
28  virtual void act() override final;
29 
31  {
34  };
35 
36  enum class ParameterType
37  {
38  BOOL,
39  REAL,
40  SHORT,
41  USHORT,
42  INT,
43  UINT,
44  LONG,
45  ULONG,
46  LONGLONG,
47  ULONGLONG,
48  DOFIDTYPE,
49  BDRYIDTYPE,
50  SDIDTYPE,
51  STRING,
52  SDNAME,
53  BDRYNAME,
54  MGNAME,
55  MFNAME,
56  ENUM,
58  POINT
59  };
60 
61 protected:
62  virtual void addMeshGenerators();
64  const std::string _mesh_generator_type;
66  const std::string _mesh_name_prefix;
68  const std::vector<std::string> _batch_scalar_input_param_names;
70  const std::vector<ParameterType> _batch_scalar_input_param_types;
72  std::vector<std::vector<std::string>> _batch_scalar_input_param_values;
74  const std::vector<std::string> _batch_vector_input_param_names;
76  const std::vector<ParameterType> _batch_vector_input_param_types;
78  std::vector<std::vector<std::vector<std::string>>> _batch_vector_input_param_values;
82  const std::vector<std::string> _fixed_scalar_input_param_names;
84  const std::vector<ParameterType> _fixed_scalar_input_param_types;
86  std::vector<std::string> _fixed_scalar_input_param_values;
88  const std::vector<std::string> _fixed_vector_input_param_names;
90  const std::vector<ParameterType> _fixed_vector_input_param_types;
92  std::vector<std::vector<std::string>> _fixed_vector_input_param_values;
95 
103  void setScalarParams(InputParameters & params,
104  const std::string & param_name,
105  const ParameterType & param_type,
106  const std::string & param_value) const;
107 
115  void setVectorParams(InputParameters & params,
116  const std::string & param_name,
117  const ParameterType & param_type,
118  const std::vector<std::string> & param_value) const;
119 
126  template <typename T>
128  const std::string & param_name,
129  const std::vector<std::string> & param_value) const;
130 
138  template <typename T>
140  const std::string & param_name,
141  const std::vector<std::string> & param_value) const;
142 
150  template <typename T>
152  const std::string & param_name,
153  const std::vector<std::string> & param_value) const;
154 
163  void checkInputParametersTypes(const InputParameters & params,
164  const std::string & action_input_param_name,
165  const std::vector<std::string> & param_names,
166  const std::vector<ParameterType> & param_types,
167  const bool & is_vector = false) const;
168 
176  template <typename T>
177  void checkInputParameterType(const InputParameters & params,
178  const std::string & action_input_param_name,
179  const std::string & param_name,
180  const bool & is_vector) const;
181 
187  template <typename T>
188  T convertStringToCompoundRealScalar(const std::string & str) const;
189 
195  bool isCompoundRealScalarType(const ParameterType & param_type) const;
196 };
void convertAndSetCompoundRealScalarVector(InputParameters &params, const std::string &param_name, const std::vector< std::string > &param_value) const
Convert a vector of strings to a compound real scalar type vector and set it in the InputParameters o...
T convertStringToCompoundRealScalar(const std::string &str) const
Convert a string to a compound real scalar type.
const std::vector< ParameterType > _fixed_scalar_input_param_types
Types of the vector input parameters to keep fixed in the batch generation.
void setVectorParams(InputParameters &params, const std::string &param_name, const ParameterType &param_type, const std::vector< std::string > &param_value) const
Set the vector input parameters for a unit mesh generator.
const std::string _mesh_generator_type
Type (object name) of the mesh generator to use for batch generation.
std::vector< std::vector< std::string > > _batch_scalar_input_param_values
Values of the scalar input parameters to vary in the batch generation.
void convertAndSetStringLikeVector(InputParameters &params, const std::string &param_name, const std::vector< std::string > &param_value) const
Convert a vector of strings to a string-derived type vector and set it in the InputParameters object...
bool isCompoundRealScalarType(const ParameterType &param_type) const
Check if the parameter type is a compound real scalar type.
std::vector< std::string > _fixed_scalar_input_param_values
Values of the vector input parameters to keep fixed in the batch generation.
BatchMeshGeneratorAction(const InputParameters &params)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const MultiBatchParamsMethod _multi_batch_params_method
Method to use for generating the batch parameters.
Action to generate batches of mesh generators from vectors of parameter values.
static InputParameters validParams()
Base class for actions.
Definition: Action.h:33
const bool _use_decomposed_index
Flag to indicate if the decomposed index should be used in the mesh name.
const std::vector< ParameterType > _batch_scalar_input_param_types
Types of the scalar input parameters to vary in the batch generation.
Utility class to help check parameters.
void setScalarParams(InputParameters &params, const std::string &param_name, const ParameterType &param_type, const std::string &param_value) const
Set the scalar input parameters for a unit mesh generator.
virtual void act() override final
Method to add objects to the simulation or perform other setup tasks.
std::vector< std::vector< std::string > > _fixed_vector_input_param_values
Values of the vector input parameters to keep fixed in the batch generation.
const std::vector< std::string > _fixed_vector_input_param_names
Names of the vector input parameters to keep fixed in the batch generation.
void checkInputParameterType(const InputParameters &params, const std::string &action_input_param_name, const std::string &param_name, const bool &is_vector) const
Check the type of the input parameter is valid, otherwise throw an error.
void convertAndSetNumericVector(InputParameters &params, const std::string &param_name, const std::vector< std::string > &param_value) const
Convert a vector of strings to a numeric vector and set it in the InputParameters object...
const std::vector< std::string > _fixed_scalar_input_param_names
Names of the vector input parameters to keep fixed in the batch generation.
const std::vector< std::string > _batch_scalar_input_param_names
Names of the scalar input parameters to vary in the batch generation.
const std::vector< std::string > _batch_vector_input_param_names
Names of the vector input parameters to vary in the batch generation.
const std::vector< ParameterType > _fixed_vector_input_param_types
Types of the vector input parameters to keep fixed in the batch generation.
void checkInputParametersTypes(const InputParameters &params, const std::string &action_input_param_name, const std::vector< std::string > &param_names, const std::vector< ParameterType > &param_types, const bool &is_vector=false) const
Check the types of the input parameters are valid, otherwise throw an error.
std::vector< std::vector< std::vector< std::string > > > _batch_vector_input_param_values
Values of the vector input parameters to vary in the batch generation.
const std::string _mesh_name_prefix
Prefix to use for naming the batch generated meshes.
const std::vector< ParameterType > _batch_vector_input_param_types
Types of the vector input parameters to vary in the batch generation.