Skip to content

Handle holes in shapes - #29

Merged
thomaslepoix merged 14 commits into
mainfrom
dev/handle-holes
Oct 31, 2025
Merged

Handle holes in shapes#29
thomaslepoix merged 14 commits into
mainfrom
dev/handle-holes

Conversation

@thomaslepoix

@thomaslepoix thomaslepoix commented Oct 13, 2025

Copy link
Copy Markdown
Member

Fixes #18

Trying instructions:

In the example, there are 4 elements:

  • One larger square plane made of a Metal property called Shape.
  • 3 elements made of a Material property called Hole, which actually has the characteristics of Air/Vacuum.
    • The left-bottom one, called Hole::0 totally transverse the plane and is of a higher priority than the plane.
    • The middle one, called Hole::1 totally transverse the plane and is of a lower priority than the plane.
    • The right-top one, called Hole::2 is located exactly like the plane in the Z axis (same width) and is of a lower priority than the plane.

  • First, if needed, you can observe the structure in 3D with AppCSXCAD. On the left panel the light bulb icons can be used to toggle the visibility of all the primitives made of each property. You can also hold the left click and move the mouse to rotate the structure.

     export NIXPKGS_ALLOW_UNFREE=1
     nix develop '.#openems'  --impure --command nixGL AppCSXCAD test/hole.csx
  • Run the mesher.

     nix develop
     	cmake -S . -B build
     	cmake --build build #-j
     	build/src/openemsh_bin -G --input test/hole.csx --lmin 2
  • Zoom enough to fit on the left-bottom hole [CTRL]+ scroll.

  • Click on its left edge, in the dropdown menu, select the MeshlinePolicy with the highest ID number.

  • On the Processing view, you will observe it originates from 2 edges from 2 faces of the cube-alike Hole::0 primitive.

  • To see which one is the second edge, you can display the ZX plane and go back to XY (on the left bar of the Structure view).

  • You will also observe both edges are marked To reverse: true, which means they are both marked with a XMIN and YMIN Normal direction, whereas the MeshlinePolicies they resulted in are marked with a MAX Normal direction.

  • To see what this means, on the Processing view, double-click on an edge, uncheck To reverse. Repeat on the second. Observe the difference in the mesh by undoing/redoing [CTRL]+[Z] / [CTRL]+[SHIFT]+[Z] and stay in the initial reversed (undid) state.

  • To understand why this reversal happens, imagine this inner square as a hole in the Shape metal planar part, as such those edges between a metal zone and an air/vacuum zone must be meshed the same way as the other outer edges of the Shape square, that is to say the thirds rule should apply (a line at 1/3 of the interval around the edge on the metal side, a line at 2/3 on the air side).

  • Now look on the right-top square. It is not at all taken into account in the meshing process because it only exists inside the Shape and is of a lower priority, so it is completely dismissed. YZ or ZX plane displays will be more meaningful.

  • Look on the middle square. It is meshed and not reversed because, due to its lower priority, it is not actually a hole, it is sliced by the Shape into two small cubes above and under it. Those two cubes are normally meshed.

    Note: It is possible to set a background property to air/vacuum too, and dismiss those two cubes in consequence, but it is not used in this example. Also, applying the thirds rule for an air/vacuum primitive is not really relevant, this will be treated as part of Find optimal meshline placement regarding structure edges #15.

@thomaslepoix thomaslepoix added the core Domain AKA business logic label Oct 13, 2025
@thomaslepoix
thomaslepoix force-pushed the dev/handle-holes branch 2 times, most recently from bbb0b8c to 29f10ab Compare October 14, 2025 05:10
@thomaslepoix
thomaslepoix force-pushed the dev/handle-holes branch 2 times, most recently from 0b8f638 to 523f8bb Compare October 14, 2025 05:36
Comment thread src/domain/board.cpp
}

ranges::sort(materials, [](auto const& a, auto const& b) {
auto const& [material_a, priority_a] = a;

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable (unnamed local variable) is not used.
Comment thread src/domain/board.cpp

ranges::sort(materials, [](auto const& a, auto const& b) {
auto const& [material_a, priority_a] = a;
auto const& [material_b, priority_b] = b;

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable (unnamed local variable) is not used.
Comment thread src/domain/board.cpp
for(shared_ptr<Polygon> const& polygon : get_current_state().polygons[plane]) {
for(shared_ptr<Edge> const& edge : polygon->edges) {
auto const& inner_material = polygon->material;
auto const& [immediate_ambient_outer_material, outer_priority] = [&]() -> pair<shared_ptr<Material>, remove_const_t<decltype(Polygon::priority)>> {

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable outer_priority is not used.
// https://github.com/thliebig/openEMS-Project/discussions/347
// Currently do not take care of Isotropy=false
// as_double() selects the first term and ditch the part after
bool isotropy = node.attribute("Isotropy").as_bool();

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable isotropy is not used.
double epsilon = property.attribute("Epsilon").as_double(Material::default_epsilon);
double mue = property.attribute("Mue").as_double(Material::default_mue);
double kappa = property.attribute("Kappa").as_double(Material::default_kappa);
double sigma = property.attribute("Sigma").as_double(Material::default_sigma);

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable sigma is not used.
Comment on lines +122 to +123
} else if(node.name() == "Cylinder"s) {
} else if(node.name() == "Wire"s) {

Check notice

Code scanning / CodeQL

Empty branch of conditional Note

Empty block without comment.
Comment on lines +123 to +124
} else if(node.name() == "Wire"s) {
} else if(node.name() == "CylindricalShell"s) {

Check notice

Code scanning / CodeQL

Empty branch of conditional Note

Empty block without comment.
Comment on lines +124 to +125
} else if(node.name() == "CylindricalShell"s) {
} else if(node.name() == "User-Defined"s) {

Check notice

Code scanning / CodeQL

Empty branch of conditional Note

Empty block without comment.
Comment on lines +125 to +126
} else if(node.name() == "User-Defined"s) {
} else if(node.name() == "Curve"s) {

Check notice

Code scanning / CodeQL

Empty branch of conditional Note

Empty block without comment.
Comment on lines +119 to +147
// switch(polygon->material->type) {
// case domain::Material::Type::CONDUCTOR:
// item->locate_structure_polygon_params = [this]() -> auto& {
// return style_selector.get_polygon_shape();
// };
// break;
// case domain::Material::Type::PORT:
// item->locate_structure_polygon_params = [this]() -> auto& {
// return style_selector.get_polygon_port();
// };
// break;
// case domain::Material::Type::GROUND:
// item->locate_structure_polygon_params = [this]() -> auto& {
// return style_selector.get_polygon_ground();
// };
// break;
// case domain::Material::Type::DIELECTRIC:
// item->locate_structure_polygon_params = [this]() -> auto& {
// return style_selector.get_polygon_substrate();
// };
// break;
// case domain::Material::Type::AIR:
// item->locate_structure_polygon_params = [this]() -> auto& {
// return style_selector.get_polygon_substrate();
// };
// break;
// default:
// unreachable();
// }

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
53.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@thomaslepoix thomaslepoix added this to the 0.0.1 milestone Oct 31, 2025
@thomaslepoix
thomaslepoix merged commit cf88205 into main Oct 31, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Domain AKA business logic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle holes in shapes

2 participants