www.mooseframework.org
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
MooseADWrapper< Real > Class Template Reference

#include <MooseADWrapper.h>

Public Types

typedef DualReal DNType
 

Public Member Functions

 MooseADWrapper (bool use_ad=false)
 
 MooseADWrapper (MooseADWrapper< Real > &&)=default
 
const Real & value () const
 
Real & value ()
 
const DualRealdn (bool=true) const
 
DualRealdn (bool=true)
 
void copyDualNumberToValue ()
 
void markAD (bool use_ad)
 
MooseADWrapper< Real > & operator= (const MooseADWrapper< Real > &)
 
MooseADWrapper< Real > & operator= (MooseADWrapper< Real > &&)=default
 

Private Attributes

bool _use_ad
 
Real _val
 
std::unique_ptr< DualReal_dual_number
 

Friends

void dataStore (std::ostream &, MooseADWrapper< Real > &, void *)
 
void dataLoad (std::istream &, MooseADWrapper< Real > &, void *)
 

Detailed Description

template<>
class MooseADWrapper< Real >

Definition at line 103 of file MooseADWrapper.h.

Member Typedef Documentation

◆ DNType

typedef DualReal MooseADWrapper< Real >::DNType

Definition at line 109 of file MooseADWrapper.h.

Constructor & Destructor Documentation

◆ MooseADWrapper() [1/2]

MooseADWrapper< Real >::MooseADWrapper ( bool  use_ad = false)

Definition at line 3 of file MooseADWrapper.C.

3  : _use_ad(use_ad), _val(), _dual_number(nullptr)
4 {
5  if (_use_ad)
6  _dual_number = libmesh_make_unique<DualReal>();
7 }
std::unique_ptr< DualReal > _dual_number

◆ MooseADWrapper() [2/2]

MooseADWrapper< Real >::MooseADWrapper ( MooseADWrapper< Real > &&  )
default

Member Function Documentation

◆ copyDualNumberToValue()

void MooseADWrapper< Real >::copyDualNumberToValue ( )

Definition at line 26 of file MooseADWrapper.C.

27 {
28  _val = _dual_number->value();
29 }
std::unique_ptr< DualReal > _dual_number

◆ dn() [1/2]

const DualReal & MooseADWrapper< Real >::dn ( bool  = true) const

Definition at line 10 of file MooseADWrapper.C.

11 {
12  if (!_dual_number)
13  _dual_number = libmesh_make_unique<DualReal>(_val);
14  else if (!_use_ad)
15  _dual_number->value() = _val;
16  return *_dual_number;
17 }
std::unique_ptr< DualReal > _dual_number

◆ dn() [2/2]

DualReal & MooseADWrapper< Real >::dn ( bool  = true)

Definition at line 20 of file MooseADWrapper.C.

21 {
22  return *_dual_number;
23 }
std::unique_ptr< DualReal > _dual_number

◆ markAD()

void MooseADWrapper< Real >::markAD ( bool  use_ad)

Definition at line 32 of file MooseADWrapper.C.

33 {
34  if (!use_ad && _use_ad)
35  _dual_number = nullptr;
36  else if (use_ad && !_use_ad)
37  _dual_number = libmesh_make_unique<DualReal>();
38  _use_ad = use_ad;
39 }
std::unique_ptr< DualReal > _dual_number

◆ operator=() [1/2]

MooseADWrapper< Real > & MooseADWrapper< Real >::operator= ( const MooseADWrapper< Real > &  rhs)

Definition at line 42 of file MooseADWrapper.C.

43 {
44  _val = rhs._val;
45  if (_dual_number && rhs._dual_number)
46  *_dual_number = *rhs._dual_number;
47  else if (_dual_number)
48  *_dual_number = 0;
49  return *this;
50 }
std::unique_ptr< DualReal > _dual_number

◆ operator=() [2/2]

MooseADWrapper<Real>& MooseADWrapper< Real >::operator= ( MooseADWrapper< Real > &&  )
default

◆ value() [1/2]

const Real& MooseADWrapper< Real >::value ( ) const
inline

Definition at line 111 of file MooseADWrapper.h.

111 { return _val; }

◆ value() [2/2]

Real& MooseADWrapper< Real >::value ( )
inline

Definition at line 113 of file MooseADWrapper.h.

113 { return _val; }

Friends And Related Function Documentation

◆ dataLoad

void dataLoad ( std::istream &  ,
MooseADWrapper< Real > &  ,
void *   
)
friend

◆ dataStore

void dataStore ( std::ostream &  ,
MooseADWrapper< Real > &  ,
void *   
)
friend

Member Data Documentation

◆ _dual_number

std::unique_ptr<DualReal> MooseADWrapper< Real >::_dual_number
mutableprivate

Definition at line 129 of file MooseADWrapper.h.

Referenced by operator=().

◆ _use_ad

bool MooseADWrapper< Real >::_use_ad
private

Definition at line 127 of file MooseADWrapper.h.

◆ _val

Real MooseADWrapper< Real >::_val
private

Definition at line 128 of file MooseADWrapper.h.

Referenced by operator=().


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