Re: [deal.II] extract_surface_mesh() does not extract refined cells

2023-12-05 Thread Simon Wiesheier
No worries :-)

Setting the boundary ids on the coarse grid did the trick (no need to do it
again on the refined grid).

A short follow-up:
After extracting the surface mesh (Triangulation<2,3>),
I want to get rid of the Z-coordinate to obtain a Triangulation<2>.
Unfortunately, GridGenerator::flatten_triangulation<2, 3, 2>(...)
does not work in the presence of hanging nodes.

Any workarounds for this issue?

Best,
Simon

Am Di., 5. Dez. 2023 um 21:48 Uhr schrieb Luca Heltai :

> By the way:
>
> Sorry if my reply was not too precise at the beginning, and if it sound
> harsh, but I cannot not run your code on my iPhone (yet), even though I’m
> working on it.
>
> :)
>
> Till then, may I suggest that you provide as much information as you can,
> if you want people to answer quickly? Asking people to download the code,
> put it somewhere where deal.II is available and then running it and
> debugging it is unlikely to produce a quick answer other than “can you tell
> us more?”.
>
> Luca
>
> Il giorno 5 dic 2023, alle ore 9:25 PM, Simon Wiesheier <
> simon.wieshe...@gmail.com> ha scritto:
>
> 
> Dear Luca,
>
> the program I provided writes the volume mesh as well as the surface mesh
> to vtk files.
> If you compare these files, for instance in paraview, you will see that
> the locally refined cells are not extracted.
>
> Best,
> Simon
>
> Am Di., 5. Dez. 2023 um 21:14 Uhr schrieb Luca Heltai <
> luca.hel...@gmail.com>:
>
>> Dear Simon,
>>
>> What do you mean by “demonstrates”? The function you refer to is supposed
>> to work with locally refined grids. What is the behavior you observe? What
>> error do you get?
>>
>> You will have to map dofs on the surface to dofs on the bulk manually.
>> The output of the function only returns a map of tria iterators to face
>> iterators, not dof to dof.
>>
>> Luca
>>
>> Il giorno 5 dic 2023, alle ore 2:23 PM, Simon 
>> ha scritto:
>>
>> Dear all,
>>
>>
>> attached is a minimal example which demonstrates that the function
>> "extract_surface_mesh()" in the GridGenerator namespace
>> does not extract refined cells.
>> That is, it seems to work only for globally refined meshes.
>> There is a comment in the implementation of this function:
>> // Create boundary mesh and mapping
>> // from only level(0) cells of the volume mesh.
>>
>> Since the documentation states nothing about the usage of this function
>> for adaptively
>> refined meshes (like it is done in flatten_triangulation, for instance),
>> I am not sure whether this is desired behavior or not.
>>
>> In my case, I probably do not need the full power of this function.
>> All I want to do is to "copy" the solution values on a surface of the
>> volume mesh
>> to a surface mesh, and to associate a DoFHandler object to the surface
>> mesh
>> that allows me to do further postprocessing.
>> So I do not care about the boundary and manifold id as well
>> as the return type, however, my volume mesh may contain hanging nodes.
>>
>>
>>
>> Best regards,
>> Simon
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/dealii/f3252992-4761-41b1-a691-05c5265f89bfn%40googlegroups.com
>> 
>> .
>> 
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/dealii/AB275257-5021-4A2C-ACA1-C2A44D8FB070%40gmail.com
>> 
>> .
>>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/CAM50jEvtuTu_vUKmg-mTGQC7tdk4v6YE7TayaA6cjnrWjqa3Zg%40mail.gmail.com
> 

Re: [deal.II] extract_surface_mesh() does not extract refined cells

2023-12-05 Thread Luca Heltai
By the way: Sorry if my reply was not too precise at the beginning, and if it sound harsh, but I cannot not run your code on my iPhone (yet), even though I’m working on it. :) Till then, may I suggest that you provide as much information as you can, if you want people to answer quickly? Asking people to download the code, put it somewhere where deal.II is available and then running it and debugging it is unlikely to produce a quick answer other than “can you tell us more?”.LucaIl giorno 5 dic 2023, alle ore 9:25 PM, Simon Wiesheier  ha scritto:Dear Luca,the program I provided writes the volume mesh as well as the surface mesh to vtk files.If you compare these files, for instance in paraview, you will see that the locally refined cells are not extracted.Best,SimonAm Di., 5. Dez. 2023 um 21:14 Uhr schrieb Luca Heltai :Dear Simon, What do you mean by “demonstrates”? The function you refer to is supposed to work with locally refined grids. What is the behavior you observe? What error do you get?You will have to map dofs on the surface to dofs on the bulk manually. The output of the function only returns a map of tria iterators to face iterators, not dof to dof.LucaIl giorno 5 dic 2023, alle ore 2:23 PM, Simon  ha scritto:Dear all,attached is a minimal example which demonstrates that the function "extract_surface_mesh()" in the GridGenerator namespace does not extract refined cells. That is, it seems to work only for globally refined meshes. There is a comment in the implementation of this function:// Create boundary mesh and mapping// from only level(0) cells of the volume mesh.Since the documentation states nothing about the usage of this function for adaptivelyrefined meshes (like it is done in flatten_triangulation, for instance), I am not sure whether this is desired behavior or not.In my case, I probably do not need the full power of this function. All I want to do is to "copy" the solution values on a surface of the volume mesh to a surface mesh, and to associate a DoFHandler object to the surface meshthat allows me to do further postprocessing.So I do not care about the boundary and manifold id as wellas the return type, however, my volume mesh may contain hanging nodes.Best regards,Simon



-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/f3252992-4761-41b1-a691-05c5265f89bfn%40googlegroups.com.




-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/AB275257-5021-4A2C-ACA1-C2A44D8FB070%40gmail.com.




-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CAM50jEvtuTu_vUKmg-mTGQC7tdk4v6YE7TayaA6cjnrWjqa3Zg%40mail.gmail.com.




-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/29F05081-782C-4BDB-B200-A040539152A7%40gmail.com.


Re: [deal.II] extract_surface_mesh() does not extract refined cells

2023-12-05 Thread Luca Heltai
The fact that the vtk file does not contain the refined cells does not necessarily mean that they are not extracted. If you look at the source code of the function, you will see that it generates the coarse surface mesh based on the coarse boundary ids to extract, and then it loops over all cells, and if they are refined, it flags the corresponding surface cells for refinement till the refinementa are the same. You are setting boundary ids on the refined grid (not on the coarse grid), and these are not there on the coarse cells, so there is nothing to refine when the bulk cell is refined. Can you try removing the set_boundary_id, and verify if this generates a grid with refinement ?This could be the issue. The coarse ids do not match the fine ids, and therefore are not extracted. Alternatively, to keep the boundary ids, you should set the boundary ids of the parent faces  as well, for the algorithm to find them on the coarse level. LucaIl giorno 5 dic 2023, alle ore 21:25, Simon Wiesheier  ha scritto:Dear Luca,the program I provided writes the volume mesh as well as the surface mesh to vtk files.If you compare these files, for instance in paraview, you will see that the locally refined cells are not extracted.Best,SimonAm Di., 5. Dez. 2023 um 21:14 Uhr schrieb Luca Heltai :Dear Simon, What do you mean by “demonstrates”? The function you refer to is supposed to work with locally refined grids. What is the behavior you observe? What error do you get?You will have to map dofs on the surface to dofs on the bulk manually. The output of the function only returns a map of tria iterators to face iterators, not dof to dof.LucaIl giorno 5 dic 2023, alle ore 2:23 PM, Simon  ha scritto:Dear all,attached is a minimal example which demonstrates that the function "extract_surface_mesh()" in the GridGenerator namespace does not extract refined cells. That is, it seems to work only for globally refined meshes. There is a comment in the implementation of this function:// Create boundary mesh and mapping// from only level(0) cells of the volume mesh.Since the documentation states nothing about the usage of this function for adaptivelyrefined meshes (like it is done in flatten_triangulation, for instance), I am not sure whether this is desired behavior or not.In my case, I probably do not need the full power of this function. All I want to do is to "copy" the solution values on a surface of the volume mesh to a surface mesh, and to associate a DoFHandler object to the surface meshthat allows me to do further postprocessing.So I do not care about the boundary and manifold id as wellas the return type, however, my volume mesh may contain hanging nodes.Best regards,Simon



-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/f3252992-4761-41b1-a691-05c5265f89bfn%40googlegroups.com.




-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/AB275257-5021-4A2C-ACA1-C2A44D8FB070%40gmail.com.




-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CAM50jEvtuTu_vUKmg-mTGQC7tdk4v6YE7TayaA6cjnrWjqa3Zg%40mail.gmail.com.




-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/876314A5-EEEC-4947-A339-01C344214104%40gmail.com.


Re: [deal.II] extract_surface_mesh() does not extract refined cells

2023-12-05 Thread Simon Wiesheier
Dear Luca,

the program I provided writes the volume mesh as well as the surface mesh
to vtk files.
If you compare these files, for instance in paraview, you will see that the
locally refined cells are not extracted.

Best,
Simon

Am Di., 5. Dez. 2023 um 21:14 Uhr schrieb Luca Heltai :

> Dear Simon,
>
> What do you mean by “demonstrates”? The function you refer to is supposed
> to work with locally refined grids. What is the behavior you observe? What
> error do you get?
>
> You will have to map dofs on the surface to dofs on the bulk manually. The
> output of the function only returns a map of tria iterators to face
> iterators, not dof to dof.
>
> Luca
>
> Il giorno 5 dic 2023, alle ore 2:23 PM, Simon 
> ha scritto:
>
> Dear all,
>
>
> attached is a minimal example which demonstrates that the function
> "extract_surface_mesh()" in the GridGenerator namespace
> does not extract refined cells.
> That is, it seems to work only for globally refined meshes.
> There is a comment in the implementation of this function:
> // Create boundary mesh and mapping
> // from only level(0) cells of the volume mesh.
>
> Since the documentation states nothing about the usage of this function
> for adaptively
> refined meshes (like it is done in flatten_triangulation, for instance),
> I am not sure whether this is desired behavior or not.
>
> In my case, I probably do not need the full power of this function.
> All I want to do is to "copy" the solution values on a surface of the
> volume mesh
> to a surface mesh, and to associate a DoFHandler object to the surface mesh
> that allows me to do further postprocessing.
> So I do not care about the boundary and manifold id as well
> as the return type, however, my volume mesh may contain hanging nodes.
>
>
>
> Best regards,
> Simon
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/f3252992-4761-41b1-a691-05c5265f89bfn%40googlegroups.com
> 
> .
> 
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/AB275257-5021-4A2C-ACA1-C2A44D8FB070%40gmail.com
> 
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/CAM50jEvtuTu_vUKmg-mTGQC7tdk4v6YE7TayaA6cjnrWjqa3Zg%40mail.gmail.com.


Re: [deal.II] extract_surface_mesh() does not extract refined cells

2023-12-05 Thread Luca Heltai
Dear Simon, What do you mean by “demonstrates”? The function you refer to is supposed to work with locally refined grids. What is the behavior you observe? What error do you get?You will have to map dofs on the surface to dofs on the bulk manually. The output of the function only returns a map of tria iterators to face iterators, not dof to dof.LucaIl giorno 5 dic 2023, alle ore 2:23 PM, Simon  ha scritto:Dear all,attached is a minimal example which demonstrates that the function "extract_surface_mesh()" in the GridGenerator namespace does not extract refined cells. That is, it seems to work only for globally refined meshes. There is a comment in the implementation of this function:// Create boundary mesh and mapping// from only level(0) cells of the volume mesh.Since the documentation states nothing about the usage of this function for adaptivelyrefined meshes (like it is done in flatten_triangulation, for instance), I am not sure whether this is desired behavior or not.In my case, I probably do not need the full power of this function. All I want to do is to "copy" the solution values on a surface of the volume mesh to a surface mesh, and to associate a DoFHandler object to the surface meshthat allows me to do further postprocessing.So I do not care about the boundary and manifold id as wellas the return type, however, my volume mesh may contain hanging nodes.Best regards,Simon



-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/f3252992-4761-41b1-a691-05c5265f89bfn%40googlegroups.com.




-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/AB275257-5021-4A2C-ACA1-C2A44D8FB070%40gmail.com.


[deal.II] extract_surface_mesh() does not extract refined cells

2023-12-05 Thread Simon
Dear all,


attached is a minimal example which demonstrates that the function 
"extract_surface_mesh()" in the GridGenerator namespace 
does not extract refined cells. 
That is, it seems to work only for globally refined meshes. 
There is a comment in the implementation of this function:
// Create boundary mesh and mapping
// from only level(0) cells of the volume mesh.

Since the documentation states nothing about the usage of this function for 
adaptively
refined meshes (like it is done in flatten_triangulation, for instance), 
I am not sure whether this is desired behavior or not.

In my case, I probably do not need the full power of this function. 
All I want to do is to "copy" the solution values on a surface of the 
volume mesh 
to a surface mesh, and to associate a DoFHandler object to the surface mesh
that allows me to do further postprocessing.
So I do not care about the boundary and manifold id as well
as the return type, however, my volume mesh may contain hanging nodes.



Best regards,
Simon

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/f3252992-4761-41b1-a691-05c5265f89bfn%40googlegroups.com.

#include 
#include 
#include 
#include 

#include 

#include 

using namespace dealii;

int main()
{

  Triangulation<3> tria, triaTmp;
  
  dealii::Point<3> center;
  double radius = 2.5;
  unsigned int boundaryID = 2;

  GridGenerator::hyper_cube_with_cylindrical_hole(triaTmp,
radius,
7.5,
2.0,
1,
false);
  triaTmp.refine_global(2);

  // symmetry in global Z
  std::set::active_cell_iterator> cellsToRemove;
  for (const auto &cell : triaTmp.active_cell_iterators())
if ( cell->center()[2] > 1.0)
  cellsToRemove.insert(cell);
  dealii::GridGenerator::create_triangulation_with_removed_cells(triaTmp,
  cellsToRemove,
  tria);
  // one local refinement along hole
  for (const auto &cell : tria.active_cell_iterators())
for (unsigned int f = 0; f < dealii::GeometryInfo<3>::faces_per_cell; ++f)
  {
dealii::Point<3> faceCenter(cell->face(f)->center());
faceCenter[2] = 0.0;
if ((std::abs(center.distance(faceCenter)) < radius))
  cell->set_refine_flag();
  }
  tria.execute_coarsening_and_refinement();

  // set boundary ID for surface mesh
  for (const auto &cell : tria.active_cell_iterators())
for (unsigned int f = 0; f < dealii::GeometryInfo<3>::faces_per_cell; ++f)
  if(std::abs(cell->face(f)->center()[2]) < 1e-5 && cell->face(f)->at_boundary())
cell->face(f)->set_boundary_id(boundaryID);

  // extract surface mesh
  dealii::Triangulation<2, 3> tria2d;
  dealii::GridGenerator::extract_boundary_mesh(
tria,
tria2d,
std::set{boundaryID});

  // output the volume mesh
  std::ofstream file("tria.vtk");
  dealii::GridOut   gridOut;
  dealii::GridOutFlags::Vtk vtkFlags(true, true, true, false);
  gridOut.set_flags(vtkFlags);
  gridOut.write_vtk(tria, file);

  // and the surface mesh
  std::ofstream file2d("tria2d.vtk");
  gridOut.write_vtk(tria2d, file2d);

  return 0;
}