]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Replace one problematic part by a better solution.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 16 Apr 2004 22:30:20 +0000 (22:30 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 16 Apr 2004 22:30:20 +0000 (22:30 +0000)
git-svn-id: https://svn.dealii.org/trunk@9034 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/examples/step-17/step-17.cc

index aac7365654061784e1f0730ac75076c13ad7e726..61b632ca90a3908499292f38c864a80df2883797 100644 (file)
@@ -809,45 +809,19 @@ unsigned int ElasticProblem<dim>::solve ()
                                    // nodes:
   hanging_node_constraints.distribute (localized_solution);
 
-                                   // The next step is a little more
-                                   // convoluted: we need to get the result
-                                   // back into the global, distributed
-                                   // vector. The problematic part is that on
-                                   // each process, we can only efficiently
-                                   // write to the elements we own ourselves,
-                                   // despite the fact that all processors
-                                   // have just computed the complete solution
-                                   // vector locally. If we write to elements
-                                   // that we do not own, this may be
-                                   // expensive since they will have to be
-                                   // communicated to the other processors
-                                   // later on. So what we do is to ask the
-                                   // library to which subdomain each degree
-                                   // of freedom belongs (or, in other words:
-                                   // which process has them stored locally,
-                                   // since we identify subdomains with
-                                   // processes), and only write to these. For
-                                   // this, let us first get the subdomain for
-                                   // each DoF:
-  std::vector<unsigned int> subdomain_association (dof_handler.n_dofs());
-  DoFTools::get_subdomain_association (dof_handler,
-                                       subdomain_association);
-
-                                   // Then loop over all degrees of freedom
-                                   // and transfer the newly computed value
-                                   // for a constrained degree of freedom into
-                                   // the global solution if a) this is really
-                                   // a constrained DoF, all other vector
-                                   // entries should not have been changed
-                                   // anyway, and b) we are the owner of this
-                                   // degree of freedom, i.e. the subdomain
-                                   // the DoF belongs to equals the present
-                                   // process's number.
-  for (unsigned int i=0; i<localized_solution.size(); ++i)
-    if (hanging_node_constraints.is_constrained (i)
-        &&
-        (subdomain_association[i] == this_mpi_process))
-      solution(i) = localized_solution(i);
+                                   // Then transfer everything back
+                                   // into the global vector. The
+                                   // following operation copies those
+                                   // elements of the localized
+                                   // solution that we store locally
+                                   // in the distributed solution, and
+                                   // does not touch the other
+                                   // ones. Since we do the same
+                                   // operation on all processors, we
+                                   // end up with a distributed vector
+                                   // that has all the constrained
+                                   // nodes fixed.
+  solution = localized_solution;
 
                                    // After this has happened, flush the PETSc
                                    // buffers. This may or may not be strictly
@@ -1249,7 +1223,7 @@ void ElasticProblem<dim>::run ()
       if (this_mpi_process == 0)
         std::cout << "   Solver converged in " << n_iterations
                   << " iterations." << std::endl;
-
+      
       output_results (cycle);
     }
 }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.