[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] r5141 - in /trunk/getfem/src: ./ getfem/
From: |
Yves . Renard |
Subject: |
[Getfem-commits] r5141 - in /trunk/getfem/src: ./ getfem/ |
Date: |
Tue, 17 Nov 2015 18:16:33 -0000 |
Author: renard
Date: Tue Nov 17 19:16:32 2015
New Revision: 5141
URL: http://svn.gna.org/viewcvs/getfem?rev=5141&view=rev
Log:
dynamic allocation changes
Modified:
trunk/getfem/src/bgeot_geometric_trans.cc
trunk/getfem/src/getfem/bgeot_convex_structure.h
trunk/getfem/src/getfem/bgeot_geometric_trans.h
trunk/getfem/src/getfem/bgeot_tensor.h
trunk/getfem/src/getfem_integration_composite.cc
Modified: trunk/getfem/src/bgeot_geometric_trans.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/bgeot_geometric_trans.cc?rev=5141&r1=5140&r2=5141&view=diff
==============================================================================
--- trunk/getfem/src/bgeot_geometric_trans.cc (original)
+++ trunk/getfem/src/bgeot_geometric_trans.cc Tue Nov 17 19:16:32 2015
@@ -328,7 +328,7 @@
double(n) == params[0].num() && double(k) == params[1].num(),
"Bad parameters");
dependencies.push_back(simplex_of_reference(dim_type(n), dim_type(k)));
- return pgeometric_trans(new simplex_trans_(dim_type(n), dim_type(k)));
+ return std::make_shared<simplex_trans_>(dim_type(n), dim_type(k));
}
/* ******************************************************************** */
@@ -371,7 +371,7 @@
= dynamic_cast<const poly_geometric_trans *>(b.get());
GMM_ASSERT1(aa && bb, "The product of geometric transformations "
"is only defined for polynomial ones");
- return pgeometric_trans(new cv_pr_t_(aa, bb));
+ return std::make_shared<cv_pr_t_>(aa, bb);
}
/* ******************************************************************** */
@@ -422,7 +422,7 @@
= dynamic_cast<const poly_geometric_trans *>(b.get());
GMM_ASSERT1(aa && bb, "The product of geometric transformations "
"is only defined for polynomial ones");
- return pgeometric_trans(new cv_pr_tl_(aa, bb));
+ return std::make_shared<cv_pr_tl_>(aa, bb);
}
/* ******************************************************************** */
@@ -540,13 +540,14 @@
static pgeometric_trans
Q2_incomplete_gt(gt_param_list& params,
std::vector<dal::pstatic_stored_object> &dependencies) {
- GMM_ASSERT1(params.size() == 1, "Bad number of parameters : " <<
params.size() << " should be 1.");
+ GMM_ASSERT1(params.size() == 1, "Bad number of parameters : "
+ << params.size() << " should be 1.");
GMM_ASSERT1(params[0].type() == 0, "Bad type of parameters");
int n = int(::floor(params[0].num() + 0.01));
GMM_ASSERT1(n == 2 || n == 3, "Bad parameter, expected value 2 or 3");
dependencies.push_back(Q2_incomplete_reference(dim_type(n)));
- return pgeometric_trans(new Q2_incomplete_trans_(dim_type(n)));
+ return std::make_shared<Q2_incomplete_trans_>(dim_type(n));
}
pgeometric_trans Q2_incomplete_geotrans(dim_type nc) {
@@ -802,7 +803,7 @@
dal::pstatic_stored_object_key pk=
std::make_shared<pre_geot_key_>(pg,pspt);
dal::pstatic_stored_object o = dal::search_stored_object(pk);
if (o) return std::dynamic_pointer_cast<const geotrans_precomp_>(o);
- pgeotrans_precomp p(new geotrans_precomp_(pg, pspt));
+ pgeotrans_precomp p = std::make_shared<geotrans_precomp_>(pg, pspt);
dal::add_stored_object(pk, p, pg, pspt, dal::AUTODELETE_STATIC_OBJECT);
if (dep) dal::add_dependency(p, dep);
return p;
Modified: trunk/getfem/src/getfem/bgeot_convex_structure.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/bgeot_convex_structure.h?rev=5141&r1=5140&r2=5141&view=diff
==============================================================================
--- trunk/getfem/src/getfem/bgeot_convex_structure.h (original)
+++ trunk/getfem/src/getfem/bgeot_convex_structure.h Tue Nov 17 19:16:32 2015
@@ -133,8 +133,10 @@
if (pprod2) *pprod2 = prod_b;
return prod_a ? true : false;
}
+ explicit convex_structure(bool auto_b)
+ : auto_basic(auto_b), prod_a(0), prod_b(0) { }
protected:
- convex_structure() { prod_a = prod_b = 0; auto_basic = false; }
+ convex_structure() : auto_basic(false), prod_a(0), prod_b(0) { }
friend std::shared_ptr<convex_structure> new_convex_structure();
friend pconvex_structure basic_structure(pconvex_structure cv);
};
@@ -144,7 +146,7 @@
{ if (cv->auto_basic) return cv; else return cv->basic_pcvs; }
inline std::shared_ptr<convex_structure> new_convex_structure()
- { return std::shared_ptr<convex_structure>(new convex_structure); }
+ { return std::make_shared<convex_structure>(false); }
/** @name functions on convex structures
*/
Modified: trunk/getfem/src/getfem/bgeot_geometric_trans.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/bgeot_geometric_trans.h?rev=5141&r1=5140&r2=5141&view=diff
==============================================================================
--- trunk/getfem/src/getfem/bgeot_geometric_trans.h (original)
+++ trunk/getfem/src/getfem/bgeot_geometric_trans.h Tue Nov 17 19:16:32 2015
@@ -310,7 +310,6 @@
pgeometric_trans get_trans() const { return pgt; }
// inline const stored_point_tab& get_point_tab() const { return *pspt; }
inline pstored_point_tab get_ppoint_tab() const { return pspt; }
- protected:
geotrans_precomp_(pgeometric_trans pg, pstored_point_tab ps);
private:
Modified: trunk/getfem/src/getfem/bgeot_tensor.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/bgeot_tensor.h?rev=5141&r1=5140&r2=5141&view=diff
==============================================================================
--- trunk/getfem/src/getfem/bgeot_tensor.h (original)
+++ trunk/getfem/src/getfem/bgeot_tensor.h Tue Nov 17 19:16:32 2015
@@ -312,45 +312,49 @@
/* reduction du tenseur t par son indice ni et la matrice */
/* transposee de m. */
- DEFINE_STATIC_THREAD_LOCAL(std::vector<T>*,tmp);
- DEFINE_STATIC_THREAD_LOCAL(multi_index*,mi);
- DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(bool,isinit,false);
-
- if (!isinit) {
- tmp = new std::vector<T>(3); mi = new multi_index(); isinit = true;
- }
-
- *mi = t.sizes();
- size_type dimt = (*mi)[ni], dim = m.nrows();
+ // DEFINE_STATIC_THREAD_LOCAL(std::vector<T>*,tmp);
+ // DEFINE_STATIC_THREAD_LOCAL(multi_index*,mi);
+ DEFINE_STATIC_THREAD_LOCAL(std::vector<T>, tmp);
+ DEFINE_STATIC_THREAD_LOCAL(multi_index, mi);
+ // DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(bool,isinit,false);
+
+ // if (!isinit) {
+ // tmp = std::make_shared<std::vector<T>(3);
+ // mi = std::make_shared<multi_index>();
+ // isinit = true;
+ // }
+
+ mi = t.sizes();
+ size_type dimt = mi[ni], dim = m.nrows();
GMM_ASSERT2(dimt, "Inconsistent dimension.");
GMM_ASSERT2(dimt == m.ncols(), "Dimensions mismatch.");
GMM_ASSERT2(&t != this, "Does not work when t and *this are the same.");
- (*mi)[ni] = dim;
- if (tmp->size() < dimt) tmp->resize(dimt);
- adjust_sizes(*mi);
+ mi[ni] = dim;
+ if (tmp.size() < dimt) tmp.resize(dimt);
+ adjust_sizes(mi);
const_iterator pft = t.begin();
iterator pf = this->begin();
size_type dd = coeff[ni]*( sizes()[ni]-1)-1, co = coeff[ni];
size_type ddt = t.coeff[ni]*(t.sizes()[ni]-1)-1, cot = t.coeff[ni];
- std::fill(mi->begin(), mi->end(), 0);
- for (;!mi->finished(sizes()); mi->incrementation(sizes()), ++pf, ++pft) {
- if ((*mi)[ni] != 0) {
+ std::fill(mi.begin(), mi.end(), 0);
+ for (;!mi.finished(sizes()); mi.incrementation(sizes()), ++pf, ++pft) {
+ if (mi[ni] != 0) {
for (size_type k = 0; k <= size_type(ni); ++k)
- (*mi)[k] = size_type(sizes()[k] - 1);
+ mi[k] = size_type(sizes()[k] - 1);
pf += dd; pft += ddt;
} else {
- const_iterator pl = pft; iterator pt = tmp->begin();
+ const_iterator pl = pft; iterator pt = tmp.begin();
*pt++ = *pl;
for(size_type k = 1; k < dimt; ++k, ++pt) { pl += cot; *pt = *pl;}
iterator pff = pf;
for (size_type k = 0; k < dim; ++k) {
if (k) pff += co;
- *pff = T(0); pt = tmp->begin(); pl = m.begin() + k;
+ *pff = T(0); pt = tmp.begin(); pl = m.begin() + k;
*pff += (*pl) * (*pt); ++pt;
for (size_type l = 1; l < dimt; ++l, ++pt) {
pl += dim;
@@ -385,41 +389,43 @@
template<class T> void tensor<T>::mat_reduction
(const tensor &t, const gmm::dense_matrix<T> &m, int ni) {
/* reduction du tenseur t par son indice ni et la matrice m. */
- DEFINE_STATIC_THREAD_LOCAL(std::vector<T>*,tmp);
- DEFINE_STATIC_THREAD_LOCAL(multi_index*,mi);
- DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(bool,isinit,false);
- if (!isinit) {
- tmp = new std::vector<T>(3); mi = new multi_index(); isinit = true;
- }
- *mi = t.sizes();
- size_type dimt = (*mi)[ni], dim = m.ncols();
+ // DEFINE_STATIC_THREAD_LOCAL(std::vector<T>*,tmp);
+ // DEFINE_STATIC_THREAD_LOCAL(multi_index*,mi);
+ // DEFINE_STATIC_THREAD_LOCAL_INITIALIZED(bool,isinit,false);
+ DEFINE_STATIC_THREAD_LOCAL(std::vector<T>, tmp);
+ DEFINE_STATIC_THREAD_LOCAL(multi_index, mi);
+ // if (!isinit) {
+ // tmp = new std::vector<T>(3); mi = new multi_index(); isinit = true;
+ // }
+ mi = t.sizes();
+ size_type dimt = mi[ni], dim = m.ncols();
GMM_ASSERT2(dimt, "Inconsistent dimension.");
GMM_ASSERT2(dimt == m.nrows(), "Dimensions mismatch.");
GMM_ASSERT2(&t != this, "Does not work when t and *this are the same.");
- (*mi)[ni] = dim;
- if (tmp->size() < dimt) tmp->resize(dimt);
- adjust_sizes(*mi);
+ mi[ni] = dim;
+ if (tmp.size() < dimt) tmp.resize(dimt);
+ adjust_sizes(mi);
const_iterator pft = t.begin();
iterator pf = this->begin();
size_type dd = coeff[ni]*( sizes()[ni]-1)-1, co = coeff[ni];
size_type ddt = t.coeff[ni]*(t.sizes()[ni]-1)-1, cot = t.coeff[ni];
- std::fill(mi->begin(), mi->end(), 0);
- for (;!mi->finished(sizes()); mi->incrementation(sizes()), ++pf, ++pft) {
- if ((*mi)[ni] != 0) {
+ std::fill(mi.begin(), mi.end(), 0);
+ for (;!mi.finished(sizes()); mi.incrementation(sizes()), ++pf, ++pft) {
+ if (mi[ni] != 0) {
for (size_type k = 0; k <= size_type(ni); ++k)
- (*mi)[k] = size_type(sizes()[k] - 1);
+ mi[k] = size_type(sizes()[k] - 1);
pf += dd; pft += ddt;
}
else {
- const_iterator pl = pft; iterator pt = tmp->begin();
+ const_iterator pl = pft; iterator pt = tmp.begin();
*pt++ = *pl;
for(size_type k = 1; k < dimt; ++k, ++pt) { pl += cot; *pt = *pl; }
iterator pff = pf; pl = m.begin();
for (size_type k = 0; k < dim; ++k) {
if (k) pff += co;
- *pff = T(0); pt = tmp->begin();
+ *pff = T(0); pt = tmp.begin();
for (size_type l = 0; l < dimt; ++l, ++pt, ++pl)
*pff += (*pl) * (*pt);
}
Modified: trunk/getfem/src/getfem_integration_composite.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_integration_composite.cc?rev=5141&r1=5140&r2=5141&view=diff
==============================================================================
--- trunk/getfem/src/getfem_integration_composite.cc (original)
+++ trunk/getfem/src/getfem_integration_composite.cc Tue Nov 17 19:16:32 2015
@@ -98,9 +98,9 @@
mi.set_integration_method(pm->convex_index(), pim);
pintegration_method
- p(new integration_method
- (composite_approx_int_method(*pmp, mi,
- pim->approx_method()->ref_convex())));
+ p = std::make_shared<integration_method>
+ (composite_approx_int_method(*pmp, mi,
+ pim->approx_method()->ref_convex()));
dependencies.push_back(p->approx_method()->ref_convex());
dependencies.push_back(p->approx_method()->pintegration_points());
return p;
@@ -136,10 +136,10 @@
mesh_im mi(jfs.m);
mi.set_integration_method(jfs.m.convex_index(), pim);
- pintegration_method
- p(new integration_method
- (composite_approx_int_method(jfs.mp, mi,
- pim->approx_method()->ref_convex())));
+ pintegration_method
+ p = std::make_shared<integration_method>
+ (composite_approx_int_method(jfs.mp, mi,
+ pim->approx_method()->ref_convex()));
dependencies.push_back(p->approx_method()->ref_convex());
dependencies.push_back(p->approx_method()->pintegration_points());
return p;
@@ -176,9 +176,9 @@
mi.set_integration_method(jfs.m.convex_index(), pim);
pintegration_method
- p(new integration_method
- (composite_approx_int_method(jfs.mp, mi,
- bgeot::parallelepiped_of_reference(2))));
+ p = std::make_shared<integration_method>
+ (composite_approx_int_method(jfs.mp, mi,
+ bgeot::parallelepiped_of_reference(2)));
dependencies.push_back(p->approx_method()->ref_convex());
dependencies.push_back(p->approx_method()->pintegration_points());
return p;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] r5141 - in /trunk/getfem/src: ./ getfem/,
Yves . Renard <=