- Thank you received: 0
Defining subdomains in a periodic mesh
- camilo.suarezafanador
- Topic Author
- Offline
- New Member
Less
More
4 years 9 months ago #2369
by camilo.suarezafanador
Defining subdomains in a periodic mesh was created 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.
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.
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
4 years 9 months ago #2392
by christopher
Replied by christopher on topic Defining subdomains in a periodic mesh
What do you mean with not working? Do you have an example code that is failing? Without inclusion it is working?
Best
Best
- camilo.suarezafanador
- Topic Author
- Offline
- New Member
Less
More
- Thank you received: 0
4 years 9 months ago #2393
by camilo.suarezafanador
Replied by camilo.suarezafanador on topic Defining subdomains in a periodic mesh
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'
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
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
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
4 years 9 months ago #2404
by christopher
Replied by christopher on topic Defining subdomains in a periodic mesh
You need to set the materials before creating the mesh.
Best
Christopher
Best
Christopher
The following user(s) said Thank You: camilo.suarezafanador
- camilo.suarezafanador
- Topic Author
- Offline
- New Member
Less
More
- Thank you received: 0
4 years 9 months ago #2407
by camilo.suarezafanador
Replied by camilo.suarezafanador on topic Defining subdomains in a periodic mesh
You're right, my bad , thanks for your time Christopher
best regards
Camilo
best regards
Camilo
Time to create page: 0.108 seconds