www.mooseframework.org
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Attributes | List of all members
ElementPropertyReadFile Class Reference

#include <ElementPropertyReadFile.h>

Inheritance diagram for ElementPropertyReadFile:
[legend]

Public Member Functions

 ElementPropertyReadFile (const InputParameters &parameters)
 
virtual ~ElementPropertyReadFile ()
 
virtual void initialize ()
 
virtual void execute ()
 
virtual void finalize ()
 
void readElementData ()
 This function reads element data from file. More...
 
virtual void readGrainData ()
 This function Read grain data from file. More...
 
virtual void initGrainCenterPoints ()
 This function generates grain center point Presently random generated. More...
 
Real getData (const Elem *, unsigned int) const
 This function assign property data to elements. More...
 
Real getElementData (const Elem *, unsigned int) const
 This function assign properties to element read from file with element based properties. More...
 
Real getGrainData (const Elem *, unsigned int) const
 This function assign properties to element read from file with grain based properties Grain distribution in the RVE can be Periodic or non-periodic (default) More...
 
Real minPeriodicDistance (Point, Point) const
 This function calculates minimum distance between 2 points considering periodicity of the simulation volume. More...
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Attributes

std::string _prop_file_name
 Name of file containing property values. More...
 
std::vector< Real > _data
 Store property values read from file. More...
 
unsigned int _nprop
 Number of properties in a row. More...
 
unsigned int _ngrain
 Number of grains (for property read based on grains) More...
 
MooseEnum _read_type
 Type of read - element or grain. More...
 
unsigned int _rand_seed
 Random seed - used for generating grain centers. More...
 
MooseEnum _rve_type
 Type of grain structure - non-periodic default. More...
 
MooseMesh & _mesh
 
std::vector< Point > _center
 

Private Attributes

unsigned int _nelem
 
Point _top_right
 
Point _bottom_left
 
Point _range
 
Real _max_range
 

Detailed Description

Definition at line 27 of file ElementPropertyReadFile.h.

Constructor & Destructor Documentation

◆ ElementPropertyReadFile()

ElementPropertyReadFile::ElementPropertyReadFile ( const InputParameters &  parameters)

Definition at line 42 of file ElementPropertyReadFile.C.

43  : GeneralUserObject(parameters),
44  _prop_file_name(getParam<FileName>("prop_file_name")),
45  _nprop(getParam<unsigned int>("nprop")),
46  _ngrain(getParam<unsigned int>("ngrain")),
47  _read_type(getParam<MooseEnum>("read_type")),
48  _rand_seed(getParam<unsigned int>("rand_seed")),
49  _rve_type(getParam<MooseEnum>("rve_type")),
50  _mesh(_fe_problem.mesh())
51 {
52  _nelem = _mesh.nElem();
53 
54  for (unsigned int i = 0; i < LIBMESH_DIM; i++)
55  {
56  _bottom_left(i) = _mesh.getMinInDimension(i);
57  _top_right(i) = _mesh.getMaxInDimension(i);
58  _range(i) = _top_right(i) - _bottom_left(i);
59  }
60 
61  _max_range = _range(0);
62  for (unsigned int i = 1; i < LIBMESH_DIM; i++)
63  if (_range(i) > _max_range)
64  _max_range = _range(i);
65 
66  switch (_read_type)
67  {
68  case 0:
70  break;
71 
72  case 1:
73  readGrainData();
74  break;
75  }
76 }

◆ ~ElementPropertyReadFile()

virtual ElementPropertyReadFile::~ElementPropertyReadFile ( )
inlinevirtual

Definition at line 33 of file ElementPropertyReadFile.h.

33 {}

Member Function Documentation

◆ execute()

virtual void ElementPropertyReadFile::execute ( )
inlinevirtual

Definition at line 36 of file ElementPropertyReadFile.h.

36 {}

◆ finalize()

virtual void ElementPropertyReadFile::finalize ( )
inlinevirtual

Definition at line 37 of file ElementPropertyReadFile.h.

37 {}

◆ getData()

Real ElementPropertyReadFile::getData ( const Elem *  elem,
unsigned int  prop_num 
) const

This function assign property data to elements.

Definition at line 126 of file ElementPropertyReadFile.C.

127 {
128  switch (_read_type)
129  {
130  case 0:
131  return getElementData(elem, prop_num);
132 
133  case 1:
134  return getGrainData(elem, prop_num);
135  }
136  mooseError("Error ElementPropertyReadFile: Provide valid read type");
137 }

Referenced by ComputeElasticityTensorCP::assignEulerAngles().

◆ getElementData()

Real ElementPropertyReadFile::getElementData ( const Elem *  elem,
unsigned int  prop_num 
) const

This function assign properties to element read from file with element based properties.

Definition at line 140 of file ElementPropertyReadFile.C.

141 {
142  unsigned int jelem = elem->id();
143  mooseAssert(jelem < _nelem,
144  "Error ElementPropertyReadFile: Element "
145  << jelem << " greater than than total number of element in mesh " << _nelem);
146  mooseAssert(prop_num < _nprop,
147  "Error ElementPropertyReadFile: Property number "
148  << prop_num << " greater than than total number of properties " << _nprop);
149  return _data[jelem * _nprop + prop_num];
150 }

Referenced by getData().

◆ getGrainData()

Real ElementPropertyReadFile::getGrainData ( const Elem *  elem,
unsigned int  prop_num 
) const

This function assign properties to element read from file with grain based properties Grain distribution in the RVE can be Periodic or non-periodic (default)

Definition at line 153 of file ElementPropertyReadFile.C.

154 {
155  mooseAssert(prop_num < _nprop,
156  "Error ElementPropertyReadFile: Property number "
157  << prop_num << " greater than than total number of properties " << _nprop
158  << "\n");
159 
160  Point centroid = elem->centroid();
161  Real min_dist = _max_range;
162  unsigned int igrain = 0;
163 
164  for (unsigned int i = 0; i < _ngrain; ++i)
165  {
166  Real dist = 0.0;
167  switch (_rve_type)
168  {
169  case 0:
170  // Calculates minimum periodic distance when "periodic" is specified
171  // for rve_type
172  dist = minPeriodicDistance(_center[i], centroid);
173  break;
174 
175  default:
176  // Calculates minimum distance when nothing is specified
177  // for rve_type
178  Point dist_vec = _center[i] - centroid;
179  dist = dist_vec.norm();
180  }
181 
182  if (dist < min_dist)
183  {
184  min_dist = dist;
185  igrain = i;
186  }
187  }
188 
189  return _data[igrain * _nprop + prop_num];
190 }

Referenced by getData().

◆ initGrainCenterPoints()

void ElementPropertyReadFile::initGrainCenterPoints ( )
virtual

This function generates grain center point Presently random generated.

Definition at line 116 of file ElementPropertyReadFile.C.

117 {
118  _center.resize(_ngrain);
119  MooseRandom::seed(_rand_seed);
120  for (unsigned int i = 0; i < _ngrain; i++)
121  for (unsigned int j = 0; j < LIBMESH_DIM; j++)
122  _center[i](j) = _bottom_left(j) + MooseRandom::rand() * _range(j);
123 }

Referenced by readGrainData().

◆ initialize()

virtual void ElementPropertyReadFile::initialize ( )
inlinevirtual

Definition at line 35 of file ElementPropertyReadFile.h.

35 {}

◆ minPeriodicDistance()

Real ElementPropertyReadFile::minPeriodicDistance ( Point  c,
Point  p 
) const

This function calculates minimum distance between 2 points considering periodicity of the simulation volume.

Definition at line 194 of file ElementPropertyReadFile.C.

195 {
196  Point dist_vec = c - p;
197  Real min_dist = dist_vec.norm();
198 
199  Real fac[3] = {-1.0, 0.0, 1.0};
200  for (unsigned int i = 0; i < 3; i++)
201  for (unsigned int j = 0; j < 3; j++)
202  for (unsigned int k = 0; k < 3; k++)
203  {
204  Point p1;
205  p1(0) = p(0) + fac[i] * _range(0);
206  p1(1) = p(1) + fac[j] * _range(1);
207  p1(2) = p(2) + fac[k] * _range(2);
208 
209  dist_vec = c - p1;
210  Real dist = dist_vec.norm();
211 
212  if (dist < min_dist)
213  min_dist = dist;
214  }
215 
216  return min_dist;
217 }

Referenced by getGrainData().

◆ readElementData()

void ElementPropertyReadFile::readElementData ( )

This function reads element data from file.

Definition at line 79 of file ElementPropertyReadFile.C.

80 {
81  _data.resize(_nprop * _nelem);
82 
83  MooseUtils::checkFileReadable(_prop_file_name);
84 
85  std::ifstream file_prop;
86  file_prop.open(_prop_file_name.c_str());
87 
88  for (unsigned int i = 0; i < _nelem; i++)
89  for (unsigned int j = 0; j < _nprop; j++)
90  if (!(file_prop >> _data[i * _nprop + j]))
91  mooseError("Error ElementPropertyReadFile: Premature end of file");
92 
93  file_prop.close();
94 }

Referenced by ElementPropertyReadFile().

◆ readGrainData()

void ElementPropertyReadFile::readGrainData ( )
virtual

This function Read grain data from file.

Definition at line 97 of file ElementPropertyReadFile.C.

98 {
99  mooseAssert(_ngrain > 0, "Error ElementPropertyReadFile: Provide non-zero number of grains");
100  _data.resize(_nprop * _ngrain);
101 
102  MooseUtils::checkFileReadable(_prop_file_name);
103  std::ifstream file_prop;
104  file_prop.open(_prop_file_name.c_str());
105 
106  for (unsigned int i = 0; i < _ngrain; i++)
107  for (unsigned int j = 0; j < _nprop; j++)
108  if (!(file_prop >> _data[i * _nprop + j]))
109  mooseError("Error ElementPropertyReadFile: Premature end of file");
110 
111  file_prop.close();
113 }

Referenced by ElementPropertyReadFile().

◆ validParams()

InputParameters ElementPropertyReadFile::validParams ( )
static

Definition at line 21 of file ElementPropertyReadFile.C.

22 {
23  InputParameters params = GeneralUserObject::validParams();
24  params.addClassDescription("User Object to read property data from an external file and assign "
25  "to elements.");
26  params.addParam<FileName>("prop_file_name", "", "Name of the property file name");
27  params.addRequiredParam<unsigned int>("nprop", "Number of tabulated property values");
28  params.addParam<unsigned int>("ngrain", 0, "Number of grains");
29  params.addRequiredParam<MooseEnum>(
30  "read_type",
31  MooseEnum("element grain"),
32  "Type of property distribution: element:element by element property "
33  "variation; grain:voronoi grain structure");
34  params.addParam<unsigned int>("rand_seed", 2000, "random seed");
35  params.addParam<MooseEnum>(
36  "rve_type",
37  MooseEnum("periodic none", "none"),
38  "Periodic or non-periodic grain distribution: Default is non-periodic");
39  return params;
40 }

Member Data Documentation

◆ _bottom_left

Point ElementPropertyReadFile::_bottom_left
private

Definition at line 99 of file ElementPropertyReadFile.h.

Referenced by ElementPropertyReadFile(), and initGrainCenterPoints().

◆ _center

std::vector<Point> ElementPropertyReadFile::_center
protected

Definition at line 94 of file ElementPropertyReadFile.h.

Referenced by getGrainData(), and initGrainCenterPoints().

◆ _data

std::vector<Real> ElementPropertyReadFile::_data
protected

Store property values read from file.

Definition at line 81 of file ElementPropertyReadFile.h.

Referenced by getElementData(), getGrainData(), readElementData(), and readGrainData().

◆ _max_range

Real ElementPropertyReadFile::_max_range
private

Definition at line 101 of file ElementPropertyReadFile.h.

Referenced by ElementPropertyReadFile(), and getGrainData().

◆ _mesh

MooseMesh& ElementPropertyReadFile::_mesh
protected

Definition at line 93 of file ElementPropertyReadFile.h.

Referenced by ElementPropertyReadFile().

◆ _nelem

unsigned int ElementPropertyReadFile::_nelem
private

◆ _ngrain

unsigned int ElementPropertyReadFile::_ngrain
protected

Number of grains (for property read based on grains)

Definition at line 85 of file ElementPropertyReadFile.h.

Referenced by getGrainData(), initGrainCenterPoints(), and readGrainData().

◆ _nprop

unsigned int ElementPropertyReadFile::_nprop
protected

Number of properties in a row.

Definition at line 83 of file ElementPropertyReadFile.h.

Referenced by getElementData(), getGrainData(), readElementData(), and readGrainData().

◆ _prop_file_name

std::string ElementPropertyReadFile::_prop_file_name
protected

Name of file containing property values.

Definition at line 79 of file ElementPropertyReadFile.h.

Referenced by readElementData(), and readGrainData().

◆ _rand_seed

unsigned int ElementPropertyReadFile::_rand_seed
protected

Random seed - used for generating grain centers.

Definition at line 89 of file ElementPropertyReadFile.h.

Referenced by initGrainCenterPoints().

◆ _range

Point ElementPropertyReadFile::_range
private

◆ _read_type

MooseEnum ElementPropertyReadFile::_read_type
protected

Type of read - element or grain.

Definition at line 87 of file ElementPropertyReadFile.h.

Referenced by ElementPropertyReadFile(), and getData().

◆ _rve_type

MooseEnum ElementPropertyReadFile::_rve_type
protected

Type of grain structure - non-periodic default.

Definition at line 91 of file ElementPropertyReadFile.h.

Referenced by getGrainData().

◆ _top_right

Point ElementPropertyReadFile::_top_right
private

Definition at line 98 of file ElementPropertyReadFile.h.

Referenced by ElementPropertyReadFile().


The documentation for this class was generated from the following files:
ElementPropertyReadFile::_ngrain
unsigned int _ngrain
Number of grains (for property read based on grains)
Definition: ElementPropertyReadFile.h:85
ElementPropertyReadFile::_nprop
unsigned int _nprop
Number of properties in a row.
Definition: ElementPropertyReadFile.h:83
ElementPropertyReadFile::_bottom_left
Point _bottom_left
Definition: ElementPropertyReadFile.h:99
ElementPropertyReadFile::_range
Point _range
Definition: ElementPropertyReadFile.h:100
ElementPropertyReadFile::_center
std::vector< Point > _center
Definition: ElementPropertyReadFile.h:94
ElementPropertyReadFile::_data
std::vector< Real > _data
Store property values read from file.
Definition: ElementPropertyReadFile.h:81
ElementPropertyReadFile::_read_type
MooseEnum _read_type
Type of read - element or grain.
Definition: ElementPropertyReadFile.h:87
ElementPropertyReadFile::_mesh
MooseMesh & _mesh
Definition: ElementPropertyReadFile.h:93
ElementPropertyReadFile::getElementData
Real getElementData(const Elem *, unsigned int) const
This function assign properties to element read from file with element based properties.
Definition: ElementPropertyReadFile.C:140
validParams
InputParameters validParams()
ElementPropertyReadFile::_max_range
Real _max_range
Definition: ElementPropertyReadFile.h:101
ElementPropertyReadFile::readElementData
void readElementData()
This function reads element data from file.
Definition: ElementPropertyReadFile.C:79
ElementPropertyReadFile::_nelem
unsigned int _nelem
Definition: ElementPropertyReadFile.h:97
ElementPropertyReadFile::readGrainData
virtual void readGrainData()
This function Read grain data from file.
Definition: ElementPropertyReadFile.C:97
ElementPropertyReadFile::_rve_type
MooseEnum _rve_type
Type of grain structure - non-periodic default.
Definition: ElementPropertyReadFile.h:91
ElementPropertyReadFile::_rand_seed
unsigned int _rand_seed
Random seed - used for generating grain centers.
Definition: ElementPropertyReadFile.h:89
ElementPropertyReadFile::minPeriodicDistance
Real minPeriodicDistance(Point, Point) const
This function calculates minimum distance between 2 points considering periodicity of the simulation ...
Definition: ElementPropertyReadFile.C:194
ElementPropertyReadFile::_prop_file_name
std::string _prop_file_name
Name of file containing property values.
Definition: ElementPropertyReadFile.h:79
ElementPropertyReadFile::_top_right
Point _top_right
Definition: ElementPropertyReadFile.h:98
ElementPropertyReadFile::getGrainData
Real getGrainData(const Elem *, unsigned int) const
This function assign properties to element read from file with grain based properties Grain distribut...
Definition: ElementPropertyReadFile.C:153
ElementPropertyReadFile::initGrainCenterPoints
virtual void initGrainCenterPoints()
This function generates grain center point Presently random generated.
Definition: ElementPropertyReadFile.C:116