Line data Source code
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 : 18 : registerMooseObject("PhaseFieldApp", FauxPolycrystalVoronoi); 19 : 20 : InputParameters 21 54 : FauxPolycrystalVoronoi::validParams() 22 : { 23 54 : InputParameters params = PolycrystalVoronoi::validParams(); 24 54 : params.addClassDescription("Random Voronoi tessellation polycrystal when the number of order " 25 : "parameters equal to the number of grains"); 26 54 : return params; 27 0 : } 28 : 29 27 : FauxPolycrystalVoronoi::FauxPolycrystalVoronoi(const InputParameters & parameters) 30 27 : : PolycrystalVoronoi(parameters) 31 : { 32 27 : if (_grain_num != _op_num) 33 0 : paramError("op_num", "The number of order parameters has to equal to the number of grains"); 34 27 : } 35 : 36 : void 37 27 : FauxPolycrystalVoronoi::initialSetup() 38 : { 39 : /** 40 : * For polycrystal ICs we need to assume that each of the variables has the same periodicity. 41 : * Since BCs are handled elsewhere in the system, we'll have to check this case explicitly. 42 : */ 43 27 : if (_op_num < 1) 44 0 : mooseError("No coupled variables found"); 45 : 46 81 : for (unsigned int dim = 0; dim < _dim; ++dim) 47 : { 48 54 : bool first_variable_value = _mesh.isTranslatedPeriodic(_vars[0]->number(), dim); 49 : 50 216 : for (unsigned int i = 1; i < _vars.size(); ++i) 51 162 : if (_mesh.isTranslatedPeriodic(_vars[i]->number(), dim) != first_variable_value) 52 0 : mooseError("Coupled polycrystal variables differ in periodicity"); 53 : } 54 27 : } 55 : 56 : void 57 20 : FauxPolycrystalVoronoi::execute() 58 : { 59 20 : precomputeGrainStructure(); 60 20 : } 61 : 62 : void 63 20 : FauxPolycrystalVoronoi::finalize() 64 : { 65 : _grain_to_op.clear(); 66 : 67 100 : for (auto grain = decltype(_grain_num)(0); grain < _grain_num; grain++) 68 80 : _grain_to_op.emplace_hint(_grain_to_op.end(), grain, grain); 69 20 : }