[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] r5208 - in /trunk/getfem/src: getfem/getfem_mesh_fem_gl
From: |
logari81 |
Subject: |
[Getfem-commits] r5208 - in /trunk/getfem/src: getfem/getfem_mesh_fem_global_function.h getfem_mesh_fem_global_function.cc |
Date: |
Thu, 24 Dec 2015 10:09:07 -0000 |
Author: logari81
Date: Thu Dec 24 11:09:07 2015
New Revision: 5208
URL: http://svn.gna.org/viewcvs/getfem?rev=5208&view=rev
Log:
minor changes
Modified:
trunk/getfem/src/getfem/getfem_mesh_fem_global_function.h
trunk/getfem/src/getfem_mesh_fem_global_function.cc
Modified: trunk/getfem/src/getfem/getfem_mesh_fem_global_function.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_mesh_fem_global_function.h?rev=5208&r1=5207&r2=5208&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_mesh_fem_global_function.h (original)
+++ trunk/getfem/src/getfem/getfem_mesh_fem_global_function.h Thu Dec 24
11:09:07 2015
@@ -43,6 +43,7 @@
#include "getfem_generic_assembly.h"
namespace getfem {
+
/// inherit from this class to define new global functions.
struct global_function : virtual public dal::static_stored_object {
virtual scalar_type val(const fem_interpolation_context&) const
@@ -83,12 +84,15 @@
cvr = cvr_;
init();
}
+ virtual ~global_function_fem()
+ { DAL_STORED_OBJECT_DEBUG_DESTROYED(this, "Global function fem"); }
};
pfem new_global_function_fem(bgeot::pconvex_ref cvr,
const std::vector<pglobal_function>& functions);
inline void del_global_function_fem(pfem pf) { dal::del_stored_object(pf); }
+
/** mesh_fem whose base functions are global functions (function
defined on the whole mesh) given by the user. This is much more
@@ -120,8 +124,9 @@
/** a general structure for interpolation of a function defined
by a mesh_fem and a vector U at any point
- (interpolation of value and radient).
+ (interpolation of value and gradient).
*/
+
struct interpolator_on_mesh_fem {
const mesh_fem &mf;
std::vector<scalar_type> U;
@@ -133,28 +138,20 @@
interpolator_on_mesh_fem(const mesh_fem &mf_,
- const std::vector<scalar_type> &U_) :
- mf(mf_), U(U_) {
- if (mf.is_reduced()) {
- gmm::resize(U, mf.nb_basic_dof());
- gmm::mult(mf.extension_matrix(), U_, U);
- }
- init();
- }
-
- void init();
- bool find_a_point(base_node pt, base_node &ptr,
+ const std::vector<scalar_type> &U_);
+ bool find_a_point(const base_node &pt, base_node &ptr,
size_type &cv) const;
- bool eval(const base_node pt, base_vector &val, base_matrix &grad) const;
+ bool eval(const base_node &pt, base_vector &val, base_matrix &grad) const;
};
typedef std::shared_ptr<const interpolator_on_mesh_fem>
pinterpolator_on_mesh_fem;
- /* below a list of simple function of (x,y)
- used for building the crack singular functions
+
+ /** below a list of simple function of (x,y)
+ used for building the crack singular functions
*/
- struct abstract_xy_function : virtual public dal::static_stored_object {
+ struct abstract_xy_function : virtual public dal::static_stored_object {
virtual scalar_type val(scalar_type x, scalar_type y) const = 0;
virtual base_small_vector grad(scalar_type x, scalar_type y) const = 0;
virtual base_matrix hess(scalar_type x, scalar_type y) const = 0;
@@ -215,7 +212,7 @@
virtual base_matrix hess(scalar_type, scalar_type) const
{ GMM_ASSERT1(false, "Sorry, to be done ..."); }
interpolated_xy_function(const pinterpolator_on_mesh_fem &itp_,
- size_type c) :
+ size_type c) :
itp(itp_), component(c) {}
};
@@ -255,9 +252,8 @@
: fn1(fn1_), fn2(fn2_) {}
};
- /*
- * some useful global functions
- */
+
+ /** some useful global functions */
class level_set;
pglobal_function
Modified: trunk/getfem/src/getfem_mesh_fem_global_function.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_mesh_fem_global_function.cc?rev=5208&r1=5207&r2=5208&view=diff
==============================================================================
--- trunk/getfem/src/getfem_mesh_fem_global_function.cc (original)
+++ trunk/getfem/src/getfem_mesh_fem_global_function.cc Thu Dec 24 11:09:07 2015
@@ -142,8 +142,8 @@
parser_xy_function::parser_xy_function(const std::string &sval,
- const std::string &sgrad,
- const std::string &shess)
+ const std::string &sgrad,
+ const std::string &shess)
: f_val(gw_val, sval), f_grad(gw_grad, sgrad), f_hess(gw_hess, shess),
ptx(1), pty(1), ptr(1), ptt(1) {
@@ -151,7 +151,7 @@
gw_val.add_fixed_size_constant("y", pty);
gw_val.add_fixed_size_constant("r", ptr);
gw_val.add_fixed_size_constant("theta", ptt);
-
+
gw_grad.add_fixed_size_constant("x", ptx);
gw_grad.add_fixed_size_constant("y", pty);
gw_grad.add_fixed_size_constant("r", ptr);
@@ -164,7 +164,7 @@
f_val.compile(); f_grad.compile(); f_hess.compile();
}
-
+
scalar_type
parser_xy_function::val(scalar_type x, scalar_type y) const {
ptx[0] = double(x); // x
@@ -224,21 +224,21 @@
scalar_type res = 0;
switch(l){
-
- /* First order enrichement displacement field (linear elasticity) */
-
+
+ /* First order enrichement displacement field (linear elasticity) */
+
case 0 : res = sqrt(r)*sin2; break;
case 1 : res = sqrt(r)*cos2; break;
case 2 : res = sin2*y/sqrt(r); break;
case 3 : res = cos2*y/sqrt(r); break;
-
+
/* Second order enrichement of displacement field (linear elasticity) */
-
+
case 4 : res = sqrt(r)*r*sin2; break;
case 5 : res = sqrt(r)*r*cos2; break;
case 6 : res = sin2*cos2*cos2*r*sqrt(r); break;
case 7 : res = cos2*cos2*cos2*r*sqrt(r); break;
-
+
/* First order enrichement of pressure field (linear elasticity) mixed
formulation */
case 8 : res = -sin2/sqrt(r); break;
@@ -251,14 +251,14 @@
/* First order enrichement of displacement field (nonlinear
elasticity)[Rodney Stephenson Journal of elasticity VOL.12 No. 1, January 1982]
*/
- case 12 : res = r*sin2*sin2; break;
+ case 12 : res = r*sin2*sin2; break;
case 13 : res = sqrt(r)*sin2; break;
/* First order enrichement of pressure field (nonlinear elasticity) */
- case 14 : res = sin2/r; break;
+ case 14 : res = sin2/r; break;
case 15 : res = cos2/r; break;
-
+
default: GMM_ASSERT2(false, "arg");
}
return res;
@@ -299,8 +299,8 @@
res[0] = -cos2*cos2*sin2*((4*cos2*cos2) - 3.)/sqrt(r);
res[1] = cos2*((4*cos2*cos2*cos2*cos2) + 2. - (5*cos2*cos2))/sqrt(r);
break;
- /* Second order enrichement of displacement field (linear elasticity) */
-
+ /* Second order enrichement of displacement field (linear elasticity) */
+
case 4 :
res[0] = sin2 *((4*cos2*cos2)-3.)*sqrt(r)/2.;
res[1] = cos2*(5. - (4*cos2*cos2))*sqrt(r)/2. ;
@@ -309,7 +309,7 @@
res[0] = cos2*((4*cos2*cos2)-1.)*sqrt(r)/2.;
res[1] = sin2*((4*cos2*cos2)+1.)*sqrt(r)/2. ;
break;
-
+
case 6 :
res[0] = sin2*cos2*cos2*sqrt(r)/2.;
res[1] = cos2*(2. - (cos2*cos2))*sqrt(r)/2.;
@@ -318,7 +318,7 @@
res[0] = 3*cos2*cos2*cos2*sqrt(r)/2.;
res[1] = 3*sin2*cos2*cos2*sqrt(r)/2.;
break;
-
+
/* First order enrichement of pressure field (linear elasticity) mixed
formulation */
case 8 :
@@ -339,7 +339,7 @@
res[0] = cos2/(2*sqrt(r));
res[1] = sin2/(2*sqrt(r));
break;
-
+
/* First order enrichement of displacement field (nonlinear
elasticity)[Rodney Stephenson Journal of elasticity VOL.12 No. 1, January 1982]
*/
case 12 :
@@ -575,7 +575,7 @@
void update_mls(size_type cv_) const {
if (cv_ != cv) {
cv=cv_;
- mls_x = ls.mls_of_convex(cv, 1);
+ mls_x = ls.mls_of_convex(cv, 1);
mls_y = ls.mls_of_convex(cv, 0);
}
}
@@ -752,42 +752,54 @@
}
- void interpolator_on_mesh_fem::init() {
- base_node min, max;
+ // interpolator on mesh_fem
+
+ interpolator_on_mesh_fem::interpolator_on_mesh_fem
+ (const mesh_fem &mf_, const std::vector<scalar_type> &U_)
+ : mf(mf_), U(U_) {
+
+ if (mf.is_reduced()) {
+ gmm::resize(U, mf.nb_basic_dof());
+ gmm::mult(mf.extension_matrix(), U_, U);
+ }
+ base_node bmin, bmax;
scalar_type EPS=1E-13;
cv_stored = size_type(-1);
boxtree.clear();
for (dal::bv_visitor cv(mf.convex_index()); !cv.finished(); ++cv) {
- bounding_box(min, max, mf.linked_mesh().points_of_convex(cv),
+ bounding_box(bmin, bmax, mf.linked_mesh().points_of_convex(cv),
mf.linked_mesh().trans_of_convex(cv));
- for (unsigned k=0; k < min.size(); ++k) { min[k]-=EPS; max[k]+=EPS; }
- boxtree.add_box(min, max, cv);
- }
- }
-
- bool interpolator_on_mesh_fem::find_a_point(base_node pt, base_node &ptr,
+ for (auto&& val : bmin) val -= EPS;
+ for (auto&& val : bmax) val += EPS;
+ boxtree.add_box(bmin, bmax, cv);
+ }
+ }
+
+ bool interpolator_on_mesh_fem::find_a_point(const base_node &pt,
+ base_node &ptr,
size_type &cv) const {
bool gt_invertible;
- if (cv_stored != size_type(-1) && gic.invert(pt, ptr, gt_invertible))
- { cv = cv_stored; if (gt_invertible) return true; }
+ if (cv_stored != size_type(-1) && gic.invert(pt, ptr, gt_invertible)) {
+ cv = cv_stored;
+ if (gt_invertible)
+ return true;
+ }
boxtree.find_boxes_at_point(pt, boxlst);
- bgeot::rtree::pbox_set::const_iterator it = boxlst.begin(),
- ite = boxlst.end();
- for (; it != ite; ++it) {
+ for (const auto &box : boxlst) {
gic = bgeot::geotrans_inv_convex
- (mf.linked_mesh().convex((*it)->id),
- mf.linked_mesh().trans_of_convex((*it)->id));
- cv_stored = (*it)->id;
+ (mf.linked_mesh().convex(box->id),
+ mf.linked_mesh().trans_of_convex(box->id));
+ cv_stored = box->id;
if (gic.invert(pt, ptr, gt_invertible)) {
- cv = (*it)->id;
+ cv = box->id;
return true;
}
}
return false;
}
- bool interpolator_on_mesh_fem::eval(const base_node pt, base_vector &val,
+ bool interpolator_on_mesh_fem::eval(const base_node &pt, base_vector &val,
base_matrix &grad) const {
base_node ptref;
size_type cv;
@@ -809,7 +821,8 @@
grad.resize(q, N);
pf->interpolation_grad(fic, coeff, grad, q);
return true;
- } else return false;
+ } else
+ return false;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] r5208 - in /trunk/getfem/src: getfem/getfem_mesh_fem_global_function.h getfem_mesh_fem_global_function.cc,
logari81 <=