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

#include <MooseADWrapper.h>

Public Types

typedef std::vector< DenseVector< DualReal > > DNType
 

Public Member Functions

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

Private Attributes

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

Friends

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

Detailed Description

template<>
class MooseADWrapper< std::vector< DenseVector< Real > > >

Definition at line 431 of file MooseADWrapper.h.

Member Typedef Documentation

◆ DNType

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

Definition at line 437 of file MooseADWrapper.h.

Constructor & Destructor Documentation

◆ MooseADWrapper() [1/2]

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

Definition at line 547 of file MooseADWrapper.C.

548  : _use_ad(use_ad), _val(), _dual_number(nullptr)
549 {
550  if (_use_ad)
551  _dual_number = libmesh_make_unique<std::vector<DenseVector<DualReal>>>();
552 }
std::unique_ptr< std::vector< DenseVector< DualReal > > > _dual_number

◆ MooseADWrapper() [2/2]

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

Member Function Documentation

◆ copyDualNumberToValue()

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

Definition at line 578 of file MooseADWrapper.C.

579 {
580  for (std::size_t i = 0; i < _dual_number->size(); ++i)
581  for (std::size_t j = 0; j < (*_dual_number)[i].size(); ++j)
582  _val[i](j) = (*_dual_number)[i](j).value();
583 }
std::unique_ptr< std::vector< DenseVector< DualReal > > > _dual_number
const std::vector< DenseVector< Real > > & value() const

◆ dn() [1/2]

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

Definition at line 555 of file MooseADWrapper.C.

556 {
557  if (!_dual_number)
558  _dual_number = libmesh_make_unique<std::vector<DenseVector<DualReal>>>(_val.size());
559  else if (!_use_ad)
560  for (std::size_t i = 0; i < _dual_number->size(); ++i)
561  {
562  auto & val = _val[i];
563  auto & dn = (*_dual_number)[i];
564  dn.resize(val.size());
565  for (std::size_t j = 0; j < val.size(); ++j)
566  dn(j).value() = val(j);
567  }
568  return *_dual_number;
569 }
const std::vector< DenseVector< DualReal > > & dn(bool=true) const
std::unique_ptr< std::vector< DenseVector< DualReal > > > _dual_number

◆ dn() [2/2]

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

Definition at line 572 of file MooseADWrapper.C.

573 {
574  return *_dual_number;
575 }
std::unique_ptr< std::vector< DenseVector< DualReal > > > _dual_number

◆ markAD()

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

Definition at line 586 of file MooseADWrapper.C.

587 {
588  if (!use_ad && _use_ad)
589  _dual_number = nullptr;
590  else if (use_ad && !_use_ad)
591  _dual_number = libmesh_make_unique<std::vector<DenseVector<DualReal>>>();
592  _use_ad = use_ad;
593 }
std::unique_ptr< std::vector< DenseVector< DualReal > > > _dual_number

◆ operator=() [1/2]

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

Definition at line 597 of file MooseADWrapper.C.

598 {
599  _val = rhs._val;
600  if (_dual_number && rhs._dual_number)
601  *_dual_number = *rhs._dual_number;
602  else if (_dual_number)
603  // I don't know why we do this, but other code does it - ask Alex.
604  for (std::size_t i = 0; i < _dual_number->size(); ++i)
605  for (std::size_t j = 0; j < (*_dual_number)[i].size(); ++j)
606  (*_dual_number)[i](j) = 0;
607  return *this;
608 }
std::unique_ptr< std::vector< DenseVector< DualReal > > > _dual_number
std::unique_ptr< T > _dual_number

◆ operator=() [2/2]

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

◆ value() [1/2]

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

Definition at line 439 of file MooseADWrapper.h.

439 { return _val; }

◆ value() [2/2]

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

Definition at line 441 of file MooseADWrapper.h.

441 { return _val; }

Friends And Related Function Documentation

◆ dataLoad

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

◆ dataStore

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

Member Data Documentation

◆ _dual_number

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

Definition at line 459 of file MooseADWrapper.h.

◆ _use_ad

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

Definition at line 457 of file MooseADWrapper.h.

◆ _val

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

Definition at line 458 of file MooseADWrapper.h.


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