Commit 6ecb6cec authored by John Tourtellott's avatar John Tourtellott

Updates for materials, initial conditions, and smtk changes

* Adds void material as instanced attribute
* Adds initial condition functions (partial functionality)
* Updates code for recent smtk changes
* Fixes bugs, mostly related to multiple-phase materials
parent 0f443722
......@@ -260,9 +260,9 @@ format_table = {
],
'MATERIAL': [
# card('density', item_path='material-type/density'),
card('void_temperature', item_path='material-type/void-temperature',
card('void_temperature', item_path='void-temperature',
if_condition=VOID_MATERIAL),
card('sound_speed', item_path='material-type/sound-speed',
card('sound_speed', item_path='sound-speed',
if_condition=VOID_MATERIAL)
],
'MATERIAL_SYSTEM': [
......@@ -319,7 +319,7 @@ format_table = {
card('density-deviation', item_path='density-deviation', as_property=True),
card('specific heat', item_path='specific-heat', as_property=True),
card('conductivity', item_path='conductivity', as_property=True),
card('viscosity', item_path='viscosity', if_condition=FLUID_PHASE, as_property=True),
card('viscosity', item_path='fluid/viscosity', if_condition=FLUID_PHASE, as_property=True),
card('electrical conductivity', item_path='electrical-properties/electrical-conductivity',
if_condition=INDUCTION_HEATING,as_property=True),
card('electrical susceptibility', item_path='electrical-properties/electrical-susceptibility',
......
......@@ -180,7 +180,7 @@
</View>
<View Type="Attribute" Title="Phases" HideAssociations="true">
<AttributeTypes>
<Att Type="phase"/>
<Att Type="phase.material"/>
</AttributeTypes>
</View>
<View Type="Attribute" Title="Phase Transitions" HideAssociations="true">
......@@ -191,6 +191,7 @@
<View Type="Group" Name="Material Assignment Group" Label="Assignment" Style="Tiled">
<Views>
<View Title="Background Material" />
<View Title="Void Material" />
<View Title="Material Assignment" />
</Views>
</View>
......@@ -199,6 +200,11 @@
<Att Name="Background Material" Type="background-material" />
</InstancedAttributes>
</View>
<View Type="Instanced" Title="Void Material" Label="Void Material">
<InstancedAttributes>
<Att Name="Void Material" Type="phase.void" />
</InstancedAttributes>
</View>
<View Type="Associations" Title="Material Assignment" Label="Element Block Assignment">
<AttributeTypes>
<Att Type="phase" />
......@@ -214,20 +220,24 @@
<Views>
<View Title="Temperature IC" />
<View Title="Velocity IC" />
<View Title="Initial Condition Functions" />
</Views>
</View>
<View Type="Attribute" Name="Temperature IC" Label="Temperature">
<AttributeTypes>
<Att Type="TemperatureInitialCondition" />
</AttributeTypes>
</View>
<View Type="Attribute" Name="Velocity IC" Label="Velocity">
<AttributeTypes>
<Att Type="VelocityInitialCondition" />
</AttributeTypes>
</View>
<View Type="Attribute" Title="Initial Condition Functions" Label="Functions">
<AttributeTypes>
<Att Type="fn.initial-condition" />
</AttributeTypes>
</View>
<View Type="Group" Title="Other" Style="tiled">
<Views>
......
This diff is collapsed.
......@@ -23,10 +23,37 @@
</Component>
</ItemDefinitions>
</AttDef>
<AttDef Type="phase" BaseType="" Label="Phase" Version="0" Unique="true">
<AttDef Type="phase" BaseType="" Abstract="true" Unique="true">
<AssociationsDef Name="MaterialAssociations" Version="0" NumberOfRequiredValues="0" Extensible="true">
<MembershipMask>volume</MembershipMask>
</AssociationsDef>
</AttDef>
<AttDef Type="phase.void" BaseType="phase" Label="Void" Version="0">
<ItemDefinitions>
<Double Name="void-temperature" Label="Temperature">
<Categories>
<Cat>Fluid Flow</Cat>
<Cat>Heat Transfer</Cat>
<Cat>Induction Heating</Cat>
<Cat>Solid Mechanics</Cat>
</Categories>
<DefaultValue>0.0</DefaultValue>
</Double>
<Double Name="sound-speed" Label="Speed of Sound" AdvanceLevel="1">
<BriefDescription>| The adiabatic sound speed that is used in computing thecompressibility of each cell containing the material.
This is not a real sound speed, but a numerical artifice
used to permit collapse of small void bubbles.</BriefDescription>
<Categories>
<Cat>Fluid Flow</Cat>
<Cat>Heat Transfer</Cat>
<Cat>Induction Heating</Cat>
<Cat>Solid Mechanics</Cat>
</Categories>
<DefaultValue>0.0</DefaultValue>
</Double>
</ItemDefinitions>
</AttDef>
<AttDef Type="phase.material" BaseType="phase" Label="Phase" Version="0">
<ItemDefinitions>
<Double Name="density" Label="Density (rho)" Optional="false">
<BriefDescription>Mass density of the material phase</BriefDescription>
......
......@@ -93,8 +93,25 @@ SMTK_AttributeResource(Version="3")
['Center Temperature', 'Polynomial Terms', 'Coefficient', 'Exponent (Temp)'])
// Initial Temperature function of x,y,z
AttDef(Type="fn.initial-condition.temperature" BaseType="fn.initial-condition" Label="Initial Temperature" RootName="TemperatureFn" Version="0")
// Initial Temperature function of x,y,z, or all 3
AttDef(Type="fn.initial-condition.temperature" BaseType="fn.initial-condition" Abstract="true" Version="0")
AttDef(Type="fn.initial-condition.temperature.x" BaseType="fn.initial-condition.temperature" Label="f(x) Initial Temperature" RootName="TemperatureFn" Version="0")
+fn1('Heat Transfer',
['Tabular Data', 'X', 'Temperature'],
['Initial Temperature', 'Polynomial Terms', 'Coefficient', 'Exponent (X)'])
AttDef(Type="fn.initial-condition.temperature.y" BaseType="fn.initial-condition.temperature" Label="f(y) Initial Temperature" RootName="TemperatureFn" Version="0")
+fn1('Heat Transfer',
['Tabular Data', 'Y', 'Temperature'],
['Initial Temperature', 'Polynomial Terms', 'Coefficient', 'Exponent (Y)'])
AttDef(Type="fn.initial-condition.temperature.z" BaseType="fn.initial-condition.temperature" Label="f(z) Initial Temperature" RootName="TemperatureFn" Version="0")
+fn1('Heat Transfer',
['Tabular Data', 'Z', 'Temperature'],
['Initial Temperature', 'Polynomial Terms', 'Coefficient', 'Exponent (Z)'])
AttDef(Type="fn.initial-condition.temperature.xyz" BaseType="fn.initial-condition.temperature" Label="f(x,y,z) Initial Temperature" RootName="TemperatureFn" Version="0")
ItemDefinitions
String(Name="type" Label="Function Type" Version="0" stuff=category)
Categories #[Cat Heat Transfer]
......
......@@ -40,10 +40,25 @@ SMTK_AttributeResource(Version="3")
Resource(Name="smtk::attribute::Resource" Filter="attribute[type='phase']")
+categories-all
AttDef(Type="phase" BaseType="" Label="Phase" Version="0" Unique="true")
AttDef(Type="phase" BaseType="" Abstract="true" Unique="true")
AssociationsDef(Name="MaterialAssociations" Version="0"
NumberOfRequiredValues="0" Extensible="true")
MembershipMask volume
AttDef(Type="phase.void" BaseType="phase" Label="Void" Version="0")
ItemDefinitions
Double( Name="void-temperature" Label="Temperature")
+categories-all
DefaultValue 0.0
Double(Name="sound-speed" Label="Speed of Sound" AdvanceLevel="1")
BriefDescription | The adiabatic sound speed that is used in computing the
| compressibility of each cell containing the material.
| This is not a real sound speed, but a numerical artifice
| used to permit collapse of small void bubbles.
+categories-all
DefaultValue 0.0
AttDef(Type="phase.material" BaseType="phase" Label="Phase" Version="0")
ItemDefinitions
Double(Name="density" Label="Density (rho)" Optional="false")
BriefDescription Mass density of the material phase
......
......@@ -74,6 +74,7 @@ class Writer:
self.mesh_file = mesh_filename
self.altmesh_file = altmesh_filename
self.namelist_sequence = list()
self.skip_void_material = False
self.out = None
# ---------------------------------------------------------------------
......@@ -651,7 +652,7 @@ class Writer:
'''Common writer for FUNCTION namelists
'''
print('Writing', namelist.title, 'namelists')
print('Writing {} namelists ({})'.format(namelist.title, namelist.att_type))
att_list = self.sim_atts.findAttributes(namelist.att_type)
att_list.sort(key=lambda att: att.name())
for att in att_list:
......@@ -782,13 +783,30 @@ class Writer:
material_list.append(lower_dict[phase_id]) # multi-phase material (transition)
# print('material_list: {}'.format(material_list))
def set_conditions(att=None):
"""Sets CardFormat conditions for given phase attribute"""
CardFormat.Conditions.discard(VOID_MATERIAL)
CardFormat.Conditions.discard(FLUID_PHASE)
if att is None:
return
if att.type() == 'phase.void':
CardFormat.Conditions.add(VOID_MATERIAL)
elif att.type() == 'phase.material':
fluid_item = att.findGroup('fluid')
if fluid_item and fluid_item.isEnabled():
CardFormat.Conditions.add(FLUID_PHASE)
# Traverse material list
# Also keep track of transitions, to make sure *all* get used
trans_id_list = [t.id() for t in trans_atts]
trans_id_set = set(trans_id_list)
for att in material_list:
if att.type() == 'phase':
if att.type() == 'phase.void' and self.skip_void_material:
continue
if att.type() in ['phase.material', 'phase.void']:
# Write single phase material
set_conditions(att)
self._write_phase_namelist(att)
self._write_material_namelist(att)
self._write_material_system_namelist(att)
......@@ -796,17 +814,21 @@ class Writer:
trans_att = att
# Write multiple phase material, starting with lowest-temp phase
lower_att = trans_att.findComponent('lower').value()
set_conditions(lower_att)
self._write_phase_namelist(lower_att)
self._write_material_namelist(lower_att)
while trans_att is not None:
trans_id_set.discard(trans_att.id())
upper_att = trans_att.findComponent('upper').value()
set_conditions(upper_att)
self._write_phase_namelist(upper_att)
self._write_material_namelist(upper_att)
# Get next transition
trans_att = lower_dict.get(upper_att.id())
self._write_material_system_namelist(att, lower_dict)
set_conditions(None) # resets material conditions
else:
raise RuntimeError('ERROR - unexpected attribute type ', att.type())
......@@ -837,21 +859,16 @@ class Writer:
CardFormat.write_value(self.out, 'material_name', phase_att.name())
CardFormat.write_value(self.out, 'material_number', number)
fluid_item = phase_att.findGroup('fluid')
immobile = not fluid_item.isEnabled()
if phase_att.type() == 'phase.material':
immobile = FLUID_PHASE not in CardFormat.Conditions
CardFormat.write_value(self.out, 'immobile', immobile, as_boolean=True)
if fluid_item.isEnabled():
CardFormat.Conditions.add(FLUID_PHASE)
for card in format_list:
card.write(self.out, phase_att)
CardFormat.Conditions.discard(FLUID_PHASE)
# Hard-code material density
# Todo set to zero for void materials
CardFormat.write_value(self.out, 'density', 1.0)
# Write material density (1 for material, 0 for void)
density = 0.0 if VOID_MATERIAL in CardFormat.Conditions else 1.0
CardFormat.write_value(self.out, 'density', density)
# Check if this material is the background material
if phase_att.id() == self.background_material_id:
......@@ -866,11 +883,14 @@ class Writer:
title = 'PHASE'
print('Writing namelist {} for attribute {}'.format(title, phase_att.name()))
self._start_namelist(title)
format_list = self.format_table.get(title)
CardFormat.PropertyIndex = 0
name = phase_att.name()
CardFormat.write_value(self.out, 'name', name[:31], tab=4)
if not VOID_MATERIAL in CardFormat.Conditions:
format_list = self.format_table.get(title)
CardFormat.PropertyIndex = 0
for card in format_list:
card.write(self.out, phase_att)
self._finish_namelist()
......@@ -887,7 +907,7 @@ class Writer:
self._start_namelist(title)
# Simple case - att is single "phase" attribute
if att.type() == 'phase':
if att.type() in ['phase.material', 'phase.void']:
number = self.material_number_dict.get(att.id())
name = 'material {}'.format(number)
CardFormat.write_value(self.out, 'name', name, tab=6)
......@@ -932,7 +952,7 @@ class Writer:
# Check that transition temps are monotonically increasing
temp_lists = (lower_temps, upper_temps)
temps = [val for pair in zip(*temp_lists) for val in pair]
print('temps', temps)
#print('temps', temps)
prev_temp = temps[0]
for i in range(1, len(temps)):
temp = temps[i]
......@@ -981,20 +1001,25 @@ class Writer:
ht_item = analysis_att.findGroup(HT)
ih_item = None # induction heating
sm_item = analysis_att.findVoid(SM)
analyses = self.sim_atts.analyses()
category_set = set()
if ht_item.isEnabled():
ht_name = analyses.find(HT).name()
print("*** ht_name", ht_name, "***")
CardFormat.Conditions.add(THERMAL_ANALYSIS)
if not ff_item.isEnabled():
CardFormat.Conditions.add(ONLY_THERMAL_ANALYSIS)
self.analyses.append(HT)
category_set |= self.sim_atts.analysisCategories(HT)
category_set |= analyses.find(HT).categories()
er_item = ht_item.find(ER)
print('er_item:', er_item)
if er_item.isEnabled():
CardFormat.Conditions.add(ENCLOSURE_RADIATION)
self.analyses.append(ER)
category_set |= self.sim_atts.analysisCategories(ER)
category_set |= analyses.find(ER).categories()
# Todo MOVING_RADIAITON
raise RuntimeError('Enclosure Radiation selected but NOT yet supported')
......@@ -1002,17 +1027,17 @@ class Writer:
if ih_item.isEnabled():
CardFormat.Conditions.add(INDUCTION_HEATING)
self.analyses.append(IH)
category_set |= self.sim_atts.analysisCategories(IH)
category_set |= analyses.find(IH).categories()
if ff_item.isEnabled():
CardFormat.Conditions.add(FLOW_ANALYSIS)
self.analyses.append(FF)
category_set |= self.sim_atts.analysisCategories(FF)
category_set |= analyses.find(FF).categories(FF)
# Todo VISCOUS_FLOW vs INVISCID_FLOW
if sm_item.isEnabled():
self.analyses.append(SM)
category_set |= self.sim_atts.analysisCategories(SM)
category_set |= analyses.find(SM).categories()
raise RuntimeError('Solid Mechanics selected but NOT yet supported')
self.categories = list(category_set)
......@@ -1043,6 +1068,14 @@ class Writer:
if item.isSet(0):
self.background_material_id = item.value(0).id()
# Determine if void material should be written
void_list = self.sim_atts.findAttributes('phase.void')
if len(void_list) == 1:
void_att = void_list[0]
self.skip_void_material = void_att.associations().numberOfValues() == 0
else:
print('Warning - missing phase.void attribute')
# Find all interface_set_ids and enclosure_surface_set_ids
self.interface_set_ids = list()
self.enclosure_surface_set_ids = list()
......
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