[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] [getfem-commits] branch master updated: Whitespace fixe
From: |
Konstantinos Poulios |
Subject: |
[Getfem-commits] [getfem-commits] branch master updated: Whitespace fixes and remove redundant header includes |
Date: |
Wed, 20 Dec 2023 19:54:51 -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 bb58bbc6 Whitespace fixes and remove redundant header includes
bb58bbc6 is described below
commit bb58bbc67ca817436cbf53150607576f06efaa11
Author: Konstantinos Poulios <logari81@gmail.com>
AuthorDate: Thu Dec 21 01:54:41 2023 +0100
Whitespace fixes and remove redundant header includes
---
contrib/crack_plate/crack_bilaplacian_problem.cc | 334 +++--
contrib/icare/icare.cc | 1335 ++++++++++----------
contrib/xfem_contact/xfem_stokes.cc | 572 ++++-----
.../xfem_stab_unilat_contact.cc | 710 +++++------
interface/src/getfemint_levelset.cc | 1 -
interface/src/getfemint_precond.h | 43 +-
interface/src/gf_global_function.cc | 1 -
interface/src/gf_levelset.cc | 1 -
interface/src/gf_linsolve.cc | 1 -
src/getfem_assembling_tensors.cc | 1 -
src/getfem_contact_and_friction_large_sliding.cc | 1 -
tests/gmm_torture05_mult.cc | 52 +-
tests/gmm_torture10_qr.cc | 73 +-
tests/laplacian.cc | 50 +-
tests/schwarz_additive.cc | 18 +-
15 files changed, 1516 insertions(+), 1677 deletions(-)
diff --git a/contrib/crack_plate/crack_bilaplacian_problem.cc
b/contrib/crack_plate/crack_bilaplacian_problem.cc
index b3a2a0a7..d6fc76d9 100644
--- a/contrib/crack_plate/crack_bilaplacian_problem.cc
+++ b/contrib/crack_plate/crack_bilaplacian_problem.cc
@@ -52,7 +52,7 @@ scalar_type CC = DD * (nu + 7.)/ (3. * (nu - 1.)) ;
scalar_type EE = 0.0 ; // singul 61
scalar_type FF = 0.0 ; // singul 62
scalar_type GG = 0.0 ; // singul 63
-scalar_type HH = 0.0 ; //3.0 // singul 6
+scalar_type HH = 0.0 ; //3.0 // singul 6
scalar_type P0 = 0.0 ;
scalar_type P1 = 0.0 ;
@@ -67,7 +67,7 @@ scalar_type sol_u(const base_node &x){
}
scalar_type sol_F(const base_node &)
-{return 1. ;//EE * D * 240. ;//256. * cos(2. * x[1]) ;
+{return 1. ;//EE * D * 240. ;//256. * cos(2. * x[1]) ;
}
void exact_solution_bilap::init(getfem::level_set &ls) {
@@ -76,7 +76,7 @@ void exact_solution_bilap::init(getfem::level_set &ls) {
cfun[j] = bilaplacian_crack_singular(j, ls, nu, 0.) ;
cfun[4] = bilaplacian_crack_singular(61, ls, nu, 0.) ;
cfun[5] = bilaplacian_crack_singular(62, ls, nu, 0.) ;
- cfun[6] = bilaplacian_crack_singular(63, ls, nu, 0.) ;
+ cfun[6] = bilaplacian_crack_singular(63, ls, nu, 0.) ;
cfun[7] = bilaplacian_crack_singular(6, ls, nu, 0.) ;
cfun[8] = bilaplacian_crack_singular(10, ls, nu, 0.) ;
cfun[9] = bilaplacian_crack_singular(11, ls, nu, 0.) ;
@@ -101,13 +101,13 @@ void exact_solution_bilap::init(getfem::level_set &ls) {
-scalar_type eval_fem_gradient_with_finite_differences(getfem::pfem pf,
+scalar_type eval_fem_gradient_with_finite_differences(getfem::pfem pf,
const base_vector &coeff,
size_type cv,
- bgeot::pgeometric_trans pgt,
+ bgeot::pgeometric_trans pgt,
bgeot::geotrans_inv_convex &gic,
- const base_matrix &G,
- base_node X0,
+ const base_matrix &G,
+ base_node X0,
scalar_type h, unsigned dg) {
X0[dg] -= h/2;
base_node X0ref; gic.invert(X0, X0ref);
@@ -126,26 +126,26 @@ scalar_type
eval_fem_gradient_with_finite_differences(getfem::pfem pf,
return (val1[0] - val0[0])/h;
}
-scalar_type eval_fem_hessian_with_finite_differences(getfem::pfem pf,
+scalar_type eval_fem_hessian_with_finite_differences(getfem::pfem pf,
const base_vector &coeff,
- size_type cv,
- bgeot::pgeometric_trans pgt,
+ size_type cv,
+ bgeot::pgeometric_trans pgt,
bgeot::geotrans_inv_convex &gic,
- const base_matrix &G,
- base_node X0,
- scalar_type h,
+ const base_matrix &G,
+ base_node X0,
+ scalar_type h,
unsigned dg, unsigned dh) {
X0[dh] -= h/2;
- scalar_type Gr0 =
+ scalar_type Gr0 =
eval_fem_gradient_with_finite_differences(pf, coeff, cv, pgt, gic, G, X0,
h, dg);
base_node X1(X0);
X1[dh] += h;
- scalar_type Gr1 =
+ scalar_type Gr1 =
eval_fem_gradient_with_finite_differences(pf, coeff, cv, pgt, gic, G, X1,
h, dg);
return (Gr1 - Gr0)/h;
}
-void validate_fem_derivatives(getfem::pfem pf, unsigned cv,
+void validate_fem_derivatives(getfem::pfem pf, unsigned cv,
bgeot::pgeometric_trans pgt, const base_matrix
&G) {
unsigned N = unsigned(gmm::mat_nrows(G));
scalar_type h = 1e-5;
@@ -158,23 +158,23 @@ void validate_fem_derivatives(getfem::pfem pf, unsigned
cv,
bgeot::geotrans_inv_convex gic(pts, pgt);
//cout << "pts = " << pts << "\n";
-
- for (unsigned idof = 0; idof < pf->nb_dof(cv); ++idof) {
+
+ for (unsigned idof = 0; idof < pf->nb_dof(cv); ++idof) {
/* choose a random point in the convex */
base_node X0(N), X0ref;
base_node w(pgt->nb_points());
do {
- for (unsigned i=0; i < w.size(); ++i) w[i] = 0.1 + 0.8*gmm::random();
+ for (unsigned i=0; i < w.size(); ++i) w[i] = 0.1 + 0.8*gmm::random();
gmm::scale(w, 1/gmm::vect_norm1(w));
gmm::mult(G, w, X0);
//cout << "w = " << w << "\n";
-
+
gic.invert(X0, X0ref);
-
+
// avoid discontinuity lines in the HCT composite element..
if (gmm::abs(X0ref[0] + X0ref[1] - 1) > 1e-2 &&
- gmm::abs(X0ref[0] - X0ref[1]) > 1e-2 &&
+ gmm::abs(X0ref[0] - X0ref[1]) > 1e-2 &&
gmm::abs(X0[0]) > 1e-3 && gmm::abs(X0[1])> 1e-3) break;
} while (1);
//cout << "testing X0 = " << X0 << " (X0ref=" << X0ref << ")\n";
@@ -189,19 +189,19 @@ void validate_fem_derivatives(getfem::pfem pf, unsigned
cv,
pf->interpolation_hess(c, coeff, hess, 1);
for (unsigned dg = 0; dg < N; ++dg) {
- grad_fd[dg] =
+ grad_fd[dg] =
eval_fem_gradient_with_finite_differences(pf, coeff, cv, pgt, gic, G,
X0, h, dg);
for (unsigned dh = 0; dh < N; ++dh) {
- hess_fd(0,dg*N+dh) =
+ hess_fd(0,dg*N+dh) =
eval_fem_hessian_with_finite_differences(pf, coeff, cv, pgt, gic, G,
X0, h, dg, dh);
}
}
-
- scalar_type err_grad =
+
+ scalar_type err_grad =
gmm::vect_dist2((base_vector&)grad, (base_vector&)grad_fd);
- scalar_type err_hess =
+ scalar_type err_hess =
gmm::vect_dist2((base_vector&)hess, (base_vector&)hess_fd);
-
+
if (err_grad > 1e-4 ||
err_hess > 1e-4) {
cout << "validate_fem_derivatives dof=" << idof << "/" << pf->nb_dof(cv)
<< " -- X0ref = " << X0ref << "\n";
@@ -271,23 +271,23 @@ void bilaplacian_crack_problem::init(void) {
tt[0] -= PARAM.real_value("CRACK_SEMI_LENGTH") ;
}
cout << "TRANSLAT_X = " << tt[0] << " ; TRANSLAT_Y = " << tt[1] << "\n" ;
- mesh.translation(tt);
+ mesh.translation(tt);
MESH_TYPE = bgeot::name_of_geometric_trans
(mesh.trans_of_convex(mesh.convex_index().first_true()));
- bgeot::pgeometric_trans pgt =
+ bgeot::pgeometric_trans pgt =
bgeot::geometric_trans_descriptor(MESH_TYPE);
cout << "MESH_TYPE=" << MESH_TYPE << "\n";
N = mesh.dim();
- }
+ }
else {
- bgeot::pgeometric_trans pgt =
+ bgeot::pgeometric_trans pgt =
bgeot::geometric_trans_descriptor(MESH_TYPE);
N = pgt->dim();
GMM_ASSERT1(N == 2, "For a plate problem, N should be 2");
std::vector<size_type> nsubdiv(N);
NX = PARAM.int_value("NX", "Number of space steps ") ;
std::fill(nsubdiv.begin(),nsubdiv.end(), NX);
- if (sol_ref == 1) nsubdiv[0] = NX / 2 ;
+ if (sol_ref == 1) nsubdiv[0] = NX / 2 ;
if (sol_ref == 2) {
size_type NY = PARAM.int_value("NY") ;
nsubdiv[1] = NY ;
@@ -313,9 +313,9 @@ void bilaplacian_crack_problem::init(void) {
tt[0] = - 0.5 + PARAM.real_value("TRANSLAT_X") ;
tt[1] = - 0.5 + PARAM.real_value("TRANSLAT_Y") ;
} break ;
- default :
+ default :
GMM_ASSERT1(false, "SOL_REF parameter is undefined");
- break ;
+ break ;
}
mesh.translation(tt);
bgeot::base_matrix M(N,N);
@@ -328,15 +328,15 @@ void bilaplacian_crack_problem::init(void) {
M(1, 1) = 1.0 ;
}
if (sol_ref == 0 || sol_ref == 3){
- M(0, 0) = cos(angle_rot) ; M(1, 1) = M(0, 0) ;
+ M(0, 0) = cos(angle_rot) ; M(1, 1) = M(0, 0) ;
M(1, 0) = sin(angle_rot) ; M(0, 1) = - M(1, 0) ;
}
mesh.transformation(M);
}
-
+
scalar_type quality = 1.0, avg_area = 0. , min_area = 1. , max_area = 0.,
area ;
scalar_type radius, avg_radius = 0., min_radius = 1., max_radius = 0. ;
- size_type cpt = 0 ;
+ size_type cpt = 0 ;
for (dal::bv_visitor i(mesh.convex_index()); !i.finished(); ++i){
quality = std::min(quality, mesh.convex_quality_estimate(i));
area = mesh.convex_area_estimate(i) ;
@@ -344,25 +344,25 @@ void bilaplacian_crack_problem::init(void) {
avg_area += area ;
avg_radius += radius ;
min_radius = std::min(radius, min_radius) ;
- max_radius = std::max(radius, max_radius) ;
- min_area = std::min(min_area, area) ;
+ max_radius = std::max(radius, max_radius) ;
+ min_area = std::min(min_area, area) ;
max_area = std::max(max_area, area) ;
cpt++ ;
}
avg_area /= scalar_type(cpt) ;
- avg_radius /= scalar_type(cpt) ;
+ avg_radius /= scalar_type(cpt) ;
/* cout << "quality of mesh : " << quality << endl;
cout << "average radius : " << avg_radius << endl;
cout << "radius min : " << min_radius << " ; radius max : " << max_radius
<< endl;
cout << "average area : " << avg_area << endl ;
- cout << "area min : " << min_area << " ; area max : " << max_area << endl;
*/
-
+ cout << "area min : " << min_area << " ; area max : " << max_area << endl;
*/
+
/* read the parameters */
epsilon = PARAM.real_value("EPSILON", "thickness") ;
nu = PARAM.real_value("NU", "nu") ;
D = PARAM.real_value("D", "Flexure modulus") ;
int mv = int(PARAM.int_value("MORTAR_VERSION", "Mortar version") );
- int cv = int(PARAM.int_value("CLOSING_VERSION") );
+ int cv = int(PARAM.int_value("CLOSING_VERSION") );
mortar_version = size_type(mv);
closing_version = size_type(cv);
datafilename=PARAM.string_value("ROOTFILENAME","Base name of data files.");
@@ -370,7 +370,7 @@ void bilaplacian_crack_problem::init(void) {
KL = PARAM.int_value("KL", "Kirchhoff-Love model or not") != 0;
D = PARAM.real_value("D", "Flexion modulus");
if (KL) nu = PARAM.real_value("NU", "Poisson ratio");
-
+
cutoff.fun_num = PARAM.int_value("CUTOFF_FUNC", "cutoff function");
cutoff.radius = PARAM.real_value("CUTOFF", "Cutoff");
cutoff.radius1 = PARAM.real_value("CUTOFF1", "Cutoff1");
@@ -379,9 +379,9 @@ void bilaplacian_crack_problem::init(void) {
// Setting the integration methods
getfem::pfem pf_u = getfem::fem_descriptor(FEM_TYPE);
- getfem::pintegration_method ppi =
+ getfem::pintegration_method ppi =
getfem::int_method_descriptor(INTEGRATION);
- getfem::pintegration_method sppi =
+ getfem::pintegration_method sppi =
getfem::int_method_descriptor(SIMPLEX_INTEGRATION);
getfem::pintegration_method sing_ppi = (SINGULAR_INTEGRATION.size() ?
getfem::int_method_descriptor(SINGULAR_INTEGRATION) : 0);
@@ -390,8 +390,8 @@ void bilaplacian_crack_problem::init(void) {
mls.add_level_set(ls);
mim.set_simplex_im(sppi, sing_ppi);
- /* Setting the finite element on the mf_u */
- mf_pre_u.set_finite_element(mesh.convex_index(), pf_u);
+ /* Setting the finite element on the mf_u */
+ mf_pre_u.set_finite_element(mesh.convex_index(), pf_u);
getfem::pfem pf_partition_of_unity =
getfem::fem_descriptor(PARAM.string_value("PARTITION_OF_UNITY_FEM_TYPE")) ;
mf_partition_of_unity.set_finite_element(mesh.convex_index(),
pf_partition_of_unity);
@@ -401,7 +401,7 @@ void bilaplacian_crack_problem::init(void) {
mf_mult.set_finite_element(mesh.convex_index(), pf_u);
else {
cout << "DIRICHLET_FEM_TYPE=" << dirichlet_fem_name << "\n";
- mf_mult.set_finite_element(mesh.convex_index(),
+ mf_mult.set_finite_element(mesh.convex_index(),
getfem::fem_descriptor(dirichlet_fem_name));
}
std::string dirichlet_der_fem_name
@@ -410,7 +410,7 @@ void bilaplacian_crack_problem::init(void) {
mf_mult_d.set_finite_element(mesh.convex_index(), pf_u);
else {
cout << "DIRICHLET_DER_FEM_TYPE=" << dirichlet_der_fem_name << "\n";
- mf_mult_d.set_finite_element(mesh.convex_index(),
+ mf_mult_d.set_finite_element(mesh.convex_index(),
getfem::fem_descriptor(dirichlet_der_fem_name));
}
@@ -423,11 +423,11 @@ void bilaplacian_crack_problem::init(void) {
<< "DATA_FEM_TYPE in the .param file");
mf_rhs.set_finite_element(mesh.convex_index(), pf_u);
} else {
- mf_rhs.set_finite_element(mesh.convex_index(),
+ mf_rhs.set_finite_element(mesh.convex_index(),
getfem::fem_descriptor(data_fem_name));
}
- // set the mesh_fem for the multipliers for the case the Integral Matching
+ // set the mesh_fem for the multipliers for the case the Integral Matching
mf_pre_mortar.set_finite_element(mesh.convex_index(),
getfem::fem_descriptor(PARAM.string_value("MORTAR_FEM_TYPE")));
mf_pre_mortar_deriv.set_finite_element(mesh.convex_index(),
@@ -443,7 +443,7 @@ void bilaplacian_crack_problem::init(void) {
un /= gmm::vect_norm2(un);
if ( gmm::abs(un[0]) >= 0.9999 ) { // vertical edges
mesh.region(SIMPLE_SUPPORT_BOUNDARY_NUM).add(i.cv(), i.f());
- mesh.region(CLAMPED_BOUNDARY_NUM).add(i.cv(), i.f());
+ mesh.region(CLAMPED_BOUNDARY_NUM).add(i.cv(), i.f());
}
else{ // horizontal edges
unsigned id_point_1_of_face, id_point_2_of_face ;
@@ -463,8 +463,8 @@ void bilaplacian_crack_problem::init(void) {
}
}
}
-
-
+
+
if (sol_ref == 1 ){
for (getfem::mr_visitor i(border_faces); !i.finished(); ++i) {
base_node un = mesh.normal_of_face_of_convex(i.cv(), i.f());
@@ -472,12 +472,12 @@ void bilaplacian_crack_problem::init(void) {
if ( (un[0] <= -0.9999) || (un[0] >= 0.9999) ) {
//if ( -un[0] >= 0.999 ) {
mesh.region(CLAMPED_BOUNDARY_NUM).add(i.cv(), i.f());
-
+
}
if (gmm::abs(un[1]) >= 0.999) {
mesh.region(SIMPLE_SUPPORT_BOUNDARY_NUM).add(i.cv(), i.f());
mesh.region(MOMENTUM_BOUNDARY_NUM).add(i.cv(), i.f());
- }
+ }
}
}
@@ -487,16 +487,16 @@ void bilaplacian_crack_problem::init(void) {
un /= gmm::vect_norm2(un);
if (un[0] < - 0.9999) { // symetry condition
mesh.region(CLAMPED_BOUNDARY_NUM).add(i.cv(), i.f());
- }
+ }
else{
mesh.region(SIMPLE_SUPPORT_BOUNDARY_NUM).add(i.cv(), i.f());
mesh.region(MOMENTUM_BOUNDARY_NUM).add(i.cv(), i.f());
}
}
}
-
- if (sol_ref == 0 && angle_rot != 0. ){
- // does not support the case of a conformal mesh around the crack
+
+ if (sol_ref == 0 && angle_rot != 0. ){
+ // does not support the case of a conformal mesh around the crack
// (all the boundary, including the crack faces, will be clamped).
for (getfem::mr_visitor i(border_faces); !i.finished(); ++i) {
mesh.region(CLAMPED_BOUNDARY_NUM).add(i.cv(), i.f());
@@ -505,12 +505,12 @@ void bilaplacian_crack_problem::init(void) {
}
exact_sol.init(ls);
-
+
cout << "initialisation de la level-set : \n" ;
-
+
// Setting the level-set
- ls.reinit();
- // scalar_type a = PARAM.real_value("CRACK_SEMI_LENGTH") ;
+ ls.reinit();
+ // scalar_type a = PARAM.real_value("CRACK_SEMI_LENGTH") ;
for (size_type d = 0; d < ls.get_mesh_fem().nb_dof(); ++d) {
scalar_type x = ls.get_mesh_fem().point_of_basic_dof(d)[0];
scalar_type y = ls.get_mesh_fem().point_of_basic_dof(d)[1];
@@ -527,7 +527,7 @@ void bilaplacian_crack_problem::init(void) {
}
}
//ls.simplify(0.5);
- ls.touch();
+ ls.touch();
mls.adapt();
mim.adapt();
mfls_u.adapt();
@@ -549,10 +549,10 @@ void bilaplacian_crack_problem::init(void) {
// cout << "L2 error = " << getfem::asm_L2_norm(mim, mf_rhs, V) << endl
// << "H1 error = " << getfem::asm_H1_norm(mim, mf_rhs, V) << endl
// << "H2 error = " << getfem::asm_H2_norm(mim, mf_rhs, V) << endl
-// /*<< "Linfty error = " << gmm::vect_norminf(V) << endl*/;
-// cout << "semi-norme H1 = " << getfem::asm_H1_semi_norm(mim, mf_rhs, V)
<< endl
+// /*<< "Linfty error = " << gmm::vect_norminf(V) << endl*/;
+// cout << "semi-norme H1 = " << getfem::asm_H1_semi_norm(mim, mf_rhs, V)
<< endl
// << "semi-norme H2 = " << getfem::asm_H2_semi_norm(mim, mf_rhs, V)
<< endl ;
-//
+//
// }
/* compute the error with respect to the exact solution */
@@ -569,14 +569,14 @@ void
bilaplacian_crack_problem::compute_error(plain_vector &U) {
<< getfem::asm_H1_dist(mim, mf_u(), U,
exact_sol.mf, exact_sol.U) << "\n";
cout << "H2 ERROR:"
- << getfem::asm_H2_dist(mim, mf_u(), U,
- exact_sol.mf, exact_sol.U) << "\n";
+ << getfem::asm_H2_dist(mim, mf_u(), U,
+ exact_sol.mf, exact_sol.U) << "\n";
// cout << "SEMI H1 ERROR:"
-// << getfem::asm_H1_semi_dist(mim, mf_u(), U,
-// exact_sol.mf, exact_sol.U) << "\n";
+// << getfem::asm_H1_semi_dist(mim, mf_u(), U,
+// exact_sol.mf, exact_sol.U) << "\n";
// cout << "SEMI H2 ERROR:"
-// << getfem::asm_H2_semi_dist(mim, mf_u(), U,
-// exact_sol.mf, exact_sol.U) << "\n";
+// << getfem::asm_H2_semi_dist(mim, mf_u(), U,
+// exact_sol.mf, exact_sol.U) << "\n";
if ( PARAM.int_value("NORM_EXACT") ){
cout << "L2 exact:"
<< getfem::asm_L2_dist(mim, mf_u(), V,
@@ -585,9 +585,9 @@ void bilaplacian_crack_problem::compute_error(plain_vector
&U) {
<< getfem::asm_H1_dist(mim, mf_u(), V,
exact_sol.mf, exact_sol.U) << "\n";
cout << "H2 exact:"
- << getfem::asm_H2_dist(mim, mf_u(), V,
+ << getfem::asm_H2_dist(mim, mf_u(), V,
exact_sol.mf, exact_sol.U) << "\n";
- }
+ }
}
else {
getfem::mesh_region r_center, r_ext ;
@@ -595,15 +595,15 @@ void
bilaplacian_crack_problem::compute_error(plain_vector &U) {
bool in_area ;
for (dal::bv_visitor cv(mesh.convex_index()) ; !cv.finished() ; ++cv){
in_area = true;
- /* For each element, we test all of its nodes.
+ /* For each element, we test all of its nodes.
If all the nodes are inside the enrichment area,
- then the element is completly inside the area too */
+ then the element is completly inside the area too */
for (unsigned j=0; j < mesh.nb_points_of_convex(cv); ++j) {
- if (gmm::sqr(mesh.points_of_convex(cv)[j][0] ) +
- gmm::sqr(mesh.points_of_convex(cv)[j][1] ) >
- gmm::sqr(radius_split_domain))
+ if (gmm::sqr(mesh.points_of_convex(cv)[j][0] ) +
+ gmm::sqr(mesh.points_of_convex(cv)[j][1] ) >
+ gmm::sqr(radius_split_domain))
in_area = false;
- break;
+ break;
}
if (in_area) r_center.add(cv) ;
else r_ext.add(cv) ;
@@ -617,8 +617,8 @@ void bilaplacian_crack_problem::compute_error(plain_vector
&U) {
cout << " H1 error:" << H1_center << "\n";
H2_center = getfem::asm_H2_dist(mim, mf_u(), U, exact_sol.mf,
exact_sol.U, r_center) ;
cout << " H2 error:" << H2_center << "\n";
-
- cout << "Error on the remaining part of the domain:\n";
+
+ cout << "Error on the remaining part of the domain:\n";
scalar_type L2_ext, H1_ext, H2_ext;
L2_ext = getfem::asm_L2_dist(mim, mf_u(), U, exact_sol.mf,
exact_sol.U, r_ext) ;
cout << " L2 error:" << L2_ext << "\n";
@@ -646,7 +646,7 @@ void bilaplacian_crack_problem::compute_error(plain_vector
&U) {
/**************************************************************************/
bool bilaplacian_crack_problem::solve(plain_vector &U) {
-
+
if (enrichment_option == 2 || enrichment_option == 3){
cout << "setting singularities \n" ;
if (PARAM.int_value("SING_BASE_TYPE") == 0){
@@ -677,7 +677,7 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
with a cutoff */
getfem::pxy_function
cc = std::make_shared<getfem::cutoff_xy_function>
- (int(cutoff.fun_num), cutoff.radius, cutoff.radius1,
+ (int(cutoff.fun_num), cutoff.radius, cutoff.radius1,
cutoff.radius0);
s = std::make_shared<getfem::product_of_xy_functions>(s, cc);
vfunc[i] = getfem::global_function_on_level_set(ls, s);
@@ -695,7 +695,7 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
with a cutoff */
getfem::pxy_function
cc = std::make_shared<getfem::cutoff_xy_function>
- (int(cutoff.fun_num), cutoff.radius, cutoff.radius1,
+ (int(cutoff.fun_num), cutoff.radius, cutoff.radius1,
cutoff.radius0);
s = std::make_shared<getfem::product_of_xy_functions>(s, cc);
vfunc[i] = getfem::global_function_on_level_set(ls, s);
@@ -704,7 +704,7 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
}
}
// Setting the enrichment --------------------------------------------/
-
+
switch(enrichment_option) {
case -1: // classical FEM
{
@@ -723,31 +723,31 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
std::fill(UU.begin(), UU.end() ,0.) ;
cout << "exporting mesh to " << "mesh_representation.vtk" << "..\n";
getfem::vtk_export exp("mesh_representation.vtk", false);
- exp.exporting(mf_enrich);
+ exp.exporting(mf_enrich);
exp.write_point_data(mf_enrich, UU, "mesh");
cout << "export done, you can view the data file with (for example)\n"
"mayavi -d mesh_representation.vtk -f "
"WarpScalar -m BandedSurfaceMap -m Outline\n";}
}
break ;
- case 1 :
+ case 1 :
{
cout << "\npointwise matching\n";
- /* first : selecting the convexes that are completly included in the
enrichment area */
+ /* first : selecting the convexes that are completly included in the
enrichment area */
for (dal::bv_visitor i(mesh.convex_index()); !i.finished(); ++i) {
pm_convexes.add(i) ;
- /* For each element, we test all of its nodes.
+ /* For each element, we test all of its nodes.
If all the nodes are inside the enrichment area,
- then the element is completly inside the area too */
+ then the element is completly inside the area too */
for (unsigned j=0; j < mesh.nb_points_of_convex(i); ++j) {
- if (gmm::sqr(mesh.points_of_convex(i)[j][0]) +
- gmm::sqr(mesh.points_of_convex(i)[j][1]) >
- gmm::sqr(enr_area_radius))
+ if (gmm::sqr(mesh.points_of_convex(i)[j][0]) +
+ gmm::sqr(mesh.points_of_convex(i)[j][1]) >
+ gmm::sqr(enr_area_radius))
pm_convexes.sup(i);
break;
}
}
-
+
for (dal::bv_visitor cv(mf_sing_u.convex_index()); !cv.finished(); ++cv)
{
if (!pm_convexes.is_in(cv))
mf_sing_u.set_finite_element(cv, 0);
@@ -761,7 +761,7 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
cout << "mf_u_sum.nb_dof = " << mf_u_sum.nb_dof() << "\n";
cout << "mfls_u.convex_index = " << mfls_u.convex_index() <<
"\nmf_sing_u: " << mf_sing_u.convex_index() << "\n";
-
+
} break ;
case 2 : // standard XFEM on a fixed zone
{
@@ -769,9 +769,9 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
plain_vector X(mf_partition_of_unity.nb_dof());
plain_vector Y(mf_partition_of_unity.nb_dof());
getfem::interpolation(ls.get_mesh_fem(), mf_partition_of_unity,
- ls.values(1), X);
+ ls.values(1), X);
getfem::interpolation(ls.get_mesh_fem(), mf_partition_of_unity,
- ls.values(0), Y);
+ ls.values(0), Y);
for (size_type j = 0; j < mf_partition_of_unity.nb_dof(); ++j) {
if (gmm::sqr(X[j]) + gmm::sqr(Y[j]) <= gmm::sqr(enr_area_radius))
enriched_dofs.add(j);
@@ -792,41 +792,41 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
// dal::bit_vector enriched_dofs;
// enriched_dofs.clear() ;
// cout << "mf_cutoff.nb_dof() = " << mf_cutoff.nb_dof() << "\n" ;
-//
+//
// for (size_type j = 0; j < mf_cutoff.nb_dof(); ++j) {
// enriched_dofs.add(j);
// }
// for (dal::bv_visitor j(enriched_dofs) ; !j.finished() ; ++j){
-// cout << j << " ; " ;
+// cout << j << " ; " ;
// }
// cout << "\n" ;
// cout << "mf_prod_cutoff.nb_dof() = " << mf_prod_cutoff.nb_dof() <<
"\n" ;
// cout << "mf_sing_u.nb_dof() = " << mf_sing_u.nb_dof() << "\n" ;
// mf_prod_cutoff.set_enrichment(enriched_dofs) ;
-//
+//
// cout << "mf_prod_cutoff.nb_dof() = " << mf_prod_cutoff.nb_dof() <<
"\n" ;
-
+
//mf_u_sum.set_mesh_fems(mf_prod_cutoff, mfls_u);
mf_u_sum.set_mesh_fems(mf_sing_u, mfls_u);
} break;
case 3 : // Integral matching (mortar)
{
- cout << "\nIntegral Matching (Mortar)\n" ;
+ cout << "\nIntegral Matching (Mortar)\n" ;
dal::bit_vector cvlist_in_area, cvlist_out_area;
bool in_area = true;
- for (dal::bv_visitor cv(mesh.convex_index());
+ for (dal::bv_visitor cv(mesh.convex_index());
!cv.finished(); ++cv) {
in_area = true;
- /* For each element, we test all of its nodes.
+ /* For each element, we test all of its nodes.
If all the nodes are inside the enrichment area,
- then the element is completly inside the area too */
+ then the element is completly inside the area too */
for (unsigned j=0; j < mesh.nb_points_of_convex(cv); ++j) {
-// if (gmm::sqr(mesh.points_of_convex(cv)[j][0] ) +
-// gmm::sqr(mesh.points_of_convex(cv)[j][1] ) >
+// if (gmm::sqr(mesh.points_of_convex(cv)[j][0] ) +
+// gmm::sqr(mesh.points_of_convex(cv)[j][1] ) >
// gmm::sqr(enr_area_radius)) {
- if ( (gmm::abs(mesh.points_of_convex(cv)[j][0] ) > enr_area_radius)
||
+ if ( (gmm::abs(mesh.points_of_convex(cv)[j][0] ) > enr_area_radius)
||
(gmm::abs(mesh.points_of_convex(cv)[j][1] ) > enr_area_radius))
{
- in_area = false;
+ in_area = false;
break;
}
}
@@ -839,16 +839,16 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
mf_u().set_dof_partition(cv, 1);
} else cvlist_in_area.add(cv);
}
-
+
/* extract the boundary of the enrichment area, from the
"inside" point-of-view, and from the "outside"
point-of-view */
getfem::mesh_region r_border, r_enr_out;
getfem::outer_faces_of_mesh(mesh, r_border);
- getfem::outer_faces_of_mesh(mesh, cvlist_in_area,
+ getfem::outer_faces_of_mesh(mesh, cvlist_in_area,
mesh.region(MORTAR_BOUNDARY_IN));
- getfem::outer_faces_of_mesh(mesh, cvlist_out_area,
+ getfem::outer_faces_of_mesh(mesh, cvlist_out_area,
mesh.region(MORTAR_BOUNDARY_OUT));
for (getfem::mr_visitor v(r_border); !v.finished(); ++v) {
mesh.region(MORTAR_BOUNDARY_OUT).sup(v.cv(), v.f());
@@ -857,14 +857,14 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
mf_u_sum.set_mesh_fems(mfls_u);
else
mf_u_sum.set_mesh_fems(mf_sing_u, mfls_u);
-
+
//cout << "cvlist_in_area: " << cvlist_in_area << "\n";
cout << "mfls_u.nb_dof: " << mfls_u.nb_dof() << "\n";
cout << "mf_u_sum.nb_dof: " << mf_u_sum.nb_dof() << "\n";
//cout << "MORTAR_BOUNDARY_IN: " << mesh.region(MORTAR_BOUNDARY_IN) <<
"\n";
//cout << "MORTAR_BOUNDARY_OUT: " << mesh.region(MORTAR_BOUNDARY_OUT) <<
"\n";
-
- // an optional treatment : creating a representation of the enrichment
area
+
+ // an optional treatment : creating a representation of the enrichment
area
getfem::mesh_fem mf_enrich(mesh);
for (dal::bv_visitor i(mesh.convex_index()) ; !i.finished() ; ++i){
getfem::pfem pf_mef = getfem::classical_fem(mesh.trans_of_convex(i),
1 );
@@ -874,23 +874,23 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
std::fill(UU.begin(), UU.end() ,0.) ;
cout << "exporting the enrichment zone: \n" ;
GMM_ASSERT1(!mf_enrich.is_reduced(), "To be adapted");
- for (dal::bv_visitor i(cvlist_in_area) ; !i.finished() ; ++i){
+ for (dal::bv_visitor i(cvlist_in_area) ; !i.finished() ; ++i){
for (unsigned int j = 0 ;
- j < mf_enrich.ind_basic_dof_of_element(i).size() ; ++j )
- UU[mf_enrich.ind_basic_dof_of_element(i)[j]] = 1. ;
+ j < mf_enrich.ind_basic_dof_of_element(i).size() ; ++j )
+ UU[mf_enrich.ind_basic_dof_of_element(i)[j]] = 1. ;
}
-
+
cout << "exporting enrichment to " << "enrichment_zone.vtk" << "..\n";
getfem::vtk_export exp("enrichment_zone.vtk", false);
- exp.exporting(mf_enrich);
+ exp.exporting(mf_enrich);
exp.write_point_data(mf_enrich, UU, "enrichment");
cout << "export done, you can view the data file with (for example)\n"
"mayavi -d enrichment_zone.vtk -f "
"WarpScalar -m BandedSurfaceMap -m Outline\n";
-
+
// // Another optional treatment :
// // Searching the elements that are both crossed by the crack
-// // and with one of their faces which constitutes a part of the
+// // and with one of their faces which constitutes a part of the
// // boundary between the enriched zone and the rest of the domain.
// getfem::mesh_region &boundary = mesh.region(MORTAR_BOUNDARY_IN);
// unsigned int cpt = 0 ;
@@ -912,18 +912,18 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
} // end of "enrichment_option = 3"
break ;
- default :
+ default :
GMM_ASSERT1(false, "Enrichment_option parameter is undefined");
- break ;
+ break ;
} // end of switch
mesh.write_to_file("toto.mesh");
if (PARAM.int_value("SHOW_NAME_OF_DOF")==1) { // printing the type of each
dof
unsigned Q = mf_u().get_qdim();
- GMM_ASSERT1(!mf_u().is_reduced(), "To be adapted");
+ GMM_ASSERT1(!mf_u().is_reduced(), "To be adapted");
for (unsigned d=0; d < mf_u().nb_dof(); d += Q) {
- printf("dof %4d @ %+6.2f:%+6.2f: ", d,
+ printf("dof %4d @ %+6.2f:%+6.2f: ", d,
mf_u().point_of_basic_dof(d)[0], mf_u().point_of_basic_dof(d)[1]);
const getfem::mesh::ind_cv_ct cvs = mf_u().convex_to_basic_dof(d);
@@ -958,7 +958,7 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
// Bilaplacian brick.
getfem::model model;
-
+
// Main unknown of the problem.
model.add_fem_variable("u", mf_u());
@@ -990,18 +990,18 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
else
add_normal_derivative_Dirichlet_condition_with_multipliers
(model, mim, "u", mf_mult_d, CLAMPED_BOUNDARY_NUM);
-
+
if (sol_ref == 2)
add_Dirichlet_condition_with_multipliers
(model, mim, "u", mf_mult, SIMPLE_SUPPORT_BOUNDARY_NUM);
else
add_Dirichlet_condition_with_multipliers
(model, mim, "u", mf_mult, SIMPLE_SUPPORT_BOUNDARY_NUM, "DData");
-
-
+
+
sparse_matrix H(1, mf_u().nb_dof());
if (enrichment_option == 3 ) {
/* add a constraint brick for the mortar junction between
@@ -1012,7 +1012,7 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
// sparse_matrix H(1, mf_u().nb_dof());
this->set_matrix_mortar(H) ;
- /* because of the discontinuous partition of mf_u(), some levelset
+ /* because of the discontinuous partition of mf_u(), some levelset
enriched functions do not contribute any more to the
mass-matrix (the ones which are null on one side of the
levelset, when split in two by the mortar partition, may create
@@ -1022,42 +1022,42 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
//gmm::HarwellBoeing_IO::write("M2.hb", M2);
cout << "PARAM.real_value(\"SEUIL\") : " << PARAM.real_value("SEUIL") <<
"\n" ;
for (size_type d = 0; d < mf_u().nb_dof(); ++d) {
- // if (M2(d,d) < 1e-7) cout << " weak mf_u() dof " << d << " @ "
<<
+ // if (M2(d,d) < 1e-7) cout << " weak mf_u() dof " << d << " @ "
<<
// mf_u().point_of_dof(d) << " M2(d,d) = " << M2(d,d) << "\n";
if (M2(d,d) < PARAM.real_value("SEUIL")) {
- cout << "removed : " << mf_u().point_of_basic_dof(d) << "\n";
+ cout << "removed : " << mf_u().point_of_basic_dof(d) << "\n";
size_type n = gmm::mat_nrows(H);
gmm::resize(H, n+1, gmm::mat_ncols(H));
H(n, d) = 1;
}
- }
- gmm::resize(R, gmm::mat_nrows(H));
+ }
+ gmm::resize(R, gmm::mat_nrows(H));
model.add_fixed_size_variable("mult_mo", gmm::mat_nrows(H));
getfem::add_constraint_with_multipliers(model, "u", "mult_mo", H, R);
gmm::Harwell_Boeing_save("H.hb", H);
}
- if ( PARAM.real_value("SEUIL_FINAL")!=0 ) {
+ if ( PARAM.real_value("SEUIL_FINAL")!=0 ) {
// suppression of nodes with a very small term on the stiffness matrix diag
sparse_matrix M2(mf_u().nb_dof(), mf_u().nb_dof());
sparse_matrix H1(0, mf_u().nb_dof());
//getfem::asm_mass_matrix(M2, mim, mf_u(), mf_u());
base_vector RR(mf_rhs.nb_dof(), 1.0);
- getfem::asm_stiffness_matrix_for_bilaplacian(M2, mim, mf_u(),
+ getfem::asm_stiffness_matrix_for_bilaplacian(M2, mim, mf_u(),
mf_rhs, RR);
-
+
//cout << "stiffness_matrix_for_bilaplacian : " << M2 << "\n" ;
cout << "termes diagonaux, de la matrice de rigidite, inferieurs a 1e-10 :
" ;
for (size_type d = 0; d < mf_u().nb_dof(); ++d) {
if (M2(d,d) < 1e-10) cout << M2(d,d) << " ; " ;
- }
+ }
cout << "\n" ;
cout << "SEUIL_FINAL = " << PARAM.real_value("SEUIL_FINAL") << "\n" ;
for (size_type d = 0; d < mf_u().nb_dof(); ++d) {
if (M2(d,d) < PARAM.real_value("SEUIL_FINAL")) {
- cout << "OULALA " << d << " @ " << mf_u().point_of_basic_dof(d) << " :
" << M2(d,d) << "\n";
+ cout << "OULALA " << d << " @ " << mf_u().point_of_basic_dof(d) << " :
" << M2(d,d) << "\n";
size_type n = gmm::mat_nrows(H);
gmm::resize(H1, n+1, gmm::mat_ncols(H));
H1(n, d) = 1;
@@ -1069,12 +1069,12 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
gmm::Harwell_Boeing_save("M2.hb", M2);
}
-
+
cout << "Total number of variables : " << model.nb_dof() << endl;
gmm::iteration iter(residual, 1, 40000);
getfem::standard_solve(model, iter);
-
+
// Solution extraction
gmm::resize(U, mf_u().nb_dof());
gmm::copy(model.real_variable("u"), U);
@@ -1091,17 +1091,17 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
cout << "cond super LU = " << 1./condest << "\n" ;
cout << "X = " << gmm::sub_vector(X, gmm::sub_interval(0, 10)) << "\n" ;
cout << "U = " << gmm::sub_vector(U, gmm::sub_interval(0, 10)) << "\n" ;
-
-
+
+
unsigned q = mf_u().get_qdim();
-
+
base_small_vector tab_fic(4);
std::vector<size_type> ind_sing(2) ;
unsigned cpt = 0;
if (PARAM.int_value("ENRICHMENT_OPTION") == 3){
// affichage des coeffs devant les singularites, avec le raccord
integral
GMM_ASSERT1(!mf_u().is_reduced(), "To be adapted");
-
+
for (unsigned d=0; d < mf_u().nb_dof(); d += q) {
size_type cv = mf_u().first_convex_of_basic_dof(d) ;
getfem::pfem pf = mf_u().fem_of_element(cv);
@@ -1110,10 +1110,10 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
if (mf_u().ind_basic_dof_of_element(cv)[dd] == d) {
ld = dd/q; break;
}
- }
+ }
if (ld == unsigned(-1)) {
cout << "DOF " << d << "NOT FOUND in " << cv << " BUG BUG\n";
- }
+ }
else {
if ( is_global_dof_type_bis(pf->dof_types().at(ld)) ){
cout << "coeff:" << U[d] << "\n" ;
@@ -1125,10 +1125,10 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
}
}
}
-
-
+
+
plain_vector b1(gmm::mat_nrows(A)), b2(b1), X1(b1), X2(b1) ;
-
+
scalar_type as1, as2, as1s2, bs1, bs2 ;
as1 = A(ind_sing[0], ind_sing[0]) ;
scalar_type max = 0. ;
@@ -1151,7 +1151,7 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
gmm::copy(gmm::mat_col(A, ind_sing[1]), b2) ;
//cout << "gmm::mat_col(A, ind_sing[0]) = " << b1 << "\n" ;
//cout << "gmm::mat_col(A, ind_sing[1]) = " << b2 << "\n" ;
-
+
for (int i=0 ; i < 2 ; i++){
for (unsigned j=0 ; j < gmm::mat_nrows(A) ; j++){
A(ind_sing[i],j) = 0. ;
@@ -1162,9 +1162,7 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
b1[ind_sing[i]] = 0. ;
b2[ind_sing[i]] = 0. ;
}
-
-
-
+
SuperLU_solve(A, X1, b1, condest, 1) ;
cout << "solving for s1 OK, cond = " << 1./condest << "\n" ;
SuperLU_solve(A, X2, b2, condest, 1) ;
@@ -1205,12 +1203,12 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
Z[0] = bs1 - gmm::vect_sp(X1, b) ;
Z[1] = bs2 - gmm::vect_sp(X2, b) ;
gmm::lu_solve(M, FIC_ORTHO, Z) ;
-
+
cout << "[as1 as2 as1s2] = " << as1 << " ; " << as2 << " ; " << as1s2
<< "\n" ;
cout << "[bs1 bs2] = " << bs1 << " ; " << bs2 << "\n" ;
cout << "M = " << M << "\n" ;
- cout << "Z = " << Z << "\n" ;
-
+ cout << "Z = " << Z << "\n" ;
+
cout << "FIC1 ORTHO = " << FIC_ORTHO[0] << "\n" ;
cout << "FIC2 ORTHO = " << FIC_ORTHO[1] << "\n" ;
cout << "-----------------------\n" ;
@@ -1220,18 +1218,18 @@ bool bilaplacian_crack_problem::solve(plain_vector &U) {
}
template<typename VEC1, typename VEC2>
-void asm_H2_semi_dist_map(const getfem::mesh_im &mim,
+void asm_H2_semi_dist_map(const getfem::mesh_im &mim,
const getfem::mesh_fem &mf1, const VEC1 &U1,
const getfem::mesh_fem &mf2, const VEC2 &U2,
const getfem::mesh_fem &mf_P0, VEC1 &V,
getfem::mesh_region rg =
getfem::mesh_region::all_convexes()) {
mim.linked_mesh().intersect_with_mpi_region(rg);
- getfem::generic_assembly assem;
+ getfem::generic_assembly assem;
assem.set("u1=data$1(#1); u2=data$2(#2); "
"V(#3)+=u1(i).u1(j).comp(Hess(#1).Hess(#1).Base(#3))(i,d,e,j,d,e,:)"
"+ u2(i).u2(j).comp(Hess(#2).Hess(#2).Base(#3))(i,d,e,j,d,e,:)"
"- 2*u1(i).u2(j).comp(Hess(#1).Hess(#2).Base(#3))(i,d,e,j,d,e,:)");
-
+
assem.push_mi(mim);
assem.push_mf(mf1);
assem.push_mf(mf2);
@@ -1241,7 +1239,7 @@ void asm_H2_semi_dist_map(const getfem::mesh_im &mim,
assem.push_vec(V);
assem.assembly(rg);
}
-
+
void bilaplacian_crack_problem::compute_H2_error_field(const plain_vector &U) {
getfem::mesh_fem mf_P0(mesh);
@@ -1252,7 +1250,7 @@ void
bilaplacian_crack_problem::compute_H2_error_field(const plain_vector &U) {
getfem::vtk_export exp2(datafilename + "_H2.vtk");
exp2.exporting(mf_P0);
exp2.write_point_data(mf_P0, V, "H2 error map");
-
+
mf_P0.write_to_file(datafilename + "_H2.meshfem", true);
gmm::vecsave(datafilename + "_H2.V", V);
}
diff --git a/contrib/icare/icare.cc b/contrib/icare/icare.cc
index 4848f117..24d05b54 100644
--- a/contrib/icare/icare.cc
+++ b/contrib/icare/icare.cc
@@ -43,17 +43,16 @@ using bgeot::size_type; /* = unsigned long */
using bgeot::base_matrix; /* small dense matrices. */
/* definition of some matrix/vector types. These ones are built
- * using the predefined types in Gmm++
+ * using the predefined types in GetFEM
*/
-typedef getfem::modeling_standard_sparse_vector sparse_vector;
typedef getfem::modeling_standard_sparse_matrix sparse_matrix;
typedef getfem::modeling_standard_plain_vector plain_vector;
enum {
- DIRICHLET_BOUNDARY_NUM = 0,
+ DIRICHLET_BOUNDARY_NUM = 0,
NONREFLECTIVE_BOUNDARY_NUM,
- NORMAL_PART_DIRICHLET_BOUNDARY_NUM,
- ON_CYLINDER_BOUNDARY_NUM,
+ NORMAL_PART_DIRICHLET_BOUNDARY_NUM,
+ ON_CYLINDER_BOUNDARY_NUM,
NEUMANN_BOUNDARY_NUM};
#if GETFEM_PARA_LEVEL > 1
@@ -63,8 +62,8 @@ enum {
std::vector<T> W(gmm::vect_size(V));
// cout<<"MPI ALLREDUCE"<<endl;
MPI_Allreduce(&(V[0]), &(W[0]), gmm::vect_size(V), gmm::mpi_type(T()),
- MPI_SUM, MPI_COMM_WORLD);
- gmm::copy(W, V);
+ MPI_SUM, MPI_COMM_WORLD);
+ gmm::copy(W, V);
}
#endif
#endif
@@ -112,7 +111,7 @@ struct navier_stokes_problem {
base_small_vector sol_f(const base_small_vector &P, scalar_type t);
base_small_vector Dir_cond(const base_small_vector &P, scalar_type t);
- void solve(void);
+ void solve();
//void solve_METHOD_SPLITTING(bool);
//void solve_FULLY_CONSERVATIVE();
//void solve_PREDICTION_CORRECTION();
@@ -120,9 +119,9 @@ struct navier_stokes_problem {
//void solve_PREDICTION_CORRECTION_ORDER2();
// void solve_FULLY_EXPLICIT_ORDER2();
- void init(void);
- navier_stokes_problem(void) : mim(mesh), mf_u(mesh), mf_p(mesh),
- mf_rhs(mesh), mf_mult(mesh) {}
+ void init();
+ navier_stokes_problem() : mim(mesh), mf_u(mesh), mf_p(mesh),
+ mf_rhs(mesh), mf_mult(mesh) {}
};
struct problem_definition {
@@ -132,29 +131,29 @@ struct problem_definition {
virtual void validate_solution(navier_stokes_problem &p, scalar_type t) {
plain_vector R; dirichlet_condition(p, t, R);
p.mf_rhs.set_qdim(bgeot::dim_type(p.N));
- scalar_type err = getfem::asm_L2_dist(p.mim,
- p.mf_u, p.Un1,
- p.mf_rhs, R);
+ scalar_type err = getfem::asm_L2_dist(p.mim,
+ p.mf_u, p.Un1,
+ p.mf_rhs, R);
p.mf_rhs.set_qdim(1);
cout << " L2 error(t=" << t <<") : " << err << "\n";
}
virtual void dirichlet_condition(navier_stokes_problem &p,
- const base_node &x, scalar_type t,
- base_small_vector &r) = 0;
+ const base_node &x, scalar_type t,
+ base_small_vector &r) = 0;
virtual void source_term(navier_stokes_problem &p,
- const base_node &x, scalar_type t,
- base_small_vector &F) = 0;
+ const base_node &x, scalar_type t,
+ base_small_vector &F) = 0;
virtual scalar_type initial_pressure(navier_stokes_problem &, const
base_node &) {
return 0.5;
}
virtual base_small_vector initial_velocity(navier_stokes_problem &p, const
base_node &P) {
base_small_vector r; dirichlet_condition(p,P,0,r); return r;
}
- void dirichlet_condition(navier_stokes_problem &p, scalar_type t,
- plain_vector &R) {
+ void dirichlet_condition(navier_stokes_problem &p, scalar_type t,
+ plain_vector &R) {
unsigned N = p.mesh.dim();
gmm::resize(R, N*p.mf_rhs.nb_dof());
- base_small_vector r;
+ base_small_vector r;
GMM_ASSERT1(!p.mf_rhs.is_reduced(), "To be adapted");
for (unsigned i=0; i < p.mf_rhs.nb_dof(); ++i) {
dirichlet_condition(p, p.mf_rhs.point_of_basic_dof(i), t, r);
@@ -171,13 +170,13 @@ struct problem_definition {
gmm::copy(f, gmm::sub_vector(F, gmm::sub_interval(i*N, N)));
}
}
-
+
void initial_condition_u(navier_stokes_problem &p, plain_vector &U0) {
GMM_ASSERT1(!p.mf_rhs.is_reduced(), "To be adapted");
plain_vector R(p.N*p.mf_rhs.nb_dof());
for (unsigned i=0; i < p.mf_rhs.nb_dof(); ++i) {
base_small_vector
- r = initial_velocity(p, p.mf_rhs.point_of_basic_dof(i));
+ r = initial_velocity(p, p.mf_rhs.point_of_basic_dof(i));
gmm::copy(r, gmm::sub_vector(R, gmm::sub_interval(i*p.N, p.N)));
}
gmm::copy(R,U0);
@@ -187,7 +186,7 @@ struct problem_definition {
// plain_vector R(p.N*p.mf_rhs.nb_dof()), F(p.mf_u.nb_dof());
// for (unsigned i=0; i < p.mf_rhs.nb_dof(); ++i) {
// base_small_vector
-// r = initial_velocity(p, p.mf_rhs.point_of_basic_dof(i));
+// r = initial_velocity(p, p.mf_rhs.point_of_basic_dof(i));
// gmm::copy(r, gmm::sub_vector(R, gmm::sub_interval(i*p.N, p.N)));
// }
// /* L2 projection from mf_rhs onto mf_u (we cannot interpolate directly
@@ -224,16 +223,16 @@ struct problem_definition {
struct problem_definition_Stokes_analytic : public problem_definition {
virtual void dirichlet_condition(navier_stokes_problem &p,
- const base_node &P, scalar_type t,
- base_small_vector &r) {
+ const base_node &P, scalar_type t,
+ base_small_vector &r) {
r = base_small_vector(p.N);
scalar_type x = P[0], y = P[1];
r[0] = 2.*(2.*y-1.)*(1.-1.*gmm::sqr(2.*x-1.))*t;
r[1] = -2.*(2.*x-1.)*(1.-1.*gmm::sqr(2.*y-1.))*t;
}
virtual void source_term(navier_stokes_problem &p,
- const base_node &P, scalar_type t,
- base_small_vector &F) {
+ const base_node &P, scalar_type t,
+ base_small_vector &F) {
scalar_type x = P[0], y = P[1];
F = base_small_vector(p.N);
F[0] =
-16.*y*x*x+16.*y*x+8.*x*x-8.*x+32.*p.nu*t*y-16.*p.nu*t+8.*t*x*x-8.*t*x;
@@ -243,16 +242,16 @@ struct problem_definition_Stokes_analytic : public
problem_definition {
struct problem_definition_Green_Taylor_analytic : public problem_definition {
virtual void dirichlet_condition(navier_stokes_problem &p,
- const base_node &P, scalar_type t,
- base_small_vector &r) {
+ const base_node &P, scalar_type t,
+ base_small_vector &r) {
r = base_small_vector(p.N);
scalar_type x = P[0], y = P[1];
r[0] = -cos(x)*sin(y)*exp(-2*t*p.nu);
r[1] = +sin(x)*cos(y)*exp(-2*t*p.nu);
}
virtual void source_term(navier_stokes_problem &p,
- const base_node &/* P */, scalar_type /* t */,
- base_small_vector &F) {
+ const base_node &/* P */, scalar_type /* t */,
+ base_small_vector &F) {
// scalar_type x = P[0], y = P[1];
F = base_small_vector(p.N);
//F[0] = -exp(-4.*t*p.nu)*sin(2.*x);
@@ -261,7 +260,7 @@ struct problem_definition_Green_Taylor_analytic : public
problem_definition {
F[1] =0;
}
virtual scalar_type initial_pressure(navier_stokes_problem &p,
- const base_node &P) {
+ const base_node &P) {
scalar_type x = P[0], y = P[1], t = 0;
return -1./4 * (cos(2*x)+cos(2*y)) * exp(-4*p.nu * t);
}
@@ -269,234 +268,242 @@ struct problem_definition_Green_Taylor_analytic :
public problem_definition {
struct problem_rotating_cylinder : public problem_definition {
scalar_type alpha;
-
- virtual bool is_on_west_face(base_node BBmin,base_node G){
+
+ virtual bool is_on_west_face(base_node BBmin,base_node G) {
bool res = false;
- if (gmm::abs(G[0] - BBmin[0]) < 1e-7)
+ if (gmm::abs(G[0] - BBmin[0]) < 1e-7)
res = true;
return res;
}
- virtual bool is_on_est_face(base_node BBmax, base_node G){
+ virtual bool is_on_est_face(base_node BBmax, base_node G) {
bool res = false;
- if (gmm::abs(G[0] - BBmax[0]) < 1e-7)
+ if (gmm::abs(G[0] - BBmax[0]) < 1e-7)
res = true;
return res;
}
- virtual bool is_on_nord_face(base_node BBmax, base_node G){
+ virtual bool is_on_nord_face(base_node BBmax, base_node G) {
bool res = false;
- if (gmm::abs(G[1] - BBmax[1]) < 1e-7)
+ if (gmm::abs(G[1] - BBmax[1]) < 1e-7)
res = true;
//if (is_on_west_face(BBmin,G))
- // res = false;
+ // res = false;
//if (is_on_est_face(BBmax,G))
- // res = false;
+ // res = false;
return res;
- }
+ }
- virtual bool is_on_sud_face(base_node BBmin, base_node G){
+ virtual bool is_on_sud_face(base_node BBmin, base_node G) {
bool res = false;
- if (gmm::abs(G[1] - BBmin[1]) < 1e-7)
+ if (gmm::abs(G[1] - BBmin[1]) < 1e-7)
res = true;
//if (is_on_west_face(BBmin,G))
- // res = false;
+ // res = false;
//if (is_on_est_face(BBmax,G))
- // res = false;
+ // res = false;
return res;
}
- virtual bool is_on_down_face(base_node BBmin, base_node G){
+ virtual bool is_on_down_face(base_node BBmin, base_node G) {
bool res = false;
- if (gmm::abs(G[2] - BBmin[2]) < 1e-7)
+ if (gmm::abs(G[2] - BBmin[2]) < 1e-7)
res = true;
- // if (is_on_est_face(BBmax,G))
- // res = false;
- //if (is_on_west_face(BBmin,G))
- // res = false;
- //if (is_on_nord_face(BBmax,G))
- // res = false;
- //if (is_on_sud_face(BBmin,G))
- // res = false;
+ // if (is_on_est_face(BBmax,G))
+ // res = false;
+ //if (is_on_west_face(BBmin,G))
+ // res = false;
+ //if (is_on_nord_face(BBmax,G))
+ // res = false;
+ //if (is_on_sud_face(BBmin,G))
+ // res = false;
return res;
}
- virtual bool is_on_up_face(base_node BBmax, base_node G){
+ virtual bool is_on_up_face(base_node BBmax, base_node G) {
bool res = false;
- if (gmm::abs(G[2] - BBmax[2]) < 1e-7)
+ if (gmm::abs(G[2] - BBmax[2]) < 1e-7)
res = true;
- //if (is_on_est_face(BBmax,G))
- // res = false;
- //if (is_on_west_face(BBmin,G))
- // res = false;
- //if (is_on_nord_face(BBmax,G))
- // res = false;
- //if (is_on_sud_face(BBmin,G))
- // res = false;
+ //if (is_on_est_face(BBmax,G))
+ // res = false;
+ //if (is_on_west_face(BBmin,G))
+ // res = false;
+ //if (is_on_nord_face(BBmax,G))
+ // res = false;
+ //if (is_on_sud_face(BBmin,G))
+ // res = false;
return res;
}
virtual void choose_boundaries(navier_stokes_problem &p) {
- getfem::mesh_region r;
+ getfem::mesh_region r;
getfem::outer_faces_of_mesh(p.mesh, r);
unsigned N = p.mesh.dim();
- if (N==2){
+ if (N == 2) {
for (getfem::mr_visitor i(r); !i.finished(); ++i) {
- base_node G = gmm
::mean_value(p.mesh.points_of_face_of_convex(i.cv(),i.f()));
- //cout << "x=" << G[0] << " y="<< G[1] << "\n";
- bool on_cyl = true;
-
- if (is_on_west_face(p.BBmin,G) )
- {on_cyl = false;
- p.mesh.region(DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());};
-
- //if (is_on_west_face(p.BBmin,G)||is_on_nord_face(p.BBmax,G) ||
is_on_sud_face(p.BBmin,G) )
- // {on_cyl = false;
- // p.mesh.region(DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());};
-
- if (is_on_est_face(p.BBmax,G))
- {on_cyl = false;
- p.mesh.region(NONREFLECTIVE_BOUNDARY_NUM).add(i.cv(),i.f());};
-
- if (is_on_nord_face(p.BBmax,G) || is_on_sud_face(p.BBmin,G))
- {on_cyl = false;
-
p.mesh.region(NORMAL_PART_DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());};
-
- //scalar_type h = p.mesh.convex_radius_estimate(i.cv());
- //if (gmm::abs(sqrt(G[0]*G[0] + G[1]*G[1]) - p.R) < h)
- // {p.mesh.region(ON_CYLINDER_BOUNDARY_NUM).add(i.cv(),i.f());};
- if (on_cyl)
- {p.mesh.region(ON_CYLINDER_BOUNDARY_NUM).add(i.cv(),i.f());};
+ base_node G = gmm
::mean_value(p.mesh.points_of_face_of_convex(i.cv(),i.f()));
+ //cout << "x=" << G[0] << " y="<< G[1] << "\n";
+ bool on_cyl = true;
+
+ if (is_on_west_face(p.BBmin,G) ) {
+ on_cyl = false;
+ p.mesh.region(DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());
+ }
+
+ //if (is_on_west_face(p.BBmin,G)||is_on_nord_face(p.BBmax,G) ||
is_on_sud_face(p.BBmin,G) )
+ // {on_cyl = false;
+ // p.mesh.region(DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());};
+
+ if (is_on_est_face(p.BBmax,G)) {
+ on_cyl = false;
+ p.mesh.region(NONREFLECTIVE_BOUNDARY_NUM).add(i.cv(),i.f());
+ }
+
+ if (is_on_nord_face(p.BBmax,G) || is_on_sud_face(p.BBmin,G)) {
+ on_cyl = false;
+ p.mesh.region(NORMAL_PART_DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());
+ }
+
+ //scalar_type h = p.mesh.convex_radius_estimate(i.cv());
+ //if (gmm::abs(sqrt(G[0]*G[0] + G[1]*G[1]) - p.R) < h)
+ // {p.mesh.region(ON_CYLINDER_BOUNDARY_NUM).add(i.cv(),i.f());};
+ if (on_cyl)
+ p.mesh.region(ON_CYLINDER_BOUNDARY_NUM).add(i.cv(),i.f());
}
}
-
- if (N==3){
+
+ if (N == 3) {
for (getfem::mr_visitor i(r); !i.finished(); ++i) {
- base_node G = gmm
::mean_value(p.mesh.points_of_face_of_convex(i.cv(),i.f()));
- //cout << "x=" << G[0] << " y="<< G[1]<< " z="<< G[2] << "\n";
- bool on_cyl = true;
-
- if (is_on_west_face(p.BBmin,G) )
- {on_cyl = false;
- p.mesh.region(DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());};
-
- //if (is_on_west_face(p.BBmin,G) || is_on_nord_face(p.BBmax,G) ||
is_on_sud_face(p.BBmin,G) )
- // {on_cyl = false;
- // p.mesh.region(DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());};
-
- if (is_on_est_face(p.BBmax,G))
- { on_cyl = false;
- p.mesh.region(NONREFLECTIVE_BOUNDARY_NUM).add(i.cv(),i.f());};
-
- if (is_on_nord_face(p.BBmax,G) || is_on_sud_face(p.BBmin,G))
- { on_cyl = false;
-
p.mesh.region(NORMAL_PART_DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());};
-
- if (is_on_down_face(p.BBmin,G) || is_on_up_face(p.BBmax,G))
- { on_cyl = false;
- p.mesh.region(NEUMANN_BOUNDARY_NUM).add(i.cv(),i.f());};
-
- //scalar_type h = p.mesh.convex_radius_estimate(i.cv());
- if (gmm::abs(sqrt(G[0]*G[0] + G[1]*G[1])) < 0.5)
- {p.mesh.region(ON_CYLINDER_BOUNDARY_NUM).add(i.cv(),i.f());};
-
- //if (on_cyl)
- // {p.mesh.region(ON_CYLINDER_BOUNDARY_NUM).add(i.cv(),i.f());};
+ base_node G = gmm
::mean_value(p.mesh.points_of_face_of_convex(i.cv(),i.f()));
+ //cout << "x=" << G[0] << " y="<< G[1]<< " z="<< G[2] << "\n";
+ bool on_cyl = true;
+
+ if (is_on_west_face(p.BBmin,G)) {
+ on_cyl = false;
+ p.mesh.region(DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());
+ }
+
+ //if (is_on_west_face(p.BBmin,G) || is_on_nord_face(p.BBmax,G) ||
is_on_sud_face(p.BBmin,G) ) {
+ // on_cyl = false;
+ // p.mesh.region(DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());
+ //}
+
+ if (is_on_est_face(p.BBmax,G)) {
+ on_cyl = false;
+ p.mesh.region(NONREFLECTIVE_BOUNDARY_NUM).add(i.cv(),i.f());
+ }
+
+ if (is_on_nord_face(p.BBmax,G) || is_on_sud_face(p.BBmin,G)) {
+ on_cyl = false;
+ p.mesh.region(NORMAL_PART_DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());
+ }
+
+ if (is_on_down_face(p.BBmin,G) || is_on_up_face(p.BBmax,G)) {
+ on_cyl = false;
+ p.mesh.region(NEUMANN_BOUNDARY_NUM).add(i.cv(),i.f());
+ }
+
+ //scalar_type h = p.mesh.convex_radius_estimate(i.cv());
+ if (gmm::abs(sqrt(G[0]*G[0] + G[1]*G[1])) < 0.5)
+ p.mesh.region(ON_CYLINDER_BOUNDARY_NUM).add(i.cv(),i.f());
+
+ //if (on_cyl)
+ // p.mesh.region(ON_CYLINDER_BOUNDARY_NUM).add(i.cv(),i.f());
}
}
}
- virtual void dirichlet_condition(navier_stokes_problem &p,
- const base_node &P, scalar_type /*t*/,
- base_small_vector &r) {
- r = base_small_vector(p.N);
- if (p.N==2){
+ virtual void dirichlet_condition(navier_stokes_problem &p,
+ const base_node &P, scalar_type /*t*/,
+ base_small_vector &r) {
+ r = base_small_vector(p.N);
+ if (p.N==2) {
scalar_type x = P[0], y = P[1];
// if (gmm::abs(x - p.BBmax[0]) < 1e-7)
// {}
// else if ((gmm::abs(y - p.BBmax[1]) < 1e-7
- // || gmm::abs(y - p.BBmin[1]) < 1e-7 ) && !(gmm::abs(x -
p.BBmin[0]) < 1e-7) ){}
- // else{
+ // || gmm::abs(y - p.BBmin[1]) < 1e-7 ) && !(gmm::abs(x
- p.BBmin[0]) < 1e-7) ) {}
+ // else{
// r[0] = 1.0;
// r[1] = 0.0;
- // if (gmm::sqr(x*x + y*y) < 1.2){
- // r[0] = -2.*alpha*y; /* HYPOTHESIS: cylinder centered at
(0,0) */
- // r[1] = 2.*alpha*x;
- // }
+ // if (gmm::sqr(x*x + y*y) < 1.2) {
+ // r[0] = -2.*alpha*y; /* HYPOTHESIS: cylinder centered at
(0,0) */
+ // r[1] = 2.*alpha*x;
+ // }
// }
r[0] = 1.0;
r[1] = 0.0;
- if (gmm::sqrt(x*x + y*y) < 1.0 ){
- r[0] = -2.*alpha*y; /* HYPOTHESIS: cylinder centered at (0,0) */
- r[1] = 2.*alpha*x;
+ if (gmm::sqrt(x*x + y*y) < 1.0 ) {
+ r[0] = -2.*alpha*y; /* HYPOTHESIS: cylinder centered at (0,0) */
+ r[1] = 2.*alpha*x;
};
- if (gmm::abs(x - p.BBmin[0]) < 1e-7){
- r[0] = 1.0;
- r[1] = 0.0;
+ if (gmm::abs(x - p.BBmin[0]) < 1e-7) {
+ r[0] = 1.0;
+ r[1] = 0.0;
};
}
-
- if (p.N==3){
+
+ if (p.N==3) {
scalar_type x = P[0], y = P[1]; //, z = P[2];
// if (gmm::abs(x - p.BBmax[0]) < 1e-7)
- // {}
- // e2lse if ((gmm::abs(y - p.BBmax[1]) < 1e-7
- // || gmm::abs(y - p.BBmin[1]) < 1e-7 ) && !(gmm::abs(x -
p.BBmin[0]) < 1e-7) ){}
- // else if ((gmm::abs(z - p.BBmax[2] < 1e-7)
- // || gmm::abs(z - p.BBmin[2] < 1e-7) ) &&
- // !(gmm::abs(y - p.BBmax[1]) < 1e-7 || gmm::abs(y -
p.BBmin[1]) < 1e-7 ) &&
- // !(gmm::abs(x - p.BBmin[0]) < 1e-7)){}
- // else{
+ // {}
+ // else if ((gmm::abs(y - p.BBmax[1]) < 1e-7
+ // || gmm::abs(y - p.BBmin[1]) < 1e-7 ) && !(gmm::abs(x
- p.BBmin[0]) < 1e-7) ) {}
+ // else if ((gmm::abs(z - p.BBmax[2] < 1e-7)
+ // || gmm::abs(z - p.BBmin[2] < 1e-7) ) &&
+ // !(gmm::abs(y - p.BBmax[1]) < 1e-7 || gmm::abs(y -
p.BBmin[1]) < 1e-7 ) &&
+ // !(gmm::abs(x - p.BBmin[0]) < 1e-7)) {}
+ // else{
// r[0] = 1.0;
// r[1] = 0.0;
// r[2] = 0.0;
- // if (gmm::sqr(x*x + y*y) < 1.2){
- // r[0] = -2.*alpha*y;
- // r[1] = 2.*alpha*x;
- // r[2] = 0.0;
- // }
+ // if (gmm::sqr(x*x + y*y) < 1.2) {
+ // r[0] = -2.*alpha*y;
+ // r[1] = 2.*alpha*x;
+ // r[2] = 0.0;
+ // }
// }
- r[0] = 1.0;
+ r[0] = 1.0;
r[1] = 0.0;
r[2] = 0.0;
- if (gmm::sqrt(x*x + y*y) < 1.0 ){
- r[0] = -2.0*alpha*y; /* HYPOTHESIS: cylinder centered at (0,0) */
- r[1] = 2.0*alpha*x;
- r[2] = 0.0;
+ if (gmm::sqrt(x*x + y*y) < 1.0 ) {
+ r[0] = -2.0*alpha*y; /* HYPOTHESIS: cylinder centered at (0,0) */
+ r[1] = 2.0*alpha*x;
+ r[2] = 0.0;
};
- if (gmm::abs(x - p.BBmin[0]) < 1e-7){
- r[0] = 1.0;
- r[1] = 0.0;
- r[2] = 0.0;
+ if (gmm::abs(x - p.BBmin[0]) < 1e-7) {
+ r[0] = 1.0;
+ r[1] = 0.0;
+ r[2] = 0.0;
};
- }
+ }
}
-
+
virtual void source_term(navier_stokes_problem &p,
- const base_node &, scalar_type /*t*/,
- base_small_vector &F) {
+ const base_node &, scalar_type /*t*/,
+ base_small_vector &F) {
F = base_small_vector(p.N);
}
-
+
void validate_solution(navier_stokes_problem &p, scalar_type t) {
- cout << "Validate_solution : t = " << t << " , |u| = "
- << gmm::vect_norm2(p.Un1) << ", |p|="
- << gmm::vect_norm2(p.Pn1) << "\n";
+ cout << "Validate_solution : t = " << t << " , |u| = "
+ << gmm::vect_norm2(p.Un1) << ", |p|="
+ << gmm::vect_norm2(p.Pn1) << "\n";
}
- virtual base_small_vector initial_velocity(navier_stokes_problem &p,const
base_node &) {
+ virtual base_small_vector initial_velocity(navier_stokes_problem &p,const
base_node &) {
//unsigned N = p.mesh.dim();
unsigned N = p.N;
base_small_vector r(N);
switch(N) {
case 1 : {
- r[0] = 1;
+ r[0] = 1;
break;}
case 2 : {
- r[0] = 1.0;
+ r[0] = 1.0;
r[1] = 0.0;
break;}
case 3 : {
@@ -510,8 +517,8 @@ struct problem_rotating_cylinder : public
problem_definition {
virtual scalar_type initial_pressure(navier_stokes_problem &,
- const base_node &) {
- return 0.0; // the mean value = 0
+ const base_node &) {
+ return 0.0; // the mean value = 0
}
problem_rotating_cylinder(scalar_type aa) : alpha(aa) {}
@@ -522,7 +529,7 @@ struct problem_rotating_cylinder : public
problem_definition {
* Read parameters from the .param file, build the mesh, set finite element
* and integration methods and selects the boundaries.
*/
-void navier_stokes_problem::init(void) {
+void navier_stokes_problem::init() {
cout << "-----------------------------------------------------------" <<
endl;
cout << "Reading the icare.param file" << endl;
cout << "-----------------------------------------------------------" <<
endl;
@@ -530,7 +537,7 @@ void navier_stokes_problem::init(void) {
std::string FEM_TYPE = PARAM.string_value("FEM_TYPE","FEM name");
std::string FEM_TYPE_P = PARAM.string_value("FEM_TYPE_P","FEM name P");
std::string INTEGRATION = PARAM.string_value("INTEGRATION",
- "Name of integration method");
+ "Name of integration method");
cout << "FEM_TYPE=" << FEM_TYPE << "\n";
cout << "INTEGRATION=" << INTEGRATION << "\n";
@@ -543,7 +550,7 @@ void navier_stokes_problem::init(void) {
mesh.bounding_box(BBmin, BBmax);
cout << "mesh bounding box: " << BBmin << " ... " << BBmax << "\n";
datafilename = PARAM.string_value("ROOTFILENAME","Data files base name.");
- residual = PARAM.real_value("RESIDUAL");
+ residual = PARAM.real_value("RESIDUAL");
if (residual == 0.) residual = 1e-10;
nu = PARAM.real_value("NU", "Viscosity");
@@ -578,8 +585,8 @@ void navier_stokes_problem::init(void) {
getfem::pfem pf_u = getfem::fem_descriptor(FEM_TYPE);
getfem::pfem pf_p = getfem::fem_descriptor(FEM_TYPE_P);
- getfem::pintegration_method ppi =
- getfem::int_method_descriptor(INTEGRATION);
+ getfem::pintegration_method ppi =
+ getfem::int_method_descriptor(INTEGRATION);
mim.set_integration_method(mesh.convex_index(), ppi);
mf_u.set_finite_element(mesh.convex_index(), pf_u);
@@ -590,23 +597,23 @@ void navier_stokes_problem::init(void) {
std::string data_fem_name = PARAM.string_value("DATA_FEM_TYPE");
if (data_fem_name.size() == 0) {
GMM_ASSERT1(pf_u->is_lagrange(), "You are using a non-lagrange FEM "
- << FEM_TYPE << ". In that case you need to set "
- << "DATA_FEM_TYPE in the .param file");
+ << FEM_TYPE << ". In that case you need to set "
+ << "DATA_FEM_TYPE in the .param file");
mf_rhs.set_finite_element(mesh.convex_index(), pf_u);
} else {
- mf_rhs.set_finite_element(mesh.convex_index(),
- getfem::fem_descriptor(data_fem_name));
+ mf_rhs.set_finite_element(mesh.convex_index(),
+ getfem::fem_descriptor(data_fem_name));
}
std::string mult_fem_name = PARAM.string_value("MULTIPLIER_FEM_TYPE");
if (mult_fem_name.size() == 0) {
GMM_ASSERT1(pf_u->is_lagrange(), "You are using a non-lagrange FEM "
- << FEM_TYPE << ". In that case you need to set "
- << "MULTIPLIER_FEM_TYPE in the .param file");
+ << FEM_TYPE << ". In that case you need to set "
+ << "MULTIPLIER_FEM_TYPE in the .param file");
mf_mult.set_finite_element(mesh.convex_index(), pf_u);
} else {
- mf_mult.set_finite_element(mesh.convex_index(),
- getfem::fem_descriptor(mult_fem_name));
+ mf_mult.set_finite_element(mesh.convex_index(),
+ getfem::fem_descriptor(mult_fem_name));
}
/* set boundary conditions */
@@ -625,8 +632,8 @@ void navier_stokes_problem::solve() {
gmm::resize(Un1, mf_u.nb_dof());
gmm::resize(Pn0, mf_p.nb_dof());
gmm::resize(Pn1, mf_p.nb_dof());
-
- if (time_order==2){
+
+ if (time_order==2) {
gmm::resize(Unm1, mf_u.nb_dof());
}
@@ -636,8 +643,8 @@ void navier_stokes_problem::solve() {
//case 2 : solve_FULLY_CONSERVATIVE(); break;
//case 3 : solve_PREDICTION_CORRECTION(); break;
case 4 : solve_PREDICTION_CORRECTION2(); break;
- //case 5 : solve_PREDICTION_CORRECTION_ORDER2(); break;
- //case 6 : solve_FULLY_EXPLICIT_ORDER2();break;
+ //case 5 : solve_PREDICTION_CORRECTION_ORDER2(); break;
+ //case 6 : solve_FULLY_EXPLICIT_ORDER2();break;
default: GMM_ASSERT1(false, "unknown method");
}
}
@@ -657,18 +664,18 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
gmm::sub_interval I1(0, nbdof_u);
cout << "nbdof rhs = " << nbdof_rhs << endl;
- cout << "h = "<< mesh.minimal_convex_radius_estimate()<< endl;
+ cout << "h = "<< mesh.minimal_convex_radius_estimate()<< endl;
// Discretization of laplace operator for u
sparse_matrix K1(nbdof_u, nbdof_u);
asm_stiffness_matrix_for_homogeneous_laplacian_componentwise
(K1, mim, mf_u, mpirg);
gmm::scale(K1, nu);
-
+
// Mass Matrix
sparse_matrix M(nbdof_u, nbdof_u);
asm_mass_matrix(M, mim, mf_u, mpirg);
-
+
// Matrix p div u
sparse_matrix B(nbdof_p, nbdof_u);
asm_stokes_B(B, mim, mf_u, mf_p, mpirg);
@@ -680,8 +687,8 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
asm_B_boundary(Bbc, mim, mf_u, mf_p,
mf_u.linked_mesh().get_mpi_sub_region(NORMAL_PART_DIRICHLET_BOUNDARY_NUM));
asm_B_boundary(Bbc, mim, mf_u,
mf_p,mf_u.linked_mesh().get_mpi_sub_region(ON_CYLINDER_BOUNDARY_NUM));
- if (N==3){
- asm_B_boundary(Bbc, mim, mf_u,
mf_p,mf_u.linked_mesh().get_mpi_sub_region(NEUMANN_BOUNDARY_NUM));
+ if (N == 3) {
+ asm_B_boundary(Bbc, mim, mf_u,
mf_p,mf_u.linked_mesh().get_mpi_sub_region(NEUMANN_BOUNDARY_NUM));
}
//////////////////////////////////////////////////////////////////////////
@@ -689,25 +696,22 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
//////////////////////////////////////////////////////////////////////////
mf_mult.set_qdim(bgeot::dim_type(N));
GMM_ASSERT1(!mf_rhs.is_reduced(), "To be adapted");
-
+
dal::bit_vector dofon_nonref =
mf_mult.basic_dof_on_region(NONREFLECTIVE_BOUNDARY_NUM);
-
+
dal::bit_vector dofon_Dirichlet_Out_Cylinder =
mf_mult.basic_dof_on_region(DIRICHLET_BOUNDARY_NUM);
-
-
-
-
-//(NORMAL_PART_DIRICHLET_BOUNDARY_NUM);
+
+//(NORMAL_PART_DIRICHLET_BOUNDARY_NUM);
//dofon_NDirichlet.setminus(dofon_nonref);
//dofon_NDirichlet.setminus(dofon_Dirichlet_Out_Cylinder);
//(NEUMANN_BOUNDARY_NUM);
//dofon_Neumann.setminus(dofon_Dirichlet_On_cylinder);
//dofon_Neumann.setminus(dofon_nonref);
//dofon_Neumann.setminus(dofon_Dirichlet_Out_Cylinder);
-
-//*******************************************************************************************************
+
+//*******************************************************************************************************
// Normal part Dirichlet condition -- sur v en 2D -- sur v et w en 3D
-//*******************************************************************************************************
+//*******************************************************************************************************
//cout << dofon_Dirichlet_Out_Cylinder << endl;
//cout << dofon_nonref << endl;
//
@@ -715,14 +719,14 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
dal::bit_vector dofon_NDirichlet =
mf_mult.basic_dof_on_region(NORMAL_PART_DIRICHLET_BOUNDARY_NUM);
dofon_NDirichlet.setminus(dofon_nonref);
dofon_NDirichlet.setminus(dofon_Dirichlet_Out_Cylinder);
-
+
std::vector<size_type> ind_ct_ndir;
for (dal::bv_visitor i(dofon_NDirichlet); !i.finished(); ++i) {
- if (dofon_Dirichlet_Out_Cylinder.is_in(i) || dofon_nonref.is_in(i))
+ if (dofon_Dirichlet_Out_Cylinder.is_in(i) || dofon_nonref.is_in(i))
dofon_NDirichlet.sup(i); // Suppress i because it is on the
else // Dirichlet or non reflective boundary.
ind_ct_ndir.push_back(i);
- }
+ }
size_type nbdof_NDir = dofon_NDirichlet.card();
gmm::sub_index SUB_CT_NDIR(ind_ct_ndir);
@@ -732,29 +736,29 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
// sparse_matrix HND1(nbdof_NDir, nbdof_u);
// {
-// sparse_matrix A(mf_mult.nb_dof(), nbdof_u);
+// sparse_matrix A(mf_mult.nb_dof(), nbdof_u);
// getfem::generic_assembly assem;
-// // assem.set("M(#2,#1)+=comp(Base(#2).vBase(#1).Normal())(:,:,i,i);"); -
Good in 2D / Bad in 3D
+// // assem.set("M(#2,#1)+=comp(Base(#2).vBase(#1).Normal())(:,:,i,i);"); -
Good in 2D / Bad in 3D
// assem.set("M(#2,#1)+=comp(Base(#2).vBase(#1))(:,:,2);"); // 2ieme
composante V = (u,v,w) : v = 0
// assem.push_mi(mim); assem.push_mf(mf_u); assem.push_mf(mf_mult);
// assem.push_mat(A); assem.assembly(mpindirrg);
// gmm::copy(gmm::sub_matrix(A, SUB_CT_NDIR, I1), HND1);
// }
// cout << "Nb of Normal part Dirichlet constraints (qdim=1): " << nbdof_NDir
<< endl;
-//
+//
// sparse_matrix HND;
- if (N==2){
+ if (N == 2) {
//gmm::resize(HND,nbdof_NDir, nbdof_u);
//gmm::copy(HND1,HND);
I2 = gmm::sub_interval(nbdof_u, nbdof_NDir);
}
-// else { //(N==3){
+// else { //(N == 3) {
// // Normal part Dirichlet condition Left - Right (in 3D only)
// sparse_matrix HND2(nbdof_NDir, nbdof_u);
// {
-// sparse_matrix A(mf_mult.nb_dof(), nbdof_u);
+// sparse_matrix A(mf_mult.nb_dof(), nbdof_u);
// getfem::generic_assembly assem;
-// assem.set("M(#2,#1)+=comp(Base(#2).vBase(#1))(:,:,3);"); // 3ieme
composante V = (u,v,w) : w = 0
+// assem.set("M(#2,#1)+=comp(Base(#2).vBase(#1))(:,:,3);"); // 3ieme
composante V = (u,v,w) : w = 0
// assem.push_mi(mim); assem.push_mf(mf_u); assem.push_mf(mf_mult);
// assem.push_mat(A); assem.assembly(mpindirrg);
// gmm::copy(gmm::sub_matrix(A, SUB_CT_NDIR, I1), HND2);
@@ -767,12 +771,12 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
// nbdof_NDir = 2*nbdof_NDir;
// I2 = gmm::sub_interval(nbdof_u, nbdof_NDir);
// }
-//
-//
+//
+//
// //M gmm::dense_matrix<double> DM(nbdof_NDir,nbdof_u);
// //M gmm:: copy(HND,DM);
-// //M for(unsigned i=0;i<nbdof_NDir;++i){
-// //M for(unsigned j=0;j<nbdof_u;++j){
+// //M for(unsigned i=0; i < nbdof_NDir; ++i) {
+// //M for(unsigned j=0; j < nbdof_u; ++j) {
// //M if (DM(i,j)!=0.0) cout << i<<" , "<<j<<" = "<<DM(i,j)<< endl;
// //M }
// //M }
@@ -780,29 +784,29 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
// // Dirichlet condition except on cylinder
// mf_mult.set_qdim(N);
// GMM_ASSERT1(!mf_rhs.is_reduced(), "To be adapted");
- //size_type nbdof_NDir = 0;
-//*******************************************************************************************************
-
- //dal::bit_vector dofon_Dirichlet_Out_Cylinder
+// size_type nbdof_NDir = 0;
+//*******************************************************************************************************
+
+ //dal::bit_vector dofon_Dirichlet_Out_Cylinder
// = mf_mult.basic_dof_on_region(DIRICHLET_BOUNDARY_NUM);
-
+
std::vector<size_type> ind_ct_dir_out_cyl;
for (dal::bv_visitor i(dofon_Dirichlet_Out_Cylinder); !i.finished(); ++i) {
- //if (dofon_nonref.is_in(i))
- // dofon_Dirichlet_Out_Cylinder.sup(i);
- //else
+ //if (dofon_nonref.is_in(i))
+ // dofon_Dirichlet_Out_Cylinder.sup(i);
+ //else
ind_ct_dir_out_cyl.push_back(i);
}
size_type nbdof_Dir_Out_Cylinder = dofon_Dirichlet_Out_Cylinder.card();
gmm::sub_index SUB_CT_DIR(ind_ct_dir_out_cyl);
gmm::sub_interval I3(nbdof_u+nbdof_NDir, nbdof_Dir_Out_Cylinder);
-
+
getfem::mesh_region mpidirrg
= mf_u.linked_mesh().get_mpi_sub_region(DIRICHLET_BOUNDARY_NUM);
-
+
sparse_matrix HD(nbdof_Dir_Out_Cylinder, nbdof_u);
{
- sparse_matrix A(mf_mult.nb_dof(), nbdof_u);
+ sparse_matrix A(mf_mult.nb_dof(), nbdof_u);
getfem::generic_assembly assem;
assem.set("M(#2,#1)+=comp(vBase(#2).vBase(#1))(:,i,:,i);");
assem.push_mi(mim); assem.push_mf(mf_u); assem.push_mf(mf_mult);
@@ -816,23 +820,23 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
mf_mult.set_qdim(bgeot::dim_type(N));
GMM_ASSERT1(!mf_rhs.is_reduced(), "To be adapted");
- dal::bit_vector dofon_Dirichlet_On_Cylinder
+ dal::bit_vector dofon_Dirichlet_On_Cylinder
= mf_mult.basic_dof_on_region(ON_CYLINDER_BOUNDARY_NUM);
std::vector<size_type> ind_ct_dir_on_cylinder;
- for (dal::bv_visitor i(dofon_Dirichlet_On_Cylinder); !i.finished(); ++i)
+ for (dal::bv_visitor i(dofon_Dirichlet_On_Cylinder); !i.finished(); ++i)
ind_ct_dir_on_cylinder.push_back(i);
size_type nbdof_Dir_On_Cylinder = dofon_Dirichlet_On_Cylinder.card();
gmm::sub_index SUB_CT_DIR_CYL(ind_ct_dir_on_cylinder);
gmm::sub_interval I3C(nbdof_u+nbdof_NDir+nbdof_Dir_Out_Cylinder,
nbdof_Dir_On_Cylinder);
-
+
getfem::mesh_region mpidircylrg
= mf_u.linked_mesh().get_mpi_sub_region(ON_CYLINDER_BOUNDARY_NUM);
sparse_matrix HDC(nbdof_Dir_On_Cylinder, nbdof_u);
{
- sparse_matrix A(mf_mult.nb_dof(), nbdof_u);
+ sparse_matrix A(mf_mult.nb_dof(), nbdof_u);
getfem::generic_assembly assem;
assem.set("M(#2,#1)+=comp(vBase(#2).vBase(#1))(:,i,:,i);");
assem.push_mi(mim); assem.push_mf(mf_u); assem.push_mf(mf_mult);
@@ -851,9 +855,9 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
std::vector<size_type> ind_ct_nonref;
for (dal::bv_visitor i(dofon_nonref); !i.finished(); ++i) {
- //if (dofon_NDirichlet.is_in(i))
- // dofon_nonref.sup(i);
- //else
+ //if (dofon_NDirichlet.is_in(i))
+ // dofon_nonref.sup(i);
+ //else
ind_ct_nonref.push_back(i);}
size_type nbdof_nonref = dofon_nonref.card();
gmm::sub_index SUB_CT_NONREF(ind_ct_nonref);
@@ -863,7 +867,7 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
sparse_matrix HNR(nbdof_nonref, nbdof_u);
{
- sparse_matrix A(mf_mult.nb_dof(), nbdof_u);
+ sparse_matrix A(mf_mult.nb_dof(), nbdof_u);
getfem::generic_assembly assem;
assem.set("M(#2,#1)+=comp(vBase(#2).vBase(#1))(:,i,:,i);");
assem.push_mi(mim); assem.push_mf(mf_u); assem.push_mf(mf_mult);
@@ -878,13 +882,13 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
sparse_matrix HN;
// size_type nbdof_neumann=0;
gmm::sub_interval I5;
-
+
dofon_nonref= mf_mult.basic_dof_on_region(NONREFLECTIVE_BOUNDARY_NUM);
dofon_Dirichlet_Out_Cylinder =
mf_mult.basic_dof_on_region(DIRICHLET_BOUNDARY_NUM);
//dofon_NDirichlet =
mf_mult.basic_dof_on_region(NORMAL_PART_DIRICHLET_BOUNDARY_NUM);
dofon_Dirichlet_On_Cylinder =
mf_mult.basic_dof_on_region(ON_CYLINDER_BOUNDARY_NUM);
- //if (N==3){
+// if (N == 3) {
// mf_mult.set_qdim(1);
//
// dal::bit_vector dofon_neumann =
mf_mult.basic_dof_on_region(NEUMANN_BOUNDARY_NUM);
@@ -892,22 +896,22 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
// std::vector<size_type> ind_ct_neumann;
// for (dal::bv_visitor i(dofon_neumann); !i.finished(); ++i) {
// if (dofon_Dirichlet_Out_Cylinder.is_in(i*N) || dofon_nonref.is_in(i*N)
||
-// dofon_NDirichlet.is_in(i*N) || dofon_Dirichlet_On_Cylinder.is_in(i*N)
)
-// dofon_neumann.sup(i);
-// else
-// ind_ct_neumann.push_back(i);
-// }
+// dofon_NDirichlet.is_in(i*N) ||
dofon_Dirichlet_On_Cylinder.is_in(i*N) )
+// dofon_neumann.sup(i);
+// else
+// ind_ct_neumann.push_back(i);
+// }
// //cout << mf_mult.point_of_basic_dof(i)<< endl;
-//
+//
// nbdof_neumann = dofon_neumann.card();
// gmm::sub_index SUB_CT_NEUMANN(ind_ct_neumann);
-//
+//
// I5 =
gmm::sub_interval(nbdof_u+nbdof_NDir+nbdof_Dir_Out_Cylinder+nbdof_Dir_On_Cylinder+nbdof_nonref,
nbdof_neumann);
// getfem::mesh_region mpineumannrg =
mf_u.linked_mesh().get_mpi_sub_region(NEUMANN_BOUNDARY_NUM);
-//
+//
// gmm::resize(HN,nbdof_neumann, nbdof_u);
// {
-// sparse_matrix A(mf_mult.nb_dof(), nbdof_u);
+// sparse_matrix A(mf_mult.nb_dof(), nbdof_u);
// getfem::generic_assembly assem;
// assem.set("M(#2,#1)+=comp(Base(#2).vBase(#1))(:,:,3);"); // 3ieme
composante V = (u,v,w) : w = 0
// assem.push_mi(mim); assem.push_mf(mf_u); assem.push_mf(mf_mult);
@@ -915,12 +919,12 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
// gmm::copy(gmm::sub_matrix(A, SUB_CT_NEUMANN, I1), HN);
// }
// cout << "Nb of Neumann part in 3D (qdim=1): " << nbdof_neumann << endl;
-//
+//
// mf_mult.set_qdim(N);
//
//
// }
-
+
/////////////////////////////////////////////////////////////////////////////////////////////////
// Operators to solve NSE
/////////////////////////////////////////////////////////////////////////////////////////////////
@@ -929,28 +933,25 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
sparse_matrix K2(nbdof_p+1, nbdof_p+1);
gmm::sub_interval IP(0, nbdof_p);
asm_stiffness_matrix_for_homogeneous_laplacian(gmm::sub_matrix(K2, IP),
- mim, mf_p, mpirgp);
-
+ mim, mf_p, mpirgp);
/*
- dal::bit_vector dofon_cylp
+ dal::bit_vector dofon_cylp
= mf_p.basic_dof_on_region(ON_CYLINDER_BOUNDARY_NUM);
getfem::mesh_region mpicylp
= mf_p.linked_mesh().get_mpi_sub_region(ON_CYLINDER_BOUNDARY_NUM);
std::vector<size_type> ind_cylp;
- for (dal::bv_visitor i(dofon_cylp); !i.finished(); ++i)
+ for (dal::bv_visitor i(dofon_cylp); !i.finished(); ++i)
ind_cylp.push_back(i);
//size_type nbdof_cylp = dofon_cylp.card();
gmm::sub_index SUB_CYLP(ind_cylp);
-
-
if (N>=2)
{
- sparse_matrix A(nbdof_p, nbdof_p);
+ sparse_matrix A(nbdof_p, nbdof_p);
getfem::generic_assembly assem;
assem.set("M(#1,#1)+=comp(Grad(#1).Normal().Base(#1))(:,1,1,:);");
assem.push_mi(mim); assem.push_mf(mf_p);
@@ -959,9 +960,9 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
gmm::add(A,gmm::sub_matrix(K2,IP,IP));
}
- if (N==3)
+ if (N == 3)
{
- sparse_matrix A(nbdof_p, nbdof_p);
+ sparse_matrix A(nbdof_p, nbdof_p);
getfem::generic_assembly assem;
assem.set("M(#1,#1)+=comp(Grad(#1).Normal().Base(#1))(:,3,3,:);");
assem.push_mi(mim); assem.push_mf(mf_p);
@@ -973,30 +974,30 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
//Prise en compte de fa�on faible
plain_vector HP(nbdof_p);
- { plain_vector A(nbdof_p);
+ { plain_vector A(nbdof_p);
getfem::generic_assembly assem;
assem.set("V(#1)+=comp(Base(#1))(:);");
assem.push_mi(mim); assem.push_mf(mf_p);
assem.push_vec(A); assem.assembly(mpirgp);
gmm::copy(A,HP);
}
-
+
// for (unsigned i=0;i<=nbdof_p; ++i) {
// HP[i];} // mean value of the pressure = 0
- //K2(nbdof_p,nbdof_p) = 0.0;
+ //K2(nbdof_p,nbdof_p) = 0.0;
*/
//Prise en compte de fa�on forte
- for (unsigned i=0;i<=nbdof_p; ++i) {
- K2(nbdof_p,i) = K2(i,nbdof_p) = 1.0;} // mean value of the pressure = 0
- //K2(nbdof_p, 0) = K2(0, nbdof_p) = 1.0;} // set the first pressure dof to 0
- K2(nbdof_p,nbdof_p) = 0.0;
+ for (unsigned i=0; i <= nbdof_p; ++i) {
+ K2(nbdof_p,i) = K2(i,nbdof_p) = 1.0; // mean value of the pressure = 0
+ //K2(nbdof_p, 0) = K2(0, nbdof_p) = 1.0; // set the first pressure dof to 0
+ }
+ K2(nbdof_p,nbdof_p) = 0.0;
gmm::SuperLU_factor<double> SLUsys2, SLUsys3,SLUsys1;
SLUsys2.build_with(K2);
-
-/////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////
// dynamic problem
/////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1005,22 +1006,22 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
/////// REPRISE DES CALCULS EVENTUELS //////
std::string initfile_Um1 = PARAM.string_value("INIT_FILE_Um1");
-
+
std::string initfile_U = PARAM.string_value("INIT_FILE_U");
std::string initfile_P = PARAM.string_value("INIT_FILE_P");
-
+
if (initfile_U.size() == 0 || initfile_P.size() == 0) {
pdef->initial_condition_u(*this, Un0);
pdef->initial_condition_p(*this, Pn0);
} else {
- gmm::vecload(initfile_U,Un0);
+ gmm::vecload(initfile_U,Un0);
gmm::vecload(initfile_P,Pn0);
}
-
+
if (initfile_Um1.size() != 0) {
- gmm::vecload(initfile_Um1,Unm1);
+ gmm::vecload(initfile_Um1,Unm1);
}
-
+
////// initialiser t et eviter les 2 initialisations suivantes
std::ofstream coeffTP("coeffTP.data");
@@ -1034,19 +1035,17 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
scalar_type BoxYmax = PARAM.real_value("BOXYmax", "Particular Point yMax");
scalar_type BoxZmin(0), BoxZmax(0);
- if (N==3) {
+ if (N == 3) {
BoxZmin = PARAM.real_value("BOXZmin", "Particular Point zMin");
BoxZmax = PARAM.real_value("BOXZmax", "Particular Point zMax");
}
-
+
base_node ptPartU(N+1), ptPartP(N+1);
-
GMM_ASSERT1(!mf_p.is_reduced(), "To be adapted");
-
- if (N==2) {
- for (unsigned i=0; i< mf_p.nb_dof(); ++i){
+ if (N == 2) {
+ for (unsigned i=0; i< mf_p.nb_dof(); ++i) {
bgeot :: base_node BN = mf_p.point_of_basic_dof(i);
if (BN[0]<BoxXmax && BN[0] > BoxXmin && BN[1]< BoxYmax && BN[1] >
BoxYmin ) {
cout << "Point Part in Box -- i on mf_p= " << i
<<",x="<<BN[0]<<",y="<<BN[1]<< endl;
@@ -1055,10 +1054,10 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
ptPartP[2] = i;
break;
}
- }
-
-
- for (unsigned i=0; i< mf_u.nb_dof(); ++i){
+ }
+
+
+ for (unsigned i=0; i< mf_u.nb_dof(); ++i) {
bgeot::base_node BN = mf_u.point_of_basic_dof(i);
if (BN[0]==ptPartP[0] && BN[1]==ptPartP[1] ) {
cout << "Point Part in Box -- i on mf_u= " << i
<<",x="<<BN[0]<<",y="<<BN[1]<< endl;
@@ -1066,17 +1065,16 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
// Vitesse =(U,V,W) alors en 2D --> sur V, en 3D --> sur W
// D'ou la modif dans ptPartU[2]
ptPartU[0] = BN[0];
- ptPartU[1] = BN[1];
+ ptPartU[1] = BN[1];
ptPartU[2] = i - N + 1;
break;
-
- }
+ }
}
- ptPartData << ptPartP[0] << " " << ptPartP[1] << endl;
-
+ ptPartData << ptPartP[0] << " " << ptPartP[1] << endl;
+
}
- if (N==3) {
- for (unsigned i=0; i< mf_p.nb_dof(); ++i){
+ if (N == 3) {
+ for (unsigned i=0; i < mf_p.nb_dof(); ++i) {
bgeot :: base_node BN = mf_p.point_of_basic_dof(i);
if (BN[0]<BoxXmax && BN[0] > BoxXmin && BN[1]< BoxYmax && BN[1] >
BoxYmin && BN[2]< BoxZmax && BN[2] > BoxZmin ) {
cout << "Point Part in Box -- i on mf_p= " << i
<<",x="<<BN[0]<<",y="<<BN[1]<< ",z="<<BN[2]<< endl;
@@ -1086,10 +1084,9 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
ptPartP[3] = i;
break;
}
- }
-
-
- for (unsigned i=0; i< mf_u.nb_dof(); ++i){
+ }
+
+ for (unsigned i=0; i < mf_u.nb_dof(); ++i) {
bgeot :: base_node BN = mf_u.point_of_basic_dof(i);
if (BN[0]==ptPartP[0] && BN[1]==ptPartP[1]&& BN[2]==ptPartP[2] ) {
cout << "Point Part in Box -- i on mf_u= " << i
<<",x="<<BN[0]<<",y="<<BN[1]<<",z="<<BN[2]<< endl;
@@ -1097,33 +1094,32 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
// Vitesse =(U,V,W) alors en 2D --> sur V, en 3D --> sur W
// D'ou la modif dans ptPartU[3]
ptPartU[0] = BN[0];
- ptPartU[1] = BN[1];
+ ptPartU[1] = BN[1];
ptPartU[2] = BN[2];
ptPartU[3] = i - N + 1;
break;
-
- }
+ }
}
- ptPartData << ptPartP[0] << " " << ptPartP[1] << " " << ptPartP[2] <<
endl;
-
- }
-
+ ptPartData << ptPartP[0] << " " << ptPartP[1] << " " << ptPartP[2] << endl;
+
+ }
+
size_type sizelsystem = 0;
size_type sizelsystemP = nbdof_p+1;
- if (N==2)
+ if (N == 2)
sizelsystem = nbdof_u + nbdof_NDir + nbdof_Dir_Out_Cylinder +
nbdof_Dir_On_Cylinder + nbdof_nonref;
- if (N==3)
+ if (N == 3)
sizelsystem = nbdof_u + nbdof_NDir + nbdof_Dir_Out_Cylinder +
nbdof_Dir_On_Cylinder + nbdof_nonref;// + nbdof_neumann;
sparse_matrix A1(sizelsystem, sizelsystem);
- sparse_matrix A2(sizelsystem, sizelsystem);
- sparse_matrix A2u(sizelsystem/2, sizelsystem/2);
- sparse_matrix A2v(sizelsystem/2, sizelsystem/2);
- sparse_matrix A1u(sizelsystem/2, sizelsystem/2);
- sparse_matrix A1v(sizelsystem/2, sizelsystem/2);
-
-
+ sparse_matrix A2(sizelsystem, sizelsystem);
+ sparse_matrix A2u(sizelsystem/2, sizelsystem/2);
+ sparse_matrix A2v(sizelsystem/2, sizelsystem/2);
+ sparse_matrix A1u(sizelsystem/2, sizelsystem/2);
+ sparse_matrix A1v(sizelsystem/2, sizelsystem/2);
+
+
plain_vector Y(sizelsystem), YY(nbdof_u), Ytmp(nbdof_u);
do_export(0);
@@ -1131,166 +1127,153 @@ void
navier_stokes_problem::solve_PREDICTION_CORRECTION2() {
cout << "Dynamic problem implementation" << endl;
cout << "-----------------------------------------------------------" <<
endl;
-
-gmm :: sub_slice SUB_CT_Vu(0,sizelsystem/N,N);
-gmm :: sub_slice SUB_CT_Vv(1,sizelsystem/N,N);
-gmm :: sub_interval SUB_CT_V(0,nbdof_u);
-gmm :: sub_interval SUB_CT_P(0,nbdof_p);
-
-// id�ees
+ gmm :: sub_slice SUB_CT_Vu(0,sizelsystem/N,N);
+ gmm :: sub_slice SUB_CT_Vv(1,sizelsystem/N,N);
+ gmm :: sub_interval SUB_CT_V(0,nbdof_u);
+ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
+
+// id�ees
//gmm::copy(gmm::sub_vector(F1generic,SUB_CT_V1full),F1full);
//gmm::copy(gmm::sub_vector(X1full,SUB_CT_V),X1);
//gmm::copy(gmm::sub_vector(X2full,SUB_CT_V),X2);
//gmm::copy(X1,gmm::sub_vector(USTAR,gmm::sub_slice(0,nbdof_u,2)));
//gmm::copy(X2,gmm::sub_vector(USTAR,gmm::sub_slice(1,nbdof_u,2)));
-
+
for (scalar_type t = Tinitial + dt; t <= T; t += dt) {
//******* Construction of the Matrix for the 3rd system (to obtain
velocity) **********//
- if (t==Tinitial+dt){ //time_order = 1 or first iterations with time_order
= 2, computed once
+ if (t == Tinitial+dt) { //time_order = 1 or first iterations with
time_order = 2, computed once
gmm::clear(A2);
gmm::add(M, gmm::sub_matrix(A2, I1));
//// Normal Dirichlet condition
//gmm::copy(HND, gmm::sub_matrix(A2, I2, I1));
//gmm::copy(gmm::transposed(HND), gmm::sub_matrix(A2, I1, I2));
-
+
// Dirichlet condition except on cylinder
gmm::copy(HD, gmm::sub_matrix(A2, I3, I1));
gmm::copy(gmm::transposed(HD), gmm::sub_matrix(A2, I1, I3));
-
+
// Dirichlet condition on cylinder
gmm::copy(HDC, gmm::sub_matrix(A2, I3C, I1));
gmm::copy(gmm::transposed(HDC), gmm::sub_matrix(A2, I1, I3C));
-
+
// Non reflective condition
gmm::copy(HNR, gmm::sub_matrix(A2, I4, I1));
gmm::copy(gmm::transposed(HNR), gmm::sub_matrix(A2, I1, I4));
-
+
// Factorization LU
// SLUsys3.build_with(A2); // pour le systeme couple (u,v)
-
-
-
- gmm::clear(A2u);
- //gmm::clear(A2v);
-
-
- gmm::copy(gmm::sub_matrix(A2,SUB_CT_Vu,SUB_CT_Vu),A2u);
- //gmm::copy(gmm::sub_matrix(A2,SUB_CT_Vv,SUB_CT_Vv),A2v);
-
-
- //gmm::add(gmm::scaled(A2u,-1.0),A2v);
- //cout <<"A2 "<< gmm::mat_norminf(A2v) << endl;
-
- SLUsys3.build_with(A2u);
-
+
+ gmm::clear(A2u);
+ //gmm::clear(A2v);
+
+ gmm::copy(gmm::sub_matrix(A2,SUB_CT_Vu,SUB_CT_Vu),A2u);
+ //gmm::copy(gmm::sub_matrix(A2,SUB_CT_Vv,SUB_CT_Vv),A2v);
+
+ //gmm::add(gmm::scaled(A2u,-1.0),A2v);
+ //cout <<"A2 "<< gmm::mat_norminf(A2v) << endl;
+
+ SLUsys3.build_with(A2u);
}
- if ((time_order==2)&&(t==Tinitial+2*dt)){ // computed once
+ if (time_order == 2 && t == Tinitial+2*dt) { // computed once
gmm::clear(A2);
gmm::add(gmm::scaled(M,1.5), gmm::sub_matrix(A2, I1));
//// Normal Dirichlet condition
//gmm::copy(HND, gmm::sub_matrix(A2, I2, I1));
//gmm::copy(gmm::transposed(HND), gmm::sub_matrix(A2, I1, I2));
-
+
// Dirichlet condition except on cylinder
gmm::copy(HD, gmm::sub_matrix(A2, I3, I1));
gmm::copy(gmm::transposed(HD), gmm::sub_matrix(A2, I1, I3));
-
+
// Dirichlet condition on cylinder
gmm::copy(HDC, gmm::sub_matrix(A2, I3C, I1));
gmm::copy(gmm::transposed(HDC), gmm::sub_matrix(A2, I1, I3C));
-
+
// Non reflective condition
gmm::copy(HNR, gmm::sub_matrix(A2, I4, I1));
gmm::copy(gmm::transposed(HNR), gmm::sub_matrix(A2, I1, I4));
-
+
// Factorization LU
//SLUsys3.build_with(A2); // pb en (u,v) coupl�
-
- gmm::clear(A2u);
- //gmm::clear(A2v);
-
-
- gmm::copy(gmm::sub_matrix(A2,SUB_CT_Vu,SUB_CT_Vu),A2u);
- //gmm::copy(gmm::sub_matrix(A2,SUB_CT_Vv,SUB_CT_Vv),A2v);
-
- SLUsys3.build_with(A2u);
-
-
+
+ gmm::clear(A2u);
+ //gmm::clear(A2v);
+
+ gmm::copy(gmm::sub_matrix(A2,SUB_CT_Vu,SUB_CT_Vu),A2u);
+ //gmm::copy(gmm::sub_matrix(A2,SUB_CT_Vv,SUB_CT_Vv),A2v);
+
+ SLUsys3.build_with(A2u);
}
-
-
+
//******* The matrix of the 3rd system is constructed and factorized
-
+
/*
// cout<<"cylinder"<<gmm::sub_vector(Un0,SUB_CT_DIR_CYL) << endl;
//cout<<"dir"<<gmm::sub_vector(Un0,SUB_CT_DIR) << endl;
-
+
dal::bit_vector dofon_NDirichlet_tmp
= mf_mult.basic_dof_on_region(NORMAL_PART_DIRICHLET_BOUNDARY_NUM);
std::vector<size_type> ind_ct_ndir_tmp;
for (dal::bv_visitor i(dofon_NDirichlet_tmp); !i.finished(); ++i) {
ind_ct_ndir_tmp.push_back(i);
- }
+ }
gmm::sub_index SUB_CT_NDIR_tmp(ind_ct_ndir_tmp);
cout<<"NdirV"<<gmm::sub_vector(Un0,SUB_CT_NDIR_tmp) << endl;
-
- // if (N==3){cout<<"NdirW"<<gmm::sub_vector(Un0,SUB_CT_NDIR_W) << endl;};
+
+ // if (N == 3) {cout<<"NdirW"<<gmm::sub_vector(Un0,SUB_CT_NDIR_W) <<
endl;};
// cout<<"Nonref"<<gmm::sub_vector(Un0,SUB_CT_NONREF) << endl;
*/
// Assembly of the first linear system
-
- if ((time_order==1)||(t==Tinitial+dt)){ //time_order = 1 or first
iterations with time_order = 2, computed once
+
+ if (time_order == 1 || t == Tinitial+dt) { //time_order = 1 or first
iterations with time_order = 2, computed once
gmm::clear(A1);
gmm::clear(Y);
// laplace operator
- gmm::copy(K1, gmm::sub_matrix(A1, I1));
+ gmm::copy(K1, gmm::sub_matrix(A1, I1));
// Nonlinear part
//cout << "avant asm_NS_uuT"<< endl;
- getfem::asm_NS_uuT(gmm::sub_matrix(A1, I1), mim, mf_u, Un0, mpirg);
+ getfem::asm_NS_uuT(gmm::sub_matrix(A1, I1), mim, mf_u, Un0, mpirg);
//cout << "apres asm_NS_uuT"<< endl;
- // Dynamic part
+ // Dynamic part
gmm::add(gmm::scaled(M, 1./dt), gmm::sub_matrix(A1, I1));
-
+
gmm::mult(M, gmm::scaled(Un0, 1.0/dt), gmm::sub_vector(Y, I1));
-
- }
- if ((time_order==2)&&(t>=Tinitial+2*dt)){
+ }
+
+ if (time_order == 2 && t >= Tinitial+2*dt) {
gmm::clear(A1);
gmm::clear(Y);
gmm::clear(Ytmp);
// laplace operator
- gmm::copy(K1, gmm::sub_matrix(A1, I1));
+ gmm::copy(K1, gmm::sub_matrix(A1, I1));
// Nonlinear part
//cout << "avant asm_NS_uuT"<< endl;
- getfem::asm_NS_uuT(gmm::sub_matrix(A1, I1), mim, mf_u, Un0, mpirg);
+ getfem::asm_NS_uuT(gmm::sub_matrix(A1, I1), mim, mf_u, Un0, mpirg);
//cout << "apres asm_NS_uuT"<< endl;
- // Dynamic part
+ // Dynamic part
gmm::add(gmm::scaled(M, 1.5/dt), gmm::sub_matrix(A1, I1));
gmm::add(gmm::scaled(Un0, 2.0/dt),gmm::scaled(Unm1,-0.5/dt),Ytmp);
gmm::mult(M, Ytmp, gmm::sub_vector(Y, I1));
-
}
-
-
#if GETFEM_PARA_LEVEL > 1
MPI_SUM_VECTOR2(Y);
#endif
-
+
// Volumic source term -- inutile d'assambler car F = 0
//pdef->source_term(*this, t, F);
//getfem::asm_source_term(Y, mim, mf_u, mf_rhs, F,mpirg); // inutile (F=0)
-
+
// // Normal Dirichlet condition
//gmm::copy(HND, gmm::sub_matrix(A1, I2, I1));
//gmm::copy(gmm::transposed(HND), gmm::sub_matrix(A1, I1, I2));
-
+
// Dirichlet condition except on cylinder
gmm::copy(HD, gmm::sub_matrix(A1, I3, I1));
gmm::copy(gmm::transposed(HD), gmm::sub_matrix(A1, I1, I3));
@@ -1302,17 +1285,16 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
// Non reflective condition
gmm::copy(HNR, gmm::sub_matrix(A1, I4, I1));
gmm::copy(gmm::transposed(HNR), gmm::sub_matrix(A1, I1, I4));
-
-
- // if (N==3){
+
+ // if (N == 3) {
// // Neumann condition in 3D
// gmm::copy(HN, gmm::sub_matrix(A1, I5, I1));
// gmm::copy(gmm::transposed(HN), gmm::sub_matrix(A1, I1, I5));
-
+
// gmm::copy(HN, gmm::sub_matrix(A2, I5, I1));
// gmm::copy(gmm::transposed(HN), gmm::sub_matrix(A2, I1, I5));
// }
-
+
// Right hand side with Dirichlet boundary conditions
gmm::resize(F, N * nbdof_rhs);
@@ -1343,25 +1325,24 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
#if GETFEM_PARA_LEVEL > 1
MPI_SUM_VECTOR2(VV);
#endif
- gmm::copy(gmm::sub_vector(VV, SUB_CT_NDIR), gmm::sub_vector(Y, I2));
+ gmm::copy(gmm::sub_vector(VV, SUB_CT_NDIR), gmm::sub_vector(Y, I2));
}*/
- {
+ {
plain_vector VV(mf_mult.nb_dof());
gmm::clear(VV);
// getfem::asm_source_term(VV, mim, mf_mult, mf_rhs, F, mpinonrefrg); //
CL P�riodiques
if (non_reflective_bc == 0) {
- asm_basic_non_reflective_bc(VV, mim, mf_u, Un0, mf_mult, dt,
mpinonrefrg);
+ asm_basic_non_reflective_bc(VV, mim, mf_u, Un0, mf_mult, dt,
mpinonrefrg);
} else {
- asm_improved_non_reflective_bc(VV, mim, mf_u, Un0, mf_mult, dt, nu,
mpinonrefrg);
+ asm_improved_non_reflective_bc(VV, mim, mf_u, Un0, mf_mult, dt, nu,
mpinonrefrg);
}
-
#if GETFEM_PARA_LEVEL > 1
- MPI_SUM_VECTOR2(VV);
-#endif
+ MPI_SUM_VECTOR2(VV);
+#endif
gmm::copy(gmm::sub_vector(VV, SUB_CT_NONREF), gmm::sub_vector(Y, I4));
}
-
+
// pressure part
gmm::clear(YY);
gmm::mult(gmm::transposed(B), gmm::scaled(Pn0, -1.0), YY);
@@ -1369,42 +1350,35 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
#if GETFEM_PARA_LEVEL > 1
MPI_SUM_VECTOR2(YY);
#endif
-
+
gmm::add(YY, gmm::sub_vector(Y, I1));
-
+
gmm::clear(YY);
gmm::mult(gmm::transposed(Bbc), Pn0, YY);
-
+
#if GETFEM_PARA_LEVEL > 1
MPI_SUM_VECTOR2(YY);
#endif
gmm::add(YY, gmm::sub_vector(Y, I1));
-
-
- gmm::clear(A1u);
- // gmm::clear(A1v);
-
-
- gmm::copy(gmm::sub_matrix(A1,SUB_CT_Vu,SUB_CT_Vu),A1u);
- // gmm::copy(gmm::sub_matrix(A1,SUB_CT_Vv,SUB_CT_Vv),A1v);
-
-
-
+
+ gmm::clear(A1u);
+ // gmm::clear(A1v);
+
+ gmm::copy(gmm::sub_matrix(A1,SUB_CT_Vu,SUB_CT_Vu),A1u);
+ // gmm::copy(gmm::sub_matrix(A1,SUB_CT_Vv,SUB_CT_Vv),A1v);
+
//
// Solving the first linear system
//
-
{
// double rcond;
plain_vector X(sizelsystem);
+ //plain_vector Xu(sizelsystem/2);
+ //plain_vector Xv(sizelsystem/2);
+ //plain_vector Yu(sizelsystem/2);
+ //plain_vector Yv(sizelsystem/2);
- //plain_vector Xu(sizelsystem/2);
- //plain_vector Xv(sizelsystem/2);
- //plain_vector Yu(sizelsystem/2);
- //plain_vector Yv(sizelsystem/2);
-
-
#if (GETFEM_PARA_LEVEL > 1 && GETFEM_PARA_SOLVER == MUMPS_PARA_SOLVER)
MUMPS_distributed_matrix_solve(A1,X,Y);
#elif (GETFEM_PARA_LEVEL==1 && defined(GMM_USES_MUMPS))
@@ -1413,37 +1387,33 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
//MUMPS_solve(A1,X,Y);
#elif (GETFEM_PARA_LEVEL==0)
// SuperLU_solve(A1, X, Y, rcond);
-
- //gmm::copy(gmm::sub_vector(Y,SUB_CT_Vu),Yu);
- //gmm::copy(gmm::sub_vector(Y,SUB_CT_Vv),Yv);
-
-
- //SuperLU_solve(A1u, Xu, Yu, rcond);
- //SuperLU_solve(A1u, Xv, Yv, rcond);
-
- // Factorisation LU
- SLUsys1.build_with(A1u);
- //SLUsys1.solve(Xu,Yu);
- //SLUsys1.solve(Xv,Yv);
-
SLUsys1.solve(gmm::sub_vector(X,SUB_CT_Vu),gmm::sub_vector(Y,SUB_CT_Vu));
-
SLUsys1.solve(gmm::sub_vector(X,SUB_CT_Vv),gmm::sub_vector(Y,SUB_CT_Vv));
-
-
-
//gmm::copy(gmm::sub_vector(Un0,gmm::sub_slice(0,nbdof_u/2,2)),gmm::sub_vector(Xu,gmm::sub_interval(0,nbdof_u/2)));
-
//gmm::copy(gmm::sub_vector(Un0,gmm::sub_slice(1,nbdof_u/2,2)),gmm::sub_vector(Xv,gmm::sub_interval(0,nbdof_u/2)));
- //gmm::iteration iter(1E-8);
- //gmm::bicgstab(A1u,Xu,Yu,gmm::identity_matrix(),iter);
- //gmm::bicgstab(A1u,Xv,Yv,gmm::identity_matrix(),iter);
-
-
-
- //gmm::copy(Xu,gmm::sub_vector(X,SUB_CT_Vu));
- //gmm::copy(Xv,gmm::sub_vector(X,SUB_CT_Vv));
-
-
- //gmm::add(gmm::scaled(Xfull,-1.0),X);
- //cout << gmm::vect_norminf(X) << endl;
-
+
+ //gmm::copy(gmm::sub_vector(Y,SUB_CT_Vu),Yu);
+ //gmm::copy(gmm::sub_vector(Y,SUB_CT_Vv),Yv);
+
+ //SuperLU_solve(A1u, Xu, Yu, rcond);
+ //SuperLU_solve(A1u, Xv, Yv, rcond);
+
+ // Factorisation LU
+ SLUsys1.build_with(A1u);
+ //SLUsys1.solve(Xu,Yu);
+ //SLUsys1.solve(Xv,Yv);
+ SLUsys1.solve(gmm::sub_vector(X,SUB_CT_Vu),gmm::sub_vector(Y,SUB_CT_Vu));
+ SLUsys1.solve(gmm::sub_vector(X,SUB_CT_Vv),gmm::sub_vector(Y,SUB_CT_Vv));
+
+
//gmm::copy(gmm::sub_vector(Un0,gmm::sub_slice(0,nbdof_u/2,2)),gmm::sub_vector(Xu,gmm::sub_interval(0,nbdof_u/2)));
+
//gmm::copy(gmm::sub_vector(Un0,gmm::sub_slice(1,nbdof_u/2,2)),gmm::sub_vector(Xv,gmm::sub_interval(0,nbdof_u/2)));
+ //gmm::iteration iter(1E-8);
+ //gmm::bicgstab(A1u,Xu,Yu,gmm::identity_matrix(),iter);
+ //gmm::bicgstab(A1u,Xv,Yv,gmm::identity_matrix(),iter);
+
+ //gmm::copy(Xu,gmm::sub_vector(X,SUB_CT_Vu));
+ //gmm::copy(Xv,gmm::sub_vector(X,SUB_CT_Vv));
+
+
+ //gmm::add(gmm::scaled(Xfull,-1.0),X);
+ //cout << gmm::vect_norminf(X) << endl;
+
// gmm::iteration iter(1E-8);
// gmm::gmres(A1,X,Y,gmm::identity_matrix(),10,iter);
// gmm::bicgstab(A1,X,Y,gmm::identity_matrix(),iter);
@@ -1452,87 +1422,82 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
#endif
gmm::copy(gmm::sub_vector(X, I1), USTAR);
//??// gmm::copy(gmm::sub_vector(X, I3C), lambda);
-
- // Relation de compatibilit� int_domaine div(ustar)=0 //
- scalar_type delta_in;
- sparse_matrix Bbc_flux_in(nbdof_p, nbdof_u);
- asm_B_boundary(Bbc_flux_in, mim, mf_u,
mf_p,mf_u.linked_mesh().get_mpi_sub_region(DIRICHLET_BOUNDARY_NUM));
-
- gmm :: resize(lambda, nbdof_p); gmm :: clear(lambda);
gmm::fill(lambda,1.0);
-
- gmm :: resize(tmp,
nbdof_Dir_Out_Cylinder+nbdof_Dir_On_Cylinder); gmm :: clear(tmp);
-
- gmm :: mult(Bbc_flux_in,lambda,tmp);
- gmm :: resize(lambda,
nbdof_Dir_On_Cylinder+nbdof_Dir_Out_Cylinder); gmm :: clear(lambda);
- gmm ::
copy(gmm::sub_vector(USTAR,I3),gmm::sub_vector(lambda,gmm::sub_interval(0,nbdof_Dir_Out_Cylinder)));
- gmm ::
copy(gmm::sub_vector(USTAR,I3C),gmm::sub_vector(lambda,gmm::sub_interval(nbdof_Dir_Out_Cylinder,nbdof_Dir_On_Cylinder)));
- delta_in = gmm :: vect_sp(tmp,lambda);
-
- scalar_type delta_out;
-
- sparse_matrix Bbc_flux_out(nbdof_p, nbdof_u);
- asm_B_boundary(Bbc_flux_out, mim, mf_u, mf_p,
mf_u.linked_mesh().get_mpi_sub_region(NONREFLECTIVE_BOUNDARY_NUM));
- asm_B_boundary(Bbc_flux_out, mim, mf_u, mf_p,
mf_u.linked_mesh().get_mpi_sub_region(NORMAL_PART_DIRICHLET_BOUNDARY_NUM));
- //asm_B_boundary(Bbc_flux_out, mim, mf_u,
mf_p,mf_u.linked_mesh().get_mpi_sub_region(ON_CYLINDER_BOUNDARY_NUM));
- //asm_B_boundary(Bbc_flux_in, mim, mf_u,
mf_p,mf_u.linked_mesh().get_mpi_sub_region(DIRICHLET_BOUNDARY_NUM));
- gmm :: resize(lambda, nbdof_p); gmm :: clear(lambda);
gmm::fill(lambda,1.0);
-
- gmm :: resize(tmp, nbdof_NDir+nbdof_nonref); gmm :: clear(tmp);
-
- gmm :: mult(Bbc_flux_out,lambda,tmp);
- gmm :: resize(lambda, nbdof_NDir+nbdof_nonref); gmm ::
clear(lambda);
- gmm ::
copy(gmm::sub_vector(USTAR,I2),gmm::sub_vector(lambda,gmm::sub_interval(0,nbdof_NDir)));
- gmm ::
copy(gmm::sub_vector(USTAR,I4),gmm::sub_vector(lambda,gmm::sub_interval(nbdof_NDir,nbdof_nonref)));
- delta_out = gmm :: vect_sp(tmp,lambda);
-
- cout<<"compatibilite" << delta_in << " "<< delta_out << " "<<
delta_in-delta_out << endl;
- gmm::scaled(gmm::sub_vector(USTAR,I2),delta_in/delta_out);
- gmm::scaled(gmm::sub_vector(USTAR,I4),delta_in/delta_out);
- gmm::scaled(gmm::sub_vector(USTAR,I2),delta_in/delta_out);
-
- if (N==3){
- asm_B_boundary(Bbc_flux_out, mim, mf_u,
mf_p,mf_u.linked_mesh().get_mpi_sub_region(NEUMANN_BOUNDARY_NUM));
- }
-
-
- //delta = 0.0;
- //for (int ii = 0; ii <= nbdof_nonref; ii += 2) {
- // delta = delta+lambda[ii];
- //}
- //delta=delta/nbdof_nonref;
- //for (int ii = 0; ii <= nbdof_nonref; ii += 2) {
- // lambda[ii] = 1.0-delta;
- //}
- //cout << "delta" << delta << endl;
- //gmm::add(lambda,gmm::sub_vector(X, I4));
- //gmm::copy(gmm::sub_vector(X, I1), USTAR);
-
- }
-
- cout << "U* - Un0 = " << gmm::vect_dist2(USTAR, Un0) << endl;
+ // Relation de compatibilit� int_domaine div(ustar)=0 //
+ scalar_type delta_in;
+ sparse_matrix Bbc_flux_in(nbdof_p, nbdof_u);
+ asm_B_boundary(Bbc_flux_in, mim, mf_u,
mf_p,mf_u.linked_mesh().get_mpi_sub_region(DIRICHLET_BOUNDARY_NUM));
+
+ gmm :: resize(lambda, nbdof_p); gmm :: clear(lambda);
gmm::fill(lambda,1.0);
+
+ gmm :: resize(tmp, nbdof_Dir_Out_Cylinder+nbdof_Dir_On_Cylinder); gmm ::
clear(tmp);
+
+ gmm :: mult(Bbc_flux_in,lambda,tmp);
+ gmm :: resize(lambda, nbdof_Dir_On_Cylinder+nbdof_Dir_Out_Cylinder); gmm
:: clear(lambda);
+ gmm ::
copy(gmm::sub_vector(USTAR,I3),gmm::sub_vector(lambda,gmm::sub_interval(0,nbdof_Dir_Out_Cylinder)));
+ gmm ::
copy(gmm::sub_vector(USTAR,I3C),gmm::sub_vector(lambda,gmm::sub_interval(nbdof_Dir_Out_Cylinder,nbdof_Dir_On_Cylinder)));
+ delta_in = gmm :: vect_sp(tmp,lambda);
+
+ scalar_type delta_out;
+
+ sparse_matrix Bbc_flux_out(nbdof_p, nbdof_u);
+ asm_B_boundary(Bbc_flux_out, mim, mf_u, mf_p,
mf_u.linked_mesh().get_mpi_sub_region(NONREFLECTIVE_BOUNDARY_NUM));
+ asm_B_boundary(Bbc_flux_out, mim, mf_u, mf_p,
mf_u.linked_mesh().get_mpi_sub_region(NORMAL_PART_DIRICHLET_BOUNDARY_NUM));
+ //asm_B_boundary(Bbc_flux_out, mim, mf_u,
mf_p,mf_u.linked_mesh().get_mpi_sub_region(ON_CYLINDER_BOUNDARY_NUM));
+ //asm_B_boundary(Bbc_flux_in, mim, mf_u,
mf_p,mf_u.linked_mesh().get_mpi_sub_region(DIRICHLET_BOUNDARY_NUM));
+ gmm :: resize(lambda, nbdof_p); gmm :: clear(lambda);
gmm::fill(lambda,1.0);
+
+ gmm :: resize(tmp, nbdof_NDir+nbdof_nonref); gmm :: clear(tmp);
+
+ gmm :: mult(Bbc_flux_out,lambda,tmp);
+ gmm :: resize(lambda, nbdof_NDir+nbdof_nonref); gmm :: clear(lambda);
+ gmm ::
copy(gmm::sub_vector(USTAR,I2),gmm::sub_vector(lambda,gmm::sub_interval(0,nbdof_NDir)));
+ gmm ::
copy(gmm::sub_vector(USTAR,I4),gmm::sub_vector(lambda,gmm::sub_interval(nbdof_NDir,nbdof_nonref)));
+ delta_out = gmm :: vect_sp(tmp,lambda);
+
+ cout<<"compatibilite" << delta_in << " "<< delta_out << " "<<
delta_in-delta_out << endl;
+ gmm::scaled(gmm::sub_vector(USTAR,I2),delta_in/delta_out);
+ gmm::scaled(gmm::sub_vector(USTAR,I4),delta_in/delta_out);
+ gmm::scaled(gmm::sub_vector(USTAR,I2),delta_in/delta_out);
+
+ if (N == 3)
+ asm_B_boundary(Bbc_flux_out, mim, mf_u,
mf_p,mf_u.linked_mesh().get_mpi_sub_region(NEUMANN_BOUNDARY_NUM));
+
+ //delta = 0.0;
+ //for (int ii = 0; ii <= nbdof_nonref; ii += 2) {
+ // delta = delta+lambda[ii];
+ //}
+ //delta=delta/nbdof_nonref;
+ //for (int ii = 0; ii <= nbdof_nonref; ii += 2) {
+ // lambda[ii] = 1.0-delta;
+ //}
+ //cout << "delta" << delta << endl;
+ //gmm::add(lambda,gmm::sub_vector(X, I4));
+ //gmm::copy(gmm::sub_vector(X, I1), USTAR);
- if (N==3){
- plain_vector DU(mf_rhs.nb_dof() * N * N);
- plain_vector DIV(mf_rhs.nb_dof());
- compute_gradient(mf_u, mf_rhs, USTAR, DU);
- for (unsigned i=0; i < mf_rhs.nb_dof(); ++i) {
- DIV[i] = DU[i*N*N] +DU[i*N*N+4] +DU[i*N*N+8];
}
- if (PARAM.int_value("VTK_EXPORT")) {
- static int cnta=0;
- char sa[128]; snprintf(sa, 127, "SolIcare/DivUstar%d.vtk", cnta++);
- getfem::vtk_export tata(sa, PARAM.int_value("VTK_EXPORT")==1);
- tata.exporting(mf_rhs);
- tata.write_point_data(mf_rhs, DIV, "divergence");
-
- char sb[128]; snprintf(sb, 127, "SolIcare/Ustar%d.vtk", cnta++);
- getfem::vtk_export tbtb(sb, PARAM.int_value("VTK_EXPORT")==1);
- tbtb.exporting(mf_u);
- tbtb.write_point_data(mf_u, USTAR, "Ustar");
- }
+ cout << "U* - Un0 = " << gmm::vect_dist2(USTAR, Un0) << endl;
+ if (N == 3) {
+ plain_vector DU(mf_rhs.nb_dof() * N * N);
+ plain_vector DIV(mf_rhs.nb_dof());
+ compute_gradient(mf_u, mf_rhs, USTAR, DU);
+ for (unsigned i=0; i < mf_rhs.nb_dof(); ++i) {
+ DIV[i] = DU[i*N*N] + DU[i*N*N+4] + DU[i*N*N+8];
+ }
+ if (PARAM.int_value("VTK_EXPORT")) {
+ static int cnta=0;
+ char sa[128]; snprintf(sa, 127, "SolIcare/DivUstar%d.vtk", cnta++);
+ getfem::vtk_export tata(sa, PARAM.int_value("VTK_EXPORT")==1);
+ tata.exporting(mf_rhs);
+ tata.write_point_data(mf_rhs, DIV, "divergence");
+
+ char sb[128]; snprintf(sb, 127, "SolIcare/Ustar%d.vtk", cnta++);
+ getfem::vtk_export tbtb(sb, PARAM.int_value("VTK_EXPORT")==1);
+ tbtb.exporting(mf_u);
+ tbtb.write_point_data(mf_u, USTAR, "Ustar");
+ }
}
//
@@ -1553,17 +1518,14 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
//#elif (GETFEM_PARA_LEVEL==0 && GMM_USES_MUMPS)
//MUMPS_solve(K2,X,Z);
#elif (GETFEM_PARA_LEVEL==0)
- // SuperLU_solve(K2,X,Z,rcond);
-
- if ((time_order==1)||(t==Tinitial+dt)){ //time_order = 1 or first
iterations with time_order = 2
- SLUsys2.solve(X, Z);
+ //SuperLU_solve(K2,X,Z,rcond);
+ if (time_order == 1 || t == Tinitial+dt) { //time_order = 1 or first
iterations with time_order = 2
+ SLUsys2.solve(X, Z);
}
- if ((time_order==2)&&(t>=Tinitial+2*dt)){
- // SLUsys2.solve(X, gmm::scaled(gmm::sub_vector(Z,IP),1.5));
- SLUsys2.solve(X, gmm::scaled(Z,1.5));
+ if (time_order == 2 && t >= Tinitial+2*dt) {
+ //SLUsys2.solve(X, gmm::scaled(gmm::sub_vector(Z,IP),1.5));
+ SLUsys2.solve(X, gmm::scaled(Z,1.5));
}
-
-
// gmm::iteration iter(1E-8);
// gmm::gmres(K2,X,Z,gmm::identity_matrix(),10,iter);
// gmm::bicgstab(K2,X,Z,gmm::identity_matrix(),iter);
@@ -1573,8 +1535,6 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
gmm::copy(gmm::sub_vector(X, IP), Phi);
}
-
-
/*
plain_vector toto(nbdof_p);
for (unsigned i=0; i <= nbdof_p; ++i) {
@@ -1582,107 +1542,91 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
cout << "Mean value of phi " << (gmm::vect_sp(Phi,toto))/nbdof_p<< endl;
*/
- if ((time_order==1)||(t==Tinitial+dt)){ //time_order = 1 or first
iterations with time_order = 2
+ if (time_order == 1 || t == Tinitial+dt) { //time_order = 1 or first
iterations with time_order = 2
gmm::mult(M, USTAR, USTARbis);
}
- if ((time_order==2)&&(t>=Tinitial+2*dt)){
+ if (time_order == 2 && t >= Tinitial+2*dt) {
gmm::mult(gmm::scaled(M,1.5), USTAR, USTARbis);
}
gmm::mult(gmm::transposed(B), gmm::scaled(Phi, -1.0), USTARbis, USTARbis);
// -B^t*Phi + USTARbis -> USTARbis
#if GETFEM_PARA_LEVEL > 1
MPI_SUM_VECTOR2(USTARbis);
-#endif
-
+#endif
gmm::copy(USTARbis, gmm::sub_vector(Y, I1)); //gmm::copy(M,
gmm::sub_matrix(A1, I1));
-
-
- //
- // Solving the third linear system
- //
+ //
+ // Solving the third linear system
+ //
gmm::clear(YY);
gmm::mult(gmm::transposed(Bbc), Phi, YY);
-
+
#if GETFEM_PARA_LEVEL > 1
MPI_SUM_VECTOR2(YY);
#endif
gmm::add(YY, gmm::sub_vector(Y, I1));
-
+
{
// double rcond;
plain_vector X(sizelsystem);
- //plain_vector Xu(sizelsystem/2);
- //plain_vector Xv(sizelsystem/2);
- //plain_vector Yu(sizelsystem/2);
- //plain_vector Yv(sizelsystem/2);
-
+ //plain_vector Xu(sizelsystem/2);
+ //plain_vector Xv(sizelsystem/2);
+ //plain_vector Yu(sizelsystem/2);
+ //plain_vector Yv(sizelsystem/2);
+
#if (GETFEM_PARA_LEVEL > 1 && GETFEM_PARA_SOLVER == MUMPS_PARA_SOLVER)
- MUMPS_distributed_matrix_solve(A2,X,Y);
+ MUMPS_distributed_matrix_solve(A2,X,Y);
#elif (GETFEM_PARA_LEVEL==1 && defined(GMM_USES_MUMPS))
MUMPS_solve(A2,X,Y);
//#elif (GETFEM_PARA_LEVEL==0 && defined(GMM_USES_MUMPS))
//MUMPS_solve(A2,X,Y);
#elif (GETFEM_PARA_LEVEL==0)
//SuperLU_solve(A2, X, Y, rcond);
- //SLUsys3.solve(X, Y);
-
-
- //gmm::copy(gmm::sub_vector(Y,SUB_CT_Vu),Yu);
- //gmm::copy(gmm::sub_vector(Y,SUB_CT_Vv),Yv);
-
- //SuperLU_solve(A2u, Xu, Yu, rcond);
- //SuperLU_solve(A2u, Xv, Yv, rcond);
- //SLUsys3.solve(Xu, Yu);
- //SLUsys3.solve(Xv, Yv);
-
-
SLUsys3.solve(gmm::sub_vector(X,SUB_CT_Vu),gmm::sub_vector(Y,SUB_CT_Vu));
-
SLUsys3.solve(gmm::sub_vector(X,SUB_CT_Vv),gmm::sub_vector(Y,SUB_CT_Vv));
-
-
+ //SLUsys3.solve(X, Y);
+
+ //gmm::copy(gmm::sub_vector(Y,SUB_CT_Vu),Yu);
+ //gmm::copy(gmm::sub_vector(Y,SUB_CT_Vv),Yv);
+
+ //SuperLU_solve(A2u, Xu, Yu, rcond);
+ //SuperLU_solve(A2u, Xv, Yv, rcond);
+ //SLUsys3.solve(Xu, Yu);
+ //SLUsys3.solve(Xv, Yv);
+
+ SLUsys3.solve(gmm::sub_vector(X,SUB_CT_Vu),gmm::sub_vector(Y,SUB_CT_Vu));
+ SLUsys3.solve(gmm::sub_vector(X,SUB_CT_Vv),gmm::sub_vector(Y,SUB_CT_Vv));
+
//gmm::iteration iter(1E-8);
//gmm::gmres(A2,X,Y,gmm::identity_matrix(),10,iter);
//gmm::bicgstab(A2,X,Y,gmm::identity_matrix(),iter);
// ??
gmm::bicgstab(A2,X,Y,gmm::diagonal_precond<sparse_matrix>(A2),iter);
// if (noisy) cout << "condition number: " << 1.0/rcond << endl;
-#endif
-
+#endif
//gmm:: clear(Un1);
gmm::copy(gmm::sub_vector(X, I1), Un1);
-
-
- // Relation de compatibilit� int_domaine div(ustar)=0 //
- scalar_type delta;
- gmm :: resize(lambda, nbdof_nonref);
- gmm:: clear(lambda);
- gmm::copy(gmm::sub_vector(X, I4),lambda);
- delta = 0.0;
- for (int ii = 0; ii <= int(nbdof_nonref); ii += 2) {
- delta = delta+lambda[ii];
- }
- delta=delta/bgeot::scalar_type(nbdof_nonref);
- for (int ii = 0; ii <= int(nbdof_nonref); ii += 2) {
- lambda[ii] = 1.0-delta;
- }
- cout << "delta" << delta << endl;
- gmm::add(lambda,gmm::sub_vector(X, I4));
- gmm::copy(gmm::sub_vector(X, I1), Un1);
-
-
-
-
-
-//??// if ((time_order==1)||(t==Tinitial+dt)){
-//??// gmm::add(gmm::scaled(gmm::sub_vector(X, I3C),1.0/dt), lambda);
-//??// }
-//??// if ((time_order==2)&&(t>=Tinitial+2*dt)){
-//??// gmm::add(gmm::scaled(gmm::sub_vector(X, I3C),1.5/dt), lambda);
-//??// }
-
- }
+ // Relation de compatibilit� int_domaine div(ustar)=0 //
+ scalar_type delta;
+ gmm :: resize(lambda, nbdof_nonref);
+ gmm:: clear(lambda);
+ gmm::copy(gmm::sub_vector(X, I4),lambda);
+ delta = 0.0;
+ for (int ii = 0; ii <= int(nbdof_nonref); ii += 2)
+ delta = delta+lambda[ii];
+ delta=delta/bgeot::scalar_type(nbdof_nonref);
+ for (int ii = 0; ii <= int(nbdof_nonref); ii += 2)
+ lambda[ii] = 1.0-delta;
+ cout << "delta" << delta << endl;
+ gmm::add(lambda,gmm::sub_vector(X, I4));
+ gmm::copy(gmm::sub_vector(X, I1), Un1);
+
+
+//??// if (time_order == 1 || t == Tinitial+dt)
+//??// gmm::add(gmm::scaled(gmm::sub_vector(X, I3C),1.0/dt), lambda);
+//??// if (time_order == 2 && t >= Tinitial+2*dt)
+//??// gmm::add(gmm::scaled(gmm::sub_vector(X, I3C),1.5/dt), lambda);
+ }
//////////////////////////////////////////////////////////////////////////
- // INFORMATION POUR VERIFS
+ // INFORMATION POUR VERIFS
//cout << "I2 "<< gmm::sub_vector(Y, I2) << endl;
// for (dal::bv_visitor i(dofon_nonref); !i.finished(); ++i) {
@@ -1690,52 +1634,46 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
// cout << i << " " << BN <<" Un1 = " << Un1[i] << endl;
//}
-
+
// gmm::sub_index SUB_CT_NDIR_tmp(ind_ct_ndir_tmp);
//cout<<"NdirV ----- "<<gmm::sub_vector(Un1,SUB_CT_NDIR_tmp) << endl;
-
- //////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////
-
// gmm::add(USTAR, Un1);
gmm::add(gmm::scaled(Phi, 1./dt), Pn0, Pn1);
-
+
pdef->validate_solution(*this, t);
cout << "Un1 - Un0 = " << gmm::vect_dist2(Un1, Un0) << endl;
-
- if (time_order==2){
+
+ if (time_order == 2) {
gmm::copy(Un0, Unm1);
}
-
+
gmm::copy(Un1, Un0); gmm::copy(Pn1, Pn0);
-
- if (N==3){
+
+ if (N == 3) {
plain_vector DU(mf_rhs.nb_dof() * N * N);
plain_vector DIV(mf_rhs.nb_dof());
compute_gradient(mf_u, mf_rhs, Un0, DU);
for (unsigned i=0; i < mf_rhs.nb_dof(); ++i) {
- DIV[i] = DU[i*N*N] +DU[i*N*N+4] +DU[i*N*N+8];
+ DIV[i] = DU[i*N*N] +DU[i*N*N+4] +DU[i*N*N+8];
+ }
+ if (PARAM.int_value("VTK_EXPORT")) {
+ static int cnta=0;
+ char sa[128]; snprintf(sa, 127, "SolIcare/DivU%d.vtk", cnta++);
+ getfem::vtk_export tata(sa, PARAM.int_value("VTK_EXPORT")==1);
+ tata.exporting(mf_rhs);
+ tata.write_point_data(mf_rhs, DIV, "divergence");
}
- if (PARAM.int_value("VTK_EXPORT")) {
- static int cnta=0;
- char sa[128]; snprintf(sa, 127, "SolIcare/DivU%d.vtk", cnta++);
- getfem::vtk_export tata(sa, PARAM.int_value("VTK_EXPORT")==1);
- tata.exporting(mf_rhs);
- tata.write_point_data(mf_rhs, DIV, "divergence");
- }
-
}
do_export(t);
-
+
//
// SORTIES : Coefficient de Train� (Cd) et de Portance (Cl)
//
-
-
-
- if (N==2) {
+ if (N == 2) {
std::vector<scalar_type> Cxn(1), Cxp(1), Cyn(1), Cyp(1);
getfem :: mesh_region mpioncylinder =
mf_u.linked_mesh().get_mpi_sub_region(ON_CYLINDER_BOUNDARY_NUM);
//Cxn[0] = 0; Cxp[0] = 0; Cyn[0] = 0; Cyp[0] = 0;
@@ -1743,67 +1681,65 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
coeffTP<<t<<" "<<nu*Cxn[0]<<" "<<Cxp[0]<<" "<<nu*Cxn[0]+Cxp[0]<<"
"<<nu*Cyn[0]<<" "<<Cyp[0]<<" "<<nu*Cyn[0]+Cyp[0]<<" "<<endl;
ptPartData << t << " " << Un1[size_type(ptPartU[2])] << " " <<
Un1[size_type(ptPartU[2] + 1)] << " " << Pn1[size_type(ptPartP[2])] << endl;
}
-
- if (N==3) {
+
+ if (N == 3) {
std::vector<scalar_type> Cxn(1), Cxp(1), Cyn(1), Cyp(1);
getfem :: mesh_region mpioncylinder =
mf_u.linked_mesh().get_mpi_sub_region(ON_CYLINDER_BOUNDARY_NUM);
getfem :: ClCd3D(Cxn,Cxp,Cyn,Cyp,mim,mf_u,mf_p,Un0,Pn1,mpioncylinder);
coeffTP <<t<<" "<<Cxn[0]<<" "<<Cxp[0]<<" "<<Cxn[0]+Cxp[0]<<"
"<<Cyn[0]<<" "<<Cyp[0]<<" "<<Cyn[0]+Cyp[0]<<" " << endl;
ptPartData <<t<<" "<<Un1[size_type(ptPartU[3])]<<"
"<<Un1[size_type(ptPartU[3]+1)]<<" " <<Un1[size_type(ptPartU[3]+2)]<<"
"<<Pn1[size_type(ptPartP[3])]<< endl;
}
-
}
-
-
+
coeffTP.close();
ptPartData.close();
}
void navier_stokes_problem::do_export(scalar_type t) {
/*dal :: bit_vector ddd = mf_p.points_index();
- cout << ddd << endl;*/
+ cout << ddd << endl;*/
if (!export_to_opendx) return;
if (first_export) {
mf_u.write_to_file("SolIcare/icare.mf_u", true);
mf_p.write_to_file("SolIcare/icare.mf_p", true);
mim.write_to_file("SolIcare/icare.mim",true);
- std::ofstream Uformat("Uformat.data");
-
- for(unsigned i=0;i<mf_u.nb_dof();++i){
- base_node G = mf_u.point_of_basic_dof(i);
- if (N==2){
- Uformat << G[0] << " " << G[1] << endl;
- }
- }
-// if (N==3){
-// for(unsigned i=0;i<mf_u.nb_dof();++i){
-// base_node G = mf_u.point_of_basic_dof(i);
-// Uformat << G[0] << " " << G[1] << " " << G[2] << endl;
-// }
-// }
- Uformat.close();
-
- std::ofstream Pformat("Pformat.data");
-
- for(unsigned i=0;i<mf_p.nb_dof();++i){
- base_node G = mf_p.point_of_basic_dof(i);
- if (N==2){
- Pformat << G[0] << " " << G[1] << endl;
- }
+ std::ofstream Uformat("Uformat.data");
+
+ for (unsigned i=0;i<mf_u.nb_dof();++i) {
+ base_node G = mf_u.point_of_basic_dof(i);
+ if (N == 2) {
+ Uformat << G[0] << " " << G[1] << endl;
+ }
}
-
-// if (N==3){
-// for(unsigned i=0;i<mf_p.nb_dof();++i){
-// base_node G = mf_p.point_of_basic_dof(i);
-// Pformat << G[0] << " " << G[1] << " " << G[2] << endl;
-// }
-// }
- Pformat.close();
-
- exp = std::make_unique<getfem::dx_export>(datafilename + ".dx", false);
- if (N <= 2)
- sl.build(mesh, getfem::slicer_none(),2);
+// if (N == 3) {
+// for(unsigned i=0; i < mf_u.nb_dof(); ++i) {
+// base_node G = mf_u.point_of_basic_dof(i);
+// Uformat << G[0] << " " << G[1] << " " << G[2] << endl;
+// }
+// }
+ Uformat.close();
+
+ std::ofstream Pformat("Pformat.data");
+
+ for (unsigned i=0;i<mf_p.nb_dof();++i) {
+ base_node G = mf_p.point_of_basic_dof(i);
+ if (N == 2) {
+ Pformat << G[0] << " " << G[1] << endl;
+ }
+ }
+
+// if (N == 3) {
+// for(unsigned i=0; i < mf_p.nb_dof(); ++i) {
+// base_node G = mf_p.point_of_basic_dof(i);
+// Pformat << G[0] << " " << G[1] << " " << G[2] << endl;
+// }
+// }
+ Pformat.close();
+
+ exp = std::make_unique<getfem::dx_export>(datafilename + ".dx", false);
+ if (N <= 2)
+ sl.build(mesh, getfem::slicer_none(),2);
else
sl.build(mesh, getfem::slicer_boundary(mesh),2);
exp->exporting(sl,true);
@@ -1811,24 +1747,25 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
t_export = 0;
first_export = false;
}
- if ((t >= t_export-dt/20.0)||(t>=99)) {
+
+ if (t >= t_export-dt/20.0 || t >= 99) {
t_export += dt_export;
-
+
static int cnt = 0;
char s[128]; snprintf(s, 127, "SolIcare/icare.U%d", cnt++);
gmm::vecsave(s, Un0);
exp->write_point_data(mf_u, Un0);
exp->serie_add_object("velocity");
-
+
cout << "Saving Pressure, |p| = " << gmm::vect_norm2(Pn1) << "\n";
exp->write_point_data(mf_p, Pn1);
exp->serie_add_object("pressure");
-
+
static int cntp=0;
char sp[128]; snprintf(sp, 127, "SolIcare/icare.P%d", cntp++);
gmm::vecsave(sp, Pn0);
-
- if (PARAM.int_value("TIME_ORDER")==2){
+
+ if (PARAM.int_value("TIME_ORDER") == 2) {
static int cntm1 = 0;
char sm1[128]; snprintf(sm1, 127, "SolIcare/icare.Um%d", cntm1++);
gmm::vecsave(sm1, Unm1);
@@ -1836,14 +1773,14 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
exp->serie_add_object("velocity");
}
-
//if (N == 2) {
- //plain_vector DU(mf_rhs.nb_dof() * N * N);
- //plain_vector Rot(mf_rhs.nb_dof());
- //compute_gradient(mf_u, mf_rhs, Un0, DU);
- //for (unsigned i=0; i < mf_rhs.nb_dof(); ++i) {
- //Rot[i] = DU[i*N*N + 3] - DU[i*N*N + 2];
- //if ((Rot[i]*Rot[i])<=1.5){Rot[i]=0;}
+ // plain_vector DU(mf_rhs.nb_dof() * N * N);
+ // plain_vector Rot(mf_rhs.nb_dof());
+ // compute_gradient(mf_u, mf_rhs, Un0, DU);
+ // for (unsigned i=0; i < mf_rhs.nb_dof(); ++i) {
+ // Rot[i] = DU[i*N*N + 3] - DU[i*N*N + 2];
+ // if ((Rot[i]*Rot[i])<=1.5)
+ // Rot[i]=0;
// }
// cout << "Saving Rot, |rot| = " << gmm::vect_norm2(Rot) << "\n";
// exp->write_point_data(mf_rhs, Rot);
@@ -1854,17 +1791,17 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
static int cnta=0;
char sa[128]; snprintf(sa, 127, "SolIcare/icareU%d.vtk", cnta++);
getfem::vtk_export tata( sa,PARAM.int_value("VTK_EXPORT")==1);
- tata.exporting(mf_u);
+ tata.exporting(mf_u);
tata.write_point_data(mf_u, Un0, "vitesse");
-
- if (PARAM.int_value("TIME_ORDER")==2){
- static int cntam1=0;
- char sam1[128]; snprintf(sam1, 127, "SolIcare/icareUm%d.vtk", cntam1++);
- getfem::vtk_export tamtam( sam1,PARAM.int_value("VTK_EXPORT")==1);
- tamtam.exporting(mf_u);
- tamtam.write_point_data(mf_u, Unm1, "vitesse");
+
+ if (PARAM.int_value("TIME_ORDER") == 2) {
+ static int cntam1=0;
+ char sam1[128]; snprintf(sam1, 127, "SolIcare/icareUm%d.vtk",
cntam1++);
+ getfem::vtk_export tamtam( sam1,PARAM.int_value("VTK_EXPORT")==1);
+ tamtam.exporting(mf_u);
+ tamtam.write_point_data(mf_u, Unm1, "vitesse");
}
-
+
static int cnte=0;
char se[128]; snprintf(se, 127, "SolIcare/icareP%d.vtk", cnte++);
getfem::vtk_export tete( se,PARAM.int_value("VTK_EXPORT")==1);
@@ -1877,7 +1814,7 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
//titi.exporting(mf_rhs);
//titi.write_point_data(mf_rhs, Rot, "rotationnel");
}
-
+
//else if (N == 3) {
// plain_vector DU(mf_rhs.nb_dof() * N * N);
//plain_vector RotX(mf_rhs.nb_dof());
@@ -1885,7 +1822,7 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
//plain_vector RotZ(mf_rhs.nb_dof());
//compute_gradient(mf_u, mf_rhs, Un0, DU);
//for (unsigned i=0; i < mf_rhs.nb_dof(); ++i) {
- // RotX[i] = DU[i*N*N + 7] - DU[i*N*N + 5];
+ // RotX[i] = DU[i*N*N + 7] - DU[i*N*N + 5];
// RotY[i] = DU[i*N*N + 2] - DU[i*N*N + 6];
// RotZ[i] = DU[i*N*N + 3] - DU[i*N*N + 1];
//
@@ -1913,11 +1850,11 @@ gmm :: sub_interval SUB_CT_P(0,nbdof_p);
/**************************************************************************/
int main(int argc, char *argv[]) {
- GETFEM_MPI_INIT(argc,argv);// For parallelized version
+ GETFEM_MPI_INIT(argc,argv);// For parallelized version
// DAL_SET_EXCEPTION_DEBUG; // Exceptions make a memory fault, to debug.
FE_ENABLE_EXCEPT; // Enable floating point exception for Nan.
- try {
+ try {
navier_stokes_problem p;
p.PARAM.read_command_line(argc, argv);
p.init();
@@ -1927,5 +1864,5 @@ int main(int argc, char *argv[]) {
GMM_STANDARD_CATCH_ERROR;
GETFEM_MPI_FINALIZE;
- return 0;
+ return 0;
}
diff --git a/contrib/xfem_contact/xfem_stokes.cc
b/contrib/xfem_contact/xfem_stokes.cc
index 1b4bad2a..3bda6b57 100644
--- a/contrib/xfem_contact/xfem_stokes.cc
+++ b/contrib/xfem_contact/xfem_stokes.cc
@@ -73,14 +73,13 @@ int u_version;
* Exact solution for the velocity u
*/
- base_small_vector u_exact(const base_node &p){
- return base_small_vector (
-
p[0]*p[0]*(p[0]-1.0)*(p[0]-1.0)*(2.0*p[1]-6.0*p[1]*p[1]+4.0*p[1]*p[1]*p[1]),
-
-p[1]*p[1]*(p[1]-1.0)*(p[1]-1.0)*(2.0*p[0]-6.0*p[0]*p[0]+4.0*p[0]*p[0]*p[0]) )
;
+ base_small_vector u_exact(const base_node &p) {
+ return base_small_vector(
+
p[0]*p[0]*(p[0]-1.0)*(p[0]-1.0)*(2.0*p[1]-6.0*p[1]*p[1]+4.0*p[1]*p[1]*p[1]),
+
-p[1]*p[1]*(p[1]-1.0)*(p[1]-1.0)*(2.0*p[0]-6.0*p[0]*p[0]+4.0*p[0]*p[0]*p[0]) ) ;
}
-
-/*
+/*
* Exact solution for the pressure p
*/
@@ -102,7 +101,7 @@ int u_version;
* Value of the normal derivative on the box boundary.
*/
base_small_vector g_exact(const base_node &p){
-
+
if (p[0] < 1e-7) {
return base_small_vector( 0.0, -2.0*p[1]*p[1]*(p[1]-1.0)*(p[1]-1.0)
) ;
@@ -122,7 +121,7 @@ int u_version;
else {
return base_small_vector( 0.0, 0.0
) ;
- }
+ }
}
/*
@@ -131,7 +130,7 @@ int u_version;
base_small_vector rhs(const base_node &p){
return base_small_vector( -nu*(
(4*(2*p[1]-1))*(6*p[1]*p[1]*p[0]*p[0]+p[1]*p[1]-6*p[1]*p[1]*p[0]-6*p[0]*p[0]*p[1]-p[1]+6*p[0]*p[1]-6*p[0]*p[0]*p[0]+3*p[0]*p[0]+3*p[0]*p[0]*p[0]*p[0])
) + 2.0*p[0]*p[1]*p[1],
- -nu*(
-(4*(-1+2*p[0]))*(6*p[1]*p[1]*p[0]*p[0]+p[0]*p[0]-6*p[0]*p[0]*p[1]-6*p[1]*p[1]*p[0]+6*p[0]*p[1]-p[0]+3*p[1]*p[1]*p[1]*p[1]-6*p[1]*p[1]*p[1]+3*p[1]*p[1])
) + 2.0*p[1]*p[0]*p[0] );
+ -nu*(
-(4*(-1+2*p[0]))*(6*p[1]*p[1]*p[0]*p[0]+p[0]*p[0]-6*p[0]*p[0]*p[1]-6*p[1]*p[1]*p[0]+6*p[0]*p[1]-p[0]+3*p[1]*p[1]*p[1]*p[1]-6*p[1]*p[1]*p[1]+3*p[1]*p[1])
) + 2.0*p[1]*p[0]*p[0] );
}
/*
@@ -142,20 +141,20 @@ int u_version;
double R = Radius;
return (p[0]-0.5)*(p[0]-0.5) + (p[1]-0.5)*(p[1]-0.5)- R*R;
}
-
+
/*
* Test procedure
*/
void test_mim(getfem::mesh_im_level_set &mim, getfem::mesh_fem &mf_rhs,
- bool bound) {
+ bool bound) {
if (!u_version) {
unsigned N = unsigned(mim.linked_mesh().dim());
size_type nbdof = mf_rhs.nb_dof();
plain_vector V(nbdof), W(1);
std::fill(V.begin(), V.end(), 1.0);
-
+
getfem::generic_assembly assem("u=data(#1); V()+=comp(Base(#1))(i).u(i);");
assem.push_mi(mim); assem.push_mf(mf_rhs); assem.push_data(V);
assem.push_vec(W);
@@ -169,7 +168,7 @@ void test_mim(getfem::mesh_im_level_set &mim,
getfem::mesh_fem &mf_rhs,
}
if (bound) cout << "Boundary length: "; else cout << "Area: ";
cout << W[0] << " should be " << exact << endl;
- assert(gmm::abs(exact-W[0])/exact < 0.01);
+ assert(gmm::abs(exact-W[0])/exact < 0.01);
}
}
@@ -177,8 +176,7 @@ void test_mim(getfem::mesh_im_level_set &mim,
getfem::mesh_fem &mf_rhs,
* Assembly of stabilization terms
*/
-
-template<typename VECT1> class level_set_unit_normal
+template<typename VECT1> class level_set_unit_normal
: public getfem::nonlinear_elem_term {
const getfem::mesh_fem &mf;
const VECT1 &U;
@@ -187,16 +185,16 @@ template<typename VECT1> class level_set_unit_normal
bgeot::base_vector coeff;
bgeot::multi_index sizes_;
public:
- level_set_unit_normal(const getfem::mesh_fem &mf_, const VECT1 &U_)
+ level_set_unit_normal(const getfem::mesh_fem &mf_, const VECT1 &U_)
: mf(mf_), U(U_), N(mf_.linked_mesh().dim()), gradU(1, N)
{ sizes_.resize(1); sizes_[0] = short_type(N); }
const bgeot::multi_index &sizes(size_type) const { return sizes_; }
virtual void compute(getfem::fem_interpolation_context& ctx,
- bgeot::base_tensor &t) {
+ bgeot::base_tensor &t) {
size_type cv = ctx.convex_num();
coeff.resize(mf.nb_basic_dof_of_element(cv));
gmm::copy(gmm::sub_vector(U,
gmm::sub_index(mf.ind_basic_dof_of_element(cv))),
- coeff);
+ coeff);
ctx.pf()->interpolation_grad(ctx, coeff, gradU, 1);
scalar_type norm = gmm::vect_norm2(gmm::mat_row(gradU, 0));
for (size_type i = 0; i < N; ++i) t[i] = - gradU(0, i) / norm;
@@ -207,7 +205,7 @@ public:
template<class MAT>
void asm_stabilization_mixed_term
-(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
+(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
const getfem::mesh_fem &mf_mult, getfem::level_set &ls,
const getfem::mesh_region &rg = getfem::mesh_region::all_convexes()) {
MAT &RM = const_cast<MAT &>(RM_);
@@ -216,7 +214,7 @@ void asm_stabilization_mixed_term
nterm(ls.get_mesh_fem(), ls.values());
getfem::generic_assembly assem("t=comp(vBase(#2).vGrad(#1).NonLin(#3));"
- "M(#2, #1)+= t(:,j,:,j,i,i)");
+ "M(#2, #1)+= t(:,j,:,j,i,i)");
assem.push_mi(mim);
assem.push_mf(mf);
assem.push_mf(mf_mult);
@@ -229,7 +227,7 @@ void asm_stabilization_mixed_term
template<class MAT>
void asm_stabilization_symm_term
-(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
+(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
getfem::level_set &ls,
const getfem::mesh_region &rg = getfem::mesh_region::all_convexes()) {
MAT &RM = const_cast<MAT &>(RM_);
@@ -239,7 +237,7 @@ void asm_stabilization_symm_term
getfem::generic_assembly
assem("t=comp(vGrad(#1).NonLin(#2).vGrad(#1).NonLin(#2));"
- "M(#1, #1)+= sym(t(:,k,i,i,:,k,j,j))");
+ "M(#1, #1)+= sym(t(:,k,i,i,:,k,j,j))");
assem.push_mi(mim);
assem.push_mf(mf);
assem.push_mf(ls.get_mesh_fem());
@@ -250,56 +248,50 @@ void asm_stabilization_symm_term
-
-
template<class MAT>
-void asm_mass_matrix_pl(const MAT &RM_, const getfem::mesh_im &mim, const
getfem::mesh_fem &mf_p, const getfem::mesh_fem &mf,
- getfem::level_set &ls,
- const getfem::mesh_region &rg
= getfem::mesh_region::all_convexes()) {
- MAT &RM = const_cast<MAT &>(RM_);
-
- level_set_unit_normal<std::vector<scalar_type> >
+void asm_mass_matrix_pl(const MAT &RM_, const getfem::mesh_im &mim,
+ const getfem::mesh_fem &mf_p, const getfem::mesh_fem
&mf,
+ getfem::level_set &ls,
+ const getfem::mesh_region &rg =
getfem::mesh_region::all_convexes()) {
+ MAT &RM = const_cast<MAT &>(RM_);
+
+ level_set_unit_normal<std::vector<scalar_type> >
nterm(ls.get_mesh_fem(), ls.values());
-
- getfem::generic_assembly
+
+ getfem::generic_assembly
assem("t=comp(Base(#1).vBase(#2).NonLin(#3));"
- "M(#1, #2)+= t(:,:,i,i)");
- assem.push_mi(mim);
- assem.push_mf(mf_p);
- assem.push_mf(mf);
- assem.push_mf(ls.get_mesh_fem());
- assem.push_mat(RM);
- assem.push_nonlinear_term(&nterm);
- assem.assembly(rg);
+ "M(#1, #2)+= t(:,:,i,i)");
+ assem.push_mi(mim);
+ assem.push_mf(mf_p);
+ assem.push_mf(mf);
+ assem.push_mf(ls.get_mesh_fem());
+ assem.push_mat(RM);
+ assem.push_nonlinear_term(&nterm);
+ assem.assembly(rg);
}
-
template<class MAT>
-void asm_mass_matrix_up(const MAT &RM_, const getfem::mesh_im &mim, const
getfem::mesh_fem &mf_p, const getfem::mesh_fem &mf,
- getfem::level_set &ls,
- const getfem::mesh_region &rg =
getfem::mesh_region::all_convexes()) {
- MAT &RM = const_cast<MAT &>(RM_);
-
- level_set_unit_normal<std::vector<scalar_type> >
+void asm_mass_matrix_up(const MAT &RM_, const getfem::mesh_im &mim,
+ const getfem::mesh_fem &mf_p, const getfem::mesh_fem
&mf,
+ getfem::level_set &ls,
+ const getfem::mesh_region &rg =
getfem::mesh_region::all_convexes()) {
+ MAT &RM = const_cast<MAT &>(RM_);
+
+ level_set_unit_normal<std::vector<scalar_type> >
nterm(ls.get_mesh_fem(), ls.values());
-
- getfem::generic_assembly
+
+ getfem::generic_assembly
assem("t=comp(Base(#1).NonLin(#3).NonLin(#3).vGrad(#2));"
- "M(#1, #2)+= t(:,i,j,:,i,j)");
- assem.push_mi(mim);
- assem.push_mf(mf_p);
- assem.push_mf(mf);
- assem.push_mf(ls.get_mesh_fem());
- assem.push_mat(RM);
- assem.push_nonlinear_term(&nterm);
- assem.assembly(rg);
+ "M(#1, #2)+= t(:,i,j,:,i,j)");
+ assem.push_mi(mim);
+ assem.push_mf(mf_p);
+ assem.push_mf(mf);
+ assem.push_mf(ls.get_mesh_fem());
+ assem.push_mat(RM);
+ assem.push_nonlinear_term(&nterm);
+ assem.assembly(rg);
}
-
-
-
-
-
@@ -317,28 +309,28 @@ void compute_mass_matrix_extra_element
bgeot::geotrans_inv_convex gic;
bgeot::base_tensor t1, t2;
getfem::base_matrix G1, G2;
-
+
const getfem::mesh &m(mf.linked_mesh());
-
+
GMM_ASSERT1(mf.convex_index().is_in(cv1) && mim.convex_index().is_in(cv1) &&
- mf.convex_index().is_in(cv2) && mim.convex_index().is_in(cv2),
- "Bad element");
-
+ mf.convex_index().is_in(cv2) && mim.convex_index().is_in(cv2),
+ "Bad element");
+
bgeot::pgeometric_trans pgt1 = m.trans_of_convex(cv1);
getfem::pintegration_method pim1 = mim.int_method_of_element(cv1);
getfem::papprox_integration pai1 =
getfem::get_approx_im_or_fail(pim1);
getfem::pfem pf1 = mf.fem_of_element(cv1);
size_type nbd1 = pf1->nb_dof(cv1);
-
+
if (pf1 != pf1_old || pai1 != pai1_old) {
pfp1 = fem_precomp(pf1, pai1->pintegration_points(), pim1);
pf1_old = pf1; pai1_old = pai1;
}
-
+
bgeot::vectors_to_base_matrix(G1, m.points_of_convex(cv1));
getfem::fem_interpolation_context ctx1(pgt1, pfp1, 0, G1, cv1,
short_type(-1));
-
+
getfem::pfem pf2 = mf.fem_of_element(cv2);
size_type nbd2 = pf1->nb_dof(cv2);
base_node xref2(pf2->dim());
@@ -348,9 +340,9 @@ void compute_mass_matrix_extra_element
gmm::resize(M, nbd1, nbd2); gmm::clear(M);
bgeot::vectors_to_base_matrix(G2, m.points_of_convex(cv2));
-
+
getfem::fem_interpolation_context ctx2(pgt2, pf2, base_node(pgt2->dim()),
- G2, cv2, short_type(-1));
+ G2, cv2, short_type(-1));
for (unsigned ii=0; ii < pai1->nb_points_on_convex(); ++ii) {
ctx1.set_ii(ii);
@@ -363,37 +355,35 @@ void compute_mass_matrix_extra_element
pf1->real_base_value(ctx1, t1);
pf2->real_base_value(ctx2, t2);
-
+
for (size_type i = 0; i < nbd1; ++i)
for (size_type j = 0; j < nbd2; ++j)
- M(i,j) += t1[i] * t2[j] * coeff;
+ M(i,j) += t1[i] * t2[j] * coeff;
}
-
}
-/*
- * Main program
+/*
+ * Main program
*/
int main(int argc, char *argv[]) {
GMM_SET_EXCEPTION_DEBUG; // Exceptions make a memory fault, to debug.
FE_ENABLE_EXCEPT; // Enable floating point exception for Nan.
-
+
// Read parameters.
bgeot::md_param PARAM;
PARAM.read_command_line(argc, argv);
u_version = int(PARAM.int_value("EXACT_SOL", "Which exact solution"));
nu = double(PARAM.real_value("NU", "Viscosité"));
-
-
+
// Load the mesh
getfem::mesh mesh;
-
- std::string MESH_FILE = PARAM.string_value("MESH_FILE", "Mesh file");
- getfem::import_mesh(MESH_FILE, mesh);
+
+ std::string MESH_FILE = PARAM.string_value("MESH_FILE", "Mesh file");
+ getfem::import_mesh(MESH_FILE, mesh);
/* //to make tables for results
Nxy = PARAM.int_value("Nxy","Number of subdivision for the mesh in x and y
direction");
@@ -408,47 +398,46 @@ int main(int argc, char *argv[]) {
getfem::import_mesh(meshname, mesh);
*/
unsigned N = mesh.dim();
-
+
// center the mesh in (0, 0).
base_node Pmin(N), Pmax(N);
mesh.bounding_box(Pmin, Pmax);
Pmin += Pmax; Pmin /= -2.0;
// Pmin[N-1] = -Pmax[N-1];
-
+
// mesh.translation(Pmin);
-
+
scalar_type h = mesh.minimal_convex_radius_estimate();
cout << "h = " << h << endl;
-
+
/*
* Level set definition
*/
unsigned lsdeg = unsigned(PARAM.int_value("LEVEL_SET_DEGREE", "level set
degree"));
- bool simplify_level_set =
+ bool simplify_level_set =
(PARAM.int_value("SIMPLIFY_LEVEL_SET",
- "simplification or not of the level sets") != 0);
+ "simplification or not of the level sets") != 0);
Radius = PARAM.real_value("RADIUS", "Domain radius");
getfem::level_set ls(mesh, dim_type(lsdeg));
//getfem::level_set lsup(mesh, dim_type(lsdeg), true), lsdown(mesh,
dim_type(lsdeg), true);
const getfem::mesh_fem &lsmf = ls.get_mesh_fem();
- for (unsigned i = 0; i < lsmf.nb_dof(); ++i) {
+ for (unsigned i = 0; i < lsmf.nb_dof(); ++i)
ls.values()[i] = ls_value(lsmf.point_of_basic_dof(i));
- }
-
-
+
+
if (simplify_level_set) {
scalar_type simplify_rate = std::min(0.03, 0.05 * sqrt(h));
cout << "Simplification of level sets with rate: " <<
simplify_rate << endl;
ls.simplify(simplify_rate);
// lsup.simplify(simplify_rate);
- // lsdown.simplify(simplify_rate);
+ // lsdown.simplify(simplify_rate);
}
-
- getfem::mesh_level_set mls(mesh); //, mlsup(mesh), mlsdown(mesh);
+
+ getfem::mesh_level_set mls(mesh); //, mlsup(mesh), mlsdown(mesh);
mls.add_level_set(ls);
mls.adapt();
// mlsup.add_level_set(lsup);
@@ -456,62 +445,56 @@ int main(int argc, char *argv[]) {
// mlsdown.add_level_set(lsdown);
// mlsdown.adapt();
-
getfem::mesh mcut;
mls.global_cut_mesh(mcut);
mcut.write_to_file("cut.mesh");
-
-/* getfem::mesh mcutdown;
- mlsdown.global_cut_mesh(mcutdown);
- mcutdown.write_to_file("cutdown.mesh");
- getfem::mesh mcutup;
- mlsup.global_cut_mesh(mcutup);
- mcutup.write_to_file("cutup.mesh");
-
-*/
-
-
-
-
+
+/* getfem::mesh mcutdown;
+ mlsdown.global_cut_mesh(mcutdown);
+ mcutdown.write_to_file("cutdown.mesh");
+ getfem::mesh mcutup;
+ mlsup.global_cut_mesh(mcutup);
+ mcutup.write_to_file("cutup.mesh");
+*/
+
// Integration method on the domain
std::string IM = PARAM.string_value("IM", "Mesh file");
std::string IMS = PARAM.string_value("IM_SIMPLEX", "Mesh file");
int intins = getfem::mesh_im_level_set::INTEGRATE_OUTSIDE;
getfem::mesh_im uncutmim(mesh);
uncutmim.set_integration_method(mesh.convex_index(),
- getfem::int_method_descriptor(IM));
+ getfem::int_method_descriptor(IM));
getfem::mesh_im_level_set mim(mls, intins,
- getfem::int_method_descriptor(IMS));
+ getfem::int_method_descriptor(IMS));
mim.set_integration_method(mesh.convex_index(),
- getfem::int_method_descriptor(IM));
+ getfem::int_method_descriptor(IM));
mim.adapt();
-
-
+
// Integration methods on the boudary
int intbound = getfem::mesh_im_level_set::INTEGRATE_BOUNDARY;
getfem::mesh_im_level_set mimbound(mls, intbound,
- getfem::int_method_descriptor(IMS));
+ getfem::int_method_descriptor(IMS));
mimbound.set_integration_method(mesh.convex_index(),
- getfem::int_method_descriptor(IM));
+ getfem::int_method_descriptor(IM));
mimbound.adapt();
// getfem::mesh_im_level_set mimboundup(mlsup, intbound,
-// getfem::int_method_descriptor(IMS));
+// getfem::int_method_descriptor(IMS));
// mimboundup.set_integration_method(mesh.convex_index(),
-// getfem::int_method_descriptor(IM));
+// getfem::int_method_descriptor(IM));
// mimboundup.adapt();
-
+
// Finite element method for the unknown velocity u
getfem::mesh_fem pre_mf(mesh);
std::string FEM = PARAM.string_value("FEM", "finite element method");
pre_mf.set_qdim(bgeot::dim_type(N));
pre_mf.set_finite_element(mesh.convex_index(),
- getfem::fem_descriptor(FEM));
-
+ getfem::fem_descriptor(FEM));
+
getfem::partial_mesh_fem mf(pre_mf);
-
+
dal::bit_vector kept_dof = select_dofs_from_im(pre_mf, mim);
-
+
dal::bit_vector rejected_elt;
for (dal::bv_visitor cv(mim.convex_index()); !cv.finished(); ++cv)
if (mim.int_method_of_element(cv) == getfem::im_none())
@@ -519,12 +502,12 @@ int main(int argc, char *argv[]) {
mf.adapt(kept_dof, rejected_elt);
size_type nb_dof = mf.nb_dof();
cout << "nb_dof = " << nb_dof << endl;
-
+
// Finite element method for the pressure p
getfem::mesh_fem pre_mf_p(mesh);
std::string FEM_p = PARAM.string_value("FEM_p", "fem for pressure");
pre_mf_p.set_finite_element(mesh.convex_index(),
- getfem::fem_descriptor(FEM_p));
+ getfem::fem_descriptor(FEM_p));
getfem::partial_mesh_fem mf_p(pre_mf_p);
dal::bit_vector kept_dof_p = select_dofs_from_im(pre_mf_p, mim);
dal::bit_vector rejected_elt_p;
@@ -534,109 +517,71 @@ int main(int argc, char *argv[]) {
mf_p.adapt(kept_dof_p, rejected_elt_p);
size_type nb_dof_p = mf_p.nb_dof();
cout << "nb_dof_p = " << nb_dof_p << endl;
-
+
// Finite element method for the rhs
getfem::mesh_fem mf_rhs(mesh);
std::string FEMR = PARAM.string_value("FEM_RHS", "finite element method");
mf_rhs.set_qdim(bgeot::dim_type(N));
mf_rhs.set_finite_element(mesh.convex_index(),
- getfem::fem_descriptor(FEMR));
+ getfem::fem_descriptor(FEMR));
size_type nb_dof_rhs = mf_rhs.nb_dof();
cout << "nb_dof_rhs = " << nb_dof_rhs << endl;
-
+
// A P0 finite element
const getfem::mesh_fem &mf_P0 = getfem::classical_mesh_fem(mesh, 0);
-
+
// Finite element method for the multipliers
getfem::mesh_fem pre_mf_mult(mesh);
std::string FEMM = PARAM.string_value("FEM_MULT", "fem for multipliers");
pre_mf_mult.set_qdim(bgeot::dim_type(N));
pre_mf_mult.set_finite_element(mesh.convex_index(),
- getfem::fem_descriptor(FEMM));
+ getfem::fem_descriptor(FEMM));
getfem::partial_mesh_fem mf_mult(pre_mf_mult);
-
-
-
-
-
+
+
dal::bit_vector kept_dof_mult
= select_dofs_from_im(pre_mf_mult, mimbound, N-1);
mf_mult.adapt(kept_dof_mult, rejected_elt);
-
-
+
size_type nb_dof_mult = mf_mult.nb_dof();
cout << "nb_dof_mult = " << nb_dof_mult << endl;
/*
- // Alternative : RANGE_BASIS ............. gmm
- sparse_matrix BBB(pre_mf.nb_dof(), pre_mf.nb_dof());
- getfem::asm_mass_matrix(BBB, mim, pre_mf, pre_mf);
- std::set<size_type> columns;
- gmm::range_basis(BBB,columns,1.e-12);
- dal::bit_vector kept_dof_mult;
- for (std::set<size_type>:: iterator
it=columns.begin();it!=columns.end();++it){
- kept_dof_mult.add(*it);
- };
- */
-
-
-
-
-
-
-
-
+ // Alternative : RANGE_BASIS ............. gmm
+ sparse_matrix BBB(pre_mf.nb_dof(), pre_mf.nb_dof());
+ getfem::asm_mass_matrix(BBB, mim, pre_mf, pre_mf);
+ std::set<size_type> columns;
+ gmm::range_basis(BBB,columns,1.e-12);
+ dal::bit_vector kept_dof_mult;
+ for (std::set<size_type>:: iterator
it=columns.begin();it!=columns.end();++it) {
+ kept_dof_mult.add(*it);
+ };
+*/
+
// Mass matrix on the boundary
sparse_matrix B2(mf_rhs.nb_dof(), pre_mf.nb_dof());
getfem::asm_mass_matrix(B2, mimbound, mf_rhs, pre_mf);
-
+
sparse_matrix B(nb_dof_mult, nb_dof);
getfem::asm_mass_matrix(B, mimbound, mf_mult, mf);
-
+
int stabilized_dirichlet =
int(PARAM.int_value("STABILIZED_DIRICHLET", "Stabilized version of "
- "Dirichlet condition or not"));
+ "Dirichlet condition or not"));
scalar_type dir_gamma0(0);
sparse_matrix MA(nb_dof_mult, nb_dof_mult), KA(nb_dof, nb_dof);
sparse_matrix BA(nb_dof_mult, nb_dof);
-
-
-
- // Stabilization of the pressure
- sparse_matrix Mup(nb_dof_p, nb_dof);
- sparse_matrix Mpp(nb_dof_p, nb_dof_p);
- sparse_matrix Mpl(nb_dof_p, nb_dof_mult);
-
-
- getfem::asm_mass_matrix(Mpp,mimbound,mf_p,mf_p);
- asm_mass_matrix_pl(Mpl,mimbound,mf_p,mf_mult,ls);
- asm_mass_matrix_up(Mup,mimbound,mf_p,mf,ls);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ // Stabilization of the pressure
+ sparse_matrix Mup(nb_dof_p, nb_dof);
+ sparse_matrix Mpp(nb_dof_p, nb_dof_p);
+ sparse_matrix Mpl(nb_dof_p, nb_dof_mult);
+
+
+ getfem::asm_mass_matrix(Mpp,mimbound,mf_p,mf_p);
+ asm_mass_matrix_pl(Mpl,mimbound,mf_p,mf_mult,ls);
+ asm_mass_matrix_up(Mup,mimbound,mf_p,mf,ls);
+
if (stabilized_dirichlet > 0) {
sparse_row_matrix E1(nb_dof, nb_dof);
@@ -644,8 +589,8 @@ int main(int argc, char *argv[]) {
if (stabilized_dirichlet == 2) {
// Computation of the extrapolation operator
scalar_type min_ratio =
- PARAM.real_value("MINIMAL_ELT_RATIO",
- "Threshold ratio for the fully stab Dirichlet");
+ PARAM.real_value("MINIMAL_ELT_RATIO",
+ "Threshold ratio for the fully stab Dirichlet");
cout << "Computation of the extrapolation operator" << endl;
dal::bit_vector elt_black_list, dof_black_list;
@@ -655,65 +600,63 @@ int main(int argc, char *argv[]) {
getfem::asm_mass_matrix(MC1, mim, mf_P0);
getfem::asm_mass_matrix(MC2, uncutmim, mf_P0);
for (size_type i = 0; i < nbe; ++i) {
- size_type cv = mf_P0.first_convex_of_basic_dof(i);
- ratios[cv] = gmm::abs(MC1(i,i)) / gmm::abs(MC2(i,i));
- if (ratios[cv] > 0 && ratios[cv] < min_ratio) elt_black_list.add(cv);
+ size_type cv = mf_P0.first_convex_of_basic_dof(i);
+ ratios[cv] = gmm::abs(MC1(i,i)) / gmm::abs(MC2(i,i));
+ if (ratios[cv] > 0 && ratios[cv] < min_ratio) elt_black_list.add(cv);
}
-
-
+
sparse_matrix EO(nb_dof, nb_dof);
sparse_row_matrix T1(nb_dof, nb_dof), EX(nb_dof, nb_dof);
asm_mass_matrix(EO, uncutmim, mf);
for (size_type i = 0; i < nb_dof; ++i) {
- bool found = false;
- getfem::mesh::ind_cv_ct ct = mf.convex_to_basic_dof(i);
- getfem::mesh::ind_cv_ct::const_iterator it;
- for (it = ct.begin(); it != ct.end(); ++it)
- if (!elt_black_list.is_in(*it)) found = true;
- if (found)
- { gmm::clear(gmm::mat_col(EO, i)); EO(i,i) = scalar_type(1); }
- else
- dof_black_list.add(i);
+ bool found = false;
+ getfem::mesh::ind_cv_ct ct = mf.convex_to_basic_dof(i);
+ getfem::mesh::ind_cv_ct::const_iterator it;
+ for (it = ct.begin(); it != ct.end(); ++it)
+ if (!elt_black_list.is_in(*it)) found = true;
+ if (found)
+ { gmm::clear(gmm::mat_col(EO, i)); EO(i,i) = scalar_type(1); }
+ else
+ dof_black_list.add(i);
}
bgeot::mesh_structure::ind_set is;
base_matrix Mloc;
for (dal::bv_visitor i(elt_black_list); !i.finished(); ++i) {
- mesh.neighbors_of_convex(i, is);
- size_type cv2 = size_type(-1);
- scalar_type ratio = scalar_type(0);
- for (size_type j = 0; j < is.size(); ++j) {
- scalar_type r = ratios[is[j]];
- if (r > ratio) { ratio = r; cv2 = is[j]; }
- }
- GMM_ASSERT1(cv2 != size_type(-1), "internal error");
- compute_mass_matrix_extra_element(Mloc, uncutmim, mf, i, cv2);
- for (size_type ii = 0; ii < gmm::mat_nrows(Mloc); ++ii)
- for (size_type jj = 0; jj < gmm::mat_ncols(Mloc); ++jj)
- EX(mf.ind_basic_dof_of_element(i)[ii],
mf.ind_basic_dof_of_element(cv2)[jj])
- += Mloc(ii, jj);
+ mesh.neighbors_of_convex(i, is);
+ size_type cv2 = size_type(-1);
+ scalar_type ratio = scalar_type(0);
+ for (size_type j = 0; j < is.size(); ++j) {
+ scalar_type r = ratios[is[j]];
+ if (r > ratio) { ratio = r; cv2 = is[j]; }
+ }
+ GMM_ASSERT1(cv2 != size_type(-1), "internal error");
+ compute_mass_matrix_extra_element(Mloc, uncutmim, mf, i, cv2);
+ for (size_type ii = 0; ii < gmm::mat_nrows(Mloc); ++ii)
+ for (size_type jj = 0; jj < gmm::mat_ncols(Mloc); ++jj)
+ EX(mf.ind_basic_dof_of_element(i)[ii],
mf.ind_basic_dof_of_element(cv2)[jj])
+ += Mloc(ii, jj);
}
gmm::copy(gmm::identity_matrix(), E1);
gmm::copy(gmm::identity_matrix(), T1);
for (dal::bv_visitor i(dof_black_list); !i.finished(); ++i)
- gmm::copy(gmm::mat_row(EX, i), gmm::mat_row(T1, i));
+ gmm::copy(gmm::mat_row(EX, i), gmm::mat_row(T1, i));
plain_vector BE(nb_dof), BS(nb_dof);
for (dal::bv_visitor i(dof_black_list); !i.finished(); ++i) {
- BE[i] = scalar_type(1);
- // TODO: store LU decomp.
- double rcond;
- gmm::SuperLU_solve(EO, BS, BE, rcond);
- gmm::mult(gmm::transposed(T1), BS, gmm::mat_row(E1, i));
- BE[i] = scalar_type(0);
+ BE[i] = scalar_type(1);
+ // TODO: store LU decomp.
+ double rcond;
+ gmm::SuperLU_solve(EO, BS, BE, rcond);
+ gmm::mult(gmm::transposed(T1), BS, gmm::mat_row(E1, i));
+ BE[i] = scalar_type(0);
}
gmm::clean(E1, 1e-13);
// gmm::clean(EO, 1e-13); cout << "E0 = " << gmm::transposed(EO) <<
endl; getchar();
// cout << "T1 = " << T1 << endl; getchar();
-
cout << "Extrapolation operator computed" << endl;
@@ -721,12 +664,11 @@ int main(int argc, char *argv[]) {
// gmm::mult(E1, gmm::transposed(EO), A1);
// gmm::clean(A1, 1e-13);
// cout << "A1 = " << A1 << endl;
-
}
dir_gamma0 = PARAM.real_value("DIRICHLET_GAMMA0",
- "Stabilization parameter for "
- "Dirichlet condition");
+ "Stabilization parameter for "
+ "Dirichlet condition");
getfem::asm_mass_matrix(MA, mimbound, mf_mult);
asm_stabilization_mixed_term(BA, mimbound, mf, mf_mult, ls);
asm_stabilization_symm_term(KA, mimbound, mf, ls);
@@ -734,11 +676,10 @@ int main(int argc, char *argv[]) {
gmm::scale(BA, -dir_gamma0 * h);
gmm::scale(KA, -dir_gamma0 * h);
- gmm::scale(Mup, dir_gamma0 * h);
- gmm::scale(Mpp, -dir_gamma0 * h);
- gmm::scale(Mpl, dir_gamma0 * h);
-
-
+ gmm::scale(Mup, dir_gamma0 * h);
+ gmm::scale(Mpp, -dir_gamma0 * h);
+ gmm::scale(Mpl, dir_gamma0 * h);
+
if (stabilized_dirichlet == 2) {
sparse_matrix A1(nb_dof_mult, nb_dof);
gmm::copy(BA, A1);
@@ -747,16 +688,14 @@ int main(int argc, char *argv[]) {
gmm::mult(gmm::transposed(E1), KA, A2);
gmm::mult(gmm::transposed(E1), gmm::transposed(A2), gmm::transposed(KA));
}
-
- gmm::add(BA, B);
-
+ gmm::add(BA, B);
}
// Tests
test_mim(mim, mf_rhs, false);
test_mim(mimbound, mf_rhs, true);
- /*
+ /*
* Choose boundaries
*/
getfem::mesh_region r;
@@ -778,28 +717,25 @@ cout << compteur << " " << G[0] << " " << G[1] << endl;
mesh.region(NEUMANN_BOUNDARY_NUM).add(i.cv(),i.f());
}
*/
- mesh.region(DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());
+ mesh.region(DIRICHLET_BOUNDARY_NUM).add(i.cv(),i.f());
}
-
// Model system
getfem::model MS;
-
// Linearized elasticity brick
// MS.add_initialized_fixed_size_data("lambada", plain_vector(1, 0.0)); //
lambada vu comme un scalaire egal à 0
MS.add_initialized_fixed_size_data("nu", plain_vector(1, nu));
MS.add_fem_variable("u", mf);
getfem::add_generic_elliptic_brick(MS, mim, "u", "nu");
-
-
-// getfem::add_isotropic_linearized_elasticity_brick(MS, mim, "u",
"lambada", "nu");
+
+// getfem::add_isotropic_linearized_elasticity_brick(MS, mim, "u", "lambada",
"nu");
// Linearized incompressibility condition brick
MS.add_fem_variable("p", mf_p); // Adding the pressure as variable
- add_linear_incompressibility(MS, mim, "u", "p");
-
+ add_linear_incompressibility(MS, mim, "u", "p");
+
/*
// Neumann condition on the box boundary
plain_vector G(nb_dof_rhs);
@@ -808,7 +744,7 @@ cout << compteur << " " << G[0] << " " << G[1] << endl;
MS.add_initialized_fem_data("NeumannData", mf_rhs, G);
getfem::add_source_term_brick(MS, mim, "u", "NeumannData",
NEUMANN_BOUNDARY_NUM);
*/
-
+
/* // Neumann condition on the level-set lsup
MS.add_multiplier("LAMBDAN", mf_mult, "u");
plain_vector G(nb_dof_rhs);
@@ -820,92 +756,80 @@ cout << compteur << " " << G[0] << " " << G[1] << endl;
//getfem::add_constraint_with_multipliers(MS, "u", "LAMBDAN",
gmm::transposed(B2), G2);
getfem::add_source_term_brick(MS, mim, "u", "Neumanndata");
*/
-
-
- /*plain_vector G(nb_dof_rhs);
- getfem::interpolation_function(mf_rhs, G, g_exact_ls);
- plain_vector G2(mf_mult.nb_dof());
- getfem::interpolation(mf_rhs, mf_mult,G,G2);
-
-
- MS.add_initialized_fem_data("Neumanndata", mf_mult, G2);
- add_source_term_brick(MS,mimboundup,"u","Neumanndata",
NEUMANN_BOUNDARY_NUM);
- */
+
+
+ /*plain_vector G(nb_dof_rhs);
+ getfem::interpolation_function(mf_rhs, G, g_exact_ls);
+ plain_vector G2(mf_mult.nb_dof());
+ getfem::interpolation(mf_rhs, mf_mult,G,G2);
+
+ MS.add_initialized_fem_data("Neumanndata", mf_mult, G2);
+ add_source_term_brick(MS,mimboundup,"u","Neumanndata", NEUMANN_BOUNDARY_NUM);
+ */
// Dirichlet on the box boundary
-
-
-// cout << B << endl;
-
+
+// cout << B << endl;
// Dirichlet condition on the box boundary
MS.add_initialized_fem_data("Dirichletdata", mf, plain_vector(nb_dof));
getfem::add_Dirichlet_condition_with_multipliers(MS, mim, "u", mf,
DIRICHLET_BOUNDARY_NUM, "Dirichletdata");
-
// Dirichlet condition on the level-set lsdown
MS.add_fem_variable("LAMBDA", mf_mult);
plain_vector H(nb_dof_rhs);
getfem::interpolation_function(mf_rhs, H, u_exact);
-
- plain_vector H3(nb_dof_mult);
- getfem :: asm_source_term(H3,mimbound,mf_mult,mf_rhs,H);
-
- cout << mf_mult.nb_dof() << endl;
+
+ plain_vector H3(nb_dof_mult);
+ getfem :: asm_source_term(H3,mimbound,mf_mult,mf_rhs,H);
+
+ cout << mf_mult.nb_dof() << endl;
getfem::add_constraint_with_multipliers(MS, "u", "LAMBDA", B, H3);
-// getfem::add_constraint_with_penalization(MS, "u", 1.e9, B, H3);
-
+// getfem::add_constraint_with_penalization(MS, "u", 1.e9, B, H3);
+
if (stabilized_dirichlet > 0){
- getfem::add_explicit_matrix(MS, "LAMBDA", "LAMBDA", MA);
- getfem::add_explicit_matrix(MS, "u", "u", KA);
-
- getfem::add_explicit_matrix(MS, "u", "p", gmm::transposed(Mup));
- getfem::add_explicit_matrix(MS, "p", "p", Mpp);
- getfem::add_explicit_matrix(MS, "p", "LAMBDA", Mpl);
- getfem::add_explicit_matrix(MS, "LAMBDA", "p", gmm::transposed(Mpl));
- }
+ getfem::add_explicit_matrix(MS, "LAMBDA", "LAMBDA", MA);
+ getfem::add_explicit_matrix(MS, "u", "u", KA);
+ getfem::add_explicit_matrix(MS, "u", "p", gmm::transposed(Mup));
+ getfem::add_explicit_matrix(MS, "p", "p", Mpp);
+ getfem::add_explicit_matrix(MS, "p", "LAMBDA", Mpl);
+ getfem::add_explicit_matrix(MS, "LAMBDA", "p", gmm::transposed(Mpl));
+ }
// Volumic source term
- plain_vector F(nb_dof_rhs);
+ plain_vector F(nb_dof_rhs);
getfem::interpolation_function(mf_rhs, F, rhs);
MS.add_initialized_fem_data("VolumicData", mf_rhs, F);
getfem::add_source_term_brick(MS, mim, "u", "VolumicData");
-//cout << F2 << endl;
-
-
+//cout << F2 << endl;
/* MS.assembly(getfem::model::BUILD_ALL);
- MS.interval_of_variables("u");
- MS.real_tangent_matrix();
- */
-
-
-
-
+ MS.interval_of_variables("u");
+ MS.real_tangent_matrix();
+ */
+
// Solving the problem
// cout << "Total number of unknown: " << final_brick->nb_dof() << endl;
gmm::iteration iter(1e-9, 1, 40000);
getfem::standard_solve(MS, iter);
plain_vector U(nb_dof);
gmm::copy(MS.real_variable("u"), U);
-
+
// plain_vector LAMBDA(nb_dof_rhs);
// gmm::copy(MS.real_variable("LAMBDA"), LAMBDA);
// interpolation of the solution on mf_rhs
plain_vector Uint(nb_dof_rhs), Vint(nb_dof_rhs), Eint(nb_dof_rhs),
Vex(nb_dof_rhs), Uex(nb_dof);
-
+
getfem::interpolation_function(mf_rhs, Vex, u_exact);
getfem::interpolation(mf_rhs, mf, Vex, Uex);
getfem::interpolation_function(mf_rhs, Vint, u_exact);
getfem::interpolation(mf, mf_rhs, U, Uint);
- for (size_type i = 0; i < nb_dof_rhs; ++i) {
- Eint[i] = gmm::abs(Uint[i] - Vint[i]);
- }
-
+ for (size_type i = 0; i < nb_dof_rhs; ++i)
+ Eint[i] = gmm::abs(Uint[i] - Vint[i]);
// computation of error on u.
double errmax = 0.0, exactmax = 0.0;
@@ -916,17 +840,16 @@ cout << compteur << " " << G[0] << " " << G[1] << endl;
}
else Eint[i] = 0.0;
cout << "Linfty error: (absolute) " << errmax << \
- "(relative) " <<100.0 * errmax
/ exactmax << "%" << endl;
+ "(relative) " <<100.0 * errmax / exactmax << "%" << endl;
-
cout << "L2 error: " << getfem::asm_L2_dist(mim, mf, U, mf_rhs, Vint) <<
- "(relative) " << 100.0
+ "(relative) " << 100.0
* getfem::asm_L2_dist(mim, mf, U, mf_rhs, Vint)
/ getfem::asm_L2_norm(mim, mf_rhs, Vint) << "%" << endl;
-
-
+
+
cout << "H1 error: " << getfem::asm_H1_dist(mim, mf, U, mf_rhs, Vint) <<
- "(relative) " << 100.0
+ "(relative) " << 100.0
* getfem::asm_H1_dist(mim, mf, U, mf_rhs, Vint)
/ getfem::asm_H1_norm(mim, mf_rhs, Vint) << "%" << endl;
@@ -937,9 +860,9 @@ cout << "OKKKK" << endl;
gmm::resize(BA, nb_dof_mult, nb_dof_rhs); gmm::clear(BA);
gmm::resize(KA, nb_dof_rhs, nb_dof_rhs); gmm::clear(KA);
gmm::resize(B, nb_dof_mult, nb_dof_mult); gmm::clear(B);
-
+
cout << "OKIDOC" << endl;
-
+
asm_stabilization_mixed_term(BA, mimbounddown, mf_rhs, mf_mult, lsdown);
cout << "OKIDOC" << endl;
@@ -952,7 +875,6 @@ cout << "OKIDOC" << endl;
+ 2 * gmm::vect_sp(BA, Vint, LAMBDA) ) / gmm::vect_sp(KA, Vint, Vint);
-
cout << "L2 error on multipliers: "
<< gmm::sgn(err_l2_mult) * gmm::sqrt(gmm::abs(err_l2_mult)) * 100.0
<< "%" << endl;
@@ -960,14 +882,12 @@ cout << "OKIDOC" << endl;
// cout << " LAMBDA^2: " << gmm::vect_sp(B, LAMBDA, LAMBDA);
// cout << " Double produit: " << 2*gmm::vect_sp(BA, Vint, LAMBDA)<<endl;
-
-
*/
// exporting solution in vtk format.
{
getfem::vtk_export exp("xfem_dirichlet.vtk", (2==1));
- exp.exporting(mf);
+ exp.exporting(mf);
exp.write_point_data(mf, U, "solution");
//cout << "export done, you can view the data file with (for example)\n"
// "mayavi -d xfem_dirichlet.vtk -f WarpScalar -m BandedSurfaceMap "
@@ -976,7 +896,7 @@ cout << "OKIDOC" << endl;
// exporting exact solution in vtk format.
{
getfem::vtk_export exp("xfem_dirichlet_exact.vtk", (2==1));
- exp.exporting(mf);
+ exp.exporting(mf);
exp.write_point_data(mf, Uex, "solution");
//cout << "export done, you can view the data file with (for example)\n"
@@ -986,7 +906,7 @@ cout << "OKIDOC" << endl;
// exporting error in vtk format.
{
getfem::vtk_export exp("xfem_dirichlet_error.vtk", (2==1));
- exp.exporting(mf_rhs);
+ exp.exporting(mf_rhs);
exp.write_point_data(mf_rhs, Eint, "error");
//cout << "export done, you can view the data file with (for example)\n"
// "mayavi -d xfem_dirichlet_error.vtk -f WarpScalar -m BandedSurfaceMap "
@@ -995,7 +915,7 @@ cout << "OKIDOC" << endl;
/* // exporting multipliers in vtk format.
{
getfem::vtk_export exp("xfem_dirichlet_mult.vtk", (2==1));
- exp.exporting(mf_mult);
+ exp.exporting(mf_mult);
exp.write_point_data(mf_mult, LAMBDA, "multipliers");
//cout << "export done, you can view the data file with (for example)\n"
// "mayavi -d xfem_dirichlet_mult.vtk -f WarpScalar -m BandedSurfaceMap "
@@ -1012,32 +932,32 @@ cout << "OKIDOC" << endl;
if (0) {
//cout << "saving the slice solution for matlab\n";
getfem::stored_mesh_slice sl, sl0,sll;
-
-
+
+
getfem::mesh_slicer slicer(mf.linked_mesh());
getfem::slicer_build_stored_mesh_slice sbuild(sl);
getfem::mesh_slice_cv_dof_data<plain_vector> mfU(mf,U);
getfem::slicer_isovalues iso(mfU, 0.0, 0);
getfem::slicer_build_stored_mesh_slice sbuild0(sl0);
-
+
slicer.push_back_action(sbuild); // full slice in sl
slicer.push_back_action(iso); // extract isosurface 0
slicer.push_back_action(sbuild0); // store it into sl0
slicer.exec(nrefine, mf.convex_index());
-
+
getfem::mesh_slicer slicer2(mf.linked_mesh());
- getfem::mesh_slice_cv_dof_data<plain_vector>
+ getfem::mesh_slice_cv_dof_data<plain_vector>
mfL(ls.get_mesh_fem(), ls.values());
getfem::slicer_isovalues iso2(mfL, 0.0, 0);
getfem::slicer_build_stored_mesh_slice sbuildl(sll);
slicer2.push_back_action(iso2); // extract isosurface 0
slicer2.push_back_action(sbuildl); // store it into sl0
slicer2.exec(nrefine, mf.convex_index());
-
+
sl.write_to_file("xfem_dirichlet.sl", true);
sl0.write_to_file("xfem_dirichlet.sl0", true);
sll.write_to_file("xfem_dirichlet.sll", true);
- plain_vector UU(sl.nb_points()), LL(sll.nb_points());
+ plain_vector UU(sl.nb_points()), LL(sll.nb_points());
sl.interpolate(mf, U, UU);
gmm::vecsave("xfem_dirichlet.slU", UU);
// gmm::scale(LAMBDA, 0.005);
@@ -1045,5 +965,5 @@ cout << "OKIDOC" << endl;
gmm::vecsave("xfem_dirichlet.slL", LL);
}
*/
- return 0;
+ return 0;
}
diff --git a/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc
b/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc
index 446be071..2e150d1a 100644
--- a/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc
+++ b/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc
@@ -78,7 +78,7 @@ typedef gmm::row_matrix<sparse_vector> sparse_row_matrix;
/******************************************************************************/
/* level set unit normal *
*/
/******************************************************************************/
-template<typename VECT1> class level_set_unit_normal
+template<typename VECT1> class level_set_unit_normal
: public getfem::nonlinear_elem_term {
const getfem::mesh_fem &mf;
std::vector<scalar_type> U;
@@ -87,7 +87,7 @@ template<typename VECT1> class level_set_unit_normal
bgeot::base_vector coeff;
bgeot::multi_index sizes_;
public:
- level_set_unit_normal(const getfem::mesh_fem &mf_, const VECT1 &U_)
+ level_set_unit_normal(const getfem::mesh_fem &mf_, const VECT1 &U_)
: mf(mf_), U(mf_.nb_basic_dof()), N(mf_.linked_mesh().dim()),
gradU(1, N) {
sizes_.resize(1); sizes_[0] = short_type(N);
@@ -118,7 +118,7 @@ template<typename VECT1> class nonlin_h
size_type cv_old;
scalar_type h;
public:
- nonlin_h(const getfem::mesh &m_)
+ nonlin_h(const getfem::mesh &m_)
: m(m_), N(m.dim())
{
sizes_.resize(1); sizes_[0] = 1;
@@ -142,7 +142,7 @@ public:
/******************************************************************************/
/* level set unit tangent
*/
/******************************************************************************/
-template<typename VECT1> class level_set_unit_tang
+template<typename VECT1> class level_set_unit_tang
: public getfem::nonlinear_elem_term {
const getfem::mesh_fem &mf;
std::vector<scalar_type> U;
@@ -151,7 +151,7 @@ template<typename VECT1> class level_set_unit_tang
bgeot::base_vector coeff;
bgeot::multi_index sizes_;
public:
- level_set_unit_tang(const getfem::mesh_fem &mf_, const VECT1 &U_)
+ level_set_unit_tang(const getfem::mesh_fem &mf_, const VECT1 &U_)
: mf(mf_), U(mf_.nb_basic_dof()), N(mf_.linked_mesh().dim()),
gradU(1, N) {
sizes_.resize(1); sizes_[0] = short_type(N);
@@ -182,18 +182,18 @@ public:
template<class MAT>
void asm_stabilization_mixed_term
-(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
+(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
const getfem::mesh_fem &mf_mult, getfem::level_set &ls,
scalar_type lambda, scalar_type mu,
const getfem::mesh_region &rg = getfem::mesh_region::all_convexes()) {
MAT &RM = const_cast<MAT &>(RM_);
-
+
level_set_unit_normal<std::vector<scalar_type> >
nterm(ls.get_mesh_fem(), ls.values());
plain_vector LAMBDA(1, lambda), MU(1, mu);
-
+
getfem::generic_assembly assem("lambda=data$1(1); mu=data$2(1);"
"t=comp(Base(#2).NonLin(#3).vGrad(#1).NonLin(#3));"
"M(#2, #1)+= t(:,i,:,j,j,i).lambda(1)"
@@ -206,9 +206,9 @@ void asm_stabilization_mixed_term
assem.push_data(MU);
assem.push_mat(RM);
assem.push_nonlinear_term(&nterm);
-
-
- gmm::clear(RM);
+
+
+ gmm::clear(RM);
ls.set_shift(1e-7);
assem.assembly(rg);
ls.set_shift(-1e-7);
@@ -222,12 +222,12 @@ void asm_stabilization_mixed_term
template<class MAT>
void asm_stabilization_tang_mixed_term
-(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
+(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
const getfem::mesh_fem &mf_mult, getfem::level_set &ls,
scalar_type lambda, scalar_type mu,
const getfem::mesh_region &rg = getfem::mesh_region::all_convexes()) {
MAT &RM = const_cast<MAT &>(RM_);
-
+
level_set_unit_normal<std::vector<scalar_type> >
nterm(ls.get_mesh_fem(), ls.values());
@@ -235,12 +235,12 @@ void asm_stabilization_tang_mixed_term
taterm(ls.get_mesh_fem(), ls.values());
plain_vector LAMBDA(1, lambda), MU(1, mu);
-
+
getfem::generic_assembly assem("lambda=data$1(1); mu=data$2(1);"
"t=comp(Base(#2).NonLin$2(#3).vGrad(#1).NonLin$1(#3));"
"M(#2, #1)+= t(:,i,:,i,j,j).mu(1)"
"+t(:,i,:,j,i,j).mu(1)");
-
+
assem.push_mi(mim);
assem.push_mf(mf);
assem.push_mf(mf_mult);
@@ -250,9 +250,9 @@ void asm_stabilization_tang_mixed_term
assem.push_mat(RM);
assem.push_nonlinear_term(&nterm);
assem.push_nonlinear_term(&taterm);
-
- gmm::clear(RM);
+
+ gmm::clear(RM);
ls.set_shift(1e-7);
assem.assembly(rg);
ls.set_shift(-1e-7);
@@ -266,14 +266,14 @@ void asm_stabilization_tang_mixed_term
template<class MAT>
void asm_mass_matrix_mixed_term
-(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
+(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
const getfem::mesh_fem &mf_mult, getfem::level_set &ls,
const getfem::mesh_region &rg = getfem::mesh_region::all_convexes()) {
MAT &RM = const_cast<MAT &>(RM_);
-
+
level_set_unit_normal<std::vector<scalar_type> >
nterm(ls.get_mesh_fem(), ls.values());
-
+
getfem::generic_assembly assem("t=comp(Base(#2).vBase(#1).NonLin(#3));"
"M(#2,#1)+= t(:,:,i,i)");
assem.push_mi(mim);
@@ -282,8 +282,8 @@ void asm_mass_matrix_mixed_term
assem.push_mf(ls.get_mesh_fem());
assem.push_mat(RM);
assem.push_nonlinear_term(&nterm);
-
-
+
+
gmm::clear(RM);
ls.set_shift(1e-7);
assem.assembly(rg);
@@ -301,14 +301,14 @@ void asm_mass_matrix_mixed_term
template<class MAT>
void asm_mass_matrix_tang_mixed_term
-(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
+(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
const getfem::mesh_fem &mf_mult, getfem::level_set &ls,
const getfem::mesh_region &rg = getfem::mesh_region::all_convexes()) {
MAT &RM = const_cast<MAT &>(RM_);
-
+
level_set_unit_tang<std::vector<scalar_type> >
taterm(ls.get_mesh_fem(), ls.values());
-
+
getfem::generic_assembly assem("t=comp(Base(#2).vBase(#1).NonLin(#3));"
"M(#2,#1)+= t(:,:,i,i)");
assem.push_mi(mim);
@@ -317,8 +317,8 @@ void asm_mass_matrix_tang_mixed_term
assem.push_mf(ls.get_mesh_fem());
assem.push_mat(RM);
assem.push_nonlinear_term(&taterm);
-
-
+
+
gmm::clear(RM);
ls.set_shift(1e-7);
assem.assembly(rg);
@@ -336,14 +336,14 @@ void asm_mass_matrix_tang_mixed_term
template<class MAT>
void asm_stabilization_symm_term
-(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
+(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
getfem::level_set &ls, scalar_type lambda, scalar_type mu,
const getfem::mesh_region &rg = getfem::mesh_region::all_convexes()) {
MAT &RM = const_cast<MAT &>(RM_);
-
+
level_set_unit_normal<std::vector<scalar_type> >
nterm(ls.get_mesh_fem(), ls.values());
-
+
plain_vector LAMBDA(1, lambda), MU(1, mu);
getfem::generic_assembly
@@ -375,17 +375,17 @@ void asm_stabilization_symm_term
template<class MAT>
void asm_stabilization_symm_tang_term
-(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
+(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf,
getfem::level_set &ls, scalar_type lambda, scalar_type mu,
const getfem::mesh_region &rg = getfem::mesh_region::all_convexes()) {
MAT &RM = const_cast<MAT &>(RM_);
-
+
level_set_unit_normal<std::vector<scalar_type> >
nterm(ls.get_mesh_fem(), ls.values());
level_set_unit_tang<std::vector<scalar_type> >
taterm(ls.get_mesh_fem(), ls.values());
-
+
plain_vector LAMBDA(1, lambda), MU(1, mu);
getfem::generic_assembly
@@ -415,17 +415,16 @@ void asm_stabilization_symm_tang_term
-
/**************************************************************/
/* assembling patch vector */
/**************************************************************/
template<class VEC>
-void asm_patch_vector
+void asm_patch_vector
(const VEC &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf_mult,
const getfem::mesh_region &rg = getfem::mesh_region::all_convexes()) {
VEC &RM = const_cast<VEC &>(RM_);
-
+
getfem::generic_assembly assem("t=comp(Base(#1)); V(#1)+= t(:);");
assem.push_mi(mim);
assem.push_mf(mf_mult);
@@ -447,13 +446,13 @@ h
#endif
){
MAT &M1 = const_cast<MAT &>(RM_);
-
+
/****************************************************/
/* " select patch " */
/****************************************************/
-
-
-
+
+
+
// assemby patch vector
const getfem::mesh_fem &mf_P0 = getfem::classical_mesh_fem(mesh, 0);
size_type nbe = mf_P0.nb_dof();
@@ -495,14 +494,14 @@ h
if (Patch_element_list.is_in(*it)) { adjncy.push_back(indelt[*it]); ++k;
}
}
}
-
+
xadj[j] = k;
// cout<<"xadj="<<xadj<<endl;
//cout<<"adjncy="<<adjncy<<endl;
//cout<<"vwgt="<<vwgt<<endl;
-
+
cout<<"ratio size beween mesh and coarse mesh= "<< ratio_size <<endl;
-
+
int nparts = 1;
#ifdef GETFEM_HAVE_METIS
nparts = int(size_of_crack/(ratio_size*h));
@@ -534,41 +533,41 @@ h
#else
GMM_ASSERT1(false, "METIS not linked");
#endif
-
+
/**************************************************************/
/* Assembly matrices */
/**************************************************************/
-
-
+
+
std::vector<double> size_patch(nparts);
size_type nb_dof_mult=mf_mult.nb_dof();
sparse_matrix M0(nb_dof_mult, nbe);
getfem::asm_mass_matrix(M0, mimbounddown, mf_mult, mf_P0);
-
+
for (size_type i=0; i < size_type(ne); i++) {
- size_patch[part[i]]= size_patch[part[i]] + vwgtt[i];
+ size_patch[part[i]]= size_patch[part[i]] + vwgtt[i];
}
-
+
//cout<<"size_patch="<<size_patch<<endl;
-
+
sparse_row_matrix MAT_aux(nparts, nb_dof_mult);
for (size_type r=0; r < nbe; r++) {
size_type cv = mf_P0.first_convex_of_basic_dof(r);
gmm::add(gmm::mat_col(M0, r), gmm::mat_row(MAT_aux, part[indelt[cv]]));
}
-
+
sparse_row_matrix MAT_proj(nbe, nb_dof_mult);
-
+
for (size_type r=0; r < nbe; r++) {
size_type cv = mf_P0.first_convex_of_basic_dof(r);
int p=part[indelt[cv]];
gmm::copy(gmm::scaled(gmm::mat_row(MAT_aux, p), 1./size_patch[p]),
gmm::mat_row(MAT_proj, r));
}
-
+
gmm::mult(M0, MAT_proj, M1);
-
+
}
@@ -581,13 +580,13 @@ void asm_mass_matrix_for_inf_sup
(const MAT &RM_, const getfem::mesh_im &mim, const getfem::mesh_fem &mf_mult,
getfem::level_set &ls, const getfem::mesh_region &rg =
getfem::mesh_region::all_convexes()) {
MAT &RM = const_cast<MAT &>(RM_);
-
+
// level_set_unit_normal<std::vector<scalar_type> >
// nterm(ls.get_mesh_fem(), ls.values());
nonlin_h<std::vector<scalar_type> >
nlinh(ls.get_mesh_fem().linked_mesh());
-
-
+
+
getfem::generic_assembly assem("t=comp(NonLin(#2).Base(#1).Base(#1));"
"M(#1,#1)+= t(i,:,:)");
assem.push_mi(mim);
@@ -596,7 +595,7 @@ void asm_mass_matrix_for_inf_sup
assem.push_mat(RM);
// assem.push_nonlinear_term(&nterm);
assem.push_nonlinear_term(&nlinh);
-
+
gmm::clear(RM);
assem.assembly(rg);
@@ -609,7 +608,7 @@ void asm_mass_matrix_for_inf_sup
/**************************************************************************/
struct unilateral_contact_problem {
-
+
enum { DIRICHLET_BOUNDARY_NUM = 0, NEUMANN1_BOUNDARY_NUM = 1,
NEUMANN2_BOUNDARY_NUM=2, NEUMANN3_BOUNDARY_NUM=3, NEUMANN4_BOUNDARY_NUM=4};
getfem::mesh mesh; /* the mesh */
getfem::level_set ls; /* The two level sets defining the crack. */
@@ -618,57 +617,57 @@ struct unilateral_contact_problem {
getfem::mesh_fem mf_pre_u, mf_dir;
getfem::mesh_fem_level_set mfls_u;
getfem::mesh_fem_global_function mf_sing_u;
-
+
getfem::mesh_fem mf_partition_of_unity;
getfem::mesh_fem_product mf_product;
getfem::mesh_fem_sum mf_u_sum;
-
+
getfem::mesh_fem mf_contt; /* mesh_fem for the contact multiplier */
getfem::mesh_fem_level_set mfls_cont; /* mesh_fem for the multiplier
contact enriched with H. */
getfem::mesh_fem_sum mf_cont_sum;
-
-
+
+
base_small_vector cracktip;
-
-
+
+
getfem::mesh_fem& mf_u() { return mf_u_sum; }
getfem::mesh_fem& mf_cont() { return mf_contt; }
getfem::mesh_fem& mf_pre_uu() { return mf_pre_u; }
-
-
+
+
scalar_type mu, lambda; /* Lame coeff */
-
- int dgr; /* Order of enrichement for u */
- scalar_type stabilized_problem;
+
+ int dgr; /* Order of enrichement for u */
+ scalar_type stabilized_problem;
scalar_type friction_coeff;
scalar_type tresca_threshold;
scalar_type ratio_size;
-
+
getfem::mesh_fem mf_rhs; /* mesh_fem for the right hand side (f(x),..) */
-
-
+
+
scalar_type residual; /* max residual for the iterative solvers */
bool contact_only;
bool Tresca_version;
bool Test_of_coer, strmesh, rangeP_P;
scalar_type cutoff_radius, cutoff_radius1, cutoff_radius0, enr_area_radius;
-
+
size_type cutoff_func;
-
- typedef enum { NO_ENRICHMENT=0,
- FIXED_ZONE=1,
+
+ typedef enum { NO_ENRICHMENT=0,
+ FIXED_ZONE=1,
GLOBAL_WITH_CUTOFF=2 } enrichment_option_enum;
enrichment_option_enum enrichment_option;
-
+
scalar_type h, cont_gamma0, R; // mesh parameter
-
-
+
+
std::string datafilename;
-
+
int reference_test;
-
+
bgeot::md_param PARAM;
-
+
bool solve(plain_vector &U, plain_vector &LAMBDA, plain_vector &LAMBDA_T);
void init(void);
unilateral_contact_problem(void) : ls(mesh, 1, true), mls(mesh),
mls_bound(mesh), mim(mls),
@@ -677,12 +676,12 @@ struct unilateral_contact_problem {
mf_sing_u(mesh),
mf_partition_of_unity(mesh),
mf_product(mf_partition_of_unity,
mf_sing_u),
- mf_u_sum(mesh), mf_contt(mesh),
mfls_cont(mls, mf_contt),
+ mf_u_sum(mesh), mf_contt(mesh),
mfls_cont(mls, mf_contt),
mf_cont_sum(mesh),
/*mf_pe(mesh),*/ mf_rhs(mesh)
{}
-};//end structure of unilateral contact problem
+};//end structure of unilateral contact problem
std::string name_of_dof(getfem::pdof_description dof) {
@@ -704,14 +703,14 @@ std::string name_of_dof(getfem::pdof_description dof) {
if (getfem::dof_xfem_index(dof) != 0) {
snprintf(s, 199, "Xfem[idx:%d]", int(dof_xfem_index(dof)));
}
-
+
for (dim_type r = 0; r < d; ++r) {
if (dof == getfem::derivative_dof(d, r)) {
snprintf(s, 199, "D_%c[%d]", "xyzuvw"[r], d); goto found;
}
for (dim_type t = 0; t < d; ++t) {
if (dof == getfem::second_derivative_dof(d, r, t)) {
- snprintf(s, 199, "D2%c%c[%d]", "xyzuvw"[r], "xyzuvw"[t], d);
+ snprintf(s, 199, "D2%c%c[%d]", "xyzuvw"[r], "xyzuvw"[t], d);
goto found;
}
}
@@ -733,7 +732,7 @@ void unilateral_contact_problem::init(void) {
std::string SIMPLEX_INTEGRATION = PARAM.string_value("SIMPLEX_INTEGRATION",
"Name of simplex
integration method");
std::string SINGULAR_INTEGRATION =
PARAM.string_value("SINGULAR_INTEGRATION");
-
+
enrichment_option =
enrichment_option_enum(PARAM.int_value("ENRICHMENT_OPTION",
"Enrichment
option"));
cout << "MESH_TYPE=" << MESH_TYPE << "\n";
@@ -743,18 +742,18 @@ void unilateral_contact_problem::init(void) {
cout << " SIMPLEX_INTEGRATION=" << SIMPLEX_INTEGRATION << "\n";
cout << "SINGULAR_INTEGRATION=" << SINGULAR_INTEGRATION << "\n";
-
+
dgr = int(PARAM.int_value("dgr", "Enrichement order ofu"));
-
-
- mu = PARAM.real_value("Mu", "Lame coefficient mu");
+
+
+ mu = PARAM.real_value("Mu", "Lame coefficient mu");
lambda =PARAM.real_value("Lambda", "Lame coefficient lambda");
-
-
+
+
/* First step : build the mesh */
strmesh=PARAM.int_value("strmesh", "Structured mesh or not");
-
- bgeot::pgeometric_trans pgt =
+
+ bgeot::pgeometric_trans pgt =
bgeot::geometric_trans_descriptor(MESH_TYPE);
size_type N = pgt->dim();
std::vector<size_type> nsubdiv(N);
@@ -764,16 +763,16 @@ void unilateral_contact_problem::init(void) {
getfem::regular_unit_mesh(mesh, nsubdiv, pgt,
PARAM.int_value("MESH_NOISED") != 0);
base_small_vector tt(N); tt[1] = -0.5;
- mesh.translation(tt);
- cout<<"Creting mesh done"<<endl;
-
+ mesh.translation(tt);
+ cout<<"Creting mesh done"<<endl;
+
cracktip.resize(2); // Cordinate of cracktip
cracktip[0] = 0.5;
cracktip[1] = 0.;
}else{
std::string MESH_FILE = PARAM.string_value("MESH_FILE","Mesh file");
mesh.read_from_file(MESH_FILE);
- cout<<"Import non-conforming mesh"<<":"<<MESH_FILE <<endl;
+ cout<<"Import non-conforming mesh"<<":"<<MESH_FILE <<endl;
}
scalar_type refinement_radius;
refinement_radius
@@ -781,7 +780,7 @@ void unilateral_contact_problem::init(void) {
size_type refinement_process;
refinement_process
= PARAM.int_value("REFINEMENT_PROCESS", "Refinement process");
-
+
if (refinement_radius > 0) {
for (size_type ref = 0; ref < refinement_process; ++ref){
dal::bit_vector conv_to_refine;
@@ -792,78 +791,75 @@ void unilateral_contact_problem::init(void) {
conv_to_refine.add(i);
}
mesh.Bank_refine(conv_to_refine);
-
+
refinement_radius = refinement_radius/3.;
cout <<"refining process step " << ref << " ... refining "
<< conv_to_refine.size() <<" convexes..." << endl;
}
cout << "refinement process completed." << endl ;
}
-
+
mesh.write_to_file("toto.mesh");
-
+
h = mesh.maximal_convex_radius_estimate();
// h = 2. * mesh.minimal_convex_radius_estimate();
cout << "h = " << h << endl;
-
+
cont_gamma0 = PARAM.real_value("CONTACT_GAMMA0",
"Stabilization parameter for "
"contact condition");
- R = PARAM.real_value( "R", "augmented parameter");
-
+ R = PARAM.real_value( "R", "augmented parameter");
+
datafilename = PARAM.string_value("ROOTFILENAME","Base name of data files.");
residual = PARAM.real_value("RESIDUAL");
if (residual == 0.) residual = 1e-10;
enr_area_radius = PARAM.real_value("RADIUS_ENR_AREA",
"radius of the enrichment area");
-
- reference_test = int(PARAM.int_value("REFERENCE_TEST", "Reference test"));
-
-
+
+ reference_test = int(PARAM.int_value("REFERENCE_TEST", "Reference test"));
+
cutoff_func = PARAM.int_value("CUTOFF_FUNC", "cutoff function");
-
+
cutoff_radius = PARAM.real_value("CUTOFF", "Cutoff");
cutoff_radius1 = PARAM.real_value("CUTOFF1", "Cutoff1");
cutoff_radius0 = PARAM.real_value("CUTOFF0", "Cutoff0");
mf_u().set_qdim(dim_type(N));
-
+
friction_coeff= PARAM.real_value("FRICTION_COEFF", "Friction_coeff");
tresca_threshold= PARAM.real_value("TRESCA_THRESHOLD", "Tresca_threshold");
ratio_size= PARAM.real_value("RATIO_SIZE", "ratio size beween mesh and
coarse mesh");
-
+
/* set the finite element on the mf_u */
- getfem::pfem pf_u =
+ getfem::pfem pf_u =
getfem::fem_descriptor(FEM_TYPE);
- getfem::pfem pf_mult_cont =
+ getfem::pfem pf_mult_cont =
getfem::fem_descriptor(FEM_TYPE_CONT);
- getfem::pintegration_method ppi =
+ getfem::pintegration_method ppi =
getfem::int_method_descriptor(INTEGRATION);
- getfem::pintegration_method simp_ppi =
+ getfem::pintegration_method simp_ppi =
getfem::int_method_descriptor(SIMPLEX_INTEGRATION);
getfem::pintegration_method sing_ppi = (SINGULAR_INTEGRATION.size() ?
getfem::int_method_descriptor(SINGULAR_INTEGRATION) : 0);
-
+
mim.set_integration_method(mesh.convex_index(), ppi);
mls.add_level_set(ls);
-
+
mim.set_simplex_im(simp_ppi, sing_ppi);
mf_pre_u.set_finite_element(mesh.convex_index(), pf_u);
mf_dir.set_finite_element(mesh.convex_index(), pf_u);
mf_dir.set_qdim(dim_type(N));
mf_partition_of_unity.set_classical_finite_element(1);
-
+
// Integration method on the boudary
-
+
mls_bound.add_level_set(ls);
int intbound = getfem::mesh_im_level_set::INTEGRATE_BOUNDARY;
mimbound.init_with_mls(mls_bound, intbound, simp_ppi, sing_ppi);
mimbound.set_integration_method(mesh.convex_index(), ppi);
-
-
-
-
+
+
contact_only = (PARAM.int_value("CONTACT_ONLY"," contact_only or not.") !=
0);
Tresca_version=(PARAM.int_value("TRESCA_VERSION"," tresca version or not.")
!= 0);
cout<< "Tresca Version="<< Tresca_version<< endl;
@@ -871,11 +867,10 @@ void unilateral_contact_problem::init(void) {
Test_of_coer= (PARAM.int_value("STABILIZED_PROBLEM"," stabilized_problem or
not.") != 0);
rangeP_P =
(PARAM.int_value("rangeP_P"," The creteria of choise in range bases is
performed by comparison to p or not.") != 0);
-
+
mf_contt.set_finite_element(mesh.convex_index(), pf_mult_cont);
-
-
-
+
+
/* set the finite element on mf_rhs (same as mf_u is DATA_FEM_TYPE is
not used in the .param file */
@@ -886,26 +881,26 @@ void unilateral_contact_problem::init(void) {
<< "DATA_FEM_TYPE in the .param file");
mf_rhs.set_finite_element(mesh.convex_index(), pf_u);
} else {
- mf_rhs.set_finite_element(mesh.convex_index(),
+ mf_rhs.set_finite_element(mesh.convex_index(),
getfem::fem_descriptor(data_fem_name));
}
-
+
/* set boundary conditions
* (Neuman on the upper face, Dirichlet elsewhere) */
cout << "Selecting Neumann and Dirichlet boundaries\n";
getfem::mesh_region border_faces;
getfem::outer_faces_of_mesh(mesh, border_faces);
for (getfem::mr_visitor i(border_faces); !i.finished(); ++i) {
-
+
base_node un = mesh.normal_of_face_of_convex(i.cv(), i.f());
un /= gmm::vect_norm2(un);
-
+
if (un[0] > 0.5) mesh.region(NEUMANN1_BOUNDARY_NUM).add(i.cv(), i.f());
if (un[1] > 0.5) mesh.region(NEUMANN2_BOUNDARY_NUM).add(i.cv(), i.f());
if (un[0] < -0.5) mesh.region(NEUMANN3_BOUNDARY_NUM).add(i.cv(), i.f());
if (un[1] < -0.5) mesh.region(NEUMANN4_BOUNDARY_NUM).add(i.cv(), i.f());
}
-
+
}//end intialisation
@@ -918,7 +913,7 @@ base_small_vector ls_function(const base_node P, int num =
0) {
base_small_vector res(2), cracktip(2), t(2), xx(2);
cracktip[0]=0.5; cracktip[1]= 0.;
switch (num) {
-
+
case 0: {
xx[0]= P[0]; xx[1]=P[1];
t[0]= cracktip[0] - x0;
@@ -929,7 +924,7 @@ base_small_vector ls_function(const base_node P, int num =
0) {
res[0]= phi/ll;
res[1]= gmm::vect_sp(xx-cracktip, t);
} break;
-
+
case 1: {
res[0] = y;
res[1] = -0.5 + x;
@@ -950,18 +945,17 @@ base_small_vector ls_function(const base_node P, int num
= 0) {
/****************************************************************************************************/
struct matrix_G {
-
+
const sparse_matrix &B;
const sparse_matrix &S;
mutable plain_vector W1, W2;
-
- gmm::SuperLU_factor<scalar_type> SLUF;
+ gmm::SuperLU_factor<scalar_type> SLUF;
matrix_G(const sparse_matrix &BB, const sparse_matrix &SS)
: B(BB), S(SS), W1(gmm::mat_nrows(SS)), W2(gmm::mat_nrows(SS)) {
SLUF.build_with(SS);
}
-
+
};
@@ -976,7 +970,6 @@ void mult(const matrix_G &G, const vector1 &X, vector2 &Y) {
}
-
template <typename vector1, typename vector2>
void mult(const matrix_G &G, const vector1 &X, const vector2 &b, vector2 &Y)
{ mult(G, X, Y); gmm::add(b, Y); }
@@ -984,34 +977,34 @@ void mult(const matrix_G &G, const vector1 &X, const
vector2 &b, vector2 &Y)
scalar_type smallest_eigen_value(const sparse_matrix &B,
const sparse_matrix &M,
const sparse_matrix &S) {
-
+
size_type n = gmm::mat_nrows(M);
scalar_type lambda;
plain_vector V(n), W(n), V2(n);
gmm::fill_random(V2);
matrix_G G(B, S);
-
+
do {
gmm::copy(V2, V);
gmm::scale(V, 1./gmm::vect_norm2(V));
gmm::mult(M, V, W);
-
+
gmm::iteration it(1E-3, 0);
- gmm::cg(G, V2, W, gmm::identity_matrix(), it);
+ gmm::cg(G, V2, W, gmm::identity_matrix(), it);
lambda = gmm::vect_norm2(V2);
-
+
// compute the Rayleigh quotient
// mult(G, V2, W);
// scalar_type lambda2 = gmm::vect_sp(V2, W);
// gmm::mult(M, V2, W);
// lambda2 /= gmm::vect_sp(V2, W);
// cout << "lambda2 = " << sqrt(lambda2) << endl;
-
+
cout << "lambda = " << sqrt(1./lambda) << endl;
cout << "residu = " << gmm::vect_dist2(V2, gmm::scaled(V, lambda)) << endl;
-
+
} while (gmm::vect_dist2(V2, gmm::scaled(V, lambda)) > 1E-3);
-
+
return sqrt(1./lambda);
}
@@ -1025,37 +1018,37 @@ scalar_type smallest_eigen_value(const sparse_matrix &B,
bool unilateral_contact_problem::solve(plain_vector &U, plain_vector &LAMBDA,
plain_vector &LAMBDA_T ) {
size_type nb_dof_rhs = mf_rhs.nb_dof();
size_type N = mesh.dim();
- ls.reinit();
-
+ ls.reinit();
+
for (size_type d = 0; d < ls.get_mesh_fem().nb_basic_dof(); ++d) {
ls.values(0)[d] = ls_function(ls.get_mesh_fem().point_of_basic_dof(d),
0)[0];
ls.values(1)[d] = ls_function(ls.get_mesh_fem().point_of_basic_dof(d),
0)[1];
}
ls.touch();
-
+
mls.adapt();
mls_bound.adapt();
mim.adapt();
mimbound.adapt();
mfls_u.adapt();
mfls_cont.adapt();
-
+
bool load_global_fun = 0;
-
-
+
+
cout << "Setting up the singular functions for the enrichment\n";
cout << dgr << endl;
-
+
std::vector<getfem::pglobal_function> vfunc(dgr*4);
if (!load_global_fun) {
std::cout << "Using default singular functions\n";
for (unsigned i = 0; i < vfunc.size(); ++i){
/* use the singularity */
-
+
getfem::pxy_function
s = std::make_shared<getfem::crack_singular_xy_function>(i);
-
+
if (enrichment_option != FIXED_ZONE ) {
/* use the product of the singularity function
with a cutoff */
@@ -1064,14 +1057,14 @@ bool unilateral_contact_problem::solve(plain_vector
&U, plain_vector &LAMBDA, p
(int(cutoff_func), cutoff_radius, cutoff_radius1,cutoff_radius0);
s = std::make_shared<getfem::product_of_xy_functions>(s, c);
}
- vfunc[i]=getfem::global_function_on_level_set(ls, s);
+ vfunc[i]=getfem::global_function_on_level_set(ls, s);
}
}
-
+
mf_sing_u.set_functions(vfunc);
-
+
switch (enrichment_option) {
-
+
case FIXED_ZONE :
{
dal::bit_vector enriched_dofs;
@@ -1094,8 +1087,8 @@ bool unilateral_contact_problem::solve(plain_vector &U,
plain_vector &LAMBDA, p
mf_cont_sum.set_mesh_fems(mf_contt);
}
break;
-
-
+
+
case GLOBAL_WITH_CUTOFF :
{
if(cutoff_func == 0)
@@ -1105,22 +1098,22 @@ bool unilateral_contact_problem::solve(plain_vector
&U, plain_vector &LAMBDA, p
mf_u_sum.set_mesh_fems(mf_sing_u, mfls_u);
mf_cont_sum.set_mesh_fems(mf_contt);
} break;
-
+
case NO_ENRICHMENT:
{
mf_u_sum.set_mesh_fems(mfls_u);
mf_cont_sum.set_mesh_fems(mf_contt);
} break;
-
+
}// end switch
-
-
+
+
/*..................................................................................*/
/* Range_basis call
*/
/*..................................................................................*/
-
+
std::set<size_type> cols;
- cols.clear();
+ cols.clear();
if (rangeP_P){
sparse_matrix BRBB(mf_cont().nb_dof(), mf_cont().nb_dof());
asm_mass_matrix(BRBB, mimbound, mf_cont(), mf_cont());
@@ -1138,23 +1131,23 @@ bool unilateral_contact_problem::solve(plain_vector
&U, plain_vector &LAMBDA, p
mf_cont().reduce_to_basic_dof(cols);
mf_pre_uu().set_qdim(dim_type(N));
}
-
-
-
-
+
+
+
+
size_type nb_dof = mf_u().nb_dof();
cout << "nb_dof = " << nb_dof << endl;
size_type nb_dof_cont = mf_cont().nb_dof();
cout << "nb_dof_cont.... = " << nb_dof_cont << endl;
cout << "nb_basic_dof_cont.... = " <<mf_cont().nb_basic_dof() << endl;
-
+
U.resize(nb_dof);
LAMBDA.resize(nb_dof_cont);
LAMBDA_T.resize(nb_dof_cont);
-
+
// Find the dofs on the upper right and lower right corners
cout << "Find the dofs on the upper right and lower right corners" << endl;
-
+
scalar_type d1 = 1.0, d2 = 1.0;
size_type icorner1 = size_type(-1), icorner2 = size_type(-1);
base_node corner1 = base_node(1.0, -0.5);
@@ -1166,20 +1159,20 @@ bool unilateral_contact_problem::solve(plain_vector
&U, plain_vector &LAMBDA, p
scalar_type dd2 = gmm::vect_dist2(mf_u().point_of_basic_dof(i), corner2);
if (dd2 < d2) { icorner2 = i; d2 = dd2; }
}//end for
-
+
GMM_ASSERT1(((d1 < 1E-8) && (d2 < 1E-8)),
"Upper right or lower right corners not found d1 = "
<< d1 << " d2 = " << d2);
-
+
// Assembling mixed term for contact problem
-
+
getfem::CONTACT_B_MATRIX BN(nb_dof_cont, nb_dof);
getfem::CONTACT_B_MATRIX BT(nb_dof_cont, nb_dof);
asm_mass_matrix_mixed_term(BN, mimbound, mf_u(), mf_cont(), ls);
if (!contact_only) {
asm_mass_matrix_tang_mixed_term(BT, mimbound, mf_u(), mf_cont(), ls);
}
-
+
getfem::CONTACT_B_MATRIX CA(nb_dof_cont, nb_dof);
// Assembling stabilized mixed term for contact problem
//cont_gamma0=cont_gamma/h;
@@ -1198,9 +1191,9 @@ bool unilateral_contact_problem::solve(plain_vector &U,
plain_vector &LAMBDA, p
gmm::scale(CAT, -cont_gamma0 * h);
}
}
-
+
// Assembling symetrique term for stabilized contact problem
-
+
sparse_matrix KA(nb_dof, nb_dof);
// if (!contact_only){
sparse_matrix KAT(nb_dof, nb_dof);
@@ -1215,9 +1208,9 @@ bool unilateral_contact_problem::solve(plain_vector &U,
plain_vector &LAMBDA, p
gmm::scale(KAT, -cont_gamma0 * h);
}
}
-
+
//Assembling mass term for stabilized problem
-
+
getfem::CONTACT_B_MATRIX MA(nb_dof_cont, nb_dof_cont);
getfem::CONTACT_B_MATRIX MAT(nb_dof_cont, nb_dof_cont);
getfem::CONTACT_B_MATRIX M1(nb_dof_cont, nb_dof_cont);
@@ -1228,12 +1221,12 @@ bool unilateral_contact_problem::solve(plain_vector
&U, plain_vector &LAMBDA, p
if (!contact_only){
cout<<"Assembling mass tangent term for stabilized problem"<<endl;
getfem::asm_mass_matrix(MAT, mimbound, mf_cont());
-
+
}
if (stabilized_problem==1) {
gmm::scale(MA, cont_gamma0 * h);
//cout << "MA = " << MA << endl;
- if (!contact_only){
+ if (!contact_only){
gmm::scale(MAT, cont_gamma0 * h);
}
}
@@ -1245,7 +1238,7 @@ bool unilateral_contact_problem::solve(plain_vector &U,
plain_vector &LAMBDA, p
gmm::scale(MA, cont_gamma0);
gmm::add(M1, MA);
// cout << "MA = " << MA << endl;
- if (!contact_only){
+ if (!contact_only){
//gmm::scale(MAT, cont_gamma0);
asm_stabilization_patch_term(M1T, mesh, mimbound, mf_cont(),
ratio_size, 2.*h);
gmm::scale(M1T, -cont_gamma0);
@@ -1254,17 +1247,17 @@ bool unilateral_contact_problem::solve(plain_vector
&U, plain_vector &LAMBDA, p
}
}
}
-
-
+
+
getfem::model model;
-
+
// Main unknown of the problem.
model.add_fem_variable("u", mf_u());
model.add_fem_variable("Lambda", mf_cont()); // Adding normal contact
variable
if (!contact_only){
model.add_fem_variable("Lambda_t", mf_cont()); // Adding friction contact
variable
}
-
+
// Linearized elasticity brick.
model.add_initialized_scalar_data("lambda", lambda);
model.add_initialized_scalar_data("mu", mu);
@@ -1275,8 +1268,8 @@ bool unilateral_contact_problem::solve(plain_vector &U,
plain_vector &LAMBDA, p
cout<<"tresca_threshold="<<tresca_threshold <<endl;
model.add_initialized_scalar_data("Tresca_threshold", tresca_threshold);
}
-
-
+
+
}
model.add_initialized_scalar_data("augmentation_parameter", R/h);
//model.add_initialized_scalar_data("augmentation_parameter", R);
@@ -1285,9 +1278,9 @@ bool unilateral_contact_problem::solve(plain_vector &U,
plain_vector &LAMBDA, p
// model.add_initialized_scalar_data("augmentation_parameter", R/h);
// model.add_initialized_scalar_data
//("augmentation_parameter", mu * (3*lambda + 2*mu) / (h*(lambda + mu)) );
// r ~= Young modulus
-
-
-
+
+
+
if (stabilized_problem!=0) {
if (stabilized_problem==1){
// cout << "KA = " << KA << endl;
@@ -1297,7 +1290,7 @@ bool unilateral_contact_problem::solve(plain_vector &U,
plain_vector &LAMBDA, p
gmm::add(CA, BN);
if (!contact_only){
getfem::add_explicit_matrix(model, "u", "u", KAT);
- gmm::add(CAT, BT);
+ gmm::add(CAT, BT);
}
}
@@ -1318,7 +1311,7 @@ bool unilateral_contact_problem::solve(plain_vector &U,
plain_vector &LAMBDA, p
}
}else{
- if (contact_only){
+ if (contact_only){
getfem::add_basic_contact_brick(model, "u", "Lambda",
"augmentation_parameter", BN);
}else{
@@ -1331,59 +1324,59 @@ bool unilateral_contact_problem::solve(plain_vector
&U, plain_vector &LAMBDA, p
(model, "u", "Lambda", "Lambda_t",
"augmentation_parameter", BN, BT, "Friction_coeff");
}
-
+
}
-
+
}
-
+
// if (stabilized_problem) {
// // cout << "KA = " << KA << endl;
// cout << "gamma = " << cont_gamma0 * h << endl;
// getfem::add_explicit_matrix(model, "u", "u", KA);
// // Defining the contact condition.
-// gmm::add(CA, BN);
+// gmm::add(CA, BN);
// if (contact_only){
// getfem::add_Hughes_stab_basic_contact_brick(model, "u", "Lambda",
// "augmentation_parameter",
// BN, MA);
-// }else {
+// }else {
// getfem::add_explicit_matrix(model, "u", "u", KAT);
// // Defining the contact condition.
-// gmm::add(CAT, BT);
+// gmm::add(CAT, BT);
// getfem::add_Hughes_stab_basic_contact_brick
// (model, "u", "Lambda", "Lambda_t", "augmentation_parameter",
// BN, BT, MA, MAT, "friction_coeff");
// }
-// } else {
+// } else {
// getfem::add_basic_contact_brick(model, "u", "Lambda",
// "augmentation_parameter", BN);
-
+
// if (!contact_only){
// getfem::add_basic_contact_brick
// (model, "u", "Lambda", "Lambda_t",
// "augmentation_parameter", BN, BT, "friction_coeff","","",0);
-
+
// }
// }
-
-
+
+
// Defining the Neumann condition right hand side.
-
+
std::vector<scalar_type> F(nb_dof_rhs * N * N);
std::vector<scalar_type> FF(nb_dof_rhs * N * N);
-
+
// Neumann condition brick.
-
+
for(size_type i = 0; i < F.size(); i=i+N*N) {
base_node pt = mf_rhs.point_of_basic_dof(i / (N*N));
for(size_type j = 0; j < N; ++j){ F[i+j+j*N] =sin(2*M_PI*pt[1])*0.4;}
-
+
// scalar_type coeff = pt[1] > 0. ? -1 : 1;
// for(size_type j = 0; j < N; ++j){ F[i+j+j*N] = coeff*0.1; FF[i+j+j*N]
= (pt[0]-0.5)*2.0;}
-
+
}
-
+
cout <<"Applied Neumann condition"<< endl;
model.add_initialized_fem_data("NeumannData", mf_rhs, F);
model.add_initialized_fem_data("NeumannData1", mf_rhs, FF);
@@ -1395,23 +1388,23 @@ bool unilateral_contact_problem::solve(plain_vector
&U, plain_vector &LAMBDA, p
// (model, mim, "u", "NeumannData1", NEUMANN2_BOUNDARY_NUM);
getfem::add_normal_source_term_brick
(model, mim, "u", "NeumannData", NEUMANN1_BOUNDARY_NUM);
-
-
+
+
std::vector<scalar_type> FFF(mf_rhs.nb_dof()*N, 0.0);
- for(size_type i = 0; i < FFF.size(); i+=N){
+ for(size_type i = 0; i < FFF.size(); i+=N){
base_node pt = mf_rhs.point_of_basic_dof(i/N);
FFF[i+1]=3.5*cos(pt[0]*2.*M_PI) * pt[1]*pt[0]*(1-pt[0]) ;
}
model.add_initialized_fem_data("VolumicForce", mf_rhs, FFF);
getfem::add_source_term_brick(model, mim, "u", "VolumicForce");
-
-
+
+
// std::vector<scalar_type> FFF(mf_rhs.nb_dof()*N);
// for(size_type i = 0; i <FFF.size(); i++){ FFF[i]=0;}
// model.add_initialized_fem_data("DirichletData", mf_rhs, FFF);
// getfem::add_Dirichlet_condition_with_multipliers
// (model, mim, "u", mf_dir, NEUMANN4_BOUNDARY_NUM, "DirichletData");
-
+
cout<<"kill rigid motion"<<endl;
GMM_ASSERT1(N==2, "To be corrected for 2D computation");
sparse_matrix BB(3, mf_u().nb_dof());
@@ -1424,20 +1417,20 @@ bool unilateral_contact_problem::solve(plain_vector
&U, plain_vector &LAMBDA, p
getfem::add_constraint_with_multipliers(model, "u", "dir", BB, LRH);
//verified coercivit condition
-
-
-
-
-
-
+
+
+
+
+
+
//classical inf-sup condition
-
+
// if (PARAM.int_value("INF_SUP_COMP")) {
-
+
// cout << "Sparse matrices computation for the test of inf-sup
condition"
// << endl;
-
+
// // sparse_matrix MUU(nb_dof, nb_dof);
// sparse_matrix MPP(nb_dof_cont, nb_dof_cont);
// sparse_matrix BBB(nb_dof_cont, nb_dof);
@@ -1452,9 +1445,9 @@ bool unilateral_contact_problem::solve(plain_vector &U,
plain_vector &LAMBDA, p
// // gmm::scaled(VVV,gmm::vect_norm2(VVV));//x_n/norm(x_n)
// do{
// gmm::mult(BBB, VVV, dd1);
-
+
// gmm::lu_solve(MPP, YYY,dd1);
-
+
// gmm::mult(MTILD, YYY, dd2);
// gmm::lu_solve(gmm::transposed(MPP), ZZZ,dd2);
@@ -1481,7 +1474,6 @@ bool unilateral_contact_problem::solve(plain_vector &U,
plain_vector &LAMBDA, p
// }
-
// Generic solve.
gmm::iteration iter(residual, 1, 2000);
@@ -1503,19 +1495,19 @@ bool unilateral_contact_problem::solve(plain_vector
&U, plain_vector &LAMBDA, p
if (PARAM.int_value("Test_of_coer")) {
cout << "Compute the smallest eigenvalue" << endl;
size_type nb_up;
- gmm::sub_interval interval;
+ gmm::sub_interval interval;
nb_up= gmm::nnz(model.real_variable("u"));
interval = model.interval_of_variable("u");
cout<< "nb_up=" << nb_up << endl;
cout <<"nbdof_in_u="<< gmm::nnz(model.real_variable("u"))<<endl;
cout <<"nbdof_in_p="<< gmm::nnz(model.real_variable("Lambda"))<<endl;
- sparse_matrix KKK(gmm::nnz(model.real_variable("u")),
gmm::nnz(model.real_variable("u"))),
+ sparse_matrix KKK(gmm::nnz(model.real_variable("u")),
gmm::nnz(model.real_variable("u"))),
KKKK(gmm::nnz(model.real_variable("u")),
gmm::nnz(model.real_variable("u")));
- gmm::copy(gmm::sub_matrix(model.real_tangent_matrix(),interval, interval)
,KKK);
+ gmm::copy(gmm::sub_matrix(model.real_tangent_matrix(),interval, interval)
,KKK);
plain_vector VVV(gmm::nnz(model.real_variable("u"))),
VVV1(gmm::nnz(model.real_variable("u"))) ;
- gmm::fill_random(VVV);
+ gmm::fill_random(VVV);
scalar_type lllambda(0), lllambda_aux(1), lllambda_max(0);
do{
lllambda_aux= lllambda;
@@ -1523,7 +1515,7 @@ bool unilateral_contact_problem::solve(plain_vector &U,
plain_vector &LAMBDA, p
gmm::copy(gmm::scaled(VVV, (1./gmm::vect_norm2(VVV))),VVV1);
// cout<<"norm="<<gmm::vect_norm2(VVV1)<<endl;
gmm::mult(KKK,VVV1,VVV);
- lllambda=gmm::vect_sp(VVV,VVV1);
+ lllambda=gmm::vect_sp(VVV,VVV1);
// cout<<"lllambda="<< lllambda<<endl;
}while (gmm::abs(lllambda-lllambda_aux ) > 1E-12);
lllambda_max=lllambda;
@@ -1537,19 +1529,19 @@ bool unilateral_contact_problem::solve(plain_vector
&U, plain_vector &LAMBDA, p
- gmm::fill_random(VVV);
+ gmm::fill_random(VVV);
lllambda=0;
lllambda_aux=1;
do{
lllambda_aux= lllambda;
gmm::copy(gmm::scaled(VVV,(1./gmm::vect_norm2(VVV))),VVV1);
gmm::mult(KKK,VVV1,VVV);
- lllambda=gmm::vect_sp(VVV,VVV1);
+ lllambda=gmm::vect_sp(VVV,VVV1);
// cout<<"lllambda="<< lllambda<<endl;
}while (gmm::abs(lllambda-lllambda_aux ) > 1E-10);
cout<<"lllambda_min="<< lllambda+2.*lllambda_max <<endl;
}
-
+
@@ -1558,17 +1550,17 @@ bool unilateral_contact_problem::solve(plain_vector
&U, plain_vector &LAMBDA, p
gmm::copy(model.real_variable("u"), U);
gmm::resize(LAMBDA, mf_cont().nb_dof());
gmm::copy(model.real_variable("Lambda"), LAMBDA);
-
+
if (!contact_only) {
gmm::resize(LAMBDA_T, mf_cont().nb_dof());
gmm::copy(model.real_variable("Lambda_t"), LAMBDA_T);
}
-
+
return (iter.converged());
-
-
+
+
}//end solv
@@ -1581,19 +1573,19 @@ bool unilateral_contact_problem::solve(plain_vector
&U, plain_vector &LAMBDA, p
/**************************************************************************************/
int main(int argc, char *argv[]) {
-
+
GETFEM_MPI_INIT(argc, argv);
FE_ENABLE_EXCEPT; // Enable floating point exception for Nan.
-
+
//getfem::getfem_mesh_level_set_noisy();
-
-
+
+
unilateral_contact_problem p;
p.PARAM.read_command_line(argc, argv);
p.init();
p.mesh.write_to_file(p.datafilename + ".mesh");
-
-
+
+
plain_vector U, Lambda, Lambda_t;
// if (!p.contact_only) {
//}
@@ -1609,25 +1601,25 @@ int main(int argc, char *argv[]) {
std::string SIMPLEX_INTEGRATION1 = PARAM1.string_value("SIMPLEX_INTEGRATION",
"Name of simplex
integration method");
std::string SINGULAR_INTEGRATION1 =
PARAM1.string_value("SINGULAR_INTEGRATION","Name of singular integration
method");
-
+
getfem::mesh mcut;
p.mls.global_cut_mesh(mcut);
unsigned Q = p.mf_u().get_qdim();
-
+
cout << p.mf_u().nb_basic_dof() << endl;
cout << p.mf_cont().nb_basic_dof() << endl;
cout << p.mf_cont().nb_dof() << endl;
//construction of mesh refined
-
+
// getfem::stored_mesh_slice slr;
getfem::mesh mcut_refined;
-
+
unsigned NX = unsigned(p.PARAM.int_value("NX")), nn;
if (NX < 6) nn = 24;
else if (NX < 12) nn = 6;
else if (NX < 30) nn = 3;
else nn = 3;
-
+
/* choose an adequate slice refinement based on the distance
to the crack tip */
std::vector<bgeot::short_type> nrefine(mcut.convex_index().last_true()+1);
@@ -1639,38 +1631,38 @@ int main(int argc, char *argv[]) {
d = gmm::vect_norm2(ls_function(Pp));
if (d < dmin || i == 0) { dmin = d; Pmin = Pp; }
}
-
+
if (dmin < 1e-5)
nrefine[cv] = short_type(nn*8);
- else if (dmin < .1)
+ else if (dmin < .1)
nrefine[cv] = short_type(nn*2);
else nrefine[cv] = short_type(nn);
// if (dmin < .01)
// cout << "cv: "<< cv << ", dmin = " << dmin << "Pmin=" << Pmin
// << " " << nrefine[cv] << "\n";
}
-
+
{
- getfem::mesh_slicer slicer(mcut);
+ getfem::mesh_slicer slicer(mcut);
getfem::slicer_build_mesh bmesh(mcut_refined);
slicer.push_back_action(bmesh);
slicer.exec(nrefine, getfem::mesh_region::all_convexes());
}
-
- if (1) {
-
+
+ if (1) {
+
getfem::mesh_fem mf(mcut, dim_type(Q));
mf.set_classical_discontinuous_finite_element(2, 1E-5);
plain_vector VV(mf.nb_dof());
getfem::interpolation(p.mf_u(), mf, U, VV);
-
+
getfem::mesh_fem mf_cont(mcut, 1);
mf_cont.set_classical_discontinuous_finite_element(2, 1E-5);
plain_vector PPP(mf_cont.nb_dof());
getfem::interpolation(p.mf_cont(), mf_cont, Lambda, PPP);
-
+
//if (!p.contact_only) {
-
+
//}
getfem::level_set ls(mcut, 1, true);
for (size_type d = 0; d < ls.get_mesh_fem().nb_basic_dof(); ++d) {
@@ -1678,31 +1670,31 @@ int main(int argc, char *argv[]) {
ls.values(1)[d] =ls_function(ls.get_mesh_fem().point_of_basic_dof(d),
0)[1];
}
ls.touch();
-
+
const getfem::mesh_fem &lsmf = ls.get_mesh_fem();
lsmf.write_to_file(p.datafilename + "_ls.mf", true);
gmm::vecsave(p.datafilename + "_ls.U", ls.values());
-
-
-
-
+
+
+
+
cout << "saving the slice solution for matlab\n";
getfem::stored_mesh_slice sl, sl0,sll;
-
-
+
+
getfem::mesh_slicer slicer1(mf.linked_mesh());
getfem::slicer_build_stored_mesh_slice sbuild(sl);
// getfem::mesh_slice_cv_dof_data<plain_vector> mfU(mf,VV);
// getfem::slicer_isovalues iso(mfU, 0.0, 0);
getfem::slicer_build_stored_mesh_slice sbuild0(sl0);
-
+
slicer1.push_back_action(sbuild); // full slice in sl
// slicer1.push_back_action(iso); // extract isosurface 0
slicer1.push_back_action(sbuild0); // store it into sl0
slicer1.exec(nrefine, mf.convex_index());
-
+
getfem::mesh_slicer slicer2(mf.linked_mesh());
- getfem::mesh_slice_cv_dof_data<plain_vector>
+ getfem::mesh_slice_cv_dof_data<plain_vector>
mfL(ls.get_mesh_fem(), ls.values());
getfem::slicer_isovalues iso2(mfL, 0.0, 0);
getfem::slicer_build_stored_mesh_slice sbuildl(sll);
@@ -1714,7 +1706,7 @@ int main(int argc, char *argv[]) {
sl.write_to_file(p.datafilename + "_ref.sl", true);
sl0.write_to_file(p.datafilename + "_ref.sl0", true);
sll.write_to_file(p.datafilename + "_ref.sll", true);
- plain_vector LL(sll.nb_points());
+ plain_vector LL(sll.nb_points());
// gmm::scale(PP, 0.005);
sll.interpolate(mf_cont, PPP, LL);
gmm::vecsave(p.datafilename + "_ref.slL", LL);
@@ -1726,18 +1718,18 @@ int main(int argc, char *argv[]) {
getfem::interpolation(p.mf_cont(), mf_tang_cont, Lambda_t, PPPT);
- plain_vector LLT(sll.nb_points());
+ plain_vector LLT(sll.nb_points());
sll.interpolate(mf_tang_cont, PPPT, LLT);
gmm::vecsave(p.datafilename + "_ref.slLT", LLT);
}
- // plain_vector UU(sl.nb_points()), LL(sll.nb_points());
+ // plain_vector UU(sl.nb_points()), LL(sll.nb_points());
// sl.interpolate(mf, V, UU);
// gmm::vecsave("xfem_stab_unilat_contact.slU", UU);
}else{
sl.write_to_file(p.datafilename + ".sl", true);
sl0.write_to_file(p.datafilename + ".sl0", true);
sll.write_to_file(p.datafilename + ".sll", true);
- plain_vector LL(sll.nb_points());
+ plain_vector LL(sll.nb_points());
// gmm::scale(PP, 0.005);
sll.interpolate(mf_cont, PPP, LL);
gmm::vecsave(p.datafilename + ".slL", LL);
@@ -1747,20 +1739,20 @@ int main(int argc, char *argv[]) {
mf_tang_cont.set_classical_discontinuous_finite_element(2, 1E-5);
plain_vector PPPT(mf_tang_cont.nb_dof());
getfem::interpolation(p.mf_cont(), mf_tang_cont, Lambda_t, PPPT);
-
- plain_vector LLT(sll.nb_points());
+
+ plain_vector LLT(sll.nb_points());
sll.interpolate(mf_tang_cont, PPPT, LLT);
gmm::vecsave(p.datafilename + ".slLT", LLT);
}
- // plain_vector UU(sl.nb_points()), LL(sll.nb_points());
+ // plain_vector UU(sl.nb_points()), LL(sll.nb_points());
// sl.interpolate(mf, V, UU);
// gmm::vecsave("xfem_stab_unilat_contact.slU", UU);
}
- }
-
+ }
+
+
+
-
-
//save desplacement
if (p.reference_test) {
cout << "Saving the reference desplacement" << endl;
@@ -1768,38 +1760,38 @@ int main(int argc, char *argv[]) {
mf.set_classical_discontinuous_finite_element(2, 1E-5);
plain_vector V(mf.nb_dof());
getfem::interpolation(p.mf_u(), mf, U, V);
-
+
mf.write_to_file(p.datafilename + ".meshfem_refined", true);
gmm::vecsave(p.datafilename + ".U_refined", V);
-
+
//Save normal contact multiplier
cout << "Saving the reference contact multiplier" << endl;
-
+
getfem::mesh_fem mf_cont(mcut_refined, 1);
mf_cont.set_classical_discontinuous_finite_element(2, 1E-5);
plain_vector PP(mf_cont.nb_dof());
-
+
getfem::interpolation(p.mf_cont(), mf_cont, Lambda, PP);
-
+
mf_cont.write_to_file(p.datafilename + ".cont_meshfem_refined", true);
gmm::vecsave(p.datafilename + ".cont_refined", PP);
p.mf_cont().write_to_file(p.datafilename + ".contt_meshfem", true);
gmm::vecsave(p.datafilename + ".contt", Lambda);
-
+
//Save tangent contact multiplier
cout << "Saving the reference tangant contact multiplier" << endl;
-
+
getfem::mesh_fem mf_tang_cont(mcut_refined, 1);
mf_tang_cont.set_classical_discontinuous_finite_element(2, 1E-5);
plain_vector PPT(mf_tang_cont.nb_dof());
-
+
getfem::interpolation(p.mf_cont(), mf_tang_cont, Lambda_t, PPT);
-
+
mf_tang_cont.write_to_file(p.datafilename + ".tang_cont_meshfem_refined",
true);
gmm::vecsave(p.datafilename + ".tang_cont_refined", PPT);
p.mf_cont().write_to_file(p.datafilename + ".tang_contt_meshfem", true);
gmm::vecsave(p.datafilename + ".tang_contt", Lambda_t);
-
+
}else{
cout << "Saving the solution" << endl;
cout << "Saving desplacement" << endl;
@@ -1807,46 +1799,46 @@ int main(int argc, char *argv[]) {
mf.set_classical_discontinuous_finite_element(2, 1E-5);
plain_vector V(mf.nb_dof());
getfem::interpolation(p.mf_u(), mf, U, V);
-
+
mf.write_to_file(p.datafilename + ".meshfem", true);
gmm::vecsave(p.datafilename + ".U", V);
-
+
//Save normal contact multiplier
cout << "Saving normal contact multiplier" << endl;
-
+
getfem::mesh_fem mf_cont(mcut, 1);
mf_cont.set_classical_discontinuous_finite_element(2, 1E-5);
plain_vector PP(mf_cont.nb_dof());
-
+
getfem::interpolation(p.mf_cont(), mf_cont, Lambda, PP);
-
+
mf_cont.write_to_file(p.datafilename + ".cont_meshfem", true);
gmm::vecsave(p.datafilename + ".cont", PP);
p.mf_cont().write_to_file(p.datafilename + ".contt_meshfem", true);
- gmm::vecsave(p.datafilename + ".contt", Lambda);
-
+ gmm::vecsave(p.datafilename + ".contt", Lambda);
+
//Save tangent contact multiplier
cout<<"Saving tangent contact multiplier"<< endl;
-
+
getfem::mesh_fem mf_tang_cont(mcut, 1);
mf_tang_cont.set_classical_discontinuous_finite_element(2, 1E-5);
plain_vector PPT(mf_tang_cont.nb_dof());
-
+
getfem::interpolation(p.mf_cont(), mf_tang_cont, Lambda_t, PPT);
-
+
mf_tang_cont.write_to_file(p.datafilename + ".tang_cont_meshfem", true);
gmm::vecsave(p.datafilename + ".tang_cont", PPT);
p.mf_cont().write_to_file(p.datafilename + ".tang_contt_meshfem", true);
- gmm::vecsave(p.datafilename + ".tang_contt", Lambda_t);
+ gmm::vecsave(p.datafilename + ".tang_contt", Lambda_t);
}
-
-
+
+
cout << "plot Von mises" << endl;
- getfem::mesh_im mim_refined(mcut);
+ getfem::mesh_im mim_refined(mcut);
mim_refined.set_integration_method(getfem::int_method_descriptor
("IM_TRIANGLE(6)"));
@@ -1855,30 +1847,30 @@ int main(int argc, char *argv[]) {
getfem::mesh_fem mf_refined(mcut,dim_type(Q));
mf_refined.set_classical_discontinuous_finite_element(4, 0.001);
plain_vector W(mf_refined.nb_dof());
-
+
getfem::interpolation(p.mf_u(), mf_refined, U, W);
mf_refined.write_to_file(p.datafilename + ".meshfemuvm", true);
gmm::vecsave(p.datafilename + ".Uvm", W);
-
+
getfem::mesh_fem mf_vm(mcut, 1);
mf_vm.set_classical_discontinuous_finite_element(4, 0.001);
plain_vector Vm(mf_vm.nb_dof());
-
+
cout << "compute Von_mises" << endl;
getfem::interpolation_von_mises(mf_refined, mf_vm, W, Vm);
gmm::vecsave(p.datafilename + ".VM",Vm);
- mf_vm.write_to_file(p.datafilename + ".meshfemvm", true);
+ mf_vm.write_to_file(p.datafilename + ".meshfemvm", true);
- //Compute error
-
+ //Compute error
+
if(p.PARAM.int_value("ERROR_TO_REF_SOL") == 1){
cout << "Computing error with respect to a reference solution..." << endl;
std::string REFERENCE_MF = p.datafilename + ".meshfem_refined";
@@ -1887,47 +1879,47 @@ int main(int argc, char *argv[]) {
std::string REFERENCE_cont = p.datafilename + ".cont_refined";
std::string REFERENCE_MF_tang_cont = p.datafilename +
".tang_cont_meshfem_refined";
std::string REFERENCE_tang_cont = p.datafilename + ".tang_cont_refined";
-
-
+
+
cout << "Load reference displacement from "
<< REFERENCE_MF << " and " << REFERENCE_U << "\n";
- getfem::mesh ref_m;
+ getfem::mesh ref_m;
ref_m.read_from_file(REFERENCE_MF);
- getfem::mesh_fem ref_mf(ref_m);
+ getfem::mesh_fem ref_mf(ref_m);
ref_mf.read_from_file(REFERENCE_MF);
plain_vector ref_U(ref_mf.nb_dof());
gmm::vecload(REFERENCE_U, ref_U);
-
+
cout << "Load reference pressure from "
<< REFERENCE_MF_cont << " and " << REFERENCE_cont << "\n";
- getfem::mesh ref_m_cont;
+ getfem::mesh ref_m_cont;
ref_m_cont.read_from_file(REFERENCE_MF_cont);
- getfem::mesh_fem ref_mf_cont(ref_m_cont);
+ getfem::mesh_fem ref_mf_cont(ref_m_cont);
ref_mf_cont.read_from_file(REFERENCE_MF_cont);
plain_vector ref_cont(ref_mf_cont.nb_dof());
gmm::vecload(REFERENCE_cont, ref_cont);
-
-
-
+
+
+
// if (!p.contact_only) {
-
+
cout << "Load reference tangent pressure from "
<< REFERENCE_MF_tang_cont << " and " << REFERENCE_tang_cont << "\n";
- getfem::mesh ref_m_tang_cont;
+ getfem::mesh ref_m_tang_cont;
ref_m_tang_cont.read_from_file(REFERENCE_MF_tang_cont);
getfem::mesh_fem ref_mf_tang_cont(ref_m_tang_cont);
ref_mf_tang_cont.read_from_file(REFERENCE_MF_tang_cont);
-
+
plain_vector ref_tang_cont(ref_mf_tang_cont.nb_dof());
gmm::vecload(REFERENCE_tang_cont, ref_tang_cont);
// }
-
+
getfem::level_set ls(ref_m_cont, 1, true);
-
-
-
+
+
+
for (size_type d = 0; d < ls.get_mesh_fem().nb_basic_dof(); ++d) {
ls.values(0)[d] =ls_function(ls.get_mesh_fem().point_of_basic_dof(d),
0)[0];
ls.values(1)[d] =ls_function(ls.get_mesh_fem().point_of_basic_dof(d),
0)[1];
@@ -1946,13 +1938,13 @@ int main(int argc, char *argv[]) {
//int intbound = getfem::mesh_im_level_set::INTEGRATE_BOUNDARY;
//mimbound.init_with_mls(mls, intbound, simp_ppi, sing_ppi);
//mimbound.set_integration_method(mesh.convex_index(), ppi);
-
+
getfem::mesh_im_level_set mimm(mls);
mimm.set_integration_method(ref_m.convex_index(),
getfem::int_method_descriptor(INTEGRATION1));
- mimm.set_simplex_im(getfem::int_method_descriptor(SIMPLEX_INTEGRATION1),
+ mimm.set_simplex_im(getfem::int_method_descriptor(SIMPLEX_INTEGRATION1),
getfem::int_method_descriptor(SINGULAR_INTEGRATION1));
-
+
// Integration methods on the boudary
int intboundd = getfem::mesh_im_level_set::INTEGRATE_BOUNDARY;
getfem::mesh_im_level_set mimboundd(mls_cont, intboundd,
@@ -1966,7 +1958,7 @@ int main(int argc, char *argv[]) {
getfem::mesh_im_level_set mimbounddt(mls_tang_cont, intboundd,
getfem::int_method_descriptor(SIMPLEX_INTEGRATION1));
if (!p.contact_only) {
-
+
mimbounddt.set_integration_method( ref_m_tang_cont.convex_index(),
getfem::int_method_descriptor(INTEGRATION1));
mimbounddt.adapt();
@@ -1974,61 +1966,61 @@ int main(int argc, char *argv[]) {
- //Interpolation of U on a reference mesh
+ //Interpolation of U on a reference mesh
getfem::mesh_im ref_mim(ref_m);
- getfem::pintegration_method ppi =
+ getfem::pintegration_method ppi =
getfem::int_method_descriptor("IM_TRIANGLE(6)");
ref_mim.set_integration_method(ref_m.convex_index(), ppi);
-
+
plain_vector interp_U(ref_mf.nb_dof());
getfem::interpolation(p.mf_u(), ref_mf, U, interp_U);
-
-
+
+
plain_vector interp_U_error(ref_mf.nb_dof());
gmm::add(interp_U, gmm::scaled(ref_U, -1.), interp_U_error);
gmm::vecsave(p.datafilename+".U_map_error", interp_U_error);
-
+
cout << "To ref L2 ERROR on U:"
<< getfem::asm_L2_dist(mimm, ref_mf, interp_U,
ref_mf, ref_U) << endl;
-
+
cout << "To ref H1 ERROR on U:"
<< getfem::asm_H1_dist(mimm, ref_mf, interp_U,
ref_mf, ref_U) << endl;
gmm::add(gmm::scaled(interp_U, -1.), ref_U);
gmm::vecsave(p.datafilename + ".diff_ref", ref_U);
-
- //Interpolation of Lambda on a reference mesh
-
+
+ //Interpolation of Lambda on a reference mesh
+
plain_vector interp_cont(ref_mf_cont.nb_dof());
getfem::interpolation(p.mf_cont(), ref_mf_cont, Lambda, interp_cont);
-
+
plain_vector interp_cont_error(ref_mf_cont.nb_dof());
gmm::add(interp_cont, gmm::scaled(ref_cont, -1.), interp_cont_error);
gmm::vecsave(p.datafilename+".cont_map_error", interp_cont_error);
-
+
cout << "To ref L2 ERROR on P:"
<< getfem::asm_L2_dist(mimboundd, ref_mf_cont, interp_cont,
ref_mf_cont, ref_cont) << endl;
- //Interpolation of Lambda_t on a reference mesh
+ //Interpolation of Lambda_t on a reference mesh
plain_vector interp_tang_cont(ref_mf_tang_cont.nb_dof());
if (!p.contact_only) {
-
+
getfem::interpolation(p.mf_cont(), ref_mf_tang_cont, Lambda_t,
interp_tang_cont);
-
+
plain_vector interp_tang_cont_error(ref_mf_tang_cont.nb_dof());
gmm::add(interp_tang_cont, gmm::scaled(ref_tang_cont, -1.),
interp_tang_cont_error);
gmm::vecsave(p.datafilename+".tang_cont_map_error",
interp_tang_cont_error);
-
+
cout << "To ref L2 ERROR on P tangent:"
<< getfem::asm_L2_dist(mimbounddt, ref_mf_tang_cont,
interp_tang_cont,
ref_mf_tang_cont, ref_tang_cont) << endl;
-
+
}
}
-
+
GETFEM_MPI_FINALIZE;
- return 0;
+ return 0;
}
diff --git a/interface/src/getfemint_levelset.cc
b/interface/src/getfemint_levelset.cc
index 83ff41bc..74636808 100644
--- a/interface/src/getfemint_levelset.cc
+++ b/interface/src/getfemint_levelset.cc
@@ -21,7 +21,6 @@
#include <getfemint_levelset.h>
#include <getfemint_workspace.h>
#include <getfem/getfem_generic_assembly.h>
-#include <getfem/getfem_arch_config.h>
namespace getfemint {
diff --git a/interface/src/getfemint_precond.h
b/interface/src/getfemint_precond.h
index 8af6c79b..2fcdf808 100644
--- a/interface/src/getfemint_precond.h
+++ b/interface/src/getfemint_precond.h
@@ -52,9 +52,9 @@ namespace getfemint {
size_type ncols(void) const { return gsp ? gsp->ncols() : ncols_; }
void set_dimensions(size_type m, size_type n) { nrows_ = m; ncols_ = n; }
gprecond_base() : nrows_(0), ncols_(0), type(IDENTITY), gsp(0) {}
- const char *name() const {
+ const char *name() const {
const char *p[] = { "IDENTITY", "DIAG", "ILDLT", "ILDLTT", "ILU", "ILUT",
- "SUPERLU", "GSPARSE" };
+ "SUPERLU", "GSPARSE" };
return p[type];
}
virtual size_type memsize() const = 0;
@@ -63,7 +63,7 @@ namespace getfemint {
template <typename T> struct gprecond : public gprecond_base {
typedef gmm::csc_matrix_ref<const T*, const unsigned int *,
- const unsigned int *> cscmat;
+ const unsigned int *> cscmat;
std::unique_ptr<gmm::diagonal_precond<cscmat> > diagonal;
std::unique_ptr<gmm::ildlt_precond<cscmat> > ildlt;
std::unique_ptr<gmm::ildltt_precond<cscmat> > ildltt;
@@ -81,10 +81,11 @@ namespace getfemint {
case ILDLT: sz += ildlt->memsize(); break;
case ILDLTT: sz += ildltt->memsize(); break;
case SUPERLU:
- sz += size_type(superlu->memsize()); break;
+ sz += size_type(superlu->memsize());
+ break;
case SPMAT: sz += gsp->memsize(); break;
}
- return sz;
+ return sz;
}
};
@@ -116,34 +117,34 @@ namespace gmm {
template <typename T, typename V1, typename V2>
void mult_or_transposed_mult(const getfemint::gprecond<T>& precond,
- const V1 &v, V2 &w, bool do_mult) {
+ const V1 &v, V2 &w, bool do_mult) {
switch (precond.type) {
case getfemint::gprecond_base::IDENTITY: gmm::copy(v,w); break;
case getfemint::gprecond_base::DIAG:
- gmm::mult(*precond.diagonal, v, w);
- break;
- case getfemint::gprecond_base::ILDLT:
- if (do_mult) gmm::mult(*precond.ildlt, v, w);
+ gmm::mult(*precond.diagonal, v, w);
+ break;
+ case getfemint::gprecond_base::ILDLT:
+ if (do_mult) gmm::mult(*precond.ildlt, v, w);
else gmm::transposed_mult(*precond.ildlt, v, w);
break;
- case getfemint::gprecond_base::ILDLTT:
- if (do_mult) gmm::mult(*precond.ildltt, v, w);
+ case getfemint::gprecond_base::ILDLTT:
+ if (do_mult) gmm::mult(*precond.ildltt, v, w);
else gmm::transposed_mult(*precond.ildltt, v, w);
break;
- case getfemint::gprecond_base::ILU:
- if (do_mult) gmm::mult(*precond.ilu, v, w);
+ case getfemint::gprecond_base::ILU:
+ if (do_mult) gmm::mult(*precond.ilu, v, w);
else gmm::transposed_mult(*precond.ilu, v, w);
break;
- case getfemint::gprecond_base::ILUT:
- if (do_mult) gmm::mult(*precond.ilut, v, w);
+ case getfemint::gprecond_base::ILUT:
+ if (do_mult) gmm::mult(*precond.ilut, v, w);
else gmm::transposed_mult(*precond.ilut, v, w);
break;
case getfemint::gprecond_base::SUPERLU:
- if (do_mult) precond.superlu->solve(w,v);
- else precond.superlu->solve(w,v,gmm::SuperLU_factor<T>::LU_TRANSP);
- break;
+ if (do_mult) precond.superlu->solve(w,v);
+ else precond.superlu->solve(w,v,gmm::SuperLU_factor<T>::LU_TRANSP);
+ break;
case getfemint::gprecond_base::SPMAT:
- precond.gsp->mult_or_transposed_mult(v, w, !do_mult);
+ precond.gsp->mult_or_transposed_mult(v, w, !do_mult);
break;
}
}
@@ -153,7 +154,7 @@ namespace gmm {
}
template <typename T, typename V1, typename V2>
void transposed_mult(const getfemint::gprecond<T>& precond, const V1 &v,
- V2 &w) {
+ V2 &w) {
mult_or_transposed_mult(precond,v,w,false);
}
diff --git a/interface/src/gf_global_function.cc
b/interface/src/gf_global_function.cc
index c09500bc..6181c998 100644
--- a/interface/src/gf_global_function.cc
+++ b/interface/src/gf_global_function.cc
@@ -22,7 +22,6 @@
#include <getfemint.h>
#include <getfemint_workspace.h>
#include <getfem/getfem_global_function.h>
-#include <getfem/getfem_arch_config.h>
using namespace getfemint;
diff --git a/interface/src/gf_levelset.cc b/interface/src/gf_levelset.cc
index 676f1bf9..66acfb16 100644
--- a/interface/src/gf_levelset.cc
+++ b/interface/src/gf_levelset.cc
@@ -22,7 +22,6 @@
#include <getfemint.h>
#include <getfemint_workspace.h>
#include <getfemint_levelset.h>
-#include <getfem/getfem_arch_config.h>
using namespace getfemint;
diff --git a/interface/src/gf_linsolve.cc b/interface/src/gf_linsolve.cc
index a04adbe5..8b42282f 100644
--- a/interface/src/gf_linsolve.cc
+++ b/interface/src/gf_linsolve.cc
@@ -190,7 +190,6 @@ void gf_linsolve(getfemint::mexargs_in& m_in,
getfemint::mexargs_out& m_out) {
else superlu_solver(gsp, in, out, scalar_type());
);
-
/*@FUNC @CELL{U, cond} = ('superlu', @tsp M, @vec b)
Solve `M.U = b` apply the SuperLU solver (sparse LU factorization).
diff --git a/src/getfem_assembling_tensors.cc b/src/getfem_assembling_tensors.cc
index 6327ad9f..91963dae 100644
--- a/src/getfem_assembling_tensors.cc
+++ b/src/getfem_assembling_tensors.cc
@@ -20,7 +20,6 @@
===========================================================================*/
#include "gmm/gmm_blas_interface.h"
-#include "getfem/getfem_arch_config.h"
#include "getfem/getfem_assembling_tensors.h"
#include "getfem/getfem_locale.h"
#include "getfem/getfem_mat_elem.h"
diff --git a/src/getfem_contact_and_friction_large_sliding.cc
b/src/getfem_contact_and_friction_large_sliding.cc
index a59ea124..3f11c58d 100644
--- a/src/getfem_contact_and_friction_large_sliding.cc
+++ b/src/getfem_contact_and_friction_large_sliding.cc
@@ -1187,7 +1187,6 @@ namespace getfem {
#if 0
-#include <getfem/getfem_arch_config.h>
#if GETFEM_HAVE_MUPARSER_MUPARSER_H
#include <muParser/muParser.h>
#elif GETFEM_HAVE_MUPARSER_H
diff --git a/tests/gmm_torture05_mult.cc b/tests/gmm_torture05_mult.cc
index ed46cf15..7e3c9fa2 100644
--- a/tests/gmm_torture05_mult.cc
+++ b/tests/gmm_torture05_mult.cc
@@ -36,9 +36,9 @@ using std::ends; using std::cin;
using gmm::size_type;
template <typename MAT1 , typename MAT2, typename VECT1, typename VECT2,
- typename VECT3, typename VECT4>
+ typename VECT3, typename VECT4>
void test_procedure2(const MAT1 &m1_, const VECT1 &v1_, const VECT2 &v2_,
- const MAT2 &m2_, const VECT3 &v3_, const VECT4 &v4_) {
+ const MAT2 &m2_, const VECT3 &v3_, const VECT4 &v4_) {
VECT1 &v1 = const_cast<VECT1 &>(v1_);
VECT2 &v2 = const_cast<VECT2 &>(v2_);
VECT3 &v3 = const_cast<VECT3 &>(v3_);
@@ -146,9 +146,9 @@ template<typename VECT> void test_vect_swap(VECT &V,
gmm::linalg_false) {
template <typename MAT1 , typename MAT2, typename VECT1, typename VECT2,
- typename VECT3, typename VECT4>
+ typename VECT3, typename VECT4>
bool test_procedure(const MAT1 &m1_, const VECT1 &v1_, const VECT2 &v2_,
- const MAT2 &m2_, const VECT3 &v3_, const VECT4 &v4_) {
+ const MAT2 &m2_, const VECT3 &v3_, const VECT4 &v4_) {
VECT1 &v1 = const_cast<VECT1 &>(v1_);
VECT2 &v2 = const_cast<VECT2 &>(v2_);
VECT3 &v3 = const_cast<VECT3 &>(v3_);
@@ -173,11 +173,11 @@ bool test_procedure(const MAT1 &m1_, const VECT1 &v1_,
const VECT2 &v2_,
size_type mm = m / 2, nn = n / 2;
gmm::sub_interval SUBI(0, mm), SUBJ(0, nn);
test_procedure2(gmm::sub_matrix(mm1, SUBI),
- gmm::sub_vector(v1, SUBI),
- gmm::sub_vector(v2, SUBI),
- gmm::sub_matrix(mm2, SUBI, SUBJ),
- gmm::sub_vector(v3, SUBJ),
- gmm::sub_vector(v4, SUBJ));
+ gmm::sub_vector(v1, SUBI),
+ gmm::sub_vector(v2, SUBI),
+ gmm::sub_matrix(mm2, SUBI, SUBJ),
+ gmm::sub_vector(v3, SUBJ),
+ gmm::sub_vector(v4, SUBJ));
gmm::add(gmm::scaled(mm1, T(-1)), m1);
gmm::add(gmm::scaled(mm2, T(-1)), m2);
@@ -196,7 +196,7 @@ bool test_procedure(const MAT1 &m1_, const VECT1 &v1_,
const VECT2 &v2_,
if (!(error <= prec))
GMM_ASSERT1(false, "Error too large: " << error);
gmm::mult(gmm::row_vector(gmm::conjugated(v3)), gmm::conjugated(m2),
- gmm::row_vector(v2));
+ gmm::row_vector(v2));
gmm::add(gmm::conjugated(gmm::scaled(v5, T(-1))), v2);
error = gmm::vect_norm2(v2);
if (!(error <= prec))
@@ -211,19 +211,19 @@ bool test_procedure(const MAT1 &m1_, const VECT1 &v1_,
const VECT2 &v2_,
gmm::resize(m1, a+a2, b+b2);
for (size_type i = 0; i < a+a2; ++i)
for (size_type j = 0; j < b+b2; ++j) {
- if (i < a && j < b) {
- if (m3(i, j) != m1(i, j))
- GMM_ASSERT1(false, "Error in resize");
- }
- else
- if (m1(i, j) != T(0))
- GMM_ASSERT1(false, "Error in resize");
+ if (i < a && j < b) {
+ if (m3(i, j) != m1(i, j))
+ GMM_ASSERT1(false, "Error in resize");
+ }
+ else
+ if (m1(i, j) != T(0))
+ GMM_ASSERT1(false, "Error in resize");
}
gmm::resize(m1, a2, b2);
for (size_type i = 0; i < a2; ++i)
for (size_type j = 0; j < b2; ++j)
- if (m3(i, j) != m1(i, j))
- GMM_ASSERT1(false, "Error in resize");
+ if (m3(i, j) != m1(i, j))
+ GMM_ASSERT1(false, "Error in resize");
}
if (gmm::is_original_linalg(v1)) {
@@ -234,17 +234,17 @@ bool test_procedure(const MAT1 &m1_, const VECT1 &v1_,
const VECT2 &v2_,
gmm::resize(v1, a+a2);
for (size_type i = 0; i < a+a2; ++i) {
if (i < a) {
- if (v1[i] != v6[i])
- GMM_ASSERT1(false, "Error in resize");
- }
- else
- if (v1[i] != T(0))
- GMM_ASSERT1(false, "Error in resize");
+ if (v1[i] != v6[i])
+ GMM_ASSERT1(false, "Error in resize");
+ }
+ else
+ if (v1[i] != T(0))
+ GMM_ASSERT1(false, "Error in resize");
}
gmm::resize(v1, a2);
for (size_type i = 0; i < a2; ++i)
if (v1[i] != v6[i])
- GMM_ASSERT1(false, "Error in resize");
+ GMM_ASSERT1(false, "Error in resize");
}
test_mat_swap(m1, typename gmm::linalg_traits<MAT1>::is_reference());
diff --git a/tests/gmm_torture10_qr.cc b/tests/gmm_torture10_qr.cc
index 22bb8d1f..d6bb1122 100644
--- a/tests/gmm_torture10_qr.cc
+++ b/tests/gmm_torture10_qr.cc
@@ -32,7 +32,7 @@ using std::ends; using std::cin;
using gmm::size_type;
bool print_debug = false;
-// template <typename MAT, typename T> void print_for_matlab(const MAT &m, T)
{
+// template <typename MAT, typename T> void print_for_matlab(const MAT &m, T) {
// cout.precision(16);
// cout << "[ ";
// for (size_type i = 0; i < gmm::mat_nrows(m); ++i) {
@@ -43,7 +43,7 @@ bool print_debug = false;
// }
// template <typename MAT, typename T> void print_for_matlab(const MAT &m,
-// std::complex<T>) {
+// std::complex<T>) {
// cout.precision(16);
// cout << "[ ";
// for (size_type i = 0; i < gmm::mat_nrows(m); ++i) {
@@ -63,7 +63,7 @@ template <typename T> inline T real_or_complex(double a,
double, T)
template <typename T> inline
std::complex<T> real_or_complex(double a, double b, std::complex<T>) {
typedef typename gmm::number_traits<T>::magnitude_type R;
- return std::complex<T>(R(a), R(b));
+ return std::complex<T>(R(a), R(b));
}
template <typename T> struct cmp_eval {
@@ -78,7 +78,7 @@ template <typename T> struct cmp_eval {
template <typename T> void sort_eval(std::vector<T> &v) {
std::sort(v.begin(), v.end(), cmp_eval<T>());
-}
+}
template <typename MAT1, typename MAT2>
@@ -102,10 +102,10 @@ bool test_procedure(const MAT1 &m1_, const MAT2 &m2_) {
if (print_debug) {
static int nexpe = 0;
- cout << "Begin experiment " << ++nexpe << "\n\nwith " << m1 << "\n\n";
+ cout << "Begin experiment " << ++nexpe << "\n\nwith " << m1 << "\n\n";
gmm::set_warning_level(3);
}
-
+
gmm::dense_matrix<T> dm1(m, n);
gmm::copy(m1, dm1);
if (m >= n) {
@@ -115,15 +115,15 @@ bool test_procedure(const MAT1 &m1_, const MAT2 &m2_) {
gmm::qr_factor(dm1);
gmm::copy(dm1, m1);
-
+
gmm::apply_house_right(dm1, q);
for (size_type j = 0; j < n; ++j)
for (size_type i = j+1; i < m; ++i)
- dm1(i, j) = T(0);
+ dm1(i, j) = T(0);
gmm::mult(q, dm1, dm1aux);
gmm::add(gmm::scaled(m1aux, T(-1)), dm1aux);
error = gmm::mat_euclidean_norm(dm1aux);
- if (!(error <= prec * R(10000)))
+ if (!(error <= prec * R(10000)))
GMM_ASSERT1(false, "Error too large: " << error);
gmm::copy(gmm::identity_matrix(), q);
@@ -137,7 +137,7 @@ bool test_procedure(const MAT1 &m1_, const MAT2 &m2_) {
error = gmm::mat_euclidean_norm(a);
if (!(error <= prec * R(10000)))
GMM_ASSERT1(false, "Error too large: " << error);
-
+
gmm::copy(gmm::conjugated(qaux), q2);
gmm::apply_house_left(m1, q2);
gmm::mult(gmm::conjugated(q2), dm1, dm1aux);
@@ -145,7 +145,6 @@ bool test_procedure(const MAT1 &m1_, const MAT2 &m2_) {
error = gmm::mat_euclidean_norm(dm1aux);
if (!(error <= prec * R(10000)))
GMM_ASSERT1(false, "Error too large: " << error);
-
}
else {
gmm::dense_matrix<T> q(k,n), qaux(k,n), q2(n,k), dm1aux(k,m), m1aux(k,m);
@@ -154,15 +153,15 @@ bool test_procedure(const MAT1 &m1_, const MAT2 &m2_) {
gmm::qr_factor(gmm::transposed(dm1));
gmm::copy(dm1, m1);
-
+
gmm::apply_house_right(gmm::transposed(dm1), q);
for (size_type i = 0; i < m; ++i)
for (size_type j = i+1; j < n; ++j)
- dm1(i, j) = T(0);
+ dm1(i, j) = T(0);
gmm::mult(q, gmm::transposed(dm1), dm1aux);
gmm::add(gmm::scaled(m1aux, T(-1)), dm1aux);
error = gmm::mat_euclidean_norm(dm1aux);
- if (!(error <= prec * R(10000)))
+ if (!(error <= prec * R(10000)))
GMM_ASSERT1(false, "Error too large: " << error);
gmm::copy(gmm::identity_matrix(), q);
@@ -176,25 +175,25 @@ bool test_procedure(const MAT1 &m1_, const MAT2 &m2_) {
error = gmm::mat_euclidean_norm(a);
if (!(error <= prec * R(10000)))
GMM_ASSERT1(false, "Error too large: " << error);
-
+
gmm::copy(gmm::conjugated(qaux), q2);
gmm::apply_house_left(gmm::transposed(m1), q2);
gmm::mult(gmm::conjugated(q2), gmm::transposed(dm1), dm1aux);
gmm::add(gmm::scaled(m1aux, T(-1)), dm1aux);
error = gmm::mat_euclidean_norm(dm1aux);
- if (!(error <= prec * R(10000)))
+ if (!(error <= prec * R(10000)))
GMM_ASSERT1(false, "Error too large: " << error);
}
-
+
//
// Test for implicit_qr_algorithm
//
-
+
m = gmm::mat_nrows(m2);
- gmm::dense_matrix<T> cq(m, m), cr(m, m), ca(m, m);
+ gmm::dense_matrix<T> cq(m, m), cr(m, m), ca(m, m);
std::vector<T> cv(m);
std::vector<std::complex<R> > eigc(m), cvc(m);
@@ -205,18 +204,18 @@ bool test_procedure(const MAT1 &m1_, const MAT2 &m2_) {
for (size_type i = 0; i < m; ++i) det2 *= eigc[i];
if (gmm::abs(det1 - det2) > (gmm::abs(det1)+gmm::abs(det2))/R(50))
GMM_ASSERT1(false, "Error in QR or det. det lu: " << det1
- << " det qr: " << det2);
+ << " det qr: " << det2);
if (print_debug)
cout << "det lu = " << det1 << " det qr = " << det2 << endl;
if (m > 0) do {
gmm::fill_random(cq);
} while (gmm::abs(gmm::lu_det(cq)) < sqrt(prec)
- || gmm::condition_number(cq) > R(1000));
+ || gmm::condition_number(cq) > R(1000));
gmm::copy(cq, cr);
gmm::lu_inverse(cr);
-
+
gmm::fill_random(cv);
if (m > 0) cv[ 0] = real_or_complex( 0.0, 0.0, cv[0]);
@@ -237,12 +236,12 @@ bool test_procedure(const MAT1 &m1_, const MAT2 &m2_) {
if (m > 15) cv[15] = real_or_complex(100000.0, 1.0, cv[0]);
gmm::clear(m2);
for (size_type l = 0; l < m; ++l) m2(l, l) = cv[l];
- gmm::mult(cq, m2, ca);
+ gmm::mult(cq, m2, ca);
gmm::mult(ca, cr, ca);
-
+
implicit_qr_algorithm(ca, eigc, cq);
gmm::copy(cv, cvc);
-
+
sort_eval(cvc);
sort_eval(eigc);
error = gmm::vect_dist2(cvc, eigc);
@@ -257,19 +256,18 @@ bool test_procedure(const MAT1 &m1_, const MAT2 &m2_) {
bb(i, j) = T(0);
error = gmm::mat_maxnorm(bb);
if (!(error <= sqrt(prec) * gmm::vect_norm2(cv) * R(10)))
- GMM_ASSERT1(false, "Error in Schur vectors, error = "<< error);
+ GMM_ASSERT1(false, "Error in Schur vectors, error = "<< error);
//
// Test for symmetric_qr_algorithm
//
-
m = gmm::mat_nrows(m2);
std::vector<R> cvr(m), eigcr(m);
if (m > 0) do {
gmm::fill_random(cr);
} while (gmm::abs(gmm::lu_det(cr)) < sqrt(prec)
- || gmm::condition_number(cr) > R(1000));
-
+ || gmm::condition_number(cr) > R(1000));
+
gmm::qr_factor(cr, cq, ca);
gmm::fill_random(cvr);
@@ -294,19 +292,18 @@ bool test_procedure(const MAT1 &m1_, const MAT2 &m2_) {
gmm::clear(m2);
for (size_type l = 0; l < m; ++l) m2(l, l) = cvr[l];
- gmm::mult(gmm::conjugated(cq), m2, ca);
+ gmm::mult(gmm::conjugated(cq), m2, ca);
gmm::mult(ca, cq, ca);
-
+
symmetric_qr_algorithm(ca, eigcr, cq);
for (size_type l = 0; l < m; ++l) {
- std::vector<T> vy(m);
- gmm::mult(ca, gmm::mat_col(cq, l),
- gmm::scaled(gmm::mat_col(cq, l), -eigcr[l]), vy);
- error = gmm::vect_norm2(vy);
- if (!(error <= sqrt(prec) * gmm::vect_norm2(cvr) * R(10)))
- GMM_ASSERT1(false, "Error too large: " << error);
-
+ std::vector<T> vy(m);
+ gmm::mult(ca, gmm::mat_col(cq, l),
+ gmm::scaled(gmm::mat_col(cq, l), -eigcr[l]), vy);
+ error = gmm::vect_norm2(vy);
+ if (!(error <= sqrt(prec) * gmm::vect_norm2(cvr) * R(10)))
+ GMM_ASSERT1(false, "Error too large: " << error);
}
sort_eval(cvr);
diff --git a/tests/laplacian.cc b/tests/laplacian.cc
index d4caf948..a8333043 100644
--- a/tests/laplacian.cc
+++ b/tests/laplacian.cc
@@ -21,7 +21,7 @@
/**@file laplacian.cc
@brief Laplacian (Poisson) problem.
-
+
The laplace equation is solved on a regular mesh of the unit
square, and is compared to the analytical solution.
@@ -88,12 +88,12 @@ struct laplacian_problem {
std::vector<scalar_type> U, B; /* main unknown, and right hand side */
std::vector<scalar_type> Ud; /* reduced sol. for gen. Dirichlet condition. */
- col_sparse_matrix_type NS; /* Dirichlet NullSpace
+ col_sparse_matrix_type NS; /* Dirichlet NullSpace
* (used if gen_dirichlet is true)
*/
std::string datafilename;
bgeot::md_param PARAM;
-
+
void assembly(void);
bool solve(void);
void init(void);
@@ -106,7 +106,7 @@ struct laplacian_problem {
* and integration methods and selects the boundaries.
*/
void laplacian_problem::init(void) {
-
+
std::string MESH_TYPE = PARAM.string_value("MESH_TYPE","Mesh type ");
std::string FEM_TYPE = PARAM.string_value("FEM_TYPE","FEM name");
std::string INTEGRATION = PARAM.string_value("INTEGRATION",
@@ -117,7 +117,7 @@ void laplacian_problem::init(void) {
cout << "INTEGRATION=" << INTEGRATION << "\n";
/* First step : build the mesh */
- bgeot::pgeometric_trans pgt =
+ bgeot::pgeometric_trans pgt =
bgeot::geometric_trans_descriptor(MESH_TYPE);
N = pgt->dim();
std::vector<size_type> nsubdiv(N);
@@ -125,7 +125,7 @@ void laplacian_problem::init(void) {
PARAM.int_value("NX", "Nomber of space steps "));
getfem::regular_unit_mesh(mesh, nsubdiv, pgt,
PARAM.int_value("MESH_NOISED") != 0);
-
+
bgeot::base_matrix M(N,N);
for (size_type i=0; i < N; ++i) {
static const char *t[] = {"LX","LY","LZ"};
@@ -160,12 +160,12 @@ void laplacian_problem::init(void) {
<< "DATA_FEM_TYPE in the .param file");
mf_rhs.set_finite_element(mesh.convex_index(), pf_u);
} else {
- mf_rhs.set_finite_element(mesh.convex_index(),
+ mf_rhs.set_finite_element(mesh.convex_index(),
getfem::fem_descriptor(data_fem_name));
}
-
+
/* set the finite element on mf_coef. Here we use a very simple element
- * since the only function that need to be interpolated on the mesh_fem
+ * since the only function that need to be interpolated on the mesh_fem
* is f(x)=1 ... */
mf_coef.set_finite_element(mesh.convex_index(),
getfem::classical_fem(pgt,0));
@@ -198,27 +198,27 @@ void laplacian_problem::assembly(void) {
size_type nb_dof_rhs = mf_rhs.nb_dof();
gmm::resize(B, nb_dof); gmm::clear(B);
- gmm::resize(U, nb_dof); gmm::clear(U);
+ gmm::resize(U, nb_dof); gmm::clear(U);
gmm::resize(SM, nb_dof, nb_dof); gmm::clear(SM);
-
+
cout << "Number of dof : " << nb_dof << endl;
cout << "Assembling stiffness matrix" << endl;
- getfem::asm_stiffness_matrix_for_laplacian(SM, mim, mf_u, mf_coef,
+ getfem::asm_stiffness_matrix_for_laplacian(SM, mim, mf_u, mf_coef,
std::vector<scalar_type>(mf_coef.nb_dof(), 1.0));
-
+
cout << "Assembling source term" << endl;
std::vector<scalar_type> F(nb_dof_rhs);
getfem::interpolation_function(mf_rhs, F, sol_f);
getfem::asm_source_term(B, mim, mf_u, mf_rhs, F);
-
+
cout << "Assembling Neumann condition" << endl;
gmm::resize(F, nb_dof_rhs*N);
getfem::interpolation_function(mf_rhs, F, sol_grad);
getfem::asm_normal_source_term(B, mim, mf_u, mf_rhs, F,
NEUMANN_BOUNDARY_NUM);
- cout << "take Dirichlet condition into account" << endl;
- if (!gen_dirichlet) {
+ cout << "take Dirichlet condition into account" << endl;
+ if (!gen_dirichlet) {
std::vector<scalar_type> D(nb_dof);
getfem::interpolation_function(mf_u, D, sol_u);
getfem::assembling_Dirichlet_condition(SM, B, mf_u,
@@ -226,7 +226,7 @@ void laplacian_problem::assembly(void) {
} else {
gmm::resize(F, nb_dof_rhs);
getfem::interpolation_function(mf_rhs, F, sol_u);
-
+
gmm::resize(Ud, nb_dof);
gmm::resize(NS, nb_dof, nb_dof);
col_sparse_matrix_type H(nb_dof_rhs, nb_dof);
@@ -277,17 +277,17 @@ bool laplacian_problem::solve(void) {
cout << "Time to compute preconditionner : "
<< gmm::uclock_sec() - time << " seconds\n";
-
+
//gmm::HarwellBoeing_IO::write("SM", SM);
// gmm::cg(SM, U, B, P, iter);
gmm::gmres(SM, U, B, P, 50, iter);
} else {
- double rcond;
- gmm::SuperLU_solve(SM, U, B, rcond);
+ double rcond;
+ gmm::SuperLU_solve(SM, U, B, rcond);
cout << "cond = " << 1/rcond << "\n";
}
-
+
cout << "Total time to solve : "
<< gmm::uclock_sec() - time << " seconds\n";
@@ -310,7 +310,7 @@ void laplacian_problem::compute_error() {
cout.precision(16);
cout << "L2 error = " << getfem::asm_L2_norm(mim, mf_rhs, V) << endl
<< "H1 error = " << getfem::asm_H1_norm(mim, mf_rhs, V) << endl
- << "Linfty error = " << gmm::vect_norminf(V) << endl;
+ << "Linfty error = " << gmm::vect_norminf(V) << endl;
}
/**************************************************************************/
@@ -323,7 +323,7 @@ int main(int argc, char *argv[]) {
GMM_SET_EXCEPTION_DEBUG; // Exceptions make a memory fault, to debug.
FE_ENABLE_EXCEPT; // Enable floating point exception for Nan.
- try {
+ try {
laplacian_problem p;
p.PARAM.read_command_line(argc, argv);
p.init();
@@ -333,8 +333,8 @@ int main(int argc, char *argv[]) {
p.compute_error();
}
GMM_STANDARD_CATCH_ERROR;
-
+
GETFEM_MPI_FINALIZE;
- return 0;
+ return 0;
}
diff --git a/tests/schwarz_additive.cc b/tests/schwarz_additive.cc
index 2df0dac8..68040126 100644
--- a/tests/schwarz_additive.cc
+++ b/tests/schwarz_additive.cc
@@ -72,15 +72,15 @@ struct pb_data {
linalg_vector U, F; /* Unknown and right hand side. */
int solver;
- void assemble(void);
+ void assemble();
void init(bgeot::md_param ¶ms);
- int solve_cg(void);
- int solve_cg2(void);
- int solve_superlu(void);
+ int solve_cg();
+ int solve_cg2();
+ int solve_superlu();
int solve_schwarz(int);
- int solve(void) {
+ int solve() {
cout << "solving" << endl;
switch (solver) {
case 0 : return solve_cg();
@@ -190,7 +190,7 @@ void pb_data::init(bgeot::md_param ¶ms) {
}
}
-void pb_data::assemble(void) {
+void pb_data::assemble() {
size_type nb_dof = mef.nb_dof();
std::cout << "number of dof : "<< nb_dof << endl;
size_type nb_dof_data = mef_data.nb_dof();
@@ -217,20 +217,20 @@ void pb_data::assemble(void) {
getfem::assembling_Dirichlet_condition(RM, F, mef, 0, UD);
}
-int pb_data::solve_cg(void) {
+int pb_data::solve_cg() {
gmm::iteration iter(residual, 1, 1000000);
gmm::ildlt_precond<general_sparse_matrix> P(RM);
gmm::cg(RM, U, F, gmm::identity_matrix(), P, iter);
return int(iter.get_iteration());
}
-int pb_data::solve_superlu(void) {
+int pb_data::solve_superlu() {
double rcond;
SuperLU_solve(RM, U, F, rcond);
return 1;
}
-int pb_data::solve_cg2(void) {
+int pb_data::solve_cg2() {
gmm::iteration iter(residual, 1, 1000000);
gmm::cg(RM, U, F, gmm::identity_matrix(), gmm::identity_matrix(), iter);
return int(iter.get_iteration());
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] [getfem-commits] branch master updated: Whitespace fixes and remove redundant header includes,
Konstantinos Poulios <=