Hello Daniel,
thanks for your message.
I know how to find the cell index.
Could I ask one more question?
The question is about the grid.
In code I used the function below to create the grid.
template <int dim>
Point<dim> grid_y_transform (const Point<dim> &pt_in)
{
const double &x = pt_in[0];
const double &y = pt_in[1];
Point<dim> pt_out = pt_in;
return pt_out;
}
template <int dim,typename NumberType>
void Solid<dim,NumberType>::make_grid()
{
// Divide the beam, but only along the x- and y-coordinate directions
std::vector< unsigned int > repetitions(dim, parameters.elements_per_edge);
// Only allow one element through the thickness
// (modelling a plane strain condition)
if (dim == 3){
repetitions[dim-1] = 8;
//repetitions[0] = 0;
//repetitions[1] = 2;
//repetitions[2] = 2;
}
repetitions[1] = 8;
repetitions[2] = 8;
const Point<dim> top_right =Point<dim>(0.0, 0.0, -10);
const Point<dim> bottom_left =Point<dim>(40,20, 10);
GridGenerator::subdivided_hyper_rectangle(triangulation,
repetitions,
bottom_left,
top_right);
// Since we wish to apply a Neumann BC to the right-hand surface, we
// must find the cell faces in this part of the domain and mark them with
// a distinct boundary ID number. The faces we are looking for are on the
// +x surface and will get boundary ID 11.
// Dirichlet boundaries exist on the left-hand face of the beam (this fixed
// boundary will get ID 1) and on the +Z and -Z faces (which correspond to
// ID 2 and we will use to impose the plane strain condition)
const double tol_boundary = 1e-6;
typename Triangulation<dim>::active_cell_iterator cell =
triangulation.begin_active(), endc = triangulation.end();
for (; cell != endc; ++cell)
for (unsigned int face = 0;
face < GeometryInfo<dim>::faces_per_cell; ++face)
if (cell->face(face)->at_boundary() == true)
{
if (std::abs(cell->face(face)->center()[0] - 0.0) < tol_boundary)
cell->face(face)->set_boundary_id(1); // -X faces
else if (std::abs(cell->face(face)->center()[0] - 40.0) < tol_boundary)
cell->face(face)->set_boundary_id(11); // +X faces
else if (dim == 3 && std::abs(std::abs(cell->face(face)->center()[2]) - 10) < tol_boundary)
cell->face(face)->set_boundary_id(2); // +Z and -Z faces
}
// Transform the hyper-rectangle into the beam shape
GridTools::transform(&grid_y_transform<dim>, triangulation);
GridTools::scale(parameters.scale, triangulation);
vol_reference = GridTools::volume(triangulation);
vol_current = vol_reference;
std::cout << "Grid:\n\t Reference volume: " << vol_reference << std::endl;
}
My question is whether I can use NURBS to create the same grids and how I could create the grids with the NURBS.