[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] [getfem-commits] branch master updated: Whitespace and
From: |
Konstantinos Poulios |
Subject: |
[Getfem-commits] [getfem-commits] branch master updated: Whitespace and other trivial simplifications |
Date: |
Sun, 19 Nov 2023 11:03:41 -0500 |
This is an automated email from the git hooks/post-receive script.
logari81 pushed a commit to branch master
in repository getfem.
The following commit(s) were added to refs/heads/master by this push:
new 3a323649 Whitespace and other trivial simplifications
3a323649 is described below
commit 3a3236490a32cea95fe1b19c744a5dfc09f435c2
Author: Konstantinos Poulios <logari81@gmail.com>
AuthorDate: Sun Nov 19 17:03:23 2023 +0100
Whitespace and other trivial simplifications
---
src/getfem/getfem_mesh_fem_sum.h | 45 +++++++++++-----------
src/getfem_mesh_fem_level_set.cc | 66 ++++++++++++++++-----------------
src/getfem_mesh_fem_sum.cc | 80 ++++++++++++++++++++--------------------
3 files changed, 95 insertions(+), 96 deletions(-)
diff --git a/src/getfem/getfem_mesh_fem_sum.h b/src/getfem/getfem_mesh_fem_sum.h
index b0391cd3..94db97df 100644
--- a/src/getfem/getfem_mesh_fem_sum.h
+++ b/src/getfem/getfem_mesh_fem_sum.h
@@ -42,35 +42,34 @@
#include "getfem_mesh_fem.h"
namespace getfem {
- typedef std::vector<const std::string *> dof_enrichments;
-
+
/** @internal FEM used in mesh_fem_sum objects. */
class fem_sum : public virtual_fem {
std::vector<pfem> pfems; /* the fems to be summed */
bool smart_global_dof_linking_;
size_type cv;
-
+
public:
size_type index_of_global_dof(size_type cv_, size_type j) const;
fem_sum(const std::vector<pfem> &pfs, size_type i,
- bool smart_global_dof_linking)
+ bool smart_global_dof_linking)
: pfems(pfs), smart_global_dof_linking_(smart_global_dof_linking),
- cv(i) { init(); }
+ cv(i) { init(); }
void init();
void valid();
void base_value(const base_node &x, base_tensor &t) const;
void grad_base_value(const base_node &x, base_tensor &t) const;
void hess_base_value(const base_node &x, base_tensor &t) const;
- void real_base_value(const fem_interpolation_context& c,
- base_tensor &t, bool = true) const;
- void real_grad_base_value(const fem_interpolation_context& c,
- base_tensor &t, bool = true) const;
- void real_hess_base_value(const fem_interpolation_context& c,
- base_tensor &t, bool = true) const;
+ void real_base_value(const fem_interpolation_context& c,
+ base_tensor &t, bool = true) const;
+ void real_grad_base_value(const fem_interpolation_context& c,
+ base_tensor &t, bool = true) const;
+ void real_hess_base_value(const fem_interpolation_context& c,
+ base_tensor &t, bool = true) const;
void mat_trans(base_matrix &M, const base_matrix &G,
- bgeot::pgeometric_trans pgt) const;
+ bgeot::pgeometric_trans pgt) const;
};
@@ -88,23 +87,23 @@ namespace getfem {
void clear_build_methods();
public :
- void adapt(void);
- void update_from_context(void) const { is_adapted = false; }
- void clear(void);
-
+ void adapt();
+ void update_from_context() const { is_adapted = false; }
+ void clear();
+
size_type memsize() const {
return mesh_fem::memsize(); // + ... ;
}
-
+
mesh_fem_sum(const mesh &me, bool smart_global_dof_linking = false)
: mesh_fem(me), smart_global_dof_linking_(smart_global_dof_linking)
{ is_adapted = false; }
void set_mesh_fems(const std::vector<const mesh_fem *> &mefs)
{ mfs = mefs; adapt(); }
- /** enabled "smart" dof linking between the mesh_fems.
- It was introduced for the point-wise matching part of
- tests/crack.cc but it does not work with discontinuous global
- functions...
+ /** enabled "smart" dof linking between the mesh_fems.
+ It was introduced for the point-wise matching part of
+ tests/crack.cc but it does not work with discontinuous global
+ functions...
*/
void set_smart_global_dof_linking(bool b)
{ smart_global_dof_linking_ = b; }
@@ -113,7 +112,7 @@ namespace getfem {
void set_mesh_fems(const mesh_fem &mf1, const mesh_fem &mf2)
{ mfs.clear(); mfs.push_back(&mf1); mfs.push_back(&mf2); adapt(); }
void set_mesh_fems(const mesh_fem &mf1, const mesh_fem &mf2,
- const mesh_fem &mf3) {
+ const mesh_fem &mf3) {
mfs.clear();
mfs.push_back(&mf1); mfs.push_back(&mf2); mfs.push_back(&mf3);
adapt();
@@ -126,4 +125,4 @@ namespace getfem {
} /* end of namespace getfem. */
#endif
-
+
diff --git a/src/getfem_mesh_fem_level_set.cc b/src/getfem_mesh_fem_level_set.cc
index 0fa492f6..64677420 100644
--- a/src/getfem_mesh_fem_level_set.cc
+++ b/src/getfem_mesh_fem_level_set.cc
@@ -22,35 +22,35 @@
#include "getfem/getfem_mesh_fem_level_set.h"
namespace getfem {
-
+
void mesh_fem_level_set::clear_build_methods() {
for (size_type i = 0; i < build_methods.size(); ++i)
del_stored_object(build_methods[i]);
build_methods.clear();
}
- void mesh_fem_level_set::clear(void) {
+ void mesh_fem_level_set::clear() {
mesh_fem::clear();
clear_build_methods();
is_adapted = false;
}
-
+
mesh_fem_level_set::mesh_fem_level_set(const mesh_level_set &me,
- const mesh_fem &mef)
+ const mesh_fem &mef)
: mesh_fem(mef.linked_mesh()), mls(me), mf(mef) {
xfem_index = reserve_xfem_index();
GMM_ASSERT1(mf.get_qdim() == 1, "base mesh_fem for mesh_fem_level_set has "
- "to be of qdim one for the moment ...");
+ "to be of qdim one for the moment ...");
this->add_dependency(mls);
is_adapted = false;
}
-
+
DAL_SIMPLE_KEY(special_mfls_key, pfem);
void mesh_fem_level_set::build_method_of_convex(size_type cv) {
pfem pf = std::make_shared<fem_level_set>
(gmm::index_ref_iterator(dof_enrichments.begin(),
- mf.ind_basic_dof_of_element(cv).begin()) ,
+ mf.ind_basic_dof_of_element(cv).begin()) ,
mf.fem_of_element(cv), mls, xfem_index);
dal::pstatic_stored_object_key
pk = std::make_shared<special_mfls_key>(pf);
@@ -58,13 +58,13 @@ namespace getfem {
build_methods.push_back(pf);
set_finite_element(cv, pf);
}
-
- void mesh_fem_level_set::adapt(void) {
+
+ void mesh_fem_level_set::adapt() {
context_check();
clear();
GMM_ASSERT1(!mf.is_reduced(), "Mesh fem level set not defined for reduced "
- "mesh fems (difficult or impossible to define it in the "
- "general case)");
+ "mesh fems (difficult or impossible to define it in the "
+ "general case)");
enriched_dofs.clear(); enriched_elements.clear();
dof_enrichments.resize(0);
dof_enrichments.resize(mf.nb_basic_dof(), 0);
@@ -73,29 +73,29 @@ namespace getfem {
const mesh::ind_cv_ct &ct = mf.convex_to_basic_dof(i);
bool touch_cut = false;
for (mesh::ind_cv_ct::const_iterator it = ct.begin();
- it != ct.end(); ++it)
- if (mls.is_convex_cut(*it)) { touch_cut = true; break; }
-
+ it != ct.end(); ++it)
+ if (mls.is_convex_cut(*it)) { touch_cut = true; break; }
+
if (touch_cut) {
- mesh_level_set::zoneset zones;
-
- for (mesh::ind_cv_ct::const_iterator it = ct.begin();
- it != ct.end(); ++it) {
- if (mls.is_convex_cut(*it)) {
- mls.merge_zoneset(zones, mls.zoneset_of_convex(*it));
- }
- else {
- mls.merge_zoneset(zones, mls.primary_zone_of_convex(*it));
- }
- }
-
- if (zones.size() != 1) {
- dof_enrichments[i] = &(*(enrichments.insert(zones).first));
- enriched_dofs.add(i);
- for (mesh::ind_cv_ct::const_iterator it = ct.begin();
- it != ct.end(); ++it) enriched_elements.add(*it);
- }
+ mesh_level_set::zoneset zones;
+
+ for (mesh::ind_cv_ct::const_iterator it = ct.begin();
+ it != ct.end(); ++it) {
+ if (mls.is_convex_cut(*it)) {
+ mls.merge_zoneset(zones, mls.zoneset_of_convex(*it));
+ }
+ else {
+ mls.merge_zoneset(zones, mls.primary_zone_of_convex(*it));
+ }
+ }
+
+ if (zones.size() != 1) {
+ dof_enrichments[i] = &(*(enrichments.insert(zones).first));
+ enriched_dofs.add(i);
+ for (mesh::ind_cv_ct::const_iterator it = ct.begin();
+ it != ct.end(); ++it) enriched_elements.add(*it);
+ }
}
}
@@ -104,7 +104,7 @@ namespace getfem {
for (dal::bv_visitor i(mf.convex_index()); !i.finished(); ++i) {
if (enriched_elements[i]) build_method_of_convex(i); else
- set_finite_element(i, mf.fem_of_element(i));
+ set_finite_element(i, mf.fem_of_element(i));
}
is_adapted = true; touch();
}
diff --git a/src/getfem_mesh_fem_sum.cc b/src/getfem_mesh_fem_sum.cc
index fc07c46c..7c53b832 100644
--- a/src/getfem_mesh_fem_sum.cc
+++ b/src/getfem_mesh_fem_sum.cc
@@ -23,7 +23,7 @@
#include "getfem/getfem_mesh_fem_sum.h"
namespace getfem {
-
+
void fem_sum::init() {
cvr = pfems[0]->ref_convex(cv);
dim_ = cvr->structure()->dim();
@@ -39,7 +39,7 @@ namespace getfem {
nm << pfems[i]->debug_name() << ",";
nm << " cv:" << cv << ")";
debug_name_ = nm.str();
-
+
init_cvs_node();
for (size_type i = 0; i < pfems.size(); ++i) {
GMM_ASSERT1(pfems[i]->target_dim() == 1, "Vectorial fems not supported");
@@ -55,7 +55,7 @@ namespace getfem {
const base_matrix &G,
bgeot::pgeometric_trans pgt) const {
- // cerr << "fem_sum::mat_trans " << debug_name_
+ // cerr << "fem_sum::mat_trans " << debug_name_
// << " / smart_global_dof_linking_ = " << smart_global_dof_linking_
// << "\n";
pdof_description gdof = 0, lagdof = lagrange_dof(dim());
@@ -66,7 +66,7 @@ namespace getfem {
gmm::copy(gmm::identity_matrix(), M);
base_vector val(1), val2(1);
base_matrix grad(1, dim());
-
+
// very inefficient, to be optimized ...
for (size_type ifem1 = 0, i=0; ifem1 < pfems.size(); ++ifem1) {
pfem pf1 = pfems[ifem1];
@@ -95,10 +95,10 @@ namespace getfem {
pfems[ifem2]->interpolation(fic2, coeff2, val2, 1);
M(i, j) = -val[0]*val2[0];
- /*if (pf2->nb_dof(cv) > 4)
- cout << "dof " << idof2 << " ("
- << pf2->node_of_dof(cv,idof2)
- << ") " << (void*)&(*pdd)
+ /*if (pf2->nb_dof(cv) > 4)
+ cout << "dof " << idof2 << " ("
+ << pf2->node_of_dof(cv,idof2)
+ << ") " << (void*)&(*pdd)
<< " compatible with lagrange\n";*/
found = true;
}
@@ -121,7 +121,7 @@ namespace getfem {
}
}
}
-
+
// static int cnt=0;
// if(++cnt < 40) cout << "fem = " << debug_name_ << ", M = " << M << "\n";
}
@@ -135,18 +135,18 @@ namespace getfem {
GMM_ASSERT1(false, "incoherent global dof.");
}
- void fem_sum::base_value(const base_node &,
+ void fem_sum::base_value(const base_node &,
base_tensor &) const
{ GMM_ASSERT1(false, "No base values, real only element."); }
- void fem_sum::grad_base_value(const base_node &,
+ void fem_sum::grad_base_value(const base_node &,
base_tensor &) const
{ GMM_ASSERT1(false, "No base values, real only element."); }
- void fem_sum::hess_base_value(const base_node &,
+ void fem_sum::hess_base_value(const base_node &,
base_tensor &) const
{ GMM_ASSERT1(false, "No base values, real only element."); }
void fem_sum::real_base_value(const fem_interpolation_context &c,
- base_tensor &t,
+ base_tensor &t,
bool withM) const {
bgeot::multi_index mi(2);
mi[1] = target_dim(); mi[0] = short_type(nb_dof(0));
@@ -162,7 +162,7 @@ namespace getfem {
} else { c0.set_pf(pfems[k]); }
c0.base_value(val_e[k]);
}
-
+
for (dim_type q = 0; q < target_dim(); ++q) {
for (size_type k = 0; k < pfems.size(); ++k) {
itf = val_e[k].begin() + q * pfems[k]->nb_dof(cv);
@@ -171,9 +171,9 @@ namespace getfem {
}
}
assert(it == t.end());
- if (!is_equivalent() && withM) {
- base_tensor tt(t);
- t.mat_transp_reduction(tt, c.M(), 0);
+ if (!is_equivalent() && withM) {
+ base_tensor tt(t);
+ t.mat_transp_reduction(tt, c.M(), 0);
}
//cerr << "fem_sum::real_base_value(" << c.xreal() << ")\n";
}
@@ -185,7 +185,7 @@ namespace getfem {
mi[0] = short_type(nb_dof(0));
t.adjust_sizes(mi);
base_tensor::iterator it = t.begin(), itf;
-
+
fem_interpolation_context c0 = c;
std::vector<base_tensor> grad_e(pfems.size());
for (size_type k = 0; k < pfems.size(); ++k) {
@@ -200,24 +200,24 @@ namespace getfem {
for (dim_type q = 0; q < target_dim(); ++q) {
for (size_type f = 0; f < pfems.size(); ++f) {
itf = grad_e[f].begin()
- + (k * target_dim() + q) * pfems[f]->nb_dof(cv);
+ + (k * target_dim() + q) * pfems[f]->nb_dof(cv);
for (size_type i = 0; i < pfems[f]->nb_dof(cv); ++i)
*it++ = *itf++;
}
}
}
assert(it == t.end());
- if (!is_equivalent() && withM) {
- base_tensor tt(t);
- t.mat_transp_reduction(tt, c.M(), 0);
+ if (!is_equivalent() && withM) {
+ base_tensor tt(t);
+ t.mat_transp_reduction(tt, c.M(), 0);
}
}
-
+
void fem_sum::real_hess_base_value(const fem_interpolation_context &c,
base_tensor &t, bool withM) const {
t.adjust_sizes(nb_dof(0), target_dim(), gmm::sqr(c.N()));
base_tensor::iterator it = t.begin(), itf;
-
+
fem_interpolation_context c0 = c;
std::vector<base_tensor> hess_e(pfems.size());
for (size_type k = 0; k < pfems.size(); ++k) {
@@ -231,15 +231,15 @@ namespace getfem {
dim_type NNdim = dim_type(gmm::sqr(c.N())*target_dim());
for (dim_type jkq = 0; jkq < NNdim ; ++jkq) {
for (size_type f = 0; f < pfems.size(); ++f) {
- itf = hess_e[f].begin() + (jkq * pfems[f]->nb_dof(cv));
+ itf = hess_e[f].begin() + (jkq * pfems[f]->nb_dof(cv));
for (size_type i = 0; i < pfems[f]->nb_dof(cv); ++i)
*it++ = *itf++;
}
}
assert(it == t.end());
- if (!is_equivalent() && withM) {
- base_tensor tt(t);
- t.mat_transp_reduction(tt, c.M(), 0);
+ if (!is_equivalent() && withM) {
+ base_tensor tt(t);
+ t.mat_transp_reduction(tt, c.M(), 0);
}
}
@@ -248,29 +248,29 @@ namespace getfem {
del_stored_object(build_methods[i]);
build_methods.clear();
}
- void mesh_fem_sum::clear(void) {
+ void mesh_fem_sum::clear() {
mesh_fem::clear();
clear_build_methods();
situations.clear();
is_adapted = false;
}
-
+
DAL_SIMPLE_KEY(special_mflsum_key, pfem);
-
- void mesh_fem_sum::adapt(void) {
+
+ void mesh_fem_sum::adapt() {
context_check();
clear();
- for (size_type i = 0; i < mfs.size(); ++i)
- GMM_ASSERT1(!(mfs[i]->is_reduced()),
+ for (const mesh_fem *pmf : mfs)
+ GMM_ASSERT1(!(pmf->is_reduced()),
"Sorry fem_sum for reduced mesh_fem is not implemented");
for (dal::bv_visitor i(linked_mesh().convex_index()); !i.finished(); ++i) {
std::vector<pfem> pfems;
bool is_cv_dep = false;
- for (size_type j = 0; j < mfs.size(); ++j) {
- if (mfs[j]->convex_index().is_in(i)) {
- pfem pf = mfs[j]->fem_of_element(i);
+ for (const mesh_fem *pmf : mfs) {
+ if (pmf->convex_index().is_in(i)) {
+ pfem pf = pmf->fem_of_element(i);
if (pf->nb_dof(i)) {
pfems.push_back(pf);
if (pf->is_on_real_element()) is_cv_dep = true;
@@ -283,9 +283,9 @@ namespace getfem {
else if (pfems.size() > 0) {
if (situations.find(pfems) == situations.end() || is_cv_dep) {
pfem pf = std::make_shared<fem_sum>(pfems, i,
- smart_global_dof_linking_);
- dal::pstatic_stored_object_key
- pk = std::make_shared<special_mflsum_key>(pf);
+ smart_global_dof_linking_);
+ dal::pstatic_stored_object_key
+ pk = std::make_shared<special_mflsum_key>(pf);
dal::add_stored_object(pk, pf, pf->ref_convex(0), pf->node_tab(0));
build_methods.push_back(pf);
situations[pfems] = pf;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] [getfem-commits] branch master updated: Whitespace and other trivial simplifications,
Konstantinos Poulios <=