From 8aab71a8559b1dd27cec5232cf97cbe0aa39b607 Mon Sep 17 00:00:00 2001 From: Knut Morten Okstad Date: Mon, 25 Mar 2024 08:27:15 +0100 Subject: [PATCH] Add time_text argument in start_step() method. Remove ndat, ndef and nstr arguments in save_*_state() methods. --- PythonAPI/PythonAPITests/test_api.py | 24 ++++++++++++-------- PythonAPI/src/fedempy/solver.py | 34 +++++++++++++++------------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/PythonAPI/PythonAPITests/test_api.py b/PythonAPI/PythonAPITests/test_api.py index e55b5493..3c1f580e 100644 --- a/PythonAPI/PythonAPITests/test_api.py +++ b/PythonAPI/PythonAPITests/test_api.py @@ -20,7 +20,7 @@ + def solver_init(self, options, fsi=None, state_data=None, gauge_data=None): - def restart_from_state(self, state_data, write_to_rdb=2): - - def solve_window(self, n_step, inputs=None, f_out=None): + - def solve_window(self, n_step, inputs=None, f_out=None, xtimes=None): - def get_state_size(self): - def get_gauge_size(self): def get_transformation_state_size(self): @@ -28,22 +28,24 @@ def get_part_deformation_state_size(self, base_id): def get_part_stress_state_size(self, base_id): - def save_state(self): - def save_gauges(self): - def save_transformation_state(self, state_data, ndat): - def save_part_deformation_state(self, base_id, state_data, ndat): - def save_part_stress_state(self, base_id, state_data, ndat): - + def solve_next(self): - + def start_step(self): + def save_transformation_state(self, state_data): + def save_part_state(self, base_id, def_state, str_state): + + def solve_next(self, inp=None, inp_def=None, out_def=None, time_next=None): + + def start_step(self, time_next=None): + def solve_iteration(self): + def finish_step(self): - + def solve_modes(self, n_modes, dof_order=False): - + def solve_inverse(self, x, x_def, g_def, out_def=None): - + def solver_done(self): + + def solve_modes(self, n_modes, dof_order=False, use_lapack=0): + + def solve_inverse(self, x_val, x_def, g_def, out_def=None): + + def solver_done(self, remove_singletons=None): - def solver_close(self): + def run_all(self, options): - def set_ext_func(self, func_id, value=None): + def get_current_time(self): + def get_next_time(self): + def check_times(self, xtimes, use_times=True): + def get_function(self, uid=0, tag=None, arg=None): - - get_functions(self, uids): + - def get_functions(self, uids): + def get_function_ids(self, tags): + def get_equations(self, bid): + def get_system_size(self): + def get_system_dofs(self): @@ -59,7 +61,9 @@ def save_part_stress_state(self, base_id, state_data, ndat): def compute_strains_from_displ(self, disp, gauge_ids): def get_current_strains(self, gauge_ids): def compute_rel_dist_from_displ(self, disp, ids): + def compute_spring_var_from_displ(self, disp, ids): def compute_int_forces_from_displ(self, disp, ids): + def get_joint_spring_stiffness(self, bid): """ from os import environ diff --git a/PythonAPI/src/fedempy/solver.py b/PythonAPI/src/fedempy/solver.py index 9968e338..323a6d99 100644 --- a/PythonAPI/src/fedempy/solver.py +++ b/PythonAPI/src/fedempy/solver.py @@ -565,7 +565,7 @@ def save_gauges(self): """ return self._solver.saveGages(self.gauge_data, self.gauge_size) - def save_transformation_state(self, state_data, ndat=None): + def save_transformation_state(self, state_data): """ This method stores current transformation state for Triads, Parts and Beams in the provided core array. @@ -592,19 +592,16 @@ def save_transformation_state(self, state_data, ndat=None): ---------- state_data : list of c_double Array to fill with transformation data - ndat : int, default=None - Length of the state_data array, set to len(state_data) if None Returns ------- bool Always True, unless the state_data array is too small """ - if ndat is None: - ndat = c_int(len(state_data)) + ndat = c_int(len(state_data)) return self._solver.saveTransformationState(state_data, ndat) - def save_part_state(self, base_id, def_state, str_state, ndef=None, nstr=None): + def save_part_state(self, base_id, def_state, str_state): """ This method stores current deformation- and stress states for the specified FE Part in the provided core arrays. @@ -617,10 +614,6 @@ def save_part_state(self, base_id, def_state, str_state, ndef=None, nstr=None): Array to fill with deformation data str_state : list of c_couble Array to fill with stress data - ndef : int, default=None - Length of the def_state array, set to len(def_state) if none - nstr : int, default=None - Length of the str_state array, set to len(str_state) if none Returns ------- @@ -628,12 +621,11 @@ def save_part_state(self, base_id, def_state, str_state, ndef=None, nstr=None): Always True, unless one or both of the state arrays are too small """ bid_ = self._convert_c_int(base_id) - if ndef is None: - ndef = c_int(len(def_state)) + ndef = c_int(len(def_state)) if not self._solver.savePartDeformationState(bid_, def_state, ndef): return False - if nstr is None: - nstr = c_int(len(str_state)) + + nstr = c_int(len(str_state)) return self._solver.savePartStressState(bid_, str_state, nstr) def solve_next(self, inp=None, inp_def=None, out_def=None, time_next=None): @@ -682,7 +674,7 @@ def solve_next(self, inp=None, inp_def=None, out_def=None, time_next=None): return self.get_functions(out_def), success - def start_step(self): + def start_step(self, time_next=None): """ This method starts a new time (or load) step, by calculating the predicted response, the coefficient matrix and right-hand-side vector @@ -693,6 +685,11 @@ def start_step(self): A non-zero value indicates some error that requires the simulation to terminate. + Parameters + ---------- + time_next : float, default=None + Time of next step, to override time step size defined in the model + Returns ------- bool @@ -700,7 +697,12 @@ def start_step(self): or the end time of the simulation has been reached """ self.__check_error("start_step") - return self._solver.startStep(byref(self.ierr)) + if time_next is None: + success = True + else: + success = self._solver.setTime(self._convert_c_double(time_next)) + + return self._solver.startStep(byref(self.ierr)) if success else False def solve_iteration(self): """