Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #12 from SAP/start-step
Browse files Browse the repository at this point in the history
Add time_text argument in start_step() method
  • Loading branch information
kmoks authored Apr 30, 2024
2 parents 9322416 + 8aab71a commit d698acf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
24 changes: 14 additions & 10 deletions PythonAPI/PythonAPITests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,32 @@
+ 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):
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):
Expand All @@ -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
Expand Down
34 changes: 18 additions & 16 deletions PythonAPI/src/fedempy/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -617,23 +614,18 @@ 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
-------
bool
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):
Expand Down Expand Up @@ -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
Expand All @@ -693,14 +685,24 @@ 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
Always True, unless the simulation has to stop due to some error,
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):
"""
Expand Down

0 comments on commit d698acf

Please sign in to comment.