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

This UserObject manages the insertion and expiration of nuclei in the simulation domain it manages a list of nuclei with their insertion times and their center positions. More...

#include <DiscreteNucleationFromFile.h>

Inheritance diagram for DiscreteNucleationFromFile:
[legend]

Public Types

using NucleusLocation = std::pair< Real, Point >
 A nucleus has an expiration time and a location. More...
 
using NucleusList = std::vector< NucleusLocation >
 Every MPI task should keep a full list of nuclei (in case they cross domains with their finite radii) More...
 
using NucleusChanges = std::pair< unsigned int, unsigned int >
 

Public Member Functions

 DiscreteNucleationFromFile (const InputParameters &parameters)
 
void initialize () override
 
void execute () override
 
void threadJoin (const UserObject &) override
 
void finalize () override
 
const Real & getRate () const override
 
virtual bool isMapUpdateRequired () const
 
virtual const NucleusListgetNucleusList () const
 
virtual const NucleusChangesgetInsertionsAndDeletions () const
 

Protected Attributes

const Real _hold_time
 Duration of time each nucleus is kept active after insertion. More...
 
MooseUtils::DelimitedFileReader _reader
 CSV file to read. More...
 
NucleusList _nucleation_history
 Total nucleation history read from file. More...
 
std::size_t _history_pointer
 pointer to the next nucleation event in the history More...
 
const Real _tol
 tolerance for determining insertion time More...
 
const Real _nucleation_rate
 total nucleation rate More...
 
NucleusList_global_nucleus_list
 the global list of all nuclei over all processors More...
 
NucleusChanges _changes_made
 count the number of nucleus insertions and deletions More...
 
bool _update_required
 is a map update required More...
 

Detailed Description

This UserObject manages the insertion and expiration of nuclei in the simulation domain it manages a list of nuclei with their insertion times and their center positions.

A DiscreteNucleationMap is needed to enable the DiscreteNucleation material to look up if a nucleus is present at a given element/qp.

Definition at line 27 of file DiscreteNucleationFromFile.h.

Member Typedef Documentation

◆ NucleusChanges

using DiscreteNucleationInserterBase::NucleusChanges = std::pair<unsigned int, unsigned int>
inherited

Definition at line 38 of file DiscreteNucleationInserterBase.h.

◆ NucleusList

Every MPI task should keep a full list of nuclei (in case they cross domains with their finite radii)

Definition at line 35 of file DiscreteNucleationInserterBase.h.

◆ NucleusLocation

using DiscreteNucleationInserterBase::NucleusLocation = std::pair<Real, Point>
inherited

A nucleus has an expiration time and a location.

Definition at line 32 of file DiscreteNucleationInserterBase.h.

Constructor & Destructor Documentation

◆ DiscreteNucleationFromFile()

DiscreteNucleationFromFile::DiscreteNucleationFromFile ( const InputParameters &  parameters)

Definition at line 32 of file DiscreteNucleationFromFile.C.

33  : DiscreteNucleationInserterBase(parameters),
34  _hold_time(getParam<Real>("hold_time")),
35  _reader(getParam<FileName>("file")),
37  _tol(getParam<Real>("tolerance")),
38  _nucleation_rate(0.0)
39 {
40  _reader.read();
41 
42  auto & names = _reader.getNames();
43  auto & data = _reader.getData();
44 
45  const std::size_t rows = data[0].size();
46  _nucleation_history.resize(rows);
47 
48  bool found_time = false;
49  bool found_x = false;
50  bool found_y = false;
51  bool found_z = false;
52 
53  for (std::size_t i = 0; i < names.size(); ++i)
54  {
55  // make sure all data columns have the same length
56  if (data[i].size() != rows)
57  paramError("file", "Mismatching column lengths in file");
58 
59  if (names[i] == "time")
60  {
61  for (std::size_t j = 0; j < rows; ++j)
62  _nucleation_history[j].first = data[i][j];
63  found_time = true;
64  }
65  else if (names[i] == "x")
66  {
67  for (std::size_t j = 0; j < rows; ++j)
68  _nucleation_history[j].second(0) = data[i][j];
69  found_x = true;
70  }
71  else if (names[i] == "y")
72  {
73  for (std::size_t j = 0; j < rows; ++j)
74  _nucleation_history[j].second(1) = data[i][j];
75  found_y = true;
76  }
77  else if (names[i] == "z")
78  {
79  for (std::size_t j = 0; j < rows; ++j)
80  _nucleation_history[j].second(2) = data[i][j];
81  found_z = true;
82  }
83  }
84 
85  // check if all required columns were found
86  if (!found_time)
87  paramError("file", "Missing 'time' column in file");
88  if (!found_x)
89  paramError("file", "Missing 'x' column in file");
90  if (!found_y && _mesh.dimension() >= 2)
91  paramError("file", "Missing 'y' column in file");
92  if (!found_z && _mesh.dimension() >= 3)
93  paramError("file", "Missing 'z' column in file");
94 
95  // sort the nucleation history primarily according to time
96  std::sort(_nucleation_history.begin(), _nucleation_history.end());
97 }
DiscreteNucleationInserterBase(const InputParameters &parameters)
NucleusList _nucleation_history
Total nucleation history read from file.
MooseUtils::DelimitedFileReader _reader
CSV file to read.
const Real _hold_time
Duration of time each nucleus is kept active after insertion.
std::size_t _history_pointer
pointer to the next nucleation event in the history
const Real _tol
tolerance for determining insertion time
const Real _nucleation_rate
total nucleation rate

Member Function Documentation

◆ execute()

void DiscreteNucleationFromFile::execute ( )
inlineoverride

Definition at line 33 of file DiscreteNucleationFromFile.h.

33 {}

◆ finalize()

void DiscreteNucleationFromFile::finalize ( )
override

Definition at line 136 of file DiscreteNucleationFromFile.C.

137 {
138  // no communication necessary as all ranks have the full nucleus history from the
139  // DelimitedFileReader
140  _update_required = _changes_made.first > 0 || _changes_made.second > 0;
141 }
NucleusChanges _changes_made
count the number of nucleus insertions and deletions
bool _update_required
is a map update required

◆ getInsertionsAndDeletions()

virtual const NucleusChanges& DiscreteNucleationInserterBase::getInsertionsAndDeletions ( ) const
inlinevirtualinherited

Definition at line 42 of file DiscreteNucleationInserterBase.h.

Referenced by DiscreteNucleationData::getValue().

42 { return _changes_made; }
NucleusChanges _changes_made
count the number of nucleus insertions and deletions

◆ getNucleusList()

virtual const NucleusList& DiscreteNucleationInserterBase::getNucleusList ( ) const
inlinevirtualinherited

Definition at line 41 of file DiscreteNucleationInserterBase.h.

41 { return _global_nucleus_list; }
NucleusList & _global_nucleus_list
the global list of all nuclei over all processors

◆ getRate()

const Real& DiscreteNucleationFromFile::getRate ( ) const
inlineoverridevirtual

Implements DiscreteNucleationInserterBase.

Definition at line 37 of file DiscreteNucleationFromFile.h.

37 { return _nucleation_rate; }
const Real _nucleation_rate
total nucleation rate

◆ initialize()

void DiscreteNucleationFromFile::initialize ( )
override

Definition at line 100 of file DiscreteNucleationFromFile.C.

101 {
102  // clear insertion and deletion counter
103  _changes_made = {0, 0};
104 
105  // expire entries from the local nucleus list (if the current time step converged)
106  if (_fe_problem.converged())
107  {
108  unsigned int i = 0;
109  while (i < _global_nucleus_list.size())
110  {
111  if (_global_nucleus_list[i].first - _tol <= _fe_problem.time())
112  {
113  // remove entry (by replacing with last element and shrinking size by one)
115  _global_nucleus_list.pop_back();
116  _changes_made.second++;
117  }
118  else
119  ++i;
120  }
121  }
122 
123  // check if it is time to insert from the nucleus history
124  while (_history_pointer < _nucleation_history.size() &&
125  _nucleation_history[_history_pointer].first <= _fe_problem.time())
126  {
127  _global_nucleus_list.push_back(
130  _changes_made.first++;
132  }
133 }
NucleusChanges _changes_made
count the number of nucleus insertions and deletions
NucleusList _nucleation_history
Total nucleation history read from file.
NucleusList & _global_nucleus_list
the global list of all nuclei over all processors
const Real _hold_time
Duration of time each nucleus is kept active after insertion.
std::size_t _history_pointer
pointer to the next nucleation event in the history
const Real _tol
tolerance for determining insertion time
std::pair< Real, Point > NucleusLocation
A nucleus has an expiration time and a location.

◆ isMapUpdateRequired()

virtual bool DiscreteNucleationInserterBase::isMapUpdateRequired ( ) const
inlinevirtualinherited

◆ threadJoin()

void DiscreteNucleationFromFile::threadJoin ( const UserObject &  )
inlineoverride

Definition at line 34 of file DiscreteNucleationFromFile.h.

34 {}

Member Data Documentation

◆ _changes_made

NucleusChanges DiscreteNucleationInserterBase::_changes_made
protectedinherited

◆ _global_nucleus_list

NucleusList& DiscreteNucleationInserterBase::_global_nucleus_list
protectedinherited

◆ _history_pointer

std::size_t DiscreteNucleationFromFile::_history_pointer
protected

pointer to the next nucleation event in the history

Definition at line 50 of file DiscreteNucleationFromFile.h.

Referenced by initialize().

◆ _hold_time

const Real DiscreteNucleationFromFile::_hold_time
protected

Duration of time each nucleus is kept active after insertion.

Definition at line 41 of file DiscreteNucleationFromFile.h.

Referenced by initialize().

◆ _nucleation_history

NucleusList DiscreteNucleationFromFile::_nucleation_history
protected

Total nucleation history read from file.

Definition at line 47 of file DiscreteNucleationFromFile.h.

Referenced by DiscreteNucleationFromFile(), and initialize().

◆ _nucleation_rate

const Real DiscreteNucleationFromFile::_nucleation_rate
protected

total nucleation rate

Definition at line 56 of file DiscreteNucleationFromFile.h.

Referenced by getRate().

◆ _reader

MooseUtils::DelimitedFileReader DiscreteNucleationFromFile::_reader
protected

CSV file to read.

Definition at line 44 of file DiscreteNucleationFromFile.h.

Referenced by DiscreteNucleationFromFile().

◆ _tol

const Real DiscreteNucleationFromFile::_tol
protected

tolerance for determining insertion time

Definition at line 53 of file DiscreteNucleationFromFile.h.

Referenced by initialize().

◆ _update_required

bool DiscreteNucleationInserterBase::_update_required
protectedinherited

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