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

#include <MooseADWrapper.h>

Public Types

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

Public Member Functions

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

Private Attributes

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

Friends

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

Detailed Description

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

Definition at line 395 of file MooseADWrapper.h.

Member Typedef Documentation

◆ DNType

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

Definition at line 401 of file MooseADWrapper.h.

Constructor & Destructor Documentation

◆ MooseADWrapper() [1/2]

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

Definition at line 458 of file MooseADWrapper.C.

459  : _use_ad(use_ad), _val(), _dual_number(nullptr)
460 {
461  if (_use_ad)
462  _dual_number = libmesh_make_unique<std::vector<DenseMatrix<DualReal>>>();
463 }
std::unique_ptr< std::vector< DenseMatrix< DualReal > > > _dual_number

◆ MooseADWrapper() [2/2]

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

Member Function Documentation

◆ copyDualNumberToValue()

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

Definition at line 504 of file MooseADWrapper.C.

505 {
506  assert(_dual_number.get());
507  _val.resize(_dual_number->size());
508  for (size_t h = 0; h < _dual_number->size(); h++)
509  {
510  auto & val = (*_dual_number)[h];
511  _val[h].resize(val.m(), val.n());
512  for (std::size_t i = 0; i < val.m(); ++i)
513  for (std::size_t j = 0; j < val.n(); ++j)
514  _val[h](i, j) = val(i, j).value();
515  }
516 }
std::unique_ptr< std::vector< DenseMatrix< DualReal > > > _dual_number

◆ dn() [1/2]

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

Definition at line 466 of file MooseADWrapper.C.

467 {
468  if (!_dual_number)
469  {
470  _dual_number = libmesh_make_unique<std::vector<DenseMatrix<DualReal>>>(_val.size());
471  for (size_t h = 0; h < _val.size(); h++)
472  {
473  auto & val = _val[h];
474  (*_dual_number)[h].resize(val.m(), val.n());
475  for (std::size_t i = 0; i < val.m(); ++i)
476  for (std::size_t j = 0; j < val.n(); ++j)
477  (*_dual_number)[h](i, j).value() = val(i, j);
478  }
479  }
480  else if (!_use_ad)
481  {
482  assert(_dual_number.get());
483  assert(_dual_number->size() == _val.size());
484  for (size_t h = 0; h < _val.size(); h++)
485  {
486  auto & val = _val[h];
487  for (std::size_t i = 0; i < val.m(); ++i)
488  for (std::size_t j = 0; j < val.n(); ++j)
489  (*_dual_number)[h](i, j).value() = val(i, j);
490  }
491  }
492  assert(_dual_number.get());
493  return *_dual_number;
494 }
std::unique_ptr< std::vector< DenseMatrix< DualReal > > > _dual_number
const std::vector< DenseMatrix< Real > > & value() const

◆ dn() [2/2]

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

Definition at line 497 of file MooseADWrapper.C.

498 {
499  assert(_dual_number.get());
500  return *_dual_number;
501 }
std::unique_ptr< std::vector< DenseMatrix< DualReal > > > _dual_number

◆ markAD()

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

Definition at line 519 of file MooseADWrapper.C.

520 {
521  if (!use_ad && _use_ad)
522  _dual_number = nullptr;
523  else if (use_ad && !_dual_number)
524  _dual_number = libmesh_make_unique<std::vector<DenseMatrix<DualReal>>>(_val.size());
525  _use_ad = use_ad;
526 }
std::unique_ptr< std::vector< DenseMatrix< DualReal > > > _dual_number

◆ operator=() [1/2]

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

Definition at line 530 of file MooseADWrapper.C.

531 {
532  _val = rhs._val;
533  if (_dual_number && rhs._dual_number)
534  *_dual_number = *rhs._dual_number;
535  else if (_dual_number)
536  // I don't know why we do this, but other code does it - ask Alex.
537  for (size_t h = 0; h < _dual_number->size(); h++)
538  {
539  auto & val = (*_dual_number)[h];
540  for (std::size_t i = 0; i < val.m(); ++i)
541  for (std::size_t j = 0; j < val.n(); ++j)
542  val(i, j) = 0;
543  }
544  return *this;
545 }
std::unique_ptr< std::vector< DenseMatrix< DualReal > > > _dual_number
std::unique_ptr< T > _dual_number

◆ operator=() [2/2]

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

◆ value() [1/2]

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

Definition at line 403 of file MooseADWrapper.h.

403 { return _val; }

◆ value() [2/2]

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

Definition at line 405 of file MooseADWrapper.h.

405 { return _val; }

Friends And Related Function Documentation

◆ dataLoad

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

◆ dataStore

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

Member Data Documentation

◆ _dual_number

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

Definition at line 423 of file MooseADWrapper.h.

◆ _use_ad

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

Definition at line 421 of file MooseADWrapper.h.

◆ _val

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

Definition at line 422 of file MooseADWrapper.h.


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