Commit 36e816d4 authored by John Tourtellott's avatar John Tourtellott

Update Truchas logic for BODY namelists

* Drop "body" attribute and instead use "material"
* Represent initial conditions as separate attributes
parent 0899a08f
......@@ -117,9 +117,9 @@ format_table = {
card('surface_name', literal_value='from mesh file'),
card('mesh_material_number', use_model_entities_for_value=True),
card('material_number', is_custom=True),
card('temperature', item_path='temperature',
card('temperature', att_type='TemperatureInitialCondition', item_path='temperature',
expression_keyword='temperature_function'),
card('velocity', item_path='velocity')
card('velocity', att_type='VelocityInitialCondition', item_path='velocity')
],
'CHAPARRAL': [
card('blocking_enclosure', item_path='blocking-enclosure'),
......@@ -381,7 +381,7 @@ namelist_sequence = [
custom_method='_write_thermal_condition'),
namelist('BC',
att_type='boundary-condition', custom_method='_write_bc'),
namelist('BODY', att_type='body', custom_method='_write_body'),
namelist('BODY', att_type='material', custom_method='_write_body'),
namelist('DS_SOURCE', att_type='ht/source'),
namelist('PROBE', att_type='probe'),
namelist(
......
......@@ -6,7 +6,7 @@
</Categories>
<Definitions>
<AttDef Type="TemperatureInitialCondition" Label="Temperature">
<AttDef Type="TemperatureInitialCondition" Label="Temperature" Unique="true">
<AssociationsDef Name="DSSourceAssociations" Version="0" NumberOfRequiredValues="0" Extensible="true">
<MembershipMask>volume</MembershipMask>
</AssociationsDef>
......@@ -23,7 +23,7 @@
</ItemDefinitions>
</AttDef>
<AttDef Type="VelocityInitialCondition" Label="Temperature">
<AttDef Type="VelocityInitialCondition" Label="Velocity" Unique="true">
<AssociationsDef Name="DSSourceAssociations" Version="0" NumberOfRequiredValues="0" Extensible="true">
<MembershipMask>volume</MembershipMask>
</AssociationsDef>
......
......@@ -11,34 +11,7 @@ SMTK_AttributeResource(Version="3")
// Attribute Definitions
Definitions
// BODY
AttDef(Type="body" Label="Body (Initial Conditions)" BaseType="" Version="0")
AssociationsDef(Name="DSSourceAssociations" Version="0"
NumberOfRequiredValues="0" Extensible="true")
MembershipMask volume
ItemDefinitions
//- Component(Name="material-ref" Label="Material" NumberOfRequiredValues="1" Version="0")
//- Accepts
//- Resource(Name="smtk::attribute::Resource" Filter="attribute")
//- Categories
//- Cat Fluid Flow
//- Cat Heat Transfer
//- Cat Induction Heating
//- Cat Solid Mechanics
Double(Name="temperature" Label="Temperature" Optional="true" IsEnabledByDefault="true")
BriefDescription Initial temperature of the material body
Categories
Cat Fluid Flow
Cat Heat Transfer
ExpressionType tabular-function
Double(Name="velocity" Label="Velocity" NumberOfRequiredValues="3" Optional="true" IsEnabledByDefault="false")
BriefDescription Initial velocity of the material body
Categories
Cat Fluid Flow
Cat Heat Transfer
DefaultValue 0.0
// Note: BODY attribute replaced by standalone initial conditions defintiions (December 2018)
// DS_SOURCE
AttDef(Type="ht/source" Label="Volumetric Heat Source" BaseType="" Version="0")
......
......@@ -451,10 +451,26 @@ class Writer:
'''
print('Writing', namelist.title, 'namelists')
# Get 'material' definition, for use below
material_defn = self.sim_atts.findDefinition('material')
# FYI the attribute type for writing body namelists is "material"
att_list = self.sim_atts.findAttributes(namelist.att_type)
if not att_list:
return
# Local method to find attribute of a specified type on
# a given model entity
def _get_attribute(att_resource, model_entity, att_type):
# Get set of attributes associated to model_entity
ent_set = att_resource.attributes(model_entity)
# Get list of attributes of given type
type_list = att_resource.findAttributes(att_type)
# Intersection gives set that meet both cases
common_set = ent_set.intersection(set(type_list))
if common_set:
return common_set.pop() # only return 1 att
# (else)
return None
# Traverse material attributes
att_list.sort(key=lambda att: att.name())
for att in att_list:
reference_item = att.associations()
......@@ -472,7 +488,7 @@ class Writer:
if 'material_number' == card.keyword:
# In _setup(), info was attached to each model entity
idlist = self.model_resource.integerProperty(
model_ent, 'material number')
model_ent.id(), 'material number')
if not idlist:
continue
......@@ -483,17 +499,18 @@ class Writer:
# per email discussions 23-Jun-2016.
# And for two-phase materials, the fluid number is +1 more
# than the property set on the model entity.
material_att_list = model_ent.attributes(material_defn)
if material_att_list:
material_att = material_att_list[0]
mat_type_item = material_att.findString('material-type')
mat_type = mat_type_item.value(0)
#print('material type:', mat_type)
if 'two-phase' == mat_type:
material_number += 1
break
mat_type_item = att.findString('material-type')
mat_type = mat_type_item.value(0)
#print('material type:', mat_type)
if 'two-phase' == mat_type:
material_number += 1
CardFormat.write_value(self.out, card.keyword, material_number)
elif card.keyword in ['temperature', 'velocity']:
# Initial conditions are separate attributes on the same model entity
ic_att = _get_attribute(self.sim_atts, model_ent, card.att_type)
if ic_att:
card.write(self.out, ic_att)
else:
card.write(self.out, att)
self.out.write('/\n')
......
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