https://mooseframework.inl.gov
VariableMappingBase.C
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 #include "VariableMappingBase.h"
11 
14 {
17  params.addClassDescription("Base class for mapping objects.");
18  params.registerBase("VariableMappingBase");
19  params.registerSystemAttributeName("VariableMappingBase");
20  params.addParam<std::vector<VariableName>>("variables",
21  "The names of the variables which need a mapping.");
22  return params;
23 }
24 
26  : MooseObject(parameters),
27  RestartableModelInterface(*this, /*read_only=*/false, _type + "_" + name()),
28  _variable_names(isParamValid("filename")
29  ? getModelData<std::vector<VariableName>>("variables")
30  : declareModelData<std::vector<VariableName>>(
31  "variables", getParam<std::vector<VariableName>>("variables"))),
32  _mapping_ready_to_use(declareModelData<std::map<VariableName, bool>>("mapping_ready_to_use"))
33 {
34 }
35 
36 void
37 VariableMappingBase::checkIfReadyToUse(const VariableName & libmesh_dbg_var(vname)) const
38 {
39  mooseAssert(_mapping_ready_to_use.find(vname) != _mapping_ready_to_use.end() &&
40  _mapping_ready_to_use[vname],
41  "The mapping for variable " + vname + "is not ready to use!");
42 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
VariableMappingBase(const InputParameters &parameters)
std::map< VariableName, bool > & _mapping_ready_to_use
Bool to decide if we already have the mapping built or not to make sure it is not computed multiple t...
void registerSystemAttributeName(const std::string &value)
void registerBase(const std::string &value)
void checkIfReadyToUse(const VariableName &libmesh_dbg_var(vname)) const
Check if we have a mapping for the variable and if it is ready to be used.
const std::string name
Definition: Setup.h:20
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
static InputParameters validParams()
An interface class which manages the model data save and load functionalities from moose objects (suc...