getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] r5048 - /trunk/getfem/tests/


From: Yves . Renard
Subject: [Getfem-commits] r5048 - /trunk/getfem/tests/
Date: Wed, 22 Jul 2015 09:51:38 -0000

Author: renard
Date: Wed Jul 22 11:51:37 2015
New Revision: 5048

URL: http://svn.gna.org/viewcvs/getfem?rev=5048&view=rev
Log:
remove some obsolete tests and integrate some others

Added:
    trunk/getfem/tests/test_continuation.pl
    trunk/getfem/tests/test_mesh_generation.pl
Removed:
    trunk/getfem/tests/test_gmm_lapack.cc
    trunk/getfem/tests/test_grad.cc
    trunk/getfem/tests/test_superlu.cc
Modified:
    trunk/getfem/tests/Makefile.am

Modified: trunk/getfem/tests/Makefile.am
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/tests/Makefile.am?rev=5048&r1=5047&r2=5048&view=diff
==============================================================================
--- trunk/getfem/tests/Makefile.am      (original)
+++ trunk/getfem/tests/Makefile.am      Wed Jul 22 11:51:37 2015
@@ -2,7 +2,8 @@
 optprogs = test_mesh_generation test_mesh_im_level_set crack 
thermo_elasticity_electrical_coupling
 optpl = test_mesh_im_level_set.pl \
         crack.pl                  \
-       thermo_elasticity_electrical_coupling.pl
+       thermo_elasticity_electrical_coupling.pl \
+       test_mesh_generation.pl
 else
 optprogs =
 optpl = 
@@ -128,7 +129,8 @@
        $(optpl)                      \
        nonlinear_elastostatic.pl     \
        nonlinear_membrane.pl         \
-       plasticity.pl                 \
+       test_continuation.pl          \
+        plasticity.pl                 \
        helmholtz.pl                  \
        schwarz_additive.pl           \
        bilaplacian.pl                \
@@ -163,6 +165,7 @@
        thermo_elasticity_electrical_coupling.param             \
        test_tree_sorted.pl                                     \
        test_mat_elem.pl                                        \
+       test_mesh_generation.pl                                 \
        crack.pl                                                \
        crack.param                                             \
        laplacian.param                                         \
@@ -192,6 +195,7 @@
        wave_equation.param                                     \
        cyl_slicer.pl                                           \
        test_continuation.param                                 \
+       test_continuation.pl                                    \
        make_gmm_test.pl                                        \
        gmm_torture01_lusolve.cc                                \
        gmm_torture05_mult.cc                                   \

Added: trunk/getfem/tests/test_continuation.pl
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/tests/test_continuation.pl?rev=5048&view=auto
==============================================================================
--- trunk/getfem/tests/test_continuation.pl     (added)
+++ trunk/getfem/tests/test_continuation.pl     Wed Jul 22 11:51:37 2015
@@ -0,0 +1,65 @@
+# Copyright (C) 2015-2015 Yves Renard
+#
+# This file is a part of GETFEM++
+#
+# Getfem++  is  free software;  you  can  redistribute  it  and/or modify it
+# under  the  terms  of the  GNU  Lesser General Public License as published
+# by  the  Free Software Foundation;  either version 3 of the License,  or
+# (at your option) any later version along with the GCC Runtime Library
+# Exception either version 3.1 or (at your option) any later version.
+# This program  is  distributed  in  the  hope  that it will be useful,  but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or  FITNESS  FOR  A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+# License and GCC Runtime Library Exception for more details.
+# You  should  have received a copy of the GNU Lesser General Public License
+# along  with  this program;  if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
+
+$bin_dir = "$ENV{srcdir}/../bin";
+$tmp = `$bin_dir/createmp cont.param`;
+
+sub catch { `rm -f $tmp`; print "error caught..\n"; exit(1); }
+$SIG{INT} = 'catch';
+
+open(TMPF, ">$tmp") or die "Open file impossible : $!\n";
+
+print TMPF <<""
+NX = 10;
+FEM_TYPE = 'FEM_PK(1,1)';
+INTEGRATION = 'IM_GAUSS1D(3)';
+DATAPATH = 'data/';
+IND_BRANCH = 2;
+DIRECTION = 1.;
+LAMBDA0 = 0.;
+NBSTEP = 80;
+SINGULARITIES = 2;
+H_INIT = 2E-2;
+H_MAX = 2E-1;
+H_MIN = 2E-5;
+H_INC = 1.3;
+H_DEC = 0.5;
+MAXITER = 5;
+THR_ITER = 4;
+RESIDUAL = 1E-6;
+DIFFERENCE = 1E-6;
+COS = 0.997;
+RESIDUAL_SOLVE = 1E-8
+NOISY = 1;
+
+;
+close(TMPF);
+
+$er = 0;
+open F, "./test_continuation $tmp 2>&1 |" or die "could not open $tmp\n";
+while (<F>) {
+  #print $_; #uncomment this line in case of problem..
+  if ($_ =~ /smooth bifurcation point/) {
+    ($a, $b) = split(',', $_);
+    if (abs($b - 2) > 0) { print "\nWrong number of bifurcation points\n"; $er 
= 1; }
+  }
+}
+close(F); if ($?) { `rm -f $tmp`; exit(1); }
+if ($er == 1) { `rm -f $tmp`; exit(1); }
+`rm -f $tmp`;
+
+

Removed: trunk/getfem/tests/test_gmm_lapack.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/tests/test_gmm_lapack.cc?rev=5047&view=auto
==============================================================================
--- trunk/getfem/tests/test_gmm_lapack.cc       (original)
+++ trunk/getfem/tests/test_gmm_lapack.cc       (removed)
@@ -1,127 +0,0 @@
-/*===========================================================================
- 
- Copyright (C) 2002-2015 Yves Renard.
- 
- This file is a part of GETFEM++
- 
- Getfem++  is  free software;  you  can  redistribute  it  and/or modify it
- under  the  terms  of the  GNU  Lesser General Public License as published
- by  the  Free Software Foundation;  either version 3 of the License,  or
- (at your option) any later version along with the GCC Runtime Library
- Exception either version 3.1 or (at your option) any later version.
- This program  is  distributed  in  the  hope  that it will be useful,  but
- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or  FITNESS  FOR  A PARTICULAR PURPOSE.  See the GNU Lesser General Public
- License and GCC Runtime Library Exception for more details.
- You  should  have received a copy of the GNU Lesser General Public License
- along  with  this program;  if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
- 
-===========================================================================*/
-
-// à compiler avec la ligne de commande pour lapack/blas
-// g++ -I ../../src -O3 ../../tests/test_gmm_lapack.C -o test_gmm_lapack 
-llapack -lblas -lg2c
-
-// à compiler avec la ligne de commande pour atlas
-// g++ -I ../../src -O3 ../../tests/test_gmm_lapack.C -o test_gmm_lapack 
/usr/lib/atlas/liblapack.a /usr/lib/atlas/libblas.a -latlas  -lg2c
-
-// options d'optimisations avec g++ :
-//  -funroll-all-loops -ffast-math -fstrict-aliasing -fomit-frame-pointer
-
-// pour qd ou dd :
-// /home/gmmpc15/renard/usr/pc_g++/lib/libqd.a 
-// #define NO_INLINE
-// #include <qd.h> 
-// #include <dd.h>
-// #include <x86.h>
-
-#define NO_INLINE
-#include <dd.h>
-#include <qd.h>
-#include <x86.h>
-
-// #define GMM_USES_LAPACK
-#include "gmm/gmm.h"
-#include "gmm/gmm_inoutput.h"
-
-
-using gmm::size_type;
-
-template<class MAT> void my_mult(const MAT &A, const MAT &B, MAT &C) {
-  gmm::mult(gmm::conjugated(A), gmm::conjugated(B), C);
-  
-}
-
-template <class T> void test_with(T) {
-  size_type n = 7;
-
-  gmm::dense_matrix<T> A(n, n), B(n, n), C(n, n);
-  std::vector<T> x(n), y(n), z(n);
-  
-  gmm::fill_random(A);
-  gmm::fill_random(B);
-  gmm::fill_random(x);
-  gmm::fill_random(y);
-
-  gmm::lu_solve(A, x, y);
-  gmm::mult(A, x, gmm::scaled(y, T(-1)), z);
-  cout << "z = " << z << endl;
-  
-  
-  double exectime = dal::uclock_sec();
-  implicit_qr_algorithm(A, x, C, 1E-10);
-
-  // gmm::mult(A, x, gmm::scaled(y, T(-1)), z);
-  // cout << "z = " << z << endl;
-
-  cout << "A = " << A << endl;
-  cout << "x = " << x << endl;
-  cout << "C = " << C << endl;
-  // my_mult(A, B, C);
-
-  gmm::mult(C, conjugated(C), B);
-  cout << "B = " << B << endl;
-  cout << "cpu time = " << dal::uclock_sec() - exectime << endl;
-  // cout << "col(B,2) = " << gmm::mat_const_col(B,2) << endl;
-  // cout << "col(C,2) = " << gmm::mat_const_col(C,2) << endl;
-  
-}
-
-int main(void)
-{
-  dal::exception_callback_debug cb;
-  dal::exception_callback::set_exception_callback(&cb);
-
-  srand(1459);
-
-# if defined(GMM_USES_LAPACK) || defined(GMM_USES_ATLAS)
-  cout << "Trying using Lapack\n";
-# else
-  cout << "Not using Lapack\n";
-# endif
-
-  try {
-
-    unsigned short old_cw;
-    x86_fix_start(&old_cw);
-    
-    // test_with(float());
-    // test_with(double());
-    // test_with(std::complex<float>());
-    // test_with(std::complex<double>());
-
-    dd_real a = "1.23456789012345678901234567890123456789";
-
-    cout << "a dd-real : " << a << endl;
-
-    test_with(qd_real());
-    test_with(std::complex<double>());
-    test_with(std::complex<qd_real>());
-
-    x86_fix_end(&old_cw);
-    
-  }
-  GMM_STANDARD_CATCH_ERROR;
-
-  return 0;
-}

Removed: trunk/getfem/tests/test_grad.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/tests/test_grad.cc?rev=5047&view=auto
==============================================================================
--- trunk/getfem/tests/test_grad.cc     (original)
+++ trunk/getfem/tests/test_grad.cc     (removed)
@@ -1,166 +0,0 @@
-/*===========================================================================
- 
- Copyright (C) 2007-2015 Yves Renard, Julien Pommier.
- 
- This file is a part of GETFEM++
- 
- Getfem++  is  free software;  you  can  redistribute  it  and/or modify it
- under  the  terms  of the  GNU  Lesser General Public License as published
- by  the  Free Software Foundation;  either version 3 of the License,  or
- (at your option) any later version along with the GCC Runtime Library
- Exception either version 3.1 or (at your option) any later version.
- This program  is  distributed  in  the  hope  that it will be useful,  but
- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or  FITNESS  FOR  A PARTICULAR PURPOSE.  See the GNU Lesser General Public
- License and GCC Runtime Library Exception for more details.
- You  should  have received a copy of the GNU Lesser General Public License
- along  with  this program;  if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
- 
-===========================================================================*/
-#include "gmm/gmm.h"
-#include "gmm/gmm.h"
-
-// scalar product working also for matrices (to be done in GMM++ ...
-template<class VAR> 
-typename gmm::linalg_traits<VAR>::value_type
-local_sp(const VAR &X, const VAR &Y)
-{ return local_sp(X, Y, typename gmm::linalg_traits<VAR>::linalg_type()); }
-
-template<class VAR> 
-typename gmm::linalg_traits<VAR>::value_type
-local_sp(const VAR &X, const VAR &Y, gmm::abstract_vector)
-{ return gmm::vect_sp(X, Y); }
-
-template<class VAR> 
-typename gmm::linalg_traits<VAR>::value_type
-local_sp(const VAR &X, const VAR &Y, gmm::abstract_matrix) {
-  typename gmm::linalg_traits<VAR>::value_type res(0);
-  for (gmm::size_type i = 0; i < gmm::mat_nrows(X); ++i) 
-    for (gmm::size_type j = 0; j < gmm::mat_ncols(X); ++j)
-      res += X(i, j) * Y(i, j);
-  return res;
-}
-
-
-// Make a test of the gradient around X.
-template <class FUNC, class GRAD, class VAR> 
-void test_grad_at(FUNC f, GRAD grad, const VAR &X) {
-  
-  typedef typename gmm::linalg_traits<VAR>::value_type T;
-  typedef typename gmm::number_traits<T>::magnitude_type R;
-  VAR Y(X), Z(X), G(X);
-  
-  grad(X, G);
-  T valx = f(X);
-
-  R eps(1), max_ratio(1), ecart, ecart_old, min_ecart(1);
-  gmm::fill_random(Z);
-  T derdir = local_sp(G, Z), estimate_derdir;
-  for (int i = 0; i < 10; ++i, eps /= R(10)) {
-    gmm::add(gmm::scaled(Z, eps), X, Y);
-    estimate_derdir = (f(Y) - valx) / eps;
-    ecart = gmm::abs(derdir - estimate_derdir);
-    min_ecart = std::min(ecart, min_ecart);
-    // The goal is of course to obtain a clear decreasing sequence
-    cout << " " << ecart;
-    if (i >= 1)
-      if (ecart != T(0)) max_ratio = std::max(max_ratio, ecart_old / ecart);
-      else max_ratio = R(10);
-    ecart_old = ecart;
-  }
-  cout << endl;
-  if (max_ratio < R(9) && min_ecart > 1E-9) {
-    cout << "ERROR, The gradient does not seem to be ok !! max_ratio = "
-        << max_ratio << "\n";
-    exit(1);
-  }
-}
-
-template <class FUNC, class GRAD, class VAR> 
-void test_grad(FUNC f, GRAD grad, const VAR &X) {
-  VAR Y(X);
-  for (long i = 0; i < 10000; ++i) {
-    gmm::fill_random(Y);
-    // gmm::scale(Y, rand() / 1000 + 1);
-    cout << "Expe " << i+1 << " X = " << Y;
-    test_grad_at(f, grad, Y);
-    cout << endl;
-  }
-  cout << "The gradient seems to be ok !!\n";
-}
-
-//
-// Gradient of the Frobenius condition number
-//
-
-template <typename MAT, typename MAT2> void
-squared_Frobenius_condition_number_gradient(const MAT& M, MAT2& G) { 
-  typedef typename gmm::linalg_traits<MAT>::value_type T;
-  typedef typename gmm::number_traits<T>::magnitude_type R;
-  
-  gmm::size_type n = gmm::mat_ncols(M);
-  gmm::dense_matrix<T> B(n,n), C(n,n);
-  gmm::mult(gmm::transposed(M), M, B);
-  R trB = gmm::mat_trace(B);
-  gmm::lu_inverse(B);
-  R trBinv = gmm::mat_trace(B);
-  gmm::mult(B,B,C);
-  gmm::mult(gmm::scaled(M, T(-2)*trB), C, G);
-  gmm::add(gmm::scaled(M, T(2)*trBinv), G);
-}
-
-
-typedef gmm::dense_matrix<double> DM;
-
-struct func {
-  double operator()(const DM &M) { return Frobenius_condition_number_sqr(M); } 
-};
-
-struct grad {
-  void operator()(const DM &M, DM &G)
-    { squared_Frobenius_condition_number_gradient(M, G); }
-};
-
-//
-// Signed distance for the torus
-//
-
-typedef std::vector<double> base_node;
-typedef double scalar_type;
-
-struct func2 {
-  scalar_type operator()(const base_node &P) const {
-    scalar_type R = 2.0, r = 0.5;
-
-    scalar_type x = P[0], y = P[1], z = P[2];
-    scalar_type c = sqrt(x*x + y*y);
-    if (c == 0.) return R - r;
-    return sqrt(gmm::sqr(c-R) + z*z) - r;
-  }
-};
-
-
-struct grad2 {
-  void operator()(const base_node &P, base_node &G) const {
-    gmm::clear(G); 
-    scalar_type R = 2.0, r = 0.5;
-    scalar_type x = P[0], y = P[1], z = P[2];
-    scalar_type c = sqrt(x*x + y*y);
-    if (c == 0.) return;
-    scalar_type w = 1. - R / c;
-    scalar_type e = sqrt(gmm::sqr(c-R) + z*z);
-    if (e == 0) return;
-    G[0] = x * w / e;
-    G[1] = y * w / e;
-    G[2] = z / e;
-  }
-};
-
-int main(void) {
-
-  test_grad(func(), grad(), DM(5, 5));
-  test_grad(func2(), grad2(), base_node(3));
-
-  return 0;
-}

Added: trunk/getfem/tests/test_mesh_generation.pl
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/tests/test_mesh_generation.pl?rev=5048&view=auto
==============================================================================
--- trunk/getfem/tests/test_mesh_generation.pl  (added)
+++ trunk/getfem/tests/test_mesh_generation.pl  Wed Jul 22 11:51:37 2015
@@ -0,0 +1,32 @@
+# Copyright (C) 2001-2015 Yves Renard
+#
+# This file is a part of GETFEM++
+#
+# Getfem++  is  free software;  you  can  redistribute  it  and/or modify it
+# under  the  terms  of the  GNU  Lesser General Public License as published
+# by  the  Free Software Foundation;  either version 3 of the License,  or
+# (at your option) any later version along with the GCC Runtime Library
+# Exception either version 3.1 or (at your option) any later version.
+# This program  is  distributed  in  the  hope  that it will be useful,  but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or  FITNESS  FOR  A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+# License and GCC Runtime Library Exception for more details.
+# You  should  have received a copy of the GNU Lesser General Public License
+# along  with  this program;  if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
+
+
+$er = 0;
+open F, "./test_mesh_generation 2>&1 |" or die;
+while (<F>) {
+  # print $_;
+    if ($_ =~ /error has been detected/) {
+    $er = 1;
+    print "=============================================================\n";
+    print $_, <F>;
+  }
+
+}
+close(F); if ($?) { exit(1); }
+if ($er == 1) { exit(1); }
+

Removed: trunk/getfem/tests/test_superlu.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/tests/test_superlu.cc?rev=5047&view=auto
==============================================================================
--- trunk/getfem/tests/test_superlu.cc  (original)
+++ trunk/getfem/tests/test_superlu.cc  (removed)
@@ -1,114 +0,0 @@
-/*===========================================================================
- 
- Copyright (C) 2002-2015 Yves Renard.
- 
- This file is a part of GETFEM++
- 
- Getfem++  is  free software;  you  can  redistribute  it  and/or modify it
- under  the  terms  of the  GNU  Lesser General Public License as published
- by  the  Free Software Foundation;  either version 3 of the License,  or
- (at your option) any later version along with the GCC Runtime Library
- Exception either version 3.1 or (at your option) any later version.
- This program  is  distributed  in  the  hope  that it will be useful,  but
- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or  FITNESS  FOR  A PARTICULAR PURPOSE.  See the GNU Lesser General Public
- License and GCC Runtime Library Exception for more details.
- You  should  have received a copy of the GNU Lesser General Public License
- along  with  this program;  if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
- 
-===========================================================================*/
-
-// à compiler avec la ligne de commande pour lapack/blas
-// g++ -I ../../src -O3 ../../tests/test_superlu.C -o test_superlu superlu.a 
-I ~/source++/ -DGMM_USES_SUPERLU
-
-
-// options d'optimisations avec g++ :
-//  -funroll-all-loops -ffast-math -fstrict-aliasing -fomit-frame-pointer
-
-#include "getfem/getfem_superlu.h"
-#include "gmm/gmm_inoutput.h"
-using gmm::size_type;
-
-template <class T> void test_with(T) {
-  size_type n = 50;
-
-  gmm::row_matrix<gmm::wsvector<T> > A(n, n), B(n, n), C(n, n);
-  std::vector<T> x(n), y(n), z(n);
-  
-  gmm::copy(gmm::identity_matrix(), A);
-  gmm::fill_random(A, 0.1);
-  gmm::fill_random(B);
-  gmm::fill_random(x);
-  gmm::fill_random(y);
-
-  A(0,1) = 0;
-  A(1,2) = 0;
-  A(2,4) = 0;
-  A(3,0) = 0;
-  A(4,1) = 0;
-  double rcond;
-
-  for (size_type cnt=0; cnt < 5; ++cnt) {
-    try {
-      gmm::SuperLU_solve(A, x, y, rcond);
-      cout << "rcond = " << rcond << "\n";
-    }
-    catch (const dal::failure_error &e) {
-      cerr << "Solve Failed: catch " << e.what() << "\n";
-    }
-  }
-
-  // gmm::lu_solve(A, z, y);
-
-  cout << "y = " << y << endl;
-  cout << "x = " << x << endl;
-  // cout << "z = " << z << endl;
-  gmm::mult(A, x, y);
-  cout << "Ax = " << y << endl;
-  // gmm::mult(A, z, y);
-  // cout << "Az = " << y << endl;
-
-  gmm::HarwellBoeing_IO hb("../../../getfem_matlab/tests/K.hb");
-  hb.read(A);
-  x.resize(gmm::mat_nrows(A)); gmm::fill_random(x);
-  y.resize(gmm::mat_nrows(A)); gmm::fill_random(y);
-  for (size_type cnt=0; cnt < 7; ++cnt) {
-    try {
-      gmm::SuperLU_solve(A, x, y, rcond);
-      cout << "rcond = " << rcond << "\n";
-    }
-    catch (const dal::failure_error &e) {
-      cerr << "Solve Failed: catch " << e.what() << "\n";
-    }
-  }
-}
-
-int main(void)
-{
-  //dal::exception_callback_debug cb;
-  //dal::exception_callback::set_exception_callback(&cb);
-
-  srand(1459);
-
-# if defined(GMM_USES_SUPERLU)
-  cout << "Trying using SuperLU\n";
-# else
-  cout << "Not using SuperLU\n";
-# endif
-
-  try {
-
-    cout << "sizeof(int) = " << sizeof(int)
-        << " sizeof(long) = " << sizeof(long) << endl;
-    
-    // test_with(float());
-    test_with(double());
-    // test_with(std::complex<float>());
-    test_with(std::complex<double>());
-    
-  }
-  GMM_STANDARD_CATCH_ERROR;
-
-  return 0;
-}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]