Hi Peter,
Thanks for the suggestion! I had an example using SolutionTransfer worked
out
and only then realized the premise of this whole feature request missed the
mark…
So let me restate what is desired: I basically want to record the refinement
(and coarsening) history of a Triangulation and reconstruct the mesh. There
are already available save_refine_flags and load_refine_flags functions
that are precisely for this but it’s not really suitable for my case
because I
need to reconstruct the mesh at every time-step and it’s better to avoid I/O
operations since they tend to slow things down.
In theory, it should work by recording level and index numbers of all cells
that has_children() and then execute_coarsening_and_refinement level by
level on the same coarse mesh. However, oddities of cell indexing were
observed. See attached mesh as an example. On level 1, I was expecting to
see
indices in the order of 0, 1, 2, 3, 6, 7, etc but instead saw the output
below
(the third column is the barycenter coordinate of the cell). The cells are
not
lexicographically ordered on level 1 despite being lexicographically refined
when the reconstruction part was carried out. This results in different
meshes.
Level: 0; Index: 0; (-8 -8) Level: 0; Index: 1; (8 -8) Level: 0; Index: 2;
(-8 8) Level: 0; Index: 3; (8 8) Level: 1; Index: 0; (-12 -12) Level: 1;
Index: 1; (-4 -12) Level: 1; Index: 2; (-12 -4) Level: 1; Index: 3; (-4 -4)
Level: 1; Index: 4; (-12 4) Level: 1; Index: 5; (-4 4) Level: 1; Index: 6;
(-12 12) Level: 1; Index: 7; (-4 12) Level: 1; Index: 8; (4 4) Level: 1;
Index: 9; (12 4) Level: 1; Index: 10; (4 12) Level: 1; Index: 11; (12 12)
Level: 1; Index: 14; (4 -4) Level: 1; Index: 15; (12 -4) Level: 2; Index:
32; (2 2) ...
And here is the chunk of my code that does the recording:
std::map<int, std::vector<int>> cell_map; for (auto &cell :
triangulation.cell_iterators()) { if (cell->has_children()) {
cell_map[cell->level()].push_back(cell->index()); } }
…then the reconstruction:
for (auto cell_data = cell_map.begin(); cell_data != cell_map.end();
++cell_data) { int cell_level = cell_data->first; std::vector<int>
cell_indices = cell_data->second; for (auto cell_index : cell_indices) {
CellAccessor<dim, dim> cell(&triangulation_copy, cell_level, cell_index);
cell.set_refine_flag(); }
triangulation_copy.execute_coarsening_and_refinement(); }
See also the picture of the reconstructed mesh. I believe that level 1 cell
12
was refined there due to 1-irregularity constraint.
Would appreciate your comments and help!
Best,
Yuan
On Wednesday, November 15, 2023 at 12:18:00 PM UTC [email protected]
wrote:
> Hi Greg,
>
> good that you find a working solution! However, I would suggest against
> using `VectorTools::interpolate_to_different_mesd` but use
> `SolutionTransfer` or `parallel::distributed::SolutionTransfer` to move the
> refinement information from a coarse mesh to a fine mesh. You can take a
> look at the tutorial how these classes are used.
>
> Hope this helps,
> Peter
> On Saturday, 11 November 2023 at 02:24:23 UTC+1 Wolfgang Bangerth wrote:
>
>> On 11/10/23 17:43, Yuan Wang wrote:
>> > And I just found that the bug comes from feeding Vector<int> to
>> > interpolate_to_different_mesh() while int is not a valid
>> > VectorType::value_type therein. Changing int to double fixes it.
>>
>> Yes, that is right. We do not seem to enforce this, but we are generally
>> expecting Vector<T> to only be instantiated for T=some floating point
>> type.
>>
>> Best
>> W.
>>
>> --
>> ------------------------------------------------------------------------
>> Wolfgang Bangerth email: [email protected]
>> www: http://www.math.colostate.edu/~bangerth/
>>
>>
>>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dealii/7c45cc72-6ff1-4e19-8e74-e502e8f40cedn%40googlegroups.com.