Hello, everyone,
In short, my question is how to get the cell_id properly by using CellId
class ?
I want to assign each cell with a different value (its pesudo density in
topology optimization). All the values are stored in a cell-based vector x,
which is initialized as follows,
opt->x.reinit(opt->mpi_communicator,
opt->triangulation.n_global_active_cells(),
opt->triangulation.n_locally_owned_active_cells(),
false);
Now I want to access to x value in each cell. My basic idea is to get the
cell_id and then use x(cell_id). In order to get cell_id, I found I should
use CellId class, specifically, cell->id().to_string().
std::string cell_id_string;
cell_id_string = cell->id().to_string();
When I printed cell_id_string to check its value
std::cout << cell_id_string << std::endl;
I found the results are in this form,
0_3:000
0_3:200
0_3:003
0_3:006
0_3:406
0_3:606
0_3:206
0_3:007
0_3:407
0_3:607
0_3:207
I am not sure how to deal with these values.
I attempted to solve it by trying to convert it to unsigned int. I achieve
this not elegantly as follows,
unsigned int cell_id = std::stoi(cell_id_string.substr(4, 1)) * 8 * 8
+ std::stoi(cell_id_string.substr(4, 1))
* 8
+ std::stoi(cell_id_string.substr(6, 1));
Incidentally, I can get the cell_id. But the number of digits in
cell_id_string can be changing with different mesh, for example, when I use
finer mesh, the output becomes,
0_5:00370
0_5:00371
0_5:00372
0_5:00373
0_5:00374
0_5:00375
0_5:00376
0_5:00377
0_5:00400
0_5:00401
0_5:00402
Thus, the previous method is not working anymore.
So may I ask for your help on this problem? *How can I intepret the cell_id
with decimal format properly in order to use it as indices?*
Do I misunderstand the CellId class? To be honest, I am not sure how this
class is working?
I am pretty new to deal.II. Please excuse me if I ask improper questions.
Looking forward to your suggestions!
Thank you very much for your help in advance!
Best regards,
Z. B. Zhang
--
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/0efb3f86-29c1-4d40-9c76-6e800a306986%40googlegroups.com.