Dear deal.II Community,
I am working on a project where I am trying to generate a parallel mesh using TriangulationDescription with parallel::fullydistributed::Triangulation. My goal is to create a triangulation from a structured grid based on a matrix of material IDs.
I have implemented the following code to generate the mesh:
template <int dim>
void LaplaceProblem<dim>::generate_mesh_from_matrix(int Nx, int Ny, int Nz)
{
std::vector<Point<dim>> vertices;
std::vector<TriangulationDescription::CellData<dim>> cells;
std::vector<unsigned int> subdomain_ids;
unsigned int vertex_counter = 0;
std::map<std::tuple<unsigned int, unsigned int, unsigned int>, unsigned int> vertex_map;
// Generate vertices
for (unsigned int i = 0; i <= Nx; ++i)
for (unsigned int j = 0; j <= Ny; ++j)
for (unsigned int k = 0; k <= Nz; ++k)
{
Point<dim> p(i, j, k);
vertices.push_back(p);
vertex_map[std::make_tuple(i, j, k)] = vertex_counter++;
}
// Generate cells
for (unsigned int i = 0; i < Nx; ++i)
for (unsigned int j = 0; j < Ny; ++j)
for (unsigned int k = 0; k < Nz; ++k)
{
int material_id = mat_matrix[j + k * Ny][i];
if (material_id == _mat_tau_1)
{
TriangulationDescription::CellData<dim> cell;
cell.vertices = {vertex_map[std::make_tuple(i, j, k)],
vertex_map[std::make_tuple(i + 1, j, k)],
vertex_map[std::make_tuple(i, j + 1, k)],
vertex_map[std::make_tuple(i + 1, j + 1, k)],
vertex_map[std::make_tuple(i, j, k + 1)],
vertex_map[std::make_tuple(i + 1, j, k + 1)],
vertex_map[std::make_tuple(i, j + 1, k + 1)],
vertex_map[std::make_tuple(i + 1, j + 1, k + 1)]};
cell.material_id = material_id;
cells.push_back(cell);
subdomain_ids.push_back(Utilities::MPI::this_mpi_process(_mpi_communicator));
}
}
TriangulationDescription::Description<dim, dim> triangulation_description;
triangulation_description.vertices = vertices;
triangulation_description.cells = cells;
triangulation_description.subdomain_ids = subdomain_ids;
triangulation_pft.create_triangulation(triangulation_description);
pcout << "Number of active cells: " << triangulation_pft.n_active_cells() << std::endl;
pcout << "Number of vertices: " << triangulation_pft.n_vertices() << std::endl;
}
When I compile the code, I get the following errors:
It seems I am misunderstanding how to use TriangulationDescription::CellData and TriangulationDescription::Description.
Could you please guide me on the correct way to set the vertices, cells, and subdomain IDs manually without relying on the utility functions? I want to fully understand how to use the classes and set the data correctly for parallel::fullydistributed::Triangulation.
Thank you for your time and support.
Best regards,
Rishabh
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
--- You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dealii/14fb678f-ffb8-40c1-abce-29bec8078fee%40colostate.edu.
Dear Prof. Wolfgang,
Thank you for your guidance regarding the use of TriangulationDescription::CellData and for suggesting Peter Munch's work on creating fully distributed triangulations. It was very insightful, and I reviewed the example provided in the repository:
https://github.com/dealii/dealii/blob/master/tests/fullydistributed_grids/create_manually_01.cc
Based on this reference, I implemented a method to generate a fully distributed triangulation for a small microstructure with dimensions 20x20x20.
The VTU files generated for each processor appear correct and are divided as expected. However, I am encountering an issue during the DoF distribution phase.
Specifically, the number of DoFs increases as I use more processors. For instance, using a single processor results in 7918 DoFs, while with two processors, the count rises to 8272, and with three processors, it increases further to 8537.
This suggests that there might be an overlapping of cell faces or an issue with ghost cells being incorrectly accounted for during the DoF distribution. I suspect the problem lies in the handling of shared faces between processors or inconsistencies in cell ownership. I am currently reviewing the partitioning logic and cell indexing within TriangulationDescription::Description.
If you have any further suggestions or recommendations to address this issue, they would be greatly appreciated. Thank you once again for your support, and I look forward to your feedback.
Best regards,
Rishabh
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dealii/14fb678f-ffb8-40c1-abce-29bec8078fee%40colostate.edu.
Hi Peter,
Great to hear from you, and thank you so much for pointing this out! I revisited the implementation and corrected the setup for ghost cells as you suggested. Now, the DoFs between subdomains are handled correctly, and the total number of DoFs remains consistent. Your observation was spot on—thanks for catching that!
One question: Can I set boundary_id as usual or do we have add in construction_data?
I am attaching here boundary_ids implementation along with generate_mesh_with_matrix.
However, I’ve run into a new issue with the solution. Somehow, I’m getting a zero solution despite following the approach in step 40. I suspect that the system might not be assembling properly.
Do you have any insights or advice on working with parallel fully distributed meshes? I would really appreciate your thoughts.
Best Regards
Rishabh
To view this discussion visit https://groups.google.com/d/msgid/dealii/c703ffab-89b5-4e7d-b363-10dc062ec9fan%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dealii/bb96467e-9dda-4739-b17e-481c16f7468bn%40googlegroups.com.