Hi,
I’m working with a Deal code and I have a doubt in the implementation which hopefully one of you can help me.
I have certain active cells that have property A. I want to loop over these cells and then loop over its neighbours so I can assign them property A.
The way that I wanted to implement this is by:
1:Create a vector "Cells_with_A" with the cell indices of the cells that have property A
2: create a loop with respect to this vector and get the cells from the index and once I have the cell call its neighbours.
However, I can’t find which function access the cell from the cell index..
I’m looking for something like
cell_from_index(cell->index())
but I haven’t find it in the documentation. Is there a function like that?
Thanks!
I have certain active cells that have property A. I want to loop over these cells and then loop over its neighbours so I can assign them property A.
The way that I wanted to implement this is by:
1:Create a vector "Cells_with_A" with the cell indices of the cells that have property A
2: create a loop with respect to this vector and get the cells from the index and once I have the cell call its neighbours.
However, I can’t find which function access the cell from the cell index..
I’m looking for something like
cell_from_index(cell->index())
Property A is having a velocity assigned, so has_A=has_vel cells_with_A=cells_with_vel and I also have cell_vel_value
if Q is a cell that has assigned a velocity strength I'm extending the velocity strength to a neighbor cell of it N as the mean value of velocity from its neighbor cells (which include Q and sometimes others)
The code is the following:
for ( typename std::vector<typename hp::DoFHandler<dim>::active_cell_iterator>::iterator p=cells_with_vel.begin(); p!=cells_with_vel.end(); ++p)
{
for (unsigned int face_no=0; face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
{
if ((*p)->at_boundary(face_no) == false) //if the face is not at the boundary
{ if ( has_vel[(*p)->neighbor(face_no)->index()]==0)//if the neighbor at this face does not have a velocity assigned
{
double vel_value=0;
int n_neighbors_non_zero_vel= 0;
for (unsigned int face_no2=0; face_no2<GeometryInfo<dim>::faces_per_cell; ++face_no2)
{// loop to assign the mean value of the neighbor cells that have velocity assigned
vel_value+=cells_vel_value[(*p)->neighbor(face_no)->neighbor(face_no2)->index()];
n_neighbors_non_zero_vel+=has_vel[(*p)->neighbor(face_no)->neighbor(face_no2)->index()];
}
vel_value/=vel_value/n_neighbors_non_zero_vel;
}
}
}
}
The error is this:
An error occurred in line <934> of file </Users/victoria/software/dealii-dev/include/deal.II/grid/tria_iterator.h> in function
Accessor &dealii::TriaRawIterator<dealii::DoFCellAccessor<dealii::hp::DoFHandler<2, 2>, false> >::operator*() [Accessor = dealii::DoFCellAccessor<dealii::hp::DoFHandler<2, 2>, false>]
The violated condition was:
Accessor::structure_dimension!=Accessor::dimension || state() == IteratorState::valid
The name and call sequence of the exception was:
ExcDereferenceInvalidCell(accessor)
Additional Information:
You tried to dereference a cell iterator for which this is not possible. More information on this iterator: level=-1, index=-1, state=past_the_end