Commit 80a9070d authored by John Tourtellott's avatar John Tourtellott

Add python writer for ThermoElastic

* Had to split TEM3P materials and analyses attributes into separate
  thermal and elastic versions, since we can have both in the same simulation
* Also renamed "tem3p-structure" --> "tem3p-elastic"
* Added test case RfGunCoupler
parent 3e32d59e
......@@ -112,10 +112,11 @@ def ExportCMB(spec):
't3p': 'T3P Analysis',
'track3p': 'Track3P Analysis',
'tem3p-eigen': 'TEM3P Eigenmode',
'tem3p-structure': 'TEM3P Elastic',
'tem3p-elastic': 'TEM3P Elastic',
'tem3p-harmonic': 'TEM3P Harmonic Response',
'tem3p-thermal-linear': 'TEM3P Thermal Linear',
'tem3p-thermal-nonlinear': 'TEM3P Thermal Nonlinear'
'tem3p-thermal-nonlinear': 'TEM3P Thermal Nonlinear',
'tem3p-thermo-elastic': 'TEMP3P ThermoElastic'
}
# Loop over all solvers and write corresponding files
......@@ -127,7 +128,7 @@ def ExportCMB(spec):
# Get full analysis name
analysis = analysis_lookup.get(solver)
if not analysis:
msg = 'The ACE3P analysis is not specified, solver %s' % solver
msg = 'The ACE3P analysis is not specified, solver %s ' % solver
scope.logger.addError(msg)
raise Exception(msg)
print 'Writing %s' % analysis
......@@ -138,14 +139,7 @@ def ExportCMB(spec):
print 'Using categories: %s' % scope.categories
# Initialize output file
extension_lookup = {
'tem3p-eigen': 'tem3p',
'tem3p-structure': 'tem3p',
'tem3p-harmonic': 'tem3p',
'tem3p-thermal-linear': 'tem3p',
'tem3p-thermal-nonlinear': 'tem3p'
}
file_ext = extension_lookup.get(solver, solver)
file_ext = 'tem3p' if solver.startswith('tem3p') else solver
filename = '%s.%s' % (scope.output_file_prefix, file_ext)
output_path = os.path.join(scope.output_folder, filename)
print 'Output file %s' % output_path
......
......@@ -75,6 +75,13 @@
<Item>OutputFilePrefix</Item>
</Items>
</Structure>
<Structure>
<Value Enum="Track3P">track3p</Value>
<Items>
<Item>OutputFolder</Item>
<Item>OutputFilePrefix</Item>
</Items>
</Structure>
<Structure>
<Value Enum="TEM3P Eigenmode">tem3p-eigen</Value>
<Items>
......@@ -111,7 +118,7 @@
</Items>
</Structure>
<Structure>
<Value Enum="Track3P">track3p</Value>
<Value Enum="TEM3P ThermoElastic">tem3p-thermo-elastic</Value>
<Items>
<Item>OutputFolder</Item>
<Item>OutputFilePrefix</Item>
......
......@@ -116,16 +116,16 @@
<View Type="Group" Title="TEM3P Harmonic Response" TabPosition="North" TabIcons="false">
<Views>
<View Title="TEM3P Mechanical BC" />
<View Title="TEM3P Material" />
<View Title="TEM3P Analysis"/>
<View Title="TEM3P Elastic Material" />
<View Title="TEM3P Elastic Analysis"/>
</Views>
</View>
<View Type="Group" Title="TEM3P Eigenmode" TabPosition="North" TabIcons="false">
<Views>
<View Title="TEM3P Mechanical BC" />
<View Title="TEM3P Material" />
<View Title="TEM3P Analysis"/>
<View Title="TEM3P Elastic Material" />
<View Title="TEM3P Elastic Analysis"/>
<View Title="Mesh Output" />
</Views>
</View>
......@@ -133,8 +133,8 @@
<View Type="Group" Title="TEM3P Elastic" TabPosition="North" TabIcons="false">
<Views>
<View Title="TEM3P Mechanical BC" />
<View Title="TEM3P Material" />
<View Title="TEM3P Analysis"/>
<View Title="TEM3P Elastic Material" />
<View Title="TEM3P Elastic Analysis"/>
<View Title="Mesh Output" />
</Views>
</View>
......@@ -142,8 +142,8 @@
<View Type="Group" Title="TEM3P Thermal Linear" TabPosition="North" TabIcons="false">
<Views>
<View Title="TEM3P Thermal BC" />
<View Title="TEM3P Material" />
<View Title="TEM3P Analysis"/>
<View Title="TEM3P Thermal Material" />
<View Title="TEM3P Thermal Analysis"/>
<View Title="Thermal Shells" />
<View Title="Heat Sources" />
</Views>
......@@ -152,8 +152,8 @@
<View Type="Group" Title="TEM3P Thermal Nonlinear" TabPosition="North" TabIcons="false">
<Views>
<View Title="TEM3P Thermal BC" />
<View Title="TEM3P Material" />
<View Title="TEM3P Analysis"/>
<View Title="TEM3P Thermal Material" />
<View Title="TEM3P Thermal Analysis"/>
<View Title="Thermal Shells" />
<View Title="Heat Sources" />
</Views>
......
......@@ -126,7 +126,7 @@ SMTK_AttributeSystem(Version="2")
BriefDescription The coordinates of the end point of the path
Categories #[Cat TEM3P-Harmonic] #[Cat TEM3P-Static] #[Cat TEM3P-ThermoElastic]
ComponentLabels #[Label x] #[Label y] #[Label z]
DefaultValue 1,1,1
DefaultValue 0,0,1
// (LFDetuningMethod)
DiscreteInfo
......@@ -274,7 +274,7 @@ SMTK_AttributeSystem(Version="2")
Double(Name="EndPoint" Label="End Point" NumberOfRequiredValues="3" Units="m" Version="0")
BriefDescription The coordinates of the end point for gradient integration
Categories #[Cat TEM3P-Linear-Thermal] #[Cat TEM3P-Nonlinear-Thermal] #[Cat TEM3P-ThermoElastic]
DefaultValue 1,1,1
DefaultValue 0,0,1
Double(Name="TargetPowerLoss" Label="Target Power Loss" Units="W" Version="0")
BriefDescription Total power loss on metallic surface
Categories #[Cat TEM3P-Linear-Thermal] #[Cat TEM3P-Nonlinear-Thermal] #[Cat TEM3P-ThermoElastic]
......
......@@ -9,13 +9,13 @@ SMTK_AttributeSystem(Version="2")
Cat TEM3P-ThermoElastic
Definitions
// Volume material properties
AttDef(Type="TEM3PMaterial" Label="Material" BaseType="" Abstract="true" Version="0")
//- Thermal and Elastic materials are completely distinct, so they can be used
concurrently in ThermoElastic analyses
AttDef(Type="TEM3PElasticMaterial" Label="Material" BaseType="" Unique="true" Version="0")
AssociationsDef(Name="TEM3PMaterialAssociations" Version="0"
NumberOfRequiredValues="0" Extensible="true")
MembershipMask volume
AttDef(Type="TEM3PElasticMaterial" Label="Material" BaseType="TEM3PMaterial" Unique="true" Version="0")
ItemDefinitions
String(Name="Material" Label="Material" Version="0")
Categories #[Cat TEM3P-Eigen] #[Cat TEM3P-Harmonic] #[Cat TEM3P-Static] #[Cat TEM3P-ThermoElastic]
......@@ -53,7 +53,10 @@ SMTK_AttributeSystem(Version="2")
Item ElasticAlpha
Item Density
AttDef(Type="TEM3PThermalMaterial" Label="Material" BaseType="TEM3PMaterial" Unique="true" Version="0")
AttDef(Type="TEM3PThermalMaterial" Label="Material" BaseType="" Unique="true" Version="0")
AssociationsDef(Name="TEM3PMaterialAssociations" Version="0"
NumberOfRequiredValues="0" Extensible="true")
MembershipMask volume
ItemDefinitions
String(Name="NonlinearMaterial" Label="Material" Version="0")
Categories #[Cat TEM3P-Nonlinear-Thermal] #[Cat TEM3P-ThermoElastic]
......
......@@ -38,7 +38,7 @@ SMTK_AttributeSystem(Version="2")
Items
Item LocalDirectory
Double(Name="MeshDeformedScale" Label="Mesh Deformed Scale" Version="0")
Double(Name="MeshDeformScale" Label="Mesh Deform Scale" Version="0")
BriefDescription Deformation scale factor
Categories #[Cat TEM3P-Eigen] #[Cat TEM3P-Static] #[Cat TEM3P-ThermoElastic]
DefaultValue 1.0
......
......@@ -22,8 +22,10 @@ SMTK_AttributeSystem(Version="2")
// Views
// View(Title="TEM3P Mechanical BC")/
// View(Title="TEM3P Thermal BC")/
// View(Title="TEM3P Material")/
// View(Title="TEM3P Analysis")/
// View(Title="TEM3P Elastic Material")/
// View(Title="TEM3P Thermal Material")/
// View(Title="TEM3P Elastic Analysis")/
// View(Title="TEM3P Thermal Analysis")/
// View(Title="TEM3P Mesh Output")/
// View(Title="TEM3P Thermal Shells")/
// View(Title="Heat Sources")
......@@ -37,18 +39,31 @@ SMTK_AttributeSystem(Version="2")
AttributeTypes
Att(Type="TEM3PThermalBC")
View(Type="Attribute" Title="TEM3P Material" Label="Materials")
View(Type="Attribute" Title="TEM3P Elastic Material" Label="Materials")
AttributeTypes
Att(Type="TEM3PMaterial")
Att(Type="TEM3PElasticMaterial")
View(Type="Instanced" Name="TEM3P Analysis" Label="Analysis")
View(Type="Attribute" Title="TEM3P Thermal Material" Label="Materials")
AttributeTypes
Att(Type="TEM3PThermalMaterial")
// Need separate elastic and thermal analysis attributes (for ThermoElastic)
View(Type="Instanced" Name="TEM3P Elastic Analysis" Label="Analysis")
InstancedAttributes
Att(Name="ElasticOrderAtt" Type="Order")/
Att(Name="ElasticEigenSolverAtt" Type="EigenSolver")/
Att(Name="ElasticLinearSolverAtt" Type="TEM3PLinearSolver")/
Att(Name="ElasticHarmonicAnalysisAtt" Type="HarmonicAnalysis")/
Att(Name="ElasticNonlinearSolverAtt" Type="NonlinearSolver")/
Att(Name="ElasticPicardSolverAtt" Type="PicardSolver")/
View(Type="Instanced" Name="TEM3P Thermal Analysis" Label="Analysis")
InstancedAttributes
Att(Name="OrderAtt" Type="Order")/
Att(Name="EigenSolverAtt" Type="EigenSolver")/
Att(Name="TEM3PLinearSolverAtt" Type="TEM3PLinearSolver")/
Att(Name="HarmonicAnalysisAtt" Type="HarmonicAnalysis")/
Att(Name="NonlinearSolverAtt" Type="NonlinearSolver")/
Att(Name="PicardSolverAtt" Type="PicardSolver")/
Att(Name="ThermalOrderAtt" Type="Order")/
Att(Name="ThermalEigenSolverAtt" Type="EigenSolver")/
Att(Name="ThermalLinearSolverAtt" Type="TEM3PLinearSolver")/
Att(Name="ThermalHarmonicAnalysisAtt" Type="HarmonicAnalysis")/
Att(Name="ThermalNonlinearSolverAtt" Type="NonlinearSolver")/
Att(Name="ThermalPicardSolverAtt" Type="PicardSolver")/
View(Type="Instanced" Title="Mesh Output")
InstancedAttributes
......
......@@ -245,7 +245,7 @@
<Label>y</Label>
<Label>z</Label>
</ComponentLabels>
<DefaultValue>1,1,1</DefaultValue>
<DefaultValue>0,0,1</DefaultValue>
</Double>
</ChildrenDefinitions>
<!-- (LFDetuningMethod)-->
......@@ -510,7 +510,7 @@
<Cat>TEM3P-Nonlinear-Thermal</Cat>
<Cat>TEM3P-ThermoElastic</Cat>
</Categories>
<DefaultValue>1,1,1</DefaultValue>
<DefaultValue>0,0,1</DefaultValue>
</Double>
<Double Name="TargetPowerLoss" Label="Target Power Loss" Units="W" Version="0">
<BriefDescription>Total power loss on metallic surface</BriefDescription>
......
......@@ -9,13 +9,10 @@
<Cat>TEM3P-ThermoElastic</Cat>
</Categories>
<Definitions>
<!-- Volume material properties-->
<AttDef Type="TEM3PMaterial" Label="Material" BaseType="" Abstract="true" Version="0">
<AttDef Type="TEM3PElasticMaterial" Label="Material" BaseType="" Unique="true" Version="0">
<AssociationsDef Name="TEM3PMaterialAssociations" Version="0" NumberOfRequiredValues="0" Extensible="true">
<MembershipMask>volume</MembershipMask>
</AssociationsDef>
</AttDef>
<AttDef Type="TEM3PElasticMaterial" Label="Material" BaseType="TEM3PMaterial" Unique="true" Version="0">
<ItemDefinitions>
<String Name="Material" Label="Material" Version="0">
<Categories>
......@@ -87,7 +84,10 @@
</String>
</ItemDefinitions>
</AttDef>
<AttDef Type="TEM3PThermalMaterial" Label="Material" BaseType="TEM3PMaterial" Unique="true" Version="0">
<AttDef Type="TEM3PThermalMaterial" Label="Material" BaseType="" Unique="true" Version="0">
<AssociationsDef Name="TEM3PMaterialAssociations" Version="0" NumberOfRequiredValues="0" Extensible="true">
<MembershipMask>volume</MembershipMask>
</AssociationsDef>
<ItemDefinitions>
<String Name="NonlinearMaterial" Label="Material" Version="0">
<Categories>
......
......@@ -48,7 +48,7 @@
</String>
</ItemDefinitions>
</Group>
<Double Name="MeshDeformedScale" Label="Mesh Deformed Scale" Version="0">
<Double Name="MeshDeformScale" Label="Mesh Deform Scale" Version="0">
<BriefDescription>Deformation scale factor</BriefDescription>
<Categories>
<Cat>TEM3P-Eigen</Cat>
......
......@@ -16,8 +16,10 @@
<!-- Views-->
<!-- View(Title="TEM3P Mechanical BC")/-->
<!-- View(Title="TEM3P Thermal BC")/-->
<!-- View(Title="TEM3P Material")/-->
<!-- View(Title="TEM3P Analysis")/-->
<!-- View(Title="TEM3P Elastic Material")/-->
<!-- View(Title="TEM3P Thermal Material")/-->
<!-- View(Title="TEM3P Elastic Analysis")/-->
<!-- View(Title="TEM3P Thermal Analysis")/-->
<!-- View(Title="TEM3P Mesh Output")/-->
<!-- View(Title="TEM3P Thermal Shells")/-->
<!-- View(Title="Heat Sources")-->
......@@ -32,19 +34,35 @@
<Att Type="TEM3PThermalBC"></Att>
</AttributeTypes>
</View>
<View Type="Attribute" Title="TEM3P Material" Label="Materials">
<View Type="Attribute" Title="TEM3P Elastic Material" Label="Materials">
<AttributeTypes>
<Att Type="TEM3PMaterial"></Att>
<Att Type="TEM3PElasticMaterial"></Att>
</AttributeTypes>
</View>
<View Type="Instanced" Name="TEM3P Analysis" Label="Analysis">
<View Type="Attribute" Title="TEM3P Thermal Material" Label="Materials">
<AttributeTypes>
<Att Type="TEM3PThermalMaterial"></Att>
</AttributeTypes>
</View>
<!-- Need separate elastic and thermal analysis attributes (for ThermoElastic)-->
<View Type="Instanced" Name="TEM3P Elastic Analysis" Label="Analysis">
<InstancedAttributes>
<Att Name="ElasticOrderAtt" Type="Order"/>
<Att Name="ElasticEigenSolverAtt" Type="EigenSolver"/>
<Att Name="ElasticLinearSolverAtt" Type="TEM3PLinearSolver"/>
<Att Name="ElasticHarmonicAnalysisAtt" Type="HarmonicAnalysis"/>
<Att Name="ElasticNonlinearSolverAtt" Type="NonlinearSolver"/>
<Att Name="ElasticPicardSolverAtt" Type="PicardSolver"/>
</InstancedAttributes>
</View>
<View Type="Instanced" Name="TEM3P Thermal Analysis" Label="Analysis">
<InstancedAttributes>
<Att Name="OrderAtt" Type="Order"/>
<Att Name="EigenSolverAtt" Type="EigenSolver"/>
<Att Name="TEM3PLinearSolverAtt" Type="TEM3PLinearSolver"/>
<Att Name="HarmonicAnalysisAtt" Type="HarmonicAnalysis"/>
<Att Name="NonlinearSolverAtt" Type="NonlinearSolver"/>
<Att Name="PicardSolverAtt" Type="PicardSolver"/>
<Att Name="ThermalOrderAtt" Type="Order"/>
<Att Name="ThermalEigenSolverAtt" Type="EigenSolver"/>
<Att Name="ThermalLinearSolverAtt" Type="TEM3PLinearSolver"/>
<Att Name="ThermalHarmonicAnalysisAtt" Type="HarmonicAnalysis"/>
<Att Name="ThermalNonlinearSolverAtt" Type="NonlinearSolver"/>
<Att Name="ThermalPicardSolverAtt" Type="PicardSolver"/>
</InstancedAttributes>
</View>
<View Type="Instanced" Title="Mesh Output">
......
This source diff could not be displayed because it is too large. You can view the blob instead.
# LCLS RF Gun Coupler Cell
TEM3P ThermoElastic example in CW16
Note that this outline does not include the prerequeist
Omega3P simulation.
## Model
Load RfGunBody.ncdf
SaveAs RfGunBody.smtk
## Template
Load ACE3P.crf
Select Module (show by category): TEM3P ThermoElastic
## Step 1: Thermal Solver Specification
Select "TEM3P Thermal Nonlinear" tab
### Boundary Conditions
surface 1 --> Heat Flux (Neumann) --> 0.0
surface 2 --> Heat Flux (Neumann) --> 0.0
surface 3 --> Heat Flux (Neumann) --> 0.0
surface 4 --> Heat Flux (Neumann) --> 0.0
surface 5 --> Robin
Robin Constant Factor --> 20000
Robin Constant Value ---> 440000
surface 6 --> RFHeating
NERSC Directory -----------> placeholder
Mode Number ---------------> 0
Method --------------------> Target Gradient Scaling
Electrical Conductivity --> 5.8e7
Target Gradient ----------> 60e6
Duty Factor --------------> 0.00036
Start Point --------------> 0.0001, 0.0001 -0.017018
End Point ----------------> 0.0001, 0.0001 0.017018
### Materials
Material ----------------> New, volume 1
Material --------------> Custom Constant...
Thermal Conductivity --> 391
### Analysis
Basis Order ---------> 2
Curved Surfaces -----> On
Linear Solver Type --> CG
Preconditioner ------> DIAGONAL
Absolute Tolerance --> 1e-18
Tolerance -----------> 1e-10
Max Iterations ------> 5000
## Step 2: Elastic (Thermostatic) Solver Specification
Select "TEM3P Elastic" tab
### Boundary Conditions
surface 1 --> Mixed --> Normal, Normal, Displacement --> 0,0,0
surface 2 --> Mixed --> Displacement, Normal, Normal --> 0,0,0
surface 3 --> Mixed --> Normal, Displacement, Normal --> 0,0,0
surface 4 --> Normal Loading (Neumann) --> 0.0
surface 5 --> Normal Loading (Neumann) --> 0.0
surface 6 --> LF Detunint
NERSC Directory ---> placeholder
Mode Number -------> 0
Omega3P Id --------> 6
Method ------------> Gradient
TargetGradient --> 60e6
Start Point -----> 0.0001, 0.0001 -0.017018
End Point -------> 0.0001, 0.0001 0.017018
### Materials
Material --> New, volume 1 --> Copper, 293K
### Analysis
Basis Order ---------> 2
Curved Surfaces -----> On
Linear Solver Type --> CG
Preconditioner ------> DIAGONAL
Absolute Tolerance --> 1e-16
Tolerance -----------> 1e-10
Max Iterations ------> 50000
### Mesh Output
Write Deformed Mesh --------------> off
Write Deformed EM Mesh -----------> on
NERSC Directory ------------------> placeholder
Mesh Deform Scale ----------------> 1
Write Stress/Strain Model Files --> on
## Save Simulation
thermo-elastic.crf
// Generated by CMB 28-Jun-2018 10:07
ThermoElasticProblem:
{
RunId: 3
}
ThermostaticProblem:
{
MeshFile: RfGunBody.ncdf
BasisOrder: 2
CurvedSurfaces: on
LinearSolver:
{
Solver: CG
Preconditioner: DIAGONAL
AbsoluteTolerance: 1e-18
Tolerance: 1e-10
MaxIterations: 5000
}
PicardSolver:
{
Solver: CG
Preconditioner: DIAGONAL
AbsoluteTolerance: 1e-18
Tolerance: 1e-10
MaxIterations: 100000
}
NonlinearSolver:
{
Solver: Newton
PicardIteration: 10
MaxIterations: 40
AbsTolerance: 1e-10
RelTolerance: 1e-08
}
ThermalConductivity:
{
Id: 1
Value: 391
}
Boundary:
{
Id: 1
ConditionType: Neumann
NeumannValue: 0
}
Boundary:
{
Id: 2
ConditionType: Neumann
NeumannValue: 0
}
Boundary:
{
Id: 3
ConditionType: Neumann
NeumannValue: 0
}
Boundary:
{
Id: 4
ConditionType: Neumann
NeumannValue: 0
}
Boundary:
{
Id: 6
ConditionType: RFHeating
WhichMode: 0
Method: Gradient
Sigma: 5.8e+07
TargetGradient: 6e+07
DutyFactor: 0.00036
StartPoint: 0.0001, 0.0001, -0.017018
EndPoint: 0.0001, 0.0001, 0.017018
SymmetryFactor: 1
Directory: placeholder
Boundary:
{
Id: 5
ConditionType: Robin
RobinConstantFactor: 20000
RobinConstantValue: 440000
}
}
ElasticProblem:
{
MeshFile: RfGunBody.ncdf
BasisOrder: 2
CurvedSurfaces: on
MeshDump:
{
WriteDeformedEMMesh: on
MeshDeformScale: 1
WriteStressStrain: on
EMMeshInputDir: placeholder
}
LinearSolver:
{
Solver: CG
Preconditioner: DIAGONAL
AbsoluteTolerance: 1e-16
Tolerance: 1e-10
MaxIterations: 50000
}
VolumeMaterial:
{
Id: 1
PoissonsRation: 0.34
YoungsModulus: 1.17E+11
Density: 8960
ElasticAlpha: 1.70E-05
}
Boundary:
{
Id: 6
ConditionType: LFDetuning
WhichMode: 0
Omega3PId: 6
Method: Gradient
TargetGradient: 6e+07
GradientDirection: 0, 0, 1
SymmetryFactor: 0
StartPoint: 0.0001, 0.0001, -0.017018
EndPoint: 0.0001, 0.0001, 0.017018
Directory: placeholder
}
Boundary:
{
Id: 1
ConditionType: Mixed
MixedType: NEUMANN NEUMANN DIRICHLET
MixedValue: 0, 0, 0
}
Boundary:
{
Id: 2
ConditionType: Mixed
MixedType: DIRICHLET NEUMANN NEUMANN
MixedValue: 0, 0, 0
}
Boundary:
{
Id: 3
ConditionType: Mixed
MixedType: NEUMANN DIRICHLET NEUMANN
MixedValue: 0, 0, 0
}
Boundary:
{
Id: 4
ConditionType: Neumann
NeumannValue: 0
}
Boundary:
{
Id: 5
ConditionType: Neumann
NeumannValue: 0
}
}
......@@ -16,6 +16,7 @@ class BaseWriter(object):
def __init__(self):
self.base_indent = ''
self.name_prefix = None # needed to disambiguate atts for ThermoElastic
def start_command(self, name, indent=None, blank_line=True):
if indent is None:
......@@ -32,14 +33,29 @@ class BaseWriter(object):
def get_attribute(self, att_type):
'''Returns single attribute of specified type
'''
att_list = self.scope.sim_atts.findAttributes(att_type)
if not att_list:
raise Exception('Warning: no attributes of type %s' % att_type)
elif len(att_list) > 1:
elif len(att_list) > 1 and self.name_prefix is None:
message = ' Warning: expected single attrbute of type %s but found %d' % \
(att_type, len(att_list))
raise Exception(message)
elif len(att_list) > 1:
match_list = list()
for att in att_list:
if att.name().startswith(self.name_prefix):
match_list.append(att)
if not match_list:
raise Exception('Warning: no attributes of type %s matches name prefix %s' % \
(att_type, self.name_prefix))
elif len(match_list) > 1:
template = 'Warning: expected single attribute of type %s to matche name prefix %s but found %d'
raise Exception(template % (att_type, self.name_prefix, len(match_list)))
else:
return match_list[0]
# (else)
return att_list[0]
......
......@@ -20,8 +20,9 @@ class Tem3PWriter(basewriter.BaseWriter):
super(Tem3PWriter, self).__init__()
self.base_indent = ' ' # overwrite default in base object
self.elastic_materials = dict()
self.name_prefix = None # needed to disambiguate atts for ThermoElastic
self.solver = solver
if self.is_elastic_solver():
if self.is_elastic_solver() or solver == 'tem3p-thermo-elastic':
# Load the elastic materials table
source_dir = os.path.dirname(__file__)
path = os.path.join(source_dir, os.pardir, 'elastic-material.csv')
......@@ -42,23 +43,60 @@ class Tem3PWriter(basewriter.BaseWriter):
#print 'self.elastic_materials:', self.elastic_materials
def is_elastic_solver(self):
return self.solver in set(['tem3p-eigen', 'tem3p-structure', 'tem3p-harmonic'])
return self.solver in set(['tem3p-eigen', 'tem3p-elastic', 'tem3p-harmonic'])
def is_thermal_solver(self):
return self.solver in set(['tem3p-thermal-linear', 'tem3p-thermal-nonlinear'])
def write(self, scope):
'''
'''
self.scope = scope
if self.solver == 'tem3p-thermo-elastic':
self.start_command('ThermoElasticProblem', indent='')
self.scope.output.write(' RunId: 3\n')
self.finish_command(indent='')
# Write thermal section
categories = scope.sim_atts.analysisCategories('TEM3P Thermal Nonlinear')
scope.categories = list(categories)
print 'Using categories: %s' % scope.categories
self.solver = 'tem3p-thermal-nonlinear'
self.name_prefix = 'Thermal'
self.write_command()
# Write elastic section
categories = scope.sim_atts.analysisCategories('TEM3P Elastic')
scope.categories = list(categories)
self.solver = 'tem3p-elastic'
self.name_prefix = 'Elastic'
self.write_command()
# Restore self.solver
self.solver = 'tem3p-thermo-elastic'
self.name_prefix = None
scope.categories = list()
elif self.is_elastic_solver():
self.name_prefix = 'Elastic'
self.write_command()
elif self.is_thermal_solver():
self.name_prefix = 'Thermal'