Commit 6679e7ae authored by John Tourtellott's avatar John Tourtellott

Add file-separator option to namelists

Writes out comment line before namelist contents
parent 8fc83250
......@@ -374,7 +374,7 @@ namelist_sequence = [
# custom_method='_write_thermal_condition'),
namelist('PHYSICS', custom_method='_write_physics'),
# Note: internally, the materials writer includes PHASE and MATERIAL_SYSTEM
namelist('MATERIAL', custom_method='_write_materials'),
namelist('MATERIAL', custom_method='_write_materials', separator='MATERIALS'),
namelist('DIFFUSION_SOLVER',
if_condition=ONLY_THERMAL_ANALYSIS,
att_type='ht.solver',
......@@ -396,20 +396,22 @@ namelist_sequence = [
# att_type='solver',
# base_item_path='analysis/fluid/viscous-flow-model/viscous-linear-solver'),
namelist('ALTMESH', if_condition=INDUCTION_HEATING, att_type='electromagnetics',
custom_method='_write_mesh'),
custom_method='_write_mesh', separator='INDUCTION HEATING'),
namelist('ELECTROMAGNETICS', if_condition=INDUCTION_HEATING, att_type='electromagnetics'),
namelist('INDUCTION_COIL', if_condition=INDUCTION_HEATING, att_type='induction-coil'),
namelist(
'DS_BOUNDARY_CONDITION',
att_type='ht.boundary',
custom_method='_write_thermal_condition'),
custom_method='_write_thermal_condition',
separator='BOUNDARY CONDITIONS'),
namelist(
'DS_INTERFACE_CONDITION',
att_type='ht.interface',
custom_method='_write_thermal_condition'),
custom_method='_write_thermal_condition',
separator='INTERFACE CONDITIONS'),
namelist('BC',
att_type='boundary-condition', custom_method='_write_bc'),
namelist('BODY', att_type='material', custom_method='_write_body'),
namelist('BODY', att_type='material', custom_method='_write_body', separator='BODIES'),
namelist('DS_SOURCE', att_type='ht.source'),
namelist('PROBE', att_type='probe'),
namelist(
......
......@@ -30,7 +30,8 @@ class Namelist:
att_type=None,
base_item_path=None,
custom_method = None,
if_condition=None):
if_condition=None,
separator=None):
'''Information for project file namelist
Required arguments:
......@@ -42,9 +43,12 @@ class Namelist:
custom_method: (string) name of custom method to call in Writer
if_condition: (string) only write output if condition is in the
CardFormat Condition set.
separator: (string) if included, write file-separator before
namelists of this type
'''
self.title = title
self.att_type = att_type
self.base_item_path = base_item_path
self.custom_method = custom_method
self.if_condition = if_condition
self.separator = separator
......@@ -107,12 +107,19 @@ class Writer:
self.out = out
for namelist in self.namelist_sequence:
format_list = self.format_table.get(namelist.title)
# Check conditions
if not CardFormat.test_conditions(namelist.if_condition):
continue
if namelist.separator:
out.write('\n')
label = '### {} '.format(namelist.separator)
line = label.ljust(80, '#')
out.write(line)
out.write('\n')
format_list = self.format_table.get(namelist.title)
# Namelists can assign custom method
if namelist.custom_method is not None:
if not hasattr(self, namelist.custom_method):
......
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