Commit 57d79fec authored by John Tourtellott's avatar John Tourtellott

Checkpoint - begin updating export logic

* Mostly for heat transfer boundary conditions
* Take out deprecated logic
parent a42bcd70
......@@ -370,18 +370,16 @@ namelist_sequence = [
base_item_path='analysis/fluid/viscous-flow-model/viscous-linear-solver'),
namelist(
'DS_BOUNDARY_CONDITION',
att_type='thermal-surface-condition',
base_item_path='type/ds-boundary-condition',
att_type='ht/boundary',
custom_method='_write_thermal_condition'),
namelist(
'DS_INTERFACE_CONDITION',
att_type='thermal-surface-condition',
base_item_path='type/ds-interface-condition',
att_type='ht/interface',
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('DS_SOURCE', att_type='ds-source'),
namelist('DS_SOURCE', att_type='ht/source'),
namelist('PROBE', att_type='probe'),
namelist(
'SIMULATION_CONTROL',
......
......@@ -11,12 +11,15 @@
#=============================================================================
import os
print 'loading', os.path.basename(__file__)
import sys
import smtk
if 'pybind11' == smtk.wrappingProtocol():
#print 'Using pybind11 bindings'
import smtk.attribute
import smtk.attribute
# Workaround for missing enum
if not hasattr(smtk.attribute.Item, 'ReferenceType'):
print 'Adding smtk.attribute.Item.ReferenceType'
smtk.attribute.Item.ReferenceType = 13
# ---------------------------------------------------------------------
class CardFormat:
......@@ -156,27 +159,31 @@ class CardFormat:
self.__class__.write_value(out, self.keyword, item.name())
return self._finish_write()
concrete_item = smtk.attribute.to_concrete(item)
# If value isn't set, skip
if not concrete_item.isSet(0):
if not item.isSet(0):
return False
# Check skip_default option
if self.skip_default and concrete_item.isUsingDefault(0):
if self.skip_default and item.isUsingDefault(0):
return False
if item.type() == smtk.attribute.Item.ModelEntityType:
id_string = self.__class__.get_model_entity_ids(concrete_item, as_string=True)
id_string = self.__class__.get_model_entity_ids(item, as_string=True)
if id_string:
self.__class__.write_value(out, self.keyword, id_string, quote_string=False)
return
if hasattr(concrete_item, 'numberOfValues') and \
concrete_item.numberOfValues() > 1:
if item.type() == smtk.attribute.Item.ReferenceType:
id_string = self.__class__.get_model_entity_ids(item, as_string=True)
if id_string:
self.__class__.write_value(out, self.keyword, id_string, quote_string=False)
return
if hasattr(item, 'numberOfValues') and \
item.numberOfValues() > 1:
value_list = list()
for i in range(concrete_item.numberOfValues()):
value_list.append(concrete_item.value(i))
for i in range(item.numberOfValues()):
value_list.append(item.value(i))
string_list = [str(x) for x in value_list]
string_value = ', '.join(string_list)
self.__class__.write_value(
......@@ -188,14 +195,14 @@ class CardFormat:
#property_prefix = 'property_constant'
value = 'undefined'
is_expression = False
if hasattr(concrete_item, 'isExpression') and concrete_item.isExpression(0):
if hasattr(item, 'isExpression') and item.isExpression(0):
is_expression = True
expression_att = concrete_item.expression(0)
expression_att = item.expression(0)
value = expression_att.name()
if self.expression_keyword is not None:
keyword = self.expression_keyword
else:
value = concrete_item.value(0)
value = item.value(0)
# RefItem a special case
if hasattr(smtk, 'AttributePtr') and isinstance(value, smtk.AttributePtr):
value = value.name()
......@@ -293,21 +300,30 @@ class CardFormat:
def get_associated_entity_ids(klass, att, as_string=False):
'''Returns list of all model entity ids associated with this attribute
'''
model_ent_item = att.associations()
return klass.get_model_entity_ids(model_ent_item, as_string)
reference_item = att.associations()
return klass.get_model_entity_ids(reference_item, as_string)
# ---------------------------------------------------------------------
@classmethod
def get_model_entity_ids(klass, model_entity_item, as_string=False):
'''Returns list of model entity ids represented by input model entity item
def get_model_entity_ids(klass, item, as_string=False):
'''Returns list of model entity ids represented by input item
Input item could be ModelEntityItem or ReferenceItem
'''
if model_entity_item is None or (0 == model_entity_item.numberOfValues()):
if item is None or (0 == item.numberOfValues()):
return []
full_id_list = list()
for i in range(model_entity_item.numberOfValues()):
ent_ref = model_entity_item.value(i)
ent_id = klass.get_model_entity_id(ent_ref)
for i in range(item.numberOfValues()):
if item.type() == smtk.attribute.Item.ModelEntityType:
ref = item.value(i)
ent = model_entity_ref.entity()
elif item.type() == smtk.attribute.Item.ReferenceType:
ent = item.objectValue(i)
else:
raise Exception('Unsupported type', item.type())
ent_id = klass.get_model_entity_id(ent)
if ent_id is not None:
full_id_list.append(ent_id)
......@@ -322,7 +338,7 @@ class CardFormat:
# ---------------------------------------------------------------------
@classmethod
def get_model_entity_id(klass, model_entity_ref, property_name='pedigree id'):
def get_model_entity_id(klass, model_entity, property_name='pedigree id'):
'''Returns id assigned to the input model entity.
Uses integer property assigned by the application
......@@ -330,8 +346,7 @@ class CardFormat:
if klass.ModelManager is None:
return None
model_ent = model_entity_ref.entity()
idlist = klass.ModelManager.integerProperty(model_ent, property_name)
idlist = klass.ModelManager.integerProperty(model_entity.id(), property_name)
if idlist:
return idlist[0]
#(else)
......
This diff is collapsed.
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