www.mooseframework.org
PolycrystalVoronoi.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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"
14 
15 // Forward Declarations
16 
18 {
19 public:
21 
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  virtual unsigned int getNumGrains() const override { return _grain_num; }
30  virtual std::vector<Point> getGrainCenters() const { return _centerpoints; }
31 
32  // Build a KD tree
33  void buildSearchTree();
34 
35 protected:
37  unsigned int _grain_num;
38 
39  const bool _columnar_3D;
40 
41  const unsigned int _rand_seed;
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 
64  std::unique_ptr<KDTree> _kd_tree;
67  std::vector<dof_id_type> _grain_gtl_ids;
69  std::vector<Point> _new_points;
73  unsigned int _point_patch_size;
75  unsigned int _grain_patch_size;
76 };
virtual void getGrainsBasedOnPoint(const Point &point, std::vector< unsigned int > &grains) const override
Method for retrieving active grain IDs based on some point in the mesh.
const FileName _file_name
static InputParameters validParams()
std::vector< Point > _new_points
Original grain center points and duplicated grain center points.
virtual std::vector< Point > getGrainCenters() const
virtual Real getVariableValue(unsigned int op_index, const Point &p) const override
Returns the variable value for a given op_index and mesh point.
Point findCenterPoint(const Point &point, const Point &p1, const Point &p2) const
std::vector< Point > _centerpoints
This object provides the base capability for creating proper polycrystal ICs.
std::vector< dof_id_type > _grain_gtl_ids
The domain is extended to consider periodic boundary conditions.
Real computeDiffuseInterface(const Point &point, const unsigned int &gr_index, const std::vector< unsigned int > &grain_ids) const
Point findNormalVector(const Point &point, const Point &p1, const Point &p2) const
PolycrystalVoronoi(const InputParameters &parameters)
Real findLinePoint(const Point &point, const Point &N, const Point &cntr, const unsigned int dim) const
std::unique_ptr< KDTree > _kd_tree
KD tree that is used to speedup grain search.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void precomputeGrainStructure() override
This callback is triggered after the object is initialized and may be optionally overridden to do pre...
const InputParameters & parameters() const
virtual unsigned int getNumGrains() const override
Must be overridden by the deriving class to provide the number of grains in the polycrystal structure...
unsigned int _grain_patch_size
The number of neighboring grains.
bool _use_kdtree
Whether or not to use a KD tree to speedup grain search.
const unsigned int _rand_seed
unsigned int _grain_num
The number of grains to create.
unsigned int _point_patch_size
The number of nearest points.