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

#include <MooseADWrapper.h>

Public Types

typedef RankTwoTensorTempl< DualRealDNType
 

Public Member Functions

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

Private Attributes

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

Friends

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

Detailed Description

template<>
class MooseADWrapper< RankTwoTensorTempl< Real > >

Definition at line 203 of file MooseADWrapper.h.

Member Typedef Documentation

◆ DNType

Definition at line 209 of file MooseADWrapper.h.

Constructor & Destructor Documentation

◆ MooseADWrapper() [1/2]

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

Definition at line 158 of file MooseADWrapper.C.

159  : _use_ad(use_ad), _val(), _dual_number(nullptr)
160 {
161  if (_use_ad)
162  _dual_number = libmesh_make_unique<RankTwoTensorTempl<DualReal>>();
163 }
std::unique_ptr< RankTwoTensorTempl< DualReal > > _dual_number

◆ MooseADWrapper() [2/2]

Member Function Documentation

◆ copyDualNumberToValue()

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

Definition at line 184 of file MooseADWrapper.C.

185 {
186  for (std::size_t i = 0; i < LIBMESH_DIM; ++i)
187  for (std::size_t j = 0; j < LIBMESH_DIM; ++j)
188  _val(i, j) = (*_dual_number)(i, j).value();
189 }
const RankTwoTensorTempl< Real > & value() const

◆ dn() [1/2]

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

Definition at line 166 of file MooseADWrapper.C.

167 {
168  if (!_dual_number)
169  _dual_number = libmesh_make_unique<RankTwoTensorTempl<DualReal>>(_val);
170  else if (!_use_ad)
171  for (std::size_t i = 0; i < LIBMESH_DIM; ++i)
172  for (std::size_t j = 0; j < LIBMESH_DIM; ++j)
173  (*_dual_number)(i, j).value() = _val(i, j);
174  return *_dual_number;
175 }
const RankTwoTensorTempl< Real > & value() const
std::unique_ptr< RankTwoTensorTempl< DualReal > > _dual_number

◆ dn() [2/2]

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

Definition at line 178 of file MooseADWrapper.C.

179 {
180  return *_dual_number;
181 }
std::unique_ptr< RankTwoTensorTempl< DualReal > > _dual_number

◆ markAD()

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

Definition at line 192 of file MooseADWrapper.C.

193 {
194  if (!use_ad && _use_ad)
195  _dual_number = nullptr;
196  else if (use_ad && !_use_ad)
197  _dual_number = libmesh_make_unique<RankTwoTensorTempl<DualReal>>();
198  _use_ad = use_ad;
199 }
std::unique_ptr< RankTwoTensorTempl< DualReal > > _dual_number

◆ operator=() [1/2]

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

Definition at line 203 of file MooseADWrapper.C.

204 {
205  _val = rhs._val;
206  if (_dual_number && rhs._dual_number)
207  *_dual_number = *rhs._dual_number;
208  else if (_dual_number)
209  *_dual_number = 0;
210  return *this;
211 }
std::unique_ptr< RankTwoTensorTempl< DualReal > > _dual_number
std::unique_ptr< T > _dual_number

◆ operator=() [2/2]

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

◆ value() [1/2]

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

Definition at line 211 of file MooseADWrapper.h.

211 { return _val; }

◆ value() [2/2]

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

Definition at line 213 of file MooseADWrapper.h.

213 { return _val; }

Friends And Related Function Documentation

◆ dataLoad

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

◆ dataStore

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

Member Data Documentation

◆ _dual_number

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

Definition at line 231 of file MooseADWrapper.h.

◆ _use_ad

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

Definition at line 229 of file MooseADWrapper.h.

◆ _val

RankTwoTensorTempl<Real> MooseADWrapper< RankTwoTensorTempl< Real > >::_val
private

Definition at line 230 of file MooseADWrapper.h.


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