- Thank you received: 0
Define a H(div) finite element space on a submain
4 years 2 months ago #3094
by wen jing
Define a H(div) finite element space on a submain was created by wen jing
Assume the domain is given as follows: How to define the H(div) finite element space on a subdomain. I define it as "V4 = HDiv(mesh, order=order, dirichlet="gammaSD", definedon = [2])", I find it has more degrees of freedom. I don't know what caused it?
geometry = SplineGeometry()
# point coordinates ...
pnts = [ (0,0), (1,0), (1,0.5), (1,1), (0,1), (0, 0.5)]
pnums = [geometry.AppendPoint(*p) for p in pnts]
# start-point, end-point, boundary-condition, domain on left side, domain on right side:
lines = [ (pnums[0],pnums[1],"gammaDd",2,0), (pnums[1],pnums[2],"gammaDd",2,0),
(pnums[2],pnums[3],"gammaS",1,0), (pnums[3],pnums[4],"gammaS",1,0),
(pnums[4],pnums[5],"gammaS",1,0),
(pnums[5],pnums[0],"gammaDd",2,0), (pnums[5],pnums[2],"gammaSD",1,2)]
for p1,p2,bc,left,right in lines:
geometry.Append( ["line", p1, p2], bc=bc, leftdomain=left, rightdomain=right)
return geometry
geometry = SplineGeometry()
# point coordinates ...
pnts = [ (0,0), (1,0), (1,0.5), (1,1), (0,1), (0, 0.5)]
pnums = [geometry.AppendPoint(*p) for p in pnts]
# start-point, end-point, boundary-condition, domain on left side, domain on right side:
lines = [ (pnums[0],pnums[1],"gammaDd",2,0), (pnums[1],pnums[2],"gammaDd",2,0),
(pnums[2],pnums[3],"gammaS",1,0), (pnums[3],pnums[4],"gammaS",1,0),
(pnums[4],pnums[5],"gammaS",1,0),
(pnums[5],pnums[0],"gammaDd",2,0), (pnums[5],pnums[2],"gammaSD",1,2)]
for p1,p2,bc,left,right in lines:
geometry.Append( ["line", p1, p2], bc=bc, leftdomain=left, rightdomain=right)
return geometry
- mneunteufel
- Offline
- Premium Member
Less
More
- Thank you received: 59
4 years 2 months ago #3098
by mneunteufel
Replied by mneunteufel on topic Define a H(div) finite element space on a submain
Hi wen jing,
when using the definedon flag there seems that some dofs are marked as unused but still appear as dofs.
However, when looking at the freedofs it should have the correct number. There is the possibility to Compress the space to neglect all unused dofs.
The code
gives the output
see also the attached code. I would highly recommend to give also regions/materials a name for better readability and avoiding errors like 0/1 based indexing.
Best
Michael
when using the definedon flag there seems that some dofs are marked as unused but still appear as dofs.
However, when looking at the freedofs it should have the correct number. There is the possibility to Compress the space to neglect all unused dofs.
The code
Code:
V1 = HDiv(mesh, order=2, dirichlet="gammaSD")
V2 = HDiv(mesh, order=2, dirichlet="gammaSD", definedon = "dom2")
V3 = Compress(V2)
print("V1 ndof = ", V1.ndof)
print("V1 fdofs = ", sum(V1.FreeDofs()))
print("V2 ndof = ", V2.ndof)
print("V2 fdofs = ", sum(V2.FreeDofs()))
print("V3 ndof = ", V3.ndof)
print("V3 fdofs = ", sum(V3.FreeDofs()))
gives the output
Code:
V1 ndof = 1845
V1 fdofs = 1815
V2 ndof = 1115
V2 fdofs = 900
V3 ndof = 930
V3 fdofs = 900
see also the attached code. I would highly recommend to give also regions/materials a name for better readability and avoiding errors like 0/1 based indexing.
Best
Michael
Attachments:
4 years 2 months ago #3099
by wen jing
Replied by wen jing on topic Define a H(div) finite element space on a submain
Thanks for you advice and help!
Best regards,
Wen JIng
Best regards,
Wen JIng
4 years 2 months ago - 4 years 2 months ago #3100
by wen jing
Replied by wen jing on topic Define a H(div) finite element space on a submain
Thanks for your answer,which help me a lot! I think the number of dof of V3 is reasonable. However, should i use V2 or V3 when we're coding?
Last edit: 4 years 2 months ago by wen jing.
- mneunteufel
- Offline
- Premium Member
Less
More
- Thank you received: 59
4 years 2 months ago #3101
by mneunteufel
Replied by mneunteufel on topic Define a H(div) finite element space on a submain
With both spaces you should get the same result. if you explicitly need the ndofs V3 is less error prone (it might be also a bit more efficient than V2). You can simplify the notation by
Best
Michael
Code:
V3 = Compress(HDiv(mesh, order=2, dirichlet="gammaSD", definedon = "dom2"))
Best
Michael
Time to create page: 0.105 seconds