Spatial Weighting of Losses with STL geometries


I’m trying to implement the spatial weighting loss for the nonslip boundary condition in a Navier-Stokes problem. This is the code I’m using, interior_mesh represents the surface of the domain of interest, which is a closed .stl mesh similar to the one in the aneurysm task.

  # interior
  interior = PointwiseInteriorConstraint(
      outvar={"continuity": 0,"momentum_x": 0, "momentum_y": 0, "momentum_z": 0},
          "continuity": interior_mesh.sdf,
          "momentum_x": interior_mesh.sdf,
          "momentum_y": interior_mesh.sdf,
          "momentum_z": interior_mesh.sdf,
  domain.add_constraint(interior, "interior")

I keep getting the following error.

Error executing job with overrides: []
Traceback (most recent call last):
  File "/modulus/examples/RT/code/", line 141, in run
    continuity = PointwiseInteriorConstraint(
  File "/opt/conda/lib/python3.8/site-packages/modulus-22.3-py3.8.egg/modulus/continuous/constraints/", line 411, in __init__
    lambda_weighting = _compute_lambda_weighting(
  File "/opt/conda/lib/python3.8/site-packages/modulus-22.3-py3.8.egg/modulus/continuous/constraints/", line 907, in _compute_lambda_weighting
    computed_lambda_weighting[key] = np_lambdify(
  File "/opt/conda/lib/python3.8/site-packages/modulus-22.3-py3.8.egg/modulus/sympy_utils/", line 144, in grouped_lambda
  File "/opt/conda/lib/python3.8/site-packages/modulus-22.3-py3.8.egg/modulus/sympy_utils/", line 60, in lambdify_f_i
    return f_i(**{key: x[key] for key in args})
  File "/opt/conda/lib/python3.8/site-packages/modulus-22.3-py3.8.egg/modulus/sympy_utils/", line 60, in <dictcomp>
    return f_i(**{key: x[key] for key in args})
KeyError: 'points'

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
1 Like

Hi @xtaltec

Is this with Modulus version 22.07? If so please try:

     "continuity": Symbol("sdf"),
     "momentum_x": Symbol("sdf"),
     "momentum_y": Symbol("sdf"),

The heat sink examples typically have this such as FPGA and three fin.