https://mooseframework.inl.gov
ADWeightedTransition.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 
10 #include "ADWeightedTransition.h"
11 
12 ADWeightedTransition::ADWeightedTransition(const ADReal & x_center, const ADReal & transition_width)
13  : ADSmoothTransition(x_center, transition_width)
14 {
15 }
16 
17 ADReal
18 ADWeightedTransition::value(const ADReal & x, const ADReal & f1, const ADReal & f2) const
19 {
20  if (x <= _x1)
21  return f1;
22  else if (x >= _x2)
23  return f2;
24  else
25  {
26  const ADReal w = weight(x);
27  return w * f1 + (1.0 - w) * f2;
28  }
29 }
30 
31 ADReal
33 {
34  return 0.5 * (std::cos(libMesh::pi / (_x2 - _x1) * (x - _x1)) + 1.0);
35 }
DualNumber< Real, DNDerivativeType, true > ADReal
ADReal weight(const ADReal &x) const
Computes the weight of the first function.
ADWeightedTransition(const ADReal &x_center, const ADReal &transition_width)
Constructor.
const std::vector< double > x
virtual ADReal value(const ADReal &x, const ADReal &f1, const ADReal &f2) const override
Computes the transition value.
Base class for smooth transitions between two functions of one variable.
const ADReal _x2
Right end point of transition.
const ADReal _x1
Left end point of transition.
const Real pi