{"action":"created","comment":{"url":"https://api.github.com/repos/geodynamics/aspect/pulls/comments/30954806","id":30954806,"diff_hunk":"@@ -0,0 +1,177 @@\n+/*\n+  Copyright (C) 2011 - 2015 by the authors of the ASPECT code.\n+\n+  This file is part of ASPECT.\n+\n+  ASPECT is free software; you can redistribute it and/or modify\n+  it under the terms of the GNU General Public License as published by\n+  the Free Software Foundation; either version 2, or (at your option)\n+  any later version.\n+\n+  ASPECT is distributed in the hope that it will be useful,\n+  but WITHOUT ANY WARRANTY; without even the implied warranty of\n+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+  GNU General Public License for more details.\n+\n+  You should have received a copy of the GNU General Public License\n+  along with ASPECT; see the file doc/COPYING.  If not see\n+  <http://www.gnu.org/licenses/>.\n+*/\n+\n+\n+\n+#include <aspect/postprocess/heating_statistics.h>\n+#include <aspect/simulator_access.h>\n+\n+#include <deal.II/base/quadrature_lib.h>\n+#include <deal.II/fe/fe_values.h>\n+\n+#include <boost/archive/text_oarchive.hpp>\n+#include <boost/archive/text_iarchive.hpp>\n+\n+\n+namespace aspect\n+{\n+  namespace Postprocess\n+  {\n+    template <int dim>\n+    std::pair<std::string,std::string>\n+    HeatingStatistics<dim>::execute (TableHandler &statistics)\n+    {\n+      // create a quadrature formula based on the temperature element alone.\n+      const QGauss<dim> quadrature_formula (this->get_fe().base_element(this->introspection().base_elements.temperature).degree+1);\n+      const unsigned int n_q_points = quadrature_formula.size();\n+\n+      FEValues<dim> fe_values (this->get_mapping(),\n+                               this->get_fe(),\n+                               quadrature_formula,\n+                               update_values   |\n+                               update_gradients |\n+                               update_quadrature_points |\n+                               update_JxW_values);\n+\n+      typename MaterialModel::Interface<dim>::MaterialModelInputs in(fe_values.n_quadrature_points, this->n_compositional_fields());\n+      typename MaterialModel::Interface<dim>::MaterialModelOutputs out(fe_values.n_quadrature_points, this->n_compositional_fields());\n+\n+      in.strain_rate.resize(0); // we do not need the viscosity\n+      std::vector<std::vector<double> > composition_values (this->n_compositional_fields(),std::vector<double> (quadrature_formula.size()));\n+\n+      std::list<std_cxx11::shared_ptr<HeatingModel::Interface<dim> > > heating_model_objects = this->get_heating_model_manager().get_heating_models();\n+      const std::vector<std::string> heating_model_names = this->get_heating_model_manager().get_active_heating_model_names();\n+\n+      HeatingModel::HeatingModelOutputs heating_model_outputs(n_q_points, this->n_compositional_fields());\n+\n+      std::ostringstream output;\n+      output.precision(4);\n+\n+      double average_heating_integral = 0.0;\n+      double total_heating_integral = 0.0;\n+\n+      unsigned int index = 0;\n+      for (typename std::list<std_cxx11::shared_ptr<HeatingModel::Interface<dim> > >::const_iterator\n+           heating_model = heating_model_objects.begin();\n+           heating_model != heating_model_objects.end(); ++heating_model, ++index)\n+        {\n+          typename DoFHandler<dim>::active_cell_iterator\n+          cell = this->get_dof_handler().begin_active(),\n+          endc = this->get_dof_handler().end();\n+\n+          double local_heating_integrals = 0;\n+          double local_mass = 0;\n+\n+          // compute the integral quantities by quadrature\n+          for (; cell!=endc; ++cell)\n+            if (cell->is_locally_owned())\n+              {\n+                fe_values.reinit (cell);\n+                fe_values[this->introspection().extractors.temperature]\n+                .get_function_values (this->get_solution(),\n+                                      in.temperature);\n+                fe_values[this->introspection().extractors.pressure]\n+                .get_function_values (this->get_solution(),\n+                                      in.pressure);\n+                fe_values[this->introspection().extractors.velocities]\n+                .get_function_values (this->get_solution(),\n+                                      in.velocity);\n+                fe_values[this->introspection().extractors.pressure]\n+                .get_function_gradients (this->get_solution(),\n+                                         in.pressure_gradient);\n+                for (unsigned int c=0; c<this->n_compositional_fields(); ++c)\n+                  fe_values[this->introspection().extractors.compositional_fields[c]]\n+                  .get_function_values(this->get_solution(),\n+                                       composition_values[c]);\n+                for (unsigned int i=0; i<fe_values.n_quadrature_points; ++i)\n+                  {\n+                    for (unsigned int c=0; c<this->n_compositional_fields(); ++c)\n+                      in.composition[i][c] = composition_values[c][i];\n+                  }\n+\n+                in.position = fe_values.get_quadrature_points();\n+\n+                this->get_material_model().evaluate(in, out);\n+                (*heating_model)->evaluate(in, out, heating_model_outputs);\n+\n+                for (unsigned int q=0; q<n_q_points; ++q)\n+                  {\n+                    local_heating_integrals += heating_model_outputs.heating_source_terms[q]\n+                                                        * out.densities[q] * fe_values.JxW(q);\n+\n+                    local_mass += out.densities[q] * fe_values.JxW(q);\n+                  }\n+              }\n+\n+          // compute the sum over all processors\n+          std::vector<double> local_value;\n+          std::vector<double> global_value;\n+          local_value.push_back(local_heating_integrals);\n+          local_value.push_back(local_mass);","path":"source/postprocess/heating_statistics.cc","position":127,"original_position":127,"commit_id":"e2e5ed378dab221c58c29d80472343c30c3cb74c","original_commit_id":"e2e5ed378dab221c58c29d80472343c30c3cb74c","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":"Since you use an array of exactly two values, can't you just use\r\n```\r\n  const double local_values[2] = { local_heating_integrals, local_mass };\r\n  double global_values[2];\r\n```\r\n?","created_at":"2015-05-24T19:01:42Z","updated_at":"2015-05-24T19:01:42Z","html_url":"https://github.com/geodynamics/aspect/pull/416#discussion_r30954806","pull_request_url":"https://api.github.com/repos/geodynamics/aspect/pulls/416","_links":{"self":{"href":"https://api.github.com/repos/geodynamics/aspect/pulls/comments/30954806"},"html":{"href":"https://github.com/geodynamics/aspect/pull/416#discussion_r30954806"},"pull_request":{"href":"https://api.github.com/repos/geodynamics/aspect/pulls/416"}}},"pull_request":{"url":"https://api.github.com/repos/geodynamics/aspect/pulls/416","id":36096073,"html_url":"https://github.com/geodynamics/aspect/pull/416","diff_url":"https://github.com/geodynamics/aspect/pull/416.diff","patch_url":"https://github.com/geodynamics/aspect/pull/416.patch","issue_url":"https://api.github.com/repos/geodynamics/aspect/issues/416","number":416,"state":"open","locked":false,"title":"[WIP] New heating plugin structure","user":{"login":"jdannberg","id":7517347,"avatar_url":"https://avatars.githubusercontent.com/u/7517347?v=3","gravatar_id":"","url":"https://api.github.com/users/jdannberg","html_url":"https://github.com/jdannberg","followers_url":"https://api.github.com/users/jdannberg/followers","following_url":"https://api.github.com/users/jdannberg/following{/other_user}","gists_url":"https://api.github.com/users/jdannberg/gists{/gist_id}","starred_url":"https://api.github.com/users/jdannberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdannberg/subscriptions","organizations_url":"https://api.github.com/users/jdannberg/orgs","repos_url":"https://api.github.com/users/jdannberg/repos","events_url":"https://api.github.com/users/jdannberg/events{/privacy}","received_events_url":"https://api.github.com/users/jdannberg/received_events","type":"User","site_admin":false},"body":"Do not merge! This is mainly to see which of the tests fail. ","created_at":"2015-05-24T00:30:50Z","updated_at":"2015-05-24T19:01:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/geodynamics/aspect/pulls/416/commits","review_comments_url":"https://api.github.com/repos/geodynamics/aspect/pulls/416/comments","review_comment_url":"https://api.github.com/repos/geodynamics/aspect/pulls/comments{/number}","comments_url":"https://api.github.com/repos/geodynamics/aspect/issues/416/comments","statuses_url":"https://api.github.com/repos/geodynamics/aspect/statuses/e2e5ed378dab221c58c29d80472343c30c3cb74c","head":{"label":"jdannberg:new_heating_plugin_structure","ref":"new_heating_plugin_structure","sha":"e2e5ed378dab221c58c29d80472343c30c3cb74c","user":{"login":"jdannberg","id":7517347,"avatar_url":"https://avatars.githubusercontent.com/u/7517347?v=3","gravatar_id":"","url":"https://api.github.com/users/jdannberg","html_url":"https://github.com/jdannberg","followers_url":"https://api.github.com/users/jdannberg/followers","following_url":"https://api.github.com/users/jdannberg/following{/other_user}","gists_url":"https://api.github.com/users/jdannberg/gists{/gist_id}","starred_url":"https://api.github.com/users/jdannberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdannberg/subscriptions","organizations_url":"https://api.github.com/users/jdannberg/orgs","repos_url":"https://api.github.com/users/jdannberg/repos","events_url":"https://api.github.com/users/jdannberg/events{/privacy}","received_events_url":"https://api.github.com/users/jdannberg/received_events","type":"User","site_admin":false},"repo":{"id":19785028,"name":"aspect","full_name":"jdannberg/aspect","owner":{"login":"jdannberg","id":7517347,"avatar_url":"https://avatars.githubusercontent.com/u/7517347?v=3","gravatar_id":"","url":"https://api.github.com/users/jdannberg","html_url":"https://github.com/jdannberg","followers_url":"https://api.github.com/users/jdannberg/followers","following_url":"https://api.github.com/users/jdannberg/following{/other_user}","gists_url":"https://api.github.com/users/jdannberg/gists{/gist_id}","starred_url":"https://api.github.com/users/jdannberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdannberg/subscriptions","organizations_url":"https://api.github.com/users/jdannberg/orgs","repos_url":"https://api.github.com/users/jdannberg/repos","events_url":"https://api.github.com/users/jdannberg/events{/privacy}","received_events_url":"https://api.github.com/users/jdannberg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jdannberg/aspect","description":"Finite element parallel code to simulate problems in thermal convection in both 2D and 3D models.","fork":true,"url":"https://api.github.com/repos/jdannberg/aspect","forks_url":"https://api.github.com/repos/jdannberg/aspect/forks","keys_url":"https://api.github.com/repos/jdannberg/aspect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jdannberg/aspect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jdannberg/aspect/teams","hooks_url":"https://api.github.com/repos/jdannberg/aspect/hooks","issue_events_url":"https://api.github.com/repos/jdannberg/aspect/issues/events{/number}","events_url":"https://api.github.com/repos/jdannberg/aspect/events","assignees_url":"https://api.github.com/repos/jdannberg/aspect/assignees{/user}","branches_url":"https://api.github.com/repos/jdannberg/aspect/branches{/branch}","tags_url":"https://api.github.com/repos/jdannberg/aspect/tags","blobs_url":"https://api.github.com/repos/jdannberg/aspect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jdannberg/aspect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jdannberg/aspect/git/refs{/sha}","trees_url":"https://api.github.com/repos/jdannberg/aspect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jdannberg/aspect/statuses/{sha}","languages_url":"https://api.github.com/repos/jdannberg/aspect/languages","stargazers_url":"https://api.github.com/repos/jdannberg/aspect/stargazers","contributors_url":"https://api.github.com/repos/jdannberg/aspect/contributors","subscribers_url":"https://api.github.com/repos/jdannberg/aspect/subscribers","subscription_url":"https://api.github.com/repos/jdannberg/aspect/subscription","commits_url":"https://api.github.com/repos/jdannberg/aspect/commits{/sha}","git_commits_url":"https://api.github.com/repos/jdannberg/aspect/git/commits{/sha}","comments_url":"https://api.github.com/repos/jdannberg/aspect/comments{/number}","issue_comment_url":"https://api.github.com/repos/jdannberg/aspect/issues/comments{/number}","contents_url":"https://api.github.com/repos/jdannberg/aspect/contents/{+path}","compare_url":"https://api.github.com/repos/jdannberg/aspect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jdannberg/aspect/merges","archive_url":"https://api.github.com/repos/jdannberg/aspect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jdannberg/aspect/downloads","issues_url":"https://api.github.com/repos/jdannberg/aspect/issues{/number}","pulls_url":"https://api.github.com/repos/jdannberg/aspect/pulls{/number}","milestones_url":"https://api.github.com/repos/jdannberg/aspect/milestones{/number}","notifications_url":"https://api.github.com/repos/jdannberg/aspect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jdannberg/aspect/labels{/name}","releases_url":"https://api.github.com/repos/jdannberg/aspect/releases{/id}","created_at":"2014-05-14T15:28:24Z","updated_at":"2014-08-06T13:34:18Z","pushed_at":"2015-05-24T17:19:17Z","git_url":"git://github.com/jdannberg/aspect.git","ssh_url":"git@github.com:jdannberg/aspect.git","clone_url":"https://github.com/jdannberg/aspect.git","svn_url":"https://github.com/jdannberg/aspect","homepage":null,"size":101447,"stargazers_count":0,"watchers_count":0,"language":"Gnuplot","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":"geodynamics:master","ref":"master","sha":"81eb226dc355974193b00e3dc2a7f937c7532764","user":{"login":"geodynamics","id":4052461,"avatar_url":"https://avatars.githubusercontent.com/u/4052461?v=3","gravatar_id":"","url":"https://api.github.com/users/geodynamics","html_url":"https://github.com/geodynamics","followers_url":"https://api.github.com/users/geodynamics/followers","following_url":"https://api.github.com/users/geodynamics/following{/other_user}","gists_url":"https://api.github.com/users/geodynamics/gists{/gist_id}","starred_url":"https://api.github.com/users/geodynamics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geodynamics/subscriptions","organizations_url":"https://api.github.com/users/geodynamics/orgs","repos_url":"https://api.github.com/users/geodynamics/repos","events_url":"https://api.github.com/users/geodynamics/events{/privacy}","received_events_url":"https://api.github.com/users/geodynamics/received_events","type":"Organization","site_admin":false},"repo":{"id":19502452,"name":"aspect","full_name":"geodynamics/aspect","owner":{"login":"geodynamics","id":4052461,"avatar_url":"https://avatars.githubusercontent.com/u/4052461?v=3","gravatar_id":"","url":"https://api.github.com/users/geodynamics","html_url":"https://github.com/geodynamics","followers_url":"https://api.github.com/users/geodynamics/followers","following_url":"https://api.github.com/users/geodynamics/following{/other_user}","gists_url":"https://api.github.com/users/geodynamics/gists{/gist_id}","starred_url":"https://api.github.com/users/geodynamics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geodynamics/subscriptions","organizations_url":"https://api.github.com/users/geodynamics/orgs","repos_url":"https://api.github.com/users/geodynamics/repos","events_url":"https://api.github.com/users/geodynamics/events{/privacy}","received_events_url":"https://api.github.com/users/geodynamics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/geodynamics/aspect","description":"A parallel, extendible finite element code to simulate thermal convection in both 2D and 3D models.","fork":false,"url":"https://api.github.com/repos/geodynamics/aspect","forks_url":"https://api.github.com/repos/geodynamics/aspect/forks","keys_url":"https://api.github.com/repos/geodynamics/aspect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/geodynamics/aspect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/geodynamics/aspect/teams","hooks_url":"https://api.github.com/repos/geodynamics/aspect/hooks","issue_events_url":"https://api.github.com/repos/geodynamics/aspect/issues/events{/number}","events_url":"https://api.github.com/repos/geodynamics/aspect/events","assignees_url":"https://api.github.com/repos/geodynamics/aspect/assignees{/user}","branches_url":"https://api.github.com/repos/geodynamics/aspect/branches{/branch}","tags_url":"https://api.github.com/repos/geodynamics/aspect/tags","blobs_url":"https://api.github.com/repos/geodynamics/aspect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/geodynamics/aspect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/geodynamics/aspect/git/refs{/sha}","trees_url":"https://api.github.com/repos/geodynamics/aspect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/geodynamics/aspect/statuses/{sha}","languages_url":"https://api.github.com/repos/geodynamics/aspect/languages","stargazers_url":"https://api.github.com/repos/geodynamics/aspect/stargazers","contributors_url":"https://api.github.com/repos/geodynamics/aspect/contributors","subscribers_url":"https://api.github.com/repos/geodynamics/aspect/subscribers","subscription_url":"https://api.github.com/repos/geodynamics/aspect/subscription","commits_url":"https://api.github.com/repos/geodynamics/aspect/commits{/sha}","git_commits_url":"https://api.github.com/repos/geodynamics/aspect/git/commits{/sha}","comments_url":"https://api.github.com/repos/geodynamics/aspect/comments{/number}","issue_comment_url":"https://api.github.com/repos/geodynamics/aspect/issues/comments{/number}","contents_url":"https://api.github.com/repos/geodynamics/aspect/contents/{+path}","compare_url":"https://api.github.com/repos/geodynamics/aspect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/geodynamics/aspect/merges","archive_url":"https://api.github.com/repos/geodynamics/aspect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/geodynamics/aspect/downloads","issues_url":"https://api.github.com/repos/geodynamics/aspect/issues{/number}","pulls_url":"https://api.github.com/repos/geodynamics/aspect/pulls{/number}","milestones_url":"https://api.github.com/repos/geodynamics/aspect/milestones{/number}","notifications_url":"https://api.github.com/repos/geodynamics/aspect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/geodynamics/aspect/labels{/name}","releases_url":"https://api.github.com/repos/geodynamics/aspect/releases{/id}","created_at":"2014-05-06T16:47:18Z","updated_at":"2015-05-08T16:13:02Z","pushed_at":"2015-05-24T18:38:33Z","git_url":"git://github.com/geodynamics/aspect.git","ssh_url":"git@github.com:geodynamics/aspect.git","clone_url":"https://github.com/geodynamics/aspect.git","svn_url":"https://github.com/geodynamics/aspect","homepage":"http://aspect.dealii.org/","size":122783,"stargazers_count":10,"watchers_count":10,"language":"Gnuplot","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":55,"forks":33,"open_issues":55,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/geodynamics/aspect/pulls/416"},"html":{"href":"https://github.com/geodynamics/aspect/pull/416"},"issue":{"href":"https://api.github.com/repos/geodynamics/aspect/issues/416"},"comments":{"href":"https://api.github.com/repos/geodynamics/aspect/issues/416/comments"},"review_comments":{"href":"https://api.github.com/repos/geodynamics/aspect/pulls/416/comments"},"review_comment":{"href":"https://api.github.com/repos/geodynamics/aspect/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/geodynamics/aspect/pulls/416/commits"},"statuses":{"href":"https://api.github.com/repos/geodynamics/aspect/statuses/e2e5ed378dab221c58c29d80472343c30c3cb74c"}}}}