- 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 #2593
by creativeworker
Replied by creativeworker on topic How to compose a region using a gfu (or cf)?
Thanks for the fast reply.
What I meant was more the other way round. So I have created my bit mask (using the limit). Now I need the dofs that surround the areas of where the limit of the gfu was beyond the limit speaking in the physical space. So, the dofs have to somehow be interpreted back in the mesh domain and decided wether the dof has only marked dofs around itself or not.
What I meant was more the other way round. So I have created my bit mask (using the limit). Now I need the dofs that surround the areas of where the limit of the gfu was beyond the limit speaking in the physical space. So, the dofs have to somehow be interpreted back in the mesh domain and decided wether the dof has only marked dofs around itself or not.
- mneunteufel
- Offline
- Premium Member
Less
More
- Thank you received: 59
4 years 6 months ago #2597
by mneunteufel
Replied by mneunteufel on topic How to compose a region using a gfu (or cf)?
So, if I understood you correctly you would like to have some kind of level-set function.
You can write a code finding the vertices on the boundary, this tutorial might help looping over elements, edges, etc.
Or you might have a look into the ngsxfem package, where a level-set can be defined (but there elements may be cut instead of using the vertices, but I'm not an expert for this package)
You can write a code finding the vertices on the boundary, this tutorial might help looping over elements, edges, etc.
Or you might have a look into the ngsxfem package, where a level-set can be defined (but there elements may be cut instead of using the vertices, but I'm not an expert for this package)
- creativeworker
- Topic Author
- Offline
- Senior Member
Less
More
- Thank you received: 0
4 years 6 months ago - 4 years 6 months ago #2667
by creativeworker
Replied by creativeworker on topic How to compose a region using a gfu (or cf)?
Thank you! I tried with iterating over all the elements. But then something strange happens. The second for-loop is stuck on the last element. So the elements are not iterated from start to end again.
Here is my code-snippet:
Here is my code-snippet:
Code:
elements = list(fes.Elements())
masterelements = []
for i in range(fes.ndof):
if gfu.vec[i] > limit:
for el in elements:
if i in el.dofs:
masterelements.append(el)
Last edit: 4 years 6 months ago by creativeworker.
4 years 6 months ago #2668
by joachim
Replied by joachim on topic How to compose a region using a gfu (or cf)?
can you post a complete failing example ?
Joachim
Joachim
- creativeworker
- Topic Author
- Offline
- Senior Member
Less
More
- Thank you received: 0
4 years 6 months ago #2669
by creativeworker
Replied by creativeworker on topic How to compose a region using a gfu (or cf)?
The attached example shows my problem.
Attachments:
4 years 6 months ago - 4 years 6 months ago #2674
by lkogler
Replied by lkogler on topic How to compose a region using a gfu (or cf)?
Making a python-list from "fes.Elements()"
does not work as you would expect it to. The reason is that fes.Elements() is only meant to be iterated through once, and is not a real "array" on C++ side.
This is not a good way to organize the loop - you go through every element for every DOF. Also, some elements will be added multiple times. Also, again, making lists from elements does not work, they are only meant to be temporary, not persistent.
Better to go through elements and for each element to only check it's DOFs, and only save the numbers of elements.
We can always iterate through the numbers, and then get the elements with those numbers:
Hope this helps.
Best,
Lukas
Code:
elements = list(fes.Elements())
This is not a good way to organize the loop - you go through every element for every DOF. Also, some elements will be added multiple times. Also, again, making lists from elements does not work, they are only meant to be temporary, not persistent.
Code:
for i in range(fes.ndof):
if gfu.vec[i] > limit:
for el in elements:
if i in el.dofs:
masterelements.append(el)
Code:
master_el_nrs = []
for el in fes.Elements():
is_master = False
for dof in el.dofs:
is_master |= gfu.vec[dof] > limit
if is_master:
master_el_nrs.append(el.nr)
We can always iterate through the numbers, and then get the elements with those numbers:
Code:
# Iterate through chosen elements:
for el_nr in master_el_nrs:
el_id = ElementId(VOL, el_nr)
print("VOL Element #", el_nr, "was chosen, dofs =", fes.GetDofNrs(el_id))
el = fes.GetFE(el_id)
# now we could do something with the element...
Hope this helps.
Best,
Lukas
Attachments:
Last edit: 4 years 6 months ago by lkogler.
The following user(s) said Thank You: creativeworker
Time to create page: 0.138 seconds