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

#include <MooseADWrapper.h>

Public Types

typedef TensorValue< DualRealDNType
 

Public Member Functions

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

Private Attributes

bool _use_ad
 
TensorValue< Real > _val
 
std::unique_ptr< TensorValue< DualReal > > _dual_number
 

Friends

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

Detailed Description

template<>
class MooseADWrapper< TensorValue< Real > >

Definition at line 169 of file MooseADWrapper.h.

Member Typedef Documentation

◆ DNType

typedef TensorValue<DualReal> MooseADWrapper< TensorValue< Real > >::DNType

Definition at line 175 of file MooseADWrapper.h.

Constructor & Destructor Documentation

◆ MooseADWrapper() [1/2]

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

Definition at line 104 of file MooseADWrapper.C.

105  : _use_ad(use_ad), _val(), _dual_number(nullptr)
106 {
107  if (_use_ad)
108  _dual_number = libmesh_make_unique<TensorValue<DualReal>>();
109 }
std::unique_ptr< TensorValue< DualReal > > _dual_number

◆ MooseADWrapper() [2/2]

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

Member Function Documentation

◆ copyDualNumberToValue()

void MooseADWrapper< TensorValue< Real > >::copyDualNumberToValue ( )

Definition at line 130 of file MooseADWrapper.C.

131 {
132  for (std::size_t i = 0; i < LIBMESH_DIM; ++i)
133  for (std::size_t j = 0; j < LIBMESH_DIM; ++j)
134  _val(i, j) = (*_dual_number)(i, j).value();
135 }
const TensorValue< Real > & value() const

◆ dn() [1/2]

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

Definition at line 112 of file MooseADWrapper.C.

113 {
114  if (!_dual_number)
115  _dual_number = libmesh_make_unique<TensorValue<DualReal>>(_val);
116  else if (!_use_ad)
117  for (std::size_t i = 0; i < LIBMESH_DIM; ++i)
118  for (std::size_t j = 0; j < LIBMESH_DIM; ++j)
119  (*_dual_number)(i, j).value() = _val(i, j);
120  return *_dual_number;
121 }
const TensorValue< Real > & value() const
std::unique_ptr< TensorValue< DualReal > > _dual_number

◆ dn() [2/2]

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

Definition at line 124 of file MooseADWrapper.C.

125 {
126  return *_dual_number;
127 }
std::unique_ptr< TensorValue< DualReal > > _dual_number

◆ markAD()

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

Definition at line 138 of file MooseADWrapper.C.

139 {
140  if (!use_ad && _use_ad)
141  _dual_number = nullptr;
142  else if (use_ad && !_use_ad)
143  _dual_number = libmesh_make_unique<TensorValue<DualReal>>();
144  _use_ad = use_ad;
145 }
std::unique_ptr< TensorValue< DualReal > > _dual_number

◆ operator=() [1/2]

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

Definition at line 148 of file MooseADWrapper.C.

149 {
150  _val = rhs._val;
151  if (_dual_number && rhs._dual_number)
152  *_dual_number = *rhs._dual_number;
153  else if (_dual_number)
154  *_dual_number = 0;
155  return *this;
156 }
std::unique_ptr< TensorValue< DualReal > > _dual_number
std::unique_ptr< T > _dual_number

◆ operator=() [2/2]

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

◆ value() [1/2]

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

Definition at line 177 of file MooseADWrapper.h.

177 { return _val; }

◆ value() [2/2]

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

Definition at line 179 of file MooseADWrapper.h.

179 { return _val; }

Friends And Related Function Documentation

◆ dataLoad

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

◆ dataStore

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

Member Data Documentation

◆ _dual_number

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

Definition at line 195 of file MooseADWrapper.h.

◆ _use_ad

bool MooseADWrapper< TensorValue< Real > >::_use_ad
private

Definition at line 193 of file MooseADWrapper.h.

◆ _val

TensorValue<Real> MooseADWrapper< TensorValue< Real > >::_val
private

Definition at line 194 of file MooseADWrapper.h.


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