core icon indicating copy to clipboard operation
core copied to clipboard

Negative Jacobian of element transformation

Open geyan3566 opened this issue 5 years ago • 6 comments

Hi,

I tried to load a pumi mesh and convert it into a parallel mfem mesh with:

pumi_mesh = apf::loadMdsMesh(model_file.c_str(), mesh_file.c_str());
mfem_mesh = ParPumiMesh(MPI_COMM_WORLD, pumi_mesh);

But all the elements in mfem_mesh have element transformation of negative jacobian. Is there a way to check the mesh orientation while loading MDS mesh? It happened to me that pumi warned me about wrong orientation elements and fixed it.

Thanks, Ge

geyan3566 avatar Mar 20 '20 21:03 geyan3566

@geyan3566 would it be possible for you to share your mesh/model and the code snippet with this behavior?

mortezah avatar Mar 20 '20 22:03 mortezah

@geyan3566 would it be possible for you to share your mesh/model and the code snippet with this behavior?

Thanks for your reply. Here are the model file and the mesh file, and I also include the x_t, sms and smd files. annulus_mesh.zip

Code that loads the mesh:

      PCU_Comm_Init();
#ifdef MFEM_USE_SIMMETRIX
      Sim_readLicenseFile(0);
      gmi_sim_start();
      gmi_register_sim();
#endif
      gmi_register_mesh();
      pumi_mesh = apf::loadMdsMesh(model_file.c_str(), mesh_file.c_str());
      pumi_mesh->verify();
      mesh.reset(new ParPumiMesh(comm, pumi_mesh));
      PCU_Comm_Free();
#ifdef MFEM_USE_SIMMETRIX
      gmi_sim_stop();
      Sim_unregisterAllKeys();
#endif

Code that check the jacobian:

      ElementTransformation *T;
      for (int i = 0; i < fes->GetNE(); i++)
      {
         T = fes->GetElementTransformation(i);
         std::cout << "element " << i << ": T-Weight is " << T->Weight() << '\n';
      }

where fes is a parallel FiniteElementSpace class defined in mfem and it has a class member holding a pointer to the mesh. Please let me know if you have any questions.

Thanks, Ge

geyan3566 avatar Mar 20 '20 23:03 geyan3566

There is also a serial version that converts a pumi mesh into mfem mesh, in which it has a function that can fix the element orientation. (This function is not called in the parallel version)

   /// Generate an MFEM mesh from a PUMI mesh.
   PumiMesh(apf::Mesh2* apf_mesh, int generate_edges = 0, int refine = 1,
            bool fix_orientation = true);

It is possible that my the PUMI mesh I generated is of wrong orientation.

geyan3566 avatar Mar 23 '20 16:03 geyan3566

@geyan3566 sorry for the late response. It appears that ParPumiMesh class creates elements with wrong orientations for 2D meshes but it works fine for 3D meshes. I have pushed a fix to my fork of mfem ( [email protected]:mortezah/mfem.git ) under the branch pumi2mfem_field_transfer (I am working on other things on this branch and once I am done I will do a Pull Request so this changes can be merged to the master branch of the mfem repo)

You can also use the serial PumiMesh class to convert your 2D mesh and that will make you an non-negative mesh.

mortezah avatar Mar 27 '20 06:03 mortezah

Thanks. Please let me know when the pull request is done because the parallel pumi mesh is necessary for my project.

geyan3566 avatar Mar 28 '20 15:03 geyan3566

@geyan3566

I just wanted to let you know that there is a PR on MFEM repo here (https://github.com/mfem/mfem/pull/1454) to merge the changes mentioned above into the master branch. That merge should go through shortly.

mortezah avatar May 26 '20 15:05 mortezah