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 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, 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 columns of the CSV data must define the coordinates of each point forming the interpolation grid. The number of columns used to define these coordinates must match the dimension of the mesh.

commentnote

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.

Example Input Syntax

In this example, we display three options for using CSV data to compute a function over an unstructured mesh:

  • the element function, using the reader_element user object, assumes the CSV file is sorted by element ID, and returns the value of the element containing each point

  • the nearest function, using the reader_nearest user object, finds the closest point defined in the CSV file, and returns the corresponding value

  • the block function, using the reader_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'
    column_number = '2'
  []
  [node]
    type = PiecewiseConstantFromCSV
    read_prop_user_object = 'reader_node'
    read_type = 'node'
    column_number = '2'
  []
  [nearest]
    type = PiecewiseConstantFromCSV
    read_prop_user_object = 'reader_nearest'
    read_type = 'voronoi'
    column_number = '2'
  []
  [block]
    type = PiecewiseConstantFromCSV
    read_prop_user_object = 'reader_block'
    read_type = 'block'
    column_number = '2'
  []
[]

[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 = 3
    nvoronoi = 3
  []
  [reader_block]
    type = PropertyReadFile
    prop_file_name = 'data_nearest.csv'
    read_type = 'block'
    nprop = 3
    nblock = 3
  []
[]
(../../../SoftwareDownloads/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.

Input Parameters

  • column_numberThe column number (0-indexing) for the desired data in the CSV

    C++ Type:unsigned int

    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

    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

    Options:element, voronoi, block, node

    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

Required Parameters

  • execute_onLINEARThe list of flag(s) indicating when this object should be executed, the available options include NONE, INITIAL, LINEAR, NONLINEAR, TIMESTEP_END, TIMESTEP_BEGIN, FINAL, CUSTOM, ALWAYS.

    Default:LINEAR

    C++ Type:ExecFlagEnum

    Options:NONE, INITIAL, LINEAR, NONLINEAR, TIMESTEP_END, TIMESTEP_BEGIN, FINAL, CUSTOM, ALWAYS

    Controllable:No

    Description:The list of flag(s) indicating when this object should be executed, the available options include NONE, INITIAL, LINEAR, NONLINEAR, TIMESTEP_END, TIMESTEP_BEGIN, FINAL, CUSTOM, ALWAYS.

  • ghost_layers1

    Default:1

    C++ Type:unsigned short

    Controllable:No

Optional Parameters

  • control_tagsAdds user-defined labels for accessing object parameters via control logic.

    C++ Type:std::vector<std::string>

    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

    Controllable:No

    Description:Set the enabled status of the MooseObject.

Advanced Parameters