https://mooseframework.inl.gov
Public Member Functions | Protected Attributes | List of all members
ADCubicTransition Class Reference

Cubic polynomial transition between two functions of one variable. More...

#include <ADCubicTransition.h>

Inheritance diagram for ADCubicTransition:
[legend]

Public Member Functions

 ADCubicTransition (const ADReal &x_center, const ADReal &transition_width)
 Constructor. More...
 
virtual ADReal value (const ADReal &x, const ADReal &f1, const ADReal &f2) const override
 Computes the transition value. More...
 
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. More...
 
const ADRealleftEnd () const
 Returns the coordinate of the left end of the transition. More...
 
const ADRealrightEnd () const
 Returns the coordinate of the right end of the transition. More...
 

Protected Attributes

ADReal _A
 
ADReal _B
 
ADReal _C
 
ADReal _D
 
bool _initialized
 Flag that transition has been initialized. More...
 
const ADReal _x_center
 Center point of transition. More...
 
const ADReal _transition_width
 Width of transition. More...
 
const ADReal _x1
 Left end point of transition. More...
 
const ADReal _x2
 Right end point of transition. More...
 

Detailed Description

Cubic polynomial transition between two functions of one variable.

Definition at line 17 of file ADCubicTransition.h.

Constructor & Destructor Documentation

◆ ADCubicTransition()

ADCubicTransition::ADCubicTransition ( const ADReal x_center,
const ADReal transition_width 
)

Constructor.

Parameters
[in]x_centerCenter point of transition
[in]transition_widthWidth of transition

Definition at line 17 of file ADCubicTransition.C.

18  : ADSmoothTransition(x_center, transition_width),
19 
20  _A(0.0),
21  _B(0.0),
22  _C(0.0),
23  _D(0.0),
24 
25  _initialized(false)
26 {
27 }
bool _initialized
Flag that transition has been initialized.
ADSmoothTransition(const ADReal &x_center, const ADReal &transition_width)
Constructor.

Member Function Documentation

◆ initialize()

void ADCubicTransition::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.

Parameters
[in]xPoint at which to evaluate transition
[in]df1dxFirst function derivative
[in]df2dxSecond function derivative

Definition at line 30 of file ADCubicTransition.C.

Referenced by ADSmoothTransitionTestMaterial::ADSmoothTransitionTestMaterial().

34 {
35  // compute cubic polynomial coefficients
36 
37  DenseMatrix<ADReal> mat(4, 4);
38 
39  mat(0, 0) = std::pow(_x1, 3);
40  mat(0, 1) = std::pow(_x1, 2);
41  mat(0, 2) = _x1;
42  mat(0, 3) = 1.0;
43 
44  mat(1, 0) = std::pow(_x2, 3);
45  mat(1, 1) = std::pow(_x2, 2);
46  mat(1, 2) = _x2;
47  mat(1, 3) = 1.0;
48 
49  mat(2, 0) = 3.0 * std::pow(_x1, 2);
50  mat(2, 1) = 2.0 * _x1;
51  mat(2, 2) = 1.0;
52  mat(2, 3) = 0.0;
53 
54  mat(3, 0) = 3.0 * std::pow(_x2, 2);
55  mat(3, 1) = 2.0 * _x2;
56  mat(3, 2) = 1.0;
57  mat(3, 3) = 0.0;
58 
59  DenseVector<ADReal> rhs(4);
60  rhs(0) = f1_end_value;
61  rhs(1) = f2_end_value;
62  rhs(2) = df1dx_end_value;
63  rhs(3) = df2dx_end_value;
64 
65  DenseVector<ADReal> coefs(4);
66  mat.lu_solve(rhs, coefs);
67 
68  _A = coefs(0);
69  _B = coefs(1);
70  _C = coefs(2);
71  _D = coefs(3);
72 
73  _initialized = true;
74 }
bool _initialized
Flag that transition has been initialized.
const ADReal _x2
Right end point of transition.
const ADReal _x1
Left end point of transition.
MooseUnits pow(const MooseUnits &, int)

◆ leftEnd()

const ADReal& ADSmoothTransition::leftEnd ( ) const
inlineinherited

Returns the coordinate of the left end of the transition.

Definition at line 40 of file ADSmoothTransition.h.

Referenced by ADSmoothTransitionTestMaterial::ADSmoothTransitionTestMaterial(), and ADShaftConnectedPump1PhaseUserObject::computeFluxesAndResiduals().

40 { return _x1; }
const ADReal _x1
Left end point of transition.

◆ rightEnd()

const ADReal& ADSmoothTransition::rightEnd ( ) const
inlineinherited

Returns the coordinate of the right end of the transition.

Definition at line 45 of file ADSmoothTransition.h.

Referenced by ADSmoothTransitionTestMaterial::ADSmoothTransitionTestMaterial(), and ADShaftConnectedPump1PhaseUserObject::computeFluxesAndResiduals().

45 { return _x2; }
const ADReal _x2
Right end point of transition.

◆ value()

ADReal ADCubicTransition::value ( const ADReal x,
const ADReal f1,
const ADReal f2 
) const
overridevirtual

Computes the transition value.

Parameters
[in]xPoint at which to evaluate function
[in]f1Left function
[in]f2Right function

Implements ADSmoothTransition.

Definition at line 77 of file ADCubicTransition.C.

Referenced by ADSmoothTransitionTestMaterial::computeQpProperties().

78 {
79  mooseAssert(_initialized, "initialize() must be called.");
80 
81  if (x <= _x1)
82  return f1;
83  else if (x >= _x2)
84  return f2;
85  else
86  return _A * std::pow(x, 3) + _B * std::pow(x, 2) + _C * x + _D;
87 }
bool _initialized
Flag that transition has been initialized.
const std::vector< double > x
const ADReal _x2
Right end point of transition.
const ADReal _x1
Left end point of transition.
MooseUnits pow(const MooseUnits &, int)

Member Data Documentation

◆ _A

ADReal ADCubicTransition::_A
protected

Definition at line 44 of file ADCubicTransition.h.

Referenced by initialize(), and value().

◆ _B

ADReal ADCubicTransition::_B
protected

Definition at line 45 of file ADCubicTransition.h.

Referenced by initialize(), and value().

◆ _C

ADReal ADCubicTransition::_C
protected

Definition at line 46 of file ADCubicTransition.h.

Referenced by initialize(), and value().

◆ _D

ADReal ADCubicTransition::_D
protected

Definition at line 47 of file ADCubicTransition.h.

Referenced by initialize(), and value().

◆ _initialized

bool ADCubicTransition::_initialized
protected

Flag that transition has been initialized.

Definition at line 50 of file ADCubicTransition.h.

Referenced by initialize(), and value().

◆ _transition_width

const ADReal ADSmoothTransition::_transition_width
protectedinherited

Width of transition.

Definition at line 51 of file ADSmoothTransition.h.

◆ _x1

const ADReal ADSmoothTransition::_x1
protectedinherited

Left end point of transition.

Definition at line 54 of file ADSmoothTransition.h.

Referenced by initialize(), ADSmoothTransition::leftEnd(), ADWeightedTransition::value(), value(), and ADWeightedTransition::weight().

◆ _x2

const ADReal ADSmoothTransition::_x2
protectedinherited

Right end point of transition.

Definition at line 56 of file ADSmoothTransition.h.

Referenced by initialize(), ADSmoothTransition::rightEnd(), ADWeightedTransition::value(), value(), and ADWeightedTransition::weight().

◆ _x_center

const ADReal ADSmoothTransition::_x_center
protectedinherited

Center point of transition.

Definition at line 49 of file ADSmoothTransition.h.


The documentation for this class was generated from the following files: