How to find the cell index by using global dof index

79 views
Skip to first unread message

Lance Zhang

unread,
Dec 3, 2023, 11:38:55 PM12/3/23
to deal.II User Group
Hello team,

may I know how to find the cell index with the information of its global Dofs index?

I have the global dofs index ,I would like to find which cell this global dof belongs to.

Thanks in advance!
Best regards
Lance

Daniel Arndt

unread,
Dec 4, 2023, 9:08:32 AM12/4/23
to dea...@googlegroups.com

--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/4453e03d-2511-43c4-a05d-71e695a9276cn%40googlegroups.com.

Lance Zhang

unread,
Dec 6, 2023, 5:06:43 PM12/6/23
to dea...@googlegroups.com
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.


Thanks in advance!

Best regards
Lance

Daniel Arndt <d.arnd...@gmail.com> 于 2023年12月4日周一 16:08写道:
You received this message because you are subscribed to a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/U7Il_6jPOCQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CAOYDWbJLsBk2D45tHF4grTeHT%3DejkqQqXMtkLBqB1K-b%3DHbh%2BA%40mail.gmail.com.

Wolfgang Bangerth

unread,
Dec 7, 2023, 1:23:38 AM12/7/23
to dea...@googlegroups.com
On 12/6/23 15:06, Lance Zhang wrote:
> My question is whether I can use NURBS to create the same grids and how I
> could create the grids with the NURBS.

Can you explain what you mean by this? NURBS are basis functions, a mesh is a
subdivision of a domain into cells. These are not the same thing, so it is not
clear to me what exactly it is you want to do.

Best
WB

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/


Reply all
Reply to author
Forward
0 new messages