onera / Fast

Fast CFD solver
https://onera.github.io/Fast/
GNU Lesser General Public License v3.0
12 stars 6 forks source link

display_temporal_criteria provokes segfault for NSTurbulent simple case #13

Open Luispain opened 1 month ago

Luispain commented 1 month ago

Hi everyone,

I came through this issue when making slight adaptions to the provided example # - convergenceHistory (pyTree) -.

I started from such examples, and did slight adaptations :

  1. changed from Euler to NSTurbulent
  2. set modulo_verif = 1
  3. added a wall at imin
  4. added distance to wall
  5. set wall and farfield as families

The script is:


# - convergenceHistory (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import FastS.PyTree as FastS
import FastC.PyTree as FastC
import Connector.PyTree as X
import Converter.Internal as Internal
import Initiator.PyTree as I

ni = 155; dx = 100./(ni-1); dz = 0.01
a1 = G.cart((-50,-50,0.), (dx,dx,dz), (ni,ni,2))

C._addBC2Zone(a1, 'WALL', 'FamilySpecified:WALL', 'imin')
C._fillEmptyBCWith(a1, 'FARFIELD', 'FamilySpecified:FARFIELD', dim=2)
C._addState(a1, 'GoverningEquations', 'NSTurbulent')
I._initConst(a1, MInf=0.4, loc='centers')
C._addState(a1, MInf=0.4)
t = C.newPyTree(['Base', a1])
C._tagWithFamily(t,'FARFIELD')
C._tagWithFamily(t,'WALL')
C._addFamily2Base(t, 'FARFIELD', bndType='BCFarfield')
C._addFamily2Base(t, 'WALL', bndType='BCWall')

import Dist2Walls.PyTree as DTW
walls = C.extractBCOfType(t, 'BCWall')
DTW._distance2Walls(t, walls, loc='centers', type='ortho')

# Numerics
modulo_verif = 1
numb = {}
numb["temporal_scheme"]    = "implicit"
numb["ss_iteration"]       = 3
numb["modulo_verif"]       = modulo_verif
numz = {}
numz["time_step"]          = 0.0007
numz["time_step_nature"]   = "local"
numz["cfl"]                = 4.0
numz["scheme"]             = "roe"
numz["slope"]              = "minmod"
FastC._setNum2Zones(t, numz) ; FastC._setNum2Base(t, numb)

(t, tc, metrics) = FastS.warmup(t, None)

# Number or records to store residuals 
nrec = 100//modulo_verif

#To remove old ConvergenceHistory nodes 
t = C.rmNodes(t, "ZoneConvergenceHistory")

#Convergence history with nrec records
FastS.createConvergenceHistory(t, nrec)

nit = 100; time = 0
time_step = Internal.getNodeFromName(t, 'time_step')
time_step = Internal.getValue(time_step)
for it in range(nit):
    FastS._compute(t, metrics, it, tc)
    if it%modulo_verif == 0:
        FastS.display_temporal_criteria(t, metrics, it)
    time += time_step

# time stamp
Internal.createUniqueChild(t, 'Iteration', 'DataArray_t', value=nit)
Internal.createUniqueChild(t, 'Time', 'DataArray_t', value=time)
C.convertPyTree2File(t, 'out.cgns')

This script provokes segfault at termination (even if everything seems to be ok during computation).

The strange behavior is as follows: if we supress the line FastS.display_temporal_criteria(t, metrics, it), then the segfault dissappears.

Run on ONERA LD machine using cassiopee v4 environment.

Thank you in advance for your help,

Luis

IvanMary69 commented 1 month ago

hello,

did you try to suppress the convergenceHistory node before the call to warmup function?

Ivan

Luispain commented 1 month ago

Hi Ivan,

I tried what you said, removing convergenceHistory nodes before the coll to warmup function but it does not seem to work either :


# - convergenceHistory (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import FastS.PyTree as FastS
import FastC.PyTree as FastC
import Connector.PyTree as X
import Converter.Internal as Internal
import Initiator.PyTree as I

ni = 155; dx = 100./(ni-1); dz = 0.01
a1 = G.cart((-50,-50,0.), (dx,dx,dz), (ni,ni,2))

C._addBC2Zone(a1, 'WALL', 'FamilySpecified:WALL', 'imin')
C._fillEmptyBCWith(a1, 'FARFIELD', 'FamilySpecified:FARFIELD', dim=2)
C._addState(a1, 'GoverningEquations', 'NSTurbulent')
I._initConst(a1, MInf=0.4, loc='centers')
C._addState(a1, MInf=0.4)
t = C.newPyTree(['Base', a1])
C._tagWithFamily(t,'FARFIELD')
C._tagWithFamily(t,'WALL')
C._addFamily2Base(t, 'FARFIELD', bndType='BCFarfield')
C._addFamily2Base(t, 'WALL', bndType='BCWall')

import Dist2Walls.PyTree as DTW
walls = C.extractBCOfType(t, 'BCWall')
DTW._distance2Walls(t, walls, loc='centers', type='ortho')

# Numerics
modulo_verif = 1
numb = {}
numb["temporal_scheme"]    = "implicit"
numb["ss_iteration"]       = 3
numb["modulo_verif"]       = modulo_verif
numz = {}
numz["time_step"]          = 0.0007
numz["time_step_nature"]   = "local"
numz["cfl"]                = 4.0
numz["scheme"]             = "roe"
numz["slope"]              = "minmod"
FastC._setNum2Zones(t, numz) ; FastC._setNum2Base(t, numb)

#To remove old ConvergenceHistory nodes 
t = C.rmNodes(t, "ZoneConvergenceHistory")

(t, tc, metrics) = FastS.warmup(t, None)

# Number or records to store residuals 
nrec = 100//modulo_verif

#Convergence history with nrec records
FastS.createConvergenceHistory(t, nrec)

nit = 100; time = 0
time_step = Internal.getNodeFromName(t, 'time_step')
time_step = Internal.getValue(time_step)
for it in range(nit):
    FastS._compute(t, metrics, it, tc)
    if it%modulo_verif == 0:
        FastS.display_temporal_criteria(t, metrics, it)
    time += time_step

# time stamp
Internal.createUniqueChild(t, 'Iteration', 'DataArray_t', value=nit)
Internal.createUniqueChild(t, 'Time', 'DataArray_t', value=time)
C.convertPyTree2File(t, 'out.cgns')

I still have the segmentation fault at iteration 85.

Luis