- column_numberThe column number (0-indexing) for the desired data in the CSV
C++ Type:unsigned int
Unit:(no unit assumed)
Controllable:No
Description:The column number (0-indexing) for the desired data in the CSV
- read_prop_user_objectThe PropertyReadFile GeneralUserObject to read element specific property values from file
C++ Type:UserObjectName
Unit:(no unit assumed)
Controllable:No
Description:The PropertyReadFile GeneralUserObject to read element specific property values from file
- read_typeOrganization of data in the CSV file: element:by element node: by node voronoi:nearest neighbor / voronoi tesselation structure block:by mesh block
C++ Type:MooseEnum
Unit:(no unit assumed)
Controllable:No
Description:Organization of data in the CSV file: element:by element node: by node voronoi:nearest neighbor / voronoi tesselation structure block:by mesh block
PiecewiseConstantFromCSV
Uses data read from CSV to assign values
Description
The PiecewiseConstantFromCSV
function is used to load data from a CSV file into a function. The PropertyReadFile user object takes care of reading the CSV file, and the function queries information from it.
It can assume CSV data
is sorted by element-id, in which case, when the function is evaluated at a point, it will locate the element containing it then return the value for that element in the CSV file
is sorted by node-id, in which case, when the function is evaluated at a point, it will locate the node at that point then return the value for that node in the CSV file
is sorted by blocks, in which case, when the function is evaluated at a point, it will locate the element containing it then return the value for that element's block in the CSV file
defines an interpolation grid, with the voronoi "read_type", in which case the function will locate the closest point in that interpolation grid, then return the value for that point in the CSV file
For the latter case, the first three columns of the CSV data must define the coordinates of each point forming the interpolation grid. The "column_number" parameter should still match the actual column number in the CSV file, so it likely should be larger than 3 (the number of columns for voronoi centers coordinates).
When use data by block or by element, if there is multiple possibilities for the element to choose from, for example at a node, the element with the lowest ID will be used.
The "column_number" parameter assumes 0-based indexing of the columns in the CSV file. If you want the values from the leftmost column in the file, you must use a column number of 0
.
Example Input Syntax
In this example, we display four options for using CSV data to compute a function over an unstructured mesh:
the
element
Function, using thereader_element
user object, assumes the CSV file is sorted by element ID, and returns the value of the element containing each pointthe
node
Function, using thereader_node
user object, assumes the CSV file is sorted by node ID, and returns the corresponding value at those nodes. Outside of these nodes, the function is currently set to error.the
nearest
Function, using thereader_nearest
user object, finds the closest point defined in the CSV file, and returns the corresponding valuethe
block
Function, using thereader_block
user object, assumes the data in the CSV file is sorted by block, and returns the value corresponding to the block containing each point
[Functions]
[element]
type = PiecewiseConstantFromCSV
read_prop_user_object = 'reader_element'
read_type = 'element'
# 0-based indexing
column_number = '2'
[]
[node]
type = PiecewiseConstantFromCSV
read_prop_user_object = 'reader_node'
read_type = 'node'
# 0-based indexing
column_number = '2'
[]
[nearest]
type = PiecewiseConstantFromCSV
read_prop_user_object = 'reader_nearest'
read_type = 'voronoi'
# 0-based indexing
column_number = '3'
[]
[block]
type = PiecewiseConstantFromCSV
read_prop_user_object = 'reader_block'
read_type = 'block'
# 0-based indexing
column_number = '3'
[]
[]
[UserObjects]
[reader_element]
type = PropertyReadFile
prop_file_name = 'data_element.csv'
read_type = 'element'
nprop = 3 # number of columns in CSV
[]
[reader_node]
type = PropertyReadFile
prop_file_name = 'data_node.csv'
read_type = 'node'
nprop = 3 # number of columns in CSV
[]
[reader_nearest]
type = PropertyReadFile
prop_file_name = 'data_nearest.csv'
read_type = 'voronoi'
nprop = 4 # number of columns in CSV
nvoronoi = 3 # number of rows that are considered
[]
[reader_block]
type = PropertyReadFile
prop_file_name = 'data_nearest.csv'
read_type = 'block'
nprop = 4 # number of columns in CSV
nblock = 3 # number of rows that are considered
[]
[]
(moose/test/tests/functions/piecewise_constant_from_csv/piecewise_constant.i)Other functions which may read data from CSV
These functions read spatial data from CSV, e.g. data that is sorted by location not node, element or block.
PiecewiseConstant (1D or time dependence)
PiecewiseLinear and CoarsenedPiecewiseLinear (1D or time dependence)
PiecewiseBilinear (2D)
PiecewiseMulticonstant (1D to 4D)
PiecewiseMultilinear (1D to 4D)
Input Parameters
- ghost_layers1
Default:1
C++ Type:unsigned short
Unit:(no unit assumed)
Controllable:No
Optional Parameters
- control_tagsAdds user-defined labels for accessing object parameters via control logic.
C++ Type:std::vector<std::string>
Unit:(no unit assumed)
Controllable:No
Description:Adds user-defined labels for accessing object parameters via control logic.
- enableTrueSet the enabled status of the MooseObject.
Default:True
C++ Type:bool
Unit:(no unit assumed)
Controllable:No
Description:Set the enabled status of the MooseObject.