Skip to content

Commit

Permalink
Merge to one Function
Browse files Browse the repository at this point in the history
  • Loading branch information
knarfnitram committed Nov 15, 2024
1 parent 6aa525d commit cdcca29
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
20 changes: 14 additions & 6 deletions meshpy/four_c/dbc_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def dbc_monitor_to_input(input_file, file_path, step=-1, function=1, n_dof=3):
def all_dbc_monitor_values_to_input(
input_file,
file_path,
steps=[0, -1],
steps=None,
n_dof=3,
time_span=[0, 1, 2],
type=None,
Expand Down Expand Up @@ -173,14 +173,22 @@ def all_dbc_monitor_values_to_input(
flip_forces: bool
indicates, if the extracted forces should be flipped or rearanged wrt. to the time
For flip_forces=true, the forces at the final time are applied at t_start.
fun_array: [Function, Function, Function]
array consisting of 3 custom functions(x,y,z). The value for boundary condition is selected from the last steps.
"""

nodes, time, force, _ = read_dbc_monitor_file(file_path)

# The forces are the negative reactions at the Dirichlet boundaries.
force *= -1.0
time = time[steps[0] : steps[1]]
force = force[steps[0] : steps[1], :]

# if special index range is provided use it
if steps:
time = time[steps[0] : steps[1] + 1]
force = force[steps[0] : steps[1] + 1, :]
else:
# otherwise define steps from start to end
steps = [0, -1]

# apply transformations to time and forces according to the schema
if type is None:
Expand Down Expand Up @@ -255,12 +263,12 @@ def all_dbc_monitor_values_to_input(
# fun_array.append(str(len(input_file.functions)))
fun_array.append(fun)

# now set forces to 1 since the force values are already extracted in the function's values
force = 0 * force + 1

elif len(fun_array) != 3:
raise ValueError("Please provide fun_array with ")

# now set forces to 1 since the force values are extracted already in the function
force = 0 * force + 1

# Create the BC condition for this set and add it to the input file.
mesh_nodes = [input_file.nodes[i_node] for i_node in nodes]
geo = GeometrySet(mesh_nodes)
Expand Down
3 changes: 1 addition & 2 deletions meshpy/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,7 @@ def get_env_variable(name, *, default="default_not_set"):
def linear_time_transformation(
time, values, time_span, flip, valid_start_and_end_point=False
):
"""
performs a transformation of the time to a new intervall with an appropriate value vector
"""Performs a transformation of the time to a new intervall with an appropriate value vector
Args
----
Expand Down
1 change: 0 additions & 1 deletion tests/testing_four_c_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,6 @@ def test_four_c_simulation_dirichlet_boundary_to_neumann_boundary(self):
),
n_dof=9,
time_span=[10 * 0.5, 21 * 0.5],
steps=[10, 10],
fun_array=[function_nbc, function_nbc, function_nbc],
)
restart_simulation.add(
Expand Down
7 changes: 2 additions & 5 deletions tests/testing_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ def test_is_node_on_plane(self):
)

def test_linear_time_transformation_scaling(self):
"""
Test the scaling of the intervall the function
"""Test the scaling of the intervall the function
it starts with a function in the intervall between [0,1] and transforms them
"""

Expand Down Expand Up @@ -123,9 +122,7 @@ def test_linear_time_transformation_scaling(self):
self.assertEqual(force_trans.tolist(), force_result.tolist())

def test_linear_time_transformation_flip(self):
"""
Test the flip flag option of linear_time_transformationto mirror the function
"""
"""Test the flip flag option of linear_time_transformationto mirror the function"""

# base case no scaling no end points should be attached
# starting time array
Expand Down

0 comments on commit cdcca29

Please sign in to comment.