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 : #pragma once 11 : 12 : #include "KDTree.h" 13 : #include "PolycrystalUserObjectBase.h" 14 : 15 : // Forward Declarations 16 : 17 : class PolycrystalVoronoi : public PolycrystalUserObjectBase 18 : { 19 : public: 20 : static InputParameters validParams(); 21 : 22 : PolycrystalVoronoi(const InputParameters & parameters); 23 : 24 : virtual void precomputeGrainStructure() override; 25 : virtual void getGrainsBasedOnPoint(const Point & point, 26 : std::vector<unsigned int> & grains) const override; 27 : virtual Real getVariableValue(unsigned int op_index, const Point & p) const override; 28 : 29 721 : virtual unsigned int getNumGrains() const override { return _grain_num; } 30 342 : virtual std::vector<Point> getGrainCenters() const { return _centerpoints; } 31 : 32 : // Build a KD tree 33 : void buildSearchTree(); 34 : 35 : protected: 36 : /// The number of grains to create 37 : unsigned int _grain_num; 38 : 39 : const bool _columnar_3D; 40 : 41 : const unsigned int _rand_seed; 42 : const Real _int_width; 43 : 44 : Point _bottom_left; 45 : Point _top_right; 46 : Point _range; 47 : 48 : std::vector<Point> _centerpoints; 49 : 50 : const FileName _file_name; 51 : 52 : private: 53 : Real computeDiffuseInterface(const Point & point, 54 : const unsigned int & gr_index, 55 : const std::vector<unsigned int> & grain_ids) const; 56 : Point findNormalVector(const Point & point, const Point & p1, const Point & p2) const; 57 : Point findCenterPoint(const Point & point, const Point & p1, const Point & p2) const; 58 : Real findLinePoint(const Point & point, 59 : const Point & N, 60 : const Point & cntr, 61 : const unsigned int dim) const; 62 : 63 : /// KD tree that is used to speedup grain search 64 : std::unique_ptr<KDTree> _kd_tree; 65 : /// The domain is extended to consider periodic boundary conditions. 66 : /// Grains are duplicated. This stores a map from global grain id to local grain id 67 : std::vector<dof_id_type> _grain_gtl_ids; 68 : /// Original grain center points and duplicated grain center points 69 : std::vector<Point> _new_points; 70 : /// Whether or not to use a KD tree to speedup grain search 71 : bool _use_kdtree; 72 : /// The number of nearest points 73 : unsigned int _point_patch_size; 74 : /// The number of neighboring grains 75 : unsigned int _grain_patch_size; 76 : };