https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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"
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
50void
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
67{
68 return 2 * x + 2;
69}
70
73{
74 using std::pow;
75 return -0.5 * pow(x - 1, 2) + 1;
76}
79{
80 return 2;
81}
82
85{
86 return 1 - x;
87}
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("ThermalHydraulicsTestApp", ADSmoothTransitionTestMaterial)
const std::vector< double > x
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
virtual ADReal value(const ADReal &x, const ADReal &f1, const ADReal &f2) const override
Computes the transition value.
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.
Class for testing objects derived from ADSmoothTransition.
ADSmoothTransitionTestMaterial(const InputParameters &parameters)
ADReal f2(const ADReal &x) const
Computes right function.
ADReal f1(const ADReal &x) const
Computes left function.
ADReal df1dx(const ADReal &x) const
Computes left function derivative.
ADMaterialProperty< Real > & _matprop
Material property created using the transition_base.
ADReal df2dx(const ADReal &x) const
Computes right function derivative.
const ADVariableValue & _var
Variable the transition depends upon.
const MooseEnum & _transition_type
Type of transition.
const ADWeightedTransition _weighted_transition
Weighted transition_base.
ADCubicTransition _cubic_transition
Cubic transition.
const ADReal & leftEnd() const
Returns the coordinate of the left end of the transition.
const ADReal & rightEnd() const
Returns the coordinate of the right end of the transition.
virtual ADReal value(const ADReal &x, const ADReal &f1, const ADReal &f2) const override
Computes the transition value.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
unsigned int _qp
static InputParameters validParams()