Opened 4 months ago

Last modified 4 months ago

#2131 confirmed defect

Boundary thorn

Reported by: miguel.zilhao.nogueira@… Owned by:
Priority: major Milestone:
Component: EinsteinToolkit thorn Version: development version
Keywords: Boundary Cc:

Description (last modified by Roland Haas)

i was trying to do a (unigrid) run with "scalar" boundary conditions on some variables but with uneven boundary width, ie width of 2 grid points on the x and y axis and 0 on the z axis. in the documentation of the Boundary thorn it states that one should create a table passing this information in an array called "BOUNDARY_WIDTH":

"The table handle identifies a table which holds extra arguments for the particular boundary condition that is requested. For example, if a negative value is passed for the boundary width, then the boundary condition will look in this table for a 2d-element integer array, which holds the width of each face of the boundary (for a d dimensional grid variable). (The first element of the array holds the width of the ‘-x’ face, the second the ‘+x’ face, the third the ‘-y’ face, etc.)"

so i've accordingly created the following table

  call Util_TableCreateFromString(param_table_handle, "BOUNDARY_WIDTH = { 2 2 2 2 0 0 }")

and then registered the variables with

   ierr = Boundary_SelectGroupForBC(cctkGH, CCTK_ALL_FACES, -one,         &
        param_table_handle, "ScalarBase::phi", "scalar")

however, i was getting errors like the following:

  Boundary/src/Check.c:130: BndSanityCheckWidths: Assertion `dim < (int)sizeof(dims)' failed.

inspecting that file, this is only triggered if (boundary_widths[i] > 100 || boundary_widths[i] < 0) which meant that my BOUNDARY_WIDTH array was likely not being parsed correctly. digging a little bit deeper, i've found the following in ScalarBoundary.c:138 (and analogous for the other files under CactusBase/Boundary/src):

     /* Determine boundary width on all faces */
     /* allocate memory for buffer */
     gdim = CCTK_GroupDimI(gi);
     if (gdim > max_gdim) {
       width_alldirs =
           (CCTK_INT *)realloc(width_alldirs, 2 * gdim * sizeof(CCTK_INT));
       max_gdim = gdim;

     /* fill it with values, either from table or the boundary_width
        parameter */
     if (widths[i] < 0) {
       err = Util_TableGetIntArray(tables[i], gdim, width_alldirs,

it seems to me that this last line should be instead

       err = Util_TableGetIntArray(tables[i], 2 * gdim, width_alldirs,

for consistency with the rest of the file and with the documentation, right? indeed, with this change the errors disappeared. i've attached a simple patch that applies this on this file, but i guess an equivalent change would be needed also for the rest of the Boundary files...

if this patch is correct, could this be ported to the current release? and if it's not correct, is there anything i'm missing, in order to register the boundary conditions?

Attachments (1)

ScalarBoundary.patch (657 bytes) - added by miguel.zilhao.nogueira@… 4 months ago.

Download all attachments as: .zip

Change History (4)

Changed 4 months ago by miguel.zilhao.nogueira@…

Attachment: ScalarBoundary.patch added

comment:1 Changed 4 months ago by Erik Schnetter

Yes, this looks like an error in the code.

We will also need to have a look at the other files in the same directory,
as they might contain the same error.

comment:2 Changed 4 months ago by Roland Haas

Description: modified (diff)

comment:3 Changed 4 months ago by Roland Haas

Status: newconfirmed

Modify Ticket

Change Properties
Set your email in Preferences
as confirmed The ticket will remain with no owner.
Next status will be 'review'.
as The resolution will be set.
to The owner will be changed from (none) to the specified user.
The owner will be changed from (none) to anonymous.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.