https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
29public:
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
103 Real getBlockData(const SubdomainID subdomain_id, const unsigned int prop_num) const;
104
110 Real minPeriodicDistance(const Point &, const Point &) const;
111
115 enum class ReadTypeEnum
116 {
117 ELEMENT = 0,
118 VORONOI = 1,
119 BLOCK = 2,
120 NODE = 3,
121 GRAIN = 4
122 };
123
128
132 unsigned int getNumProperties() const { return _nprop; }
133
134protected:
136 std::vector<FileName> _prop_file_names;
138 unsigned int & _current_file_index;
141
144
149 const unsigned int _rand_seed;
154
156 const unsigned int _ngrain;
157
159 std::vector<Point> _center;
160
161private:
163 BoundingBox _bounding_box;
164
167 const unsigned int _nprop;
169 const unsigned int _nvoronoi;
171 const unsigned int _nblock;
172
175
178};
subdomain_id_type SubdomainID
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
Utility class for reading delimited data (e.g., CSV data).
Read properties from file - grain, element, node or block Input file syntax: prop1 prop2 etc.
Real getData(const Elem *const elem, const unsigned int prop_num) const
This function retrieves property data for elements.
unsigned int getNumProperties() const
Returns the number of properties (columns) read in the file.
ReadTypeEnum getReadType() const
Returns the ordering of data expected in the CSV file.
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.
virtual void execute()
Execute method.
virtual void finalize()
Finalize.
const unsigned int _rand_seed
Random seed - used for generating grain centers.
const bool _use_random_tesselation
Parameters for the nearest neighbor / grain interpolation Whether to use a random tesselation for the...
unsigned int & _current_file_index
Index of the file we last read.
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 _block_zero
Do the block numbers start with zero or one?
std::vector< FileName > _prop_file_names
Name of file containing property values.
virtual ~PropertyReadFile()
BoundingBox _bounding_box
Bounding box for the mesh.
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.
const unsigned int _ngrain
Legacy attribute to keep Grizzly functional, see idaholab/moose#19109, idaholab/Grizzly#182.
MooseUtils::DelimitedFileReader _reader
Use DelimitedFileReader to read and store data from file.
void readData()
This function reads the data from file.
virtual void initVoronoiCenterPoints()
This function generates voronoi tesselation center points Presently random generated.
virtual void initialize()
Called before execute() is ever called so that data can be cleared.
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.
const ReadTypeEnum _read_type
Type of read - element, grain, or block.
const unsigned int _nblock
Number of blocks (for reading a CSV file with properties ordered by blocks)
const MooseEnum _rve_type
Type of voronoi tesselation/grain structure - non-periodic default.
std::vector< Point > _center
const unsigned int _nvoronoi
Number of grains (for reading a CSV file with properties ordered by grains)
std::vector< FileName > getFileNames()
Retrieve the property file names from the parameters.
static InputParameters validParams()
Real minPeriodicDistance(const Point &, const Point &) const
This function calculates minimum distance between 2 points considering periodicity of the simulation ...
ReadTypeEnum
How data is organized in the CSV file.
const unsigned int _nprop
Class attributes useful for range-checking Number of properties in a row.
const bool _load_on_construction
Whether to read the first CSV file in the constructor or on the first initialization before execution...