Skip to content

Commit

Permalink
Revert "fixes for initialisation"
Browse files Browse the repository at this point in the history
This reverts commit 282cb31.
  • Loading branch information
kccwing committed Apr 8, 2024
1 parent 282cb31 commit 017583b
Show file tree
Hide file tree
Showing 10 changed files with 298 additions and 1,572 deletions.
48 changes: 9 additions & 39 deletions sharpy/solvers/aerogridloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import sharpy.utils.settings as settings_utils
import sharpy.utils.h5utils as h5utils
import sharpy.utils.generator_interface as gen_interface
from sharpy.solvers.gridloader import GridLoader


@solver
class AerogridLoader(BaseSolver):
class AerogridLoader(GridLoader):
"""
``AerogridLoader`` class, inherited from ``BaseSolver``
``AerogridLoader`` class, inherited from ``GridLoader``
Generates aerodynamic grid based on the input data
Expand All @@ -36,9 +37,9 @@ class AerogridLoader(BaseSolver):
settings_types (dict): Acceptable types for the values in ``settings``
settings_default (dict): Name-value pair of default values for the aerodynamic settings
data (ProblemData): class structure
aero_file_name (str): name of the ``.aero.h5`` HDF5 file
file_name (str): name of the ``.aero.h5`` HDF5 file
aero: empty attribute
aero_data_dict (dict): key-value pairs of aerodynamic data
data_dict (dict): key-value pairs of aerodynamic data
wake_shape_generator (class): Wake shape generator
"""
Expand Down Expand Up @@ -89,28 +90,13 @@ class AerogridLoader(BaseSolver):
settings_options=settings_options)

def __init__(self):
self.data = None
self.settings = None
self.aero_file_name = ''
# storage of file contents
self.aero_data_dict = dict()

# aero storage
super().__init__
self.file_name = '.aero.h5'
self.aero = None

self.wake_shape_generator = None

def initialise(self, data, restart=False):
self.data = data
self.settings = data.settings[self.solver_id]

# init settings
settings_utils.to_custom_types(self.settings,
self.settings_types,
self.settings_default, options=self.settings_options)

# read input file (aero)
self.read_files()
super().initialise(data)

wake_shape_generator_type = gen_interface.generator_from_string(
self.settings['wake_shape_generator'])
Expand All @@ -119,25 +105,9 @@ def initialise(self, data, restart=False):
self.settings['wake_shape_generator_input'],
restart=restart)

def read_files(self):
# open aero file
# first, file names
self.aero_file_name = (self.data.case_route +
'/' +
self.data.case_name +
'.aero.h5')

# then check that the file exists
h5utils.check_file_exists(self.aero_file_name)

# read and store the hdf5 file
with h5.File(self.aero_file_name, 'r') as aero_file_handle:
# store files in dictionary
self.aero_data_dict = h5utils.load_h5_in_dict(aero_file_handle)

def run(self, **kwargs):
self.data.aero = aerogrid.Aerogrid()
self.data.aero.generate(self.aero_data_dict,
self.data.aero.generate(self.data_dict,
self.data.structure,
self.settings,
self.data.ts)
Expand Down
391 changes: 64 additions & 327 deletions sharpy/solvers/dynamiccoupled.py

Large diffs are not rendered by default.

732 changes: 0 additions & 732 deletions sharpy/solvers/dynamictrim.py

This file was deleted.

2 changes: 1 addition & 1 deletion sharpy/solvers/noaero.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def update_grid(self, beam):
-1,
beam_ts=-1)

def update_custom_grid(self, structure_tstep, aero_tstep):
def update_custom_grid(self, structure_tstep, aero_tstep, nl_body_tstep = None):
# called by DynamicCoupled
if self.settings['update_grid']:
self.data.aero.generate_zeta_timestep_info(structure_tstep,
Expand Down
3 changes: 1 addition & 2 deletions sharpy/solvers/nonlineardynamiccoupledstep.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ def initialise(self, data, custom_settings=None, restart=False):
def run(self, **kwargs):

structural_step = settings_utils.set_value_or_default(kwargs, 'structural_step', self.data.structure.timestep_info[-1])
# TODO: previous_structural_step never used
previous_structural_step = settings_utils.set_value_or_default(kwargs, 'previous_structural_step', self.data.structure.timestep_info[-1])

dt= settings_utils.set_value_or_default(kwargs, 'dt', self.settings['dt'])

xbeamlib.xbeam_step_couplednlndyn(self.data.structure,
Expand Down
430 changes: 32 additions & 398 deletions sharpy/solvers/nonlineardynamicmultibody.py

Large diffs are not rendered by default.

50 changes: 35 additions & 15 deletions sharpy/solvers/staticcoupled.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class StaticCoupled(BaseSolver):
settings_description['runtime_generators'] = 'The dictionary keys are the runtime generators to be used. ' \
'The dictionary values are dictionaries with the settings ' \
'needed by each generator.'

settings_types['nonlifting_body_interactions'] = 'bool'
settings_default['nonlifting_body_interactions'] = False
settings_description['nonlifting_body_interactions'] = 'Consider forces induced by nonlifting bodies'

settings_table = settings_utils.SettingsTable()
__doc__ += settings_table.generate(settings_types, settings_default, settings_description, settings_options)
Expand Down Expand Up @@ -149,17 +153,20 @@ def increase_ts(self):

def cleanup_timestep_info(self):
if max(len(self.data.aero.timestep_info), len(self.data.structure.timestep_info)) > 1:
# copy last info to first
self.data.aero.timestep_info[0] = self.data.aero.timestep_info[-1].copy()
self.data.structure.timestep_info[0] = self.data.structure.timestep_info[-1].copy()
# delete all the rest
while len(self.data.aero.timestep_info) - 1:
del self.data.aero.timestep_info[-1]
while len(self.data.structure.timestep_info) - 1:
del self.data.structure.timestep_info[-1]
self.remove_old_timestep_info(self.data.structure.timestep_info)
self.remove_old_timestep_info(self.data.aero.timestep_info)
if self.settings['nonlifting_body_interactions']:
self.remove_old_timestep_info(self.data.nonlifting_body.timestep_info)

self.data.ts = 0

def remove_old_timestep_info(self, tstep_info):
# copy last info to first
tstep_info[0] = tstep_info[-1].copy()
# delete all the rest
while len(tstep_info) - 1:
del tstep_info[-1]

def run(self, **kwargs):
for i_step in range(self.settings['n_load_steps'] + 1):
if (i_step == self.settings['n_load_steps'] and
Expand Down Expand Up @@ -189,14 +196,29 @@ def run(self, **kwargs):
self.data.structure.node_master_elem,
self.data.structure.connectivities,
self.data.structure.timestep_info[self.data.ts].cag(),
self.data.aero.aero_dict)

self.data.aero.data_dict)
if self.correct_forces:
struct_forces = \
self.correct_forces_generator.generate(aero_kstep=self.data.aero.timestep_info[self.data.ts],
structural_kstep=self.data.structure.timestep_info[self.data.ts],
struct_forces=struct_forces,
ts=0)

# map nonlifting forces to structural nodes
if self.settings['nonlifting_body_interactions']:
struct_forces += mapping.aero2struct_force_mapping(
self.data.nonlifting_body.timestep_info[self.data.ts].forces,
self.data.nonlifting_body.struct2aero_mapping,
self.data.nonlifting_body.timestep_info[self.data.ts].zeta,
self.data.structure.timestep_info[self.data.ts].pos,
self.data.structure.timestep_info[self.data.ts].psi,
self.data.structure.node_master_elem,
self.data.structure.connectivities,
self.data.structure.timestep_info[self.data.ts].cag(),
self.data.nonlifting_body.data_dict,
skip_moments_generated_by_forces = True)

self.data.aero.timestep_info[self.data.ts].aero_steady_forces_beam_dof = struct_forces
self.data.structure.timestep_info[self.data.ts].postproc_node['aero_steady_forces'] = struct_forces # B

Expand Down Expand Up @@ -239,6 +261,7 @@ def run(self, **kwargs):
# update grid
self.aero_solver.update_step()

self.structural_solver.update(self.data.structure.timestep_info[self.data.ts])
# convergence
if self.convergence(i_iter, i_step):
# create q and dqdt vectors
Expand Down Expand Up @@ -322,10 +345,7 @@ def change_trim(self, alpha, thrust, thrust_nodes, tail_deflection, tail_cs_inde
for i_node, node in enumerate(thrust_nodes):
self.force_orientation[i_node, :] = (
algebra.unit_vector(self.data.structure.ini_info.steady_applied_forces[node, 0:3]))
print(self.force_orientation)
#TODO: HARDCODE
self.force_orientation = np.array([[0., 1., 0.],[0., -1., 0.]])
print(self.force_orientation)
# print(self.force_orientation)

# thrust
# thrust is scaled so that the direction of the forces is conserved
Expand All @@ -345,7 +365,7 @@ def change_trim(self, alpha, thrust, thrust_nodes, tail_deflection, tail_cs_inde

# tail deflection
try:
self.data.aero.aero_dict['control_surface_deflection'][tail_cs_index] = tail_deflection
self.data.aero.data_dict['control_surface_deflection'][tail_cs_index] = tail_deflection
except KeyError:
raise Exception('This model has no control surfaces')
except IndexError:
Expand Down
Loading

0 comments on commit 017583b

Please sign in to comment.