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

Constructor & Destructor Documentation

◆ ElementPropertyReadFile()

ElementPropertyReadFile::ElementPropertyReadFile ( const InputParameters &  parameters)

Definition at line 40 of file ElementPropertyReadFile.C.

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

◆ ~ElementPropertyReadFile()

virtual ElementPropertyReadFile::~ElementPropertyReadFile ( )
inlinevirtual

Definition at line 32 of file ElementPropertyReadFile.h.

32 {}

Member Function Documentation

◆ execute()

virtual void ElementPropertyReadFile::execute ( )
inlinevirtual

Definition at line 35 of file ElementPropertyReadFile.h.

35 {}

◆ finalize()

virtual void ElementPropertyReadFile::finalize ( )
inlinevirtual

Definition at line 36 of file ElementPropertyReadFile.h.

36 {}

◆ getData()

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

This function assign property data to elements.

Definition at line 127 of file ElementPropertyReadFile.C.

Referenced by ComputeElasticityTensorCP::assignEulerAngles().

128 {
129  switch (_read_type)
130  {
131  case 0:
132  return getElementData(elem, prop_num);
133 
134  case 1:
135  return getGrainData(elem, prop_num);
136  }
137  mooseError("Error ElementPropertyReadFile: Provide valid read type");
138 }
MooseEnum _read_type
Type of read - element or grain.
Real getElementData(const Elem *, unsigned int) const
This function assign properties to element read from file with element based properties.
Real getGrainData(const Elem *, unsigned int) const
This function assign properties to element read from file with grain based properties Grain distribut...

◆ 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 141 of file ElementPropertyReadFile.C.

Referenced by getData().

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

◆ 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 158 of file ElementPropertyReadFile.C.

Referenced by getData().

159 {
160  mooseAssert(prop_num < _nprop,
161  "Error ElementPropertyReadFile: Property number "
162  << prop_num
163  << " greater than than total number of properties "
164  << _nprop
165  << "\n");
166 
167  Point centroid = elem->centroid();
168  Real min_dist = _max_range;
169  unsigned int igrain = 0;
170 
171  for (unsigned int i = 0; i < _ngrain; ++i)
172  {
173  Real dist = 0.0;
174  switch (_rve_type)
175  {
176  case 0:
177  // Calculates minimum periodic distance when "periodic" is specified
178  // for rve_type
179  dist = minPeriodicDistance(_center[i], centroid);
180  break;
181 
182  default:
183  // Calculates minimum distance when nothing is specified
184  // for rve_type
185  Point dist_vec = _center[i] - centroid;
186  dist = dist_vec.norm();
187  }
188 
189  if (dist < min_dist)
190  {
191  min_dist = dist;
192  igrain = i;
193  }
194  }
195 
196  return _data[igrain * _nprop + prop_num];
197 }
unsigned int _nprop
Number of properties in a row.
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.
Real minPeriodicDistance(Point, Point) const
This function calculates minimum distance between 2 points considering periodicity of the simulation ...

◆ initGrainCenterPoints()

void ElementPropertyReadFile::initGrainCenterPoints ( )
virtual

This function generates grain center point Presently random generated.

Definition at line 117 of file ElementPropertyReadFile.C.

Referenced by readGrainData().

118 {
119  _center.resize(_ngrain);
120  MooseRandom::seed(_rand_seed);
121  for (unsigned int i = 0; i < _ngrain; i++)
122  for (unsigned int j = 0; j < LIBMESH_DIM; j++)
123  _center[i](j) = _bottom_left(j) + MooseRandom::rand() * _range(j);
124 }
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.

◆ initialize()

virtual void ElementPropertyReadFile::initialize ( )
inlinevirtual

Definition at line 34 of file ElementPropertyReadFile.h.

34 {}

◆ 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 201 of file ElementPropertyReadFile.C.

Referenced by getGrainData().

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

◆ readElementData()

void ElementPropertyReadFile::readElementData ( )

This function reads element data from file.

Definition at line 80 of file ElementPropertyReadFile.C.

Referenced by ElementPropertyReadFile().

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

◆ readGrainData()

void ElementPropertyReadFile::readGrainData ( )
virtual

This function Read grain data from file.

Definition at line 98 of file ElementPropertyReadFile.C.

Referenced by ElementPropertyReadFile().

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

◆ _bottom_left

Point ElementPropertyReadFile::_bottom_left
private

Definition at line 98 of file ElementPropertyReadFile.h.

Referenced by ElementPropertyReadFile(), and initGrainCenterPoints().

◆ _center

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

Definition at line 93 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 80 of file ElementPropertyReadFile.h.

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

◆ _max_range

Real ElementPropertyReadFile::_max_range
private

Definition at line 100 of file ElementPropertyReadFile.h.

Referenced by ElementPropertyReadFile(), and getGrainData().

◆ _mesh

MooseMesh& ElementPropertyReadFile::_mesh
protected

Definition at line 92 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 84 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 82 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 78 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 88 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 86 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 90 of file ElementPropertyReadFile.h.

Referenced by getGrainData().

◆ _top_right

Point ElementPropertyReadFile::_top_right
private

Definition at line 97 of file ElementPropertyReadFile.h.

Referenced by ElementPropertyReadFile().


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