Defining a Mesh with multiple objects

More
3 years 4 months ago #3563 by Emilio4d46
Hello all!

I am still relatively new to creating meshes and NGSolve as a whole. As the title says I am trying to make a mesh with multiple objects such that I would be able to model a scattering problem that is more complex than just one simple shape, so far I have written this
Code:
geo = SplineGeometry() s = 0.2 Points = [(-s/2,-sqrt(3)/6*s), (s/2,-sqrt(3)/6*s), (0,sqrt(3)/3*s)] for pnt in Points: geo.AddPoint(*pnt) for pids in [[0,1],[1,2],[2,0]]: geo.Append(["line"]+pids,leftdomain=1,rightdomain=2,bc="scat1") geo.AddCircle( (0.5,0.5), .35, leftdomain=1, rightdomain=2, bc="scat2") geo.AddCircle( (0,0), 1.75, leftdomain=3, rightdomain=0, bc="outer") geo.AddCircle( (0,0), 1, leftdomain=2, rightdomain=3, bc="innerbnd") geo.SetMaterial(1, "inner") geo.SetMaterial(2, "mid") geo.SetMaterial(3, "outer") mesh = Mesh(geo.GenerateMesh (maxh=0.1)) mesh.Curve(3) mesh.SetPML(pml.Radial(rad=1.5,alpha=1j,origin=(0,0)), "pmlregion") omega_0 = 54 omega_tilde = 51 domain_values = {'inner': omega_tilde, 'mid': omega_0, 'outer': omega_0} values_list = [domain_values[mat] for mat in mesh.GetMaterials()] omega = CoefficientFunction(values_list) Draw(omega, mesh, 'piecewise')

But running this causes my machine to loop and it does not finish executing the cell in the notebook, I have tried defining the scat2 circle to have a different material then the scat1 triangle but this doesn't help matters (though if possible I would like them to be the same material)

Thank you all for your time
More
3 years 4 months ago #3564 by cwinters
Hi,

the materials are not causing the problem, the code already fails earlier in the meshing routine.
For each object you have to define "leftdomain" and "rightdomain", which are used to generate the mesh. These domains are inconsistent in your case, since "scat2" intersects with "innerbnd". Reducing the radius of "scat2" such that the circle is inside the "innerbnd" circle solves your problem.

Best,
Christoph
The following user(s) said Thank You: Emilio4d46
More
3 years 4 months ago #3571 by Emilio4d46
Yes, thank you so much! I didn't notice that before.
Time to create page: 0.152 seconds