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

Member Typedef Documentation

◆ DNType

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

Definition at line 171 of file MooseADWrapper.h.

Constructor & Destructor Documentation

◆ MooseADWrapper() [1/2]

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

Definition at line 107 of file MooseADWrapper.C.

108  : _use_ad(use_ad), _val(), _dual_number(nullptr)
109 {
110  if (_use_ad)
111  _dual_number = libmesh_make_unique<TensorValue<DualReal>>();
112 }
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 133 of file MooseADWrapper.C.

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

◆ dn() [1/2]

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

Definition at line 115 of file MooseADWrapper.C.

116 {
117  if (!_dual_number)
118  _dual_number = libmesh_make_unique<TensorValue<DualReal>>(_val);
119  else if (!_use_ad)
120  for (std::size_t i = 0; i < LIBMESH_DIM; ++i)
121  for (std::size_t j = 0; j < LIBMESH_DIM; ++j)
122  (*_dual_number)(i, j).value() = _val(i, j);
123  return *_dual_number;
124 }
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 127 of file MooseADWrapper.C.

128 {
129  return *_dual_number;
130 }
std::unique_ptr< TensorValue< DualReal > > _dual_number

◆ markAD()

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

Definition at line 141 of file MooseADWrapper.C.

142 {
143  if (!use_ad && _use_ad)
144  _dual_number = nullptr;
145  else if (use_ad && !_use_ad)
146  _dual_number = libmesh_make_unique<TensorValue<DualReal>>();
147  _use_ad = use_ad;
148 }
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 151 of file MooseADWrapper.C.

152 {
153  _val = rhs._val;
154  if (_dual_number && rhs._dual_number)
155  *_dual_number = *rhs._dual_number;
156  else if (_dual_number)
157  *_dual_number = 0;
158  return *this;
159 }
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 173 of file MooseADWrapper.h.

173 { return _val; }

◆ value() [2/2]

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

Definition at line 175 of file MooseADWrapper.h.

175 { 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 191 of file MooseADWrapper.h.

◆ _use_ad

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

Definition at line 189 of file MooseADWrapper.h.

◆ _val

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

Definition at line 190 of file MooseADWrapper.h.


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