{"action":"created","comment":{"url":"https://api.github.com/repos/geodynamics/aspect/pulls/comments/152389626","pull_request_review_id":78241101,"id":152389626,"diff_hunk":"@@ -0,0 +1,718 @@\n+/*\n+  Copyright (C) 2017 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 LICENSE.  If not see\n+  <http://www.gnu.org/licenses/>.\n+*/\n+\n+#ifndef _aspect_simulator_assemblers_interface_h\n+#define _aspect_simulator_assemblers_interface_h\n+\n+#include <aspect/global.h>\n+#include <aspect/heating_model/interface.h>\n+#include <aspect/material_model/interface.h>\n+\n+#include <deal.II/fe/fe_values.h>\n+\n+namespace aspect\n+{\n+  using namespace dealii;\n+\n+  template <int dim>\n+  class Simulator;\n+\n+  struct AdvectionField;\n+\n+  /**\n+   * A namespace that is used for internal scratch objects, i.e. objects that define\n+   * the inputs and outputs for the individual assembler objects. The different classes\n+   * are provided for the different systems of equations, and the inputs are filled\n+   * by the <code>local_assemble_...</code> functions in <code>assembly.cc</code>,\n+   * before being handed over to the assemblers.\n+   */\n+  namespace internal\n+  {\n+    namespace Assembly\n+    {\n+      namespace Scratch\n+      {\n+        /**\n+         * Scratch objects are used to store information about a cell that is\n+         * necessary for assembling matrix and right hand side terms for this\n+         * cell. The ScratchBase class acts as a empty base class for\n+         * individual scratch objects for the different equations.\n+         */\n+        template <int dim>\n+        struct ScratchBase\n+        {\n+          ScratchBase()\n+            :\n+            cell(),\n+            face_number(numbers::invalid_unsigned_int)\n+          {};\n+\n+          ScratchBase(const ScratchBase &scratch)\n+            :\n+            cell(scratch.cell),\n+            face_number(scratch.face_number)\n+          {};\n+\n+          virtual ~ScratchBase () {};\n+\n+          /**\n+           * Cell object on which we currently operate.\n+           */\n+          typename DoFHandler<dim>::active_cell_iterator cell;\n+\n+          /**\n+           * The number of the face object with respect to the current\n+           * cell on which we operate. If we currently\n+           * operate on a cell, this member is set to\n+           * numbers::invalid_unsigned_int.\n+           */\n+          unsigned face_number;\n+        };\n+\n+        /**\n+         * A scratch object to store all necessary information to assemble\n+         * the Stokes preconditioner terms.\n+         */\n+        template <int dim>\n+        struct StokesPreconditioner: public ScratchBase<dim>\n+        {\n+          StokesPreconditioner (const FiniteElement<dim> &finite_element,\n+                                const Quadrature<dim>    &quadrature,\n+                                const Mapping<dim>       &mapping,\n+                                const UpdateFlags         update_flags,\n+                                const unsigned int        n_compositional_fields,\n+                                const unsigned int        stokes_dofs_per_cell,\n+                                const bool                add_compaction_pressure,\n+                                const bool                rebuild_stokes_matrix);\n+          StokesPreconditioner (const StokesPreconditioner &scratch);\n+\n+          virtual ~StokesPreconditioner ();\n+\n+          FEValues<dim> finite_element_values;\n+\n+          std::vector<types::global_dof_index> local_dof_indices;\n+          std::vector<unsigned int>            dof_component_indices;\n+          std::vector<SymmetricTensor<2,dim> > grads_phi_u;\n+          std::vector<double>                  div_phi_u;\n+          std::vector<double>                  phi_p;\n+          std::vector<double>                  phi_p_c;\n+          std::vector<Tensor<1,dim> >          grad_phi_p;\n+\n+          /**\n+           * Material model inputs and outputs computed at the current\n+           * linearization point.\n+           */\n+          MaterialModel::MaterialModelInputs<dim> material_model_inputs;\n+          MaterialModel::MaterialModelOutputs<dim> material_model_outputs;\n+\n+          /**\n+           * Whether the Stokes matrix should be rebuild during this\n+           * assembly. If the matrix does not change, assembling the right\n+           * hand side is sufficient.\n+           */\n+          const bool rebuild_stokes_matrix;\n+        };\n+\n+        /**\n+         * A scratch object to store all necessary information to assemble\n+         * the terms in the Stokes equations.\n+         * We derive the StokesSystem scratch class from the\n+         * StokesPreconditioner class, because all the objects that\n+         * are necessary for the assembly of the preconditioner are also\n+         * needed for the actual system matrix and right hand side, plus some\n+         * extra data that we need for the time stepping and traction boundaries\n+         * on the right hand side.\n+         */\n+        template <int dim>\n+        struct StokesSystem : public StokesPreconditioner<dim>\n+        {\n+          StokesSystem (const FiniteElement<dim> &finite_element,\n+                        const Mapping<dim>       &mapping,\n+                        const Quadrature<dim>    &quadrature,\n+                        const Quadrature<dim-1>  &face_quadrature,\n+                        const UpdateFlags         update_flags,\n+                        const UpdateFlags         face_update_flags,\n+                        const unsigned int        n_compositional_fields,\n+                        const unsigned int        stokes_dofs_per_cell,\n+                        const bool                add_compaction_pressure,\n+                        const bool                use_reference_profile,\n+                        const bool                rebuild_stokes_matrix,\n+                        const bool                rebuild_stokes_newton_matrix);\n+\n+          StokesSystem (const StokesSystem<dim> &data);\n+\n+          FEFaceValues<dim> face_finite_element_values;\n+\n+          std::vector<Tensor<1,dim> >          phi_u;\n+          std::vector<Tensor<1,dim> >          velocity_values;\n+          std::vector<double>                  velocity_divergence;\n+\n+          /**\n+           * Material model inputs and outputs computed at the current\n+           * linearization point.\n+           *\n+           * In contrast to the variables above, the following two\n+           * variables are used in the assembly at quadrature points\n+           * on faces, not on cells.\n+           */\n+          MaterialModel::MaterialModelInputs<dim> face_material_model_inputs;\n+          MaterialModel::MaterialModelOutputs<dim> face_material_model_outputs;\n+\n+          /**\n+           * In some approximations of the Stokes equations the density used\n+           * for the mass conservation (/continuity) equation is some form\n+           * of reference density, while the density used for calculating\n+           * the buoyancy force is the full density. In case such a formulation\n+           * is used the reference density (and its derivative in depth\n+           * direction) is queried from the adiabatic conditions plugin\n+           * and is stored in these variables.\n+           */\n+          std::vector<double> reference_densities;\n+          std::vector<double> reference_densities_depth_derivative;\n+\n+          /**\n+           * Whether the Newton solver Stokes matrix should be rebuild during\n+           * this assembly. If the matrix does not change, assembling the right\n+           * hand side is sufficient.\n+           */\n+          const bool rebuild_newton_stokes_matrix;\n+        };\n+\n+        /**\n+         * A scratch object to store all necessary information to assemble\n+         * the terms in the advection equations.\n+         */\n+        template <int dim>\n+        struct AdvectionSystem: public ScratchBase<dim>\n+        {\n+          AdvectionSystem (const FiniteElement<dim> &finite_element,\n+                           const FiniteElement<dim> &advection_element,\n+                           const Mapping<dim>       &mapping,\n+                           const Quadrature<dim>    &quadrature,\n+                           const Quadrature<dim-1>  &face_quadrature,\n+                           const UpdateFlags         update_flags,\n+                           const UpdateFlags         face_update_flags,\n+                           const unsigned int        n_compositional_fields,\n+                           const typename Simulator<dim>::AdvectionField     &advection_field);\n+          AdvectionSystem (const AdvectionSystem &data);\n+\n+          FEValues<dim> finite_element_values;\n+\n+          std_cxx11::shared_ptr<FEFaceValues<dim> >    face_finite_element_values;\n+          std_cxx11::shared_ptr<FEFaceValues<dim> >    neighbor_face_finite_element_values;\n+          std_cxx11::shared_ptr<FESubfaceValues<dim> > subface_finite_element_values;\n+\n+          std::vector<types::global_dof_index>   local_dof_indices;\n+\n+          /**\n+           * Variables describing the values and gradients of the\n+           * shape functions at the quadrature points, as they are\n+           * used in the advection assembly function. note that the sizes\n+           * of these arrays are equal to the number of shape functions\n+           * corresponding to the currently advected field (and not all of the\n+           * existing fields), and that they are also correspondingly indexed.\n+           */\n+          std::vector<double>         phi_field;\n+          std::vector<Tensor<1,dim> > grad_phi_field;\n+          std::vector<double>         face_phi_field;\n+          std::vector<Tensor<1,dim> > face_grad_phi_field;\n+          std::vector<double>         neighbor_face_phi_field;\n+          std::vector<Tensor<1,dim> > neighbor_face_grad_phi_field;\n+\n+          std::vector<Tensor<1,dim> > old_velocity_values;\n+          std::vector<Tensor<1,dim> > old_old_velocity_values;\n+\n+          std::vector<double>         old_pressure;\n+          std::vector<double>         old_old_pressure;\n+          std::vector<Tensor<1,dim> > old_pressure_gradients;\n+          std::vector<Tensor<1,dim> > old_old_pressure_gradients;\n+\n+          std::vector<SymmetricTensor<2,dim> > old_strain_rates;\n+          std::vector<SymmetricTensor<2,dim> > old_old_strain_rates;\n+\n+          std::vector<double>         old_temperature_values;\n+          std::vector<double>         old_old_temperature_values;\n+\n+          std::vector<double>         old_field_values;\n+          std::vector<double>         old_old_field_values;\n+          std::vector<Tensor<1,dim> > old_field_grads;\n+          std::vector<Tensor<1,dim> > old_old_field_grads;\n+          std::vector<double>         old_field_laplacians;\n+          std::vector<double>         old_old_field_laplacians;\n+\n+          std::vector<std::vector<double> > old_composition_values;\n+          std::vector<std::vector<double> > old_old_composition_values;\n+\n+          std::vector<double>         current_temperature_values;\n+          std::vector<Tensor<1,dim> > current_velocity_values;\n+          std::vector<Tensor<1,dim> > face_current_velocity_values;\n+          std::vector<Tensor<1,dim> > mesh_velocity_values;\n+          std::vector<Tensor<1,dim> > face_mesh_velocity_values;\n+\n+          std::vector<SymmetricTensor<2,dim> > current_strain_rates;\n+          std::vector<std::vector<double> > current_composition_values;\n+          std::vector<double>         current_velocity_divergences;\n+\n+          /**\n+           * Material model inputs and outputs computed at the current\n+           * linearization point.\n+           */\n+          MaterialModel::MaterialModelInputs<dim> material_model_inputs;\n+          MaterialModel::MaterialModelOutputs<dim> material_model_outputs;\n+\n+          MaterialModel::MaterialModelInputs<dim> face_material_model_inputs;\n+          MaterialModel::MaterialModelOutputs<dim> face_material_model_outputs;\n+\n+          MaterialModel::MaterialModelInputs<dim> neighbor_face_material_model_inputs;\n+          MaterialModel::MaterialModelOutputs<dim> neighbor_face_material_model_outputs;\n+\n+          /**\n+           * Heating model outputs computed at the quadrature points of the\n+           * current cell at the time of the current linearization point.\n+           * As explained in the class documentation of\n+           * HeatingModel::HeatingModelOutputs each term contains the sum of all\n+           * enabled heating mechanism contributions.\n+           */\n+          HeatingModel::HeatingModelOutputs heating_model_outputs;\n+          HeatingModel::HeatingModelOutputs face_heating_model_outputs;\n+          HeatingModel::HeatingModelOutputs neighbor_face_heating_model_outputs;\n+\n+          /**\n+           * This pointer contains a struct that can be used to identify the\n+           * advection field that is currently assembled. It can be used to\n+           * determine between temperature and the available compositional\n+           * fields. See the documentation of the AdvectionField class for\n+           * more details.\n+           */\n+          const typename Simulator<dim>::AdvectionField *advection_field;\n+\n+          /**\n+           * The amount of entropy viscosity that should be applied to the\n+           * current cell to stabilize the solution of the advection system.\n+           */\n+          double artificial_viscosity;\n+        };\n+      }\n+\n+      /**\n+       * The CopyData arrays are similar to the Scratch arrays except they are\n+       * meant as containers for the output of assembler objects. They provide a\n+       * constructor and some data objects for local matrix, local vectors and\n+       * the relation between local and global degrees of freedom (a.k.a.\n+       * <code>local_dof_indices</code>). After all assemblers are finished\n+       * the objects contain the local contributions of a particular cell to\n+       * the global matrix and right hand side. This copy data object is then\n+       * handed over to one of the <code>copy_local_to_global...</code>\n+       * functions in assembly.cc that copy their content to the global matrix\n+       * and right hand side vector.\n+       */\n+      namespace CopyData\n+      {\n+        /**\n+         * The base class is empty and only allows us to hand over pointers\n+         * or references of a generic type and later cast them to their actual\n+         * derived class.\n+         */\n+        template <int dim>\n+        struct CopyDataBase\n+        {\n+          CopyDataBase() {};\n+\n+          virtual ~CopyDataBase () {};\n+        };\n+\n+        /**\n+         * The Stokes preconditioner object only requires the bare minimum of\n+         * copy data objects. Matrix contributions and degrees of freedom this\n+         * cell corresponds to.\n+         */\n+        template <int dim>\n+        struct StokesPreconditioner: public CopyDataBase<dim>\n+        {\n+          StokesPreconditioner (const unsigned int stokes_dofs_per_cell);\n+\n+          StokesPreconditioner (const StokesPreconditioner &data);\n+\n+          virtual ~StokesPreconditioner ();\n+\n+          FullMatrix<double> local_matrix;\n+          std::vector<types::global_dof_index> local_dof_indices;\n+\n+          /**\n+           * Extract the values listed in @p all_dof_indices only if\n+           * it corresponds to the Stokes component and copy it to the variable\n+           * local_dof_indices declared above in the same class as this function\n+          */\n+          void extract_stokes_dof_indices(const std::vector<types::global_dof_index> &all_dof_indices,\n+                                          const Introspection<dim>                   &introspection,\n+                                          const FiniteElement<dim>                   &finite_element);\n+        };\n+\n+        /**\n+         * Similar to the scratch object the Stokes system requires all\n+         * data from the Stokes preconditioner copy data class, plus some\n+         * extras like the right hand side contribution.\n+         */\n+        template <int dim>\n+        struct StokesSystem : public StokesPreconditioner<dim>\n+        {\n+          StokesSystem (const unsigned int        stokes_dofs_per_cell,\n+                        const bool                do_pressure_rhs_compatibility_modification);\n+          StokesSystem (const StokesSystem<dim> &data);\n+\n+          Vector<double> local_rhs;\n+          Vector<double> local_pressure_shape_function_integrals;\n+        };\n+\n+        /**\n+         * Additionally to the Stokes system the Advection system copy data\n+         * object also needs to keep track of contributions across faces\n+         * (mostly for discontinuous elements that contain DG terms).\n+         */\n+        template <int dim>\n+        struct AdvectionSystem: public CopyDataBase<dim>\n+        {\n+          /**\n+           * Constructor.\n+           *\n+           * @param finite_element The element that describes the field for\n+           *    which we are trying to assemble a linear system. <b>Not</b>\n+           *    the global finite element.\n+           * @param field_is_discontinuous If true, the field is a DG element.\n+           */\n+          AdvectionSystem (const FiniteElement<dim> &finite_element,\n+                           const bool                field_is_discontinuous);\n+\n+          /**\n+           * Copy constructor.\n+           */\n+          AdvectionSystem (const AdvectionSystem &data);\n+\n+          /**\n+           * Local contributions to the global matrix\n+           * that correspond only to the variables listed in local_dof_indices\n+           */\n+          FullMatrix<double>          local_matrix;\n+\n+          /** Local contributions to the global matrix from the face terms in the\n+           * discontinuous Galerkin method. The vectors are of length\n+           * GeometryInfo<dim>::max_children_per_face * GeometryInfo<dim>::faces_per_cell\n+           * so as to hold one matrix for each possible face or subface of the cell.\n+           * The discontinuous Galerkin bilinear form contains terms arising from internal\n+           * (to the cell) values and external (to the cell) values.\n+           * _int_ext and ext_int hold the terms arising from the pairing between a cell\n+           * and its neighbor, while _ext_ext is the pairing of the neighbor's dofs with\n+           * themselves. In the continuous Galerkin case, these are unused, and set to size zero.\n+           **/\n+          std::vector<FullMatrix<double> >         local_matrices_int_ext;\n+          std::vector<FullMatrix<double> >         local_matrices_ext_int;\n+          std::vector<FullMatrix<double> >         local_matrices_ext_ext;\n+\n+          /**\n+           * Local contributions to the right hand side\n+           * that correspond only to the variables listed in local_dof_indices\n+           */\n+          Vector<double>              local_rhs;\n+\n+          /** Denotes which face matrices have actually been assembled in the DG field\n+           * assembly. Entries for matrices not used (for example, those corresponding\n+           * to non-existent subfaces; or faces being assembled by the neighboring cell)\n+           * are set to false.\n+           **/\n+          std::vector<bool>               assembled_matrices;\n+\n+          /**\n+           * Indices of those degrees of freedom that actually correspond\n+           * to the temperature or compositional field. since this structure\n+           * is used to represent just contributions to the advection\n+           * systems, there will be no contributions to other parts of the\n+           * system and consequently, we do not need to list here indices\n+           * that correspond to velocity or pressure degrees (or, in fact\n+           * any other variable outside the block we are currently considering)\n+           */\n+          std::vector<types::global_dof_index>   local_dof_indices;\n+\n+          /**\n+           * Indices of the degrees of freedom corresponding to the temperature\n+           * or composition field on all possible neighboring cells. This is used\n+           * in the discontinuous Galerkin method. The outer std::vector has\n+           * length GeometryInfo<dim>::max_children_per_face * GeometryInfo<dim>::faces_per_cell,\n+           * and has size zero if in the continuous Galerkin case.\n+           **/\n+          std::vector<std::vector<types::global_dof_index> >   neighbor_dof_indices;\n+        };\n+      }\n+    }\n+  }\n+\n+  /**\n+   * A namespace for the definition of assemblers for the various terms in the\n+   * linear systems ASPECT solves.\n+   */\n+  namespace Assemblers\n+  {\n+    /**\n+     * A base class for objects that implement assembly\n+     * operations.\n+     *\n+     * The point of this class is primarily so that we can store\n+     * pointers to such objects in a list. The objects are created\n+     * in Simulator::set_assemblers() and destroyed in the destructor of\n+     * the Simulator object. Derived classes of this base class usually\n+     * handle groups of terms in the equations that are\n+     * logically connected (such as all terms in the Stokes equations that\n+     * appear independent on the selected compressibility formulation). This\n+     * way selecting a certain set of assembler objects effectively controls\n+     * which equation is solved.\n+     */\n+    template <int dim>\n+    class Interface\n+    {\n+      public:\n+        virtual ~Interface () {}\n+\n+        /**\n+         * Execute this assembler object. This function performs the primary work\n+         * of an assembler. More precisely, it uses information for the current\n+         * cell that is stored in @p scratch (like the material properties on\n+         * this cell and the position of quadrature points) and computes the\n+         * matrix and right hand side contributions for a set of terms for\n+         * the given cell. These contributions are stored in @p data. Note, that\n+         * the data in @p scratch and @p data is shared between all active\n+         * assemblers so that each assembler should only add contributions to\n+         * @p data, not overwrite entries in the matrix. After all assemblers\n+         * have finished, the final content of @p data is distributed into the\n+         * global matrix and right hand side vector.\n+         */\n+        virtual\n+        void\n+        execute(internal::Assembly::Scratch::ScratchBase<dim> &scratch,\n+                internal::Assembly::CopyData::CopyDataBase<dim> &data) const =0;\n+\n+        /**\n+         * This function gets called if a MaterialModelOutputs is created\n+         * and allows the assembler to attach AdditionalOutputs. The\n+         * function might be called more than once for a\n+         * MaterialModelOutput, so it is recommended to check if\n+         * get_additional_output() returns an instance before adding a new\n+         * one to the additional_outputs vector. By default this function does\n+         * not create additional outputs.\n+         *\n+         * Material models, through functions derived from\n+         * MaterialModel::Interface::evaluate(), put their computed material\n+         * parameters into a structure of type MaterialModel::MaterialModelOutputs.\n+         * By default, material models will compute those parameters that\n+         * correspond to the member variables of that structure. However,\n+         * there are situations where parts of the simulator need additional\n+         * pieces of information; a typical example would be the use of a\n+         * Newton scheme that also requires the computation of <i>derivatives</i>\n+         * of material parameters with respect to pressure, temperature, and\n+         * possibly other variables.\n+         *\n+         * The computation of such additional information is controlled by\n+         * the presence of a collection of pointers in\n+         * MaterialModel::MaterialModelOutputs that point to additional\n+         * objects. Whether or not one needs these additional objects depends\n+         * on what assemblers are selected, or what postprocessing one\n+         * wants to compute. For the purpose of assembly, the current\n+         * function creates the additional objects (such as the one that stores\n+         * derivatives) and adds pointers to them to the collection, based on\n+         * what this assembler class requires. This function is always called\n+         * before the material model is evaluated and execute() is called.\n+         * This ensures the additional material model output is available when\n+         * execute() is called.\n+         */\n+        virtual void create_additional_material_model_outputs(MaterialModel::MaterialModelOutputs<dim> &) const {}\n+\n+        /**\n+         * A required function for objects that implement the assembly of terms\n+         * in an equation that requires the computation of residuals\n+         * (in particular the advection equation in ASPECT).\n+         * Just like the assemblers itself, the residual\n+         * that we use to compute the necessary entropy viscosity depend on the\n+         * equation (i.e. which terms are actually included in the\n+         * equation). Thus different objects compute different residuals (i.e.\n+         * the residual for a melt advection equation looks different from the\n+         * residual for a passive compositional field).\n+         */\n+        virtual\n+        std::vector<double>\n+        compute_residual(internal::Assembly::Scratch::ScratchBase<dim> &) const\n+        {\n+          AssertThrow(false, ExcMessage(\"This function should either be implemented \"\n+                                        \"(if this is an assembler that has to compute a residual, or not be called \"\n+                                        \"(if this is an assembler that has not to compute a residual).\"));","path":"include/aspect/simulator/assemblers/interface.h","position":561,"original_position":561,"commit_id":"f93c011ab906b0e9e008709225fd6a09ea4688cf","original_commit_id":"f93c011ab906b0e9e008709225fd6a09ea4688cf","user":{"login":"tjhei","id":1531285,"avatar_url":"https://avatars0.githubusercontent.com/u/1531285?v=4","gravatar_id":"","url":"https://api.github.com/users/tjhei","html_url":"https://github.com/tjhei","followers_url":"https://api.github.com/users/tjhei/followers","following_url":"https://api.github.com/users/tjhei/following{/other_user}","gists_url":"https://api.github.com/users/tjhei/gists{/gist_id}","starred_url":"https://api.github.com/users/tjhei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjhei/subscriptions","organizations_url":"https://api.github.com/users/tjhei/orgs","repos_url":"https://api.github.com/users/tjhei/repos","events_url":"https://api.github.com/users/tjhei/events{/privacy}","received_events_url":"https://api.github.com/users/tjhei/received_events","type":"User","site_admin":false},"body":"copy&paste error?","created_at":"2017-11-21T20:16:04Z","updated_at":"2017-11-21T20:34:05Z","html_url":"https://github.com/geodynamics/aspect/pull/1785#discussion_r152389626","pull_request_url":"https://api.github.com/repos/geodynamics/aspect/pulls/1785","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/geodynamics/aspect/pulls/comments/152389626"},"html":{"href":"https://github.com/geodynamics/aspect/pull/1785#discussion_r152389626"},"pull_request":{"href":"https://api.github.com/repos/geodynamics/aspect/pulls/1785"}}},"pull_request":{"url":"https://api.github.com/repos/geodynamics/aspect/pulls/1785","id":122736577,"html_url":"https://github.com/geodynamics/aspect/pull/1785","diff_url":"https://github.com/geodynamics/aspect/pull/1785.diff","patch_url":"https://github.com/geodynamics/aspect/pull/1785.patch","issue_url":"https://api.github.com/repos/geodynamics/aspect/issues/1785","number":1785,"state":"open","locked":false,"title":"Unify assembler structure","user":{"login":"gassmoeller","id":7582930,"avatar_url":"https://avatars0.githubusercontent.com/u/7582930?v=4","gravatar_id":"","url":"https://api.github.com/users/gassmoeller","html_url":"https://github.com/gassmoeller","followers_url":"https://api.github.com/users/gassmoeller/followers","following_url":"https://api.github.com/users/gassmoeller/following{/other_user}","gists_url":"https://api.github.com/users/gassmoeller/gists{/gist_id}","starred_url":"https://api.github.com/users/gassmoeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gassmoeller/subscriptions","organizations_url":"https://api.github.com/users/gassmoeller/orgs","repos_url":"https://api.github.com/users/gassmoeller/repos","events_url":"https://api.github.com/users/gassmoeller/events{/privacy}","received_events_url":"https://api.github.com/users/gassmoeller/received_events","type":"User","site_admin":false},"body":"Our current assembler system is somewhat messy, because the structure for how an assembler has to look like is not well defined. Essentially any function can be attached to the available signals, and we do not know which functions are already attached (because we can not check which type each connection has), or which quantities an individual assembler needs to work correctly. This has lead to the extremely confusing logic inside of `set_assemblers`, and to the fact that for every new assembler we need to modify three objects: Connect to the associated signal. Add the parent object to `assembler_objects`. Modify the correct `assembler_properties` object to compute the correct quantities before calling the assembler.\r\nIf instead we had an interface-plugin system as for the other parts of ASPECT, all this would be handled in one object, the individual assembler plugin. It would have a defined function that is called by Simulator (which replaces the signal), and could (optionally) implement another function that specifies which quantities need to be provided (which replaces the properties object). We could still keep the `set_assemblers` signal that allows every part of the code to modify the list of existing assembler plugins with the added benefit that we can then remove specific plugins, instead of wiping them all and starting from scratch, which is our only option right now.\r\nThis is a very early draft on which changes we would need to implement in order to move in such a direction, but I wanted to start a discussion about it first, before spending more time with it. The important bits can be seen in `assembly.h` below. For now I moved the `StokesPreconditioner` assembly out of the `StokesAssembler` class and made it a separate fully-functional assembler plugin. It still connects its `execute` function to the old signal, but we could as well call it via the pointer to the base class stored in `assembler_objects`. The one disadvantage of the new system is that we have less flexibility of providing plugin-specific information into the assembler (see my workaround for `pressure_scaling` below). However, I would argue that we can provide all necessary information in two ways: Either add it to the `scratch` object that is already designed to store all necessary information or provide it via the `SimulatorAccess` class.\r\n\r\nI would like to ask for opinion from @tjhei and @bangerth (and all other interested parties). I think the new way would keep the code cleaner and will be easier to understand. Everything else (performance, flexibility) should be similar to the current approach with signals.","created_at":"2017-05-26T23:52:38Z","updated_at":"2017-11-21T20:34:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3d085ac06a44840086a8742ca87c5be3ca505492","assignee":{"login":"jdannberg","id":7517347,"avatar_url":"https://avatars1.githubusercontent.com/u/7517347?v=4","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},"assignees":[{"login":"jdannberg","id":7517347,"avatar_url":"https://avatars1.githubusercontent.com/u/7517347?v=4","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}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/geodynamics/aspect/pulls/1785/commits","review_comments_url":"https://api.github.com/repos/geodynamics/aspect/pulls/1785/comments","review_comment_url":"https://api.github.com/repos/geodynamics/aspect/pulls/comments{/number}","comments_url":"https://api.github.com/repos/geodynamics/aspect/issues/1785/comments","statuses_url":"https://api.github.com/repos/geodynamics/aspect/statuses/f93c011ab906b0e9e008709225fd6a09ea4688cf","head":{"label":"gassmoeller:extend_assembler_base","ref":"extend_assembler_base","sha":"f93c011ab906b0e9e008709225fd6a09ea4688cf","user":{"login":"gassmoeller","id":7582930,"avatar_url":"https://avatars0.githubusercontent.com/u/7582930?v=4","gravatar_id":"","url":"https://api.github.com/users/gassmoeller","html_url":"https://github.com/gassmoeller","followers_url":"https://api.github.com/users/gassmoeller/followers","following_url":"https://api.github.com/users/gassmoeller/following{/other_user}","gists_url":"https://api.github.com/users/gassmoeller/gists{/gist_id}","starred_url":"https://api.github.com/users/gassmoeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gassmoeller/subscriptions","organizations_url":"https://api.github.com/users/gassmoeller/orgs","repos_url":"https://api.github.com/users/gassmoeller/repos","events_url":"https://api.github.com/users/gassmoeller/events{/privacy}","received_events_url":"https://api.github.com/users/gassmoeller/received_events","type":"User","site_admin":false},"repo":{"id":19785507,"name":"aspect","full_name":"gassmoeller/aspect","owner":{"login":"gassmoeller","id":7582930,"avatar_url":"https://avatars0.githubusercontent.com/u/7582930?v=4","gravatar_id":"","url":"https://api.github.com/users/gassmoeller","html_url":"https://github.com/gassmoeller","followers_url":"https://api.github.com/users/gassmoeller/followers","following_url":"https://api.github.com/users/gassmoeller/following{/other_user}","gists_url":"https://api.github.com/users/gassmoeller/gists{/gist_id}","starred_url":"https://api.github.com/users/gassmoeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gassmoeller/subscriptions","organizations_url":"https://api.github.com/users/gassmoeller/orgs","repos_url":"https://api.github.com/users/gassmoeller/repos","events_url":"https://api.github.com/users/gassmoeller/events{/privacy}","received_events_url":"https://api.github.com/users/gassmoeller/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gassmoeller/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/gassmoeller/aspect","forks_url":"https://api.github.com/repos/gassmoeller/aspect/forks","keys_url":"https://api.github.com/repos/gassmoeller/aspect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gassmoeller/aspect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gassmoeller/aspect/teams","hooks_url":"https://api.github.com/repos/gassmoeller/aspect/hooks","issue_events_url":"https://api.github.com/repos/gassmoeller/aspect/issues/events{/number}","events_url":"https://api.github.com/repos/gassmoeller/aspect/events","assignees_url":"https://api.github.com/repos/gassmoeller/aspect/assignees{/user}","branches_url":"https://api.github.com/repos/gassmoeller/aspect/branches{/branch}","tags_url":"https://api.github.com/repos/gassmoeller/aspect/tags","blobs_url":"https://api.github.com/repos/gassmoeller/aspect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gassmoeller/aspect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gassmoeller/aspect/git/refs{/sha}","trees_url":"https://api.github.com/repos/gassmoeller/aspect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gassmoeller/aspect/statuses/{sha}","languages_url":"https://api.github.com/repos/gassmoeller/aspect/languages","stargazers_url":"https://api.github.com/repos/gassmoeller/aspect/stargazers","contributors_url":"https://api.github.com/repos/gassmoeller/aspect/contributors","subscribers_url":"https://api.github.com/repos/gassmoeller/aspect/subscribers","subscription_url":"https://api.github.com/repos/gassmoeller/aspect/subscription","commits_url":"https://api.github.com/repos/gassmoeller/aspect/commits{/sha}","git_commits_url":"https://api.github.com/repos/gassmoeller/aspect/git/commits{/sha}","comments_url":"https://api.github.com/repos/gassmoeller/aspect/comments{/number}","issue_comment_url":"https://api.github.com/repos/gassmoeller/aspect/issues/comments{/number}","contents_url":"https://api.github.com/repos/gassmoeller/aspect/contents/{+path}","compare_url":"https://api.github.com/repos/gassmoeller/aspect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gassmoeller/aspect/merges","archive_url":"https://api.github.com/repos/gassmoeller/aspect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gassmoeller/aspect/downloads","issues_url":"https://api.github.com/repos/gassmoeller/aspect/issues{/number}","pulls_url":"https://api.github.com/repos/gassmoeller/aspect/pulls{/number}","milestones_url":"https://api.github.com/repos/gassmoeller/aspect/milestones{/number}","notifications_url":"https://api.github.com/repos/gassmoeller/aspect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gassmoeller/aspect/labels{/name}","releases_url":"https://api.github.com/repos/gassmoeller/aspect/releases{/id}","deployments_url":"https://api.github.com/repos/gassmoeller/aspect/deployments","created_at":"2014-05-14T15:40:43Z","updated_at":"2016-12-01T18:45:12Z","pushed_at":"2017-11-21T20:29:08Z","git_url":"git://github.com/gassmoeller/aspect.git","ssh_url":"git@github.com:gassmoeller/aspect.git","clone_url":"https://github.com/gassmoeller/aspect.git","svn_url":"https://github.com/gassmoeller/aspect","homepage":null,"size":163297,"stargazers_count":2,"watchers_count":2,"language":"Gnuplot","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"geodynamics:master","ref":"master","sha":"9f8710c42270031869108970a43c1745e7cc6d80","user":{"login":"geodynamics","id":4052461,"avatar_url":"https://avatars1.githubusercontent.com/u/4052461?v=4","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://avatars1.githubusercontent.com/u/4052461?v=4","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}","deployments_url":"https://api.github.com/repos/geodynamics/aspect/deployments","created_at":"2014-05-06T16:47:18Z","updated_at":"2017-10-12T15:05:01Z","pushed_at":"2017-11-21T20:29:09Z","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":"https://aspect.geodynamics.org/","size":167319,"stargazers_count":41,"watchers_count":41,"language":"Gnuplot","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":84,"mirror_url":null,"archived":false,"open_issues_count":158,"forks":84,"open_issues":158,"watchers":41,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/geodynamics/aspect/pulls/1785"},"html":{"href":"https://github.com/geodynamics/aspect/pull/1785"},"issue":{"href":"https://api.github.com/repos/geodynamics/aspect/issues/1785"},"comments":{"href":"https://api.github.com/repos/geodynamics/aspect/issues/1785/comments"},"review_comments":{"href":"https://api.github.com/repos/geodynamics/aspect/pulls/1785/comments"},"review_comment":{"href":"https://api.github.com/repos/geodynamics/aspect/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/geodynamics/aspect/pulls/1785/commits"},"statuses":{"href":"https://api.github.com/repos/geodynamics/aspect/statuses/f93c011ab906b0e9e008709225fd6a09ea4688cf"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"tjhei"}}