Commit bd2f8150 authored by John Tourtellott's avatar John Tourtellott

Fix/update writer scripts

parent efcafac3
......@@ -362,7 +362,7 @@ namelist_sequence = [
namelist('CHAPARRAL', att_type='enclosure-radiation',
base_item_path='enable/chaparral',
if_condition=ENCLOSURE_RADIATION),
namelist('NUMERICS', att_type='solver'),
namelist('NUMERICS', att_type='numerics'),
namelist('LINEAR_SOLVER',
if_condition=FLOW_ANALYSIS,
att_type='solver',
......
......@@ -767,91 +767,53 @@ class Writer:
'''
CardFormat.ModelManager = self.model_resource
# Get mesh file from model manager
# mask = int(smtk.model.ModelEntityType)
# mask = int(smtk.model.EntityTypeBits.MODEL_ENTITY)
# model_ents = self.model_resource.entitiesMatchingFlags(mask, True)
# print('model_ents', model_ents)
# if not model_ents:
# msg = 'No model - export will be incomplete'
# print('WARNING:', msg)
# elif len(model_ents) > 1:
# msg = 'Multiple models - using first one'
# print('WARNING:', msg)
# model_ent = model_ents.pop()
# print('has smtk_url?', self.model_resource.hasStringProperty(model_ent, 'smtk_url'))
# urls = self.model_resource.stringProperty(model_ent, 'url')
# if urls:
# url = urls[0]
# print('url', url)
# # Get model fileanme
# model_file = os.path.basename(url)
# print('model_file', model_file)
# #self.output.write(' File: %s\n\n' % model_file)
# # Get full path to model
# model_path = model_file # default case, when testing w/smtk
# if os.path.isabs(url):
# model_path = url
# else:
# smtk_urls = self.model_resource.stringProperty(model_ent, 'smtk_url')
# print('smtk_urls', smtk_urls)
# if smtk_urls:
# smtk_url = smtk_urls[0]
# model_path = os.path.join(smtk_url, url)
# model_path = os.path.abspath(model_path)
# print('model_path', model_path)
# self.mesh_file = model_path
# Get analysis type and set CardFormat conditions
# Todo rewrite this code once analysis view is in place
# att_list = self.sim_atts.findAttributes('solver')
# att_list.sort(key=lambda att: att.name())
# if att_list:
# solver_att = att_list[0]
# analysis_item = solver_att.findString('analysis')
# analysis = analysis_item.value(0)
# print('analysis', analysis)
# viscous_item = None
# if 'fluid' == analysis:
# CardFormat.Conditions.add(FLOW_ANALYSIS)
# viscous_item = solver_att.itemAtPath(
# 'analysis/fluid/viscous-flow-model', '/')
# elif 'thermal' == analysis:
# CardFormat.Conditions.add(THERMAL_ANALYSIS)
# CardFormat.Conditions.add(ONLY_THERMAL_ANALYSIS)
# else:
# CardFormat.Conditions.add(FLOW_ANALYSIS)
# CardFormat.Conditions.add(THERMAL_ANALYSIS)
# viscous_item = solver_att.itemAtPath(
# 'analysis/fluid/viscous-flow-model', '/')
# if viscous_item is not None:
# if viscous_item.isEnabled:
# CardFormat.Conditions.add(VISCOUS_FLOW)
# else:
# CardFormat.Conditions.add(INVISCID_FLOW)
# #print('Initial Conditions', CardFormat.Conditions)
# Get analysis type(s) and set CardFormat conditions
analysis_att = self.sim_atts.findAttribute('analysis')
if not analysis_att:
raise RuntimeError('Internal Error -- missing analysis att')
# Only looking at Heat Transfer and Fluid Flow initially
er_item = None # enclosure radition
ff_item = analysis_att.findVoid('Fluid Flow')
ht_item = analysis_att.findGroup('Heat Transfer')
ih_item = None # induction heating
sm_item = analysis_att.findVoid('Solid Mechanics')
if ht_item.isEnabled():
ht_condition = THERMAL_ANALYSIS if ff_item.isEnabled() else ONLY_THERMAL_ANALYSIS
CardFormat.Conditions.add(ht_condition)
er_item = ht_item.find('Enclosure Radiation')
if er_item.isEnabled():
CardFormat.Conditions.add(ENCLOSURE_RADIATION)
# Todo MOVING_RADIAITON
ih_item = ht_item.find('Induction Heating')
if ih_item.isEnabled():
raise RuntimeError('Induction Heating selected but NOT yet supported')
if ff_item.isEnabled():
CardFormat.Conditions.add(FLOW_ANALYSIS)
# Todo VISCOUS_FLOW vs INVISCID_FLOW
if sm_item.isEnabled():
raise RuntimeError('Solid Mechanics selected but NOT yet supported')
# Iterim logic during development
att_list = self.sim_atts.findAttributes('ht/solver')
for att in att_list:
analysis_item = att.findString('analysis')
if analysis_item is not None:
analysis = analysis_item.value(0)
if analysis == 'thermal':
print('Adding analysis conditions "{}" "{}"'.format(
THERMAL_ANALYSIS, ONLY_THERMAL_ANALYSIS))
CardFormat.Conditions.add(THERMAL_ANALYSIS)
CardFormat.Conditions.add(ONLY_THERMAL_ANALYSIS)
elif analysis == 'thermal-plus-fluid':
print('Adding analysis conditions "{}", "{}"'.format(
THERMAL_ANALYSIS, FLOW_ANALYSIS))
CardFormat.Conditions.add(THERMAL_ANALYSIS)
CardFormat.Conditions.add(FLOW_ANALYSIS)
# att_list = self.sim_atts.findAttributes('ht/solver')
# for att in att_list:
# analysis_item = att.findString('analysis')
# if analysis_item is not None:
# analysis = analysis_item.value(0)
# if analysis == 'thermal':
# print('Adding analysis conditions "{}" "{}"'.format(
# THERMAL_ANALYSIS, ONLY_THERMAL_ANALYSIS))
# CardFormat.Conditions.add(THERMAL_ANALYSIS)
# CardFormat.Conditions.add(ONLY_THERMAL_ANALYSIS)
# elif analysis == 'thermal-plus-fluid':
# print('Adding analysis conditions "{}", "{}"'.format(
# THERMAL_ANALYSIS, FLOW_ANALYSIS))
# CardFormat.Conditions.add(THERMAL_ANALYSIS)
# CardFormat.Conditions.add(FLOW_ANALYSIS)
# Get the background material attribute's id
att_list = self.sim_atts.findAttributes('background-material')
......@@ -915,14 +877,13 @@ class Writer:
print('moving_enclosure_surface_set_ids', self.moving_enclosure_surface_set_ids)
# Check for moving radiation
att_list = self.sim_atts.findAttributes('enclosure-radiation')
enclosure_att = att_list[0]
enable_item = enclosure_att.find('enable')
if enable_item.isEnabled():
CardFormat.Conditions.add(ENCLOSURE_RADIATION)
moving_item = enclosure_att.itemAtPath('enable/enclosure/moving-radiation', '/')
#print('moving_item value', moving_item.value(0))
if moving_item.value(0) == 1:
print('Set condition', MOVING_RADIATION)
CardFormat.Conditions.add(MOVING_RADIATION)
# att_list = self.sim_atts.findAttributes('enclosure-radiation')
# if att_list:
# enclosure_att = att_list[0]
# CardFormat.Conditions.add(ENCLOSURE_RADIATION)
# moving_item = enclosure_att.itemAtPath('enclosure/moving-radiation', '/')
# #print('moving_item value', moving_item.value(0))
# if moving_item.value(0) == 1:
# print('Set condition', MOVING_RADIATION)
# CardFormat.Conditions.add(MOVING_RADIATION)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment