- Thank you received: 0
Excluding gradients in non conducting regions of a mesh
- BenWilson94
- Topic Author
- Offline
- Junior Member
Less
More
5 years 8 months ago #1485
by BenWilson94
Hi,
I’m interested in solving eddy current problems with ngsolve. I’ve already done some experiments with magnetostatic problems. Here I know that I can turn off the gradients in the complete domain by specifying a finite element space of the form
fes=HCurl(mesh, order=1, flags={“no grads”:True})
and adding an appropriate regularisation term to the bilinear form.
However, for eddy current problems, I have a conducting region and a non-conducting region. If I used a vector potential formulation, I know that I need to keep the gradients in the conducting region but that are not needed in the non-conducting region. To save on the number of degrees of freedom I would like to turn off the gradients in the non-conducting region. Is this possible through defining an appropriate finite element space that tags a region in the mesh? Or do I need to define two different fes and combine them in someway?
Also, in terms of the local Jacobi preconditioner, can I apply this directly to such problems?
Thanks for your help,
Ben
I’m interested in solving eddy current problems with ngsolve. I’ve already done some experiments with magnetostatic problems. Here I know that I can turn off the gradients in the complete domain by specifying a finite element space of the form
fes=HCurl(mesh, order=1, flags={“no grads”:True})
and adding an appropriate regularisation term to the bilinear form.
However, for eddy current problems, I have a conducting region and a non-conducting region. If I used a vector potential formulation, I know that I need to keep the gradients in the conducting region but that are not needed in the non-conducting region. To save on the number of degrees of freedom I would like to turn off the gradients in the non-conducting region. Is this possible through defining an appropriate finite element space that tags a region in the mesh? Or do I need to define two different fes and combine them in someway?
Also, in terms of the local Jacobi preconditioner, can I apply this directly to such problems?
Thanks for your help,
Ben
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
5 years 8 months ago - 5 years 8 months ago #1486
by christopher
Replied by christopher on topic Excluding gradients in non conducting regions of a mesh
Yes there is a feature for that:
Results in
So you can see, that the gradients are only in the metal and on the boundary to the metal (thats why some of the air elements have some gradients as well). You can ignore the warning about the undocumented flag.
Best
Christopher
Code:
from netgen.csg import *
from ngsolve import *
ngsglobals.msg_level = 0
geo = CSGeometry()
block = OrthoBrick(Pnt(-1,-1,-1), Pnt(1,1,1))
sphere = Sphere(Pnt(0,0,0),0.5)
geo.Add((block-sphere).mat("air"))
geo.Add(sphere.mat("metal").bc("metalbc"))
mesh = Mesh(geo.GenerateMesh())
Draw(mesh)
dom_nrs_metal = [1 if mat == "metal" else 0 for mat in mesh.GetMaterials()]
order = 3
full_fes = HCurl(mesh, order=order)
nograds_fes = HCurl(mesh, order=order, nograds=True)
domainwisegrad_fes = HCurl(mesh, order=order, gradientdomains=dom_nrs_metal)
ndofs = {"air" : {}, "metal" : {}}
for el in domainwisegrad_fes.Elements(VOL):
if len(el.dofs) not in ndofs[el.mat]:
ndofs[el.mat][len(el.dofs)] = 1
else:
ndofs[el.mat][len(el.dofs)] += 1
print(ndofs)
print("ndof full = ", full_fes.ndof)
print("reduce all = ", nograds_fes.ndof)
print("gradient domains =", domainwisegrad_fes.ndof)
Results in
Code:
{'air': {41: 188, 32: 156, 29: 100, 35: 6, 50: 2}, 'metal': {60: 142}}
ndof full = 15164
reduce all = 8639
gradient domains = 11124
Best
Christopher
Last edit: 5 years 8 months ago by christopher.
Time to create page: 0.099 seconds