[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] r4883 - in /trunk/getfem: interface/src/gf_mesh_get.cc
From: |
Yves . Renard |
Subject: |
[Getfem-commits] r4883 - in /trunk/getfem: interface/src/gf_mesh_get.cc interface/tests/matlab/demo_bilaplacian.m src/getfem/getfem_mesh.h |
Date: |
Mon, 16 Mar 2015 11:47:53 -0000 |
Author: renard
Date: Mon Mar 16 12:47:52 2015
New Revision: 4883
URL: http://svn.gna.org/viewcvs/getfem?rev=4883&view=rev
Log:
adding a function selecting outer faces of a mesh with respect to a given
direction
Modified:
trunk/getfem/interface/src/gf_mesh_get.cc
trunk/getfem/interface/tests/matlab/demo_bilaplacian.m
trunk/getfem/src/getfem/getfem_mesh.h
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=4883&r1=4882&r2=4883&view=diff
==============================================================================
--- trunk/getfem/interface/src/gf_mesh_get.cc (original)
+++ trunk/getfem/interface/src/gf_mesh_get.cc Mon Mar 16 12:47:52 2015
@@ -1,6 +1,7 @@
+/* -*- c++ -*- (enables emacs c++ mode) */
/*===========================================================================
- Copyright (C) 2006-2012 Yves Renard, Julien Pommier.
+ Copyright (C) 2006-2015 Yves Renard, Julien Pommier.
This file is a part of GETFEM++
@@ -156,36 +157,56 @@
static void
-outer_faces(const getfem::mesh &m, mexargs_in &in, mexargs_out &out)
+outer_faces(const getfem::mesh &m, mexargs_in &in, mexargs_out &out, bool
with_normal)
{
mesh_faces_by_pts_list lst;
dal::bit_vector convex_tested;
dal::bit_vector cvlst;
+ darray normal_vector;
+ bgeot::base_node un;
+ scalar_type threshold(0);
+ if (with_normal) {
+ normal_vector = in.pop().to_darray();
+ scalar_type angle = in.pop().to_scalar();
+ threshold = gmm::vect_norm2(normal_vector)*cos(angle);
+ }
+
if (in.remaining()) cvlst = in.pop().to_bit_vector(&m.convex_index());
else cvlst = m.convex_index();
for (dal::bv_visitor ic(cvlst); !ic.finished(); ++ic) {
if (m.structure_of_convex(ic)->dim() == m.dim()) {
for (short_type f = 0; f < m.structure_of_convex(ic)->nb_faces(); f++) {
- bgeot::mesh_structure::ind_pt_face_ct pt =
m.ind_points_of_face_of_convex(ic, f);
+ bgeot::mesh_structure::ind_pt_face_ct pt
+ = m.ind_points_of_face_of_convex(ic, f);
std::vector<size_type> p(pt.begin(), pt.end());
size_type idx = lst.add_norepeat(mesh_faces_by_pts_list_elt(ic,f,p));
- // cerr << " <-- idx = " << idx << endl;
lst[idx].cnt++;
}
- } else { /* les objets de dim inferieure sont considérés comme "exterieurs"
- (c'ets plus pratique pour faire des dessins)
- */
- bgeot::mesh_structure::ind_cv_ct pt = m.ind_points_of_convex(ic);
- std::vector<size_type> p(pt.begin(), pt.end());
- size_type idx = lst.add_norepeat(mesh_faces_by_pts_list_elt(ic,
short_type(-1), p));
- lst[idx].cnt++;
- }
+ }
+// else { // DEPRECATED
+// bgeot::mesh_structure::ind_cv_ct pt = m.ind_points_of_convex(ic);
+// std::vector<size_type> p(pt.begin(), pt.end());
+// size_type idx =
+// lst.add_norepeat(mesh_faces_by_pts_list_elt(ic, short_type(-1), p));
+// lst[idx].cnt++;
+// }
}
size_type fcnt = 0;
for (size_type i = 0; i < lst.size(); i++) {
- fcnt += (lst[i].cnt == 1 ? 1 : 0);
+ if (lst[i].cnt == 1) {
+ size_type icv = lst[i].cv;
+ short_type iif = lst[i].f;
+ if (with_normal) un = m.mean_normal_of_face_of_convex(icv, iif);
+ if (!with_normal ||
+ (gmm::vect_sp(normal_vector, un) - threshold >= -1E-8)) {
+ fcnt++;
+ } else {
+ lst[i].cnt = 2;
+ }
+ }
+
}
iarray w = out.pop().create_iarray(2,unsigned(fcnt));
@@ -197,6 +218,7 @@
fcnt++;
}
}
+
}
@@ -699,7 +721,7 @@
/address@hidden CVFIDs = ('outer faces'[, CVIDs])
- Return the faces which are not shared by two convexes.
+ Return the set of faces not shared by two convexes.
`CVFIDs` is a two-rows matrix, the first row lists convex #ids,
and the second lists face numbers (local number in the convex).
@@ -710,7 +732,22 @@
sub_command
("outer faces", 0, 1, 0, 1,
check_empty_mesh(pmesh);
- outer_faces(*pmesh, in, out);
+ outer_faces(*pmesh, in, out, false);
+ );
+
+ /address@hidden CVFIDs = ('outer faces with direction', @vec v, @scalar
angle [, CVIDs])
+ Return the set of faces not shared by two convexes and whose mean outward
unit vector have at most an angle `angle` with vector `v`.
+
+ `CVFIDs` is a two-rows matrix, the first row lists convex #ids,
+ and the second lists face numbers (local number in the convex).
+ If `CVIDs` is not given, all convexes are considered, and it
+ basically returns the mesh boundary. If `CVIDs` is given, it
+ returns the boundary of the convex set whose #ids are listed
+ in address@hidden/
+ sub_command
+ ("outer faces with direction", 2, 3, 0, 1,
+ check_empty_mesh(pmesh);
+ outer_faces(*pmesh, in, out, true);
);
Modified: trunk/getfem/interface/tests/matlab/demo_bilaplacian.m
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/tests/matlab/demo_bilaplacian.m?rev=4883&r1=4882&r2=4883&view=diff
==============================================================================
--- trunk/getfem/interface/tests/matlab/demo_bilaplacian.m (original)
+++ trunk/getfem/interface/tests/matlab/demo_bilaplacian.m Mon Mar 16
12:47:52 2015
@@ -1,4 +1,4 @@
-% Copyright (C) 2005-2012 Yves Renard, Julien Pommier.
+% Copyright (C) 2005-2015 Yves Renard, Julien Pommier.
%
% This file is a part of GETFEM++
%
@@ -26,7 +26,7 @@
useKL=1; % use the Kirchhoff-Love plate model, or just a pure
% bilaplacian problem
-D=1.0; % Flexion modulus
+D=1.0; % Flexion modulus
newbricks=1; % Use new bricks or old ones.
if useKL, NU=0.3; end; % poisson ratio (0 <= NU <= 1)
@@ -42,12 +42,19 @@
% set(mfu, 'fem', gfFem('FEM_REDUCED_QUADC1_COMPOSITE'));
% set(mfd, 'fem', gfFem('FEM_QK(2,3)'));
-flst = get(m, 'outer_faces');
-n = get(m, 'normal of faces', flst);
-ftop = flst(:,find(abs(n(1,:)-1) < 1e-5));
-fbottom = flst(:,find(abs(n(1,:)+1) < 1e-5));
-fleft = flst(:,find(abs(n(2,:)+1) < 1e-5));
-fright = flst(:,find(abs(n(2,:)-1) < 1e-5));
+% flst = get(m, 'outer_faces');
+% n = get(m, 'normal of faces', flst);
+% ftop = flst(:,find(abs(n(1,:)-1) < 1e-5));
+% fbottom = flst(:,find(abs(n(1,:)+1) < 1e-5));
+% fleft = flst(:,find(abs(n(2,:)+1) < 1e-5));
+% fright = flst(:,find(abs(n(2,:)-1) < 1e-5));
+
+ftop = get(m, 'outer faces with direction', [ 1; 0], 0.1);
+fbottom = get(m, 'outer faces with direction', [-1; 0], 0.1);
+fleft = get(m, 'outer faces with direction', [0; -1], 0.1);
+fright = get(m, 'outer faces with direction', [0; 1], 0.1);
+
+
FORCE_BOUNDARY_NUM=1;
MOMENTUM_BOUNDARY_NUM=2;
Modified: trunk/getfem/src/getfem/getfem_mesh.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_mesh.h?rev=4883&r1=4882&r2=4883&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_mesh.h (original)
+++ trunk/getfem/src/getfem/getfem_mesh.h Mon Mar 16 12:47:52 2015
@@ -1,7 +1,7 @@
/* -*- c++ -*- (enables emacs c++ mode) */
/*===========================================================================
- Copyright (C) 1999-2012 Yves Renard
+ Copyright (C) 1999-2015 Yves Renard
This file is a part of GETFEM++
@@ -66,8 +66,8 @@
/address@hidden mesh*/
/address@hidden/
- /** Describe a mesh (collection of convexes and points). Note that
- mesh object have no copy constructor, use
+ /** Describe a mesh (collection of convexes (elements) and points).
+ Note that mesh object have no copy constructor, use
mesh::copy_from instead. This class inherits from
bgeot::mesh<base_node> and bgeot::mesh_structure. Compared to
bgeot::mesh, It provides some additional methods for convenience
@@ -673,9 +673,10 @@
/** Select in the region mr the faces of the mesh m with their unit
outward vector having a maximal angle "angle" with the vector V.
*/
- mesh_region APIDECL select_faces_of_normal(const mesh &m, const mesh_region
&mr,
- const base_small_vector &V,
- scalar_type angle);
+ mesh_region APIDECL select_faces_of_normal(const mesh &m,
+ const mesh_region &mr,
+ const base_small_vector &V,
+ scalar_type angle);
///@}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] r4883 - in /trunk/getfem: interface/src/gf_mesh_get.cc interface/tests/matlab/demo_bilaplacian.m src/getfem/getfem_mesh.h,
Yves . Renard <=