Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Defining subdomains in a periodic mesh

More
4 years 2 months ago #2369 by camilo.suarezafanador
dear Colleagues

I would like to know if someone has already worked with subdomains in a L2 periodic mesh, I am trying to set a unite square cell with a circle inclusion but is not working the material definition, thanks by advance for your help.

Camilo.
More
4 years 2 months ago #2392 by christopher
What do you mean with not working? Do you have an example code that is failing? Without inclusion it is working?

Best
More
4 years 2 months ago #2393 by camilo.suarezafanador
Thanks Christopher

First, yes the code is running without inclusion.

It seem the subdomains are not being recognized after adding the circle to the periodic square, when I call the them with mesh.GetMaterials is shows: KeyError: 'default'
Code:
from math import pi from ngsolve import * from netgen.geom2d import SplineGeometry from ngsolve.internal import * from netgen.meshing import MeshingParameters from math import pi # Creating Geometry # Unite cell set-up l = 1 ST = l*l vf = 0.2 Sf = vf*ST r = sqrt(Sf/pi) # Creating Periodic Geometry periodic = SplineGeometry() pnts = [ (-0.5*l,-0.5*l), (0.5*l,-0.5*l), (0.5*l,0.5*l), (-0.5*l,0.5*l) ] pnums = [periodic.AppendPoint(*p) for p in pnts] lright = periodic.Append ( ["line", pnums[1], pnums[2]], bc="periodicx") lsup = periodic.Append ( ["line", pnums[2], pnums[3]],bc="periodicy") periodic.Append ( ["line", pnums[0], pnums[3]], leftdomain=0, rightdomain=1, copy=lright, bc="periodicx") periodic.Append ( ["line", pnums[1], pnums[0]], leftdomain=0, rightdomain=1, copy=lsup, bc="periodicy") periodic.AddCircle(c=(0,0), r=r, bc="circle", leftdomain=2, rightdomain=1) mesh = Mesh(periodic.GenerateMesh(maxh=0.1, quad_dominated=False)) order = 2 periodic.SetMaterial (1, "outer") periodic.SetMaterial (2, "inner") domain_values = {'inner': -1, 'outer': 1} values_list = [domain_values[mat] for mat in mesh.GetMaterials()]

I don't know if could be the definition of periodic.SetMaterial .... or the definitions in left-right domain. Thank you so much by advance for your help.

Best regards
More
4 years 2 months ago #2404 by christopher
You need to set the materials before creating the mesh.

Best
Christopher
The following user(s) said Thank You: camilo.suarezafanador
More
4 years 2 months ago #2407 by camilo.suarezafanador
You're right, my bad :p , thanks for your time Christopher

best regards

Camilo
Time to create page: 0.172 seconds