Efficient Selection of Multiple surfaces as boundaries

Please login with a confirmed email address before reporting spam

Hello everyone,

I’m modeling a system in COMSOL where two rectangular boundary regions must be dynamically moved across a surface, as guided by an optimization algorithm. My current method updates rectangle coordinates on a workplane for each optimization step, but this requires running form union and remeshing every time boundaries change, which is very computationally expensive.

As an alternative, I’m considering pre-generating hundreds of small rectangles on the surface as potential boundary areas. For each optimization iteration, I would simply select subsets of these rectangles to define "terminal" and "ground" regions for electric current physics, without touching the geometry or mesh modules.

To clarify:

Geometry and mesh remain unchanged; only boundary conditions are reassigned among rectangles. I need an efficient way to programmatically select which rectangles to use at each step, ideally automated via MATLAB LiveLink. Currently, I reference rectangles by their surface numbers, which works for a simple test case, but managing hundreds will quickly become unwieldy. I’d like to avoid manually tracking indices.

My main questions:

Is this approach feasible for avoiding repeated form union and remeshing while constantly changing boundary conditions? Is there a robust way in COMSOL to tag or systematically reference large numbers of geometric entities for flexible boundary condition management, especially with MATLAB automation?

I've attached a sample model showcasing this approach, with hundreds of small rectangles and the previous large-rectangle method for reference. For this model, my optimization algorithm will guide me to shit my terminal and based on that I want to select another set of rectangles.

Thank you in advance for any insights!



Reply

Please read the discussion forum rules before posting.

Please log in to post a reply.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.