Dear Daniel, > It seems that you are now constraining all the components, i.e. > u_x(0,y)=u_x(L,y) and u_y(0,y)=u_y(L,y). > Is this really what you want to do? Otherwise, you should have a > ComponentMask in your call to > DoFTools::make_periodicity_constraints as well, i.e. > > You are right Daniel. I want to constraint all displacement components. If I constraint U_x for left and right faces and U_y for top and bottom faces, I do not confront the problem I have now. The problem is that the DoFs residing at the bottom-left node (where two faces on which we apply inhomogenity, interface) the inhomogenity for the U_y is doubled despite the similarity of the code for x and y direction !!! However, this happens by "constraints.close" function since when I uncomment it, the constraints are exactly what is coded. Nevertheless, the constraints.close is required and can not be omitted.
Again, I don't see an immediate reason why x- and y-direction don't behave > similarly. Can you provide a minimal working code showing this? > The minimal code is attached. It would be appreciated if you could investigate what is wrong! Thanks, Hamed -- 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.
#include <deal.II/dofs/dof_tools.h> #include <deal.II/dofs/dof_handler.h> #include <deal.II/grid/grid_generator.h> #include <deal.II/grid/tria.h> #include <deal.II/fe/fe_q.h> #include <deal.II/fe/fe_system.h> #include <iostream> #include <fstream> namespace PhaseField { using namespace dealii; template <int dim> class Solid { public: Solid(); virtual ~Solid(); void run(); private: void make_grid(); void make_constraints(); Triangulation<dim> triangulation; const FESystem<dim> fe; DoFHandler<dim> dof_handler; ConstraintMatrix constraints; }; template <int dim> Solid<dim>::Solid() : fe(FE_Q<dim>(1), dim), dof_handler(triangulation) {} template <int dim> Solid<dim>::~Solid() { dof_handler.clear(); } template <int dim> void Solid<dim>::make_grid() { GridGenerator::hyper_cube (triangulation, -1, 1,true); dof_handler.distribute_dofs(fe); } //////////////////////////////// template <int dim> void Solid<dim>::make_constraints() { constraints.clear(); const FEValuesExtractors::Scalar x_displacement(0); const FEValuesExtractors::Scalar y_displacement(1); const FEValuesExtractors::Scalar z_displacement(2); DoFTools::make_periodicity_constraints(dof_handler, /*b_id*/ 0, /*b_id*/ 1, /*direction*/ 0, constraints); DoFTools::make_periodicity_constraints(dof_handler, /*b_id*/ 2, /*b_id*/ 3, /*direction*/ 1, constraints); { IndexSet selected_dofs_x; std::set< types::boundary_id > boundary_ids_x= std::set<types::boundary_id>(); boundary_ids_x.insert(0); DoFTools::extract_boundary_dofs(dof_handler, fe.component_mask(x_displacement), selected_dofs_x, boundary_ids_x); unsigned int nb_dofs_face_x = selected_dofs_x.n_elements(); IndexSet::ElementIterator dofs_x = selected_dofs_x.begin(); for(unsigned int i = 0; i < nb_dofs_face_x; i++) { constraints.set_inhomogeneity(*dofs_x, 0.1); dofs_x++; } } { IndexSet selected_dofs_y; std::set< types::boundary_id > boundary_ids_y= std::set<types::boundary_id>(); boundary_ids_y.insert(2); DoFTools::extract_boundary_dofs(dof_handler, fe.component_mask(y_displacement), selected_dofs_y, boundary_ids_y); unsigned int nb_dofs_face_y = selected_dofs_y.n_elements(); IndexSet::ElementIterator dofs_y = selected_dofs_y.begin(); for(unsigned int i = 0; i < nb_dofs_face_y; i++) { constraints.set_inhomogeneity(*dofs_y, 0.3 ); dofs_y++; } } constraints.close(); } ////////////////////////////////////////////////// template <int dim> void Solid<dim>::run() { make_grid(); make_constraints(); constraints.print(std::cout); } } ///////////////////////////////////////////////////////// int main () { using namespace dealii; using namespace PhaseField; { Solid<2> solid_2d; solid_2d.run(); } }