getfem-commits
[Top][All Lists]
Advanced

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

[Getfem-commits] (no subject)


From: arsha shiri
Subject: [Getfem-commits] (no subject)
Date: Mon, 19 Mar 2018 08:39:21 -0400 (EDT)

branch: devel_arsha_adding_bounding_box_method_to_mesh_region_class
commit ffc87a3e8368a2f4050d1da064ddc1a4e6419ac7
Author: shiri <address@hidden>
Date:   Mon Mar 19 13:38:37 2018 +0100

    Added a bounding box method to mesh_region class.
---
 src/getfem/getfem_mesh_region.h |  3 +++
 src/getfem_mesh_region.cc       | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/src/getfem/getfem_mesh_region.h b/src/getfem/getfem_mesh_region.h
index de57419..d930a7d 100644
--- a/src/getfem/getfem_mesh_region.h
+++ b/src/getfem/getfem_mesh_region.h
@@ -181,6 +181,9 @@ namespace getfem {
     iterations with mr_visitor. This is a default behaviour*/
     void  allow_partitioning();
 
+    /** Return the bounding box [Pmin - Pmax] of the mesh_region. */
+    void bounding_box(base_node& Pmin, base_node& Pmax) const;
+
     /** Disregard partitioning, which means being able to see the whole region
     in multirheaded code. Can be used, for instance, for contact problems
     where master region is partitioned, while the slave region is not*/
diff --git a/src/getfem_mesh_region.cc b/src/getfem_mesh_region.cc
index 98f372e..11ebfdc 100644
--- a/src/getfem_mesh_region.cc
+++ b/src/getfem_mesh_region.cc
@@ -215,6 +215,18 @@ namespace getfem {
     else partitioning_allowed.all_threads() = true;
   }
 
+  void mesh_region::bounding_box(base_node& Pmin, base_node& Pmax) const {
+    auto &mesh = *this->get_parent_mesh();
+    for (auto cv : dal::bv_iterable_c(index())) {
+      for (auto &&pt : mesh.points_of_convex(cv)) {
+        for (auto j = 0; j < Pmin.size(); j++){
+          Pmin[j] = std::min(Pmin[j], pt[j]);
+          Pmax[j] = std::max(Pmax[j], pt[j]);
+        }
+      }
+    }
+  }
+
   void  mesh_region::prohibit_partitioning()
   {
     if (me_is_multithreaded_now()) partitioning_allowed = false;



reply via email to

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