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

Member Typedef Documentation

◆ DNType

Definition at line 295 of file MooseADWrapper.h.

Constructor & Destructor Documentation

◆ MooseADWrapper() [1/2]

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

Definition at line 281 of file MooseADWrapper.C.

282  : _use_ad(use_ad), _val(), _dual_number(nullptr)
283 {
284  if (_use_ad)
285  _dual_number = libmesh_make_unique<RankFourTensorTempl<DualReal>>();
286 }
std::unique_ptr< RankFourTensorTempl< DualReal > > _dual_number

◆ MooseADWrapper() [2/2]

Member Function Documentation

◆ copyDualNumberToValue()

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

Definition at line 309 of file MooseADWrapper.C.

310 {
311  for (std::size_t i = 0; i < LIBMESH_DIM; ++i)
312  for (std::size_t j = 0; j < LIBMESH_DIM; ++j)
313  for (std::size_t k = 0; k < LIBMESH_DIM; ++k)
314  for (std::size_t l = 0; l < LIBMESH_DIM; ++l)
315  _val(i, j, k, l) = (*_dual_number)(i, j, k, l).value();
316 }
const RankFourTensorTempl< Real > & value() const

◆ dn() [1/2]

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

Definition at line 289 of file MooseADWrapper.C.

290 {
291  if (!_dual_number)
292  _dual_number = libmesh_make_unique<RankFourTensorTempl<DualReal>>(_val);
293  else if (!_use_ad)
294  for (std::size_t i = 0; i < LIBMESH_DIM; ++i)
295  for (std::size_t j = 0; j < LIBMESH_DIM; ++j)
296  for (std::size_t k = 0; k < LIBMESH_DIM; ++k)
297  for (std::size_t l = 0; l < LIBMESH_DIM; ++l)
298  (*_dual_number)(i, j, k, l).value() = _val(i, j, k, l);
299  return *_dual_number;
300 }
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 303 of file MooseADWrapper.C.

304 {
305  return *_dual_number;
306 }
std::unique_ptr< RankFourTensorTempl< DualReal > > _dual_number

◆ markAD()

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

Definition at line 319 of file MooseADWrapper.C.

320 {
321  if (!use_ad && _use_ad)
322  _dual_number = nullptr;
323  else if (use_ad && !_use_ad)
324  _dual_number = libmesh_make_unique<RankFourTensorTempl<DualReal>>();
325  _use_ad = use_ad;
326 }
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 330 of file MooseADWrapper.C.

331 {
332  _val = rhs._val;
333  if (_dual_number && rhs._dual_number)
334  *_dual_number = *rhs._dual_number;
335  else if (_dual_number)
336  *_dual_number = 0;
337  return *this;
338 }
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 297 of file MooseADWrapper.h.

297 { return _val; }

◆ value() [2/2]

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

Definition at line 299 of file MooseADWrapper.h.

299 { 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 317 of file MooseADWrapper.h.

◆ _use_ad

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

Definition at line 315 of file MooseADWrapper.h.

◆ _val

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

Definition at line 316 of file MooseADWrapper.h.


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