Skip to content

Commit

Permalink
Connector: corr. BCFlux
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit128 committed Jan 31, 2025
1 parent f68e89d commit e9d7469
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 58 deletions.
8 changes: 4 additions & 4 deletions Cassiopee/Apps/Apps/Fast/IBM.py
Original file line number Diff line number Diff line change
Expand Up @@ -2131,12 +2131,12 @@ def buildConservativeFlux__(self, t, tc):
#Internal.createUniqueChild( tmp, 'PointRange', 'DataArray_t', winD[:,idir])
#Internal.createUniqueChild( tmp, 'PointRangeDonor', 'DataArray_t', win[:,idir])

C._addBC2Zone(zr_t, 'Flux_'+zd_t[0]+'_'+name, 'BCFluxOctree_C', wrange=win[:,idir])
C._addBC2Zone(zr_t, 'Flux_'+zd_t[0]+'_'+name, 'BCFluxOctreeC', wrange=win[:,idir])
if name[2]=='i':
name2= name[0:2]+'ax'
else:
name2= name[0:2]+'in'
C._addBC2Zone(zd_t, 'Flux_'+zr_t[0]+'_'+name2, 'BCFluxOctree_F', wrange=winD[:,idir])
C._addBC2Zone(zd_t, 'Flux_'+zr_t[0]+'_'+name2, 'BCFluxOctreeF', wrange=winD[:,idir])

else:

Expand Down Expand Up @@ -2290,12 +2290,12 @@ def buildConservativeFlux__(self, t, tc):
#Internal.createUniqueChild(tmp,'PointRange', 'DataArray_t', winD[:,idir])
#Internal.createUniqueChild( tmp, 'PointRangeDonor', 'DataArray_t', win[:,idir])

C._addBC2Zone(zr_t, 'Flux_'+zd_t[0]+'_'+name, 'BCFluxOctree_C', wrange=win[:,idir])
C._addBC2Zone(zr_t, 'Flux_'+zd_t[0]+'_'+name, 'BCFluxOctreeC', wrange=win[:,idir])
if name[2]=='i':
name2= name[0:2]+'ax'
else:
name2= name[0:2]+'in'
C._addBC2Zone(zd_t, 'Flux_'+zr_t[0]+'_'+name2, 'BCFluxOctree_F', wrange=winD[:,idir])
C._addBC2Zone(zd_t, 'Flux_'+zr_t[0]+'_'+name2, 'BCFluxOctreeF', wrange=winD[:,idir])

else: print("Error: build flux conservative octree"+name, sz, count[idir], win[:,idir])
#stop
Expand Down
14 changes: 7 additions & 7 deletions Cassiopee/Connector/Connector/compactTransfers.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ def miseAPlatDonorTree__(zones, tc, graph=None, list_graph=None, nbpts_linelets=
for c4, bc in enumerate(bcs):
bcname = bc[0].split('_') #
btype = Internal.getValue(bc)
if 'BCFluxOctree_F' == btype and bcname[1]==zRname: nbfluCons+=1 #flux donneur(Fine)
if 'BCFluxOctree_C' == btype: #flux receveur (Coarse)
if 'BCFluxOctreeF' == btype and bcname[1]==zRname: nbfluCons+=1 #flux donneur(Fine)
if 'BCFluxOctreeC' == btype: #flux receveur (Coarse)
if bcname[2][0:5]=='imin': idir_tg=2
elif bcname[2][0:5]=='imax': idir_tg=1
elif bcname[2][0:5]=='jmin': idir_tg=4
Expand Down Expand Up @@ -414,7 +414,7 @@ def miseAPlatDonorTree__(zones, tc, graph=None, list_graph=None, nbpts_linelets=
shift_coef = shift_coef + sizeR[i]

param_int[i+shift_graph] = NbP2P + shift #adresse echange
shift = shift + sizeproc[i]
shift = shift + sizeproc[i]
size_ptflux.append(0)
size_ptlist.append(0)
size_ptlistD.append(0)
Expand Down Expand Up @@ -443,13 +443,13 @@ def miseAPlatDonorTree__(zones, tc, graph=None, list_graph=None, nbpts_linelets=
#recherche raccord conservatif
zd = zones[NozoneD]
nbfluCons=0
bcs = Internal.getNodesFromType2(zd, 'BC_t')
bcs = Internal.getNodesFromType2(zd, 'BC_t')
no_bc=[]
for c1, bc in enumerate(bcs):
bcname = bc[0].split('_')
btype = Internal.getValue(bc)
if 'BCFluxOctree_F' == btype and bcname[1]==zRname:
nbfluCons+=1
if 'BCFluxOctreeF' == btype and bcname[1] == zRname:
nbfluCons += 1
no_bc.append(c1)
param_int_zD = Internal.getNodeFromName2( zd, 'Parameter_int' )[1]
#print("bc", s[0], bc[0])
Expand Down Expand Up @@ -879,7 +879,7 @@ def miseAPlatDonorTree__(zones, tc, graph=None, list_graph=None, nbpts_linelets=
for c1, bc in enumerate(bcs):
bcname = bc[0].split('_')
btype = Internal.getValue(bc)
if 'BCFluxOctree_F' == btype and bcname[1]==zRname:
if 'BCFluxOctreeF' == btype and bcname[1]==zRname:
nbfluCons+=1
no_bc.append(c1)
param_int_zD = Internal.getNodeFromName2( zd, 'Parameter_int' )[1]
Expand Down
46 changes: 22 additions & 24 deletions Cassiopee/Generator/Generator/IBM.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Mesh generation for IBM"""
from . import Generator
from . import generator
from . import PyTree as G

import Converter.PyTree as C
Expand Down Expand Up @@ -1414,49 +1413,48 @@ def checkCartesian(t, nghost=0):
"""Checks if the provided mesh in Cartesian or Rectilinear.
Usage: checkCartesian(t, nghost)"""
dimPb = Internal.getNodeFromName(t, 'EquationDimension')
if dimPb is None: raise ValueError('prepareIBMData: EquationDimension is missing in input tree.')
if dimPb is None: raise ValueError('checkCartesian: EquationDimension is missing in input tree.')
dimPb = Internal.getValue(dimPb)

nghostZ=0
if dimPb==3: nghostZ=nghost
nghostZ = 0
if dimPb == 3: nghostZ = nghost

isCartesian=1
isCartesian = 1
for z in Internal.getZones(t):
##X Direction
coord = Internal.getNodeFromName(z,'CoordinateX')[1]
i = 0
dx = coord[i+1+nghost, 0+nghost, 0+nghostZ] - coord[i +nghost, 0+nghost, 0+nghostZ]
coord = Internal.getNodeFromName2(z, 'CoordinateX')[1]
i = 0
dx = coord[i+1+nghost, 0+nghost, 0+nghostZ] - coord[i+nghost, 0+nghost, 0+nghostZ]
for i in range(1,4):
dx2 = coord[i+1+nghost, 0+nghost, 0+nghostZ] - coord[i +nghost, 0+nghost, 0+nghostZ]
dx2 = coord[i+1+nghost, 0+nghost, 0+nghostZ] - coord[i+nghost, 0+nghost, 0+nghostZ]
diff = abs(dx2-dx)
if diff>1e-12: isCartesian=0
if isCartesian<1:break
if diff > 1e-12: isCartesian=0
if isCartesian < 1: break

##Y Direction
coord = Internal.getNodeFromName(z,'CoordinateY')[1]
i = 0
dx = coord[0+nghost,i+1+nghost,0+nghostZ] - coord[0+nghost,i +nghost,0+nghostZ]
coord = Internal.getNodeFromName2(z, 'CoordinateY')[1]
i = 0
dx = coord[0+nghost, i+1+nghost, 0+nghostZ] - coord[0+nghost, i+nghost, 0+nghostZ]
for i in range(1,4):
dx2 = coord[0+nghost,i+1+nghost,0+nghostZ] - coord[0+nghost,i +nghost,0+nghostZ]
dx2 = coord[0+nghost, i+1+nghost, 0+nghostZ] - coord[0+nghost, i+nghost, 0+nghostZ]
diff = abs(dx2-dx)
if diff>1e-12: isCartesian=0
if isCartesian<1:break

if diff > 1e-12: isCartesian=0
if isCartesian < 1: break

##Z Direction
if dimPb==3:
coord = Internal.getNodeFromName(z,'CoordinateZ')[1]
coord = Internal.getNodeFromName2(z, 'CoordinateZ')[1]
i = 0
dx = coord[0+nghost,0+nghost,i+1+nghost] - coord[0+nghost,0+nghost,i +nghost]
for i in range(1,4):
dx2 = coord[0+nghost,0+nghost,i+1+nghost] - coord[0+nghost,0+nghost,i +nghost]
diff = abs(dx2-dx)
if diff>1e-12: isCartesian=0
if isCartesian<1:break
if diff > 1e-12: isCartesian=0
if isCartesian < 1: break

isCartesian=Cmpi.allreduce(isCartesian,op=Cmpi.MIN)
if isCartesian==1:cartesian=True
else: cartesian=False
isCartesian = Cmpi.allreduce(isCartesian, op=Cmpi.MIN)
if isCartesian == 1: cartesian=True
else: cartesian=False
return cartesian


Expand Down
38 changes: 19 additions & 19 deletions Cassiopee/Generator/test/checkCartesian_m1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,39 @@

LOCAL = test.getLocal()

if Cmpi.rank==0:
if Cmpi.rank == 0:
a = G.cart((0.,0.,0.), (0.1,0.1,1), (40,40,40))
t = C.newPyTree(['CARTESIAN', a])
C._addState(t, 'EquationDimension', 3)

t = T.splitNParts(t, 10)
t = T.splitNParts(t, 10)
t,stats = D2.distribute(t, 2)
C.convertPyTree2File(t,LOCAL+'/t_TMP.cgns')
t=Cmpi.convertFile2PyTree(LOCAL+'/t_TMP.cgns',proc=Cmpi.rank)
t = Cmpi.convertFile2PyTree(LOCAL+'/t_TMP.cgns',proc=Cmpi.rank)

##Test 1 - Cartesian
cartesian=G_IBM.checkCartesian(t)
isCartesian=0
if cartesian:isCartesian=1
cartesian = G_IBM.checkCartesian(t)
isCartesian = 0
if cartesian: isCartesian=1
Internal._createUniqueChild(t, 'TMP_Node', 'UserDefinedData_t')
Internal._createUniqueChild(Internal.getNodeFromName1(t, 'TMP_Node'), 'Cartesian', 'DataArray_t', value=isCartesian)
if Cmpi.rank==0:
if Cmpi.rank == 0:
test.testT(t,1)
print('Is Cartesian::',cartesian,isCartesian)
print('Is Cartesian::', cartesian, isCartesian)
tsave = Internal.copyTree(t)
#C.convertPyTree2File(t,'t_test1.cgns')

## Test 2 - Z direction is non homogenous --> non Cartesian mesh
Internal._rmNode(t, Internal.getNodeFromName(t, 'TMP_Node'))
coord = Internal.getNodeFromName(Internal.getZones(t)[0],'CoordinateZ')[1]
for i in range(6): coord[:,:,i]=coord[:,:,i]*i/10+coord[:,:,i]
cartesian=G_IBM.checkCartesian(t)
for i in range(6): coord[:,:,i] = coord[:,:,i]*i/10+coord[:,:,i]
cartesian = G_IBM.checkCartesian(t)

isCartesian=0
if cartesian:isCartesian=1
if cartesian: isCartesian=1
Internal._createUniqueChild(t, 'TMP_Node', 'UserDefinedData_t')
Internal._createUniqueChild(Internal.getNodeFromName1(t, 'TMP_Node'), 'Cartesian', 'DataArray_t', value=isCartesian)
if Cmpi.rank==0:
if Cmpi.rank == 0:
test.testT(t,2)
print('Is Cartesian::',cartesian,isCartesian)
#C.convertPyTree2File(t,'t_test2.cgns')
Expand All @@ -52,14 +52,14 @@
t = Internal.copyTree(tsave)
Internal._rmNode(t, Internal.getNodeFromName(t, 'TMP_Node'))
coord = Internal.getNodeFromName(Internal.getZones(t)[0],'CoordinateY')[1]
for i in range(6): coord[:,i,:]=coord[:,i,:]*i/10+coord[:,i,:]
cartesian=G_IBM.checkCartesian(t)
for i in range(6): coord[:,i,:] = coord[:,i,:]*i/10+coord[:,i,:]
cartesian = G_IBM.checkCartesian(t)

isCartesian=0
if cartesian:isCartesian=1
Internal._createUniqueChild(t, 'TMP_Node', 'UserDefinedData_t')
Internal._createUniqueChild(Internal.getNodeFromName1(t, 'TMP_Node'), 'Cartesian', 'DataArray_t', value=isCartesian)
if Cmpi.rank==0:
if Cmpi.rank == 0:
test.testT(t,3)
print('Is Cartesian::',cartesian,isCartesian)
#C.convertPyTree2File(t,'t_test3.cgns')
Expand All @@ -68,18 +68,18 @@
t = Internal.copyTree(tsave)
Internal._rmNode(t, Internal.getNodeFromName(t, 'TMP_Node'))
coord = Internal.getNodeFromName(Internal.getZones(t)[0],'CoordinateX')[1]
for i in range(6): coord[i,:,:]=coord[i,:,:]*i/10+coord[i,:,:]
cartesian=G_IBM.checkCartesian(t)
for i in range(6): coord[i,:,:] = coord[i,:,:]*i/10+coord[i,:,:]
cartesian = G_IBM.checkCartesian(t)

isCartesian=0
if cartesian:isCartesian=1
Internal._createUniqueChild(t, 'TMP_Node', 'UserDefinedData_t')
Internal._createUniqueChild(Internal.getNodeFromName1(t, 'TMP_Node'), 'Cartesian', 'DataArray_t', value=isCartesian)
if Cmpi.rank==0:
if Cmpi.rank == 0:
test.testT(t,4)
print('Is Cartesian::',cartesian,isCartesian)
#C.convertPyTree2File(t,'t_test4.cgns')

del t
del tsave
if Cmpi.rank==0: os.remove(LOCAL+'/t_TMP.cgns')
if Cmpi.rank == 0: os.remove(LOCAL+'/t_TMP.cgns')
1 change: 0 additions & 1 deletion Cassiopee/Generator/test/checkCartesian_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import Converter.Internal as Internal
import Generator.PyTree as G
import Generator.IBM as G_IBM
import random

a = G.cart((0.,0.,0.), (0.1,0.1,1), (20,20,20))
t = C.newPyTree(['CARTESIAN', a])
Expand Down
1 change: 0 additions & 1 deletion Cassiopee/Generator/test/checkCartesian_t2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import Converter.Internal as Internal
import Generator.PyTree as G
import Generator.IBM as G_IBM
import random

a = G.cart((0.,0.,0.), (0.1,0.1,1), (20,20,2))
t = C.newPyTree(['CARTESIAN', a])
Expand Down
1 change: 0 additions & 1 deletion Cassiopee/Generator/test/checkCartesian_t3.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import Converter.Internal as Internal
import Generator.PyTree as G
import Generator.IBM as G_IBM
import random

a = G.cart((0.,0.,0.), (0.1,0.1,1), (40,40,40))
t = C.newPyTree(['CARTESIAN', a])
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/KCore/KCore/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ def checkObject_(objet, refObjet, reference):
#=============================================================================
def testO(objet, number=1):
"""Test python object."""
# perform some sort on dict to be predictible
if isinstance(objet, dict):
# perform some sort on dict to be predictible
from collections import OrderedDict
objet = OrderedDict(sorted(objet.items(), key=lambda t: t[0]))

Expand Down

0 comments on commit e9d7469

Please sign in to comment.