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  for (unsigned int dim = 0; dim < _dim; ++dim)
47  {
48  bool first_variable_value = _mesh.isTranslatedPeriodic(_vars[0]->number(), dim);
49 
50  for (unsigned int i = 1; i < _vars.size(); ++i)
51  if (_mesh.isTranslatedPeriodic(_vars[i]->number(), dim) != first_variable_value)
52  mooseError("Coupled polycrystal variables differ in periodicity");
53  }
54 }
55 
56 void
58 {
60 }
61 
62 void
64 {
65  _grain_to_op.clear();
66 
67  for (auto grain = decltype(_grain_num)(0); grain < _grain_num; grain++)
68  _grain_to_op.emplace_hint(_grain_to_op.end(), grain, grain);
69 }
registerMooseObject("PhaseFieldApp", FauxPolycrystalVoronoi)
std::map< unsigned int, unsigned int > _grain_to_op
A map of the grain_id to op.
unsigned int dim
static InputParameters validParams()
bool isTranslatedPeriodic(unsigned int nonlinear_var_num, unsigned int component) const
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.
const unsigned int _dim
mesh dimension
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.
void paramError(const std::string &param, Args... args) 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.