Skip to content

An Error related to "BoxToCell" #832

@friedenhe

Description

@friedenhe

Discussed in #825

Originally posted by WangWen-kang May 7, 2025
Dear Prof. He
I run into a problem when I test the Periodic_hill tutorial. I changed the sources of UFieldVar and BetaVar to "boxToCell". The related code excerpt is as following

    "function": {
        "UFieldVar": {
            "type": "variance",
            "source": "boxToCell",#Options are: allCells, patchToFace, or boxToCell
            "min": [0.0, 0.0, 0.0],
            "max": [3.0, 1.0, 1.0],
            "scale": 1.0,
            "mode": "field",
            "varName": "U",
            #"data":"Udata", the class search for varName+"data" Automatically
            "varType": "vector",
            "components": [0, 1],
            "timeDependentRefData": False,
        },
        "betaVar": {
            "type": "variance",
            "source": "boxToCell",#Options are: allCells, patchToFace, or boxToCell
            "min": [0.0, 0.0, 0.0],
            "max": [3.0, 1.0, 1.0],
            "scale": 1.0,
            "mode": "field",
            "varName": "betaFINuTilda",
            "varType": "scalar",
            #components": [0, 1],# need to add components when changed to vector
            "timeDependentRefData": False,
        },
    },

The total domain of the periodic hill channel is 0<x<9, 0<y<3. So the box I defined is close to the inlet. Then I run the optimization, and this error pops out.

Time = 4000

U Initial residual: (8.771002271424421e-07 3.032438309462439e-07 0.05643213808966887)
U   Final residual: (2.583228439216592e-08 1.638783373336687e-08 0.005531226451734137)
p Initial residual: 6.567763486324534e-06
p   Final residual: 5.277840886562293e-06
Time step continuity errors : sum local = 3.790311999558141e-09
                                 global = -8.967393233392048e-21
                             cumulative = -1.773041426170868e-18
nuTilda Initial residual: 7.884177505128676e-07
nuTilda   Final residual: 4.731480442453503e-08
Bounding nuTilda>1e-16
UFieldVar: 7.279209604676434e-06 final: 7.279209604676434e-06
betaVar: 0.6579903404115919 final: 0.6579903404115919
yPlus min: 0.04722117146807396 max: 0.568779943167962 mean: 0.3408143097966469
ExecutionTime = 123.24 s  ClockTime = 123 s

    Writing cell-centre field C to 4000
    Writing the x component field of the cell-centres Cx to 4000
    Writing the y component field of the cell-centres Cy to 4000
    Writing the z component field of the cell-centres Cz to 4000
End

Printing Primal Residual Statistics.
U Residual Norm2: (3.185704274202537e-07 3.497185123745539e-08 2.397127734052122e-18)
U Residual Mean: (4.266514115025727e-09 2.003633842073476e-10 2.56904504616983e-20)
U Residual Max: (1.277554495938797e-08 6.34085529460475e-09 2.72082254514642e-19)
p Residual Norm2: 2.068401886328395e-06
p Residual Mean: 1.789652285070416e-08
p Residual Max: 5.000025626296046e-07
nuTilda Residual Norm2: 2.419979747523048e-09
nuTilda Residual Mean: 2.873135448567068e-11
nuTilda Residual Max: 1.512689429284541e-10
phi Residual Norm2: 4.553997430715362e-07
phi Residual Mean: 1.62728178838802e-09
phi Residual Max: 1.503339096242937e-08
 
 
Nonlinear constraints
None

Objectives
{'obj.val': array([0.65799762])}

Computing d[UFieldVar]/d[aero_states]^T * psi
Computing d[UFieldVar]/d[beta]^T * psi
Computing d[betaVar]/d[aero_states]^T * psi
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind
[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run 
[0]PETSC ERROR: to get more information on the crash.
[0]PETSC ERROR: Run with -malloc_debug to check if memory corruption is causing the crash.
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
with errorcode 59.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------

Such error disappears and the code runs perfectly when I use very large boxes, such as min=[-100 -100 -100] max=[100 100 100]. It seems that the box has to be larger than the whole domain in order to avoid this error. Could you give me some hint why this happens? What should I do if I only want to select certain area for my object function? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions