www.mooseframework.org
Material.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 // MOOSE includes
11 #include "Material.h"
12 
14 
17 {
18 
21  MooseEnum const_option("NONE=0 ELEMENT=1 SUBDOMAIN=2", "none");
22  params.addParam<MooseEnum>(
23  "constant_on",
24  const_option,
25  "When ELEMENT, MOOSE will only call computeQpProperties() for the 0th "
26  "quadrature point, and then copy that value to the other qps."
27  "When SUBDOMAIN, MOOSE will only call computeSubdomainProperties() for the 0th "
28  "quadrature point, and then copy that value to the other qps. Evaluations on element qps "
29  "will be skipped");
30  params.addParamNamesToGroup("use_displaced_mesh", "Advanced");
31  return params;
32 }
33 
35  : MaterialBase(parameters),
36  Coupleable(this, false),
37  MaterialPropertyInterface(this, blockIDs(), boundaryIDs()),
38  _bnd(_material_data_type != Moose::BLOCK_MATERIAL_DATA),
39  _neighbor(_material_data_type == Moose::NEIGHBOR_MATERIAL_DATA),
40  _q_point(_bnd ? _assembly.qPointsFace() : _assembly.qPoints()),
41  _qrule(_bnd ? _assembly.qRuleFace() : _assembly.qRule()),
42  _JxW(_bnd ? _assembly.JxWFace() : _assembly.JxW()),
43  _current_elem(_neighbor ? _assembly.neighbor() : _assembly.elem()),
44  _current_subdomain_id(_neighbor ? _assembly.currentNeighborSubdomainID()
45  : _assembly.currentSubdomainID()),
46  _current_side(_neighbor ? _assembly.neighborSide() : _assembly.side()),
47  _constant_option(getParam<MooseEnum>("constant_on").getEnum<ConstantTypeEnum>())
48 {
49  // Fill in the MooseVariable dependencies
50  const std::vector<MooseVariableFEBase *> & coupled_vars = getCoupledMooseVars();
51  for (const auto & var : coupled_vars)
53 }
54 
55 void
57 {
58  if (_constant_option == ConstantTypeEnum::SUBDOMAIN)
59  {
60  unsigned int nqp = _fe_problem.getMaxQps();
61 
63  for (const auto & prop_id : _supplied_prop_ids)
64  props[prop_id]->resize(nqp);
65 
66  _qp = 0;
68 
69  for (const auto & prop_id : _supplied_prop_ids)
70  {
71  for (decltype(nqp) qp = 1; qp < nqp; ++qp)
72  props[prop_id]->qpCopy(qp, props[prop_id], 0);
73  }
74  }
75 }
76 
77 void
79 {
80  if (_constant_option == ConstantTypeEnum::SUBDOMAIN)
81  return;
82 
83  // Reference to *all* the MaterialProperties in the MaterialData object, not
84  // just the ones for this Material.
85  MaterialProperties & props = _material_data->props();
86 
87  // If this Material has the _constant_on_elem flag set, we take the
88  // value computed for _qp==0 and use it at all the quadrature points
89  // in the Elem.
90  if (_constant_option == ConstantTypeEnum::ELEMENT)
91  {
92  // Compute MaterialProperty values at the first qp.
93  _qp = 0;
95 
96  // Now copy the values computed at qp 0 to all the other qps.
97  for (const auto & prop_id : _supplied_regular_prop_ids)
98  {
99  auto nqp = _qrule->n_points();
100  for (decltype(nqp) qp = 1; qp < nqp; ++qp)
101  props[prop_id]->qpCopy(qp, props[prop_id], 0);
102  }
103  for (const auto & prop_id : _supplied_ad_prop_ids)
104  {
105  auto nqp = _qrule->n_points();
106  for (decltype(nqp) qp = 1; qp < nqp; ++qp)
107  props[prop_id]->qpCopy(qp, props[prop_id], 0);
108  }
110  }
111  else
112  {
113  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
116  }
117 }
Moose
Definition: Moose.h:116
Material::_qrule
const QBase *const & _qrule
Definition: Material.h:85
Material::materialData
virtual const MaterialData & materialData() const override
Definition: Material.h:76
MaterialProperties
Container for storing material properties.
Definition: MaterialProperty.h:296
MooseVariableDependencyInterface::addMooseVariableDependency
void addMooseVariableDependency(MooseVariableFEBase *var)
Call this function to add the passed in MooseVariableFEBase as a variable that this object depends on...
Definition: MooseVariableDependencyInterface.h:36
FEProblemBase::getMaxQps
unsigned int getMaxQps() const
Definition: FEProblemBase.C:1120
MooseEnum
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
Material
Materials compute MaterialProperties.
Definition: Material.h:26
InputParameters::addParam
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object.
Definition: InputParameters.h:1198
MaterialBase::_supplied_ad_prop_ids
std::set< unsigned int > _supplied_ad_prop_ids
Definition: MaterialBase.h:236
defineLegacyParams
defineLegacyParams(Material)
Moose::NEIGHBOR_MATERIAL_DATA
Definition: MooseTypes.h:588
MaterialBase::_supplied_regular_prop_ids
std::set< unsigned int > _supplied_regular_prop_ids
Definition: MaterialBase.h:234
MaterialBase::computeSubdomainProperties
virtual void computeSubdomainProperties()
Evaluate material properties on subdomain.
Definition: MaterialBase.C:172
MaterialBase::validParams
static InputParameters validParams()
Definition: MaterialBase.C:22
MaterialPropertyInterface::validParams
static InputParameters validParams()
Definition: MaterialPropertyInterface.C:18
Material::_constant_option
const ConstantTypeEnum _constant_option
Options of the constantness level of the material.
Definition: Material.h:104
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition: InputParameters.h:53
Material::validParams
static InputParameters validParams()
Definition: Material.C:16
MaterialBase::computeQpProperties
virtual void computeQpProperties()
Users must override this method.
Definition: MaterialBase.C:192
MaterialPropertyInterface::_material_data
std::shared_ptr< MaterialData > _material_data
Pointer to the material data class that stores properties.
Definition: MaterialPropertyInterface.h:203
MaterialBase
MaterialBases compute MaterialProperties.
Definition: MaterialBase.h:47
MaterialBase::copyDualNumbersToValues
void copyDualNumbersToValues()
Definition: MaterialBase.C:230
Coupleable
Interface for objects that needs coupling capabilities.
Definition: Coupleable.h:62
Material::ConstantTypeEnum
ConstantTypeEnum
Definition: Material.h:96
MaterialData::props
MaterialProperties & props()
Methods for retrieving MaterialProperties object.
Definition: MaterialData.h:100
Material::subdomainSetup
virtual void subdomainSetup() override
Subdomain setup evaluating material properties when required.
Definition: Material.C:56
MaterialBase::_fe_problem
FEProblemBase & _fe_problem
Definition: MaterialBase.h:201
Material::computeProperties
virtual void computeProperties() override
Performs the quadrature point loop, calling computeQpProperties.
Definition: Material.C:78
InputParameters::addParamNamesToGroup
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
Definition: InputParameters.C:590
Coupleable::getCoupledMooseVars
const std::vector< MooseVariableFEBase * > & getCoupledMooseVars() const
Get the list of all coupled variables.
Definition: Coupleable.h:85
Material::Material
Material(const InputParameters &parameters)
Definition: Material.C:34
MaterialBase::_qp
unsigned int _qp
Definition: MaterialBase.h:205
MaterialBase::_supplied_prop_ids
std::set< unsigned int > _supplied_prop_ids
The ids of the supplied properties, i.e.
Definition: MaterialBase.h:229
Material.h
MaterialPropertyInterface
An interface for accessing Materials.
Definition: MaterialPropertyInterface.h:38
Moose::BLOCK_MATERIAL_DATA
Definition: MooseTypes.h:585