- Thank you received: 0
Bisect does not use marked elements when used through nglib
3 years 11 months ago #3389
by vgeza
Bisect does not use marked elements when used through nglib was created by vgeza
Hi,
I am using slightly modified nglib interface for meshing. However, remeshing does not work as expected.
First I mark elements I need to be refined by passing true or false to function:
then I use Bisect:
The result is that nothing gets refined. I suspect that function Bisect works only with refinfofile is passed, otherwise, all marked elements are reset. Is there a way to bisect marked elements without passing the file?
Thank you!
I am using slightly modified nglib interface for meshing. However, remeshing does not work as expected.
First I mark elements I need to be refined by passing true or false to function:
Code:
mesh->VolumeElement(el_index).SetRefinementFlag(flag)
then I use Bisect:
Code:
BisectionOptions bo;
bo.usemarkedelements = 1;
bo.refine_p = 1;
mesh->GetGeometry()->GetRefinement().Bisect(*mesh, bo);
me->UpdateTopology();
The result is that nothing gets refined. I suspect that function Bisect works only with refinfofile is passed, otherwise, all marked elements are reset. Is there a way to bisect marked elements without passing the file?
Thank you!
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
3 years 11 months ago #3395
by christopher
Replied by christopher on topic Bisect does not use marked elements when used through nglib
Hi, I think the refinement flag only works with the geometry.GetRefinement().Refine method. Can you use this instead of the bisect? Afaik the bisect is legacy code and not currently used in Netgen/NGSolve.
Best
Christopher
Best
Christopher
3 years 11 months ago #3411
by vgeza
Replied by vgeza on topic Bisect does not use marked elements when used through nglib
I tried using Refine, but it refines all elements.
I also followed through with the logic used for refinement. SetRefinementFlag sets the state of refflag. Then I followed the track of this variable (refflag), and it seems that it is only returned by function TestRefinementFlag(). Again, searching the whole source directory, I realized that this function is called only in Bisect() (and in some visualization functions), and not in Refine().
I also tried to follow through with the huge Refine() function, and I do not see any kind of checks for elements being marked for refinement.
What am I missing?
I also followed through with the logic used for refinement. SetRefinementFlag sets the state of refflag. Then I followed the track of this variable (refflag), and it seems that it is only returned by function TestRefinementFlag(). Again, searching the whole source directory, I realized that this function is called only in Bisect() (and in some visualization functions), and not in Refine().
I also tried to follow through with the huge Refine() function, and I do not see any kind of checks for elements being marked for refinement.
What am I missing?
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
3 years 11 months ago #3412
by christopher
Replied by christopher on topic Bisect does not use marked elements when used through nglib
Ah yes sorry, I was wrong. Bisect is actually the one used when called on a ngsolve mesh. For me this works:
Code:
#include <meshing.hpp>
using namespace netgen;
int main()
{
auto mesh = make_shared<Mesh>();
mesh->Load("cube.vol.gz");
for(auto& el : mesh->VolumeElements())
el.SetRefinementFlag(false);
for(auto& el : mesh->SurfaceElements())
el.SetRefinementFlag(false);
cout << "mesh ne = " << mesh->GetNE() << endl;
mesh->VolumeElements()[0].SetRefinementFlag(true);
BisectionOptions bo;
bo.usemarkedelements = 1;
mesh->GetGeometry()->GetRefinement().Bisect(*mesh, bo);
mesh->UpdateTopology();
mesh->Save("refined.vol.gz");
cout << "mesh ne = " << mesh->GetNE() << endl;
return 0;
}
3 years 11 months ago #3418
by vgeza
Replied by vgeza on topic Bisect does not use marked elements when used through nglib
Thank you, this works! The problem turned out to be that I used the refine_p method which, if I understand correctly, just increases the order of elements.
Time to create page: 0.129 seconds