https://mooseframework.inl.gov
InterpolatedStatefulMaterial.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 
11 #include "SerialAccess.h"
12 
17 
18 template <typename T>
21 {
23  params.addClassDescription("Access old state from projected data.");
24  params.addRequiredCoupledVar("old_state", "The AuxVars for the coupled components");
25  params.addRequiredParam<MaterialPropertyName>("prop_name", "Name to emit");
26  return params;
27 }
28 
29 template <typename T>
31  const InputParameters & parameters)
32  : Material(parameters),
33  _old_state(coupledValuesOld("old_state")),
34  _older_state(coupledValuesOlder("old_state")),
35  _size(Moose::SerialAccess<T>::size()),
36  _prop_name(getParam<MaterialPropertyName>("prop_name")),
37  _prop_old(declareProperty<T>(_prop_name + _interpolated_old)),
38  _prop_older(declareProperty<T>(_prop_name + _interpolated_older))
39 {
40  if (_old_state.size() != _size)
41  paramError("old_state", "Wrong number of component AuxVariables passed in.");
42  mooseAssert(_old_state.size() == _older_state.size(),
43  "Internal error. Old and older coupled variable vectors should have the same size.");
44 }
45 
46 template <typename T>
47 void
49 {
50  std::size_t index = 0;
51  for (auto & v : Moose::serialAccess(_prop_old[_qp]))
52  v = (*_old_state[index++])[_qp];
53 
54  index = 0;
55  for (auto & v : Moose::serialAccess(_prop_older[_qp]))
56  v = (*_older_state[index++])[_qp];
57 }
58 
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition: MooseBase.h:435
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
const std::size_t _size
Total number of components (e.g. 1 for Real, LIBMESH_DIM for RealVectorValue, LIBMESH_DIM^2 for RankT...
static InputParameters validParams()
Definition: Material.C:14
Materials compute MaterialProperties.
Definition: Material.h:34
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
SerialAccessRange< T > serialAccess(T &obj)
Definition: SerialAccess.h:151
registerMooseObject("MooseApp", InterpolatedStatefulMaterialReal)
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
virtual void computeQpProperties() override
Users must override this method.
const std::vector< const VariableValue * > _old_state
Old projected state.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
InterpolatedStatefulMaterialTempl(const InputParameters &parameters)
Reconstitute a materal property from the old and older states of projected AuxVariables.
const std::vector< const VariableValue * > _older_state
Older projected state.