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

#include <MooseADWrapper.h>

Public Types

typedef DenseMatrix< DualRealDNType
 

Public Member Functions

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

Private Attributes

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

Friends

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

Detailed Description

template<>
class MooseADWrapper< DenseMatrix< Real > >

Definition at line 361 of file MooseADWrapper.h.

Member Typedef Documentation

◆ DNType

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

Definition at line 367 of file MooseADWrapper.h.

Constructor & Destructor Documentation

◆ MooseADWrapper() [1/2]

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

Definition at line 394 of file MooseADWrapper.C.

395  : _use_ad(use_ad), _val(), _dual_number(nullptr)
396 {
397  if (_use_ad)
398  _dual_number = libmesh_make_unique<DenseMatrix<DualReal>>();
399 }
std::unique_ptr< DenseMatrix< DualReal > > _dual_number

◆ MooseADWrapper() [2/2]

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

Member Function Documentation

◆ copyDualNumberToValue()

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

Definition at line 427 of file MooseADWrapper.C.

428 {
429  for (std::size_t i = 0; i < _dual_number->m(); ++i)
430  for (std::size_t j = 0; j < _dual_number->n(); ++j)
431  _val(i, j) = (*_dual_number)(i, j).value();
432 }
std::unique_ptr< DenseMatrix< DualReal > > _dual_number
const DenseMatrix< Real > & value() const

◆ dn() [1/2]

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

Definition at line 402 of file MooseADWrapper.C.

403 {
404  auto m = _val.m();
405  auto n = _val.n();
406  if (!_dual_number)
407  {
408  _dual_number = libmesh_make_unique<DenseMatrix<DualReal>>(m, n);
409  for (std::size_t i = 0; i < m; ++i)
410  for (std::size_t j = 0; j < n; ++j)
411  (*_dual_number)(i, j).value() = _val(i, j);
412  }
413  else if (!_use_ad)
414  for (std::size_t i = 0; i < m; ++i)
415  for (std::size_t j = 0; j < n; ++j)
416  (*_dual_number)(i, j).value() = _val(i, j);
417  return *_dual_number;
418 }
std::unique_ptr< DenseMatrix< DualReal > > _dual_number
const DenseMatrix< Real > & value() const
PetscInt m
PetscInt n

◆ dn() [2/2]

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

Definition at line 421 of file MooseADWrapper.C.

422 {
423  return *_dual_number;
424 }
std::unique_ptr< DenseMatrix< DualReal > > _dual_number

◆ markAD()

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

Definition at line 435 of file MooseADWrapper.C.

436 {
437  if (!use_ad && _use_ad)
438  _dual_number = nullptr;
439  else if (use_ad && !_use_ad)
440  _dual_number = libmesh_make_unique<DenseMatrix<DualReal>>();
441  _use_ad = use_ad;
442 }
std::unique_ptr< DenseMatrix< DualReal > > _dual_number

◆ operator=() [1/2]

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

Definition at line 445 of file MooseADWrapper.C.

446 {
447  _val = rhs._val;
448  if (_dual_number && rhs._dual_number)
449  *_dual_number = *rhs._dual_number;
450  else if (_dual_number)
451  // I don't know why we do this, but other code does it - ask Alex.
452  for (std::size_t i = 0; i < _dual_number->m(); ++i)
453  for (std::size_t j = 0; j < _dual_number->n(); ++j)
454  (*_dual_number)(i, j) = 0;
455  return *this;
456 }
std::unique_ptr< DenseMatrix< DualReal > > _dual_number
std::unique_ptr< T > _dual_number

◆ operator=() [2/2]

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

◆ value() [1/2]

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

Definition at line 369 of file MooseADWrapper.h.

369 { return _val; }

◆ value() [2/2]

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

Definition at line 371 of file MooseADWrapper.h.

371 { return _val; }

Friends And Related Function Documentation

◆ dataLoad

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

◆ dataStore

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

Member Data Documentation

◆ _dual_number

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

Definition at line 387 of file MooseADWrapper.h.

◆ _use_ad

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

Definition at line 385 of file MooseADWrapper.h.

◆ _val

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

Definition at line 386 of file MooseADWrapper.h.


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