]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fixed indentation
authorNicolas Barnafi <nabw91@gmail.com>
Wed, 6 Apr 2022 14:00:31 +0000 (16:00 +0200)
committerNicolas Barnafi <nabw91@gmail.com>
Wed, 6 Apr 2022 14:00:31 +0000 (16:00 +0200)
include/deal.II/lac/petsc_precondition.h
source/lac/petsc_parallel_sparse_matrix.cc
source/lac/petsc_precondition.cc

index 678e4eab2fb328519d90afada1dfb402112a038f..65e0d996172fbf5a5072149ccbcbf59f84b267c0 100644 (file)
@@ -957,110 +957,111 @@ namespace PETScWrappers
     AdditionalData additional_data;
   };
 
+  /**
+   * A class that implements the interface to use the BDDC preconditioner from
+   * PETSc.
+   *
+   * @ingroup PETScWrappers
+   * @author Nicolas Barnafi, 2022
+   */
+  class PreconditionBDDC : public PreconditionBase
+  {
+  public:
     /**
-     * A class that implements the interface to use the BDDC preconditioner from
-     * PETSc.
-     *
-     * @ingroup PETScWrappers
-     * @author Nicolas Barnafi, 2022
+     * Standardized data struct to pipe additional flags to the
+     * preconditioner.
      */
-    class PreconditionBDDC : public PreconditionBase
+    struct AdditionalData
     {
-    public:
       /**
-       * Standardized data struct to pipe additional flags to the
-       * preconditioner.
-       */
-      struct AdditionalData
-      {
-        /**
-         * Constructor. Note that BDDC offers a lot more options to set
-         * than what is exposed here.
-         */
-        AdditionalData(const bool use_vertices_ = true,
-                       const bool use_edges_    = false,
-                       const bool use_faces_    = false,
-                       const bool symmetric_    = false,
-                       const unsigned int coords_cdim_ = 0,
-                       const types::global_dof_index coords_n_ = 0,
-                       const PetscReal *coords_data_ = nullptr);
-
-        /**
-         * This flag sets the use of degrees of freedom in the vertices of the
-         * subdomain as primal variables.
-         */
-        bool use_vertices;
-
-        /**
-         * This flag sets the use of degrees of freedom in the edges of the
-         * subdomain as primal variables.
-         */
-        bool use_edges;
-
-        /**
-         * This flag sets the use of degrees of freedom in the faces of the
-         * subdomain as primal variables.
-         */
-        bool use_faces;
-
-        /**
-         * Set whether the matrix is symmetric or not.
-         */
-        bool symmetric;
-
-        /**
-         * Support for H1 problems
-         */
-        unsigned int coords_cdim;
-        types::global_dof_index coords_n;
-        const PetscReal *coords_data; /* not referenced, consumed at initialize time */
-      };
-
-      /**
-       * Empty Constructor. You need to call initialize() before using this
-       * object.
+       * Constructor. Note that BDDC offers a lot more options to set
+       * than what is exposed here.
        */
-      PreconditionBDDC() = default;
+      AdditionalData(const bool                    use_vertices_ = true,
+                     const bool                    use_edges_    = false,
+                     const bool                    use_faces_    = false,
+                     const bool                    symmetric_    = false,
+                     const unsigned int            coords_cdim_  = 0,
+                     const types::global_dof_index coords_n_     = 0,
+                     const PetscReal *             coords_data_  = nullptr);
 
       /**
-       * Constructor. Take the matrix which is used to form the preconditioner,
-       * and additional flags if there are any.
+       * This flag sets the use of degrees of freedom in the vertices of the
+       * subdomain as primal variables.
        */
-      PreconditionBDDC(const MatrixBase &    matrix,
-                       const AdditionalData &additional_data = AdditionalData());
+      bool use_vertices;
 
       /**
-       * Same as above but without setting a matrix to form the preconditioner.
-       * Intended to be used with SLEPc objects.
+       * This flag sets the use of degrees of freedom in the edges of the
+       * subdomain as primal variables.
        */
-      PreconditionBDDC(const MPI_Comm        communicator,
-                       const AdditionalData &additional_data = AdditionalData());
+      bool use_edges;
 
       /**
-       * Initialize the preconditioner object and calculate all data that is
-       * necessary for applying it in a solver. This function is automatically
-       * called when calling the constructor with the same arguments and is only
-       * used if you create the preconditioner without arguments.
+       * This flag sets the use of degrees of freedom in the faces of the
+       * subdomain as primal variables.
        */
-      void
-      initialize(const MatrixBase &    matrix,
-                 const AdditionalData &additional_data = AdditionalData());
+      bool use_faces;
 
-    protected:
       /**
-       * Store a copy of the flags for this particular preconditioner.
+       * Set whether the matrix is symmetric or not.
        */
-      AdditionalData additional_data;
+      bool symmetric;
 
       /**
-       * Initialize the preconditioner object without knowing a particular
-       * matrix. This function sets up appropriate parameters to the underlying
-       * PETSc object after it has been created.
+       * Support for H1 problems
        */
-      void
-      initialize();
+      unsigned int            coords_cdim;
+      types::global_dof_index coords_n;
+      const PetscReal
+        *coords_data; /* not referenced, consumed at initialize time */
     };
 
+    /**
+     * Empty Constructor. You need to call initialize() before using this
+     * object.
+     */
+    PreconditionBDDC() = default;
+
+    /**
+     * Constructor. Take the matrix which is used to form the preconditioner,
+     * and additional flags if there are any.
+     */
+    PreconditionBDDC(const MatrixBase &    matrix,
+                     const AdditionalData &additional_data = AdditionalData());
+
+    /**
+     * Same as above but without setting a matrix to form the preconditioner.
+     * Intended to be used with SLEPc objects.
+     */
+    PreconditionBDDC(const MPI_Comm        communicator,
+                     const AdditionalData &additional_data = AdditionalData());
+
+    /**
+     * Initialize the preconditioner object and calculate all data that is
+     * necessary for applying it in a solver. This function is automatically
+     * called when calling the constructor with the same arguments and is only
+     * used if you create the preconditioner without arguments.
+     */
+    void
+    initialize(const MatrixBase &    matrix,
+               const AdditionalData &additional_data = AdditionalData());
+
+  protected:
+    /**
+     * Store a copy of the flags for this particular preconditioner.
+     */
+    AdditionalData additional_data;
+
+    /**
+     * Initialize the preconditioner object without knowing a particular
+     * matrix. This function sets up appropriate parameters to the underlying
+     * PETSc object after it has been created.
+     */
+    void
+    initialize();
+  };
+
   /**
    * Alias for backwards-compatibility.
    * @deprecated Use PETScWrappers::PreconditionBase instead.
index 76b7419099bd8f6e8124295075a11456ecaaed9c..d93dd196043f4e06e5e94d76acf9fca98d0d9712 100644 (file)
@@ -449,7 +449,7 @@ namespace PETScWrappers
       Assert(local_rows.is_ascending_and_one_to_one(communicator),
              ExcNotImplemented());
 
-    #  ifdef DEBUG
+#  ifdef DEBUG
       {
         // check indexsets
         types::global_dof_index row_owners =
@@ -472,7 +472,7 @@ namespace PETScWrappers
             " but sum(local_columns.n_elements())=" +
             std::to_string(col_owners) + ")"));
       }
-    #  endif
+#  endif
 
       // create the local to global mappings as arrays.
       IndexSet::size_type n_l2g_row = local_active_rows.n_elements();
index 8cd0c0ca2c4011625fb2a91e6b68b3c292ad212b..f1061a265910fd23d1780484e4a1da27213bf662 100644 (file)
@@ -852,100 +852,101 @@ namespace PETScWrappers
 
   /* ----------------- PreconditionBDDC -------------------- */
 
-    PreconditionBDDC::AdditionalData::AdditionalData(const bool use_vertices_,
-                                                     const bool use_edges_,
-                                                     const bool use_faces_,
-                                                     const bool symmetric_,
-                                                     const unsigned int coords_cdim_,
-                                                     const types::global_dof_index coords_n_,
-                                                     const PetscReal *coords_data_)
-      : use_vertices(use_vertices_)
-      , use_edges(use_edges_)
-      , use_faces(use_faces_)
-      , symmetric(symmetric_)
-      , coords_cdim(coords_cdim_)
-      , coords_n(coords_n_)
-      , coords_data(coords_data_)
-    {}
-
-    PreconditionBDDC::PreconditionBDDC(const MPI_Comm        comm,
-                                       const AdditionalData &additional_data_)
-    {
-      additional_data = additional_data_;
+  PreconditionBDDC::AdditionalData::AdditionalData(
+    const bool                    use_vertices_,
+    const bool                    use_edges_,
+    const bool                    use_faces_,
+    const bool                    symmetric_,
+    const unsigned int            coords_cdim_,
+    const types::global_dof_index coords_n_,
+    const PetscReal *             coords_data_)
+    : use_vertices(use_vertices_)
+    , use_edges(use_edges_)
+    , use_faces(use_faces_)
+    , symmetric(symmetric_)
+    , coords_cdim(coords_cdim_)
+    , coords_n(coords_n_)
+    , coords_data(coords_data_)
+  {}
 
-      PetscErrorCode ierr = PCCreate(comm, &pc);
-      AssertThrow(ierr == 0, ExcPETScError(ierr));
+  PreconditionBDDC::PreconditionBDDC(const MPI_Comm        comm,
+                                     const AdditionalData &additional_data_)
+  {
+    additional_data = additional_data_;
 
-      initialize();
-    }
+    PetscErrorCode ierr = PCCreate(comm, &pc);
+    AssertThrow(ierr == 0, ExcPETScError(ierr));
 
-    PreconditionBDDC::PreconditionBDDC(const MatrixBase &    matrix,
-                                       const AdditionalData &additional_data)
-    {
-      initialize(matrix, additional_data);
-    }
+    initialize();
+  }
 
-    void
-    PreconditionBDDC::initialize()
-    {
-      PetscErrorCode ierr = PCSetType(pc, const_cast<char *>(PCBDDC));
-      AssertThrow(ierr == 0, ExcPETScError(ierr));
-
-      // TODO: Add BDDC options, in particular the additional primal nodes
-      std::stringstream ssStream;
-
-      if (additional_data.use_vertices)
-        set_option_value("-pc_bddc_use_vertices", "true");
-      else
-        set_option_value("-pc_bddc_use_vertices", "false");
-      if (additional_data.use_edges)
-        set_option_value("-pc_bddc_use_edges", "true");
-      else
-        set_option_value("-pc_bddc_use_edges", "false");
-      if (additional_data.use_faces)
-        set_option_value("-pc_bddc_use_faces", "true");
-      else
-        set_option_value("-pc_bddc_use_faces", "false");
-      if (additional_data.symmetric)
-        set_option_value("-pc_bddc_symmetric", "true");
-      else
-        set_option_value("-pc_bddc_symmetric", "false");
-      if (additional_data.coords_cdim)
+  PreconditionBDDC::PreconditionBDDC(const MatrixBase &    matrix,
+                                     const AdditionalData &additional_data)
+  {
+    initialize(matrix, additional_data);
+  }
+
+  void
+  PreconditionBDDC::initialize()
+  {
+    PetscErrorCode ierr = PCSetType(pc, const_cast<char *>(PCBDDC));
+    AssertThrow(ierr == 0, ExcPETScError(ierr));
+
+    // TODO: Add BDDC options, in particular the additional primal nodes
+    std::stringstream ssStream;
+
+    if (additional_data.use_vertices)
+      set_option_value("-pc_bddc_use_vertices", "true");
+    else
+      set_option_value("-pc_bddc_use_vertices", "false");
+    if (additional_data.use_edges)
+      set_option_value("-pc_bddc_use_edges", "true");
+    else
+      set_option_value("-pc_bddc_use_edges", "false");
+    if (additional_data.use_faces)
+      set_option_value("-pc_bddc_use_faces", "true");
+    else
+      set_option_value("-pc_bddc_use_faces", "false");
+    if (additional_data.symmetric)
+      set_option_value("-pc_bddc_symmetric", "true");
+    else
+      set_option_value("-pc_bddc_symmetric", "false");
+    if (additional_data.coords_cdim)
       {
         set_option_value("-pc_bddc_corner_selection", "true");
         ierr = PCSetCoordinates(pc,
                                 additional_data.coords_cdim,
                                 additional_data.coords_n,
-                                (PetscReal*)additional_data.coords_data);
+                                (PetscReal *)additional_data.coords_data);
         AssertThrow(ierr == 0, ExcPETScError(ierr));
       }
-      else
+    else
       {
         set_option_value("-pc_bddc_corner_selection", "false");
-        ierr = PCSetCoordinates(pc,0,0,NULL);
+        ierr = PCSetCoordinates(pc, 0, 0, NULL);
         AssertThrow(ierr == 0, ExcPETScError(ierr));
       }
 
 
-      ierr = PCSetFromOptions(pc);
-      AssertThrow(ierr == 0, ExcPETScError(ierr));
-    }
+    ierr = PCSetFromOptions(pc);
+    AssertThrow(ierr == 0, ExcPETScError(ierr));
+  }
 
-    void
-    PreconditionBDDC::initialize(const MatrixBase &    matrix_,
-                                 const AdditionalData &additional_data_)
-    {
-      clear();
+  void
+  PreconditionBDDC::initialize(const MatrixBase &    matrix_,
+                               const AdditionalData &additional_data_)
+  {
+    clear();
 
-      matrix          = static_cast<Mat>(matrix_);
-      additional_data = additional_data_;
+    matrix          = static_cast<Mat>(matrix_);
+    additional_data = additional_data_;
 
-      create_pc();
-      initialize();
+    create_pc();
+    initialize();
 
-      PetscErrorCode ierr = PCSetUp(pc);
-      AssertThrow(ierr == 0, ExcPETScError(ierr));
-    }
+    PetscErrorCode ierr = PCSetUp(pc);
+    AssertThrow(ierr == 0, ExcPETScError(ierr));
+  }
 
 
 } // namespace PETScWrappers

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.