www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
DiscreteNucleation Class Reference

Free energy penalty contribution to force the nucleation of subresolution particles. More...

#include <DiscreteNucleation.h>

Inheritance diagram for DiscreteNucleation:
[legend]

Public Member Functions

 DiscreteNucleation (const InputParameters &params)
 
virtual void computeProperties ()
 

Protected Attributes

unsigned int _nvar
 
std::vector< unsigned int > _op_index
 map op_names indices to _args indices More...
 
const std::vector< Real > _op_values
 Target concentration values. More...
 
const Real _penalty
 Nucleation free energy prefactor. More...
 
const unsigned int _penalty_mode
 Match concentration exactly or use the target as a minumum or maximum value. More...
 
const DiscreteNucleationMap_map
 UserObject providing a map of currently active nuclei. More...
 

Detailed Description

Free energy penalty contribution to force the nucleation of subresolution particles.

Definition at line 25 of file DiscreteNucleation.h.

Constructor & Destructor Documentation

◆ DiscreteNucleation()

DiscreteNucleation::DiscreteNucleation ( const InputParameters &  params)

Definition at line 36 of file DiscreteNucleation.C.

37  : DerivativeFunctionMaterialBase(params),
38  _nvar(coupledComponents("op_names")),
40  _op_values(getParam<std::vector<Real>>("op_values")),
41  _penalty(getParam<Real>("penalty")),
42  _penalty_mode(getParam<MooseEnum>("penalty_mode")),
43  _map(getUserObject<DiscreteNucleationMap>("map"))
44 {
45  // check inputs
46  if (_nvar != _op_values.size())
47  mooseError("The op_names and op_values parameter vectors must have the same number of entries");
48  if (_nvar != _args.size())
49  mooseError("Internal error.");
50 
51  // get libMesh variable numbers
52  for (unsigned int i = 0; i < _nvar; ++i)
53  _op_index[i] = argIndex(coupled("op_names", i));
54 }
const unsigned int _penalty_mode
Match concentration exactly or use the target as a minumum or maximum value.
const Real _penalty
Nucleation free energy prefactor.
const DiscreteNucleationMap & _map
UserObject providing a map of currently active nuclei.
std::vector< unsigned int > _op_index
map op_names indices to _args indices
const std::vector< Real > _op_values
Target concentration values.

Member Function Documentation

◆ computeProperties()

void DiscreteNucleation::computeProperties ( )
virtual

Definition at line 57 of file DiscreteNucleation.C.

58 {
59  // check if a nucleation event list is available for the current element
60  const std::vector<Real> & nucleus = _map.nuclei(_current_elem);
61 
62  // calculate penalty
63  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
64  {
65  // clear penalty value
66  if (_prop_F)
67  (*_prop_F)[_qp] = 0.0;
68 
69  for (unsigned int i = 0; i < _nvar; ++i)
70  {
71  const unsigned ii = _op_index[i];
72 
73  // modify the penalty magnitude with the nucleus mask
74  const Real penalty = _penalty * nucleus[_qp];
75 
76  // deviation from the target concentration
77  Real dc = (*_args[ii])[_qp] - _op_values[i];
78 
79  // ignore above/below target values for min/max modes respectively
80  if ((_penalty_mode == 1 && dc > 0.0) || (_penalty_mode == 2 && dc < 0.0))
81  dc = 0.0;
82 
83  // build free energy correction
84  if (_prop_F)
85  (*_prop_F)[_qp] += dc * dc * penalty;
86 
87  // first derivative
88  if (_prop_dF[ii])
89  (*_prop_dF[ii])[_qp] = 2.0 * dc * penalty;
90 
91  // second derivatives
92  for (unsigned int jj = ii; jj < _nvar; ++jj)
93  {
94  if (_prop_d2F[ii][jj])
95  (*_prop_d2F[ii][jj])[_qp] = 2.0 * penalty;
96 
97  // third derivatives
98  if (_third_derivatives)
99  for (unsigned int kk = jj; kk < _nvar; ++kk)
100  if (_prop_d3F[ii][jj][kk])
101  (*_prop_d3F[ii][jj][kk])[_qp] = 0.0;
102  }
103  }
104  }
105 }
const unsigned int _penalty_mode
Match concentration exactly or use the target as a minumum or maximum value.
const Real _penalty
Nucleation free energy prefactor.
const DiscreteNucleationMap & _map
UserObject providing a map of currently active nuclei.
const std::vector< Real > & nuclei(const Elem *) const
std::vector< unsigned int > _op_index
map op_names indices to _args indices
const std::vector< Real > _op_values
Target concentration values.

Member Data Documentation

◆ _map

const DiscreteNucleationMap& DiscreteNucleation::_map
protected

UserObject providing a map of currently active nuclei.

Definition at line 48 of file DiscreteNucleation.h.

Referenced by computeProperties().

◆ _nvar

unsigned int DiscreteNucleation::_nvar
protected

Definition at line 33 of file DiscreteNucleation.h.

Referenced by computeProperties(), and DiscreteNucleation().

◆ _op_index

std::vector<unsigned int> DiscreteNucleation::_op_index
protected

map op_names indices to _args indices

Definition at line 36 of file DiscreteNucleation.h.

Referenced by computeProperties(), and DiscreteNucleation().

◆ _op_values

const std::vector<Real> DiscreteNucleation::_op_values
protected

Target concentration values.

Definition at line 39 of file DiscreteNucleation.h.

Referenced by computeProperties(), and DiscreteNucleation().

◆ _penalty

const Real DiscreteNucleation::_penalty
protected

Nucleation free energy prefactor.

Definition at line 42 of file DiscreteNucleation.h.

Referenced by computeProperties().

◆ _penalty_mode

const unsigned int DiscreteNucleation::_penalty_mode
protected

Match concentration exactly or use the target as a minumum or maximum value.

Definition at line 45 of file DiscreteNucleation.h.

Referenced by computeProperties().


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