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

#include <MooseADWrapper.h>

Public Types

typedef DenseVector< DualRealDNType
 

Public Member Functions

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

Private Attributes

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

Friends

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

Detailed Description

template<>
class MooseADWrapper< DenseVector< Real > >

Definition at line 327 of file MooseADWrapper.h.

Member Typedef Documentation

◆ DNType

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

Definition at line 333 of file MooseADWrapper.h.

Constructor & Destructor Documentation

◆ MooseADWrapper() [1/2]

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

Definition at line 340 of file MooseADWrapper.C.

341  : _use_ad(use_ad), _val(), _dual_number(nullptr)
342 {
343  if (_use_ad)
344  _dual_number = libmesh_make_unique<DenseVector<DualReal>>();
345 }
std::unique_ptr< DenseVector< DualReal > > _dual_number

◆ MooseADWrapper() [2/2]

MooseADWrapper< DenseVector< Real > >::MooseADWrapper ( MooseADWrapper< DenseVector< Real >> &&  )
default

Member Function Documentation

◆ copyDualNumberToValue()

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

Definition at line 365 of file MooseADWrapper.C.

366 {
367  for (std::size_t i = 0; i < _dual_number->size(); ++i)
368  _val(i) = (*_dual_number)(i).value();
369 }
const DenseVector< Real > & value() const
std::unique_ptr< DenseVector< DualReal > > _dual_number

◆ dn() [1/2]

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

Definition at line 348 of file MooseADWrapper.C.

349 {
350  if (!_dual_number)
351  _dual_number = libmesh_make_unique<DenseVector<DualReal>>(_val);
352  else if (!_use_ad)
353  for (std::size_t i = 0; i < _dual_number->size(); ++i)
354  (*_dual_number)(i).value() = _val(i);
355  return *_dual_number;
356 }
const DenseVector< Real > & value() const
std::unique_ptr< DenseVector< DualReal > > _dual_number

◆ dn() [2/2]

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

Definition at line 359 of file MooseADWrapper.C.

360 {
361  return *_dual_number;
362 }
std::unique_ptr< DenseVector< DualReal > > _dual_number

◆ markAD()

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

Definition at line 372 of file MooseADWrapper.C.

373 {
374  if (!use_ad && _use_ad)
375  _dual_number = nullptr;
376  else if (use_ad && !_use_ad)
377  _dual_number = libmesh_make_unique<DenseVector<DualReal>>();
378  _use_ad = use_ad;
379 }
std::unique_ptr< DenseVector< DualReal > > _dual_number

◆ operator=() [1/2]

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

Definition at line 382 of file MooseADWrapper.C.

383 {
384  _val = rhs._val;
385  if (_dual_number && rhs._dual_number)
386  *_dual_number = *rhs._dual_number;
387  else if (_dual_number)
388  // I don't know why we do this, but other code does it - ask Alex.
389  for (size_t i = 0; i < _dual_number->size(); ++i)
390  (*_dual_number)(i) = 0;
391  return *this;
392 }
std::unique_ptr< DenseVector< DualReal > > _dual_number
std::unique_ptr< T > _dual_number

◆ operator=() [2/2]

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

◆ value() [1/2]

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

Definition at line 335 of file MooseADWrapper.h.

335 { return _val; }

◆ value() [2/2]

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

Definition at line 337 of file MooseADWrapper.h.

337 { return _val; }

Friends And Related Function Documentation

◆ dataLoad

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

◆ dataStore

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

Member Data Documentation

◆ _dual_number

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

Definition at line 353 of file MooseADWrapper.h.

◆ _use_ad

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

Definition at line 351 of file MooseADWrapper.h.

◆ _val

DenseVector<Real> MooseADWrapper< DenseVector< Real > >::_val
private

Definition at line 352 of file MooseADWrapper.h.


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