Bisect does not use marked elements when used through nglib


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:

[code]BisectionOptions bo;
bo.usemarkedelements = 1;
bo.refine_p = 1;

mesh->GetGeometry()->GetRefinement().Bisect(*mesh, bo);

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!

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.

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?

Ah yes sorry, I was wrong. Bisect is actually the one used when called on a ngsolve mesh. For me this works:

#include <meshing.hpp>

using namespace netgen;

int main()
  auto mesh = make_shared<Mesh>();
  for(auto& el : mesh->VolumeElements())
  for(auto& el : mesh->SurfaceElements())

  cout << "mesh ne = " << mesh->GetNE() << endl;
  BisectionOptions bo;
  bo.usemarkedelements = 1;

  mesh->GetGeometry()->GetRefinement().Bisect(*mesh, bo);
  cout << "mesh ne = " << mesh->GetNE() << endl;
  return 0;

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.