www.mooseframework.org
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...
 

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 25 of file ElementPropertyReadFile.h.

Constructor & Destructor Documentation

ElementPropertyReadFile::ElementPropertyReadFile ( const InputParameters &  parameters)

Definition at line 36 of file ElementPropertyReadFile.C.

37  : GeneralUserObject(parameters),
38  _prop_file_name(getParam<FileName>("prop_file_name")),
39  _nprop(getParam<unsigned int>("nprop")),
40  _ngrain(getParam<unsigned int>("ngrain")),
41  _read_type(getParam<MooseEnum>("read_type")),
42  _rand_seed(getParam<unsigned int>("rand_seed")),
43  _rve_type(getParam<MooseEnum>("rve_type")),
44  _mesh(_fe_problem.mesh())
45 {
46  _nelem = _mesh.nElem();
47 
48  for (unsigned int i = 0; i < LIBMESH_DIM; i++)
49  {
50  _bottom_left(i) = _mesh.getMinInDimension(i);
51  _top_right(i) = _mesh.getMaxInDimension(i);
52  _range(i) = _top_right(i) - _bottom_left(i);
53  }
54 
55  _max_range = _range(0);
56  for (unsigned int i = 1; i < LIBMESH_DIM; i++)
57  if (_range(i) > _max_range)
58  _max_range = _range(i);
59 
60  switch (_read_type)
61  {
62  case 0:
64  break;
65 
66  case 1:
67  readGrainData();
68  break;
69 
70  default:
71  mooseError("Error ElementPropertyReadFile: Provide valid read type");
72  }
73 }
unsigned int _nprop
Number of properties in a row.
unsigned int _ngrain
Number of grains (for property read based on grains)
MooseEnum _read_type
Type of read - element or grain.
void readElementData()
This function reads element data from file.
virtual void readGrainData()
This function Read grain data from file.
unsigned int _rand_seed
Random seed - used for generating grain centers.
MooseEnum _rve_type
Type of grain structure - non-periodic default.
std::string _prop_file_name
Name of file containing property values.
virtual ElementPropertyReadFile::~ElementPropertyReadFile ( )
inlinevirtual

Definition at line 29 of file ElementPropertyReadFile.h.

29 {}

Member Function Documentation

virtual void ElementPropertyReadFile::execute ( )
inlinevirtual

Definition at line 32 of file ElementPropertyReadFile.h.

32 {}
virtual void ElementPropertyReadFile::finalize ( )
inlinevirtual

Definition at line 33 of file ElementPropertyReadFile.h.

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

This function assign property data to elements.

Definition at line 123 of file ElementPropertyReadFile.C.

Referenced by ComputeElasticityTensorCP::assignEulerAngles(), and finalize().

124 {
125  switch (_read_type)
126  {
127  case 0:
128  return getElementData(elem, prop_num);
129 
130  case 1:
131  return getGrainData(elem, prop_num);
132  }
133  mooseError("Error ElementPropertyReadFile: Provide valid read type");
134 }
Real getElementData(const Elem *, unsigned int) const
This function assign properties to element read from file with element based properties.
MooseEnum _read_type
Type of read - element or grain.
Real getGrainData(const Elem *, unsigned int) const
This function assign properties to element read from file with grain based properties Grain distribut...
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 137 of file ElementPropertyReadFile.C.

Referenced by finalize(), and getData().

138 {
139  unsigned int jelem = elem->id();
140  mooseAssert(jelem < _nelem,
141  "Error ElementPropertyReadFile: Element "
142  << jelem
143  << " greater than than total number of element in mesh "
144  << _nelem);
145  mooseAssert(prop_num < _nprop,
146  "Error ElementPropertyReadFile: Property number "
147  << prop_num
148  << " greater than than total number of properties "
149  << _nprop);
150  return _data[jelem * _nprop + prop_num];
151 }
unsigned int _nprop
Number of properties in a row.
std::vector< Real > _data
Store property values read from file.
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 154 of file ElementPropertyReadFile.C.

Referenced by finalize(), and getData().

155 {
156  mooseAssert(prop_num < _nprop,
157  "Error ElementPropertyReadFile: Property number "
158  << prop_num
159  << " greater than than total number of properties "
160  << _nprop
161  << "\n");
162 
163  Point centroid = elem->centroid();
164  Real min_dist = _max_range;
165  unsigned int igrain = 0;
166 
167  for (unsigned int i = 0; i < _ngrain; ++i)
168  {
169  Real dist = 0.0;
170  switch (_rve_type)
171  {
172  case 0:
173  // Calculates minimum periodic distance when "periodic" is specified
174  // for rve_type
175  dist = minPeriodicDistance(_center[i], centroid);
176  break;
177 
178  default:
179  // Calculates minimum distance when nothing is specified
180  // for rve_type
181  Point dist_vec = _center[i] - centroid;
182  dist = dist_vec.norm();
183  }
184 
185  if (dist < min_dist)
186  {
187  min_dist = dist;
188  igrain = i;
189  }
190  }
191 
192  return _data[igrain * _nprop + prop_num];
193 }
unsigned int _nprop
Number of properties in a row.
Real minPeriodicDistance(Point, Point) const
This function calculates minimum distance between 2 points considering periodicity of the simulation ...
std::vector< Point > _center
unsigned int _ngrain
Number of grains (for property read based on grains)
std::vector< Real > _data
Store property values read from file.
MooseEnum _rve_type
Type of grain structure - non-periodic default.
void ElementPropertyReadFile::initGrainCenterPoints ( )
virtual

This function generates grain center point Presently random generated.

Definition at line 113 of file ElementPropertyReadFile.C.

Referenced by finalize(), and readGrainData().

114 {
115  _center.resize(_ngrain);
116  MooseRandom::seed(_rand_seed);
117  for (unsigned int i = 0; i < _ngrain; i++)
118  for (unsigned int j = 0; j < LIBMESH_DIM; j++)
119  _center[i](j) = _bottom_left(j) + MooseRandom::rand() * _range(j);
120 }
std::vector< Point > _center
unsigned int _ngrain
Number of grains (for property read based on grains)
unsigned int _rand_seed
Random seed - used for generating grain centers.
virtual void ElementPropertyReadFile::initialize ( )
inlinevirtual

Definition at line 31 of file ElementPropertyReadFile.h.

31 {}
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 197 of file ElementPropertyReadFile.C.

Referenced by finalize(), and getGrainData().

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

This function reads element data from file.

Definition at line 76 of file ElementPropertyReadFile.C.

Referenced by ElementPropertyReadFile(), and finalize().

77 {
78  _data.resize(_nprop * _nelem);
79 
80  MooseUtils::checkFileReadable(_prop_file_name);
81 
82  std::ifstream file_prop;
83  file_prop.open(_prop_file_name.c_str());
84 
85  for (unsigned int i = 0; i < _nelem; i++)
86  for (unsigned int j = 0; j < _nprop; j++)
87  if (!(file_prop >> _data[i * _nprop + j]))
88  mooseError("Error ElementPropertyReadFile: Premature end of file");
89 
90  file_prop.close();
91 }
unsigned int _nprop
Number of properties in a row.
std::vector< Real > _data
Store property values read from file.
std::string _prop_file_name
Name of file containing property values.
void ElementPropertyReadFile::readGrainData ( )
virtual

This function Read grain data from file.

Definition at line 94 of file ElementPropertyReadFile.C.

Referenced by ElementPropertyReadFile(), and finalize().

95 {
96  mooseAssert(_ngrain > 0, "Error ElementPropertyReadFile: Provide non-zero number of grains");
97  _data.resize(_nprop * _ngrain);
98 
99  MooseUtils::checkFileReadable(_prop_file_name);
100  std::ifstream file_prop;
101  file_prop.open(_prop_file_name.c_str());
102 
103  for (unsigned int i = 0; i < _ngrain; i++)
104  for (unsigned int j = 0; j < _nprop; j++)
105  if (!(file_prop >> _data[i * _nprop + j]))
106  mooseError("Error ElementPropertyReadFile: Premature end of file");
107 
108  file_prop.close();
110 }
unsigned int _nprop
Number of properties in a row.
unsigned int _ngrain
Number of grains (for property read based on grains)
std::vector< Real > _data
Store property values read from file.
virtual void initGrainCenterPoints()
This function generates grain center point Presently random generated.
std::string _prop_file_name
Name of file containing property values.

Member Data Documentation

Point ElementPropertyReadFile::_bottom_left
private

Definition at line 95 of file ElementPropertyReadFile.h.

Referenced by ElementPropertyReadFile(), and initGrainCenterPoints().

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

Definition at line 90 of file ElementPropertyReadFile.h.

Referenced by getGrainData(), and initGrainCenterPoints().

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

Store property values read from file.

Definition at line 77 of file ElementPropertyReadFile.h.

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

Real ElementPropertyReadFile::_max_range
private

Definition at line 97 of file ElementPropertyReadFile.h.

Referenced by ElementPropertyReadFile(), and getGrainData().

MooseMesh& ElementPropertyReadFile::_mesh
protected

Definition at line 89 of file ElementPropertyReadFile.h.

Referenced by ElementPropertyReadFile().

unsigned int ElementPropertyReadFile::_nelem
private
unsigned int ElementPropertyReadFile::_ngrain
protected

Number of grains (for property read based on grains)

Definition at line 81 of file ElementPropertyReadFile.h.

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

unsigned int ElementPropertyReadFile::_nprop
protected

Number of properties in a row.

Definition at line 79 of file ElementPropertyReadFile.h.

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

std::string ElementPropertyReadFile::_prop_file_name
protected

Name of file containing property values.

Definition at line 75 of file ElementPropertyReadFile.h.

Referenced by readElementData(), and readGrainData().

unsigned int ElementPropertyReadFile::_rand_seed
protected

Random seed - used for generating grain centers.

Definition at line 85 of file ElementPropertyReadFile.h.

Referenced by initGrainCenterPoints().

Point ElementPropertyReadFile::_range
private
MooseEnum ElementPropertyReadFile::_read_type
protected

Type of read - element or grain.

Definition at line 83 of file ElementPropertyReadFile.h.

Referenced by ElementPropertyReadFile(), and getData().

MooseEnum ElementPropertyReadFile::_rve_type
protected

Type of grain structure - non-periodic default.

Definition at line 87 of file ElementPropertyReadFile.h.

Referenced by getGrainData().

Point ElementPropertyReadFile::_top_right
private

Definition at line 94 of file ElementPropertyReadFile.h.

Referenced by ElementPropertyReadFile().


The documentation for this class was generated from the following files: