Skip to content

Commit

Permalink
Merge pull request #52 from antjost/dev
Browse files Browse the repository at this point in the history
[IBM] Add filament & wire mesh model (WMM) IBC.
  • Loading branch information
benoit128 authored Jun 21, 2024
2 parents 3c11ff3 + 10afb7a commit a561510
Show file tree
Hide file tree
Showing 8 changed files with 418 additions and 91 deletions.
7 changes: 7 additions & 0 deletions Cassiopee/Apps/Apps/Fast/IBM.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@

__IBCNameServer__={}


## ============================= June 2024 =================================
## No further developments in this file. All IBM developments need to be
## performed in the IBM.py files in each Cassiopee module (e.g.$CASSIOPEE/Cassiopee/Connector/Connector/IBM.py)
## Any developments in this file will be REJECTED to be merged (pull request) in the official/upstream ONERA Cassiopee.
## Please address any questions to: Christophe Benoit, Benjamin Constant, Antoine Jost, and Stephanie Peron.

def getIBCDName(proposedName):
global __IBCNameServer__
(ibcname,__IBCNameServer__) = C.getUniqueName(proposedName, __IBCNameServer__)
Expand Down
398 changes: 341 additions & 57 deletions Cassiopee/Connector/Connector/IBM.py

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cassiopee/Connector/test/buildFrontIBMPT_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=2)
XIBM._blankingIBM(t, tb, dimPb=2)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=2)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=2)
test.testT(t, 1)
test.testT(tc, 11)

Expand All @@ -36,7 +36,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=2, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=2, frontType=42)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=2)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=2)
test.testT(t, 2)
test.testT(tc, 21)

Expand All @@ -55,7 +55,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=2, correctionMultiCorpsF42=True, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=2, correctionMultiCorpsF42=True, frontType=42)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=2)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=2)
test.testT(t, 3)
test.testT(tc, 31)

Expand All @@ -72,7 +72,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=2, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=2, frontType=42, blankingF42=True)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=2)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=2)
test.testT(t, 4)
test.testT(tc, 41)

Expand All @@ -89,6 +89,6 @@
XIBM._dist2wallIBM(t, tb, dimPb=2, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=2, frontType=42, twoFronts=True)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=2, twoFronts=True)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=2, twoFronts=True)
test.testT(t, 5)
test.testT(tc, 51)
10 changes: 5 additions & 5 deletions Cassiopee/Connector/test/buildFrontIBMPT_t2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=3)
XIBM._blankingIBM(t, tb, dimPb=3)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=3)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=3)
test.testT(t, 1)
test.testT(tc, 11)

Expand All @@ -37,7 +37,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=3, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=3, frontType=42)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42)
test.testT(t, 2)
test.testT(tc, 21)

Expand All @@ -56,7 +56,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=3, correctionMultiCorpsF42=True, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=3, correctionMultiCorpsF42=True, frontType=42)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42)
test.testT(t, 3)
test.testT(tc, 31)

Expand All @@ -73,7 +73,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=3, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=3, frontType=42, blankingF42=True)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42)
test.testT(t, 4)
test.testT(tc, 41)

Expand All @@ -90,6 +90,6 @@
XIBM._dist2wallIBM(t, tb, dimPb=3, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=3, frontType=42, twoFronts=True)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42, twoFronts=True)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42, twoFronts=True)
test.testT(t, 5)
test.testT(tc, 51)
10 changes: 5 additions & 5 deletions Cassiopee/Connector/test/setInterpDataIBMPT_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=2)
XIBM._blankingIBM(t, tb, dimPb=2)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=2)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=2)
XIBM._setInterpDataIBM(t, tc, tb, front, dimPb=2, frontType=1)
test.testT(t, 1)
test.testT(tc, 11)
Expand All @@ -42,7 +42,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=2, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=2, frontType=42)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=2, frontType=42)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=2, frontType=42)
XIBM._setInterpDataIBM(t, tc, tb, front, dimPb=2, frontType=42)
test.testT(t, 2)
test.testT(tc, 21)
Expand All @@ -64,7 +64,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=2, correctionMultiCorpsF42=True, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=2, correctionMultiCorpsF42=True, frontType=42)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=2, frontType=42)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=2, frontType=42)
XIBM._setInterpDataIBM(t, tc, tb, front, front2=front2, dimPb=2, frontType=42)
test.testT(t, 3)
test.testT(tc, 31)
Expand All @@ -84,7 +84,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=2, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=2, frontType=42, blankingF42=True)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=2)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=2)
XIBM._setInterpDataIBM(t, tc, tb, front, dimPb=2, frontType=42)
test.testT(t, 4)
test.testT(tc, 41)
Expand All @@ -104,7 +104,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=2, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=2, frontType=42, twoFronts=True)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=2, frontType=42, twoFronts=True)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=2, frontType=42, twoFronts=True)
XIBM._setInterpDataIBM(t, tc, tb, front, front2=front2, dimPb=2, frontType=42, twoFronts=True)
test.testT(t, 5)
test.testT(tc, 51)
10 changes: 5 additions & 5 deletions Cassiopee/Connector/test/setInterpDataIBMPT_t2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=3)
XIBM._blankingIBM(t, tb, dimPb=3)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=3)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=3)
XIBM._setInterpDataIBM(t, tc, tb, front, dimPb=3, frontType=1)
test.testT(t, 1)
test.testT(tc, 11)
Expand All @@ -38,7 +38,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=3, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=3, frontType=42)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42)
XIBM._setInterpDataIBM(t, tc, tb, front, dimPb=3, frontType=42)
test.testT(t, 2)
test.testT(tc, 21)
Expand All @@ -58,7 +58,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=3, correctionMultiCorpsF42=True, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=3, correctionMultiCorpsF42=True, frontType=42)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42)
XIBM._setInterpDataIBM(t, tc, tb, front, dimPb=3, frontType=42)
test.testT(t, 3)
test.testT(tc, 31)
Expand All @@ -76,7 +76,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=3, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=3, frontType=42, blankingF42=True)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42)
XIBM._setInterpDataIBM(t, tc, tb, front, dimPb=3, frontType=42)
test.testT(t, 4)
test.testT(tc, 41)
Expand All @@ -94,7 +94,7 @@
XIBM._dist2wallIBM(t, tb, dimPb=3, frontType=42)
XIBM._blankingIBM(t, tb, dimPb=3, frontType=42, twoFronts=True)
tc = C.node2Center(t)
t, tc, front, front2 = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42, twoFronts=True)
t, tc, front, front2, frontWMM = XIBM.buildFrontIBM(t, tc, dimPb=3, frontType=42, twoFronts=True)
XIBM._setInterpDataIBM(t, tc, tb, front, front2=front2, dimPb=3, frontType=42, twoFronts=True)
test.testT(t, 5)
test.testT(tc, 51)
30 changes: 17 additions & 13 deletions Cassiopee/Generator/Generator/IBM.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def _addBCsForSymmetry(t, bbox=None, dimPb=3, dir_sym=0, X_SYM=0., depth=2):
def generateIBMMeshPara(tb, vmin=15, snears=None, dimPb=3, dfar=10., dfarList=[], tbox=None,
snearsf=None, check=True, to=None, ext=2,
expand=3, dfarDir=0, check_snear=False, mode=0,
tbOneOver=None, listF1save=[]):
tbOneOver=None, listF1save=[], fileoutpre='./'):
import KCore.test as test
# list of dfars
if dfarList == []:
Expand All @@ -387,7 +387,9 @@ def generateIBMMeshPara(tb, vmin=15, snears=None, dimPb=3, dfar=10., dfarList=[]
else: snearsf.append(1.)

fileout = None
if check: fileout = 'octree.cgns'
if check:
fileoutpre[-1]='octree.cgns'
fileout = '/'.join(fileoutpre)
# Octree identical on all procs
if to is not None:
if isinstance(to, str):
Expand All @@ -398,9 +400,9 @@ def generateIBMMeshPara(tb, vmin=15, snears=None, dimPb=3, dfar=10., dfarList=[]
parento = None
else:
o = buildOctree(tb, snears=snears, snearFactor=1., dfar=dfar, dfarList=dfarList,
to=to, tbox=tbox, snearsf=snearsf,
dimPb=dimPb, vmin=vmin, fileout=None, rank=Cmpi.rank,
expand=expand, dfarDir=dfarDir, mode=mode)
to=to, tbox=tbox, snearsf=snearsf,
dimPb=dimPb, vmin=vmin, fileout=None, rank=Cmpi.rank,
expand=expand, dfarDir=dfarDir, mode=mode)

if Cmpi.rank==0 and check: C.convertPyTree2File(o,fileout)
# build parent octree 3 levels higher
Expand Down Expand Up @@ -732,6 +734,7 @@ def buildOctree(tb, snears=None, snearFactor=1., dfar=10., dfarList=[], to=None,


def addRefinementZones(o, tb, tbox, snearsf, vmin, dim):
tbSolid = Internal.rmNodesByName(tb, 'IBCFil*')
boxes = []
for b in Internal.getBases(tbox):
boxes.append(Internal.getNodesFromType1(b, 'Zone_t'))
Expand All @@ -752,7 +755,7 @@ def addRefinementZones(o, tb, tbox, snearsf, vmin, dim):
snearl = Internal.getValue(snearl)
snearsf.append(snearl*(vmin-1))


to = C.newPyTree(['Base', o])
end = 0
G._getVolumeMap(to)
Expand All @@ -762,7 +765,7 @@ def addRefinementZones(o, tb, tbox, snearsf, vmin, dim):
while end == 0:
# Do not refine inside obstacles
C._initVars(to, 'centers:cellN', 1.)
to = X_IBM.blankByIBCBodies(to, tb, 'centers', dim)
to = X_IBM.blankByIBCBodies(to, tbSolid, 'centers', dim)
C._initVars(to, '{centers:cellNBody}={centers:cellN}')
nob = 0
C._initVars(to, 'centers:indicator', 0.)
Expand All @@ -771,7 +774,6 @@ def addRefinementZones(o, tb, tbox, snearsf, vmin, dim):
C._initVars(to,'centers:cellN',1.)
tboxl = C.newPyTree(['BOXLOC']); tboxl[2][1][2] = box
to = X_IBM.blankByIBCBodies(to, tboxl, 'centers', dim)

fact = 1.1
while C.getMinValue(to, 'centers:cellN') == 1 and fact < 10.:
print("Info: addRefinementZones: tbox too small - increase tbox by fact = %2.1f"%(fact))
Expand All @@ -782,10 +784,11 @@ def addRefinementZones(o, tb, tbox, snearsf, vmin, dim):

C._initVars(to,'{centers:indicator}=({centers:indicator}>0.)+({centers:indicator}<1.)*logical_and({centers:cellN}<0.001, {centers:vol}>%g)'%volmin2)
nob += 1



end = 1
C._initVars(to,'{centers:indicator}={centers:indicator}*({centers:cellNBody}>0.)*({centers:vol}>%g)'%volmin0)

if C.getMaxValue(to, 'centers:indicator') == 1.:
end = 0
# Maintien du niveau de raffinement le plus fin
Expand Down Expand Up @@ -830,9 +833,10 @@ def octree2StructLoc__(o, parento=None, vmin=21, ext=0, optimized=0, sizeMax=4e6

if parento is None:
## Rectilinear mesh modifications
ZONEStbOneOver = None
ZONEStbOneOverTmp = None
if tbOneOver:
listSavetbOneOverZones = []
ZONEStbOneOver = None

##Add zones to list of TbOneOver list &
##Remove zone from orig list of zones
Expand All @@ -853,8 +857,8 @@ def octree2StructLoc__(o, parento=None, vmin=21, ext=0, optimized=0, sizeMax=4e6
zones = T.mergeCart(zones,sizeMax=sizeMax)
else:
## Rectilinear mesh modifications
ZONEStbOneOver = None

ZONEStbOneOver = None
ZONEStbOneOverTmp = None
eps = 1.e-10
bbo = G.bbox(parento[0])# 1st octant lower left side
xmeano=bbo[3]; ymeano=bbo[4]; zmeano=bbo[5]
Expand Down
34 changes: 33 additions & 1 deletion Cassiopee/Geom/Geom/IBM.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,4 +505,36 @@ def _transformTc2(tc2):

return None


#================================================================================
# Selection/determination of tb for closed solid & filament
#================================================================================
def determineClosedSolidFilament__(tb):
##OUT - filamentBases :list of names of open geometries
##OUT - isFilamentOnly :boolean if there is only a filament in tb
##OUT - isOrthoProjectFirst :bolean to do orthonormal projection first
##OUT - tb :tb of solid geometries only
##OUT - tbFilament :tb of filament geometries only

## General case where only a closeSolid is in tb
## or tb only has a filament
filamentBases = []
isFilamentOnly= False

len_tb = len(Internal.getBases(tb))
for b in Internal.getBases(tb):
if "IBCFil" in b[0]:filamentBases.append(b[0])

if len(filamentBases) == len_tb:isFilamentOnly=True
isOrthoProjectFirst = isFilamentOnly

## if tb has both a closed solid and filaments
tbFilament = Internal.copyTree(tb)
if not isFilamentOnly:
tbFilament = []
for b in filamentBases:
node_local = Internal.getNodeFromNameAndType(tb, b, 'CGNSBase_t')
tbFilament.append(node_local)
Internal._rmNode(tb,node_local)
isOrthoProjectFirst = True
tbFilament = C.newPyTree(tbFilament);
return [filamentBases, isFilamentOnly, isOrthoProjectFirst, tb, tbFilament]

0 comments on commit a561510

Please sign in to comment.