{"action":"created","comment":{"url":"https://api.github.com/repos/dealii/dealii/pulls/comments/39448793","id":39448793,"diff_hunk":"@@ -1,72 +1,142 @@\n <br>\n \n-<i>This program was contributed by Markus B&uuml;rg.</i>\n-<br>\n-\n+<i>This program was contributed by Daniel Arndt and Matthias Maier.</i>\n <a name=\"Intro\"></a>\n <h1>Introduction</h1>\n \n-In this example we consider how to use periodic boundary conditions in\n-deal.II. Periodic boundary conditions are a typical approach when one wants to\n-solve some equation on a representative piece of a larger domain that repeats\n-in one or more direction; an example is the simulation of the electronic\n-structure of photonic\n+In this example we present how to use periodic boundary conditions in\n+deal.II. Periodic boundary conditions are algebraic constraints that\n+typically occur in computations on representative regions of a larger\n+domain that repeat in one or more directions.\n+\n+An example is the simulation of the electronic structure of photonic\n crystals, because they have a lattice-like structure and, thus, it often\n-suffices to do the actual computation on only one cell of the lattice. To be\n-able to proceed this way one has to assume that the computation can be periodically\n-extended to the other cells. This requires the solution to be periodic with respect\n-to the cells. Hence the solution has to obtain the same nodal values on opposite\n-parts of the boundary. In the figure below we show this\n-concept in two space-dimensions. There, all dashed faces with the same color should\n-have the same boundary values:\n+suffices to do the actual computation on only one cell of the lattice. To\n+be able to proceed this way one has to assume that the computation can be\n+periodically extended to the other cells; this requires the solution to\n+have a periodic structure.\n \n-<img src=\"http://www.dealii.org/images/steps/developer/step-45.periodic_cells.png\" alt=\"\">\n+<a name=\"Procedure\"></a>\n+<h1>Procedure</h1>\n \n-To keep things simple, in this tutorial we will consider an academic,\n-simplified problem that allows us to focus on only that part that we are\n-interested in here, namely how to set up periodic boundary\n-conditions. Specifically, we solve the Poisson problem on a domain, where the\n-left and right parts of the boundary are identified. Let $\\Omega=(0,1)^2$ and\n-consider the problem\n-@f{align*}\n-   -\\Delta u &=\n-   \\cos(2\\pi x)e^{-2x}\\cos(2\\pi y)e^{-2y}  \\qquad &&\\text{in }\\Omega\n-  \\\\ \n-   u(x,0) &= 0 \\qquad &&\\text{for }x\\in(0,1)\\qquad &&\\text{(bottom boundary)}\n-  \\\\\n-   u(x,1) &= 0 \\qquad &&\\text{for }x\\in(0,1)\\qquad &&\\text{(top boundary)}\n-  \\\\\n-   u(0,y) &= u(1,y) \\qquad &&\\text{for }y\\in(0,1) \n-   \\qquad && \\text{(left and right boundaries)}\n-@f}\n-Note that the source term is not symmetric and so the solution would not be\n-periodic unless this is explicitly enforced.\n+deal.II provides a number of high level functionality to impose periodic\n+boundary conditions.\n+The general approach to apply periodic boundary conditions consists of\n+three steps (see also the\n+@ref GlossPeriodicConstraints \"Glossary entry on periodic boundary conditions\"):\n+-# Create a mesh\n+-# Gather the periodic faces using GridTools::collect_periodic_faces()\n+-# Add the periodicity information to the mesh\n+  using parallel::distributed::Triangulation::add_periodicity()\n+-# Add periodicity constraints using DoFTools::make_periodicity_constraints()\n+The second and third step can be omitted if the Triangulation is not a\n+parallel::distributed::Triangulation.\n+\n+The first step consists of collecting matching periodic faces and store them in\n+a <code>std::vector</code> of PeriodicFacePair. This is done with the function\n+GridTools::collect_periodic_faces() that can be invoked for example like this:\n+@code\n+using GridTools::collect_periodic_faces;\n+collect_periodic_faces(dof_handler,\n+                       b_id1,\n+                       b_id2,\n+                       direction,\n+                       matched_pairs,\n+                       offset = <default value>,\n+                       matrix = <default value>,\n+                       first_vector_components = <default value>);\n+@endcode\n+\n+This call loops over all faces of the container dof_handler on the opposing\n+boundaries with boundary indicator b_id1 and b_id2, respecitvely. It matches\n+pairs of faces (and dofs) such that the difference between $face_2$ and\n+$matrix\\cdot face_1+offset$ vanishes in every component apart from direction\n+and stores the resulting pairs with associated data in matched_pairs. (See\n+GridTools::orthogonal_equality() for detailed information about the\n+matching process.)\n+\n+Consider, for example, the colored unit square $\\Omega=[1,1]^2$ with boundary\n+indicator 0 on the left, 1 on the right, 2 on the bottom and 3 on the top\n+faces. Then,\n+@code\n+collect_periodic_faces(dof_handler,\n+                       /*b_id1*/ 0,\n+                       /*b_id2*/ 1,\n+                       /*direction*/ 0,\n+                       matched_pairs);\n+@endcode\n+would yield periodicity constraints such that $u(0,y)=u(1,y)$ for all\n+$y\\in[0,1]$.\n \n-The way one has to see these periodic boundary conditions $u(x,0) = u(x,1)$ is\n-as follows: Assume for a moment (as we do in this program) that we have a\n-uniformly refined mesh. Then, after discretization there are a number of nodes\n-(degrees of freedom) with indices $i \\in {\\cal I}_l$ on the left boundary of\n-the domain, and  a second set of nodes at the right boundary $j \\in {\\cal\n-I}_r$. Since we have assumed that the mesh is uniformly refined, there is\n-exactly one node $j \\in {\\cal I}_r$ for each $i \\in {\\cal I}_l$ so that\n-${\\mathrm x}_j = {\\mathrm x}_i + (1,0)^T$, i.e. the two of them match with\n-respect to the periodicity. We will then write that $j=\\text{periodic}(i)$\n-(and, if you want, $i=\\text{periodic}(j)$).\n-If now $U_k, k=0,\\ldots,N-1,$ are the unknowns of our discretized problem, then\n-the periodic boundary condition boils down to the following set of\n-constraints:\n+If we instead consider the parallelogram given by the convex hull of\n+$(0,0)$, $(1,1)$, $(1,2)$, $(0,1)$ we can achieve the constraints\n+$u(0,y)=u(1,y+1)$ by specifying an @p offset:\n+@code\n+GridTools::collect_periodic_faces(dof_handler,\n+                                  /*b_id1*/ 0,\n+                                  /*b_id2*/ 1,\n+                                  /*direction*/ 0,\n+                                  matched_pairs,\n+                                  Tensor<1, 2>(0.,1.));\n+@endcode\n+or\n+@code\n+GridTools::collect_periodic_faces(dof_handler,\n+                                  /*b_id1*/ 0,\n+                                  /*b_id2*/ 1,\n+                                  /*arbitrary direction*/ 0,\n+                                  matched_pairs,\n+                                  Tensor<1, 2>(1.,1.));\n+@endcode\n+\n+The resulting matched_pairs can be used in\n+DoFTools::make_periodicity_constraints for populating a ConstraintMatrix\n+with periodicity constraints:\n+@code\n+DoFTools::make_periodicity_constraints(matched_pairs, constraints);\n+@endcode\n+\n+Apart from this high level interface there are also variants of\n+DoFTools::make_periodicity_constraints available that combine those two\n+steps (see the variants of DofTools::make_periodicity_constraints).\n+\n+There is also a low level interface to\n+DofTools::make_periodicity_constraints if more flexibility is needed. The\n+low level variant allows to directly specify two faces that shall be\n+constrained:\n+@code\n+using namespace DoFTools;\n+make_periodicity_constraints(face_1,\n+                             face_2,\n+                             constraint_matrix,\n+                             component_mask = <default value>;\n+                             face_orientation = <default value>,\n+                             face_flip = <default value>,\n+                             face_rotation = <default value>,\n+                             matrix = <default value>);\n+@endcode\n+Here, we need to specify the orientation of the two faces using\n+face_orientation, face_flip and face_orientation. For a closer desription","path":"examples/step-45/doc/intro.dox","position":167,"original_position":167,"commit_id":"5832a7d3f0b81b488c943cf89824b130d25721d6","original_commit_id":"5832a7d3f0b81b488c943cf89824b130d25721d6","user":{"login":"bangerth","id":7504421,"avatar_url":"https://avatars.githubusercontent.com/u/7504421?v=3","gravatar_id":"","url":"https://api.github.com/users/bangerth","html_url":"https://github.com/bangerth","followers_url":"https://api.github.com/users/bangerth/followers","following_url":"https://api.github.com/users/bangerth/following{/other_user}","gists_url":"https://api.github.com/users/bangerth/gists{/gist_id}","starred_url":"https://api.github.com/users/bangerth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bangerth/subscriptions","organizations_url":"https://api.github.com/users/bangerth/orgs","repos_url":"https://api.github.com/users/bangerth/repos","events_url":"https://api.github.com/users/bangerth/events{/privacy}","received_events_url":"https://api.github.com/users/bangerth/received_events","type":"User","site_admin":false},"body":"desription -> description","created_at":"2015-09-14T21:20:24Z","updated_at":"2015-09-14T21:20:24Z","html_url":"https://github.com/dealii/dealii/pull/1421#discussion_r39448793","pull_request_url":"https://api.github.com/repos/dealii/dealii/pulls/1421","_links":{"self":{"href":"https://api.github.com/repos/dealii/dealii/pulls/comments/39448793"},"html":{"href":"https://github.com/dealii/dealii/pull/1421#discussion_r39448793"},"pull_request":{"href":"https://api.github.com/repos/dealii/dealii/pulls/1421"}}},"pull_request":{"url":"https://api.github.com/repos/dealii/dealii/pulls/1421","id":43134389,"html_url":"https://github.com/dealii/dealii/pull/1421","diff_url":"https://github.com/dealii/dealii/pull/1421.diff","patch_url":"https://github.com/dealii/dealii/pull/1421.patch","issue_url":"https://api.github.com/repos/dealii/dealii/issues/1421","number":1421,"state":"open","locked":false,"title":"Replace obsolete step-45 with new version","user":{"login":"tamiko","id":3432917,"avatar_url":"https://avatars.githubusercontent.com/u/3432917?v=3","gravatar_id":"","url":"https://api.github.com/users/tamiko","html_url":"https://github.com/tamiko","followers_url":"https://api.github.com/users/tamiko/followers","following_url":"https://api.github.com/users/tamiko/following{/other_user}","gists_url":"https://api.github.com/users/tamiko/gists{/gist_id}","starred_url":"https://api.github.com/users/tamiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamiko/subscriptions","organizations_url":"https://api.github.com/users/tamiko/orgs","repos_url":"https://api.github.com/users/tamiko/repos","events_url":"https://api.github.com/users/tamiko/events{/privacy}","received_events_url":"https://api.github.com/users/tamiko/received_events","type":"User","site_admin":false},"body":"This pull-request replaces the obsolete step-45 with a new version that\ndemonstrates how to use the library features for periodic boundary conditions.\n\nIt is based on step-22 and solves a Stokes Flow with periodic boundary\nconditions on a quarter disc on a distributed triangulation *yay*\n\nFor convenience I have uploaded the tutorial page [1]\n\n[1] http://tamiko.kyomu.43-1.org/tmp/step_45.html","created_at":"2015-08-24T02:04:24Z","updated_at":"2015-09-14T21:20:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"433e7819205090509d6a43be68e41635cca1647d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dealii/dealii/pulls/1421/commits","review_comments_url":"https://api.github.com/repos/dealii/dealii/pulls/1421/comments","review_comment_url":"https://api.github.com/repos/dealii/dealii/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dealii/dealii/issues/1421/comments","statuses_url":"https://api.github.com/repos/dealii/dealii/statuses/5832a7d3f0b81b488c943cf89824b130d25721d6","head":{"label":"tamiko:branch_fix_step45","ref":"branch_fix_step45","sha":"5832a7d3f0b81b488c943cf89824b130d25721d6","user":{"login":"tamiko","id":3432917,"avatar_url":"https://avatars.githubusercontent.com/u/3432917?v=3","gravatar_id":"","url":"https://api.github.com/users/tamiko","html_url":"https://github.com/tamiko","followers_url":"https://api.github.com/users/tamiko/followers","following_url":"https://api.github.com/users/tamiko/following{/other_user}","gists_url":"https://api.github.com/users/tamiko/gists{/gist_id}","starred_url":"https://api.github.com/users/tamiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamiko/subscriptions","organizations_url":"https://api.github.com/users/tamiko/orgs","repos_url":"https://api.github.com/users/tamiko/repos","events_url":"https://api.github.com/users/tamiko/events{/privacy}","received_events_url":"https://api.github.com/users/tamiko/received_events","type":"User","site_admin":false},"repo":{"id":22046756,"name":"dealii","full_name":"tamiko/dealii","owner":{"login":"tamiko","id":3432917,"avatar_url":"https://avatars.githubusercontent.com/u/3432917?v=3","gravatar_id":"","url":"https://api.github.com/users/tamiko","html_url":"https://github.com/tamiko","followers_url":"https://api.github.com/users/tamiko/followers","following_url":"https://api.github.com/users/tamiko/following{/other_user}","gists_url":"https://api.github.com/users/tamiko/gists{/gist_id}","starred_url":"https://api.github.com/users/tamiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamiko/subscriptions","organizations_url":"https://api.github.com/users/tamiko/orgs","repos_url":"https://api.github.com/users/tamiko/repos","events_url":"https://api.github.com/users/tamiko/events{/privacy}","received_events_url":"https://api.github.com/users/tamiko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tamiko/dealii","description":"","fork":true,"url":"https://api.github.com/repos/tamiko/dealii","forks_url":"https://api.github.com/repos/tamiko/dealii/forks","keys_url":"https://api.github.com/repos/tamiko/dealii/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tamiko/dealii/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tamiko/dealii/teams","hooks_url":"https://api.github.com/repos/tamiko/dealii/hooks","issue_events_url":"https://api.github.com/repos/tamiko/dealii/issues/events{/number}","events_url":"https://api.github.com/repos/tamiko/dealii/events","assignees_url":"https://api.github.com/repos/tamiko/dealii/assignees{/user}","branches_url":"https://api.github.com/repos/tamiko/dealii/branches{/branch}","tags_url":"https://api.github.com/repos/tamiko/dealii/tags","blobs_url":"https://api.github.com/repos/tamiko/dealii/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tamiko/dealii/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tamiko/dealii/git/refs{/sha}","trees_url":"https://api.github.com/repos/tamiko/dealii/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tamiko/dealii/statuses/{sha}","languages_url":"https://api.github.com/repos/tamiko/dealii/languages","stargazers_url":"https://api.github.com/repos/tamiko/dealii/stargazers","contributors_url":"https://api.github.com/repos/tamiko/dealii/contributors","subscribers_url":"https://api.github.com/repos/tamiko/dealii/subscribers","subscription_url":"https://api.github.com/repos/tamiko/dealii/subscription","commits_url":"https://api.github.com/repos/tamiko/dealii/commits{/sha}","git_commits_url":"https://api.github.com/repos/tamiko/dealii/git/commits{/sha}","comments_url":"https://api.github.com/repos/tamiko/dealii/comments{/number}","issue_comment_url":"https://api.github.com/repos/tamiko/dealii/issues/comments{/number}","contents_url":"https://api.github.com/repos/tamiko/dealii/contents/{+path}","compare_url":"https://api.github.com/repos/tamiko/dealii/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tamiko/dealii/merges","archive_url":"https://api.github.com/repos/tamiko/dealii/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tamiko/dealii/downloads","issues_url":"https://api.github.com/repos/tamiko/dealii/issues{/number}","pulls_url":"https://api.github.com/repos/tamiko/dealii/pulls{/number}","milestones_url":"https://api.github.com/repos/tamiko/dealii/milestones{/number}","notifications_url":"https://api.github.com/repos/tamiko/dealii/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tamiko/dealii/labels{/name}","releases_url":"https://api.github.com/repos/tamiko/dealii/releases{/id}","created_at":"2014-07-21T00:21:17Z","updated_at":"2015-05-07T08:20:43Z","pushed_at":"2015-09-14T15:39:48Z","git_url":"git://github.com/tamiko/dealii.git","ssh_url":"git@github.com:tamiko/dealii.git","clone_url":"https://github.com/tamiko/dealii.git","svn_url":"https://github.com/tamiko/dealii","homepage":null,"size":126728,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dealii:master","ref":"master","sha":"52b70a119e902196680732d97e642dce7c0d92bd","user":{"login":"dealii","id":7506070,"avatar_url":"https://avatars.githubusercontent.com/u/7506070?v=3","gravatar_id":"","url":"https://api.github.com/users/dealii","html_url":"https://github.com/dealii","followers_url":"https://api.github.com/users/dealii/followers","following_url":"https://api.github.com/users/dealii/following{/other_user}","gists_url":"https://api.github.com/users/dealii/gists{/gist_id}","starred_url":"https://api.github.com/users/dealii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dealii/subscriptions","organizations_url":"https://api.github.com/users/dealii/orgs","repos_url":"https://api.github.com/users/dealii/repos","events_url":"https://api.github.com/users/dealii/events{/privacy}","received_events_url":"https://api.github.com/users/dealii/received_events","type":"Organization","site_admin":false},"repo":{"id":21943980,"name":"dealii","full_name":"dealii/dealii","owner":{"login":"dealii","id":7506070,"avatar_url":"https://avatars.githubusercontent.com/u/7506070?v=3","gravatar_id":"","url":"https://api.github.com/users/dealii","html_url":"https://github.com/dealii","followers_url":"https://api.github.com/users/dealii/followers","following_url":"https://api.github.com/users/dealii/following{/other_user}","gists_url":"https://api.github.com/users/dealii/gists{/gist_id}","starred_url":"https://api.github.com/users/dealii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dealii/subscriptions","organizations_url":"https://api.github.com/users/dealii/orgs","repos_url":"https://api.github.com/users/dealii/repos","events_url":"https://api.github.com/users/dealii/events{/privacy}","received_events_url":"https://api.github.com/users/dealii/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dealii/dealii","description":"The development repository for the deal.II finite element library.","fork":false,"url":"https://api.github.com/repos/dealii/dealii","forks_url":"https://api.github.com/repos/dealii/dealii/forks","keys_url":"https://api.github.com/repos/dealii/dealii/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dealii/dealii/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dealii/dealii/teams","hooks_url":"https://api.github.com/repos/dealii/dealii/hooks","issue_events_url":"https://api.github.com/repos/dealii/dealii/issues/events{/number}","events_url":"https://api.github.com/repos/dealii/dealii/events","assignees_url":"https://api.github.com/repos/dealii/dealii/assignees{/user}","branches_url":"https://api.github.com/repos/dealii/dealii/branches{/branch}","tags_url":"https://api.github.com/repos/dealii/dealii/tags","blobs_url":"https://api.github.com/repos/dealii/dealii/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dealii/dealii/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dealii/dealii/git/refs{/sha}","trees_url":"https://api.github.com/repos/dealii/dealii/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dealii/dealii/statuses/{sha}","languages_url":"https://api.github.com/repos/dealii/dealii/languages","stargazers_url":"https://api.github.com/repos/dealii/dealii/stargazers","contributors_url":"https://api.github.com/repos/dealii/dealii/contributors","subscribers_url":"https://api.github.com/repos/dealii/dealii/subscribers","subscription_url":"https://api.github.com/repos/dealii/dealii/subscription","commits_url":"https://api.github.com/repos/dealii/dealii/commits{/sha}","git_commits_url":"https://api.github.com/repos/dealii/dealii/git/commits{/sha}","comments_url":"https://api.github.com/repos/dealii/dealii/comments{/number}","issue_comment_url":"https://api.github.com/repos/dealii/dealii/issues/comments{/number}","contents_url":"https://api.github.com/repos/dealii/dealii/contents/{+path}","compare_url":"https://api.github.com/repos/dealii/dealii/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dealii/dealii/merges","archive_url":"https://api.github.com/repos/dealii/dealii/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dealii/dealii/downloads","issues_url":"https://api.github.com/repos/dealii/dealii/issues{/number}","pulls_url":"https://api.github.com/repos/dealii/dealii/pulls{/number}","milestones_url":"https://api.github.com/repos/dealii/dealii/milestones{/number}","notifications_url":"https://api.github.com/repos/dealii/dealii/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dealii/dealii/labels{/name}","releases_url":"https://api.github.com/repos/dealii/dealii/releases{/id}","created_at":"2014-07-17T14:00:26Z","updated_at":"2015-09-09T05:46:25Z","pushed_at":"2015-09-14T19:53:30Z","git_url":"git://github.com/dealii/dealii.git","ssh_url":"git@github.com:dealii/dealii.git","clone_url":"https://github.com/dealii/dealii.git","svn_url":"https://github.com/dealii/dealii","homepage":"http://www.dealii.org/","size":160259,"stargazers_count":83,"watchers_count":83,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":116,"mirror_url":null,"open_issues_count":123,"forks":116,"open_issues":123,"watchers":83,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dealii/dealii/pulls/1421"},"html":{"href":"https://github.com/dealii/dealii/pull/1421"},"issue":{"href":"https://api.github.com/repos/dealii/dealii/issues/1421"},"comments":{"href":"https://api.github.com/repos/dealii/dealii/issues/1421/comments"},"review_comments":{"href":"https://api.github.com/repos/dealii/dealii/pulls/1421/comments"},"review_comment":{"href":"https://api.github.com/repos/dealii/dealii/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dealii/dealii/pulls/1421/commits"},"statuses":{"href":"https://api.github.com/repos/dealii/dealii/statuses/5832a7d3f0b81b488c943cf89824b130d25721d6"}}}}