[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] r5147 - in /trunk/getfem/src: ./ getfem/
From: |
Yves . Renard |
Subject: |
[Getfem-commits] r5147 - in /trunk/getfem/src: ./ getfem/ |
Date: |
Thu, 19 Nov 2015 18:27:38 -0000 |
Author: renard
Date: Thu Nov 19 19:27:37 2015
New Revision: 5147
URL: http://svn.gna.org/viewcvs/getfem?rev=5147&view=rev
Log:
Dynamic allocation changes
Modified:
trunk/getfem/src/bgeot_poly_composite.cc
trunk/getfem/src/getfem/bgeot_poly_composite.h
trunk/getfem/src/getfem/getfem_mesh.h
trunk/getfem/src/getfem_mesh.cc
trunk/getfem/src/getfem_mesh_slicers.cc
Modified: trunk/getfem/src/bgeot_poly_composite.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/bgeot_poly_composite.cc?rev=5147&r1=5146&r2=5147&view=diff
==============================================================================
--- trunk/getfem/src/bgeot_poly_composite.cc (original)
+++ trunk/getfem/src/bgeot_poly_composite.cc Thu Nov 19 19:27:37 2015
@@ -187,7 +187,7 @@
static void structured_mesh_for_simplex_(pconvex_structure cvs,
pgeometric_trans opt_gt,
const std::vector<base_node> *opt_gt_pts,
- short_type k, pbasic_mesh &pm) {
+ short_type k, pbasic_mesh pm) {
scalar_type h = 1./k;
switch (cvs->dim()) {
case 1 :
@@ -304,7 +304,7 @@
static void structured_mesh_for_parallelepiped_
(pconvex_structure cvs, pgeometric_trans opt_gt,
- const std::vector<base_node> *opt_gt_pts, short_type k, pbasic_mesh &pm) {
+ const std::vector<base_node> *opt_gt_pts, short_type k, pbasic_mesh pm) {
scalar_type h = 1./k;
size_type n = cvs->dim();
size_type pow2n = (size_type(1) << n);
@@ -350,7 +350,7 @@
static void structured_mesh_for_convex_(pconvex_structure cvs,
pgeometric_trans opt_gt,
const std::vector<base_node> *opt_gt_pts,
- short_type k, pbasic_mesh &pm) {
+ short_type k, pbasic_mesh pm) {
size_type nbp = basic_structure(cvs)->nb_points();
dim_type n = cvs->dim();
/* Identifying simplexes. */
@@ -410,17 +410,13 @@
short_type n;
bool simplex_mesh; /* true if the convex has been splited into simplexes,
which were refined */
- basic_mesh *pm;
- std::vector<mesh_structure *> pfacem; /* array of mesh_structures for
faces */
+ std::unique_ptr<basic_mesh> pm;
+ std::vector<std::unique_ptr<mesh_structure>> pfacem; /* array of
mesh_structures for faces */
dal::bit_vector nodes_on_edges;
- mesh_precomposite *pmp;
- str_mesh_cv__(void) : pm(0), pmp(0) {}
+ std::unique_ptr<mesh_precomposite> pmp;
+ str_mesh_cv__(void) {}
str_mesh_cv__(pconvex_structure c, short_type k, bool smesh_) :
cvs(c), n(k), simplex_mesh(smesh_) {}
- ~str_mesh_cv__() {
- if (pm) delete pm; if (pmp) delete pmp; pm = 0; pmp = 0;
- for (size_type i=0; i < pfacem.size(); ++i) delete pfacem[i];
- }
};
typedef std::shared_ptr<const str_mesh_cv__> pstr_mesh_cv__;
@@ -445,15 +441,16 @@
dal::pstatic_stored_object o = dal::search_stored_object(pk);
pstr_mesh_cv__ psmc;
- if (o) {
+ if (o)
psmc = std::dynamic_pointer_cast<const str_mesh_cv__>(o);
- }
else {
- str_mesh_cv__ &smc(*(new
str_mesh_cv__(basic_structure(cvr->structure()), k,
- force_simplexification)));
- psmc = pstr_mesh_cv__(&smc);
-
- smc.pm = new basic_mesh();
+
+ auto ppsmc = std::make_shared<str_mesh_cv__>
+ (basic_structure(cvr->structure()), k, force_simplexification);
+ str_mesh_cv__ &smc(*ppsmc);
+ psmc = ppsmc;
+
+ smc.pm = std::make_unique<basic_mesh>();
if (force_simplexification) {
// cout << "cvr = " << int(cvr->structure()->dim()) << " : "
@@ -471,34 +468,33 @@
//cerr << "cvpts[" << j << "]=" << cvpts[j] << endl;
}
structured_mesh_for_convex_(splx_mesh->structure_of_convex(ic),
- sgt, &cvpts, k, smc.pm);
+ sgt, &cvpts, k, smc.pm.get());
}
} else {
- structured_mesh_for_convex_(cvr->structure(), 0, 0, k, smc.pm);
+ structured_mesh_for_convex_(cvr->structure(), 0, 0, k, smc.pm.get());
}
smc.pfacem.resize(cvr->structure()->nb_faces());
for (dim_type f=0; f < cvr->structure()->nb_faces(); ++f) {
- smc.pfacem[f] = new mesh_structure();
- structured_mesh_of_faces_(cvr, f, *smc.pm, *smc.pfacem[f]);
- }
-
- smc.pmp = new mesh_precomposite(*(smc.pm));
+ smc.pfacem[f] = std::make_unique<mesh_structure>();
+ structured_mesh_of_faces_(cvr, f, *(smc.pm), *(smc.pfacem[f]));
+ }
+
+ smc.pmp = std::make_unique<mesh_precomposite>(*(smc.pm));
dal::add_stored_object(pk, psmc, basic_structure(cvr->structure()));
}
- pm = psmc->pm;
- pmp = psmc->pmp;
+ pm = psmc->pm.get();
+ pmp = psmc->pmp.get();
}
const basic_mesh *
refined_simplex_mesh_for_convex(pconvex_ref cvr, short_type k) {
pbasic_mesh pm; pmesh_precomposite pmp;
- structured_mesh_for_convex(cvr,k,pm,pmp,true);
+ structured_mesh_for_convex(cvr, k, pm, pmp, true);
return pm;
}
- const std::vector<mesh_structure*>&
- refined_simplex_mesh_for_convex_faces(pconvex_ref cvr,
- short_type k) {
+ const std::vector<std::unique_ptr<mesh_structure>>&
+ refined_simplex_mesh_for_convex_faces(pconvex_ref cvr, short_type k) {
dal::pstatic_stored_object_key
pk = std::make_shared<str_mesh_key>(basic_structure(cvr->structure()),
k, true);
Modified: trunk/getfem/src/getfem/bgeot_poly_composite.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/bgeot_poly_composite.h?rev=5147&r1=5146&r2=5147&view=diff
==============================================================================
--- trunk/getfem/src/getfem/bgeot_poly_composite.h (original)
+++ trunk/getfem/src/getfem/bgeot_poly_composite.h Thu Nov 19 19:27:37 2015
@@ -143,7 +143,7 @@
the mesh_structure refer to the points of the mesh given by
refined_simplex_mesh_for_convex.
*/
- const std::vector<mesh_structure*>&
+ const std::vector<std::unique_ptr<mesh_structure>>&
refined_simplex_mesh_for_convex_faces(pconvex_ref cvr, short_type k);
} /* end of namespace bgeot. */
Modified: trunk/getfem/src/getfem/getfem_mesh.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_mesh.h?rev=5147&r1=5146&r2=5147&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_mesh.h (original)
+++ trunk/getfem/src/getfem/getfem_mesh.h Thu Nov 19 19:27:37 2015
@@ -506,9 +506,6 @@
/** Clone a mesh */
void copy_from(const mesh& m); /* might be the copy constructor */
size_type memsize(void) const;
- ~mesh() {
- if (Bank_info) delete Bank_info;
- }
friend class mesh_region;
private:
@@ -545,7 +542,7 @@
edge_set edges;
};
- Bank_info_struct *Bank_info;
+ std::unique_ptr<Bank_info_struct> Bank_info;
std::string name_; //optional name of the mesh
void set_name(const std::string&);
Modified: trunk/getfem/src/getfem_mesh.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_mesh.cc?rev=5147&r1=5146&r2=5147&view=diff
==============================================================================
--- trunk/getfem/src/getfem_mesh.cc (original)
+++ trunk/getfem/src/getfem_mesh.cc Thu Nov 19 19:27:37 2015
@@ -127,7 +127,6 @@
modified = true;
#endif
cuthill_mckee_uptodate = false;
- Bank_info = 0;
}
mesh::mesh(const std::string name) : name_(name) { init(); }
@@ -235,7 +234,7 @@
void mesh::transformation(const base_matrix &M) {
pts.transformation(M);
- if (Bank_info) { delete Bank_info; Bank_info = 0; }
+ Bank_info = std::unique_ptr<Bank_info_struct>();
touch();
}
@@ -257,7 +256,7 @@
gtab.clear(); trans_exists.clear();
cvf_sets.clear(); valid_cvf_sets.clear();
cvs_v_num.clear();
- if (Bank_info) { delete Bank_info; Bank_info = 0; }
+ Bank_info = std::unique_ptr<Bank_info_struct>();
touch();
}
@@ -300,7 +299,7 @@
for (size_type ip = 0; ip < ipt.size(); ++ip) sup_point(ipt[ip]);
trans_exists.sup(ic);
sup_convex_from_regions(ic);
- if (Bank_info) Bank_sup_convex_from_green(ic);
+ if (Bank_info.get()) Bank_sup_convex_from_green(ic);
touch();
}
@@ -310,7 +309,7 @@
trans_exists.swap(i, j);
gtab.swap(i,j);
swap_convex_in_regions(i, j);
- if (Bank_info) Bank_swap_convex(i,j);
+ if (Bank_info.get()) Bank_swap_convex(i,j);
cvs_v_num[i] = cvs_v_num[j] = act_counter(); touch();
}
}
@@ -428,11 +427,9 @@
gmm::uint64_type d = act_counter();
for (dal::bv_visitor i(convex_index()); !i.finished(); ++i)
cvs_v_num[i] = d;
- if (Bank_info) { delete Bank_info; Bank_info = 0; }
- if (m.Bank_info) {
- Bank_info = new Bank_info_struct;
- *Bank_info = *(m.Bank_info);
- }
+ Bank_info = std::unique_ptr<Bank_info_struct>();
+ if (m.Bank_info.get())
+ Bank_info = std::make_unique<Bank_info_struct>(*(m.Bank_info));
}
struct mesh_convex_structure_loc {
@@ -914,7 +911,7 @@
}
void mesh::Bank_sup_convex_from_green(size_type i) {
- if (Bank_info && Bank_info->is_green_simplex.is_in(i)) {
+ if (Bank_info.get() && Bank_info->is_green_simplex.is_in(i)) {
size_type igs = Bank_info->num_green_simplex[i];
green_simplex &gs = Bank_info->green_simplices[igs];
for (size_type j = 0; j < gs.sub_simplices.size(); ++j) {
@@ -926,7 +923,7 @@
}
void mesh::Bank_swap_convex(size_type i, size_type j) {
- if (Bank_info) {
+ if (Bank_info.get()) {
Bank_info->is_green_simplex.swap(i, j);
std::map<size_type, size_type>::iterator
iti = Bank_info->num_green_simplex.find(i);
@@ -1195,7 +1192,7 @@
}
void mesh::Bank_refine(dal::bit_vector b) {
- if (Bank_info == 0) Bank_info = new Bank_info_struct;
+ if (!(Bank_info.get())) Bank_info = std::make_unique<Bank_info_struct>();
b &= convex_index();
if (b.card() == 0) return;
Modified: trunk/getfem/src/getfem_mesh_slicers.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_mesh_slicers.cc?rev=5147&r1=5146&r2=5147&view=diff
==============================================================================
--- trunk/getfem/src/getfem_mesh_slicers.cc (original)
+++ trunk/getfem/src/getfem_mesh_slicers.cc Thu Nov 19 19:27:37 2015
@@ -702,7 +702,7 @@
prev_nrefine = nrefine;
}
if (face < dim_type(-1))
- cvms = bgeot::refined_simplex_mesh_for_convex_faces(cvr,
nrefine)[face];
+ cvms = bgeot::refined_simplex_mesh_for_convex_faces(cvr,
nrefine)[face].get();
else
cvms = cvm;
@@ -848,7 +848,7 @@
}
if (face < dim_type(-1)) {
if (!discont) {
- cvms = bgeot::refined_simplex_mesh_for_convex_faces(cvr,
short_type(nrefine))[face];
+ cvms = bgeot::refined_simplex_mesh_for_convex_faces(cvr,
short_type(nrefine))[face].get();
} else {
cvms = &refined_simplex_mesh_for_convex_faces_cut_by_level_set(face);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] r5147 - in /trunk/getfem/src: ./ getfem/,
Yves . Renard <=