Hi, Dr. W. Bangerth,
I have tried the your suggestion that is to use FE_DGQ(0) to build another
finite element field.
It works even though there is till some small problems. However, I prefer
to double check the implementation with you:
I built two fem field objects.
FESystem<dim> fe; // for describing the vector-valued field (eg.
displacement)
FE_DGQ<dim> fe_dg; // for describing the cell field (eg. pesudo density in
topology optimization)
And initialize them in the initialization list of the class,
fe(FE_Q<dim>(1), dim),
fe_dg(0),
And I initialize the cell-based vector (the pesudo density in topology
optimization) as follows,
opt->locally_owned_cells= opt->dof_handler_dg.locally_owned_dofs();
DoFTools::extract_locally_relevant_dofs(opt->dof_handler_dg,
opt->locally_relevant_cells);
opt->x.reinit(opt->locally_owned_cells,
opt->locally_relevant_cells,
opt->mpi_communicator);
Is this process correct?
Moreover, I wonder how to access opt->x by the cell ("cell" represents the
cell iterator)?
My attempting solution is to use the syntax of PETSc directly as follows,
PetscScalar *xp;
VecGetArray(opt->x, &xp); // getting a local array of the global vector
But when I access it by
xp[cell->active_cell_index()]
I got error:
Abort: Memory balance (p4est)
Abort: ../../zzd_Software_Installation_Packages/p4est-2.2/sc/src/sc.c:705
Abort
Abort: Memory balance (p4est)
Abort: ../../zzd_Software_Installation_Packages/p4est-2.2/sc/src/sc.c:705
Abort
Abort: Memory balance (p4est)
Abort: ../../zzd_Software_Installation_Packages/p4est-2.2/sc/src/sc.c:705
Abort
Abort: Memory balance (p4est)
Abort: ../../zzd_Software_Installation_Packages/p4est-2.2/sc/src/sc.c:705
Abort
===================================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= PID 7914 RUNNING AT zzd-tnk-4755
= EXIT CODE: 6
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Aborted (signal 6)
This typically refers to a problem with your application.
Please see the FAQ page for debugging suggestions
May I ask you to give me some hints on this problem?
Thank you very much in advance!
Best regards,
Zhidong Brian Zhang
On Saturday, October 19, 2019 at 10:56:47 AM UTC-4, Wolfgang Bangerth wrote:
>
>
> Zhidong,
>
> > 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().
>
> I think this is the wrong approach. The cell ids are used to globally
> identify
> cells, but there is no easy way to translate between cell ids and an index
> into vectors. What you want to do is create another finite element field
> that
> is piecewise constant, i.e., using FE_DGQ(0). Such fields have exactly one
> value per cell, and they can be accessed like any other field-based
> quantity.
>
> Best
> W.
>
> --
> ------------------------------------------------------------------------
> Wolfgang Bangerth email: [email protected]
> <javascript:>
> 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/8736fe0f-4366-455c-9c4e-f184774c80d7%40googlegroups.com.