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

Member Typedef Documentation

◆ DNType

Definition at line 285 of file MooseADWrapper.h.

Constructor & Destructor Documentation

◆ MooseADWrapper() [1/2]

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

Definition at line 272 of file MooseADWrapper.C.

273  : _use_ad(use_ad), _val(), _dual_number(nullptr)
274 {
275  if (_use_ad)
276  _dual_number = libmesh_make_unique<RankFourTensorTempl<DualReal>>();
277 }
std::unique_ptr< RankFourTensorTempl< DualReal > > _dual_number

◆ MooseADWrapper() [2/2]

Member Function Documentation

◆ copyDualNumberToValue()

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

Definition at line 300 of file MooseADWrapper.C.

301 {
302  for (std::size_t i = 0; i < LIBMESH_DIM; ++i)
303  for (std::size_t j = 0; j < LIBMESH_DIM; ++j)
304  for (std::size_t k = 0; k < LIBMESH_DIM; ++k)
305  for (std::size_t l = 0; l < LIBMESH_DIM; ++l)
306  _val(i, j, k, l) = (*_dual_number)(i, j, k, l).value();
307 }
const RankFourTensorTempl< Real > & value() const

◆ dn() [1/2]

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

Definition at line 280 of file MooseADWrapper.C.

281 {
282  if (!_dual_number)
283  _dual_number = libmesh_make_unique<RankFourTensorTempl<DualReal>>(_val);
284  else if (!_use_ad)
285  for (std::size_t i = 0; i < LIBMESH_DIM; ++i)
286  for (std::size_t j = 0; j < LIBMESH_DIM; ++j)
287  for (std::size_t k = 0; k < LIBMESH_DIM; ++k)
288  for (std::size_t l = 0; l < LIBMESH_DIM; ++l)
289  (*_dual_number)(i, j, k, l).value() = _val(i, j, k, l);
290  return *_dual_number;
291 }
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 294 of file MooseADWrapper.C.

295 {
296  return *_dual_number;
297 }
std::unique_ptr< RankFourTensorTempl< DualReal > > _dual_number

◆ markAD()

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

Definition at line 310 of file MooseADWrapper.C.

311 {
312  if (!use_ad && _use_ad)
313  _dual_number = nullptr;
314  else if (use_ad && !_use_ad)
315  _dual_number = libmesh_make_unique<RankFourTensorTempl<DualReal>>();
316  _use_ad = use_ad;
317 }
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 321 of file MooseADWrapper.C.

322 {
323  _val = rhs._val;
324  if (_dual_number && rhs._dual_number)
325  *_dual_number = *rhs._dual_number;
326  else if (_dual_number)
327  *_dual_number = 0;
328  return *this;
329 }
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 287 of file MooseADWrapper.h.

287 { return _val; }

◆ value() [2/2]

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

Definition at line 289 of file MooseADWrapper.h.

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

◆ _use_ad

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

Definition at line 305 of file MooseADWrapper.h.

◆ _val

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

Definition at line 306 of file MooseADWrapper.h.


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