https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
CubicTransition Class Reference

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

#include <CubicTransition.h>

Inheritance diagram for CubicTransition:
[legend]

Public Member Functions

 CubicTransition (const Real &x_center, const Real &transition_width)
 Constructor.
 
virtual Real value (const Real &x, const Real &f1, const Real &f2) const override
 Computes the transition value.
 
Real derivative (const Real &x, const Real &df1dx, const Real &df2dx) const
 Computes the derivative of the transition value.
 
void initialize (const Real &f1_end_value, const Real &f2_end_value, const Real &df1dx_end_value, const Real &df2dx_end_value)
 Initializes the polynomial coefficients.
 
const Real & leftEnd () const
 Returns the coordinate of the left end of the transition.
 
const Real & rightEnd () const
 Returns the coordinate of the right end of the transition.
 

Protected Attributes

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

Detailed Description

Cubic polynomial transition between two functions of one variable.

Definition at line 17 of file CubicTransition.h.

Constructor & Destructor Documentation

◆ CubicTransition()

CubicTransition::CubicTransition ( const Real &  x_center,
const Real &  transition_width 
)

Constructor.

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

Definition at line 16 of file CubicTransition.C.

17 : SmoothTransition(x_center, transition_width),
18
19 _A(0.0),
20 _B(0.0),
21 _C(0.0),
22 _D(0.0),
23
24 _initialized(false)
25{
26}
bool _initialized
Flag that transition has been initialized.
Base class for smooth transitions between two functions of one variable.

Member Function Documentation

◆ derivative()

Real CubicTransition::derivative ( const Real &  x,
const Real &  df1dx,
const Real &  df2dx 
) const

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 89 of file CubicTransition.C.

90{
91 mooseAssert(_initialized, "initialize() must be called.");
92
93 if (x <= _x1)
94 return df1dx;
95 else if (x >= _x2)
96 return df2dx;
97 else
98 return 3.0 * _A * std::pow(x, 2) + 2.0 * _B * x + _C;
99}
const std::vector< double > x
const Real _x1
Left end point of transition.
const Real _x2
Right end point of transition.

Referenced by SmoothTransitionTestMaterial::computeQpProperties().

◆ initialize()

void CubicTransition::initialize ( const Real &  f1_end_value,
const Real &  f2_end_value,
const Real &  df1dx_end_value,
const Real &  df2dx_end_value 
)

Initializes the polynomial coefficients.

Parameters
[in]f1_end_valueValue of left function at left transition end point
[in]f2_end_valueValue of right function at right transition end point
[in]df1dx_end_valueValue of left function derivative at left transition end point
[in]df2dx_end_valueValue of right function derivative at right transition end point

Definition at line 29 of file CubicTransition.C.

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

Referenced by CubicTransitionFunction::CubicTransitionFunction(), and SmoothTransitionTestMaterial::SmoothTransitionTestMaterial().

◆ leftEnd()

const Real & SmoothTransition::leftEnd ( ) const
inlineinherited

Returns the coordinate of the left end of the transition.

Definition at line 40 of file SmoothTransition.h.

40{ return _x1; }

Referenced by CubicTransitionFunction::CubicTransitionFunction(), and SmoothTransitionTestMaterial::SmoothTransitionTestMaterial().

◆ rightEnd()

const Real & SmoothTransition::rightEnd ( ) const
inlineinherited

Returns the coordinate of the right end of the transition.

Definition at line 45 of file SmoothTransition.h.

45{ return _x2; }

Referenced by CubicTransitionFunction::CubicTransitionFunction(), and SmoothTransitionTestMaterial::SmoothTransitionTestMaterial().

◆ value()

Real CubicTransition::value ( const Real &  x,
const Real &  f1,
const Real &  f2 
) const
overridevirtual

Computes the transition value.

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

Implements SmoothTransition.

Definition at line 76 of file CubicTransition.C.

77{
78 mooseAssert(_initialized, "initialize() must be called.");
79
80 if (x <= _x1)
81 return f1;
82 else if (x >= _x2)
83 return f2;
84 else
85 return _A * std::pow(x, 3) + _B * std::pow(x, 2) + _C * x + _D;
86}

Referenced by SmoothTransitionTestMaterial::computeQpProperties(), and CubicTransitionFunction::value().

Member Data Documentation

◆ _A

Real CubicTransition::_A
protected

Definition at line 54 of file CubicTransition.h.

Referenced by derivative(), initialize(), and value().

◆ _B

Real CubicTransition::_B
protected

Definition at line 55 of file CubicTransition.h.

Referenced by derivative(), initialize(), and value().

◆ _C

Real CubicTransition::_C
protected

Definition at line 56 of file CubicTransition.h.

Referenced by derivative(), initialize(), and value().

◆ _D

Real CubicTransition::_D
protected

Definition at line 57 of file CubicTransition.h.

Referenced by initialize(), and value().

◆ _initialized

bool CubicTransition::_initialized
protected

Flag that transition has been initialized.

Definition at line 60 of file CubicTransition.h.

Referenced by derivative(), initialize(), and value().

◆ _transition_width

const Real SmoothTransition::_transition_width
protectedinherited

Width of transition.

Definition at line 51 of file SmoothTransition.h.

◆ _x1

const Real SmoothTransition::_x1
protectedinherited

◆ _x2

const Real SmoothTransition::_x2
protectedinherited

◆ _x_center

const Real SmoothTransition::_x_center
protectedinherited

Center point of transition.

Definition at line 49 of file SmoothTransition.h.


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