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 179 of file MooseADWrapper.h.

Member Typedef Documentation

◆ DNType

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

Definition at line 185 of file MooseADWrapper.h.

Constructor & Destructor Documentation

◆ MooseADWrapper() [1/2]

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

Definition at line 113 of file MooseADWrapper.C.

114  : _use_ad(use_ad), _val(), _dual_number(nullptr)
115 {
116  if (_use_ad)
117  _dual_number = libmesh_make_unique<TensorValue<DualReal>>();
118 }
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 139 of file MooseADWrapper.C.

140 {
141  for (std::size_t i = 0; i < LIBMESH_DIM; ++i)
142  for (std::size_t j = 0; j < LIBMESH_DIM; ++j)
143  _val(i, j) = (*_dual_number)(i, j).value();
144 }
const TensorValue< Real > & value() const

◆ dn() [1/2]

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

Definition at line 121 of file MooseADWrapper.C.

122 {
123  if (!_dual_number)
124  _dual_number = libmesh_make_unique<TensorValue<DualReal>>(_val);
125  else if (!_use_ad)
126  for (std::size_t i = 0; i < LIBMESH_DIM; ++i)
127  for (std::size_t j = 0; j < LIBMESH_DIM; ++j)
128  (*_dual_number)(i, j).value() = _val(i, j);
129  return *_dual_number;
130 }
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 133 of file MooseADWrapper.C.

134 {
135  return *_dual_number;
136 }
std::unique_ptr< TensorValue< DualReal > > _dual_number

◆ markAD()

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

Definition at line 147 of file MooseADWrapper.C.

148 {
149  if (!use_ad && _use_ad)
150  _dual_number = nullptr;
151  else if (use_ad && !_use_ad)
152  _dual_number = libmesh_make_unique<TensorValue<DualReal>>();
153  _use_ad = use_ad;
154 }
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 157 of file MooseADWrapper.C.

158 {
159  _val = rhs._val;
160  if (_dual_number && rhs._dual_number)
161  *_dual_number = *rhs._dual_number;
162  else if (_dual_number)
163  *_dual_number = 0;
164  return *this;
165 }
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 187 of file MooseADWrapper.h.

187 { return _val; }

◆ value() [2/2]

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

Definition at line 189 of file MooseADWrapper.h.

189 { 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 205 of file MooseADWrapper.h.

◆ _use_ad

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

Definition at line 203 of file MooseADWrapper.h.

◆ _val

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

Definition at line 204 of file MooseADWrapper.h.


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