https://mooseframework.inl.gov
ADSmoothTransitionTestMaterial.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 "ADReal.h"
12 
13 #include "ADReal.h"
14 registerMooseObject("ThermalHydraulicsTestApp", ADSmoothTransitionTestMaterial);
15 
18 {
20 
21  MooseEnum transition_type("cubic weighted");
22  params.addRequiredParam<MooseEnum>("transition_type", transition_type, "The transition to test");
23 
24  params.addRequiredCoupledVar("var", "Variable on which transition depends");
25 
26  params.addClassDescription("Class for testing objects derived from SmoothTransition");
27 
28  return params;
29 }
30 
32  : Material(parameters),
33 
34  _transition_type(getParam<MooseEnum>("transition_type")),
35 
36  _var(adCoupledValue("var")),
37  _center(0.0),
38  _width(1.),
39 
40  _cubic_transition(_center, _width),
41  _weighted_transition(_center, _width),
42 
43  _matprop(declareADProperty<Real>("myadmatprop"))
44 {
45  const ADReal & x1 = _cubic_transition.leftEnd();
46  const ADReal & x2 = _cubic_transition.rightEnd();
47  _cubic_transition.initialize(f1(x1), f2(x2), df1dx(x1), df2dx(x2));
48 }
49 
50 void
52 {
53  const ADReal & x = _var[_qp];
54 
55  if (_transition_type == "cubic")
56  {
58  }
59  else if (_transition_type == "weighted")
60  {
62  }
63 }
64 
65 ADReal
67 {
68  return 2 * x + 2;
69 }
70 
71 ADReal
73 {
74  return -0.5 * std::pow(x - 1, 2) + 1;
75 }
76 ADReal
78 {
79  return 2;
80 }
81 
82 ADReal
84 {
85  return 1 - x;
86 }
ADCubicTransition _cubic_transition
Cubic transition.
const MooseEnum & _transition_type
Type of transition.
ADReal f2(const ADReal &x) const
Computes right function.
const ADReal & leftEnd() const
Returns the coordinate of the left end of the transition.
DualNumber< Real, DNDerivativeType, true > ADReal
void addRequiredParam(const std::string &name, const std::string &doc_string)
const ADVariableValue & _var
Variable the transition depends upon.
ADMaterialProperty< Real > & _matprop
Material property created using the transition_base.
virtual ADReal value(const ADReal &x, const ADReal &f1, const ADReal &f2) const override
Computes the transition value.
unsigned int _qp
ADSmoothTransitionTestMaterial(const InputParameters &parameters)
const ADReal & rightEnd() const
Returns the coordinate of the right end of the transition.
static InputParameters validParams()
const std::vector< double > x
Class for testing objects derived from ADSmoothTransition.
virtual ADReal value(const ADReal &x, const ADReal &f1, const ADReal &f2) const override
Computes the transition value.
registerMooseObject("ThermalHydraulicsTestApp", ADSmoothTransitionTestMaterial)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
ADReal df1dx(const ADReal &x) const
Computes left function derivative.
ADReal df2dx(const ADReal &x) const
Computes right function derivative.
void addClassDescription(const std::string &doc_string)
ADReal f1(const ADReal &x) const
Computes left function.
void initialize(const ADReal &f1_end_value, const ADReal &f2_end_value, const ADReal &df1dx_end_value, const ADReal &df2dx_end_value)
Computes the derivative of the transition value.
MooseUnits pow(const MooseUnits &, int)
const ADWeightedTransition _weighted_transition
Weighted transition_base.