- Thank you received: 0
How to compose a region using a gfu (or cf)?
- creativeworker
- Topic Author
- Offline
- Senior Member
Less
More
4 years 7 months ago - 4 years 7 months ago #2583
by creativeworker
How to compose a region using a gfu (or cf)? was created by creativeworker
Hello,
I don't understand how i could compose a ngsolve.comp.Region using a given gfu (or cf). Using that region i'd like to separate two groups of dofs (using the definedon=region).
Here the concrete goal:
- sort every dof of fes into a second fes where the gfu value is higher than tol. All the other dofs should go into a third fes.
Perhaps its easy and I just didn't go the correct way of solving the problem.
Thanks for your help!
I don't understand how i could compose a ngsolve.comp.Region using a given gfu (or cf). Using that region i'd like to separate two groups of dofs (using the definedon=region).
Here the concrete goal:
- sort every dof of fes into a second fes where the gfu value is higher than tol. All the other dofs should go into a third fes.
Perhaps its easy and I just didn't go the correct way of solving the problem.
Thanks for your help!
Last edit: 4 years 7 months ago by creativeworker.
- mneunteufel
- Offline
- Premium Member
Less
More
- Thank you received: 59
4 years 7 months ago #2584
by mneunteufel
Replied by mneunteufel on topic How to compose a region using a gfu (or cf)?
Hi creativeworker,
you can use a BitArray to sort dofs. This works only for lowest order H1 elements where every dof is associated with the vertex value.
For example
saves all dofs where gfu is greater than 1.5.
Defining a second space which lives only on these dofs can be done only with
Best,
Michael
you can use a BitArray to sort dofs. This works only for lowest order H1 elements where every dof is associated with the vertex value.
For example
Code:
fes = H1(mesh, order=1)
gfu = GridFunction(fes)
gfu.Set(x*y+2*y)
limit = 1.5
dofs = BitArray(fes.ndof)
dofs[:] = False
for i in range(fes.ndof):
if gfu.vec[i] > limit:
dofs[i] = True
Defining a second space which lives only on these dofs can be done only with
Code:
fes2 = H1(mesh, order=1, dirichlet="left|top|bottom|right")
for i in range(fes.ndof):
if dofs[i] == False:
fes2.SetCouplingType(i,COUPLING_TYPE.UNUSED_DOF)
fes2 = Compress(fes2)
Best,
Michael
Attachments:
4 years 7 months ago #2585
by schruste
Replied by schruste on topic How to compose a region using a gfu (or cf)?
Hi,
Short addition. Compress has an argument "active_dofs" exactly for replacing the last loop:
Best,
Christoph
Short addition. Compress has an argument "active_dofs" exactly for replacing the last loop:
Code:
fes2 = H1(mesh, order=1, dirichlet="left|top|bottom|right")
fes2 = Compress(fes2, active_dofs=dofs)
Best,
Christoph
The following user(s) said Thank You: creativeworker
- creativeworker
- Topic Author
- Offline
- Senior Member
Less
More
- Thank you received: 0
4 years 7 months ago #2586
by creativeworker
Replied by creativeworker on topic How to compose a region using a gfu (or cf)?
Thank you very much. The Compress function helps me also in another place!
- creativeworker
- Topic Author
- Offline
- Senior Member
Less
More
- Thank you received: 0
4 years 7 months ago - 4 years 7 months ago #2587
by creativeworker
Replied by creativeworker on topic How to compose a region using a gfu (or cf)?
May i ask two further things on that topic:
Is there a possibility to find the boundary dofs of such a bit mask? Or to define a region with the bit mask and find the boundary dofs there?
Secondly, is there a chance to bring this idea to HCurl space?
Is there a possibility to find the boundary dofs of such a bit mask? Or to define a region with the bit mask and find the boundary dofs there?
Secondly, is there a chance to bring this idea to HCurl space?
Last edit: 4 years 7 months ago by creativeworker.
- mneunteufel
- Offline
- Premium Member
Less
More
- Thank you received: 59
4 years 7 months ago #2591
by mneunteufel
Replied by mneunteufel on topic How to compose a region using a gfu (or cf)?
Hi creativeworker,
you can get the dofs of a boundary as a BitArray with
which then can be combined with other BitArrays, see attached file.
Best
Michael
you can get the dofs of a boundary as a BitArray with
Code:
fes.GetDofs(mesh.Boundaries("left"))
Best
Michael
Attachments:
Time to create page: 0.107 seconds