Issues with single element boundary conditions

25 views
Skip to first unread message

BBah

unread,
Dec 12, 2022, 5:55:50 AM12/12/22
to deal.II User Group
Hello,

it is the first time i am using the GridGenerator and i am trying to create just a single element (3D) and add dirichlet BC on one side.

I did the following:
    repetitions[0] = 1;
    repetitions[1] = 1;
    // Only allow one element through the thickness
    // (modelling a plane strain condition)
    if (dim == 3)
      repetitions[dim-1] = 1;
    const Point<dim> bottom_left = (dim == 3 ? Point<dim>(0.0, 0.0, -0.5) : Point<dim>(0.0, 0.0));
    const Point<dim> top_right = (dim == 3 ? Point<dim>(1.0, 1.0, 0.5) : Point<dim>(1.0, 1.0));
    GridIn<dim> grid_in;
    grid_in.attach_triangulation(triangulation);
    GridGenerator::subdivided_hyper_rectangle(triangulation,
                                          repetitions,
                                          bottom_left,
                                          top_right,true);

and it is working fine. Now i mark the faces to add the boundary conditions:
    const double tol_boundary = 1e-3;
    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] - 1.0) < tol_boundary)
              cell->face(face)->set_boundary_id(11); // +X faces
            else if (std::abs(cell->face(face)->center()[1] - 0.0) < tol_boundary)
              cell->face(face)->set_boundary_id(13); // +Y faces
            else if (std::abs(cell->face(face)->center()[0] - 0.0) < tol_boundary)
              cell->face(face)->set_boundary_id(10); // -X faces  
            else if (dim == 3 && std::abs(std::abs(cell->face(face)->center()[2]) - 0.5) < tol_boundary)
              cell->face(face)->set_boundary_id(12); // +Z and -Z faces
           
          }

When i add the BC i cannot see any movement of my element:
      const int boundary_id1 = 11;
      VectorTools::interpolate_boundary_values(dof_handler_ref,
                                              boundary_id1,
                                              ZeroFunction<dim>(n_components),
                                              constraints,
                                              fe.component_mask(u_fe));
          const int  boundary_id = 10;
              const double delta_u_x = load_rate*time.get_delta_t();
              VectorTools::interpolate_boundary_values(dof_handler_ref,
                                                    boundary_id,
                                                    ConstantFunction<dim>(-delta_u_x,n_components),
                                                    constraints,
                                                    fe.component_mask(x_displacement));
Is there any reason why it is not working ?

Wolfgang Bangerth

unread,
Dec 12, 2022, 7:12:43 PM12/12/22
to dea...@googlegroups.com
On 12/12/22 03:55, BBah wrote:
>
> When i add the BC i cannot see any movement of my element:
> constintboundary_id1=11;
> VectorTools::interpolate_boundary_values(dof_handler_ref,
> boundary_id1,
> ZeroFunction<dim>(n_components),
> constraints,
> fe.component_mask(u_fe));
>           const int boundary_id=10;
> constdoubledelta_u_x=load_rate*time.get_delta_t();
> VectorTools::interpolate_boundary_values(dof_handler_ref,
> boundary_id,
> ConstantFunction<dim>(-delta_u_x,n_components),
> constraints,
> fe.component_mask(x_displacement));
> Is there any reason why it is not working ?

@bbah: We don't know since we don't have access to your code and so we can't
try -- but in any case, you will have to learn to debug these sorts of things.
In your case, if I understand you correctly, you want to implement a time
dependent displacement delta_u_x=load_rate*time to your displacement
computation. The questions to ask then are:

* If you print delta_u_x in each time step, is it nonzero?
* If it is, if you print the 'constraints' object that you create in each time
step, does it change from time step to time step?
* If it does change, are the entries in there reasonable, i.e., do they
correspond to the displacement you want to achieve?
* If yes, are you correctly applying them to the linear system and does the
output of the linear solve match what you believe it should be?

You are looking at the output of your program after running through a few
hundred lines of code, and it appears wrong. But try to break it down into
smaller parts that you can individually look at, like the questions mentioned
above.

Best
W.

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


Reply all
Reply to author
Forward
0 new messages