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

#include <MooseADWrapper.h>

Public Types

typedef RankFourTensorTempl< DualRealDNType
 

Public Member Functions

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

Private Attributes

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

Friends

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

Detailed Description

template<>
class MooseADWrapper< RankFourTensorTempl< Real > >

Definition at line 237 of file MooseADWrapper.h.

Member Typedef Documentation

◆ DNType

Definition at line 243 of file MooseADWrapper.h.

Constructor & Destructor Documentation

◆ MooseADWrapper() [1/2]

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

Definition at line 216 of file MooseADWrapper.C.

217  : _use_ad(use_ad), _val(), _dual_number(nullptr)
218 {
219  if (_use_ad)
220  _dual_number = libmesh_make_unique<RankFourTensorTempl<DualReal>>();
221 }
std::unique_ptr< RankFourTensorTempl< DualReal > > _dual_number

◆ MooseADWrapper() [2/2]

Member Function Documentation

◆ copyDualNumberToValue()

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

Definition at line 244 of file MooseADWrapper.C.

245 {
246  for (std::size_t i = 0; i < LIBMESH_DIM; ++i)
247  for (std::size_t j = 0; j < LIBMESH_DIM; ++j)
248  for (std::size_t k = 0; k < LIBMESH_DIM; ++k)
249  for (std::size_t l = 0; l < LIBMESH_DIM; ++l)
250  _val(i, j, k, l) = (*_dual_number)(i, j, k, l).value();
251 }
const RankFourTensorTempl< Real > & value() const

◆ dn() [1/2]

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

Definition at line 224 of file MooseADWrapper.C.

225 {
226  if (!_dual_number)
227  _dual_number = libmesh_make_unique<RankFourTensorTempl<DualReal>>(_val);
228  else if (!_use_ad)
229  for (std::size_t i = 0; i < LIBMESH_DIM; ++i)
230  for (std::size_t j = 0; j < LIBMESH_DIM; ++j)
231  for (std::size_t k = 0; k < LIBMESH_DIM; ++k)
232  for (std::size_t l = 0; l < LIBMESH_DIM; ++l)
233  (*_dual_number)(i, j, k, l).value() = _val(i, j, k, l);
234  return *_dual_number;
235 }
std::unique_ptr< RankFourTensorTempl< DualReal > > _dual_number
const RankFourTensorTempl< Real > & value() const

◆ dn() [2/2]

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

Definition at line 238 of file MooseADWrapper.C.

239 {
240  return *_dual_number;
241 }
std::unique_ptr< RankFourTensorTempl< DualReal > > _dual_number

◆ markAD()

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

Definition at line 254 of file MooseADWrapper.C.

255 {
256  if (!use_ad && _use_ad)
257  _dual_number = nullptr;
258  else if (use_ad && !_use_ad)
259  _dual_number = libmesh_make_unique<RankFourTensorTempl<DualReal>>();
260  _use_ad = use_ad;
261 }
std::unique_ptr< RankFourTensorTempl< DualReal > > _dual_number

◆ operator=() [1/2]

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

Definition at line 265 of file MooseADWrapper.C.

266 {
267  _val = rhs._val;
268  if (_dual_number && rhs._dual_number)
269  *_dual_number = *rhs._dual_number;
270  else if (_dual_number)
271  *_dual_number = 0;
272  return *this;
273 }
std::unique_ptr< RankFourTensorTempl< DualReal > > _dual_number
std::unique_ptr< T > _dual_number

◆ operator=() [2/2]

◆ value() [1/2]

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

Definition at line 245 of file MooseADWrapper.h.

245 { return _val; }

◆ value() [2/2]

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

Definition at line 247 of file MooseADWrapper.h.

247 { return _val; }

Friends And Related Function Documentation

◆ dataLoad

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

◆ dataStore

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

Member Data Documentation

◆ _dual_number

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

Definition at line 265 of file MooseADWrapper.h.

◆ _use_ad

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

Definition at line 263 of file MooseADWrapper.h.

◆ _val

RankFourTensorTempl<Real> MooseADWrapper< RankFourTensorTempl< Real > >::_val
private

Definition at line 264 of file MooseADWrapper.h.


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