Dear All, I'm trying to calculate something differently depending on material id.
So, I have to set material id before next iteration.(I'm going to use picard iteration) The way I have done is 1.the middle point of mesh would be selected. (it is indicated as max_cell in my code) 2.the neighbor cells of max_cell are accessed and the neighbor cells of those neighbor cells would be also accessed later. 3.If neighbor cell satisfy the certain condition and have never been accessed before I will set the new material id on these cells. (The condition is "fabs(solution)>=fabs(psi_b) " and the new material id would be same as iteration number to check whether it has been accessed before) 4.those cells that satisfy the condition, would also have access to the neighbor cells.(those neighbor cells are indicated as next_cell in my code) 5.the process would continue until there is no neighbor cells anymore that satisfy fabs(solution)>=fabs(psi_b) i.e. What I'm going to do is to set the new material id in the inside of contour of psi_b. So, my code is as follows. template <int dim> void Step6<dim>::set_id () { const QGauss<dim> quadrature_formula(2); FEValues<dim> fe_values (fe, quadrature_formula, update_values | update_quadrature_points); const unsigned int n_q_points = quadrature_formula.size(); std::vector<typename DoFHandler<dim>::cell_iterator> next_cell; std::vector<typename DoFHandler<dim>::cell_iterator> neigh_cell; typename DoFHandler<dim>::cell_iterator neigh_cell_tmp; std::vector<double> sol_tmp(n_q_points); std::cout<<"to check out the position of max cell"<<std::endl; fe_values.reinit(max_cell); const Point<dim> &p=fe_values.quadrature_point(0); std::cout<<"R_max="<<p(0)<<"Z_max="<<p(1)<<std::endl; std::cout<<"mat_id="<<int(max_cell->material_id())<<std::endl; max_cell->set_material_id(iter); //set new material id as iteration number for(unsigned int face_no=0;face_no< GeometryInfo<dim>::faces_per_cell;++face_no) //starting from the neighbor cells of max_cell next_cell.push_back(max_cell->neighbor(face_no)); while(next_cell.size()!=0) //until there is no neighbor cells that satisfy the condition anymore. { neigh_cell.clear(); neigh_cell.resize(next_cell.size()); std::copy(next_cell.begin(), next_cell.end(),neigh_cell.begin()); next_cell.clear(); for(unsigned int i=0; i<neigh_cell.size(); ++i) { fe_values.reinit(neigh_cell[i]); fe_values.get_function_values(solution,sol_tmp); unsigned int determine=0; //to determine that whether all quad points are not satisfied with the condition. for(unsigned int q=0; q < n_q_points; q++) { if(std::fabs(sol_tmp[q])>=std::fabs(psi_b)) { neigh_cell[i]->set_material_id(iter); for(unsigned int face_no=0;face_no< GeometryInfo<dim>::faces_per_cell;++face_no) { neigh_cell_tmp=(neigh_cell[i]->neighbor(face_no)); if(int(neigh_cell_tmp->material_id())!=iter) //To exclude the already checked cell { next_cell.push_back(neigh_cell_tmp); } } break; } determine++; } if(determine==n_q_points) //if all points on the cell are not satisfied with the condition, set material id as zero { neigh_cell[i]->set_material_id(0); //vacuum } } std::cout<<"#next_cell="<<next_cell.size()<<std::endl; } } the above code works. However, the problem is when I check the number of next_cell, it is much larger than the number of active cells. The number of active cells is 9390 but the number of active cell is from 11 to 16359020 that is much larger than 9390. I guess that "if(int(neigh_cell_tmp->material_id())!=iter) //To exclude the already checked cell" this part in the above code is not working properly. So, the duplication of access happens. Could you let me know what the problem is in the above code...? Thank you. Kyusik. -- 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. For more options, visit https://groups.google.com/d/optout.