getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] (no subject)


From: Tetsuo Koyama
Subject: [Getfem-commits] (no subject)
Date: Sun, 6 Jan 2019 09:30:28 -0500 (EST)

branch: devel-tetsuo-asm_lumped_mass_matrix
commit f04b73d51ff45df35a8e8d167a039df1e841867c
Author: Tetsuo Koyama <address@hidden>
Date:   Sun Jan 6 11:49:54 2019 +0900

    Add asm_lumped_mass_matrix
---
 src/getfem/getfem_assembling.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/getfem/getfem_assembling.h b/src/getfem/getfem_assembling.h
index 0232009..9330a97 100644
--- a/src/getfem/getfem_assembling.h
+++ b/src/getfem/getfem_assembling.h
@@ -825,6 +825,31 @@ namespace getfem {
       (M, mim, mf_u, 0, F, rg, "(A*Test_u):Test2_u");
   }
 
+  /**
+   * lumped mass matrix assembly (on the whole mesh or on the specified
+   * boundary)
+   * @ingroup asm
+   */
+  template<typename MAT>
+  inline void asm_lumped_mass_matrix
+  (const MAT &M, const mesh_im &mim, const mesh_fem &mf1,
+   const mesh_region &rg = mesh_region::all_convexes()) {
+    asm_mass_matrix(M, mim, mf1, rg);
+    size_type nbd = gmm::mat_ncols(M), nbr = gmm::mat_nrows(M);
+    MAT TEMP_M(nbd, nbr);
+    GMM_ASSERT1(nbd == nbr, "mass matrix is not square");
+    gmm::clear(TEMP_M);
+    for (size_type i =0; i < nbr; ++i) {
+      for (size_type j =0; j < nbd; ++j) {
+        gmm::add(
+          gmm::sub_matrix(M, gmm::sub_interval(i, 1), gmm::sub_interval(j, 1)),
+          gmm::sub_matrix(TEMP_M, gmm::sub_interval(i, 1), 
gmm::sub_interval(i, 1))
+        );
+      }
+    }
+    gmm::copy(TEMP_M, const_cast<MAT &>(M));
+  }
+
   /** 
       source term (for both volumic sources and boundary (Neumann) sources).
       @ingroup asm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]