https://mooseframework.inl.gov
FauxPolycrystalVoronoi.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "FauxPolycrystalVoronoi.h"
11 #include "IndirectSort.h"
12 #include "MooseRandom.h"
13 #include "MooseMesh.h"
14 #include "MooseVariable.h"
15 #include "NonlinearSystemBase.h"
16 #include "DelimitedFileReader.h"
17 
19 
22 {
24  params.addClassDescription("Random Voronoi tessellation polycrystal when the number of order "
25  "parameters equal to the number of grains");
26  return params;
27 }
28 
30  : PolycrystalVoronoi(parameters)
31 {
32  if (_grain_num != _op_num)
33  paramError("op_num", "The number of order parameters has to equal to the number of grains");
34 }
35 
36 void
38 {
43  if (_op_num < 1)
44  mooseError("No coupled variables found");
45 
46  const auto first_variable_value = _mesh.queryPeriodicDimensions(*_vars[0]);
47  for (unsigned int i = 1; i < _vars.size(); ++i)
48  if (_mesh.queryPeriodicDimensions(*_vars[i]) != first_variable_value)
49  mooseError("Coupled polycrystal variables differ in periodicity");
50 }
51 
52 void
54 {
56 }
57 
58 void
60 {
61  _grain_to_op.clear();
62 
63  for (auto grain = decltype(_grain_num)(0); grain < _grain_num; grain++)
64  _grain_to_op.emplace_hint(_grain_to_op.end(), grain, grain);
65 }
registerMooseObject("PhaseFieldApp", FauxPolycrystalVoronoi)
std::map< unsigned int, unsigned int > _grain_to_op
A map of the grain_id to op.
void paramError(const std::string &param, Args... args) const
static InputParameters validParams()
virtual void initialSetup() override
We override all these functions to avoid calling FeatureFloodCount We know here is a one-to-one mappi...
static InputParameters validParams()
virtual void execute() override
const unsigned int _op_num
The maximum number of order parameters (colors) available to assign to the grain structure.
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.
const std::array< bool, 3 > & queryPeriodicDimensions(const unsigned int sys_num, const unsigned int var_num) const
virtual void precomputeGrainStructure() override
This callback is triggered after the object is initialized and may be optionally overridden to do pre...
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
FauxPolycrystalVoronoi(const InputParameters &parameters)
virtual void finalize() override
MooseMesh & _mesh
A reference to the mesh.
unsigned int _grain_num
The number of grains to create.