]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
A first step to multigrid
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 14 Jan 1999 16:37:24 +0000 (16:37 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 14 Jan 1999 16:37:24 +0000 (16:37 +0000)
git-svn-id: https://svn.dealii.org/trunk@735 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/multigrid/multigrid.h [new file with mode: 0644]
deal.II/deal.II/include/numerics/multigrid.h [new file with mode: 0644]
deal.II/deal.II/source/multigrid/multigrid.cc [new file with mode: 0644]
deal.II/deal.II/source/numerics/multigrid.cc [new file with mode: 0644]

diff --git a/deal.II/deal.II/include/multigrid/multigrid.h b/deal.II/deal.II/include/multigrid/multigrid.h
new file mode 100644 (file)
index 0000000..d3951e8
--- /dev/null
@@ -0,0 +1,44 @@
+/*----------------------------   multigrid.h     ---------------------------*/
+/*      $Id$                 */
+#ifndef __multigrid_H
+#define __multigrid_H
+/*----------------------------   multigrid.h     ---------------------------*/
+
+/**
+ * Basic matrix class for multigrid preconditioning.
+ *
+ * This matrix may be used in the iterative methods of LAC, where the
+ * functions #vmult# and #precondition# and possibly their transposed
+ * versions are needed.
+ *
+ * The function #precondition# is the actual multigrid method and
+ * makes use of several operations to be implemented in derived
+ * classes...
+ *
+ */
+class MGMatrix
+{
+  MGMatrix(const MGMatrix&);
+  operator=(const MGMatrix&);
+public:
+                                  /** Matrix-vector multiplication.
+                                   *
+                                   * The global, non-multigrid
+                                   * matrix-vector multiplication
+                                   * used to compute the residual in
+                                   * the outer iteration.
+                                   *
+                                   */
+  void vmult(dVector& dst, const dVector& src) const;
+                                  /** Multigrid preconditioning.
+                                   */
+  void precondition(dVector& dst, const dVector& src) const;
+};
+
+
+
+
+/*----------------------------   multigrid.h     ---------------------------*/
+/* end of #ifndef __multigrid_H */
+#endif
+/*----------------------------   multigrid.h     ---------------------------*/
diff --git a/deal.II/deal.II/include/numerics/multigrid.h b/deal.II/deal.II/include/numerics/multigrid.h
new file mode 100644 (file)
index 0000000..d3951e8
--- /dev/null
@@ -0,0 +1,44 @@
+/*----------------------------   multigrid.h     ---------------------------*/
+/*      $Id$                 */
+#ifndef __multigrid_H
+#define __multigrid_H
+/*----------------------------   multigrid.h     ---------------------------*/
+
+/**
+ * Basic matrix class for multigrid preconditioning.
+ *
+ * This matrix may be used in the iterative methods of LAC, where the
+ * functions #vmult# and #precondition# and possibly their transposed
+ * versions are needed.
+ *
+ * The function #precondition# is the actual multigrid method and
+ * makes use of several operations to be implemented in derived
+ * classes...
+ *
+ */
+class MGMatrix
+{
+  MGMatrix(const MGMatrix&);
+  operator=(const MGMatrix&);
+public:
+                                  /** Matrix-vector multiplication.
+                                   *
+                                   * The global, non-multigrid
+                                   * matrix-vector multiplication
+                                   * used to compute the residual in
+                                   * the outer iteration.
+                                   *
+                                   */
+  void vmult(dVector& dst, const dVector& src) const;
+                                  /** Multigrid preconditioning.
+                                   */
+  void precondition(dVector& dst, const dVector& src) const;
+};
+
+
+
+
+/*----------------------------   multigrid.h     ---------------------------*/
+/* end of #ifndef __multigrid_H */
+#endif
+/*----------------------------   multigrid.h     ---------------------------*/
diff --git a/deal.II/deal.II/source/multigrid/multigrid.cc b/deal.II/deal.II/source/multigrid/multigrid.cc
new file mode 100644 (file)
index 0000000..08646d8
--- /dev/null
@@ -0,0 +1,38 @@
+// $Id$
+// Copyright Guido Kanschat, Universitaet Heidelberg, 1999
+
+#include <numerics/multigrid.h>
+
+void
+MGMatrix::vmult(dVector& dst, const dVector& src) const
+{
+  dst = 0.;
+  
+  copy_to_mg(s,src);
+  
+  for (int l=0;l<maxlevel;++l)
+  {
+    level_active_vmult(l,d,s);
+  }
+  copy_from_mg(dst,d);
+}
+
+
+void
+MGMatrix::precondition(dVector& dst, const dVector& src) const
+{
+  copy_to_mg(s,src);
+  d = 0.;
+  
+    
+}
+
+void
+MGMatrix::level_mgstep(int level)
+{
+  for (int i=0; i< n_presmooth; ++i)
+  {
+    smooth(level, d, s);
+  }
+}
+
diff --git a/deal.II/deal.II/source/numerics/multigrid.cc b/deal.II/deal.II/source/numerics/multigrid.cc
new file mode 100644 (file)
index 0000000..08646d8
--- /dev/null
@@ -0,0 +1,38 @@
+// $Id$
+// Copyright Guido Kanschat, Universitaet Heidelberg, 1999
+
+#include <numerics/multigrid.h>
+
+void
+MGMatrix::vmult(dVector& dst, const dVector& src) const
+{
+  dst = 0.;
+  
+  copy_to_mg(s,src);
+  
+  for (int l=0;l<maxlevel;++l)
+  {
+    level_active_vmult(l,d,s);
+  }
+  copy_from_mg(dst,d);
+}
+
+
+void
+MGMatrix::precondition(dVector& dst, const dVector& src) const
+{
+  copy_to_mg(s,src);
+  d = 0.;
+  
+    
+}
+
+void
+MGMatrix::level_mgstep(int level)
+{
+  for (int i=0; i< n_presmooth; ++i)
+  {
+    smooth(level, d, s);
+  }
+}
+

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.