About applying periodic boundary condition on the same mesh by different methods

108 views
Skip to first unread message

Chuyi Duan

unread,
Jun 1, 2017, 7:00:34 AM6/1/17
to deal.II User Group
Dear all,

i was trying to use Dealii to solve a 3-dimensional elastic-plastic question on a cubic by applying periodic boundary condition like in step-45 (v. 8.5.0).
std::vector<GridTools::PeriodicFacePair<typename DoFHandler<dim>::cell_iterator> > periodicity_vector;
GridTools::collect_periodic_faces(dof_handler, 1, 2, 2, periodicity_vector);//1,2,2: the first two numbers refer to the cell faces at the boundary, the third number to the direction
DoFTools::make_periodicity_constraints<DoFHandler<dim> >(periodicity_vector,constraint_matrix);

But i got different results as i have created the mesh using
GridGenerator::subdivided_hyper_rectangle (triangulation, rep, p1, p2);//rep is the repetition
method 1 to get the mesh:
p1 (0, 0, 0)
p2(1, 1, 1)
rep=(8, 8, 8)
no global refinement

method 2 to get the mesh:
p1 (0, 0, 0)
p2(1, 1, 1)
rep=(1, 1, 1)
global refinement = 3

I just wonder why there come two different results when these two meshes are actually the same.

Thank you guys for the help!
Chuyi

Daniel Arndt

unread,
Jun 1, 2017, 8:31:58 AM6/1/17
to deal.II User Group
Chuyi,
How do the two solutions actually differ? How many constraints a created in either of these cases?
Can you provide us with a minimal example just setting up the periodic constraints in case they are different?

Best,
Daniel

Chuyi Duan

unread,
Jun 13, 2017, 4:50:44 AM6/13/17
to deal.II User Group
Hello Daniel,

I think i've found where the problem was. It's because I used set_boundary_id with active_cell_iterator after global_refinement. But I found in source codes of collect_periodic_faces function it's just cell_iterator that has been used. I've instead called set_boundary_id at first then global_refinement and it goes well.

Thank you anyway.

Chuyi

在 2017年6月1日星期四 UTC+2下午2:31:58,Daniel Arndt写道:

Chuyi Duan

unread,
Jun 26, 2017, 12:32:49 PM6/26/17
to deal.II User Group
Hi Daniel,

I still have a question about how to apply periodic boundary conditons: Is there any possibility now to apply PBC with a value 1.0 in x_component and y_component while -1.0 in z_component? I've read an older version of step-45 before (like 8.3.0), which showed we could change that when calling ConstraintMatrix::add_entry, but later this has been removed, and now I can't find how to do it.

Best

Chuyi

在 2017年6月1日星期四 UTC+2下午2:31:58,Daniel Arndt写道:
Chuyi,

Daniel Arndt

unread,
Jun 26, 2017, 6:01:10 PM6/26/17
to deal.II User Group
Chuyi,

I still have a question about how to apply periodic boundary conditons: Is there any possibility now to apply PBC with a value 1.0 in x_component and y_component while -1.0 in z_component? I've read an older version of step-45 before (like 8.3.0), which showed we could change that when calling ConstraintMatrix::add_entry, but later this has been removed, and now I can't find how to do it.
I guess with PBC in z_component with value -1.0 you mean something similar to u(x,y,0)=-u(x,y,1)?
Unfortunately, this is a bit complicated as constraints in a ConstraintMatrix can't be changed easily after they have been added.

Using make_periodicity_constraints you get u(x,y,0)=u(x,y,1) and then you would just invert the sign for all the entries in the lines corresponding to the respective DoFs in the ConstraintMatrix.
For doing so, you can get the interesting DoFs via DoFTools::extract_boundary_dofs() [1] and then request the respective constraints via ConstraintMatrix::get_constraint_lines() [2].
From these information you would create another ConstraintMatrix (where the line entries have the inverted sign) and merge the other constraints in via ConstraintMatrix::merge() [3] with left_object_wins.

Best,
Daniel

Chuyi Duan

unread,
Jul 5, 2017, 9:16:43 AM7/5/17
to deal.II User Group
Thanks Daniel,

i finished it. But i think in the second step ConstraintMatrix::get_constraint_lines() should be (*constraint_entries)[0].first by calling constraint_entries = ConstraintMatrix::get_constraint_entries(* IndexSet::ElementIterator), right?

Best,
Chuyi

在 2017年6月27日星期二 UTC+2上午12:01:10,Daniel Arndt写道:

Daniel Arndt

unread,
Jul 5, 2017, 4:45:17 PM7/5/17
to deal.II User Group
Chuyi,


i finished it. But i think in the second step ConstraintMatrix::get_constraint_lines() should be (*constraint_entries)[0].first by calling constraint_entries = ConstraintMatrix::get_constraint_entries(* IndexSet::ElementIterator), right?
Yes, you're right ConstraintMatrix::get_constraint_lines()  should have been ConstraintMatrix::get_constraint_entries(). Also note that there might be more than one constraint entry and that not all the coefficients are 1. This in particular happens if you consider adaptive mesh refinement.
Otherwise, I am happy to hear that this worked well for you!

Best,
Daniel
Reply all
Reply to author
Forward
0 new messages