29 #ifdef EXPERIMENTAL_PURPOSE_ONLY
32 void error_estimate_nitsche(
const mesh_im & mim,
41 scalar_type vertical_force,
48 const mesh &m = mf_u.linked_mesh();
52 std::vector<scalar_type> coeff1, coeff2;
53 base_matrix grad1(qdim, N), grad2(qdim, N), E(N, N), S1(N, N), S2(N, N);
54 base_matrix hess1(qdim, N*N);
58 base_small_vector up(N), jump(N), U1(N), sig(N), sigt(N);
60 scalar_type Pr, scal, sign, Un ;
61 scalar_type eta1 = 0, eta2 = 0, eta3 = 0, eta4 = 0;
62 scalar_type force_coeff= f_coeff;
67 base_small_vector F(N);
68 for (
unsigned ii=0; ii < N-1; ++ii) F[ii]=0;
69 F[N-1]=-vertical_force;
71 GMM_ASSERT1(!mf_u.is_reduced(),
"To be adapted");
73 for (dal::bv_visitor cv(m.convex_index()); !cv.finished(); ++cv) {
76 getfem::papprox_integration pai1 =
77 get_approx_im_or_fail(mim.int_method_of_element(cv));
79 scalar_type radius = m.convex_radius_estimate(cv);
80 m.points_of_convex(cv, G1);
81 coeff1.resize(mf_u.nb_basic_dof_of_element(cv));
82 gmm::copy(gmm::sub_vector(U, gmm::sub_index(mf_u.ind_basic_dof_of_element(cv))), coeff1);
87 for (
unsigned ii=0; ii < pai1->nb_points_on_convex(); ++ii) {
88 base_small_vector res(N);
89 ctx1.set_xref(pai1->point(ii));
90 pf1->interpolation_hess(ctx1, coeff1, hess1, dim_type(qdim));
94 res[i] += (lambda + mu) * hess1(j, i*N+j) + mu * hess1(i, j*N+j)+F[i];
105 for (
short_type f1=0; f1 < m.structure_of_convex(cv)->nb_faces(); ++f1) {
107 size_type cvn = m.neighbor_of_convex(cv, f1);
112 m.points_of_convex(cvn, G2);
113 coeff2.resize(mf_u.nb_basic_dof_of_element(cvn));
114 gmm::copy(gmm::sub_vector(U, gmm::sub_index(mf_u.ind_basic_dof_of_element(cvn))), coeff2);
116 gic.init(m.points_of_convex(cvn), pgt2);
117 for (
unsigned ii=0; ii < pai1->nb_points_on_face(f1); ++ii) {
119 ctx1.set_xref(pai1->point_on_face(f1, ii));
120 gmm::mult(ctx1.B(), pgt1->normals()[f1], up);
123 scalar_type coefficient = pai1->coeff_on_face(f1, ii) * ctx1.J() * norm;
124 pf1->interpolation_grad(ctx1, coeff1, grad1, dim_type(qdim));
129 gmm::scale(S1, lambda * trace);
132 gic.
invert(ctx1.xreal(), xref2, converged);
133 GMM_ASSERT1(converged,
"geometric transformation not well inverted ... !");
134 ctx2.set_xref(xref2);
135 pf2->interpolation_grad(ctx2, coeff2, grad2, dim_type(qdim));
140 gmm::scale(S2, lambda * trace);
166 getfem::papprox_integration pai1 =
167 get_approx_im_or_fail(mim.int_method_of_element(v.cv()));
169 scalar_type radius = m.convex_radius_estimate(v.cv());
171 m.points_of_convex(v.cv(), G1);
173 coeff1.resize(mf_u.nb_basic_dof_of_element(v.cv()));
174 gmm::copy(gmm::sub_vector(U, gmm::sub_index(mf_u.ind_basic_dof_of_element(v.cv()))), coeff1);
180 for (
unsigned ii=0; ii < pai1->nb_points_on_face(f); ++ii) {
182 ctx1.set_xref(pai1->point_on_face(f, ii));
183 gmm::mult(ctx1.B(), pgt1->normals()[f], up);
186 scalar_type coefficient = pai1->coeff_on_face(f, ii) * ctx1.J() * norm;
187 pf1->interpolation_grad(ctx1, coeff1, grad1, dim_type(qdim));
192 gmm::scale(S1, lambda * trace);
216 getfem::papprox_integration pai1 =
217 get_approx_im_or_fail(mim.int_method_of_element(v.cv()));
220 m.points_of_convex(v.cv(), G1);
222 coeff1.resize(mf_u.nb_basic_dof_of_element(v.cv()));
223 gmm::copy(gmm::sub_vector(U, gmm::sub_index(mf_u.ind_basic_dof_of_element(v.cv()))), coeff1);
232 scalar_type radius = m.convex_radius_estimate(v.cv());
233 scalar_type gamma=radius*gamma0;
235 for (
unsigned ii=0; ii < pai1->nb_points_on_face(f); ++ii) {
237 ctx1.set_xref(pai1->point_on_face(f, ii));
238 gmm::mult(ctx1.B(), pgt1->normals()[f], up);
241 scalar_type coefficient = pai1->coeff_on_face(f, ii) * ctx1.J() * norm;
242 pf1->interpolation_grad(ctx1, coeff1, grad1, dim_type(qdim));
243 pf1->interpolation(ctx1, coeff1, U1, dim_type(qdim));
248 gmm::scale(S1, lambda * trace);
253 scal = Un-gamma*sign;
257 Pr = (scal/gamma + sign);
258 ERR[v.cv()] += coefficient*radius*Pr*Pr;
259 eta4 += coefficient*radius* Pr*Pr;
262 gmm::scale(sigt, - sign);
276 cout <<
"eta1, eta2, eta3, eta4 = " << endl;
277 cout << sqrt(eta1) << endl;
278 cout << sqrt(eta2) << endl;
279 cout << sqrt(eta3) << endl;
280 cout << sqrt(eta4) << endl;
281 cout << sqrt(eta1+eta2+eta3+eta4) << endl;
does the inversion of the geometric transformation for a given convex
bool invert(const base_node &n, base_node &n_ref, scalar_type IN_EPS=1e-12, bool project_into_element=false)
given the node on the real element, returns the node on the reference element (even if it is outside ...
structure passed as the argument of fem interpolation functions.
"iterator" class for regions.
structure used to hold a set of convexes and/or convex faces.
Definition of a posteriori error estimates.
void mult_add(const L1 &l1, const L2 &l2, L3 &l3)
*/
void copy(const L1 &l1, L2 &l2)
*/
number_traits< typename linalg_traits< V >::value_type >::magnitude_type vect_norm2(const V &v)
Euclidean norm of a vector.
linalg_traits< M >::value_type mat_trace(const M &m)
Trace of a matrix.
number_traits< typename linalg_traits< V >::value_type >::magnitude_type vect_norm2_sqr(const V &v)
squared Euclidean norm of a vector.
void clear(L &l)
clear (fill with zeros) a vector or matrix.
void mult(const L1 &l1, const L2 &l2, L3 &l3)
*/
strongest_value_type< V1, V2 >::value_type vect_sp(const V1 &v1, const V2 &v2)
*/
void add(const L1 &l1, L2 &l2)
*/
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
gmm::uint16_type short_type
used as the common short type integer in the library
size_t size_type
used as the common size type in the library
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation
GEneric Tool for Finite Element Methods.