https://mooseframework.inl.gov
PropertyReadFile.h
Go to the documentation of this file.
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 "GeneralUserObject.h"
13 #include "MooseEnum.h"
14 #include "DelimitedFileReader.h"
15 
28 {
29 public:
31 
33  virtual ~PropertyReadFile() {}
34 
36  std::vector<FileName> getFileNames();
37 
38  virtual void initialize();
39  virtual void execute() {}
40  virtual void finalize() {}
41 
45  void readData();
46 
51  virtual void initVoronoiCenterPoints();
52 
59  Real getData(const Elem * const elem, const unsigned int prop_num) const;
60 
67  Real getElementData(const Elem * const elem, const unsigned int prop_num) const;
68 
75  Real getNodeData(const Node * const node, const unsigned int prop_num) const;
76 
84  Real getVoronoiData(const Point & point, const unsigned int prop_num) const;
85 
92  Real getBlockData(const Elem * const elem, const unsigned int prop_num) const;
93 
99  Real minPeriodicDistance(const Point &, const Point &) const;
100 
104  enum class ReadTypeEnum
105  {
106  ELEMENT = 0,
107  VORONOI = 1,
108  BLOCK = 2,
109  NODE = 3,
110  GRAIN = 4
111  };
112 
116  ReadTypeEnum getReadType() const { return _read_type; }
117 
121  unsigned int getNumProperties() const { return _nprop; }
122 
123 protected:
125  std::vector<FileName> _prop_file_names;
127  unsigned int & _current_file_index;
130 
133 
138  const unsigned int _rand_seed;
143 
145  const unsigned int _ngrain;
146 
148  std::vector<Point> _center;
149 
150 private:
152  BoundingBox _bounding_box;
153 
156  const unsigned int _nprop;
158  const unsigned int _nvoronoi;
160  const unsigned int _nblock;
161 
164 
167 };
void readData()
This function reads the data from file.
BoundingBox _bounding_box
Bounding box for the mesh.
Real getVoronoiData(const Point &point, const unsigned int prop_num) const
This function retrieves properties for elements from a file with nearest neighbor / grain based prope...
bool & _initialize_called_once
To keep track of initialization to avoid reading the files twice.
Real getBlockData(const Elem *const elem, const unsigned int prop_num) const
This function retrieves properties for elements, from a file that has block-based data...
std::vector< FileName > _prop_file_names
Name of file containing property values.
std::vector< Point > _center
unsigned int & _current_file_index
Index of the file we last read.
const ReadTypeEnum _read_type
Type of read - element, grain, or block.
PropertyReadFile(const InputParameters &parameters)
virtual ~PropertyReadFile()
Read properties from file - grain, element, node or block Input file syntax: prop1 prop2 etc...
ReadTypeEnum getReadType() const
Returns the ordering of data expected in the CSV file.
const MooseEnum _rve_type
Type of voronoi tesselation/grain structure - non-periodic default.
MooseUtils::DelimitedFileReader _reader
Use DelimitedFileReader to read and store data from file.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Real getNodeData(const Node *const node, const unsigned int prop_num) const
This function retrieves properties for nodes, from a file that has node-based data.
static InputParameters validParams()
Real getData(const Elem *const elem, const unsigned int prop_num) const
This function retrieves property data for elements.
Real minPeriodicDistance(const Point &, const Point &) const
This function calculates minimum distance between 2 points considering periodicity of the simulation ...
const unsigned int _rand_seed
Random seed - used for generating grain centers.
const unsigned int _nvoronoi
Number of grains (for reading a CSV file with properties ordered by grains)
ReadTypeEnum
How data is organized in the CSV file.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
const bool _load_on_construction
Whether to read the first CSV file in the constructor or on the first initialization before execution...
const unsigned int _nblock
Number of blocks (for reading a CSV file with properties ordered by blocks)
virtual void finalize()
Finalize.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Utility class for reading delimited data (e.g., CSV data).
const bool _use_random_tesselation
Parameters for the nearest neighbor / grain interpolation Whether to use a random tesselation for the...
const InputParameters & parameters() const
Get the parameters of the object.
const unsigned int _nprop
Class attributes useful for range-checking Number of properties in a row.
virtual void initVoronoiCenterPoints()
This function generates voronoi tesselation center points Presently random generated.
bool _block_zero
Do the block numbers start with zero or one?
const unsigned int _ngrain
Legacy attribute to keep Grizzly functional, see idaholab/moose#19109, idaholab/Grizzly#182.
std::vector< FileName > getFileNames()
Retrieve the property file names from the parameters.
unsigned int getNumProperties() const
Returns the number of properties (columns) read in the file.
virtual void initialize()
Called before execute() is ever called so that data can be cleared.
virtual void execute()
Execute method.
Real getElementData(const Elem *const elem, const unsigned int prop_num) const
This function retrieves properties for elements, from a file that has element-based data...