femio.util package
Submodules
femio.util.brick_generator module
- femio.util.brick_generator.generate_brick(element_type, n_x_element, n_y_element, n_z_element=None, *, x_length=1.0, y_length=1.0, z_length=1.0)
Generate brick mesh.
- Parameters:
element_type (str) – Element type selected from [‘tri’, ‘quad’, ‘tet’, ‘hex’].
n_x_element (int) – The number of element in the X direction.
n_y_element (int) – The number of element in the Y direction.
n_z_element (int, optional) – The number of element in the Z direction.
x_length (float, optional) – The X length of the brick. The default is 1.
y_length (float, optional) – The Y length of the brick. The default is 1.
z_length (float, optional) – The Z length of the brick. The default is 1.
- Returns:
fem_data – FEMData object of the generated brick mesh.
- Return type:
femio.FEMData
femio.util.random_generator module
- femio.util.random_generator.generate_random_mesh(element_type, n_point, *, x_length=1.0, y_length=1.0, z_length=1.0, quality_threshold=None, noise_scale=1.0, strip_epsilon=None)
Generate random mesh.
- Parameters:
element_type (str) – Element type selected from [‘tri’, ‘quad’, ‘tet’, ‘hex’].
n_point (int) – The number of points.
x_length (float, optional) – The maximum X length of the mesh. The default is 1.
y_length (float, optional) – The maximum Y length of the mesh. The default is 1.
z_length (float, optional) – The maximum Z length of the mesh. The default is 1.
quality_threshold (float, optional) – If fed, compute quality of elements and remove some when the quality is bad.
noise_scale (float, optional) – The scale of the noise added to node positions. The default is 0.1.
strip_epsilon (float, optional) – If True, remove superfacial elements, which tend to have bad quality.
- Returns:
fem_data – FEMData object of the generated brick mesh.
- Return type:
femio.FEMData
femio.util.string_parser module
- class femio.util.string_parser.HeaderData(headers, list_indices, data)
Bases:
object
- extract_data(key, *, concatenate=True)
- extract_headers(key)
- class femio.util.string_parser.ListStringSeries(list_string_series)
Bases:
object
- expand_include(pattern, base_name)
- strip()
- class femio.util.string_parser.StringSeries(*args, **kw)
Bases:
Series
- classmethod concat(list_data, axis=0)
- connect(other, delimiter=',')
Connect two StringSeries objects with specified delimiter. Lengths of two objects should be the same.
- Parameters:
other – Other StringSeries object to be connected.
delimiter – String to appear at the connection.
- Returns:
StringSeries object after connection.
- classmethod connect_all(list_data, delimiter=',', str_format=None)
- delimit(delimiter=',')
Delimit StringLines object with the specified delimiter to output rank-2 ndarray of strings.
- Parameters:
delimiter – String of delimiter (default: ‘,’).
- Returns:
rank-2 ndarray of string.
- expand_include(pattern, base_name)
Expand data like ‘include’ statement. Expanded data is concatenated at the end of the non-expanded data.
- Parameters:
pattern – Pattern showing include statement. Include file should be captured with the first expression.
base_name – Directory name of the include file location.
- Returns:
StringSeries object after expansion.
- extract_captures(pattern, *, convert_values=False)
- find_match(pattern, *, allow_multiple_matches=True, convert_values=False, negative_match=False)
Find match to the specified pattern.
- Parameters:
pattern – Pattern to be used for matching.
allow_multiple_matches – True to accept several matches. (Default = True)
convert_values – Bool, [True] Flag to convert StringSeries to values
- Returns:
StringSeries or ndarray of matches.
- indices_match_clusters(pattern, *, negative_match=False)
Make cluster of indices of matches. Cluster means a group with continuous indices.
- Parameters:
pattern – Pattern to be used for matching.
- Returns:
list of ndarrays containing indices of each cluster.
- indices_matches(pattern, *, negative_match=False)
Return indices of matched lines.
- Parameters:
pattern – Pattern to be used for matching.
- Returns:
Ndarray of ints indicating indices of matched lines.
- classmethod read_array(_array, *, delimiter=',', str_format=None)
Read array to make StringSeries object.
- Parameters:
array – Ndarray or list of NDarray to make StringSeries object.
delimiter – String indicating delimiter to connect components in a raw (default: ‘,’).
str_format – Format string to be passed to numpy.savetxt.
Returns: StringSeries object after reading arrays.
- classmethod read_file(file_name, *, pattern_ignore=None)
Read file and convert to numpy string array.
- Parameters:
file_name – String of file name.
pattern_ignore – String to be used for ignore unecessary line e.g. comment.
- Returns:
StringDataFrame object. Each component corresponds to each line of the input file.
- classmethod read_files(file_names, *, pattern_ignore=None, separate=False)
Read files.
- Parameters:
file_names – Array of strings indicating file names.
pattern_ignore – String to be used for ignore unecessary line e.g. comment.
separate – bool If True, return separated contents, namely, ListStringSeries object.
- Returns:
StringDataFrame object. Each component corresponds to each line of input files (contents are concatenated).
- split_vertical(index_cut, delimiter=',')
Split StringSeries object vertically.
- Parameters:
index_cut – Index (= start index of 2nd obj) to cut the StringLines.
- Returns:
2-tuple of DataFrame objects after splitting.
- split_vertical_all(delimiter=',')
Split StringSeries object vertically. Output will be n StringSeries objects.
Args: :returns: n-tuple of StringSeries objexts after splitting.
- strip()
- to_dict_fem_attributes(names, component_nums, data_units=None, delimiter=',')
Generate dict of FEMAttribute objects with parsing the lines.
- Parameters:
names – List of strings indicating names of the attributes.
component_nums – List of ints indicating # of components of each attributes.
data_units – List of strings indicating unit of data. (default: ‘unit_unknown’)
- Returns:
Dict with key = name, value = fem.FEMAttribute.
- to_fem_attribute(name, id_column, slice_data_columns, *, data_type=<class 'float'>, delimiter=', ', data_unit='unit_unknown', generate_id2index=False)
Generate FEMAttribute object with parsing the series.
- Parameters:
name – String indicating name of the attribute.
lines – Ndarray of strings contains data.
id_column – Int indicating the column of ids.
slice_data_columns – Slice object indicating the columns of data.
data_type – Type of the data (default: float)
delimiter – String of delimiter. (default: ‘,’)
data_unit – String indicating unit of data. (default: ‘unit_unknown’)
generate_id2index – bool If True, generate pandas.DataFrame of IDs and indices.
- Returns:
femio.FEMAttribute object.
- to_header_data(pattern)
- to_values(delimiter=', ', data_type=<class 'float'>, to_rank1=False, until_column=None)
Delimit StringLines object with the specified delimiter to output ndarray of the specified data_type.
- Parameters:
delimiter – String of delimiter (default: ‘,’).
data_type – Type of output data (default: float).
to_rank1 – Boolean to control output (True: rank-1, False: rank-2, default: False)
until_column – int, optional, [None] Read until the specified column.
- Returns:
Ndarray of the specified data_type.