# Discussion Forum

## Average coordinate of a boundary face

Dear all,

I am looking for a method to compute the average coordinate (centroid) of a complete boundary face. While I found built-in functions to compute the mean or centroid of an expression on a mesh element, there doesnt seem to be a function to do that for a boundary.

Since I need to do that for 256 boundary faces non-local-couplings or integration operators are not an option since they need to be defined for each face separately.

Any help or idea you can provide is greatly appreciated.

Best regards, André.

PS: I have 16x16 individual domains with the a certain boundary condition on the top face of the domain. To implement the boundary condition with a general expression I want to use the coordinate of the domain/face to compute the array indices for each of the faces and use these in the equation for the bc. If there is a different method to do that, I also appreciate other ideas. Thanks!

9 Replies Last Post 2023年6月8日 GMT-4 03:01

Posted: 4 months ago

Hello Andre,

If you are only considering using the coordinates of the centroid as a proxy for the face number, then an option would be to use "dom" to get the face number. In the attached file, I set up an array of cubes where the temperature on the top face of each cube equals that face's number.

Best,

Jeff

-------------------
Jeff Hiller

Posted: 4 months ago

Hello Jeff,

I do not use the face number but derive the array index in x and y direction. This way I can "identify" each array by a couple of integer, i. e. 2,2 for the second face in the x and y direction. Since I know the the geometric parameters of the array I can then compute the distance to a focal point taking into account the steering direction of the array and subsequently compute appropriate time delay for each face.

Hope this makes what I intend clearer. If there is another way to achieve what I want I am open to suggestions.

Posted: 4 months ago

Wouldn't you prefer to compute the distance to the focal point by using the actual x and y coordinates of individual points on the faces, rather than via the coordinates of the centroids of those faces?

Jeff

-------------------
Jeff Hiller

Posted: 4 months ago

Hello Jeff,

you are absolutely correct, why not use the coordinates directly, my mistake. Probably a case of not seeing the forrest because of all the trees.

Regarding your point of using the points on the faces directly. The faces are oscillating membranes of sufficiently small diameter. Therefore I intend to model them as point sources as an approximation.

However, the problem remains the same since I still need the face centroid and not the mesh element centroid.

Best regards, André

Posted: 4 months ago

Hello Jeff,

just checked the manual regarding the built-in dom variable. It apparently returns the boundary face number as you said. Would something like centroid(dom(x)) return the x coordinate of the boundary?

I am currently on my phone and cannot test it.

Best regards, André

Posted: 4 months ago

My question is whether you wouldn't be better off NOT making the approximation of replacing the actual coordinates of the points of each face with the coordinates of the centroid of that face.

Jeff

-------------------
Jeff Hiller

Posted: 4 months ago

Hello Jeff,

Regarding your last comment, it is certainly easier to implement.

Maybe more details are required to understand what I am doing. I have a phased array of 16x16 ultrasonic transducers at 40kHz. I model the transducer using a normal acceleration boundary condition with a and pressure acoustics (implemented using the PDE interface) in a frequency domain study. The phase of each transducer is computed from a time delay that is derived from the distance difference from a reference point on the array (RR) and the respective transducer point (RT) to the focal point: deltaT = (RT-RR)/c0 where c0 is the speed of sound. Then in the frequency domain the bc for the transducer should be pressureAmplitudeexp(- i omega deltaT), where omega is the angular frequency and i the imaginary unit.

Since each transducer has just one delay, IMO the entire boundary must have the same delay in each point on it. Using the x-coordinate of each mesh point on the boundary would compute different time delays for each point and hence different phases for them, which IMO is too far from the actual behavior of the array.

Hope I could make the problem I am facing and the reason why I want to follow this approach clearer.

Best regards and thank you again for your help, André

Posted: 4 months ago

Thanks, André, now I think I get the gist of it.

Is your array a simple one (plane, with the shifts in the x and y directions constant)? If so, would you be able to use the mod, floor and ceil operators to determine from the coordinates of each point on a face the 2 indices for the face and from there the coordinates of the centroid of that face?

Jeff

-------------------
Jeff Hiller

Posted: 4 months ago
Updated: 4 months ago

Hello Jeff,

yes the array has constant pitch in both directions and consist of transducers of constant size.

And what you suggested using the mod/ceil/floor operator I just thought off on my way home after work, but think I found another solution, that might work as well.

Seting up a piecwise function in the definitions of the component with intervals of the coordinates in x and y direction and use the centroid as the function value should work. Testing it now and waiting for the results to check if this does work as intended.