[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] r5113 - in /trunk/getfem: interface/src/gf_mesh_get.cc
From: |
Yves . Renard |
Subject: |
[Getfem-commits] r5113 - in /trunk/getfem: interface/src/gf_mesh_get.cc src/getfem_mesh.cc |
Date: |
Thu, 29 Oct 2015 18:55:33 -0000 |
Author: renard
Date: Thu Oct 29 19:55:32 2015
New Revision: 5113
URL: http://svn.gna.org/viewcvs/getfem?rev=5113&view=rev
Log:
imrovement of inner_faces and adding the method to the interface
Modified:
trunk/getfem/interface/src/gf_mesh_get.cc
trunk/getfem/src/getfem_mesh.cc
Modified: trunk/getfem/interface/src/gf_mesh_get.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/gf_mesh_get.cc?rev=5113&r1=5112&r2=5113&view=diff
==============================================================================
--- trunk/getfem/interface/src/gf_mesh_get.cc (original)
+++ trunk/getfem/interface/src/gf_mesh_get.cc Thu Oct 29 19:55:32 2015
@@ -247,6 +247,28 @@
}
+static void
+inner_faces(const getfem::mesh &m, mexargs_in &in, mexargs_out &out) {
+ dal::bit_vector cvlst;
+
+ if (in.remaining()) cvlst = in.pop().to_bit_vector(&m.convex_index());
+ else cvlst = m.convex_index();
+ getfem::mesh_region mr;
+ for (dal::bv_visitor ic(cvlst); !ic.finished(); ++ic) mr.add(ic);
+ getfem::mesh_region mrr = inner_faces_of_mesh(m, mr);
+
+ unsigned fcnt = 0;
+ for (getfem::mr_visitor i(mrr); !i.finished(); ++i) ++fcnt;
+ iarray w = out.pop().create_iarray(2, fcnt);
+ fcnt = 0;
+ for (getfem::mr_visitor i(mrr); !i.finished(); ++i) {
+ w(0,fcnt) = int(i.cv()+config::base_index());
+ w(1,fcnt) = int(short_type(i.f()+config::base_index()));
+ fcnt++;
+ }
+}
+
+
static bgeot::base_node
normal_of_face(const getfem::mesh& mesh, size_type cv, short_type f, size_type
node) {
if (!mesh.convex_index().is_in(cv)) THROW_BADARG("convex " << cv+1 << " not
found in mesh");
@@ -746,7 +768,7 @@
/address@hidden CVFIDs = ('outer faces'[, CVIDs])
- Return the set of faces not shared by two convexes.
+ Return the set of faces not shared by two elements.
The output `CVFIDs` is a two-rows matrix, the first row lists
convex #ids, and the second one lists face numbers (local number
@@ -758,6 +780,16 @@
("outer faces", 0, 1, 0, 1,
check_empty_mesh(pmesh);
outer_faces(*pmesh, in, out);
+ );
+
+ /address@hidden CVFIDs = ('inner faces'[, CVIDs])
+ Return the set of faces shared at least by two elements in CVIDs.
+ Each face is represented only once and is arbitrary chosen
+ between the two neighbour elements. @*/
+ sub_command
+ ("inner faces", 0, 1, 0, 1,
+ check_empty_mesh(pmesh);
+ inner_faces(*pmesh, in, out);
);
/address@hidden CVFIDs = ('outer faces with direction', @vec v, @scalar
angle [, CVIDs])
Modified: trunk/getfem/src/getfem_mesh.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_mesh.cc?rev=5113&r1=5112&r2=5113&view=diff
==============================================================================
--- trunk/getfem/src/getfem_mesh.cc (original)
+++ trunk/getfem/src/getfem_mesh.cc Thu Oct 29 19:55:32 2015
@@ -782,20 +782,22 @@
mr.error_if_not_convexes();
mesh_region mrr;
dal::bit_vector visited;
+ bgeot::mesh_structure::ind_set neighbours;
for (mr_visitor i(mr); !i.finished(); ++i) {
size_type cv1 = i.cv();
short_type nbf = m.structure_of_convex(i.cv())->nb_faces();
bool neighbour_visited = false;
- for (short_type f = 0; f < nbf; f++) {
- size_type cv2 = m.neighbour_of_convex(cv1, f);
- if (cv2 == size_type(-1) && visited.is_in(cv2))
- { neighbour_visited = true; break; }
+ for (short_type f = 0; f < nbf; ++f) {
+ neighbours.resize(0); m.neighbours_of_convex(cv1, f, neighbours);
+ for (size_type j = 0; j < neighbours.size(); ++j)
+ if (visited.is_in(neighbours[j]))
+ { neighbour_visited = true; break; }
}
if (!neighbour_visited) {
- for (short_type f = 0; f < nbf; f++) {
+ for (short_type f = 0; f < nbf; ++f) {
size_type cv2 = m.neighbour_of_convex(cv1, f);
- if (cv2 == size_type(-1) && mr.is_in(cv2) && !(visited.is_in(cv2)))
+ if (cv2 == size_type(-1) && mr.is_in(cv2))
mrr.add(cv1,f);
}
visited.add(cv1);
@@ -806,10 +808,15 @@
size_type cv1 = i.cv();
short_type nbf = m.structure_of_convex(i.cv())->nb_faces();
if (!(visited.is_in(cv1))) {
- for (short_type f = 0; f < nbf; f++) {
- size_type cv2 = m.neighbour_of_convex(i.cv(), f);
- if (cv2 == size_type(-1) && mr.is_in(cv2) && !(visited.is_in(cv2)))
- mrr.add(cv1,f);
+ for (short_type f = 0; f < nbf; ++f) {
+
+ neighbours.resize(0); m.neighbours_of_convex(cv1, f, neighbours);
+ bool ok = false;
+ for (size_type j = 0; j < neighbours.size(); ++j) {
+ if (visited.is_in(neighbours[j])) { ok = false; break; }
+ if (mr.is_in(neighbours[j])) { ok = true; }
+ }
+ if (ok) mrr.add(cv1,f);
}
visited.add(cv1);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] r5113 - in /trunk/getfem: interface/src/gf_mesh_get.cc src/getfem_mesh.cc,
Yves . Renard <=