Example of .Rep File
The .rep file may look something like the example shown below.
##***************************************************************************
## Copyright (c) 1994-2022 ALTAIR Engineering, Inc.
## All rights reserved.
## This source code is confidential and may not be disclosed.
##***************************************************************************
#===========================================================================
#
# "WindTunnel.rep": Generate a report for the WindTunnel problem
#
# To get a report, execute:
# acuReport -problem IM -file WindTunnel.rep -pdf
#
#===========================================================================
import acuCnf
import acuUnit
import string
import glob
import os
import os.path
import copy
import re
import acupu
import time
import math
import inspect
import numpy
import sys
import shutil
import subprocess
from acuFvx import AcuFvx, AcuPlot
from acuXmlParReader import AcuXmlParReader
from acuUtil import cnvStr2Val
#---------------------------------------------------------------------------
# getMaxFileInd:
#---------------------------------------------------------------------------
def getMaxFileInd( prefix, suffix ):
ind = -1
maxInd = -1
prefix = prefix + "."
suffix = "." + suffix
searchStr = str(prefix) + '*[0-9]' + str(suffix)
fileList = glob.glob( searchStr )
if len( fileList ) == 0: return -1
for mFile in fileList:
preFile = string.split( mFile, str(prefix) )
if len( preFile ) == 2:
sufFile = string.split( preFile[1], str(suffix) )
if len( sufFile ) == 2:
try:
ind = int( sufFile[0] )
if ind > maxInd:
maxInd = ind
except:
pass
return maxInd
#---------------------------------------------------------------------------
# getListVals: Get the entries of a list
#---------------------------------------------------------------------------
def getListVals( lstStrVal ):
""" Get the array value.
Argument:
aryStrVal - a sting contains array value
Output:
aryVal - Tha array values
"""
parValue = []
strLst = lstStrVal.split(',')
for item in strLst:
item = \
item.split('(')[-1].split(')')[0].strip().split('\"')[1].strip()
parValue.append( item )
return parValue
#---------------------------------------------------------------------
# Check the end of the array values and put "," after the last value
# if does not exist. It needed for findall()
#---------------------------------------------------------------------
if not _endAryReg.match( aryStrVal ):
indx = aryStrVal.find( "]" )
if indx == -1:
indx = aryStrVal.find( ")" )
aryStrVal = aryStrVal[:indx] + "," + aryStrVal[indx:]
parValue = []
lstVals = re.findall( _aryVals, aryStrVal )
for val in lstVals:
value = val #float( val[0] )
parValue.append( value )
return parValue
#---------------------------------------------------------------------------
# getArrayVals: Get the array Value
#---------------------------------------------------------------------------
def getArrayVals( aryStrVal, _endAryReg, _aryVals ):
""" Get the array value.
Argument:
aryStrVal - a sting contains array value
Output:
aryVal - Tha array values
"""
#---------------------------------------------------------------------
# Check the end of the array values and put "," after the last value
# if does not exist. It needed for findall()
#---------------------------------------------------------------------
if not _endAryReg.match( aryStrVal ):
indx = aryStrVal.find( "]" )
if indx == -1:
indx = aryStrVal.find( ")" )
aryStrVal = aryStrVal[:indx] + "," + aryStrVal[indx:]
parValue = []
lstVals = re.findall( _aryVals, aryStrVal )
for val in lstVals:
value = float( val[0] )
unit = val[1].strip( )
if unit != "":
value = acuUnit.convert( value, unit )
parValue.append( value )
return parValue
#===========================================================================
# dict2Val
#===========================================================================
def dict2Val( dict1 ):
return cnvStr2Val( dict1['type'], dict1['value'] )
#===========================================================================
# Read Vars
#===========================================================================
def readVars( fileName, wtComps ):
hmDic = {}
parDic = {}
fsiDic = {}
if not os.path.exists( fileName ):
for compName in wtComps:
hmDic[compName] = compName
return ( hmDic, parDic )
reader = AcuXmlParReader( None, fileName = fileName )
parDic = reader.getElementsDic( "ACS_PARS" )['ACS_PARS']
if 'ACS_FLEXIBLE_BODIES' in parDic:
for comp in parDic['ACS_FLEXIBLE_BODIES']:
component = dict2Val(
parDic['ACS_FLEXIBLE_BODIES'][comp]['component'])
fsiDic[comp] = []
for item in component:
fsiDic[comp].append( item )
return ( hmDic, parDic, fsiDic )
#===========================================================================
# Get Time History Info
#===========================================================================
def getMonitorPoints( parDic ):
othDir = {}
defVar = []
defLgndRng = []
if 'time_history_variables' in parDic['ACS_GLOBAL']:
defVar = dict2Val(parDic['ACS_GLOBAL']['time_history_variables'])
if 'time_history_legend_range' in parDic['ACS_GLOBAL']:
defLgndRng = dict2Val(
parDic['ACS_GLOBAL']['time_history_legend_range'])
if 'ACS_TIME_HISTORY_OUTPUTS' in parDic:
for item in parDic['ACS_TIME_HISTORY_OUTPUTS']:
othDir[item] = {}
othDir[item]['coords'] = dict2Val(
parDic['ACS_TIME_HISTORY_OUTPUTS'][item]['coordinates'])
othDir[item]['output'] = {}
othDir[item]['legend_range'] = {}
lgndRng = []
if 'legend_range' in parDic['ACS_TIME_HISTORY_OUTPUTS'][item]:
lgndRng = dict2Val(
parDic['ACS_TIME_HISTORY_OUTPUTS'][item]['legend_range'])
if 'variables' in parDic['ACS_TIME_HISTORY_OUTPUTS'][item]:
vars = dict2Val(
parDic['ACS_TIME_HISTORY_OUTPUTS'][item]['variables'])
for var in vars:
othDir[item]['output'][var] = []
try:
if lgndRng != []:
if isinstance(lgndRng[0], list):
othDir[item]['legend_range'][var] = \
[lgndRng[vars.index(var)][0],
lgndRng[vars.index(var)][1]]
else:
othDir[item]['legend_range'][var] = \
[lgndRng[0],lgndRng[1]]
except:
othDir[item]['legend_range'][var] = \
['Auto','Auto']
else:
for var in defVar:
othDir[item]['output'][var] = []
try:
if defLgndRng != []:
if isinstance(defLgndRng[0], list):
othDir[item]['legend_range'][var] = \
[defLgndRng[defVar.index(var)][0],
defLgndRng[defVar.index(var)][1]]
else:
othDir[item]['legend_range'][var] = \
[defLgndRng[0],defLgndRng[1]]
except:
othDir[item]['legend_range'][var] = \
['Auto','Auto']
return othDir
#===========================================================================
# Get Drag Info
#===========================================================================
def createResultData( rep, adb, compMap,
parDic, fsiDic, othDir,
rho, Aref, fDir=0,
tDir=1, cDir=2
):
try:
os.mkdir('Figures')
except:
pass
fsiFlag = False
if 'fsi' in parDic['ACS_GLOBAL']:
if dict2Val(parDic['ACS_GLOBAL']['fsi']):
fsiFlag = True
osiNames = adb.getOsiNames()
osiVars = adb.getOsiVarNames()
thPrts = adb.getOthNames()
othVars = adb.getOthVarNames()
bdyPrts = []
whlPrts = []
prsPrts = []
fsiPrts = {}
nFsiComps = 0
if 'ACS_COMPONENTS' in parDic:
for comp in parDic['ACS_COMPONENTS']:
if comp in osiNames or \
comp + " tri3 Fluid tet4" in osiNames:
if dict2Val(
parDic['ACS_COMPONENTS'][comp]['wtcomp']).find('WHEEL')\
!= -1:
whlPrts.append( comp )
if dict2Val(
parDic['ACS_COMPONENTS'][comp]['wtcomp']).find('BODY')\
!= -1:
bdyPrts.append( comp )
if dict2Val(
parDic['ACS_COMPONENTS'][comp]['wtcomp']).find('WT_INLET')\
!= -1:
inPrt = comp
if dict2Val(
parDic['ACS_COMPONENTS'][comp]['wtcomp']).find('POROUS')\
!= -1:
comp = "%s tri3 Fluid tet4" % comp
prsPrts.append( comp )
else:
if 'surface_output' in parDic['ACS_COMPONENTS'][comp]:
srfout = dict2Val(
parDic['ACS_COMPONENTS'][comp]['surface_output'])
if not srfout:
print "%s surface output is not active" % comp
else:
print "%s surface output does not exist" % comp
if 'ACS_FLEXIBLE_BODIES' in parDic:
for comp in parDic['ACS_FLEXIBLE_BODIES']:
component = dict2Val(
parDic['ACS_FLEXIBLE_BODIES'][comp]['component'])
fsiPrts[comp] = []
for item in component:
fsiPrts[comp].append( item )
nBdyPrts = len( bdyPrts )
nWhlPrts = len( whlPrts )
nPrsPrts = len( prsPrts )
nFsiPrts = 0
#fsiPrts = fsiDic
for item in fsiPrts:
nFsiPrts= nFsiPrts + len( fsiPrts[item] )
Uin = adb.getOsiValues( inPrt ,"velocity")
Ux = Uin[:,0]
Uy = Uin[:,1]
Uz = Uin[:,2]
Usum = Ux*Ux + Uy*Uy + Uz*Uz
U = numpy.sqrt( Usum )
Dr = 0.5 * rho * U * U * Aref
nSteps = adb.get('nOsiSteps',1)
osiSteps = adb.get('osiSteps',1)
osiTimes = adb.get('osiTimes',1)
DragBody = {}
DragAreaBody = {}
LiftBody = {}
CrossBody = {}
DragBodyAvg = {}
DragAreaBodyAvg = {}
LiftBodyAvg = {}
CrossBodyAvg = {}
TotDragBody = numpy.zeros( nSteps, dtype='d' )
TotDragAreaBody = numpy.zeros( nSteps, dtype='d' )
TotLiftBody = numpy.zeros( nSteps, dtype='d' )
TotCrossBody = numpy.zeros( nSteps, dtype='d' )
TotDrag = numpy.zeros( nSteps, dtype='d' )
TotDragArea = numpy.zeros( nSteps, dtype='d' )
TotLift = numpy.zeros( nSteps, dtype='d' )
TotCross = numpy.zeros( nSteps, dtype='d' )
As = 1
if nSteps > 50:
if 'avg_iter_coefficient' in parDic['ACS_GLOBAL']:
As = dict2Val(parDic['ACS_GLOBAL']['avg_iter_coefficient'])
else:
As = 50
for bdyPrt in bdyPrts:
trc = adb.getOsiValues( bdyPrt, "traction" )
DragBody[bdyPrt] = trc[:,fDir] / Dr
DragAreaBody[bdyPrt] = DragBody[bdyPrt] * Aref
LiftBody[bdyPrt] = trc[:,tDir] / Dr
CrossBody[bdyPrt] = trc[:,cDir] / Dr
TotDragBody = TotDragBody + DragBody[bdyPrt]
TotDragAreaBody = TotDragAreaBody + DragAreaBody[bdyPrt]
TotLiftBody = TotLiftBody + LiftBody[bdyPrt]
TotCrossBody = TotCrossBody + CrossBody[bdyPrt]
TotDrag = TotDrag + DragBody[bdyPrt]
TotDragArea = TotDragArea + DragAreaBody[bdyPrt]
TotLift = TotLift + LiftBody[bdyPrt]
TotCross = TotCross + CrossBody[bdyPrt]
DragBodyAvg[bdyPrt] = DragBody[bdyPrt][-As:].mean()
DragAreaBodyAvg[bdyPrt] = DragAreaBody[bdyPrt][-As:].mean()
LiftBodyAvg[bdyPrt] = LiftBody[bdyPrt][-As:].mean()
CrossBodyAvg[bdyPrt] = CrossBody[bdyPrt][-As:].mean()
DragPorous = {}
DragAreaPorous = {}
LiftPorous = {}
CrossPorous = {}
DragPorousAvg = {}
DragAreaPorousAvg = {}
LiftPorousAvg = {}
CrossPorousAvg = {}
TotDragPorous = numpy.zeros( nSteps, dtype='d' )
TotDragAreaPorous = numpy.zeros( nSteps, dtype='d' )
TotLiftPorous = numpy.zeros( nSteps, dtype='d' )
TotCrossPorous = numpy.zeros( nSteps, dtype='d' )
for prsPrt in prsPrts:
trc = adb.getOsiValues( prsPrt,
"traction" )
mtm = adb.getOsiValues( prsPrt,
"momentum_flux" )
DragPorous[prsPrt] = (trc[:,fDir] + mtm[:,fDir]) / Dr
DragAreaPorous[prsPrt] = DragPorous[prsPrt] * Aref
LiftPorous[prsPrt] = (trc[:,tDir] + mtm[:,tDir]) / Dr
CrossPorous[prsPrt] = (trc[:,cDir] + mtm[:,cDir]) / Dr
TotDragPorous = TotDragPorous + DragPorous[prsPrt]
TotDragAreaPorous = TotDragAreaPorous \
+ DragAreaPorous[prsPrt]
TotLiftPorous = TotLiftPorous + LiftPorous[prsPrt]
TotCrossPorous = TotCrossPorous + CrossPorous[prsPrt]
TotDrag = TotDrag + DragPorous[prsPrt]
TotDragArea = TotDragArea + DragAreaPorous[prsPrt]
TotLift = TotLift + LiftPorous[prsPrt]
TotCross = TotCross + CrossPorous[prsPrt]
DragPorousAvg[prsPrt] = DragPorous[prsPrt][-As:].mean()
DragAreaPorousAvg[prsPrt] = DragAreaPorous[prsPrt][-As:].mean()
LiftPorousAvg[prsPrt] = LiftPorous[prsPrt][-As:].mean()
CrossPorousAvg[prsPrt] = CrossPorous[prsPrt][-As:].mean()
DragWheel = {}
DragAreaWheel = {}
LiftWheel = {}
CrossWheel = {}
DragWheelAvg = {}
DragAreaWheelAvg= {}
LiftWheelAvg = {}
CrossWheelAvg = {}
TotDragWheel = numpy.zeros( nSteps, dtype='d' )
TotDragAreaWheel= numpy.zeros( nSteps, dtype='d' )
TotLiftWheel = numpy.zeros( nSteps, dtype='d' )
TotCrossWheel = numpy.zeros( nSteps, dtype='d' )
for whlPrt in whlPrts:
trc = adb.getOsiValues( whlPrt, "traction" )
DragWheel[whlPrt] = trc[:,fDir] / Dr
DragAreaWheel[whlPrt] = DragWheel[whlPrt] * Aref
LiftWheel[whlPrt] = trc[:,tDir] / Dr
CrossWheel[whlPrt] = trc[:,cDir] / Dr
TotDragWheel = TotDragWheel + DragWheel[whlPrt]
TotDragAreaWheel = TotDragAreaWheel \
+ DragAreaWheel[whlPrt]
TotLiftWheel = TotLiftWheel + LiftWheel[whlPrt]
TotCrossWheel = TotCrossWheel + CrossWheel[whlPrt]
TotDrag = TotDrag + DragWheel[whlPrt]
TotDragArea = TotDragArea + DragAreaWheel[whlPrt]
TotLift = TotLift + LiftWheel[whlPrt]
TotCross = TotCross + CrossWheel[whlPrt]
DragWheelAvg[whlPrt] = DragWheel[whlPrt][-As:].mean()
DragAreaWheelAvg[whlPrt]= DragAreaWheel[whlPrt][-As:].mean()
LiftWheelAvg[whlPrt] = LiftWheel[whlPrt][-As:].mean()
CrossWheelAvg[whlPrt] = CrossWheel[whlPrt][-As:].mean()
DragFsi = {}
DragAreaFsi = {}
LiftFsi = {}
CrossFsi = {}
DragFsiAvg = {}
DragAreaFsiAvg = {}
LiftFsiAvg = {}
CrossFsiAvg = {}
TotDragFsi = {}
TotDragAreaFsi = {}
TotLiftFsi = {}
TotCrossFsi = {}
MeshXDisplacement = {}
MeshYDisplacement = {}
MeshZDisplacement = {}
for item in fsiPrts:
TotDragFsi[item] = numpy.zeros( nSteps, dtype='d' )
TotDragAreaFsi[item] = numpy.zeros( nSteps, dtype='d' )
TotLiftFsi[item] = numpy.zeros( nSteps, dtype='d' )
TotCrossFsi[item] = numpy.zeros( nSteps, dtype='d' )
MeshXDisplacement[item] = numpy.zeros( nSteps, dtype='d' )
MeshYDisplacement[item] = numpy.zeros( nSteps, dtype='d' )
MeshZDisplacement[item] = numpy.zeros( nSteps, dtype='d' )
for fsiPrt in fsiPrts[item]:
trc = adb.getOsiValues( fsiPrt,
"traction" )
disp = adb.getOsiValues( fsiPrt,
"mesh_displacement" )
DragFsi[fsiPrt] = trc[:,fDir] / Dr
DragAreaFsi[fsiPrt] = DragFsi[fsiPrt] * Aref
LiftFsi[fsiPrt] = trc[:,tDir] / Dr
CrossFsi[fsiPrt] = trc[:,cDir] / Dr
TotDragFsi[item] = TotDragFsi[item] + DragFsi[fsiPrt]
TotDragAreaFsi[item] = TotDragAreaFsi[item] \
+ DragAreaFsi[fsiPrt]
TotLiftFsi[item] = TotLiftFsi[item] + LiftFsi[fsiPrt]
TotCrossFsi[item] = TotCrossFsi[item] \
+ CrossFsi[fsiPrt]
TotDrag = TotDrag + DragFsi[fsiPrt]
TotDragArea = TotDragArea + DragAreaFsi[fsiPrt]
TotLift = TotLift + LiftFsi[fsiPrt]
TotCross = TotCross + CrossFsi[fsiPrt]
DragFsiAvg[fsiPrt] = DragFsi[fsiPrt][-As:].mean()
DragAreaFsiAvg[fsiPrt] = DragAreaFsi[fsiPrt][-As:].mean()
LiftFsiAvg[fsiPrt] = LiftFsi[fsiPrt][-As:].mean()
CrossFsiAvg[fsiPrt] = CrossFsi[fsiPrt][-As:].mean()
MeshXDisplacement[item] = MeshXDisplacement[item] + disp[:,0]
MeshYDisplacement[item] = MeshYDisplacement[item] + disp[:,1]
MeshZDisplacement[item] = MeshZDisplacement[item] + disp[:,2]
print "plotting time history"
timeHistory_Disp = {}
othVarNms = othVars
if 'velocity' in othVars:
othVarNms = othVarNms + [ 'x_velocity', 'y_velocity',
'z_velocity', 'velocity_magnitude' ]
if 'mesh_displacement' in othVars:
othVarNms = othVarNms + [ 'x_mesh_displacement',
'y_mesh_displacement', 'z_mesh_displacement' ]
def which(lst, var):
for element in lst:
if element in var:
return element
return False
coordDic = { "x_" : 0, "y_" : 1, "z_" : 2 }
scalarVar = [ '_magnitude' ]
for entryName, entry in othDir.iteritems():
if entryName not in thPrts:
print "monitor point %s not in database!" % entryName
continue
if 'velocity' in entry['output']:
if 'velocity' in othVars:
if 'x_velocity' not in entry['output']:
entry['output'][u'x_velocity'] = []
entry['legend_range'][u'x_velocity'] = \
entry['legend_range'][u'velocity']
if 'y_velocity' not in entry['output']:
entry['output'][u'y_velocity'] = []
entry['legend_range'][u'y_velocity'] = \
entry['legend_range'][u'velocity']
if 'z_velocity' not in entry['output']:
entry['output'][u'z_velocity'] = []
entry['legend_range'][u'z_velocity'] = \
entry['legend_range'][u'velocity']
else:
if 'x_velocity' in entry['output']:
entry['output'].pop(u'x_velocity')
entry['legend_range'].pop(u'x_velocity')
if 'y_velocity' in entry['output']:
entry['output'].pop(u'y_velocity')
entry['legend_range'].pop(u'y_velocity')
if 'z_velocity' in entry['output']:
entry['output'].pop(u'z_velocity')
entry['legend_range'].pop(u'z_velocity')
entry['output'].pop(u'velocity')
entry['legend_range'].pop(u'velocity')
if 'mesh_displacement' in entry['output']:
if 'mesh_displacement' in othVars:
if 'x_mesh_displacement' not in entry['output']:
entry['output'][u'x_mesh_displacement'] = []
entry['legend_range'][u'x_mesh_displacement'] = \
entry['legend_range'][u'mesh_displacement']
if 'y_mesh_displacement' not in entry['output']:
entry['output'][u'y_mesh_displacement'] = []
entry['legend_range'][u'y_mesh_displacement'] = \
entry['legend_range'][u'mesh_displacement']
if 'z_mesh_displacement' not in entry['output']:
entry['output'][u'z_mesh_displacement'] = []
entry['legend_range'][u'z_mesh_displacement'] = \
entry['legend_range'][u'mesh_displacement']
else:
if 'x_mesh_displacement' in entry['output']:
entry['output'].pop(u'x_mesh_displacement')
entry['legend_range'].pop(u'x_mesh_displacement')
if 'y_mesh_displacement' in entry['output']:
entry['output'].pop(u'y_mesh_displacement')
entry['legend_range'].pop(u'y_mesh_displacement')
if 'z_mesh_displacement' in entry['output']:
entry['output'].pop(u'z_mesh_displacement')
entry['legend_range'].pop(u'z_mesh_displacement')
entry['output'].pop(u'mesh_displacement')
entry['legend_range'].pop(u'mesh_displacement')
for output,outputArray in entry['output'].iteritems():
if output not in othVarNms:
print "given output %s not a valid output" % output
continue
arrayInd = which(coordDic, output)
if arrayInd:
outputVar = output.split(arrayInd,1)[1]
if outputVar != 'magnitude' and outputVar != 'viscosity':
index = coordDic[arrayInd]
entry['output'][output] = numpy.asarray(
adb.getOthValues(entryName, 0, outputVar)[:,index])
continue
scalarInd = which( scalarVar, output )
if scalarInd:
outputVar = output.split(scalarInd,1)[0]
xValue = numpy.asarray(
adb.getOthValues(entryName,0,outputVar)[:,0])
yValue = numpy.asarray(
adb.getOthValues(entryName,0,outputVar)[:,1])
zValue = numpy.asarray(
adb.getOthValues(entryName,0,outputVar)[:,2])
value = numpy.sqrt(
xValue**2 + yValue**2 + zValue**2 )
else:
value = numpy.asarray(
adb.getOthValues( entryName, 0, output)[:,0])
entry['output'][output] = value
#############################################################
# Add tables to the report
#############################################################
Cd = 0.0
Cl = 0.0
Cc = 0.0
Ca = 0.0
global dataTable
dataTable = [ ( "Surface", "Drag Coefficient",
"Lift Coefficient", "Cross Coefficient" ) ]
global fsiTable
fsiTable = [ ( "Surface", "Drag Coefficient",
"Lift Coefficient", "Cross Coefficient") ]
for bdyPrt in bdyPrts:
sName = str(bdyPrt)
sName = string.replace( sName, "_", "\_" )
dCoeff = "%6.5f" % DragBodyAvg[bdyPrt]
lCoeff = "%6.5f" % LiftBodyAvg[bdyPrt]
cCoeff = "%6.5f" % CrossBodyAvg[bdyPrt]
dataTable.append( ( sName, dCoeff, lCoeff, cCoeff ) )
Cd = Cd + DragBodyAvg[bdyPrt]
Cl = Cl + LiftBodyAvg[bdyPrt]
Cc = Cc + CrossBodyAvg[bdyPrt]
for whlPrt in whlPrts:
sName = str(whlPrt)
sName = string.replace( sName, "_", "\_" )
dCoeff = "%6.5f" % DragWheelAvg[whlPrt]
lCoeff = "%6.5f" % LiftWheelAvg[whlPrt]
cCoeff = "%6.5f" % CrossWheelAvg[whlPrt]
dataTable.append( ( sName, dCoeff, lCoeff, cCoeff ) )
Cd = Cd + DragWheelAvg[whlPrt]
Cl = Cl + LiftWheelAvg[whlPrt]
Cc = Cc + CrossWheelAvg[whlPrt]
for item in sorted(fsiPrts.iterkeys()):
fCd = 0.0
fCl = 0.0
fCc = 0.0
fCa = 0.0
for fsiPrt in fsiPrts[item]:
fCd = fCd + DragFsiAvg[fsiPrt]
fCl = fCl + LiftFsiAvg[fsiPrt]
fCc = fCc + CrossFsiAvg[fsiPrt]
fCa = fCa + DragAreaFsiAvg[fsiPrt]
sName = (str(item)).replace( "_" , " " )
fCd = "%6.5f" % fCd
fCl = "%6.5f" % fCl
fCc = "%6.5f" % fCc
fCa = "%6.5f" % fCa
fsiTable.append( ( sName, fCd, fCl, fCc ) )
for prsPrt in prsPrts:
sName = str(prsPrt)
if sName.endswith(' tri3 Fluid tet4'):
sName = sName[:-16]
sName = string.replace( sName, "_", "\_" )
dCoeff = "%6.5f" % DragPorousAvg[prsPrt]
lCoeff = "%6.5f" % LiftPorousAvg[prsPrt]
cCoeff = "%6.5f" % CrossPorousAvg[prsPrt]
dataTable.append( ( sName, dCoeff, lCoeff, cCoeff ) )
Cd = Cd + DragPorousAvg[prsPrt]
Cl = Cl + LiftPorousAvg[prsPrt]
Cc = Cc + CrossPorousAvg[prsPrt]
dataTable.append( ( "Total ", Cd, Cl, Cc ) )
global areaDataTable
areaDataTable = [ ( "Surface", "Drag Area" ) ]
for bdyPrt in bdyPrts:
sName = str(bdyPrt)
sName = string.replace( sName, "_", "\_" )
aCoeff = "%6.5f" % DragAreaBodyAvg[bdyPrt]
areaDataTable.append( ( sName, aCoeff ) )
Ca = Ca + DragAreaBodyAvg[bdyPrt]
for whlPrt in whlPrts:
sName = str(whlPrt)
sName = string.replace( sName, "_", "\_" )
aCoeff = "%6.5f" % DragAreaWheelAvg[whlPrt]
areaDataTable.append( ( sName, aCoeff ) )
Ca = Ca + DragAreaWheelAvg[whlPrt]
for item in fsiPrts:
for fsiPrt in fsiPrts[item]:
sName = str(fsiPrt)
sName = string.replace( sName, "_", "\_" )
aCoeff = "%6.5f" % DragAreaFsiAvg[fsiPrt]
for prsPrt in prsPrts:
sName = str(prsPrt)
if sName.endswith(' tri3 Fluid tet4'):
sName = sName[:-16]
sName = string.replace( sName, "_", "\_" )
aCoeff = "%6.5f" % DragAreaPorousAvg[prsPrt]
areaDataTable.append( ( sName, aCoeff ) )
Ca = Ca + DragAreaPorousAvg[prsPrt]
areaDataTable.append( ( "Total ", Ca ) )
#############################################################
# Add curves to the report
#############################################################
if sys.platform == "win32":
lnTyp = "dotted"
else:
lnTyp = "solid"
if 'simulationType' in parDic['ACS_GLOBAL']:
if dict2Val(parDic['ACS_GLOBAL']['simulationType'])=='transient':
xLabel = "Time (s)"
xTimes = osiTimes
else:
xLabel = "Iterations"
xTimes = osiSteps
else:
xLabel = "Iterations"
xTimes = osiSteps
yLabel = "Coefficients"
crvList1= []
curve1 = Curve(xTimes, TotDrag, name="Drag Coeff", color="Green",
lineType = lnTyp) #, symbol = "circle")
crvList1.append( curve1 )
curve2 = Curve(xTimes, TotLift, name="Lift Coeff", color="Red",
lineType = lnTyp) #, symbol = "square")
crvList1.append( curve2 )
curve3 = Curve(xTimes, TotCross, name="Cross Coeff", color="Blue",
lineType = lnTyp) #, symbol = "diamond")
crvList1.append( curve3 )
curve4 = Curve(xTimes, TotDragArea, name="Drag Area", color="Black",
lineType = lnTyp) #, symbol = "diamond")
crvList1.append( curve4 )
yMin = -0.1
yMax = 0.5
xMin = xTimes[0]
xMax = xTimes[-1]
if nSteps > 10:
yMin = min( TotDrag[10:,].min(),TotLift[10:,].min(),
TotCross[10:,].min(),TotDragArea[10:,].min()) * 0.8
yMax = max( TotDrag[10:,].max(),TotLift[10:,].max(),
TotCross[10:,].max(),TotDragArea[10:,].max()) * 1.2
if sys.platform == "win32":
x_data = {}
y_data = {}
x_data['all'] = xTimes
y_data['Drag Coeff'] = TotDrag
y_data['Lift Coeff'] = TotLift
y_data['Cross Coeff'] = TotCross
y_data['Drag Area'] = TotDragArea
fvPlots = AcuPlot()
fvPlots.addPlot(x_data = x_data, y_data = y_data,
x_label = xLabel, y_label = yLabel,
title = "Drag Plots", xRange = (xMin, xMax),
yRange = (yMin, yMax))
if len(othDir) != 0:
for entry in othDir:
for output in othDir[entry]['output']:
try:
yMin = othDir[entry]['legend_range'][output][0]
yMax = othDir[entry]['legend_range'][output][1]
except:
yMin = 'Auto'
yMax = 'Auto'
if yMin == 'Auto':
try:
yMin = othDir[entry]['output'][output].min()
except:
yMin = min(othDir[entry]['output'][output])
else:
yMin = float(yMin)
if yMax == 'Auto':
try:
yMax = othDir[entry]['output'][output].max()
except:
yMax = max(othDir[entry]['output'][output])
else:
yMax = float(yMax)
fvPlots.addPlot(
x_data = x_data,
y_data = {output:othDir[entry]['output'][output]},
x_label = xLabel,
y_label = output,
title = '%s_%s' % ( entry, output ),
xRange = (xMin, xMax),
yRange = (yMin, yMax) )
fvPlots.createPlots()
else:
global plot1
plot1 = Plot2D(crvList1, width = 800,height = 600,
xLabel = xLabel, yLabel = yLabel,
yRange = [yMin,yMax],gridFlag= True )
if len(othDir) != 0:
for entry in othDir:
for output in othDir[entry]['output']:
try:
yMin = othDir[entry]['legend_range'][output][0]
yMax = othDir[entry]['legend_range'][output][1]
except:
yMin = 'Auto'
yMax = 'Auto'
if yMin == 'Auto':
try:
yMin = othDir[entry]['output'][output].min()
except:
yMin = min(othDir[entry]['output'][output])
else:
yMin = float(yMin)
if yMax == 'Auto':
try:
yMax = othDir[entry]['output'][output].max()
except:
yMax = max(othDir[entry]['output'][output])
else:
yMax = float(yMax)
crvls = []
crvnm = '%s_%s' % (entry, output)
crvnm = crvnm.replace(' ', '_')
curvv = Curve(xTimes, othDir[entry]['output'][output],
name = crvnm, color = "Red",
lineType = lnTyp) #, symbol = "circle")
crvls.append( curvv )
curfn = 'Figures/%s' % crvnm
optDir[crvnm] = Plot2D(
crvls, width = 800, height = 600,
xLabel = xLabel, yLabel = output,
xRange = [xMin, xMax],
yRange = [yMin, yMax], gridFlag = True,
fileName = curfn)
fsiFlag = False
if 'fsi' in parDic['ACS_GLOBAL']:
if dict2Val(parDic['ACS_GLOBAL']['fsi']):
fsiFlag = True
return
if not fsiFlag:
return
#############################################################
# MESH DISPLACEMENTS - already return called
#############################################################
colortable = [ 'Green', 'Red', 'Blue', 'Yellow', 'Black' ]
colortable = colortable + colortable
#symboltable = [ 'circle', 'square']
#for i in range(8):
#symboltable.append('diamond')
xDisplacements = []
yDisplacements = []
zDisplacements = []
for item,ind in zip( sorted( fsiPrts.iterkeys() ),
range( len( fsiPrts ) ) ):
tmpCrv = Curve(xTimes,
MeshXDisplacement[item],
name = "mesh_x_displacement " + item,
color = colortable[ind],
lineType= lnTyp,
#symbol = symboltable[ind]
)
xDisplacements.append( tmpCrv )
tmpCrv = Curve(xTimes,
MeshYDisplacement[item],
name ="mesh_y_displacement " + item,
color =colortable[ind],
lineType= lnTyp,
#symbol = symboltable[ind]
)
yDisplacements.append( tmpCrv )
tmpCrv = Curve(xTimes,
MeshZDisplacement[item],
name ="mesh_z_displacement " + item,
color =colortable[ind],
lineType= lnTyp,
#symbol = symboltable[ind]
)
zDisplacements.append( tmpCrv )
### x displacement plot
yMin = 1000
yMax = -1000
for item in MeshXDisplacement:
yMin = min( yMin, MeshXDisplacement[item].min() )
yMax = max( yMax, MeshXDisplacement[item].max() )
yLabel = "mesh_x_displacement in [m]"
plotX = Plot2D(
xDisplacements, width = 800, height = 600,
xLabel = xLabel, yLabel = yLabel,
yRange = [ yMin * 0.8 , yMax * 1.2 ],
gridFlag= True
)
### y displacement plot
yMin = 1000
yMax = -1000
for item in MeshYDisplacement:
yMin = min( yMin, MeshYDisplacement[item].min() )
yMax = max( yMax, MeshYDisplacement[item].max() )
yLabel = "mesh_y_displacement in [m]"
plotY = Plot2D(
yDisplacements, width = 800, height = 600,
xLabel = xLabel, yLabel = yLabel,
yRange = [ yMin * 0.8 , yMax * 1.2 ],
gridFlag= True
)
### z displacement plot
yMin = 1000
yMax = -1000
for item in MeshZDisplacement:
yMin = min( yMin, MeshZDisplacement[item].min() )
yMax = max( yMax, MeshZDisplacement[item].max() )
yLabel = "mesh_z_displacement in [m]"
plotZ = Plot2D(
zDisplacements, width = 800, height = 600,
xLabel = xLabel, yLabel = yLabel,
yRange = [ yMin * 0.8 , yMax * 1.2 ],
gridFlag= True )
rep.beginBullet()
rep.addItem("The mesh displacement in x-direction for the different"\
" FSI components is plotted in Figure"\
" \\ref{fig:xDisplacements}.", name = "" )
rep.endBullet()
rep.addFigure( plotX, "center", "x-displacement",
1.0/imgFct, ref="fig:xDisplacements" )
rep.beginBullet()
rep.addItem("The mesh displacement in y-direction for the different"\
" FSI components is plotted in Figure"\
" \\ref{fig:yDisplacements}.", name = "" )
rep.endBullet()
rep.addFigure( plotY, "center", "y-displacement",
1.0/imgFct, ref="fig:yDisplacements" )
rep.beginBullet()
rep.addItem("The mesh displacement in z-direction for the different"\
" FSI components is plotted in Figure"\
" \\ref{fig:zDisplacements}.", name = "" )
rep.endBullet()
rep.addFigure( plotZ, "center", "z-displacement",
1.0/imgFct, ref="fig:zDisplacements" )
#===========================================================================
# Residual and Solution ratio
#===========================================================================
def createResidualSolutionRatios( rep, adb ):
'''
#tStp = adb.getSteps()
timeSecs= adb.get('times')
pressure= adb.getResRatioData( "pressure", type = "final" )
eddy = adb.getResRatioData( "eddy-viscosity", type = "final" )
velocity= adb.getResRatioData( "velocity", type = "final" )
pTim = pressure[1]
vTim = velocity[1]
eTim = eddy[1]
pRes = pressure[2]
vRes = velocity[2]
eRes = eddy[2]
if len(pTim) != len(pRes):
pRes = pRes[:len(pRes)-1]
vRes = vRes[:len(vRes)-1]
eRes = eRes[:len(eRes)-1]
if sys.platform == "win32":
lnTyp = "dotted"
else:
lnTyp = "solid"
curve1 = Curve( pTim, pRes, name = "Pressure", color = "blue",
symbol="circle", lineType = lnTyp )
curve2 = Curve( vTim, vRes, name = "Velocity", color = "red",
symbol="square", lineType = lnTyp )
curve3 = Curve( eTim, eRes, name = "Eddy Viscosity", color = "green",
symbol="diamond", lineType = lnTyp )
rcrvList= []
rcrvList.append( curve1 )
rcrvList.append( curve2 )
rcrvList.append( curve3 )
fname = Plot2D(rcrvList, width =1200,
height =800, resScale= 2,
xLabel = "Time (s)", yLog = True,
yLabel = "Residual Ratio", gridFlag= True,
fileName= "resratio", fileType= "png" )
pressure= adb.getSolRatioData( "pressure", type = "final" )
eddy = adb.getSolRatioData( "eddy-viscosity", type = "final" )
velocity= adb.getSolRatioData( "velocity", type = "final" )
pTim = pressure[1]
vTim = velocity[1]
eTim = eddy[1]
pSol = pressure[2]
vSol = velocity[2]
eSol = eddy[2]
if len(pTim) != len(pSol):
pSol= pSol[:len(pSol)-1]
vSol= vSol[:len(vSol)-1]
eSol= eSol[:len(eSol)-1]
curve4 = Curve( pTim, pSol, name = "Pressure", color = "blue",
symbol="circle", lineType = lnTyp )
curve5 = Curve( vTim, vSol, name = "Velocity", color = "red",
symbol="square" , lineType = lnTyp )
curve6 = Curve( eTim, eSol, name = "Eddy Viscosity", color = "green",
symbol="diamond" , lineType = lnTyp )
scrvList= []
scrvList.append( curve4 )
scrvList.append( curve5 )
scrvList.append( curve6 )
fname = Plot2D(scrvList, width =1200, height =800,
resScale= 2,
xLabel = "Time (s)", yLog = True,
yLabel = "Solution Ratio", gridFlag= True,
fileName= "solratio", fileType= "png" )
'''
pass
#===========================================================================
# animation
#===========================================================================
def createVideo( lZeros ):
homeDir = os.getenv( 'ACUSIM_HOME', 'none' )
verDir = os.getenv( 'ACUSIM_VERSION', 'none' )
machineDir = os.getenv( 'ACUSIM_MACHINE', 'none' )
acuDir = os.path.join( homeDir , machineDir )
if sys.platform == "win32":
acuDir = os.path.join(
os.path.join( acuDir, 'base'),
'ImageMagick' )
vidExec = os.path.join( acuDir, 'ffmpeg' )
else:
acuDir = os.path.join(
os.path.join( acuDir, 'base'),
'bin' )
vidExec = os.path.join( acuDir, 'ffmpeg' )
os.chdir('Animation')
extension = ( "%%0%dd" % lZeros ) % 1
testBase = glob.glob( '*_%s.*' % extension )
if not testBase:
print "no files to convert"
os.chdir('..')
return
ext = testBase[0].rsplit('.')[-1]
for ind,item in enumerate(testBase):
testBase[ind] = item.split('_%s.' % extension)[0]
nOutputs = len( glob.glob( testBase[0] + '*' ) )
if nOutputs >= 50:
frate = 15
elif nOutputs >= 10:
frate = 7
else:
frate = 1
for base in testBase:
vidCmd = [ vidExec, '-f', 'image2', '-r', '%d' % frate, '-i',
'%s_%%0%dd.%s' % (base, lZeros , ext),
'-vcodec','copy', '-y', '%s.mp4' % base ]
proc = subprocess.Popen(vidCmd , stdout=subprocess.PIPE,
stderr=subprocess.PIPE )
proc.wait()
os.chdir('..')
#===========================================================================
# Images
#===========================================================================
def createImages( rep, compMap, parDic, fsiDic,
fDir=0, tDir=1, cDir=2, rho=1.225
):
print "enter images"
if 'flow_direction' in parDic['ACS_GLOBAL']:
fDir = dict2Val( parDic['ACS_GLOBAL']['flow_direction'] )
if 'top_direction' in parDic['ACS_GLOBAL']:
tDir = dict2Val( parDic['ACS_GLOBAL']['top_direction'] )
if 'cross_direction' in parDic['ACS_GLOBAL']:
cDir = dict2Val( parDic['ACS_GLOBAL']['cross_direction'] )
cbbox = (0.0,1.0,0.0,1.0,0.0,1.0)
tbbox = (-1.0,6.0,-2.0,2.0,0.0,4.0)
fsiBbox = {}
angle_axis_from = (4.0,0.7,-4.0)
Vin = 1.0
if "angle_axis_from" in parDic['ACS_GLOBAL']:
angle_axis_from = dict2Val(
parDic['ACS_GLOBAL']['angle_axis_from'] )
if "zoom" in parDic['ACS_GLOBAL']:
zoom = dict2Val( parDic['ACS_GLOBAL']['zoom'] )
if "inletVelocity" in parDic['ACS_GLOBAL']:
Vin = dict2Val( parDic['ACS_GLOBAL']['inletVelocity'] )
if "body_bounding_box" in parDic['ACS_GLOBAL']:
cbbox = dict2Val( parDic['ACS_GLOBAL']['body_bounding_box'] )
if "tunnel_bounding_box" in parDic['ACS_GLOBAL']:
tbbox = dict2Val( parDic['ACS_GLOBAL']['tunnel_bounding_box'] )
if 'ACS_FLEXIBLE_BODIES' in parDic:
for comp in parDic['ACS_FLEXIBLE_BODIES']:
fsiBbox[comp]= dict2Val(
parDic['ACS_FLEXIBLE_BODIES'][comp]['bounding_box'] )
( Bx1, Bx2, By1, By2, Bz1, Bz2 ) = cbbox
Bxa = 0.5 * ( Bx1+Bx2 )
Bya = 0.5 * ( By1+By2 )
Bza = 0.5 * ( Bz1+Bz2 )
( Tx1, Tx2, Ty1, Ty2, Tz1, Tz2 ) = tbbox
Txa = 0.5 * ( Tx1+Tx2 )
Tya = 0.5 * ( Ty1+Ty2 )
Tza = 0.5 * ( Tz1+Tz2 )
if tDir == 1:
axis_up = (0,1,0)
elif tDir == 2:
axis_up = (0,0,1)
elif tDir == 0:
axis_up = (1,0,0)
if fDir == 0:
Bxf = Bx1
Tyf = Ty1
if tDir == 1:
Byf = By2
Bzf = Bz1
Tyf = Ty2
Tzf = Tz1
if tDir == 2:
Bzf = Bz2
Byf = By1
Tzf = Tz2
Tyf = Ty1
bdyType = []
botType = []
fsiType = {}
if 'ACS_FLEXIBLE_BODIES' in parDic:
for comp in parDic['ACS_FLEXIBLE_BODIES']:
component = dict2Val(
parDic['ACS_FLEXIBLE_BODIES'][comp]['component'])
fsiType[comp] = []
for item in component:
fsiType[comp].append( "OSF: %s" % str(item) )
inType = []
prsType = []
osiNames = adb.getOsiNames()
if 'ACS_COMPONENTS' in parDic:
for comp in parDic['ACS_COMPONENTS']:
if comp in osiNames or \
comp + " tri3 Fluid tet4" in osiNames:
ikey = dict2Val(
parDic['ACS_COMPONENTS'][comp]['wtcomp'])
if (ikey.find( 'WHEEL' )!= -1 \
or ikey.find( 'BODY' ) != -1 \
or ikey.find( 'flex' ) != -1 ):
bdyStr = "OSF: %s" % str(comp)
bdyType.append( bdyStr )
if ikey.find( 'WT_BOTTOM' ) != -1:
botStr = "SBC: %s" % str(comp)
botType.append( botStr )
if ikey.find( 'WT_INLET' ) != -1:
inStr = "SBC: %s" % str(comp)
inType.append( inStr )
if ikey.find('POROUS') != -1:
prsStr = "OSF: %s tri3 Fluid tet4" % str(comp)
prsType.append( prsStr )
bdyType.append( prsStr )
else:
if 'surface_output' in parDic['ACS_COMPONENTS'][comp]:
srfout = dict2Val(
parDic['ACS_COMPONENTS'][comp]['surface_output'])
if not srfout:
print "%s surface output is not active" % comp
else:
print "%s surface output does not exist" % comp
botTup = tuple( botType )
bdyTup = tuple( bdyType )
inTup = tuple( inType )
prsTup = tuple( prsType )
###create fsi view factors
fsiView = {}
fsiSideL = {}
fsiSideR = {}
fsiTop = {}
for bc in fsiType:
fsiView[bc] = {}
( fx1, fx2, fy1, fy2, fz1, fz2 )= fsiBbox[bc]
c1, c2, c3 = (fx1+fx2)/2, (fy1+fy2)/2, (fz1+fz2)/2
center = "%6.3f %6.3f %6.3f" % ( c1, c2, c3 )
zoomArr = [ fx2-fx1, fy2-fy1, fz2-fz1 ]
zoomArr.sort()
zoomFsi = zoomArr[2]/zoomArr[0]
zoomFsi = zoomFsi * 10
if tDir == 2:
fTopY = c2
fTopZ = fz2 + zoomArr[2]
fLeftY = fy1 - zoomArr[2]
fLeftZ = c3
fRightY = fy2 + zoomArr[2]
fRightZ = c3
## check if flexible component is
## left or right of the body center
if (Bya - fy1 ) >= 0:
lf1, lf2, lf3 = \
c1 - zoomArr[2], c2 - zoomArr[2], c3 + zoomArr[2] / 2
else:
lf1, lf2, lf3 = \
c1 - zoomArr[2], c2 + zoomArr[2], c3 + zoomArr[2] / 2
else:
fTopY = fy2 + zoomArr[2]
fTopZ = c3
fLeftY = c2
fLeftZ = fz1 - zoomArr[2]
fRightY = c2
fRightZ = fz2 + zoomArr[2]
if (Bza - fz2) >= 0:
lf1, lf2, lf3 = \
c1 - zoomArr[2], c2 + zoomArr[2], c3 - zoomArr[2] / 2
else:
lf1, lf2, lf3 = \
c1 - zoomArr[2], c2 + zoomArr[2], c3 + zoomArr[2] / 2
fsiView[bc]['axis_from'] = ( lf1, lf2, lf3 )
fsiView[bc]['axis_at'] = ( c1, c2, c3 )
fsiView[bc]['axis_up'] = axis_up
fsiView[bc]['center'] = center
fsiView[bc]['zoom'] = zoomFsi
fsiView[bc]['outline'] = "off"
fsiSideL[bc] = copy.copy( fsiView[bc] )
fsiSideL[bc]['axis_from'] = ( c1, fLeftY, fLeftZ )
fsiSideR[bc] = copy.copy( fsiView[bc] )
fsiSideR[bc]['axis_from'] = ( c1, fRightY, fRightZ )
fsiTop[bc] = copy.copy( fsiView[bc] )
fsiTop[bc]['axis_from'] = ( c1, fTopY, fTopZ )
##################
### ANIMATION ###
##################
if 'animation' in parDic['ACS_GLOBAL']:
animation = dict2Val(parDic['ACS_GLOBAL']['animation'])
digits = -1
else:
animation = False
if animation: #if animation == 'True':
print "enter animation"
try:
os.mkdir('Animation')
except:
pass
nSteps = adb.get( 'nSteps' )
if 'outputFrequency' in parDic['ACS_GLOBAL']:
outputFreq = dict2Val(
parDic['ACS_GLOBAL']['outputFrequency'] )
if 'saved_states' in parDic['ACS_GLOBAL']:
nSavedStates= dict2Val( parDic['ACS_GLOBAL']['saved_states'])
startTimeStep = nSteps - (nSavedStates - 1) * outputFreq
center = "%6.3f %6.3f %6.3f" % (Bxa + (Bx2-Bxa)/2,
Bya, Bz2 + Bz2 )
sideView = {}
sideView['axis_at'] = ( Bxa, Bya, Bza )
sideView['axis_from'] = ( Bxa, Byf, Bza )
sideView['center'] = center
sideView['zoom'] = (Bx2 - Bx1) / (Bz2 - Bz1) * 2
fvxObj = AcuFvx( logFile = "./%s" % logFile,
transient="on",
transStart = startTimeStep,
fvxFile = fvxFile )
fvxObj.writeVerbatim(text = 'fv_script("SIZE 640 360")' )
fvxObj.setBackground(color = "white" )
fvxObj.addViewTable(name = "view_table_1",
zoom = sideView['zoom'],
angle_axis_at = sideView['axis_at'],
angle_axis_up = axis_up,
angle_axis_from = sideView['axis_from'],
axis_markers = "on",
outline = "off",)
fvxObj.writeViewTable( "view_table_1" )
tmpdic ={'center':sideView['center']}
fvxObj.modifyView( name = "view_table_1",
dTable = {'center':sideView['center']} )
fvxObj.addBndSrf( "bnd_surf_bdy",
types = bdyTup,
show_mesh ="off",
scalar_func ="none",
transparency= 0.0 )
fvxObj.writeBndSrf( "bnd_surf_bdy" )
fvxObj.addCrdSrf( name = "crd_surf_y",
axis = "Y",
y_axis_current = Bya,
scalar_func = "velocity_magnitude" )
fvxObj.writeCrdSrf( name = "crd_surf_y" )
fvxObj.createDisplacementFormula( name="vwtDisplacement" )
for bc in fsiType:
bndName = "bnd_surf_fsi_%s" % str(bc)
crdName = "crd_surf_fsi_%s" % str(bc)
fsiTup = tuple( fsiType[bc] )
fvxObj.addBndSrf( bndName,
types = fsiTup,
show_mesh ="off",
scalar_func ="vwtDisplacement",
transparency= 0.0,
visibility ="off" )
fvxObj.writeBndSrf( bndName )
fvxObj.addCrdSrf( name = crdName,
axis = "Y",
y_axis_current = c2,
scalar_func = "velocity_magnitude",
transparency = 0.2,
visibility = "off" )
fvxObj.writeCrdSrf( crdName )
## go through transient loop and create images
counter = 0
digits = len( str(( nSteps - startTimeStep ) / outputFreq + 1 ))
for ts in range( startTimeStep, nSteps + 1, outputFreq ):
counter = counter + 1
strCounter = ("%%0%dd" % digits) % counter
fvxObj.writeVerbatim(
text = "set_transient( {time_step = %d},1 )" % ts )
## get handles and turn off all configurations
fvxObj.updateHdls()
##select views
# side view
fvxObj.modifyView( name = "view_table_1", dTable = sideView )
fvxObj.writeVerbatim(
'modify(boundary_surface_0,{transparency=0.0})' )
fvxObj.setVis( name = "crd_surf_y",
dataType = 'crdSrf',
visibility = True )
fvxObj.setCrdLeg( name = "crd_surf_y" )
fvxObj.saveImage(
fileName = "Animation/body_section_%s.jpg" % strCounter)
#fvxObj.updateHdls()
# fsi views
fvxObj.writeVerbatim(
'modify(boundary_surface_0,{transparency=0.5})' )
fvxObj.setVis( name = "crd_surf_y",
dataType = 'crdSrf',
visibility = False )
for bc in fsiType:
bndName = "bnd_surf_fsi_%s" % str(bc)
crdName = "crd_surf_fsi_%s" % str(bc)
fvxObj.modifyView( name = "view_table_1",
dTable = fsiView[bc] )
fvxObj.writeVerbatim( '-- view modified')
fvxObj.setVis( name = bndName,
dataType = 'bndSrf',
visibility = True )
fvxObj.writeVerbatim(
'modify(%s,{scalar_func="vwtDisplacement"})' \
% fvxObj.bndHdl[bndName] )
fvxObj.setBndLeg( name = bndName )
fvxObj.saveImage(
fileName = "Animation/fsi_displacement_%s_%s.jpg" % \
( str(bc), strCounter ) )
fvxObj.writeVerbatim(
'modify(%s,{scalar_func="pressure"})' % \
fvxObj.bndHdl[bndName] )
fvxObj.saveImage(
fileName = "Animation/fsi_pressure_%s_%s.jpg" % \
(str(bc),strCounter) )
fvxObj.writeVerbatim(
'modify(%s,{scalar_func="none"})' % \
fvxObj.bndHdl[bndName] )
fvxObj.setVis( name = crdName,
dataType = 'crdSrf',
visibility = True )
fvxObj.setBndLeg( name = bndName, on = False )
fvxObj.setCrdLeg( name = crdName )
fvxObj.saveImage(
fileName = "Animation/fsi_section_%s_%s.jpg" % \
( str(bc), strCounter ) )
fvxObj.setCrdLeg( name = crdName, on = False )
fvxObj.setVis( name = bndName,
dataType = 'bndSrf',
visibility = False )
fvxObj.setVis( name = crdName,
dataType = 'crdSrf',
visibility = False )
else:
fvxObj = AcuFvx( logFile = "./%s" % logFile,
transient = "off",
fvxFile = fvxFile )
fvxObj.writeVerbatim( text = 'fv_script("SIZE 640 360")' )
fvxObj.setBackground( color = "white" )
size = len( fvxObj.bndSrf )
for i in range( size ):
fvxObj.writeVerbatim( 'all_handles = get_all_object_handles(1)' )
fvxObj.writeVerbatim(
'tmp_hdl = all_handles.boundary_handles[%d]'% (size - i))
fvxObj.writeVerbatim( 'delete( tmp_hdl )' )
tmpList = []
for item in fvxObj.bndSrf:
tmpList.append( item )
for item in tmpList:
fvxObj.writeDelBndSrf( name = item )
size = len( fvxObj.crdSrf )
for i in range( size ):
fvxObj.writeVerbatim( 'all_handles = get_all_object_handles(1)' )
fvxObj.writeVerbatim(
'tmp_hdl = all_handles.coord_handles[%d]'% (size - i) )
fvxObj.writeVerbatim( 'delete(tmp_hdl)' )
tmpList = []
for item in fvxObj.crdSrf:
tmpList.append( item )
for item in tmpList:
fvxObj.writeDelCrdSrf( name = item )
axis_at = ( Bxa, Bya, Bza )
axis_from = ( Bxf, Byf, Bzf )
zoomSort = [ Tx2-Tx1, Ty2-Ty1, Tz2-Tz1 ]
zoomSort.sort()
zoom = 0.75*zoomSort[2]/zoomSort[1]
#fvxObj= AcuFvx( logFile = "./%s" % logFile,
# transient = "off",
# fvxFile = fvxFile )
#fvxObj.writeVerbatim( text = 'fv_script("SIZE 640 360")' )
#fvxObj.setBackground( color = "white" )
fvxObj.addViewTable(name = "view_table_1",
zoom = zoom,
angle_axis_at = axis_at,
angle_axis_up = axis_up,
angle_axis_from = axis_from,
axis_markers = "on",
outline = "on", )
fvxObj.writeViewTable( "view_table_1" )
center = "%6.3f %6.3f %6.3f" % ( Txa, Tya, Tza )
fvxObj.writeVerbatim( text='fv_script("CENTER %s")'% center )
fvxObj.addBndSrf( "bnd_surf_bdy",
types = bdyTup,
show_mesh = "off",
scalar_func = "none",
transparency= 0.0 )
fvxObj.writeBndSrf( "bnd_surf_bdy" )
fvxObj.addBndSrf( "bnd_surf_bot",
types = botTup,
show_mesh = "off",
scalar_func = "none",
transparency= 0.5 )
fvxObj.writeBndSrf( "bnd_surf_bot" )
fvxObj.saveImage( fileName = "tun_bdy_vew.jpg" )
zoom = 2 * ( Tx2 - Tx1 ) / ( Bx2 - Bx1 )
fvxObj.writeVerbatim( "view_table_1.zoom=%f"%zoom)
fvxObj.writeVerbatim( text = 'view_table_1.outline="off"' )
fvxObj.writeVerbatim( text = 'set_view( view_table_1)' )
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bza )
fvxObj.writeVerbatim( text = 'fv_script("CENTER %s")'% center )
fvxObj.writeVerbatim(
text = 'modify(boundary_surface_1,{visibility="off"})' )
fvxObj.writeVerbatim(
text = 'modify(boundary_surface_0,{scalar_func="none"})')
fvxObj.saveImage( fileName = "wnd_tun_log.jpg" )
fvxObj.writeVerbatim( text = \
'modify(boundary_surface_0,{scalar_func="none",show_mesh="on"})')
fvxObj.saveImage( fileName= "bod_msh.jpg" )
fvxObj.writeVerbatim( text = \
'modify(boundary_surface_0,{scalar_func="pressure",'\
'show_mesh="off"})' )
fvxObj.writeVerbatim(
text = 'set_legend("1","0.95","0.85","BOUNDARY",1)' )
fvxObj.saveImage( fileName = "bnd_press.jpg" )
fvxObj.writeVerbatim(
text = 'handle_table = get_all_object_handles(1)' )
fvxObj.writeVerbatim(
text = 'boundary_handle_0 = handle_table.boundary_handles[1]' )
fvxObj.writeVerbatim(
text = 'boundary_handle_1 = handle_table.boundary_handles[2]' )
if 'inletVelocity' in parDic['ACS_GLOBAL']:
Vin = dict2Val( parDic['ACS_GLOBAL']['inletVelocity'] )
fvxObj.createCpFormula( name = "vwtCp",
velocity= Vin,
density = rho )
fvxObj.addCrdSrf( "coord_surf_1",
show_mesh = "off",
scalar_func = "vwtCp",
axis = 'X',
x_axis_current = Bx2 + Bxa / 2 )
fvxObj.writeCrdSrf( "coord_surf_1")
fvxObj.writeVerbatim(
text = 'modify(coordinate_surface_0,{visibility="off"})')
fvxObj.writeVerbatim(
text = 'modify(boundary_handle_0,{scalar_func="vwtCp"})')
fvxObj.saveImage( fileName = "coord_press.jpg" )
lookat = "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Bya, Bza )
if cDir == 1:
fvxObj.addCrdSrf( "coord_surf_2",
show_mesh = "on",
axis = 'Y',
y_axis_current = Bya )
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Byf, Bza )
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bz2 )
elif cDir == 2:
fvxObj.addCrdSrf( "coord_surf_2",
show_mesh = "on",
axis = 'Z',
z_axis_current = Bza )
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Bya, Bzf )
center = "%6.3f %6.3f %6.3f" % ( Bxa, By2, Bza )
else:
fvxObj.addCrdSrf( "coord_surf_2",
show_mesh = "on",
axis = 'X',
x_axis_current = Bxa )
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bx2, Bya, Bza )
center = "%6.3f %6.3f %6.3f" % ( Bx2, Bya, Bza )
fvxObj.writeVerbatim( "view_table_1.angle_axis.from=%s" % lookfrom)
fvxObj.writeVerbatim( "view_table_1.angle_axis.at=%s" % lookat )
fvxObj.writeVerbatim( text = 'set_view( view_table_1)' )
fvxObj.writeVerbatim( text = 'fv_script("CENTER %s")' % center )
fvxObj.writeCrdSrf( "coord_surf_2" )
fvxObj.writeVerbatim(
text = 'modify(boundary_handle_0,{scalar_func="none"})' )
fvxObj.saveImage( fileName = "coord_mesh.jpg" )
fvxObj.writeVerbatim(
text = 'modify(boundary_handle_0,{scalar_func="pressure"})' )
fvxObj.writeVerbatim(
text = 'modify(coordinate_surface_1,{show_mesh="off"})' )
fvxObj.writeVerbatim(
text = 'modify(coordinate_surface_1,{scalar_func="pressure"})' )
#fvxObj.saveImage( fileName = "coord_press.jpg" )
zoomStr = "%d" % (zoom*0.75)
fvxObj.writeVerbatim( "view_table_1.zoom = %s" % zoomStr )
fvxObj.writeVerbatim( text = 'set_view( view_table_1)' )
centerEnd = "%6.3f %6.3f %6.3f" % ( Bx2, Bya, Bza )
fvxObj.writeVerbatim( text = 'fv_script("CENTER %s")'% centerEnd )
fvxObj.saveImage( fileName = "coord_press22.jpg" )
fvxObj.writeVerbatim(
text = 'modify(boundary_handle_0,{scalar_func="none"})' )
fvxObj.writeVerbatim( text = \
'modify(coordinate_surface_1,{scalar_func="velocity_magnitude"})' )
zoomStr = "%d" % zoom
fvxObj.writeVerbatim( "view_table_1.zoom = %s" % zoomStr )
fvxObj.writeVerbatim( text = 'set_view( view_table_1)' )
fvxObj.writeVerbatim( text = 'fv_script("CENTER %s")'% center )
fvxObj.writeVerbatim(
text = 'set_legend("1","0.95","0.85","COORD",2)')
fvxObj.saveImage( fileName= "coord_velocity.jpg" )
fvxObj.writeVerbatim(
text = 'handle_table = get_all_object_handles(1)' )
fvxObj.writeVerbatim(
text = 'boundary_handle_0 = handle_table.boundary_handles[1]' )
fvxObj.writeVerbatim(
text = 'coordinate_handle_1 = handle_table.coord_handles[2]' )
fvxObj.writeVerbatim(
text = 'modify(coordinate_handle_1,{visibility="off"})' )
if fDir == 0:
xC = Bxa
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bx2, Bya, Bza )
lookat = "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Bya, Bza )
fvxObj.writeVerbatim( "view_table_1.angle_axis.at=%s" % lookat )
fvxObj.writeVerbatim( "view_table_1.angle_axis.from=%s"%lookfrom)
fvxObj.writeVerbatim( text = 'set_view( view_table_1)' )
if tDir == 1:
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bza )
if tDir == 2:
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bz2 )
fvxObj.writeVerbatim( text = 'fv_script("CENTER %s")'% center )
fvxObj.addCrdSrf( "coord_surf_3",
show_mesh = "on",
axis = 'X',
x_axis_current = xC )
fvxObj.writeCrdSrf( "coord_surf_3")
fvxObj.writeVerbatim(
text = 'modify(boundary_handle_0,{scalar_func="none"})' )
fvxObj.saveImage( fileName = "coord_mesh2.jpg" )
fvxObj.writeVerbatim(
text = 'modify(boundary_handle_0,{scalar_func="pressure"})' )
fvxObj.writeVerbatim(
text = 'modify(coordinate_surface_2, {show_mesh="off"})' )
fvxObj.writeVerbatim( text = \
'modify(coordinate_surface_2, {scalar_func="pressure"})' )
fvxObj.saveImage( fileName = "coord_press2.jpg" )
fvxObj.writeVerbatim(
text = 'modify(boundary_handle_0,{scalar_func="none"})' )
fvxObj.writeVerbatim(
text = 'modify(coordinate_surface_2,{visibility="off"})' )
lookat = "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Bya, Bza )
if cDir == 1:
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Bya, Bzf )
axis_up = "{%d,%d,%d,}" % (0,1,0)
fvxObj.addCrdSrf( "coord_surf_4",
show_mesh = "off",
axis = 'Z',
z_axis_current = Bza,
scalar_func = "velocity_magnitude" )
if cDir == 2:
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Byf, Bza )
axis_up = "{%d,%d,%d,}" % (0,0,1)
fvxObj.addCrdSrf( "coord_surf_4",
show_mesh = "off",
axis = 'Y',
y_axis_current = Bya,
scalar_func = "velocity_magnitude" )
fvxObj.writeVerbatim( "view_table_1.angle_axis.at=%s" % lookat )
fvxObj.writeVerbatim( "view_table_1.angle_axis.from=%s" % lookfrom)
fvxObj.writeVerbatim( "view_table_1.angle_axis.up=%s" % axis_up )
fvxObj.writeVerbatim( text = 'set_view( view_table_1)' )
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bza )
fvxObj.writeVerbatim( text = 'fv_script("CENTER %s")'% center )
fvxObj.writeCrdSrf( "coord_surf_4" )
fvxObj.writeVerbatim(
text = 'set_legend("1","0.95","0.85","COORD",4)')
fvxObj.saveImage( fileName = "coord_velocity2.jpg" )
fvxObj.writeVerbatim(
text = 'handle_table = get_all_object_handles(1)' )
fvxObj.writeVerbatim(
text = 'boundary_handle_0 = handle_table.boundary_handles[1]' )
fvxObj.writeVerbatim(
text =' coordinate_handle_3 = handle_table.coord_handles[4]' )
fvxObj.writeVerbatim(
text = 'modify(coordinate_handle_3,{visibility="off"})' )
fvxObj.writeVerbatim( text = \
'modify(boundary_handle_0,{scalar_func="none", transparency =0.5})')
bndIndex = len( fvxObj.bndHdl )
for bc in fsiType:
bndName = "bnd_surf_fsi_%s" % str(bc)
fsiTup = tuple( fsiType[bc] )
fvxObj.addBndSrf( bndName,
types = fsiTup,
show_mesh = "off",
scalar_func = "surface_y_plus",
transparency= 0.0,
visibility = "on" )
fvxObj.writeBndSrf( bndName )
fsiView[bc]['zoom'] = fsiView[bc]['zoom'] * 2
fvxObj.modifyView( name = "view_table_1", dTable = fsiView[bc] )
fvxObj.setBndLeg( name = bndName )
fvxObj.saveImage( fileName = "y_plus_flex_%s.jpg" % str(bc) )
'''
fvxObj.modifyView( name = "view_table_1", dTable = fsiSideR[bc] )
fvxObj.saveImage( fileName = "y_plus_side_flex_%s.jpg" % str(bc))
fvxObj.modifyView( name = "view_table_1", dTable = fsiTop[bc] )
fvxObj.saveImage( fileName = "y_plus_top_flex_%s.jpg" % str(bc) )
'''
fvxObj.setVis( name = bndName,
dataType = 'bndSrf',
visibility = False )
fvxObj.writeVerbatim(
text = 'handle_table = get_all_object_handles(1)' )
fvxObj.writeVerbatim(
text = 'boundary_handle_0 = handle_table.boundary_handles[1]' )
fvxObj.writeVerbatim(
text = 'coordinate_handle_3 = handle_table.coord_handles[4]' )
fvxObj.writeVerbatim(
text = 'modify(boundary_handle_0,{transparency=0.0})' )
fvxObj.writeVerbatim(
text = 'view_table_1.zoom = %s' % zoomStr )
seedX = []
seedY = []
seedZ = []
if tDir == 1:
I = 10
J = 6
if tDir == 2:
I = 6
J = 10
for i in range(0, I):
for j in range(0, J):
seedX.append(Tx1+0.01*(Tx2-Tx1))
seedY.append(By2-i*(By2-By1)/10)
seedZ.append(Bz2-j*(Bz2-Bz1)/10)
seedingX = "%s" % seedX
seedingY = "%s" % seedY
seedingZ = "%s" % seedZ
seedingX = '{'+seedingX.strip('[]')+'}'
seedingY = '{'+seedingY.strip('[]')+'}'
seedingZ = '{'+seedingZ.strip('[]')+'}'
fvxObj.addStrmLn( "strm_ln_0",
calculation_parameters_direction = "both",
calculation_parameters_step = 5,
calculation_parameters_time_limit = 2,
calculation_parameters_release_interval = 3,
calculation_parameters_duration = 1,
visibility = "on",
display_seeds = "off",
vector_func = "velocity",
scalar_func = "velocity_magnitude",
mode = "add",
seed_coord = "XYZ",
x = seedingX,
y = seedingY,
z = seedingZ)
fvxObj.writeStrmLn( "strm_ln_0" )
if tDir == 1:
axis_up = "{%d,%d,%d,}" % (0,1,0)
if tDir == 2:
axis_up = "{%d,%d,%d,}" % (0,0,1)
lookat = "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Bya, Bza )
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bxf, Byf, Bzf )
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bza )
fvxObj.writeVerbatim( "view_table_1.angle_axis.at=%s" % lookat )
fvxObj.writeVerbatim( "view_table_1.angle_axis.from=%s" % lookfrom )
fvxObj.writeVerbatim( "view_table_1.angle_axis.up=%s" % axis_up )
fvxObj.writeVerbatim( text = 'set_view( view_table_1)' )
fvxObj.writeVerbatim( text = 'fv_script("CENTER %s")' % center )
fvxObj.writeVerbatim(
text = 'set_legend("1","0.95","0.85","STREAM",1)' )
fvxObj.saveImage( fileName = "stream_lines_1.jpg" )
if fDir == 0:
lookat = "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Bya, Bza )
if tDir == 1:
axis_up = "{%d,%d,%d,}" % (0,1,0)
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Bya, Bzf )
center = "%6.3f %6.3f %6.3f" % ( Bxa, By2, Bza )
if tDir == 2:
axis_up = "{%d,%d,%d,}" % (0,0,1)
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Byf, Bza )
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bz2 )
fvxObj.writeVerbatim( "view_table_1.angle_axis.at=%s" % lookat )
fvxObj.writeVerbatim( "view_table_1.angle_axis.from=%s"%lookfrom)
fvxObj.writeVerbatim( "view_table_1.angle_axis.up=%s" % axis_up )
fvxObj.writeVerbatim( text = 'set_view( view_table_1)' )
fvxObj.writeVerbatim( text = 'fv_script("CENTER %s")' % center )
fvxObj.saveImage( fileName= "stream_lines_2.jpg" )
#fvxObj.writeVerbatim( text= 'modify(strm_ln_0,{visibility="off"})' )
fvxObj.writeVerbatim(
text = 'handle_table = get_all_object_handles(1)' )
fvxObj.writeVerbatim(
text = 'boundary_handle_0 = handle_table.boundary_handles[1]' )
fvxObj.writeVerbatim(
text = 'strm_ln_handle_0 = handle_table.streamline_handles[1]' )
fvxObj.writeVerbatim(
text = 'modify(strm_ln_handle_0,{visibility="off"})' )
fvxObj.writeVerbatim(
text = 'modify(boundary_handle_0,{scalar_func="surface_y_plus"})')
if tDir == 1:
axis_up = "{%d,%d,%d,}" % (0,1,0)
if tDir == 2:
axis_up = "{%d,%d,%d,}" % (0,0,1)
lookat = "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Bya, Bza )
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bxf, Byf, Bzf )
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bza )
fvxObj.writeVerbatim( "view_table_1.angle_axis.at=%s" % lookat )
fvxObj.writeVerbatim( "view_table_1.angle_axis.from=%s" % lookfrom )
fvxObj.writeVerbatim( "view_table_1.angle_axis.up=%s" % axis_up )
fvxObj.writeVerbatim( text = 'set_view( view_table_1)' )
fvxObj.writeVerbatim( text = 'fv_script("CENTER %s")' % center )
fvxObj.saveImage( fileName = "body_y_plus_front.jpg" )
if fDir == 0:
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bx2, Bya, Bza )
lookat = "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Bya, Bza )
fvxObj.writeVerbatim( "view_table_1.angle_axis.at=%s" % lookat )
fvxObj.writeVerbatim( "view_table_1.angle_axis.from=%s"%lookfrom)
fvxObj.writeVerbatim( text = 'set_view( view_table_1)' )
if tDir == 1:
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bza )
if tDir == 2:
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bza )
fvxObj.writeVerbatim( text = 'fv_script("CENTER %s")' % center )
fvxObj.saveImage( fileName = "body_y_plus_back.jpg" )
if fDir == 0:
lookat = "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Bya, Bza )
if tDir == 1:
axis_up = "{%d,%d,%d,}" % (1,0,0)
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, By1, Bza )
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bza )
if tDir == 2:
axis_up = "{%d,%d,%d,}" % (1,0,0)
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Bya, Bz1 )
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bza )
fvxObj.writeVerbatim( "view_table_1.angle_axis.at=%s" % lookat )
fvxObj.writeVerbatim( "view_table_1.angle_axis.from=%s"%lookfrom)
fvxObj.writeVerbatim( "view_table_1.angle_axis.up=%s" % axis_up )
fvxObj.writeVerbatim( text = 'set_view( view_table_1)' )
fvxObj.writeVerbatim( text = 'fv_script("CENTER %s")' % center )
fvxObj.saveImage( fileName = "body_y_plus_bottom.jpg" )
fvxObj.writeViewTable( "view_table_1" )
zoom = 2*(Tx2-Tx1)/(Bx2-Bx1)
fvxObj.writeVerbatim( "view_table_1.zoom=%f" % zoom )
fvxObj.writeVerbatim( text = 'view_table_1.outline="off"' )
fvxObj.writeVerbatim( text = 'set_view( view_table_1)' )
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bza )
fvxObj.writeVerbatim( text = 'fv_script("CENTER %s")' % center)
sVarDic = { 'x_velocity':'x-velocity',
'y_velocity':'y-velocity',
'z_velocity':'z-velocity',
'x_mesh_displacement':'x-mesh_displacement',
'y_mesh_displacement':'y-mesh_displacement',
'z_mesh_displacement':'z-mesh_displacement' }
allVars = [ 'pressure', 'velocity', 'velocity_magnitude',
'mesh_displacement', 'eddy_viscosity', 'x_velocity',
'y_velocity', 'z_velocity', 'x_mesh_displacement',
'y_mesh_displacement', 'z_mesh_displacement' ]
fsiFlag = False
if 'fsi' in parDic['ACS_GLOBAL']:
if dict2Val(parDic['ACS_GLOBAL']['fsi']):
fsiFlag = True
if 'ACS_BOUNDARY_SURFACES' in parDic:
for bndSrf in parDic['ACS_BOUNDARY_SURFACES']:
surfaces = dict2Val(
parDic['ACS_BOUNDARY_SURFACES'][bndSrf]['surfaces'] )
types = '{ '
for srf in surfaces:
types = types + '"OSF: %s",' % srf
types = types + ' }'
variables = dict2Val(
parDic['ACS_BOUNDARY_SURFACES'][bndSrf]['variables'])
fvxObj.writeVerbatim(
text = 'handle_table = get_all_object_handles(1)' )
fvxObj.writeVerbatim( text = \
'boundary_handle_last = handle_table.boundary_handles[1]' )
for var in variables:
if var not in allVars:
continue
elif var == 'velocity':
sVars = ['x_velocity', 'y_velocity', 'z_velocity']
sVars = [ x for x in sVars if x not in variables ]
sVars = [ sVarDic[x] for x in sVars ]
elif var == 'mesh_displacement':
if fsiFlag:
sVars = [ 'x_mesh_displacement',
'y_mesh_displacement',
'z_mesh_displacement']
sVars = [ x for x in sVars if x not in variables]
sVars = [ sVarDic[x] for x in sVars ]
else:
sVars = []
else:
if 'mesh_displacement' in var:
if fsiFlag:
sVars = [ sVarDic[var] ]
else:
sVars = []
else:
if var in sVarDic:
sVars = [ sVarDic[var] ]
else:
sVars = [ var ]
for sVar in sVars:
fvxObj.writeVerbatim(text = \
'modify(boundary_handle_last,'\
'{types=%s, scalar_func="%s"})'\
% (types, sVar) )
fvxObj.saveImage(fileName="%s_%s.jpg" % (bndSrf,sVar))
fvxObj.writeVerbatim(
text = 'handle_table = get_all_object_handles(1)' )
fvxObj.writeVerbatim(
text = 'boundary_handle_0 = handle_table.boundary_handles[1]' )
fvxObj.writeVerbatim(
text = 'modify(boundary_handle_0,{visibility="off"})' )
if 'ACS_COORDINATE_SURFACES' in parDic:
for crdSrf in parDic['ACS_COORDINATE_SURFACES']:
bbox = None
lrange = None
axis = dict2Val(
parDic['ACS_COORDINATE_SURFACES'][crdSrf]['axis'] )
point = dict2Val(
parDic['ACS_COORDINATE_SURFACES'][crdSrf]['point'] )
if 'variables' in parDic['ACS_COORDINATE_SURFACES'][crdSrf]:
variables = dict2Val(
parDic['ACS_COORDINATE_SURFACES'][crdSrf]['variables'])
else:
variables = dict2Val(
parDic['ACS_GLOBAL']['coordinate_variables'])
if 'bounding_box' in parDic['ACS_COORDINATE_SURFACES'][crdSrf]:
bbox = dict2Val(
parDic['ACS_COORDINATE_SURFACES'][crdSrf]['bounding_box'])
else:
bbox = dict2Val(
parDic['ACS_GLOBAL']['coordinate_bounding_box'])
if 'legend_range' in parDic['ACS_COORDINATE_SURFACES'][crdSrf]:
lrange = dict2Val(
parDic['ACS_COORDINATE_SURFACES'][crdSrf]['legend_range'])
else:
lrange = dict2Val(
parDic['ACS_GLOBAL']['coordinate_legend_range'])
if axis[0] == 1.0:
Byc = Bya
Bzc = Bza
if bbox != None:
dr1_axis_min= str(bbox[2])
dr1_axis_max= str(bbox[3])
dr2_axis_min= str(bbox[4])
dr2_axis_max= str(bbox[5])
Byc = (bbox[3]+bbox[2])/2
Bzc = (bbox[5]+bbox[4])/2
lookat = "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Byc, Bzc )
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bx2, Byc, Bzc )
center = "%6.3f %6.3f %6.3f" % ( Bxa, Byc, Bzc )
axis_up = "{%d,%d,%d,}" % (0,0,1)
axis_new= 'X'
axis_dr1= 'Y'
axis_dr2= 'Z'
axis_cur= point[0]
sclRat = max( (Ty2-Ty1)/(bbox[3]-bbox[2]),
(Tz2-Tz1)/(bbox[5]-bbox[4]) )
imgRat = max( (bbox[5]-bbox[4])/(bbox[3]-bbox[2]),
(bbox[3]-bbox[2])/(bbox[5]-bbox[4]) )
zoom = 2 * sclRat #* imgRat
if axis[1] == 1.0:
Bxc = Bxa
Bzc = Bza
if bbox != None:
dr1_axis_min= str(bbox[0])
dr1_axis_max= str(bbox[1])
dr2_axis_min= str(bbox[4])
dr2_axis_max= str(bbox[5])
Bxc = (bbox[1]+bbox[0])/2
Bzc = (bbox[5]+bbox[4])/2
lookat = "{%6.3f,%6.3f,%6.3f,}" % ( Bxc, Bya, Bzc )
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bxc, By1, Bzc )
center = "%6.3f %6.3f %6.3f" % ( Bxc, Bya, Bzc )
axis_up = "{%d,%d,%d,}" % (0,0,1)
axis_new= 'Y'
axis_dr1= 'X'
axis_dr2= 'Z'
axis_cur= point[1]
sclRat = max( (Tx2-Tx1)/(bbox[1]-bbox[0]),
(Tz2-Tz1)/(bbox[5]-bbox[4]) )
imgRat = max( (bbox[5]-bbox[4])/(bbox[1]-bbox[0]),
(bbox[1]-bbox[0])/(bbox[5]-bbox[4]) )
zoom = 2 * sclRat #* imgRat
if axis[2] == 1.0:
Bxc = Bxa
Byc = Bya
if bbox != None:
dr1_axis_min= str(bbox[0])
dr1_axis_max= str(bbox[1])
dr2_axis_min= str(bbox[2])
dr2_axis_max= str(bbox[3])
Bxc = (bbox[1]+bbox[0])/2
Byc = (bbox[3]+bbox[2])/2
lookat = "{%6.3f,%6.3f,%6.3f,}" % ( Bxc, Byc, Bza )
lookfrom= "{%6.3f,%6.3f,%6.3f,}" % ( Bxc, Byc, Bz2 )
center = "%6.3f %6.3f %6.3f" % ( Bxc, Byc, Bza )
axis_up = "{%d,%d,%d,}" % (0,1,0)
axis_new= 'Z'
axis_dr1= 'X'
axis_dr2= 'Y'
axis_cur= point[2]
sclRat = max( (Tx2-Tx1)/(bbox[1]-bbox[0]),
(Ty2-Ty1)/(bbox[3]-bbox[2]) )
imgRat = max( (bbox[3]-bbox[2])/(bbox[1]-bbox[0]),
(bbox[1]-bbox[0])/(bbox[3]-bbox[2]) )
zoom = 2 * sclRat #* imgRat
fvxObj.writeVerbatim( "view_table_1.angle_axis.at=%s"%lookat)
fvxObj.writeVerbatim(
"view_table_1.angle_axis.from=%s" % lookfrom)
fvxObj.writeVerbatim("view_table_1.angle_axis.up=%s"%axis_up)
fvxObj.writeVerbatim( "view_table_1.zoom=%f" % zoom )
fvxObj.writeVerbatim( text = 'set_view( view_table_1)' )
fvxObj.writeVerbatim(
text = 'fv_script("CENTER %s")' % center )
fvxObj.writeVerbatim(
text = 'handle_table = get_all_object_handles(1)' )
fvxObj.writeVerbatim( text = \
'coordinate_handle_3 = handle_table.coord_handles[4]' )
for var in variables:
try:
if lrange != []:
if isinstance(lrange[0], list):
scalar_min = lrange[variables.index(var)][0]
scalar_max = lrange[variables.index(var)][1]
else:
scalar_min = lrange[0]
scalar_max = lrange[1]
else:
scalar_min = 'Auto'
scalar_max = 'Auto'
except:
scalar_min = 'Auto'
scalar_max = 'Auto'
if var not in allVars:
continue
elif var == 'velocity':
sVars = ['x_velocity', 'y_velocity', 'z_velocity']
sVars = [ x for x in sVars if x not in variables ]
sVars = [ sVarDic[x] for x in sVars ]
elif var == 'mesh_displacement':
if fsiFlag:
sVars = [ 'x_mesh_displacement',
'y_mesh_displacement',
'z_mesh_displacement']
sVars = [ x for x in sVars if x not in variables]
sVars = [ sVarDic[x] for x in sVars ]
else:
sVars = []
else:
if 'mesh_displacement' in var:
if fsiFlag:
sVars = [ sVarDic[var] ]
else:
sVars = []
else:
if var in sVarDic:
sVars = [ sVarDic[var] ]
else:
sVars = [ var ]
for sVar in sVars:
if scalar_min != 'Auto' and scalar_max != 'Auto':
fvxObj.writeVerbatim(text = \
'modify(coordinate_handle_3,'\
'{axis="%s", %s_axis={current=%f},'\
'%s_axis={min=%s, max=%s},'\
'%s_axis={min=%s, max=%s},'\
'scalar_func="%s",'\
'scalar_range={min=%s, max=%s},'\
'visibility="on"})'\
% (axis_new,axis_new,axis_cur,
axis_dr1,dr1_axis_min,dr1_axis_max,
axis_dr2,dr2_axis_min,dr2_axis_max,
sVar,scalar_min,scalar_max ) )
elif scalar_min != 'Auto' and scalar_max == 'Auto':
fvxObj.writeVerbatim(text = \
'modify(coordinate_handle_3,'\
'{axis="%s", %s_axis={current=%f},'\
'%s_axis={min=%s, max=%s},'\
'%s_axis={min=%s, max=%s},'\
'scalar_func="%s",'\
'scalar_range={min=%s},'\
'visibility="on"})'\
% (axis_new,axis_new,axis_cur,
axis_dr1,dr1_axis_min,dr1_axis_max,
axis_dr2,dr2_axis_min,dr2_axis_max,
sVar,scalar_min ) )
elif scalar_min == 'Auto' and scalar_max != 'Auto':
fvxObj.writeVerbatim(text = \
'modify(coordinate_handle_3,'\
'{axis="%s", %s_axis={current=%f},'\
'%s_axis={min=%s, max=%s},'\
'%s_axis={min=%s, max=%s},'\
'scalar_func="%s",'\
'scalar_range={max=%s},'\
'visibility="on"})'\
% (axis_new,axis_new,axis_cur,
axis_dr1,dr1_axis_min,dr1_axis_max,
axis_dr2,dr2_axis_min,dr2_axis_max,
sVar,scalar_max ) )
else:
fvxObj.writeVerbatim(text = \
'modify(coordinate_handle_3,'\
'{axis="%s", %s_axis={current=%f},'\
'%s_axis={min=%s, max=%s},'\
'%s_axis={min=%s, max=%s},'\
'scalar_func="%s",visibility="on"})'\
% (axis_new,axis_new,axis_cur,
axis_dr1,dr1_axis_min,dr1_axis_max,
axis_dr2,dr2_axis_min,dr2_axis_max,
sVar ) )
fvxObj.saveImage(fileName="%s_%s.jpg" % (crdSrf,sVar))
fvxObj.writeVerbatim(
text = 'handle_table = get_all_object_handles(1)' )
fvxObj.writeVerbatim(
text = 'coordinate_handle_3 = handle_table.coord_handles[4]')
fvxObj.writeVerbatim(
text = 'modify(coordinate_handle_3,{visibility="off"})' )
'''
acuHome = os.getenv( "ACUSIM_HOME" )
acuMach = os.getenv( "ACUSIM_MACHINE" )
reportDir = os.path.join( acuHome, acuMach, 'plugins', 'report' )
initFile = os.path.join( reportDir, 'init.frm' )
initFile = fvxObj.getUnixPath( initFile )
fvxObj.readFormula( fileName = "%s" % initFile)
if tDir == 1:
axis_up = "{%d,%d,%d,}" % (0,1,0)
if tDir == 2:
axis_up = "{%d,%d,%d,}" % (0,0,1)
lookat = "{%6.3f,%6.3f,%6.3f,}" % ( Bxa, Bya, Bza )
lookfrom = "{%6.3f,%6.3f,%6.3f,}" % ( Bxf, Byf, Bzf )
center = "%6.3f %6.3f %6.3f" % ( Bxa, Bya, Bza )
fvxObj.writeVerbatim( "view_table_1.angle_axis.at=%s" % lookat )
fvxObj.writeVerbatim( "view_table_1.angle_axis.from=%s" % lookfrom )
fvxObj.writeVerbatim( "view_table_1.angle_axis.up=%s" % axis_up )
fvxObj.writeVerbatim( text = 'set_view( view_table_1)')
fvxObj.writeVerbatim( text = 'fv_script("CENTER %s")' % center )
fvxObj.addIsoSrf( "iso_srf_1",
show_mesh = "off" ,
scalar_func = "velocity_magnitude",
iso_func = "Q",
iso_value_current = 1 )
fvxObj.writeIsoSrf( "iso_srf_1")
fvxObj.writeVerbatim(
text = 'set_legend("1","0.95","0.85","ISO",1)' )
fvxObj.writeVerbatim(
text = 'handle_table = get_all_object_handles(1)' )
fvxObj.writeVerbatim(
text = 'boundary_handle_0 = handle_table.boundary_handles[1]' )
fvxObj.writeVerbatim(
text='modify( boundary_handle_0,{visibility="off"})' )
fvxObj.saveImage( fileName = "iso_velocity.jpg" )
fvxObj.writeVerbatim( text = 'delete(strm_ln_0)' )
fvxObj.writeVerbatim( text = 'delete(coordinate_surface_3)' )
fvxObj.writeVerbatim( text = 'delete(coordinate_surface_2)' )
fvxObj.writeVerbatim( text = 'delete(coordinate_surface_1)' )
fvxObj.writeVerbatim( text = 'delete(coordinate_surface_0)' )
fvxObj.writeVerbatim( text = 'delete(boundary_handle_1)' )
fvxObj.writeVerbatim( text = 'delete(boundary_handle_0)' )
'''
fvxObj.close()
fvxObj.runAcuFieldView()
fvxObj.clear()
if animation: #if animation == 'True':
if digits != -1:
createVideo( digits )
#===========================================================================
# SetUp
#===========================================================================
print "Set Up"
problem = acuCnf.cnfGetStr( "problem" )
runId = acuCnf.cnfGetInt( "run_id" )
if runId == 0:
Index = getMaxFileInd( problem, "Log" )
if Index == -1:
runId = 1
else:
runId = Index
logFile = "%s.%d.Log" % ( problem , runId )
texFile = problem + ".tex"
parFile = problem + ".vpar"
fvxFile = problem + ".fvx"
print "Log File = %s " % logFile
#===========================================================================
# WT component names
#===========================================================================
wtComps = {}
wtComps['BODY' ] = ( 'solid', [ 1.0, 0.0, 0.0 ], 'on', 'off' )
wtComps['POROUS' ] = ( 'solid', [ 1.0, 0.0, 0.0 ], 'on', 'off' )
wtComps['WT_BOTTOM'] = ( 'solid', [ 0.0, 1.0, 1.0 ], 'on', 'off' )
wtComps['WT_INLET' ] = ( 'solid', [ 0.0, 1.0, 0.0 ], 'on', 'on' )
wtComps['WT_OUTLET'] = ( 'solid', [ 0.0, 0.0, 1.0 ], 'on', 'on' )
wtComps['WT_LEFT' ] = ( 'solid', [ 1.0, 1.0, 0.0 ], 'on', 'on' )
wtComps['WT_RIGHT' ] = ( 'solid', [ 0.0, 1.0, 1.0 ], 'on', 'on' )
wtComps['WT_TOP' ] = ( 'solid', [ 1.0, 0.0, 1.0 ], 'on', 'on' )
wtComps['WT_SYMMETRY' ] = ( 'solid', [ 1.0, 0.0, 1.0 ], 'on', 'on' )
for i in range( 24 ):
ikey = 'WHEEL_%d' % i
wtComps[ikey] = ( 'solid', [ 1.0, 0.0, 1.0 ], 'on', 'off' )
for i in range( 10 ):
ikey = 'flex_comp_%d' % (i+1)
compNames = wtComps.keys()
( compMap, parDic, fsiDic ) = readVars( parFile, compNames )
invCompMap = {}
for ikey in compMap:
vals = compMap[ikey]
for val in vals:
invCompMap[val] = ikey
othDir = getMonitorPoints(parDic)
optDir = {}
#===========================================================================
# Open a document
#===========================================================================
rep = Report( texFile,
packages = ("graphicx","hyperref","geometry","movie15") )
rep.modifyPackageOptions( "hypersetup",
optionMap={"pdfborder":"{0 0 0}"} )
#===========================================================================
# Open the model and solution
#===========================================================================
adb = Adb( )
#===========================================================================
# Front Page
#===========================================================================
rho = 1.225
Aref = 1
Ainl = 1
fDir = 0
tDir = 1
cDir = 2
Vin = 1.0
(Bx1, Bx2, By1, By2, Bz1, Bz2) = [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 ]
(Tx1, Tx2, Ty1, Ty2, Tz1, Tz2) = [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 ]
if 'flow_direction' in parDic['ACS_GLOBAL']:
fDir = dict2Val( parDic['ACS_GLOBAL']['flow_direction'] )
if 'top_direction' in parDic['ACS_GLOBAL']:
tDir = dict2Val( parDic['ACS_GLOBAL']['top_direction'] )
if 'cross_direction' in parDic['ACS_GLOBAL']:
cDir = dict2Val( parDic['ACS_GLOBAL']['cross_direction'] )
if 'body_bounding_box' in parDic['ACS_GLOBAL']:
body_bounding_box = parDic['ACS_GLOBAL']['body_bounding_box']
(Bx1, Bx2, By1, By2, Bz1, Bz2) = dict2Val( body_bounding_box )
if 'tunnel_bounding_box' in parDic['ACS_GLOBAL']:
tunnel_bounding_box = parDic['ACS_GLOBAL']['tunnel_bounding_box']
(Tx1, Tx2, Ty1, Ty2, Tz1, Tz2) = dict2Val( tunnel_bounding_box )
Txl = Tx2-Tx1
Tyh = Ty2-Ty1
Tzw = Tz2-Tz1
Bxl = Bx2-Bx1
Byh = By2-By1
Bzw = Bz2-Bz1
if 'reference_area' in parDic['ACS_GLOBAL']:
Aref = dict2Val( parDic['ACS_GLOBAL']['reference_area'] )
else:
if fDir == 0:
Aref = abs(By2-By1)*abs(Bz2-Bz1)
if fDir == 1:
Aref = abs(Bz2-Bz1)*abs(Bx2-Bx1)
if fDir == 2:
Aref = abs(Bx2-Bx1)*abs(By2-By1)
if 'inlet_area' in parDic['ACS_GLOBAL']:
Ainl = dict2Val( parDic['ACS_GLOBAL']['inlet_area'] )
else:
if fDir == 0:
Ainl = abs(Ty2-Ty1)*abs(Tz2-Tz1)
if fDir == 1:
Ainl = abs(Tz2-Tz1)*abs(Tx2-Tx1)
if fDir == 2:
Ainl = abs(Tx2-Tx1)*abs(Ty2-Ty1)
Brat= Aref/Ainl*100
if sys.platform == "win32":
figExt = "jpg";
else:
figExt = "jpeg";
if 'ACS_MATERIAL_MODELS' in parDic:
for matMdl in parDic['ACS_MATERIAL_MODELS']:
rho = dict2Val(parDic['ACS_MATERIAL_MODELS'][matMdl]['density'])
break
else:
rho = 1.225
#createResidualSolutionRatios( rep, adb )
createResultData( rep, adb, compMap, parDic, fsiDic,
othDir, rho, Aref, fDir, tDir, cDir )
createImages( rep, compMap, parDic, fsiDic, rho )
rep.newPage()
rep.addSpace( 2 )
acuHome = os.getenv( "ACUSIM_HOME" )
acuMach = os.getenv( "ACUSIM_MACHINE" )
logoFile = os.path.join( acuHome, acuMach, 'plugins',
'report', 'logo_altair.png' )
newFile = 'logo.png'
if sys.platform == "win32":
shutil.copy( logoFile, newFile )
logoFile = newFile
if os.path.exists( logoFile ):
rep.addImage( logoFile, scale = 2,)
rep.addSpace( 2 )
imgFct = 640/ ( 6.0 * 72 )
rep.addTitle( "Wind Tunnel Simulation" )
if "engineerName" in parDic['ACS_GLOBAL']:
engName = "Engineer name: %s" % dict2Val(
parDic['ACS_GLOBAL']['engineerName'])
rep.addTitle( engName )
rep.fillVSpace( )
rep.addDate( )
rep.addImage( "wnd_tun_log.%s" % figExt, scale = 1.0/imgFct,)
rep.fillVSpace( )
rep.addText( "\\emph{Product of Altair Engineering Inc.}", "center" )
rep.addText( "http://www.altair.com", "center" )
rep.newPage( )
#===========================================================================
# Table of Contents
#===========================================================================
rep.addTableOfContent( )
rep.newPage( )
#===========================================================================
# Introduction
#===========================================================================
rep.addSection( "Summary" )
rep.addText("This report summarizes the results of an external"\
"aerodynamic CFD analysis performed by "\
"Altair\\textquoteright s Virtual Wind Tunnel, "\
"leveraging AcuSolve\\textquoteright s CFD technology." )
rep.addText(" ")
rep.addText("The first section provides a brief overview of the"\
" run and its results." )
nElms = adb.get( "nElms" )
nTotElems = 0
for i in range( nElms ):
nTotElems = nTotElems + adb.get( "nElmElems", i )
cpuTimes = adb.getCpuTimes()
elapseTimes = adb.getElapseTimes()
cpuHrs = cpuTimes.sum() / 3600.0
elapseHrs = elapseTimes.sum() / 3600.0
summTable = []
runVersion = adb.get( 'runVersion' )
summTable.append( ( "AcuSolve version", "%s" % runVersion ) )
if 'simulationType' in parDic['ACS_GLOBAL']:
summTable.append( ( "Simulation type", "%s" % dict2Val(
parDic['ACS_GLOBAL']['simulationType'] ) ) )
summTable.append( ( "Element count", "%d" % nTotElems ) )
summTable.append( ( "Run time ( Elapse time )", "%6.3f h" % elapseHrs ) )
#summTable.append( ( "CPU time", "%6.3f h" % cpuHrs ) )
if 'inletVelocity' in parDic['ACS_GLOBAL']:
keyCount = 0
for comp in parDic['ACS_COMPONENTS']:
if dict2Val(
parDic['ACS_COMPONENTS'][comp]['wtcomp'] ) == "WT_INLET":
keyCount += 1
if 'velocity' in parDic['ACS_COMPONENTS'][comp]:
velocity = dict2Val(
parDic['ACS_COMPONENTS'][comp]['velocity'] )
else:
velocity = ( dict2Val(
parDic['ACS_GLOBAL']['inletVelocity'] ),0.0,0.0 )
( xVel, yVel, zVel ) = velocity
summTable.append( ( "%s" % str( comp ).replace( "_", "\_" ),
"%.2f %.2f %.2f m/s" % ( xVel, yVel, zVel ) ) )
if keyCount == 0:
summTable.append( ( "Inflow velocity", "%s m/s" % dict2Val(
parDic['ACS_GLOBAL']['inletVelocity'] ) ) )
summTable.append( ( "Drag coefficient, Cd", "%6.3f" % \
dataTable[len(dataTable)-1][1] ) )
summTable.append( ( "Lift coefficient, Cl", "%6.3f" % \
dataTable[len(dataTable)-1][2] ) )
rep.addTable( summTable, "Problem Information", ref="tab:summ")
#===========================================================================
# Geometry
#===========================================================================
rep.addSection( "Dimensions" )
rep.addText("This sections contains geometric dimensions"\
"related to the wind tunnel and the body." )
dimmTable = [ ( "Wind tunnel, bounding box",
"[%6.3f, %6.3f], [%6.3f, %6.3f], [%6.3f, %6.3f]" % \
(Tx1, Tx2, Ty1, Ty2, Tz1, Tz2) ) ]
dimmTable.append( ( "Body, bounding box",
"[%6.3f, %6.3f], [%6.3f, %6.3f], [%6.3f, %6.3f]" % \
(Bx1, Bx2, By1, By2, Bz1, Bz2) ) )
dimmTable.append( ( "Wind tunnel dimension",
"%6.3f m x %6.3f m x %6.3f m." % (Txl, Tyh, Tzw)) )
dimmTable.append( ( "Body dimension",
"%6.3f m x %6.3f m x %6.3f m." % (Bxl, Byh, Bzw)) )
dimmTable.append( ( "Frontal ref. area, Aref", "%s m^{2}" % Aref ) )
dimmTable.append( ( "Blockage ratio \\%", "%s" % Brat ) )
dimmTable.append( ( "Distance inflow - body", "%6.3f m" % abs(Bx1-Tx1)) )
rep.addTable( dimmTable, "Geometric Dimensions", ref="tab:dimm")
rep.newPage( )
rep.addFigure( "tun_bdy_vew.%s" % figExt,
scale=1.0/imgFct, caption = "Virtual Wind Tunnel", ref="fig:tunbdy" )
rep.addSection( "Mesh" )
rep.addText("This section contains mesh statistics and screen"\
"shots of several cutting planes through the mesh." )
nNodes = adb.get("nNodes")
meshTable = []
meshTable.append( ( "Numb. of nodes", "%d" % nNodes ) )
meshTable.append( ( "Numb. of elements", "%d" % nTotElems ) )
if 'nZones' in parDic['ACS_GLOBAL']:
meshTable.append( ( "Numb. of refinement zones",
"%s" % dict2Val(parDic['ACS_GLOBAL']['nZones'] ) ) )
rep.addTable( meshTable, "Mesh statistics", ref="tab:mesh" )
meshFigTable = [ ( "Figure \\ref{fig:flowmesh}", "Symmetry plane " ) ]
meshFigTable.append( ( "Figure \\ref{fig:crossmesh}", "Cross section" ) )
rep.addTable( meshFigTable,
"Cutting planes through mesh", ref="tab:meshFig" )
rep.newPage()
rep.addFigure( "coord_mesh.%s" % figExt, scale = 1.0 / imgFct,
caption = "Mesh in Flow Direction", ref = "fig:flowmesh")
rep.addFigure( "coord_mesh2.%s" % figExt, scale = 1.0 / imgFct,
caption = "Mesh in Cross Direction", ref="fig:crossmesh")
rep.fillVSpace()
#===========================================================================
# Boundary Conditions and Solution Strategy
#===========================================================================
rep.newPage( )
rep.addSection( "Boundary Conditions and Solution Strategy" )
rep.addText("In this section the boundary conditions and "\
"the setup for the CFD run are listed." )
boundTable = []
leftCount = 0
rightCount = 0
if 'inletVelocity' in parDic['ACS_GLOBAL']:
keyCount = 0
for comp in parDic['ACS_COMPONENTS']:
if dict2Val(
parDic['ACS_COMPONENTS'][comp]['wtcomp'] ) == "WT_INLET":
keyCount += 1
if 'velocity' in parDic['ACS_COMPONENTS'][comp]:
velocity = dict2Val(
parDic['ACS_COMPONENTS'][comp]['velocity'] )
else:
velocity = ( dict2Val(
parDic['ACS_GLOBAL']['inletVelocity'] ),0.0,0.0 )
( xVel, yVel, zVel ) = velocity
boundTable.append( ( "%s" % str( comp ).replace( "_", "\_" ),
"%.2f %.2f %.2f m/s" % ( xVel, yVel, zVel )))
if 'Wind_Tunnel_Left' in comp:
leftCount += 1
if 'Wind_Tunnel_Right' in comp:
rightCount += 1
if keyCount == 0:
boundTable.append( ( "Inflow velocity",
"%s m/s" % dict2Val(parDic['ACS_GLOBAL']['inletVelocity'] )))
keyCount = 0
for comp in parDic['ACS_COMPONENTS']:
if dict2Val(parDic['ACS_COMPONENTS'][comp]['wtcomp']) == "WT_OUTLET":
keyCount += 1
boundTable.append( ( "%s" % str( comp ).replace( "_", "\_" ),
"Pressure outlet" ) )
if 'Wind_Tunnel_Left' in comp:
leftCount += 1
if 'Wind_Tunnel_Right' in comp:
rightCount += 1
if keyCount == 0:
boundTable.append( ( "Outflow", "Pressure outlet" ) )
if leftCount > 0 and rightCount > 0:
slipFaces = "Top face of wind tunnel"
elif leftCount > 0 and rightCount == 0:
slipFaces = "Top, right faces of wind tunnel"
elif leftCount == 0 and rightCount > 0:
slipFaces = "Top, left faces of wind tunnel"
else:
slipFaces = "Top, right, left faces of wind tunnel"
boundTable.append( ("Slip Walls", "%s" % slipFaces ) )
boundTable.append( ("No-slip Walls",
"wind tunnel ground, body, wheels, heat-exchange" ) )
rep.addTable( boundTable, "Boundary conditions", ref = "tab:bound" )
solTable = []
if 'simulationType' in parDic['ACS_GLOBAL']:
solTable.append( ( "Simulation type", "%s" % dict2Val(
parDic['ACS_GLOBAL']['simulationType'] ) ) )
if 'nTimeSteps' in parDic['ACS_GLOBAL']:
try:
nSteps = adb.get('nSteps')
except:
nSteps = dict2Val( parDic['ACS_GLOBAL']['nTimeSteps'] )
solTable.append( ( "Number of time steps", "%s" % nSteps ) )
if 'timeIncr' in parDic['ACS_GLOBAL'] and \
dict2Val( parDic['ACS_GLOBAL']['simulationType'] ) == "transient":
try:
nSteps = adb.get('nSteps')
timeInc= adb.get('timeInc',nSteps-1)
time = adb.get('time',nSteps-1)
except:
nSteps = dict2Val(parDic['ACS_GLOBAL']['nTimeSteps'])
timeInc= dict2Val(parDic['ACS_GLOBAL']['timeIncr'])
time = nSteps * timeInc
solTable.append( ( "Time increment", "%s" % timeInc ) )
solTable.append( ( "Physical time", "%6.3f" % time ) )
if dict2Val( parDic['ACS_GLOBAL']['simulationType'] ) == "transient":
solTable.append( ( "Turbulence model", "Detached Eddy Simulation" ) )
else:
solTable.append( ( "Turbulence model", "Spalart-Allmaras" ) )
if 'movingGround' in parDic['ACS_GLOBAL']:
if dict2Val( parDic['ACS_GLOBAL']['movingGround'] ) == 1:
mgVal = True
elif dict2Val( parDic['ACS_GLOBAL']['movingGround'] ) == 0:
mgVal = False
else:
mgVal = dict2Val( parDic['ACS_GLOBAL']['movingGround'] )
solTable.append( ( "Moving ground", "%s" % mgVal ) )
if 'rotatingWheels' in parDic['ACS_GLOBAL']:
if dict2Val( parDic['ACS_GLOBAL']['rotatingWheels'] ) == 1:
rwVal = True
elif dict2Val( parDic['ACS_GLOBAL']['rotatingWheels'] ) == 0:
rwVal = False
else:
rwVal = dict2Val( parDic['ACS_GLOBAL']['rotatingWheels'] )
solTable.append( ( "Rotating wheels", "%s" % rwVal ) )
rep.addTable( solTable, "Solution Strategy", ref="tab:sol")
matTable = []
if 'ACS_MATERIAL_MODELS' in parDic:
for matMdl in parDic['ACS_MATERIAL_MODELS']:
matDens = dict2Val( parDic['ACS_MATERIAL_MODELS'][matMdl]['density'] )
matVisc = dict2Val( parDic['ACS_MATERIAL_MODELS'][matMdl]['viscosity'] )
break
else:
matDens = 1.225
matVisc = 1.781e-5
matTable.append( ( "Density", "%s kg/m3" % matDens ) )
matTable.append( ( "Dynamic Viscosity", "%s kg/m-sec" % matVisc ) )
rep.addTable( matTable, "Material Model", ref="tab:mat" )
#===========================================================================
# Results
#===========================================================================
rep.addSection("Results")
rep.addText("In this section the results of the CFD run are reported. "\
"Table \\ref{tab:res} gives an overview of the different "\
"result types." )
fsiFlag = False
if 'fsi' in parDic['ACS_GLOBAL']:
if dict2Val(parDic['ACS_GLOBAL']['fsi']):
fsiFlag = True
dirEntries = os.listdir( os.path.join( os.getcwd(), 'Figures' ) )
monitorPoints = ""
ref = ""
fileNames = []
for item in dirEntries:
if 'pressure' in item:
monitorPoints = monitorPoints + "pressure, "
ref = ref + "\\ref{fig:pressCrv}, "
fileNames.append(item)
elif 'vel' in item:
monitorPoints = monitorPoints + "velocity, "
ref = ref + "\\ref{fig:velCrv}, "
fileNames.append(item)
elif 'disp' in item:
monitorPoints = monitorPoints + "displacement, "
ref = ref + "\\ref{fig:dispCrv}, "
fileNames.append(item)
elif 'visc' in item:
monitorPoints = monitorPoints + "eddy_viscosity, "
ref = ref + "\\ref{fig:viscCrv}, "
fileNames.append(item)
monitorPoints = monitorPoints.rsplit(',' , 1)[0]
ref = ref.rsplit(',' , 1)[0]
comps = ref.split(',')
for ind,comp in enumerate(comps):
comps[ind] = comp.split('{')[-1].split('}')[0]
resTable = []
resTable.append( ( "Table \\ref{tab:coeff}",
"Drag, lift and cross coefficient of "\
"individual parts and their totals" ) )
resTable.append( ( "Table \\ref{tab:areas}",
"Drag area of individual parts and their totals" ) )
resTable.append( ( "Figure \\ref{fig:crvList1}",
"Drag, lift and cross coefficient history" ) )
resTable.append( ( "Figure \\ref{fig:bdypres}",
"Pressure contours on body" ) )
resTable.append( ( "Figure \\ref{fig:mppress}",
"Pressure coefficient on body surface" ) )
resTable.append( (
"Figure \\ref{fig:bdyplusf}, \\ref{fig:bdyplusr}, \\ref{fig:bdyplusb}",
"Body Surface y+ contours" ) )
resTable.append( ( "Figure \\ref{fig:strmtp}, \\ref{fig:strmsd}",
"Streamlines around body" ) )
compfsi = "Figure"
if fsiFlag:
resTable.append( ( "Table \\ref{tab:flex}",
"Drag, lift and cross coefficients for the flexible components"))
resTable.append( ( "Table \\ref{tab:monitor}",
"Monitor point information" ) )
for comp in fsiDic:
compfsi = compfsi + " \\ref{fig:yPlus_%s}" % str(comp)
resTable.append( ( "%s" % compfsi,
"y+ Contour plots for flexible components" ) )
compStr = ""
for file,comp in zip(fileNames,comps):
compStr = compStr + " \\ref{%s}," % str(comp)
resTable.append( ( "Figure%s" % compStr,
"Displacement, pressure and velocity curves for monitor points"))
rep.addTable( resTable, "Results", ref = "tab:res" )
rep.newPage( )
rep.addTable( dataTable, "Coefficients", ref = "tab:coeff" )
rep.fillVSpace( )
rep.addTable( areaDataTable, "Drag Areas", ref = "tab:areas" )
rep.fillVSpace( )
rep.addText("To compute the above aerodynamic coefficients, "\
"the following equations are used" )
rep.beginBullet()
rep.addText( "\\addtolength{\itemindent}{1.5cm}" )
rep.addItem( "\\indent Drag coefficient, "\
"C_{d}=\\frac{2\\times F_{x}}{rho\\times v^{2}\\times A_{ref}}",
name = "" )
rep.endBullet()
rep.addText("")
rep.beginBullet()
rep.addText( "\\addtolength{\itemindent}{1.5cm}" )
rep.addItem( "\\indent Lift coefficient, "\
"C_{l}=\\frac{2\\times F_{z}}{rho\\times v^{2}\\times A_{ref}}",
name = "" )
rep.endBullet()
rep.addText("")
rep.beginBullet()
rep.addText( "\\addtolength{\itemindent}{1.5cm}" )
rep.addItem( "Cross coefficient, "\
"C_{c}=\\frac{2\\times F_{y}}{rho\\times v^{2}\\times A_{ref}}",
name = "" )
rep.endBullet()
rep.addText(" with")
rep.beginBullet()
rep.addText( "\\addtolength{\itemindent}{2cm}" )
rep.addItem( "F_{x}, F_{y}, and F_{z},", name = "" )
rep.endBullet()
rep.addText("forces are acting on the body in x, y and z directions, "\
"respectively" )
rep.beginBullet()
rep.addText( "\\addtolength{\itemindent}{2cm}" )
if 'ACS_MATERIAL_MODELS' in parDic:
for matMdl in parDic['ACS_MATERIAL_MODELS']:
matDens=dict2Val(parDic['ACS_MATERIAL_MODELS'][matMdl]['density'])
break
else:
matDens = 1.225
rep.addItem( "rho is density of fluid (%s kg/m^3)" % matDens, name = "" )
rep.endBullet()
rep.addText("")
rep.beginBullet()
rep.addText( "\\addtolength{\itemindent}{2cm}" )
rep.addItem( "v_{}", name = "" )
rep.endBullet()
rep.addText("is free stream velocity")
rep.beginBullet()
rep.addText( "\\addtolength{\itemindent}{2cm}" )
rep.addItem( "A_{ref}", name = "" )
rep.endBullet()
rep.addText("is frontal projected area of the object")
rep.beginBullet()
rep.addText( "\\addtolength{\itemindent}{1.5cm}" )
rep.addItem( "Drag area, "\
"C_{d}\\times A_{ref}=\\frac{2\\times F_{x}}{rho\\times v^{2}}",
name = "" )
rep.endBullet()
rep.addText("")
rep.beginBullet()
rep.addText( "\\addtolength{\itemindent}{1.5cm}" )
rep.addItem( "Pressure coefficient, "\
"C_{p}=\\frac{p-p_{infinity}}{0.5\\times rho\\times v^{2}}",
name = "" )
rep.endBullet()
rep.fillVSpace()
if sys.platform == "win32":
rep.addFigure( "Figures/Drag_Plots.png", scale = 1.0 / imgFct,
caption = "Coefficients", ref = "fig:crvList1" )
else:
rep.addFigure( plot1, scale = 1.0 / imgFct,
caption = "Coefficients", ref = "fig:crvList1" )
if fsiFlag:
resTable.append( ( "\\ref{tab:flex}",
"Drag, lift and cross coefficients for the flexible components"))
rep.addTable( fsiTable, "Flexible Part Coefficients", ref="tab:flex")
rep.fillVSpace( )
print "Creating images"
'''
nOutSteps=adb.get('nOutSteps')
outSteps=adb.get('outSteps')
outTimes=adb.get('outTimes')
pressure= adb.getResRatioData( "pressure", type = "final" )
pTim = pressure[1]
pRes = pressure[2]
if len(pTim) != len(pRes):
tranTime = outTimes[len(outTimes)-2]
else:
tranTime = outTimes[len(outTimes)-1]
'''
if ',' in monitorPoints:
monitorPoints = monitorPoints.rsplit(', ' , 1)[0] + ' and ' + \
monitorPoints.rsplit(', ' , 1)[1]
ref = ref.rsplit(', ', 1)[0] + ' and ' + \
ref.rsplit(', ',1)[1]
othTable = [ ("Monitor name", "coordinates") ]
for item in othDir:
x = othDir[item]['coords'][0]
y = othDir[item]['coords'][1]
z = othDir[item]['coords'][2]
tableItem = ( str(item), "(%6.3f,%6.3f,%6.3f)" % ( x, y, z ) )
othTable.append(tableItem)
if ref:
resTable.append( ("%s" % ref, "Monitor points") )
resTable.append( ("\\ref{tab:monitor}", "Monitor point information"))
rep.addTable(othTable, "Monitor Point information",ref="tab:monitor")
for file,comp in zip(fileNames,comps):
caption = ( file.rsplit('.',1)[0] ).replace('_', ' ')
if sys.platform == "win32":
rep.addFigure( 'Figures/'+file, scale = 1.0/imgFct,
caption = caption, ref = comp )
else:
plotfn = os.path.splitext(file)[0]
if plotfn in optDir.keys():
plothnd = str(optDir[plotfn])
rep.addFigure(plothnd, scale = 1.0 / imgFct,
caption = caption, ref = comp)
if 'ACS_BOUNDARY_SURFACES' in parDic:
for bndSrf in parDic['ACS_BOUNDARY_SURFACES']:
for var in dict2Val(
parDic['ACS_BOUNDARY_SURFACES'][bndSrf]['variables'] ):
rep.addFigure( "%s_%s.%s" % (str(bndSrf),str(var),figExt),
scale = 1.0/imgFct,
caption = "user defined boundary surface " + \
str(bndSrf) + '_' + str(var),
ref = "fig:%s_%s" % (str(bndSrf),str(var)) )
sVarDic = { 'x_velocity':'x-velocity',
'y_velocity':'y-velocity',
'z_velocity':'z-velocity',
'x_mesh_displacement':'x-mesh_displacement',
'y_mesh_displacement':'y-mesh_displacement',
'z_mesh_displacement':'z-mesh_displacement' }
if 'ACS_COORDINATE_SURFACES' in parDic:
for crdSrf in parDic['ACS_COORDINATE_SURFACES']:
if 'variables' in parDic['ACS_COORDINATE_SURFACES'][crdSrf]:
variables = dict2Val( parDic['ACS_COORDINATE_SURFACES'][crdSrf]['variables'] )
else:
variables = dict2Val( parDic['ACS_GLOBAL']['coordinate_variables'] )
for var in variables:
if var in sVarDic:
sVar = sVarDic[var]
else:
sVar = var
caption = "%s on %s" % ( str(sVar), str(crdSrf) )
rep.addFigure( "%s_%s.%s" % (str(crdSrf),str(sVar),figExt),
scale = 1.0/imgFct,
caption = caption.replace('_',' '),
ref = "fig:%s_%s" % (str(crdSrf), str(sVar)))
rep.newPage( )
rep.addFigure( "bnd_press.%s" % figExt, scale = 1.0/imgFct,
caption = "Body Surface Pressure Contours", ref = "fig:bdypres" )
'''
rep.addFigure( "coord_press22.%s" % figExt, scale = 1.0/imgFct,
caption = "Mid Plane Pressure Contours", ref = "fig:mppress2" )
rep.addFigure( "coord_press2.%s" % figExt, scale = 1.0/imgFct,
caption = "Cross Plane Pressure Contours", ref = "fig:cppress" )
'''
rep.addFigure( "coord_press.%s" % figExt, scale = 1.0/imgFct,
caption = "Body Surface Pressure Coefficient", ref="fig:mppress")
rep.newPage( )
'''
rep.addFigure( "coord_velocity.%s" % figExt, scale = 1.0/imgFct,
caption = "Mid Plane Velocity Contours", ref = "fig:mpvel" )
rep.addFigure( "coord_velocity2.%s" % figExt, scale = 1.0/imgFct,
caption = "Cross Plane Velocity Contours", ref = "fig:cpvel")
rep.newPage( )
'''
rep.addFigure( "body_y_plus_front.%s" % figExt, scale = 1.0/imgFct,
caption = "Body Surface y+ Front View", ref = "fig:bdyplusf")
rep.addFigure( "body_y_plus_back.%s" % figExt, scale = 1.0/imgFct,
caption = "Body Surface y+ Rear View", ref = "fig:bdyplusr" )
rep.addFigure( "body_y_plus_bottom.%s" % figExt, scale = 1.0/imgFct,
caption = "Body Surface y+ Bottom View", ref = "fig:bdyplusb")
rep.newPage( )
rep.addFigure( "stream_lines_1.%s" % figExt, scale = 1.0/imgFct,
caption = "Stream lines", ref = "fig:strmtp" )
rep.addFigure( "stream_lines_2.%s" % figExt, scale = 1.0/imgFct,
caption = "Stream lines Side View", ref = "fig:strmsd" )
#rep.addFigure( "iso_velocity.%s" % figExt, scale=1.0/imgFct,
#caption = "Iso Surface of Velocity for Q of 1 m/s", ref="fig:isovel")
for comp in fsiDic:
resTable.append( ( "\\ref{fig:yPlus_%s}" % str(comp),
"A y+ Contour plot for flexible component %s" % str(comp) ) )
rep.addFigure( "y_plus_flex_%s.%s" % (str(comp), figExt),
scale = 1.0/imgFct,
caption = "y+ Contour for flexible component " + str(comp),
ref = "fig:yPlus_%s" % str(comp) )
rep.newPage()
print "Done."
#===========================================================================
# Summary
#===========================================================================
rep.addSection("References")
rep.beginBullet()
rep.addItem("Altair Engineering Inc, 2015, Virtual Wind Tunnel, "\
"Online Documentation", name = "" )
rep.addItem("Altair Engineering Inc, 2015, AcuSolve Command "\
"Reference Manual.", name = "" )
rep.addItem("Hucho, W.-H., 1997, Aerodynamics of Road Vehicles, "\
"SAE, ISBN 0-7680-0029-7.", name = "" )
rep.endBullet()
rep.newPage()
#===========================================================================
# Close the report and make PDF
#===========================================================================
rep.close( )
rep.writePdf( )
#===========================================================================
# Remove temporary files
#===========================================================================
'''
try:
dir = "Figures"
for file in os.listdir( "Figures" ):
os.remove( os.path.join( dir, file ) )
os.rmdir( dir )
except:
pass
'''