[Getfem-commits] (no subject)
branch: master commit 18e801fef4a0420d4e1b5903c17a90bc687c8f76 Author: Konstantinos Poulios AuthorDate: Fri Apr 12 16:13:46 2024 +0200 Require relaxing overstrict security checks with MSVC --- src/gmm/gmm_std.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gmm/gmm_std.h b/src/gmm/gmm_std.h index 3a2e4b13..c0ade0fc 100644 --- a/src/gmm/gmm_std.h +++ b/src/gmm/gmm_std.h @@ -60,6 +60,9 @@ # define SECURE_SPRINTF2(S, l, st, p1, p2) sprintf_s(S, l, st, p1, p2) # define SECURE_SPRINTF4(S, l, st, p1, p2, p3, p4) sprintf_s(S, l, st, p1, p2, p3, p4) # define SECURE_STRDUP(s) _strdup(s) +# ifndef _CRT_SECURE_NO_DEPRECATE +# error Add _CRT_SECURE_NO_DEPRECATE to your compilation options, Microsoft is overstrict (e.g. bans fopen) without offering portable alternatives +# endif #else # define SECURE_NONCHAR_SSCANF sscanf # define SECURE_NONCHAR_FSCANF fscanf
[Getfem-commits] (no subject)
branch: master commit ae3680eac2c860e17921f5ef09de7995fba77340 Author: Konstantinos Poulios AuthorDate: Fri Apr 12 16:15:02 2024 +0200 Fix configure issue with clang --- m4/ax_check_cxx_flag.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/m4/ax_check_cxx_flag.m4 b/m4/ax_check_cxx_flag.m4 index 6513885a..aebdf5fd 100644 --- a/m4/ax_check_cxx_flag.m4 +++ b/m4/ax_check_cxx_flag.m4 @@ -16,8 +16,8 @@ dnl Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. AC_DEFUN([AC_CHECK_CXX_FLAG], [AC_MSG_CHECKING([whether ${CXX} accepts $1]) -echo 'int main(){}' > conftest.c -if test -z "`${CXX} $1 -o conftest conftest.c 2>&1`"; then +echo 'int main(){}' > conftest.cc +if test -z "`${CXX} $1 -o conftest conftest.cc 2>&1`"; then $2="${$2} $1" echo "yes" else
[Getfem-commits] (no subject)
branch: master commit e5b68e126f672926cfd6171c7d886964f831324e Author: Konstantinos Poulios AuthorDate: Fri Apr 12 16:14:33 2024 +0200 Fix minor compilation issues --- src/getfem/bgeot_tensor.h | 2 -- src/getfem_fem.cc | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/getfem/bgeot_tensor.h b/src/getfem/bgeot_tensor.h index b5e28210..46e3d01a 100644 --- a/src/getfem/bgeot_tensor.h +++ b/src/getfem/bgeot_tensor.h @@ -130,9 +130,7 @@ namespace bgeot { template inline const T& operator ()(const CONT ) const { typename CONT::const_iterator it = c.begin(); multi_index::const_iterator q = coeff_.begin(), e = coeff_.end(); -#ifndef NDEBUG multi_index::const_iterator qv = sizes_.begin(); -#endif size_type d = 0; for ( ; q != e; ++q, ++it) { d += (*q) * (*it); diff --git a/src/getfem_fem.cc b/src/getfem_fem.cc index 2cc58661..8456df84 100644 --- a/src/getfem_fem.cc +++ b/src/getfem_fem.cc @@ -4426,8 +4426,8 @@ namespace getfem { THREAD_SAFE_STATIC bgeot::pgeometric_trans pgt_last = nullptr; THREAD_SAFE_STATIC short_type k_last = short_type(-1); THREAD_SAFE_STATIC pfem fem_last = nullptr; -THREAD_SAFE_STATIC char complete_last = 0; -THREAD_SAFE_STATIC char discont_last = 0; +THREAD_SAFE_STATIC bool complete_last = 0; +THREAD_SAFE_STATIC bool discont_last = 0; THREAD_SAFE_STATIC scalar_type alpha_last = 0; bool found = false;
[Getfem-commits] (no subject)
branch: master commit 9e3d4ec635fdadf84c744c66f622a5e7ad0b6040 Author: Konstantinos Poulios AuthorDate: Fri Apr 12 16:12:27 2024 +0200 Variables renaming and typo fixes --- src/getfem_generic_assembly_compile_and_exec.cc | 22 +++--- src/getfem_generic_assembly_tree.cc | 2 +- src/gmm/gmm_arch_config.h.in| 2 +- tests/test_interpolation.cc | 6 ++ 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/getfem_generic_assembly_compile_and_exec.cc b/src/getfem_generic_assembly_compile_and_exec.cc index 7ae88cb6..15857c0e 100644 --- a/src/getfem_generic_assembly_compile_and_exec.cc +++ b/src/getfem_generic_assembly_compile_and_exec.cc @@ -1873,20 +1873,20 @@ namespace getfem { struct ga_instruction_transpose : public ga_instruction { // To be optimized base_tensor const base_tensor -size_type n1, n2, nn; +size_type J, K, I; virtual int exec() { GA_DEBUG_INFO("Instruction: transpose"); GA_DEBUG_ASSERT(t.size() == tc1.size(), "Wrong sizes"); - size_type n0 = tc1.size() / (n1*n2*nn); + size_type L = tc1.size() / (J*K*I); auto it = t.begin(); - for (size_type i = 0; i < nn; ++i) { -size_type s1 = i*n1*n2*n0; -for (size_type j = 0; j < n1; ++j) { - size_type s2 = s1 + j*n0; - for (size_type k = 0; k < n2; ++k) { -size_type s3 = s2 + k*n1*n0; -for (size_type l = 0; l < n0; ++l, ++it) + for (size_type i = 0; i < I; ++i) { +size_type s1 = i*J*K*L; +for (size_type j = 0; j < J; ++j) { + size_type s2 = s1 + j*L; + for (size_type k = 0; k < K; ++k) { +size_type s3 = s2 + k*J*L; +for (size_type l = 0; l < L; ++l, ++it) *it = tc1[s3+l]; } } @@ -1895,8 +1895,8 @@ namespace getfem { return 0; } ga_instruction_transpose(base_tensor _, const base_tensor _, - size_type n1_, size_type n2_, size_type nn_) - : t(t_), tc1(tc1_), n1(n1_), n2(n2_), nn(nn_) {} + size_type J_, size_type K_, size_type I_) + : t(t_), tc1(tc1_), J(J_), K(K_), I(I_) {} }; struct ga_instruction_swap_indices : public ga_instruction {// To be optimized diff --git a/src/getfem_generic_assembly_tree.cc b/src/getfem_generic_assembly_tree.cc index 3dee62a8..0450930f 100644 --- a/src/getfem_generic_assembly_tree.cc +++ b/src/getfem_generic_assembly_tree.cc @@ -1713,7 +1713,7 @@ namespace getfem { if (t_type != GA_NAME) ga_throw_error(expr, pos, "First argument of Interpolate should the " - "interpolate transformtion name "); + "interpolate transformation name "); tree.current_node->interpolate_name_der = std::string(&((*expr)[token_pos]), token_length); t_type = ga_get_token(*expr, pos, token_pos, token_length); diff --git a/src/gmm/gmm_arch_config.h.in b/src/gmm/gmm_arch_config.h.in index 2dd8f0f0..3e656c3a 100644 --- a/src/gmm/gmm_arch_config.h.in +++ b/src/gmm/gmm_arch_config.h.in @@ -9,7 +9,7 @@ /* defined if GMM is linked to a lapack library */ #undef GMM_USES_LAPACK -/* defined if GMM is linked to a lapack library */ +/* defined if GMM is used when building the Matlab interface */ #undef GMM_MATLAB_INTERFACE /* defined if GMM uses MPI */ diff --git a/tests/test_interpolation.cc b/tests/test_interpolation.cc index 99ea0692..6199a2d4 100644 --- a/tests/test_interpolation.cc +++ b/tests/test_interpolation.cc @@ -242,8 +242,7 @@ void test_same_mesh(int mat_version, size_type N, size_type NX, size_type K, siz /* force evaluation of a number of things which are not part of interpolation */ size_type d = mf1.nb_dof(); d -= mf2.nb_dof(); double err = 0.; - for (int i=0; i<3; ++i) { /* pour amortir/cout de la construction du maillage, et de divers trucs - (�a a un gros impact) */ + for (int i=0; i<3; ++i) { /* To mitigate the cost of mesh generation etc. (has a significant impact). */ c.init().tic(); double err2 = interpolate_check(mf1, mf2, i, mat_version); if (i==0 || (mat_version > 0 && i == 1)) err = err2; @@ -269,8 +268,7 @@ void test_different_mesh(int mat_version, size_type dim, size_type N, size_type /* force evaluation of a number of things which are not part of interpolation */ size_type d = mf1.nb_dof(); d -= mf2.nb_dof(); double err = 0; - for (int i=0; i<3; ++i) { /* pour amortir/cout de la construction du maillage, et de divers trucs - (�a a un gros impact) */ + for (int i=0; i<3; ++i) { /* To mitigate the cost of mesh generation etc. (has a significant impact). */ c.init().tic(); double err2 = interpolate_check(mf1, mf2, i, mat_version); if (i==0 || (mat_version > 0
[Getfem-commits] (no subject)
branch: master commit 9216a7acc4c992e99beaf8eeccfce871348a2e55 Author: Konstantinos Poulios AuthorDate: Fri Apr 12 16:16:53 2024 +0200 Avoid nested preprocessor macros in gmm blas interface --- src/gmm/gmm_blas_interface.h | 44 +--- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/gmm/gmm_blas_interface.h b/src/gmm/gmm_blas_interface.h index 4c8deddf..1b83f1cd 100644 --- a/src/gmm/gmm_blas_interface.h +++ b/src/gmm/gmm_blas_interface.h @@ -385,41 +385,39 @@ namespace gmm { } -# define axpy_interface(param1, trans1, blas_name, base_type) \ - inline void add(param1(base_type), std::vector ) { \ +# define axpy_interface(blas_name, base_type) \ + inline void add(const std::vector , \ + std::vector ) { \ GMMLAPACK_TRACE("axpy_interface"); \ -BLAS_INT inc(1), n(BLAS_INT(vect_size(y))); trans1(base_type); \ +BLAS_INT inc(1), n(BLAS_INT(vect_size(y))); base_type a(1);\ if(n == 0) return; \ else if(n < 25) add_for_short_vectors(x, y, n);\ else blas_name(, , [0], , [0], ); \ } -# define axpy2_interface(param1, trans1, blas_name, base_type) \ - inline void add(param1(base_type), std::vector ) { \ + axpy_interface(saxpy_, BLAS_S) + axpy_interface(daxpy_, BLAS_D) + axpy_interface(caxpy_, BLAS_C) + axpy_interface(zaxpy_, BLAS_Z) + + +# define axpy2_interface(blas_name, base_type) \ + inline void add \ + (const scaled_vector_const_ref,base_type> _,\ + std::vector ) {\ GMMLAPACK_TRACE("axpy_interface"); \ -BLAS_INT inc(1), n(BLAS_INT(vect_size(y))); trans1(base_type); \ +BLAS_INT inc(1), n(BLAS_INT(vect_size(y)));\ +const std::vector& x = *(linalg_origin(x_));\ +base_type a(x_.r); \ if(n == 0) return; \ else if(n < 25) add_for_short_vectors(x, y, a, n); \ else blas_name(, , [0], , [0], ); \ } -# define axpy_p1(base_type) const std::vector -# define axpy_trans1(base_type) base_type a(1) -# define axpy_p1_s(base_type) \ -const scaled_vector_const_ref,base_type> _ -# define axpy_trans1_s(base_type) \ - const std::vector = *(linalg_origin(x_)); \ - base_type a(x_.r) - - axpy_interface(axpy_p1, axpy_trans1, saxpy_, BLAS_S) - axpy_interface(axpy_p1, axpy_trans1, daxpy_, BLAS_D) - axpy_interface(axpy_p1, axpy_trans1, caxpy_, BLAS_C) - axpy_interface(axpy_p1, axpy_trans1, zaxpy_, BLAS_Z) - - axpy2_interface(axpy_p1_s, axpy_trans1_s, saxpy_, BLAS_S) - axpy2_interface(axpy_p1_s, axpy_trans1_s, daxpy_, BLAS_D) - axpy2_interface(axpy_p1_s, axpy_trans1_s, caxpy_, BLAS_C) - axpy2_interface(axpy_p1_s, axpy_trans1_s, zaxpy_, BLAS_Z) + axpy2_interface(saxpy_, BLAS_S) + axpy2_interface(daxpy_, BLAS_D) + axpy2_interface(caxpy_, BLAS_C) + axpy2_interface(zaxpy_, BLAS_Z) /* * */
[Getfem-commits] (no subject)
branch: master commit 30067565d5dd21989381d4cbd84dd3155b3e0c31 Author: Konstantinos Poulios AuthorDate: Fri Apr 12 16:16:02 2024 +0200 Treat clang separately in autoconf system and other minor build system changes --- CMakeLists.txt | 2 +- configure.ac | 36 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f8694be..b6dd7b7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation prefix") # General tests and configurations -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 14 CACHE STRING "Set C++ standard version (default: 14)) set(CMAKE_CXX_STANDARD_REQUIRED ON) check_include_file_cxx("cxxabi.h" GETFEM_HAVE_CXXABI_H) check_cxx_source_compiles( diff --git a/configure.ac b/configure.ac index 339025ba..8d03612d 100644 --- a/configure.ac +++ b/configure.ac @@ -27,7 +27,7 @@ dnl thus, updating cache ./config.cache avoided. define([AC_CACHE_LOAD], )dnl define([AC_CACHE_SAVE], )dnl -AC_INIT(getfem, 5.4.2) +AC_INIT([getfem],[5.4.2]) MAJOR_VERSION="5" MINOR_VERSION="4" PATCH_VERSION="2" @@ -40,7 +40,7 @@ AC_DEFINE_UNQUOTED(GMM_VERSION,"${PACKAGE_VERSION}",[GMM version]) AC_CONFIG_SRCDIR([install-sh]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([config_autogenerated_not_used.h src/getfem/getfem_arch_config.h src/gmm/gmm_arch_config.h]) -AC_PREREQ(2.61) +AC_PREREQ([2.71]) AC_ARG_PROGRAM dnl @@ -114,15 +114,12 @@ dnl AC_CXX_FULL_SPECIALIZATION_SYNTAX (c)Luc Maisonobe v 1.1.1.1 (2001/07/26) dnl with some modification to test partial specialization AC_CACHE_CHECK(whether the compiler recognizes the partial specialization syntax, ac_cv_cxx_partial_specialization_syntax, -[AC_DIAGNOSE([obsolete],[Instead of using `AC_LANG', `AC_LANG_SAVE', and `AC_LANG_RESTORE', -you should use `AC_LANG_PUSH' and `AC_LANG_POP'.])dnl -AC_LANG_SAVE - AC_LANG([C++]) +[AC_LANG_PUSH([C++]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ template class A{ public : int f () const { return 1; } }; template class A{ public : int f () const { return 0; } };]], [[ A a; return a.f();]])],[ac_cv_cxx_partial_specialization_syntax=yes],[ac_cv_cxx_partial_specialization_syntax=no]) - AC_LANG_POP([]) + AC_LANG_POP([C++]) ]) if test "$ac_cv_cxx_partial_specialization_syntax" != yes; then echo "Your compiler ($CXX) does not support partial template specialization, trash it" @@ -135,6 +132,29 @@ echo "you are compiling GetFEM on a $host" case $CXX in + clang++) + GLANGVER=`$CXX --version | head -n 1 | grep -o -E "[[:digit:]]+.[[:digit:]]+.[[:digit:]]+"` + echo "Using the clang++ compiler $GLANGVER" + AC_CHECK_CXX_FLAG([$with_optimization],CXXFLAGS) + AC_CHECK_CXX_FLAG([-fmessage-length=0],CXXFLAGS) + AC_CHECK_CXX_FLAG([-fvisibility-inlines-hidden],CXXFLAGS) + AC_CHECK_CXX_FLAG([-ftemplate-depth-100],CXXFLAGS) + AC_CHECK_CXX_FLAG([-std=c++14], CXXFLAGS, [AC_MSG_ERROR([Used clang++ version does not support option -std=c++14.])]) + AC_CHECK_CXX_FLAG([-fPIC],CXXFLAGS) + AC_CHECK_CXX_FLAG([-Wall -W -Wextra],CXXFLAGS) + AC_CHECK_CXX_FLAG([-Wshadow],CXXFLAGS) + AC_CHECK_CXX_FLAG([-Wno-unknown-pragmas],CXXFLAGS) + AC_CHECK_CXX_FLAG([-Wno-variadic-macros],CXXFLAGS) + AC_CHECK_CXX_FLAG([-Wno-unused-but-set-variable],CXXFLAGS) + AC_CHECK_CXX_FLAG([-Wpointer-arith],CXXFLAGS) + AC_CHECK_CXX_FLAG([-Wcast-qual],CXXFLAGS) + AC_CHECK_CXX_FLAG([-Wwrite-strings],CXXFLAGS) + AC_CHECK_CXX_FLAG([-Wconversion],CXXFLAGS) + AC_CHECK_CXX_FLAG([-Wredundant-decls],CXXFLAGS) + AC_CHECK_CXX_FLAG([-Wno-long-long],CXXFLAGS) + AC_CHECK_CXX_FLAG([-rdynamic],SUPLDFLAGS) +CFLAGS="$CFLAGS $with_optimization -fPIC" + ;; *g++* | c++) GCCVER=`$CXX --version | head -1 | cut -d ' ' -f3` echo "Using the GNU g++ compiler $GCCVER" @@ -142,7 +162,7 @@ case $CXX in AC_CHECK_CXX_FLAG([-fmessage-length=0],CXXFLAGS) AC_CHECK_CXX_FLAG([-fvisibility-inlines-hidden],CXXFLAGS) AC_CHECK_CXX_FLAG([-ftemplate-depth-100],CXXFLAGS) - AC_CHECK_CXX_FLAG([-std=c++14], CXXFLAGS,[AC_CHECK_CXX_FLAG([-std=c++0x],CXXFLAGS,[AC_MSG_ERROR([g++ do not support option -std=c++14. Update g++ to at least release 4.9])] )]) + AC_CHECK_CXX_FLAG([-std=c++14], CXXFLAGS,[AC_CHECK_CXX_FLAG([-std=c++0x],CXXFLAGS,[AC_MSG_ERROR([Used g++ does not support option -std=c++14. Update g++ to at least release 4.9])] )]) AC_CHECK_CXX_FLAG([-fPIC],CXXFLAGS) AC_CHECK_CXX_FLAG([-Wall -W -Wextra],CXXFLAGS) dnl AC_CHECK_CXX_FLAG([-pedantic],CXXFLAGS)
[Getfem-commits] (no subject)
branch: master commit 5ddd2b51f5bf0dc7086eadc2ae24230acfc11e8e Author: Konstantinos Poulios AuthorDate: Fri Mar 8 00:16:50 2024 +0100 Improve compatibility with MSVC compiler --- interface/src/python/getfem_python.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/interface/src/python/getfem_python.c b/interface/src/python/getfem_python.c index 0f5c6f5d..2a42e844 100644 --- a/interface/src/python/getfem_python.c +++ b/interface/src/python/getfem_python.c @@ -739,7 +739,11 @@ call_getfem_(PyObject *self, PyObject *args, int in__init__) result = Py_None; Py_INCREF(Py_None); } else if (out) { int i, err = 0; +#if defined(_MSC_VER) +PyObject **d = (PyObject **)malloc(out_cnt*sizeof(PyObject*)); +#else PyObject *d[out_cnt]; +#endif for (i = 0; i < out_cnt; ++i) { if (!err && !(d[i] = gfi_array_to_PyObject(out[i], in__init__))) err = 1; @@ -753,6 +757,9 @@ call_getfem_(PyObject *self, PyObject *args, int in__init__) for (i = 0; i < out_cnt; ++i) PyTuple_SET_ITEM(result,i,d[i]); } else result = d[0]; } +#if defined(_MSC_VER) +free(d); +#endif } } }
[Getfem-commits] (no subject)
branch: master commit 8921634bf2c210f28eadebe0a7a202fd2be573c3 Author: Konstantinos Poulios AuthorDate: Mon Mar 11 09:01:59 2024 +0100 Improve portability of auxiliary python script --- bin/extract_doc | 34 +- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/bin/extract_doc b/bin/extract_doc index d444e652..fc41752a 100755 --- a/bin/extract_doc +++ b/bin/extract_doc @@ -30,6 +30,7 @@ import string import os import textwrap import sys +import glob class ParseError(Exception): def __init__(self, value): @@ -483,14 +484,9 @@ option = sys.argv[2] # List the filenames and extract object and command names. # -fl = os.popen('(cd ' + directory + '; ls gf_*.cc)'); -lines = fl.readlines(); -a = fl.close() -if (a) : # Windows -fl = os.popen('((cd ' + directory + ') & (ls gf_*.cc))'); -lines = fl.readlines(); -a = fl.close() - +directory=os.path.abspath(directory) +os.chdir(directory) +lines = glob.glob('gf_*.cc') objects = set() objects.add('eltm'); @@ -519,19 +515,12 @@ commands = sorted(commands, key=cmp_to_key(cmpobj)) if (option == 'pseudo_loc'): -fl = os.popen('cd ' + directory + ' && ls gf_*.cc') - -for l in fl: -l = l.strip() +for l in glob.glob('gf_*.cc'): sys.stdout.write(l+' ') elif (option == 'pseudo_gen'): -directory_abs=os.path.abspath(directory) -fl = os.popen('ls ' + directory_abs+'/gf_*.cc') - -for l in fl: -l = l.strip() +for l in glob.glob(directory+'/gf_*.cc'): sys.stdout.write(l+' ') elif (option == 'mobj_dirs'): @@ -541,19 +530,14 @@ elif (option == 'mobj_dirs'): sys.stdout.write('@gf'+oname+' ') elif (option == 'cubature'): -directory_abs=os.path.abspath(directory+'/../../cubature') -fl = os.popen('ls ' + directory_abs+'/*.IM') -for l in fl: -l = l.strip() +for l in glob.glob(os.path.abspath(directory+'/../../cubature/*.IM')): sys.stdout.write(l+' ') elif (option == 'cubature_loc'): -directory_abs=os.path.abspath(directory+'/../../cubature') -fl = os.popen('cd ' + directory_abs + ' && ls *.IM') -for l in fl: -l = l.strip() +os.chdir(os.path.abspath(directory+'/../../cubature')) +for l in glob.glob('*.IM'): sys.stdout.write(l+' ')
[Getfem-commits] (no subject)
branch: master commit 25aa8df02ca1cc95c967e33b137eecba41582a7e Author: Konstantinos Poulios AuthorDate: Fri Mar 8 00:13:15 2024 +0100 Whitespace --- src/getfem_mesh_slicers.cc | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/getfem_mesh_slicers.cc b/src/getfem_mesh_slicers.cc index cdc6a409..e636dc4b 100644 --- a/src/getfem_mesh_slicers.cc +++ b/src/getfem_mesh_slicers.cc @@ -657,12 +657,12 @@ namespace getfem { } void mesh_slicer::exec(const std::vector , -const mesh_region& cvlst) { + const mesh_region& cvlst) { exec_([0], 1, cvlst); } static bool check_orient(size_type cv, bgeot::pgeometric_trans pgt, - const mesh& m) { + const mesh& m) { if (pgt->dim() == m.dim() && m.dim()>=2) { /* no orient check for convexes of lower dim */ base_matrix G; bgeot::vectors_to_base_matrix(G,m.points_of_convex(cv)); @@ -681,7 +681,7 @@ namespace getfem { #if OLD_MESH_SLICER void mesh_slicer::exec_(const short_type *pnrefine, int nref_stride, - const mesh_region& cvlst) { + const mesh_region& cvlst) { std::vector cvm_pts; const bgeot::basic_mesh *cvm = 0; const bgeot::mesh_structure *cvms = 0; @@ -835,7 +835,7 @@ namespace getfem { /* update structure-dependent data */ /* TODO : fix levelset handling when slicing faces .. */ if (prev_cvr != cvr || nrefine != prev_nrefine - || discont || prev_discont) { + || discont || prev_discont) { if (discont) { cvm = _simplex_mesh_for_convex_cut_by_level_set (mls->mesh_of_convex(cv), unsigned(nrefine)); @@ -851,7 +851,7 @@ namespace getfem { if (face < dim_type(-1)) { if (!discont) { cvms = bgeot::refined_simplex_mesh_for_convex_faces - (cvr, short_type(nrefine))[face].get(); +(cvr, short_type(nrefine))[face].get(); } else { cvms = _simplex_mesh_for_convex_faces_cut_by_level_set(face); }
[Getfem-commits] (no subject)
branch: master commit e3372b14e48bb32d6271f6c4658799a922968712 Author: Konstantinos Poulios AuthorDate: Fri Mar 8 00:14:06 2024 +0100 Move function implementations from header to source file --- src/getfem/getfem_mesh_slicers.h | 81 +++ src/getfem_mesh_slicers.cc | 102 ++- 2 files changed, 109 insertions(+), 74 deletions(-) diff --git a/src/getfem/getfem_mesh_slicers.h b/src/getfem/getfem_mesh_slicers.h index e69e7078..d8f613e3 100644 --- a/src/getfem/getfem_mesh_slicers.h +++ b/src/getfem/getfem_mesh_slicers.h @@ -324,14 +324,7 @@ namespace getfem { slicer_volume(int orient_) : orient(orient_) {} /** Utility function */ -static scalar_type trinom(scalar_type a, scalar_type b, scalar_type c) { - scalar_type delta = b*b - 4*a*c; - if (delta < 0.) return 1./EPS; - delta = sqrt(delta); - scalar_type s1 = (-b - delta) / (2*a); - scalar_type s2 = (-b + delta) / (2*a); - if (gmm::abs(s1-.5) < gmm::abs(s2-.5)) return s1; else return s2; -} +static scalar_type trinom(scalar_type a, scalar_type b, scalar_type c); void split_simplex(mesh_slicer , slice_simplex s, /* s is NOT a reference, it is on * purpose(push_back in the function)*/ @@ -346,22 +339,9 @@ namespace getfem { */ class slicer_half_space : public slicer_volume { const base_node x0, n; /* normal directed from inside toward outside */ -void test_point(const base_node& P, bool& in, bool& bound) const { - scalar_type s = gmm::vect_sp(P-x0,n); - in = (s <= 0); bound = (s*s <= EPS); // gmm::vect_norm2_sqr(P-x0)); No! - // do not try to be smart with the boundary check .. easily broken with - // slicer_mesh_with_mesh -} +void test_point(const base_node& P, bool& in, bool& bound) const; scalar_type edge_intersect(size_type iA, size_type iB, - const mesh_slicer::cs_nodes_ct& nodes) const { - const base_node& A=nodes[iA].pt; - const base_node& B=nodes[iB].pt; - scalar_type s1 = 0., s2 = 0.; - for (unsigned i=0; i < A.size(); ++i) -{ s1 += (A[i] - B[i])*n[i]; s2 += (A[i]-x0[i])*n[i]; } - if (gmm::abs(s1) < EPS) return 1./EPS; - else return s2/s1; -} + const mesh_slicer::cs_nodes_ct& nodes) const; public: slicer_half_space(base_node x0_, base_node n_, int orient_) : slicer_volume(orient_), x0(x0_), n(n_/gmm::vect_norm2(n_)) { @@ -375,22 +355,9 @@ namespace getfem { class slicer_sphere : public slicer_volume { base_node x0; scalar_type R; -void test_point(const base_node& P, bool& in, bool& bound) const { - scalar_type R2 = gmm::vect_dist2_sqr(P,x0); - bound = (R2 >= (1-EPS)*R*R && R2 <= (1+EPS)*R*R); - in = R2 <= R*R; -} +void test_point(const base_node& P, bool& in, bool& bound) const; scalar_type edge_intersect(size_type iA, size_type iB, - const mesh_slicer::cs_nodes_ct& nodes) const { - const base_node& A=nodes[iA].pt; - const base_node& B=nodes[iB].pt; - scalar_type a,b,c; // a*x^2 + b*x + c = 0 - a = gmm::vect_norm2_sqr(B-A); - if (a < EPS) return pt_bin.is_in(iA) ? 0. : 1./EPS; - b = 2*gmm::vect_sp(A-x0,B-A); - c = gmm::vect_norm2_sqr(A-x0)-R*R; - return slicer_volume::trinom(a,b,c); -} + const mesh_slicer::cs_nodes_ct& nodes) const; public: /* orient = -1 => select interior, orient = 0 => select boundary @@ -406,35 +373,9 @@ namespace getfem { class slicer_cylinder : public slicer_volume { base_node x0, d; scalar_type R; -void test_point(const base_node& P, bool& in, bool& bound) const { - base_node N = P; - if (2 == N.size()) { /* Add Z coorinate if mesh is 2D */ -N.push_back(0.0); - } - N = N-x0; - scalar_type axpos = gmm::vect_sp(d, N); - scalar_type dist2 = gmm::vect_norm2_sqr(N) - gmm::sqr(axpos); - bound = gmm::abs(dist2-R*R) < EPS; - in = dist2 < R*R; -} +void test_point(const base_node& P, bool& in, bool& bound) const; scalar_type edge_intersect(size_type iA, size_type iB, - const mesh_slicer::cs_nodes_ct& nodes) const { - base_node F=nodes[iA].pt; - base_node D=nodes[iB].pt-nodes[iA].pt; - if (2 == F.size()) { -F.push_back(0.0); -D.push_back(0.0); - } - F = F - x0; - scalar_type Fd = gmm::vect_sp(F,d); - scalar_type Dd = gmm::vect_sp(D,d); - scalar_type a = gmm::vect_norm2_sqr(D) - gmm::sqr(Dd); - if (a < EPS) return pt_bin.is_in(iA) ? 0. : 1./EPS; - assert(a> -EPS); - scalar_type b = 2*(gmm::vect_sp(F,D) - Fd*Dd); - scalar_type c = gmm::vect_norm2_sqr(F) - gmm::sqr(Fd) - gmm::sqr(R); - return slicer_volume::trinom(a,b,c); -} +
[Getfem-commits] (no subject)
branch: add-umfpack-interface commit 0534ebd1d8da9030871e8d8b7bc813e3c8520a07 Author: Konstantinos Poulios AuthorDate: Tue Jan 23 11:31:15 2024 +0100 Convert file to utf8 and add option for umfpack solver --- contrib/icare/icare.cc | 43 --- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/contrib/icare/icare.cc b/contrib/icare/icare.cc index 10846366..0cb77ae1 100644 --- a/contrib/icare/icare.cc +++ b/contrib/icare/icare.cc @@ -1,6 +1,6 @@ /*=== - Copyright (C) 2002-2020 Michel Fourni�, Julien Pommier, + Copyright (C) 2002-2020 Michel Fournié, Julien Pommier, This file is a part of GetFEM @@ -972,7 +972,7 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() { } - //Prise en compte de fa�on faible + //Prise en compte de façon faible plain_vector HP(nbdof_p); { plain_vector A(nbdof_p); getfem::generic_assembly assem; @@ -987,14 +987,14 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() { //K2(nbdof_p,nbdof_p) = 0.0; */ - //Prise en compte de fa�on forte + //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; -#if !defined(GMM_USES_MUMPS) +#if !defined(GMM_USES_MUMPS) && defined(GMM_USES_SUPERLU) gmm::SuperLU_factor SLUsys2; SLUsys2.build_with(K2); #endif @@ -1029,7 +1029,7 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() { std::ofstream coeffTP("coeffTP.data"); std::ofstream ptPartData("ptPart.data"); - // Recherche d'un point de r�ference pour le calcul des coeff de train�e ... + // Recherche d'un point de réference pour le calcul des coeff de trainée ... scalar_type BoxXmin = PARAM.real_value("BOXXmin", "Particular Point xMin"); scalar_type BoxXmax = PARAM.real_value("BOXXmax", "Particular Point xMax"); @@ -1063,7 +1063,7 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() { 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="< en sortie i <-> pt sur la derni�re composante de la vitesse +// Attention c'est vectoriel => en sortie i <-> pt sur la dernière composante de la vitesse // Vitesse =(U,V,W) alors en 2D --> sur V, en 3D --> sur W // D'ou la modif dans ptPartU[2] ptPartU[0] = BN[0]; @@ -1092,7 +1092,7 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() { 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="< en sortie i <-> pt sur la derni�re composante de la vitesse +// Attention c'est vectoriel => en sortie i <-> pt sur la dernière composante de la vitesse // Vitesse =(U,V,W) alors en 2D --> sur V, en 3D --> sur W // D'ou la modif dans ptPartU[3] ptPartU[0] = BN[0]; @@ -1134,14 +1134,13 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() { 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))); -#if !defined(GMM_USES_MUMPS) +#if !defined(GMM_USES_MUMPS) && defined(GMM_USES_SUPERLU) gmm::SuperLU_factor SLUsys3; #endif for (scalar_type t = Tinitial + dt; t <= T; t += dt) { @@ -1178,7 +1177,7 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() { //gmm::add(gmm::scaled(A2u,-1.0),A2v); //cout <<"A2 "<< gmm::mat_norminf(A2v) << endl; -#if !defined(GMM_USES_MUMPS) +#if !defined(GMM_USES_MUMPS) && defined(GMM_USES_SUPERLU) SLUsys3.build_with(A2u); #endif } @@ -1203,7 +1202,7 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() { gmm::copy(gmm::transposed(HNR), gmm::sub_matrix(A2, I1, I4)); // Factorization LU - //SLUsys3.build_with(A2); // pb en (u,v) coupl� + //SLUsys3.build_with(A2); // pb en (u,v) couple gmm::clear(A2u); //gmm::clear(A2v); @@ -1211,7 +1210,7 @@ void navier_stokes_problem::solve_PREDICTION_CORRECTION2() { 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); -#if !defined(GMM_USES_MUMPS) +#if !defined(GMM_USES_MUMPS) && defined(GMM_USES_SUPERLU) SLUsys3.build_with(A2u); #endif } @@ -1334,7 +1333,7 @@ void
[Getfem-commits] (no subject)
branch: add-umfpack-interface commit a3afc92c2b6a10b138da320b28e06baa75746e94 Author: Konstantinos Poulios AuthorDate: Tue Jan 23 11:30:21 2024 +0100 Add experimental UMFPACK support - compiles but does not work properly yet --- CMakeLists.txt| 1 + cmake/gmm_arch_config.h.in| 3 + configure.ac | 107 ++- src/Makefile.am | 1 + src/getfem/getfem_model_solvers.h | 21 src/gmm/gmm_UMFPACK_interface.h | 188 ++ src/gmm/gmm_arch_config.h.in | 3 + src/gmm/gmm_solver_Schwarz_additive.h | 8 +- tests/test_condensation.cc| 4 +- 9 files changed, 329 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ff2cdd8..be062820 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -322,6 +322,7 @@ set(HEADERS src/gmm/gmm_superlu_interface.h src/gmm/gmm_transposed.h src/gmm/gmm_tri_solve.h +src/gmm/gmm_UMFPACK_interface.h src/gmm/gmm_vector.h src/gmm/gmm_vector_to_matrix.h src/getfem/bgeot_comma_init.h diff --git a/cmake/gmm_arch_config.h.in b/cmake/gmm_arch_config.h.in index 50f47daa..4b4b029a 100644 --- a/cmake/gmm_arch_config.h.in +++ b/cmake/gmm_arch_config.h.in @@ -19,6 +19,9 @@ /* defined if GMM is linked to the superlu library */ #cmakedefine GMM_USES_SUPERLU +/* defined if GMM is linked to the umfpack library */ +#cmakedefine GMM_USES_UMFPACK + /* Use blas with 64 bits integers */ #cmakedefine GMM_USE_BLAS64_INTERFACE diff --git a/configure.ac b/configure.ac index cd519ed5..65e505ce 100644 --- a/configure.ac +++ b/configure.ac @@ -958,9 +958,98 @@ fi dnl ---END OF MUMPS TEST-- +dnl --UMFPACK TEST +require_umfpack="auto" +AC_ARG_ENABLE(umfpack, + [AS_HELP_STRING([--enable-umfpack], [Enable UMFPACK support])], + [require_umfpack=$enableval], + [require_umfpack="auto"]) + +UMFPACK_LIBS="-lumfpack" +# the user can override these defaults using --with-umfpack= +AC_ARG_WITH(umfpack, + [AS_HELP_STRING([--with-umfpack=],[use UMFPACK library ])], + [case $with_umfpack in + yes | "") + if test "x$require_umfpack" = "xno"; then + AC_MSG_ERROR([Contradicting arguments between --enable-umfpack and --with-umfpack.]) + elif test "x$require_umfpack" = "xauto"; then + require_umfpack="yes" + fi;; + no) + if test "x$require_umfpack" = "xyes"; then + AC_MSG_ERROR([Contradicting arguments between --enable-umfpack and --with-umfpack.]) + elif test "x$require_umfpack" = "xauto"; then + require_umfpack="no" + fi;; + -* | */* | *.a | *.so | *.so.* | *.o| builtin) UMFPACK_LIBS="$with_umfpack";; + *) UMFPACK_LIBS=`echo $with_umfpack | sed -e 's/^/-l/g;s/ \+/ -l/g'`;; + esac] +) + +UMFPACKINC="" +AC_ARG_WITH(umfpack-include-dir, + [AS_HELP_STRING([--with-umfpack-include-dir],[directory in which the umfpack.h headers can be found])], + [ if test x$require_umfpack = xno; then + AC_MSG_ERROR([Inconsistent options for --enable-umfpack, --with-umfpack and --with-umfpack-include-dir.]); + else + require_umfpack="yes" + case $withval in + -I* ) UMFPACKINC="$withval";; + * ) UMFPACKINC="-I$withval";; + esac + fi;], +) +CPPFLAGS="$CPPFLAGS $UMFPACKINC" -if test "x$found_superlu" = "xno" -a "x$found_mumps" = "xno"; then - AC_MSG_ERROR([Neither MUMPS nor SuperLU was enabled. At least one linear solver is required.]) +if test "x$require_umfpack" = "xno"; then + UMFPACK_LIBS="" + found_umfpack="no" + echo "Building with UMFPACK explicitly disabled"; +else + AC_CHECK_HEADERS( +[umfpack.h], +[found_umfpack="yes"], +[ if test "x$require_umfpack" = "xyes"; then +AC_MSG_ERROR([Header files of UMFPACK not found.]); + else +found_umfpack="no" + fi; +]) + if test x$found_umfpack = xyes; then +save_LIBS="$LIBS"; +AC_CHECK_LIB([umfpack], [umfpack_di_solve], + [AC_DEFINE(GMM_USES_UMFPACK,,[defined if GMM is linked to the umfpack library])], + [if test "x$require_umfpack" = "xyes"; then +AC_MSG_ERROR([UMFPACK library not found]); + else +found_umfpack="no" + fi;]) +if test "x$found_umfpack" = "xyes"; then + echo "Building with UMFPACK (use --enable-umfpack=no to disable it)" + LIBS="$UMFPACK_LIBS $save_LIBS" +else + UMFPACK_LIBS="" + LIBS="$save_LIBS" +fi + elif test "x$require_umfpack" = "xyes"; then +AC_MSG_ERROR([UMFPACK header files not found but required by the user. Aborting configure...]); + else +echo "UMFPACK header files not found, building without UMFPACK" +UMPFPACK_LIBS="" + fi +fi + +AM_CONDITIONAL(UMFPACK, test x$found_umfpack = xyes) +AC_SUBST([UMFPACK_LIBS]) +if test
[Getfem-commits] (no subject)
branch: add-umfpack-interface commit c33dc738a672c98c19dd3dc45bf80dc96bf3d583 Author: Konstantinos Poulios AuthorDate: Tue Jan 23 11:28:31 2024 +0100 Minor code maintenance changes --- src/gmm/gmm_matrix.h | 68 +- tests/wave_equation.cc | 48 +-- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/gmm/gmm_matrix.h b/src/gmm/gmm_matrix.h index 60b29178..db375938 100644 --- a/src/gmm/gmm_matrix.h +++ b/src/gmm/gmm_matrix.h @@ -140,7 +140,7 @@ namespace gmm typedef typename linalg_traits::value_type value_type; row_matrix(size_type r, size_type c) : li(r, V(c)), nc(c) {} -row_matrix(void) : nc(0) {} +row_matrix() : nc(0) {} reference operator ()(size_type l, size_type c) { return li[l][c]; } value_type operator ()(size_type l, size_type c) const @@ -149,13 +149,13 @@ namespace gmm void clear_mat(); void resize(size_type m, size_type n); -typename std::vector::iterator begin(void) +typename std::vector::iterator begin() { return li.begin(); } -typename std::vector::iterator end(void) +typename std::vector::iterator end() { return li.end(); } -typename std::vector::const_iterator begin(void) const +typename std::vector::const_iterator begin() const { return li.begin(); } -typename std::vector::const_iterator end(void) const +typename std::vector::const_iterator end() const { return li.end(); } @@ -164,8 +164,8 @@ namespace gmm V& operator[](size_type i) { return li[i]; } const V& operator[](size_type i) const { return li[i]; } -inline size_type nrows(void) const { return li.size(); } -inline size_type ncols(void) const { return nc;} +inline size_type nrows() const { return li.size(); } +inline size_type ncols() const { return nc;} void swap(row_matrix ) { std::swap(li, m.li); std::swap(nc, m.nc); } void swap_row(size_type i, size_type j) { std::swap(li[i], li[j]); } @@ -248,7 +248,7 @@ namespace gmm typedef typename linalg_traits::value_type value_type; col_matrix(size_type r, size_type c) : li(c, V(r)), nr(r) { } -col_matrix(void) : nr(0) {} +col_matrix() : nr(0) {} reference operator ()(size_type l, size_type c) { return li[c][l]; } value_type operator ()(size_type l, size_type c) const @@ -262,17 +262,17 @@ namespace gmm V& operator[](size_type i) { return li[i]; } const V& operator[](size_type i) const { return li[i]; } -typename std::vector::iterator begin(void) +typename std::vector::iterator begin() { return li.begin(); } -typename std::vector::iterator end(void) +typename std::vector::iterator end() { return li.end(); } -typename std::vector::const_iterator begin(void) const +typename std::vector::const_iterator begin() const { return li.begin(); } -typename std::vector::const_iterator end(void) const +typename std::vector::const_iterator end() const { return li.end(); } -inline size_type ncols(void) const { return li.size(); } -inline size_type nrows(void) const { return nr; } +inline size_type ncols() const { return li.size(); } +inline size_type nrows() const { return nr; } void swap(col_matrix ) { std::swap(li, m.li); std::swap(nr, m.nr); } void swap_col(size_type i, size_type j) { std::swap(li[i], li[j]); } @@ -365,22 +365,22 @@ namespace gmm return *(this->begin() + c*nbl+l); } -std::vector _vector(void) { return *this; } -const std::vector _vector(void) const { return *this; } +std::vector _vector() { return *this; } +const std::vector _vector() const { return *this; } void resize(size_type, size_type); void base_resize(size_type, size_type); void reshape(size_type, size_type); void fill(T a, T b = T(0)); -inline size_type nrows(void) const { return nbl; } -inline size_type ncols(void) const { return nbc; } +inline size_type nrows() const { return nbl; } +inline size_type ncols() const { return nbc; } void swap(dense_matrix ) { std::vector::swap(m); std::swap(nbc, m.nbc); std::swap(nbl, m.nbl); } dense_matrix(size_type l, size_type c) : std::vector(c*l), nbc(c), nbl(l) {} -dense_matrix(void) { nbl = nbc = 0; } +dense_matrix() { nbl = nbc = 0; } }; template void dense_matrix::reshape(size_type m,size_type n) { @@ -523,11 +523,11 @@ namespace gmm void init_with_identity(size_type n); -csc_matrix(void) : nc(0), nr(0) {} +csc_matrix() : nc(0), nr(0) {} csc_matrix(size_type nnr, size_type nnc); -size_type nrows(void) const { return nr; } -size_type ncols(void) const { return nc; } +size_type nrows() const { return nr; } +size_type ncols() const { return nc; } void swap(csc_matrix ) { std::swap(pr, m.pr); std::swap(ir, m.ir); std::swap(jc,
[Getfem-commits] (no subject)
branch: add-umfpack-interface commit 87cf885eae1bbf2ffcdb1804a66ea35ca7949c95 Author: Konstantinos Poulios AuthorDate: Tue Jan 23 11:24:47 2024 +0100 Fix error in configure script --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6f7d6c82..cd519ed5 100644 --- a/configure.ac +++ b/configure.ac @@ -1275,7 +1275,7 @@ fi; if test "x$found_mumps" = "xyes"; then echo "- Mumps found. A direct solver for large sparse linear systems." else - if test "x$require_superlu" = "xno"; then + if test "x$require_mumps" = "xno"; then echo "- Not using the MUMPS library for large sparse linear systems." else echo "- Mumps not found. Not using the MUMPS library for large sparse linear systems."
[Getfem-commits] (no subject)
branch: remove-local-superlu commit aa84a361909484226d0d1c59f382b8c88d8f4c34 Author: Konstantinos Poulios AuthorDate: Sat Nov 18 20:52:37 2023 +0100 Make SuperLU optional --- interface/src/getfemint_precond.h | 43 --- interface/src/gf_linsolve.cc | 5 - interface/src/gf_precond.cc | 4 src/Makefile.am | 7 +-- src/getfem/getfem_config.h| 7 +++ src/getfem/getfem_model_solvers.h | 18 src/getfem/getfem_superlu.h | 10 - tests/laplacian.cc| 4 +++- tests/schwarz_additive.cc | 28 +++-- 9 files changed, 86 insertions(+), 40 deletions(-) diff --git a/interface/src/getfemint_precond.h b/interface/src/getfemint_precond.h index 8af6c79b..7dee1aaa 100644 --- a/interface/src/getfemint_precond.h +++ b/interface/src/getfemint_precond.h @@ -52,7 +52,7 @@ 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" }; return p[type]; @@ -69,7 +69,9 @@ namespace getfemint { std::unique_ptr > ildltt; std::unique_ptr > ilu; std::unique_ptr > ilut; +#if defined(GETFEM_USES_SUPERLU) std::unique_ptr > superlu; +#endif virtual size_type memsize() const { size_type sz = sizeof(*this); @@ -81,10 +83,15 @@ namespace getfemint { case ILDLT: sz += ildlt->memsize(); break; case ILDLTT: sz += ildltt->memsize(); break; case SUPERLU: - sz += size_type(superlu->memsize()); break; +#if defined(GETFEM_USES_SUPERLU) +sz += size_type(superlu->memsize()); +#else +GMM_ASSERT1(false, "GetFEM built without SuperLU support"); +#endif +break; case SPMAT: sz += gsp->memsize(); break; } - return sz; + return sz; } }; @@ -120,28 +127,32 @@ namespace gmm { 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::LU_TRANSP); - break; +#if defined(GETFEM_USES_SUPERLU) +if (do_mult) precond.superlu->solve(w,v); +else precond.superlu->solve(w,v,gmm::SuperLU_factor::LU_TRANSP); +#else +GMM_ASSERT1(false, "GetFEM built without SuperLU support"); +#endif +break; case getfemint::gprecond_base::SPMAT: precond.gsp->mult_or_transposed_mult(v, w, !do_mult); break; diff --git a/interface/src/gf_linsolve.cc b/interface/src/gf_linsolve.cc index a04adbe5..1b8f42ff 100644 --- a/interface/src/gf_linsolve.cc +++ b/interface/src/gf_linsolve.cc @@ -85,6 +85,7 @@ void iterative_gmm_solver(iterative_gmm_solver_type stype, else iterative_gmm_solver(stype, gsp, in, out, scalar_type()); } +#if defined(GETFEM_USES_SUPERLU) template static void superlu_solver(gsparse , getfemint::mexargs_in& in, getfemint::mexargs_out& out, T) { @@ -96,6 +97,7 @@ superlu_solver(gsparse , if (out.remaining()) out.pop().from_scalar(rcond ? 1./rcond : 0.); } +#endif #if defined(GMM_USES_MUMPS) || defined(HAVE_DMUMPS_C_H) template static void @@ -178,6 +180,7 @@ void gf_linsolve(getfemint::mexargs_in& m_in, getfemint::mexargs_out& m_out) { ); +#if
[Getfem-commits] (no subject)
branch: remove-local-superlu commit 8ce9151ff5378061db7784aa031250455b47c60a Author: Konstantinos Poulios AuthorDate: Tue Dec 5 14:04:25 2023 +0100 Improve configuration without superlu --- configure.ac | 6 ++ 1 file changed, 6 insertions(+) diff --git a/configure.ac b/configure.ac index 16a854de..1ab7d38d 100644 --- a/configure.ac +++ b/configure.ac @@ -807,6 +807,7 @@ AC_ARG_WITH(superlu-include-dir, CPPFLAGS="$CPPFLAGS $SUPERLUINC" if test "x$require_superlu" = "xno"; then + SUPERLU_LIBS="" echo "Building with SuperLU explicitly disabled"; else AC_CHECK_HEADERS( @@ -834,6 +835,11 @@ else SUPERLU_LIBS="" LIBS="$save_LIBS" fi + elif test "x$require_superlu" = "xyes"; then +AC_MSG_ERROR([SuperLU header files not found but required by the user. Aborting configure...]); + else +echo "SuperLU header files not found, building without SuperLU" +SUPERLU_LIBS="" fi fi
[Getfem-commits] (no subject)
branch: master commit fb3a2e86e4b3d663fc1a25aaf52784a45d6dd209 Author: Matthias Bussonnier AuthorDate: Wed Dec 13 16:26:43 2023 +0100 Typo and UTF-8 It look like there is a typo in the conditional include, I guessing you want to include only if not defined, but there is not the same number of underscore in define. Also one of the files are in ISO-8859 (latin1) I guess, which make clang show warnings for `é` and a few other character, do not change content but change to utf8, it seems to fix the warning. This has the side effect of making the diff show the correct characters instead of mojibake. --- src/getfem/getfem_fourth_order.h | 2 +- src/getfem/getfem_im_list.h | 2 +- tests/plate.cc | 22 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/getfem/getfem_fourth_order.h b/src/getfem/getfem_fourth_order.h index 1c06e324..1d3d81a7 100644 --- a/src/getfem/getfem_fourth_order.h +++ b/src/getfem/getfem_fourth_order.h @@ -35,7 +35,7 @@ @date January 6, 2006. @brief assembly procedures and bricks for fourth order pdes. */ -#ifndef GETFEM_FOURTH_ORDER_H_ +#ifndef GETFEM_FOURTH_ORDER_H__ #define GETFEM_FOURTH_ORDER_H__ #include "getfem_models.h" diff --git a/src/getfem/getfem_im_list.h b/src/getfem/getfem_im_list.h index a86ee4f5..0b145355 100644 --- a/src/getfem/getfem_im_list.h +++ b/src/getfem/getfem_im_list.h @@ -2,7 +2,7 @@ /*=== - Copyright (C) 2002-2022 Yves Renard + Copyright (C) 2002-2023 Yves Renard This file is a part of GetFEM++ diff --git a/tests/plate.cc b/tests/plate.cc index 6273a3cd..455b59aa 100644 --- a/tests/plate.cc +++ b/tests/plate.cc @@ -1,6 +1,6 @@ /*=== - Copyright (C) 2002-2020 Yves Renard, Michel Sala�n. + Copyright (C) 2002-2020 Yves Renard, Michel Salaün. This file is a part of GetFEM @@ -65,8 +65,8 @@ struct plate_problem { getfem::mesh_fem mf_theta; getfem::mesh_fem mf_rhs; /* mesh_fem for the right hand side (f(x),..) */ getfem::mesh_fem mf_coef; /* mesh_fem used to represent pde coefficients */ - scalar_type lambda, mu;/* Lam� coefficients. */ - scalar_type E, nu;/* Lam� coefficients. */ + scalar_type lambda, mu;/* Lamé coefficients. */ + scalar_type E, nu;/* Lamé coefficients. */ scalar_type epsilon; /* thickness of the plate. */ scalar_type pressure; scalar_type residual; /* max residual for the iterative solvers */ @@ -75,7 +75,7 @@ struct plate_problem { int sol_ref; // sol_ref = 0 : simple support on the vertical edges // sol_ref = 1 : homogeneous on the vertical edges // sol_ref = 2 : homogeneous on the 4 vertical - // edges with solution u3 = sin�(x)*sin�(y) + // edges with solution u3 = sin²(x)*sin²(y) scalar_type eta; // useful only if sol_ref == 2 : // eta = 0 => Kirchhoff-Love // eta = small => Mindlin @@ -153,8 +153,8 @@ void plate_problem::init(void) { LX = PARAM.real_value("LX"); LY = PARAM.real_value("LY"); - mu = PARAM.real_value("MU", "Lam� coefficient mu"); - lambda = PARAM.real_value("LAMBDA", "Lam� coefficient lambda"); + mu = PARAM.real_value("MU", "Lamé coefficient mu"); + lambda = PARAM.real_value("LAMBDA", "Lamé coefficient lambda"); epsilon = PARAM.real_value("EPSILON", "thickness of the plate"); pressure = PARAM.real_value("PRESSURE", "pressure on the top surface of the plate."); @@ -171,7 +171,7 @@ void plate_problem::init(void) { cout << "bord en appuis simple\n" ; cout << "nombre de terme pour calcul sol exacte : " << N_Four << " \n" ; // Calcul des coeeficients de Fourier de la solution exacte : - // Cas o� le chargement est seulement vertical (pas de moment appliqu�) + // Cas où le chargement est seulement vertical (pas de moment appliqué) gmm::resize( theta1_Four, N_Four, N_Four) ; gmm::resize( theta2_Four, N_Four, N_Four) ; gmm::resize( u3_Four, N_Four, N_Four) ; @@ -196,7 +196,7 @@ void plate_problem::init(void) { Jmn(2, 2) = A * A + B * B ; gmm::scale(Jmn, - E*(epsilon/2.) / (1. + nu) ) ; - // calcul du d�veloppement de Fourrier du chargement : + // calcul du développement de Fourrier du chargement : if ( ( (i + 1) % 2 == 1 ) && ( (j + 1) % 2 == 1) ) { Pmn = 16. * pressure / ( scalar_type(i + 1) * scalar_type(j + 1) * M_PI * M_PI) ; } else { @@ -347,7 +347,7 @@ scalar_type
[Getfem-commits] (no subject)
branch: master commit b41cdfe53655685161a87e563d664da3a77a7c02 Author: Matthias Bussonnier AuthorDate: Wed Dec 13 14:53:25 2023 +0100 Unconditionally inclide -lstdc++. Compiling with clang does not do that by default on macos, leading to linking failure in `make check`. --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 2bfe16bf..4c30278e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -122,7 +122,7 @@ test_continuation_SOURCES = test_continuation.cc test_gmm_matrix_functions_SOURCES = test_gmm_matrix_functions.cc AM_CPPFLAGS = -I$(top_srcdir)/src -I../src -LDADD= ../src/libgetfem.la -lm @SUPLDFLAGS@ +LDADD= ../src/libgetfem.la -lm @SUPLDFLAGS@ -lstdc++ TESTS = \ dynamic_array.pl \
[Getfem-commits] (no subject)
branch: master commit 5582edc12a753ee7d80cadac5767462b07ce9d75 Author: Matthias Bussonnier AuthorDate: Wed Dec 13 14:51:22 2023 +0100 Explicitly opt-out of clang, got gcc specific instructions. Clangs sometime pretends to be GCC or to support GNU C extensions but does not. Thus skip GCC code when we are clang. --- src/gmm/gmm_except.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gmm/gmm_except.h b/src/gmm/gmm_except.h index 442de139..271d261f 100644 --- a/src/gmm/gmm_except.h +++ b/src/gmm/gmm_except.h @@ -394,7 +394,7 @@ inline void GMM_THROW() {} // exit(1); // } -#if defined(__GNUC__) && (__GNUC__ > 3) +#if defined(__GNUC__) && (__GNUC__ > 3) && !defined(__clang__) # define GMM_SET_EXCEPTION_DEBUG\ std::set_terminate(__gnu_cxx::__verbose_terminate_handler); #else
[Getfem-commits] (no subject)
branch: remove-local-superlu commit cfad3bd4775148b5b41d301e83085eb52f239b09 Author: Konstantinos Poulios AuthorDate: Sat Nov 18 20:52:37 2023 +0100 Make SuperLU optional --- interface/src/getfemint_precond.h | 43 --- interface/src/gf_linsolve.cc | 5 - interface/src/gf_precond.cc | 4 src/Makefile.am | 7 +-- src/getfem/getfem_config.h| 7 +++ src/getfem/getfem_model_solvers.h | 18 src/getfem/getfem_superlu.h | 10 - tests/laplacian.cc| 4 +++- tests/schwarz_additive.cc | 28 +++-- 9 files changed, 86 insertions(+), 40 deletions(-) diff --git a/interface/src/getfemint_precond.h b/interface/src/getfemint_precond.h index 8af6c79b..7dee1aaa 100644 --- a/interface/src/getfemint_precond.h +++ b/interface/src/getfemint_precond.h @@ -52,7 +52,7 @@ 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" }; return p[type]; @@ -69,7 +69,9 @@ namespace getfemint { std::unique_ptr > ildltt; std::unique_ptr > ilu; std::unique_ptr > ilut; +#if defined(GETFEM_USES_SUPERLU) std::unique_ptr > superlu; +#endif virtual size_type memsize() const { size_type sz = sizeof(*this); @@ -81,10 +83,15 @@ namespace getfemint { case ILDLT: sz += ildlt->memsize(); break; case ILDLTT: sz += ildltt->memsize(); break; case SUPERLU: - sz += size_type(superlu->memsize()); break; +#if defined(GETFEM_USES_SUPERLU) +sz += size_type(superlu->memsize()); +#else +GMM_ASSERT1(false, "GetFEM built without SuperLU support"); +#endif +break; case SPMAT: sz += gsp->memsize(); break; } - return sz; + return sz; } }; @@ -120,28 +127,32 @@ namespace gmm { 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::LU_TRANSP); - break; +#if defined(GETFEM_USES_SUPERLU) +if (do_mult) precond.superlu->solve(w,v); +else precond.superlu->solve(w,v,gmm::SuperLU_factor::LU_TRANSP); +#else +GMM_ASSERT1(false, "GetFEM built without SuperLU support"); +#endif +break; case getfemint::gprecond_base::SPMAT: precond.gsp->mult_or_transposed_mult(v, w, !do_mult); break; diff --git a/interface/src/gf_linsolve.cc b/interface/src/gf_linsolve.cc index a04adbe5..1b8f42ff 100644 --- a/interface/src/gf_linsolve.cc +++ b/interface/src/gf_linsolve.cc @@ -85,6 +85,7 @@ void iterative_gmm_solver(iterative_gmm_solver_type stype, else iterative_gmm_solver(stype, gsp, in, out, scalar_type()); } +#if defined(GETFEM_USES_SUPERLU) template static void superlu_solver(gsparse , getfemint::mexargs_in& in, getfemint::mexargs_out& out, T) { @@ -96,6 +97,7 @@ superlu_solver(gsparse , if (out.remaining()) out.pop().from_scalar(rcond ? 1./rcond : 0.); } +#endif #if defined(GMM_USES_MUMPS) || defined(HAVE_DMUMPS_C_H) template static void @@ -178,6 +180,7 @@ void gf_linsolve(getfemint::mexargs_in& m_in, getfemint::mexargs_out& m_out) { ); +#if
[Getfem-commits] (no subject)
branch: remove-local-superlu commit a7601235adf39a1b141542d8c7535aac9f54a29e Author: Konstantinos Poulios AuthorDate: Tue Dec 5 14:04:25 2023 +0100 Improve configuration without superlu --- configure.ac | 6 ++ 1 file changed, 6 insertions(+) diff --git a/configure.ac b/configure.ac index 16a854de..1ab7d38d 100644 --- a/configure.ac +++ b/configure.ac @@ -807,6 +807,7 @@ AC_ARG_WITH(superlu-include-dir, CPPFLAGS="$CPPFLAGS $SUPERLUINC" if test "x$require_superlu" = "xno"; then + SUPERLU_LIBS="" echo "Building with SuperLU explicitly disabled"; else AC_CHECK_HEADERS( @@ -834,6 +835,11 @@ else SUPERLU_LIBS="" LIBS="$save_LIBS" fi + elif test "x$require_superlu" = "xyes"; then +AC_MSG_ERROR([SuperLU header files not found but required by the user. Aborting configure...]); + else +echo "SuperLU header files not found, building without SuperLU" +SUPERLU_LIBS="" fi fi
[Getfem-commits] (no subject)
branch: remove-local-superlu commit c7c7db695aed8a964521448c1c7eff3f7e16887f Author: Konstantinos Poulios AuthorDate: Sat Nov 18 20:52:37 2023 +0100 Make SuperLU optional --- interface/src/getfemint_precond.h | 43 --- interface/src/gf_linsolve.cc | 5 - interface/src/gf_precond.cc | 4 src/Makefile.am | 7 +-- src/getfem/getfem_config.h| 7 +++ src/getfem/getfem_model_solvers.h | 18 src/getfem/getfem_superlu.h | 10 - tests/laplacian.cc| 4 +++- tests/schwarz_additive.cc | 28 +++-- 9 files changed, 86 insertions(+), 40 deletions(-) diff --git a/interface/src/getfemint_precond.h b/interface/src/getfemint_precond.h index 8af6c79b..7dee1aaa 100644 --- a/interface/src/getfemint_precond.h +++ b/interface/src/getfemint_precond.h @@ -52,7 +52,7 @@ 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" }; return p[type]; @@ -69,7 +69,9 @@ namespace getfemint { std::unique_ptr > ildltt; std::unique_ptr > ilu; std::unique_ptr > ilut; +#if defined(GETFEM_USES_SUPERLU) std::unique_ptr > superlu; +#endif virtual size_type memsize() const { size_type sz = sizeof(*this); @@ -81,10 +83,15 @@ namespace getfemint { case ILDLT: sz += ildlt->memsize(); break; case ILDLTT: sz += ildltt->memsize(); break; case SUPERLU: - sz += size_type(superlu->memsize()); break; +#if defined(GETFEM_USES_SUPERLU) +sz += size_type(superlu->memsize()); +#else +GMM_ASSERT1(false, "GetFEM built without SuperLU support"); +#endif +break; case SPMAT: sz += gsp->memsize(); break; } - return sz; + return sz; } }; @@ -120,28 +127,32 @@ namespace gmm { 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::LU_TRANSP); - break; +#if defined(GETFEM_USES_SUPERLU) +if (do_mult) precond.superlu->solve(w,v); +else precond.superlu->solve(w,v,gmm::SuperLU_factor::LU_TRANSP); +#else +GMM_ASSERT1(false, "GetFEM built without SuperLU support"); +#endif +break; case getfemint::gprecond_base::SPMAT: precond.gsp->mult_or_transposed_mult(v, w, !do_mult); break; diff --git a/interface/src/gf_linsolve.cc b/interface/src/gf_linsolve.cc index a04adbe5..1b8f42ff 100644 --- a/interface/src/gf_linsolve.cc +++ b/interface/src/gf_linsolve.cc @@ -85,6 +85,7 @@ void iterative_gmm_solver(iterative_gmm_solver_type stype, else iterative_gmm_solver(stype, gsp, in, out, scalar_type()); } +#if defined(GETFEM_USES_SUPERLU) template static void superlu_solver(gsparse , getfemint::mexargs_in& in, getfemint::mexargs_out& out, T) { @@ -96,6 +97,7 @@ superlu_solver(gsparse , if (out.remaining()) out.pop().from_scalar(rcond ? 1./rcond : 0.); } +#endif #if defined(GMM_USES_MUMPS) || defined(HAVE_DMUMPS_C_H) template static void @@ -178,6 +180,7 @@ void gf_linsolve(getfemint::mexargs_in& m_in, getfemint::mexargs_out& m_out) { ); +#if
[Getfem-commits] (no subject)
branch: master commit 517ffd4daed62e304c02bee37cd68772b1bdb8fa Author: Konstantinos Poulios AuthorDate: Tue Nov 21 00:04:26 2023 +0100 Naming, whitespace and simplifications --- interface/src/gf_mesh_fem.cc | 12 ++--- src/getfem_global_function.cc | 18 +++ src/getfem_mesh_fem_product.cc | 120 - src/getfem_mesh_fem_sum.cc | 3 +- 4 files changed, 77 insertions(+), 76 deletions(-) diff --git a/interface/src/gf_mesh_fem.cc b/interface/src/gf_mesh_fem.cc index 3851f036..cf675d81 100644 --- a/interface/src/gf_mesh_fem.cc +++ b/interface/src/gf_mesh_fem.cc @@ -176,21 +176,21 @@ void gf_mesh_fem(getfemint::mexargs_in& m_in, sub_command ("sum", 1, -1, 0, 1, std::vector mftab; - std::shared_ptr msum; + std::shared_ptr mfsum; while (in.remaining()) { getfem::mesh_fem *gfimf = to_meshfem_object(in.pop()); if (mmf.get() == 0) { mm = >linked_mesh(); - msum = std::make_shared(*mm); - mmf = msum; + mfsum = std::make_shared(*mm); + mmf = mfsum; store_meshfem_object(mmf); } workspace().set_dependence(mmf.get(), gfimf); mftab.push_back(gfimf); } - msum->set_mesh_fems(mftab); - msum->adapt(); - mmf = msum; + mfsum->set_mesh_fems(mftab); + mfsum->adapt(); + mmf = mfsum; ); /*@INIT MF = ('product', @tmf mf1, @tmf mf2) diff --git a/src/getfem_global_function.cc b/src/getfem_global_function.cc index 0ed103f4..bcd2e55e 100644 --- a/src/getfem_global_function.cc +++ b/src/getfem_global_function.cc @@ -32,7 +32,7 @@ namespace getfem { (const fem_interpolation_context ) const { base_node pt = c.xreal(); GMM_ASSERT1(pt.size() == dim_, "Point of wrong size (" << pt.size() << ") " - << "passed to a global function of dim = "<< dim_ <<"."); +<< "passed to a global function of dim = "<< dim_ <<"."); return this->val(pt); } @@ -40,7 +40,7 @@ namespace getfem { (const fem_interpolation_context , base_small_vector ) const { base_node pt = c.xreal(); GMM_ASSERT1(pt.size() == dim_, "Point of wrong size (" << pt.size() << ") " - << "passed to a global function of dim = "<< dim_ <<"."); +<< "passed to a global function of dim = "<< dim_ <<"."); this->grad(pt, g); } @@ -48,7 +48,7 @@ namespace getfem { (const fem_interpolation_context , base_matrix ) const { base_node pt = c.xreal(); GMM_ASSERT1(pt.size() == dim_, "Point of wrong size (" << pt.size() << ") " - << "passed to a global function of dim = "<< dim_ <<"."); +<< "passed to a global function of dim = "<< dim_ <<"."); this->hess(pt, h); } @@ -717,12 +717,12 @@ namespace getfem { if (cv_ != cv) { cv=cv_; if (lsets.size() == 0) { - mls_x = ls.mls_of_convex(cv, 1); - mls_y = ls.mls_of_convex(cv, 0); + mls_x = ls.mls_of_convex(cv, 1); + mls_y = ls.mls_of_convex(cv, 0); } else { - base_node pt(n); + base_node pt(n); scalar_type d = scalar_type(-2); - for (const auto _ : lsets) { + for (const level_set _ : lsets) { pmesher_signed_distance mls_xx, mls_yy; mls_xx = ls_.mls_of_convex(cv, 1); mls_yy = ls_.mls_of_convex(cv, 0); @@ -806,8 +806,8 @@ namespace getfem { GMM_ASSERT1(lsets.size() > 0, "The list of level sets should" " contain at least one level set."); cv = size_type(-1); - for (size_type i = 0; i < lsets.size(); ++i) -this->add_dependency(lsets[i]); + for (const level_set _ : lsets) +this->add_dependency(ls_); } global_function_on_levelsets_2D_(const level_set _, diff --git a/src/getfem_mesh_fem_product.cc b/src/getfem_mesh_fem_product.cc index 33608757..69117915 100644 --- a/src/getfem_mesh_fem_product.cc +++ b/src/getfem_mesh_fem_product.cc @@ -23,12 +23,12 @@ #include "getfem/getfem_mesh_fem_product.h" namespace getfem { - + void fem_product::init() { - + GMM_ASSERT1(pfems[0]->target_dim() == 1, "To be done"); GMM_ASSERT1(pfems[1]->target_dim() == 1, - "The second finite element should be scalar"); +"The second finite element should be scalar"); cvr = pfems[0]->ref_convex(cv); dim_ = cvr->structure()->dim(); @@ -40,27 +40,27 @@ namespace getfem { nm << "FEM_PRODUCT(" << pfems[0]->debug_name() << "," << pfems[1]->debug_name() << "," << cv << ")"; debug_name_ = nm.str(); - + init_cvs_node(); for (dal::bv_visitor i(enriched_dof1); !i.finished(); ++i) { for (size_type j = 0; j < pfems[1]->nb_dof(cv); ++j) - add_node(xfem_dof(pfems[0]->dof_types()[i], xfem_index+j), -pfems[0]->node_of_dof(cv,i));
[Getfem-commits] (no subject)
branch: remove-local-superlu commit bb9888000da89f9d55f2f474545994e76f4063ae Author: Konstantinos Poulios AuthorDate: Sat Nov 18 20:52:37 2023 +0100 Make SuperLU optional --- interface/src/getfemint_precond.h | 43 --- interface/src/gf_linsolve.cc | 5 - interface/src/gf_precond.cc | 4 src/Makefile.am | 7 +-- src/getfem/getfem_config.h| 7 +++ src/getfem/getfem_model_solvers.h | 18 src/getfem/getfem_superlu.h | 10 - tests/laplacian.cc| 4 +++- tests/schwarz_additive.cc | 28 +++-- 9 files changed, 86 insertions(+), 40 deletions(-) diff --git a/interface/src/getfemint_precond.h b/interface/src/getfemint_precond.h index 8af6c79b..7dee1aaa 100644 --- a/interface/src/getfemint_precond.h +++ b/interface/src/getfemint_precond.h @@ -52,7 +52,7 @@ 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" }; return p[type]; @@ -69,7 +69,9 @@ namespace getfemint { std::unique_ptr > ildltt; std::unique_ptr > ilu; std::unique_ptr > ilut; +#if defined(GETFEM_USES_SUPERLU) std::unique_ptr > superlu; +#endif virtual size_type memsize() const { size_type sz = sizeof(*this); @@ -81,10 +83,15 @@ namespace getfemint { case ILDLT: sz += ildlt->memsize(); break; case ILDLTT: sz += ildltt->memsize(); break; case SUPERLU: - sz += size_type(superlu->memsize()); break; +#if defined(GETFEM_USES_SUPERLU) +sz += size_type(superlu->memsize()); +#else +GMM_ASSERT1(false, "GetFEM built without SuperLU support"); +#endif +break; case SPMAT: sz += gsp->memsize(); break; } - return sz; + return sz; } }; @@ -120,28 +127,32 @@ namespace gmm { 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::LU_TRANSP); - break; +#if defined(GETFEM_USES_SUPERLU) +if (do_mult) precond.superlu->solve(w,v); +else precond.superlu->solve(w,v,gmm::SuperLU_factor::LU_TRANSP); +#else +GMM_ASSERT1(false, "GetFEM built without SuperLU support"); +#endif +break; case getfemint::gprecond_base::SPMAT: precond.gsp->mult_or_transposed_mult(v, w, !do_mult); break; diff --git a/interface/src/gf_linsolve.cc b/interface/src/gf_linsolve.cc index a04adbe5..1b8f42ff 100644 --- a/interface/src/gf_linsolve.cc +++ b/interface/src/gf_linsolve.cc @@ -85,6 +85,7 @@ void iterative_gmm_solver(iterative_gmm_solver_type stype, else iterative_gmm_solver(stype, gsp, in, out, scalar_type()); } +#if defined(GETFEM_USES_SUPERLU) template static void superlu_solver(gsparse , getfemint::mexargs_in& in, getfemint::mexargs_out& out, T) { @@ -96,6 +97,7 @@ superlu_solver(gsparse , if (out.remaining()) out.pop().from_scalar(rcond ? 1./rcond : 0.); } +#endif #if defined(GMM_USES_MUMPS) || defined(HAVE_DMUMPS_C_H) template static void @@ -178,6 +180,7 @@ void gf_linsolve(getfemint::mexargs_in& m_in, getfemint::mexargs_out& m_out) { ); +#if
[Getfem-commits] (no subject)
branch: improve-expm-performance commit ee139e697b50db9198ef8257e2c492202b037a35 Author: Konstantinos Poulios AuthorDate: Fri Oct 20 10:59:42 2023 +0200 Use a Pade approximation for expm, ported from Eigen/Unsupported --- src/getfem_plasticity.cc | 472 ++- 1 file changed, 386 insertions(+), 86 deletions(-) diff --git a/src/getfem_plasticity.cc b/src/getfem_plasticity.cc index 5a0ec9c0..69ca66b2 100644 --- a/src/getfem_plasticity.cc +++ b/src/getfem_plasticity.cc @@ -46,109 +46,409 @@ namespace getfem { { mi.resize(2); mi[0] = mi[1] = N; } - bool expm(const base_matrix _, base_matrix , scalar_type tol=1e-15) { + inline void matmul(base_matrix ,base_matrix ,base_matrix ) +{gmm::mult(aa,bb,cc);} -const size_type itmax = 40; -base_matrix a(a_); -// scale input matrix a -int e; -frexp(gmm::mat_norminf(a), ); -e = std::max(0, std::min(1023, e)); -gmm::scale(a, pow(scalar_type(2),-scalar_type(e))); - -base_matrix atmp(a), an(a); -gmm::copy(a, aexp); -gmm::add(gmm::identity_matrix(), aexp); -scalar_type factn(1); + bool expm(const base_matrix _, base_matrix ) { + +const size_type N = gmm::mat_nrows(a_); bool success(false); -for (size_type n=2; n < itmax; ++n) { - factn /= scalar_type(n); - gmm::mult(an, a, atmp); - gmm::copy(atmp, an); - gmm::scale(atmp, factn); - gmm::add(atmp, aexp); - if (gmm::mat_euclidean_norm(atmp) < tol) { -success = true; -break; - } + +// Pade approximation ported from Eigen/Unsupported +base_matrix a(a_); +gmm::clear(aexp.as_vector()); +base_matrix tmp(aexp), v(aexp), u(aexp); // Pade approximant is (v+u)/(v-u) +const scalar_type l1norm = gmm::mat_norminf(a_); +int e = 0; // squarings +if (l1norm < 1.495585217958292e-002) { // matrix_exp_pade3(a, u, v) + const static std::array b{120,60,12,1}; + base_matrix a2(a); + matmul(a, a, a2); + gmm::copy(gmm::scaled(a2,b[2]), v); // v = b2*A2 + b0*I + gmm::copy(gmm::scaled(a2,b[3]), u); // u = b3*A2 + b1*I + for (size_type ij=0; ij < N; ++ij) +{ v(ij,ij) += b[0]; u(ij,ij) += b[1]; } +} else if (l1norm < 2.539398330063230e-001) { // matrix_exp_pade5(a, u, v) + const static std::array b{30240,15120,3360,420,30,1}; + base_matrix a2(a), a4(a); + matmul(a, a, a2); + matmul(a2, a2, a4); + gmm::add(gmm::scaled(a4,b[4]),// v = b4*A4 + b2*A2 + b0*I + gmm::scaled(a2,b[2]), v); + gmm::add(gmm::scaled(a4,b[5]),// u = b5*A4 + b3*A2 + b1*I + gmm::scaled(a2,b[3]), u); + for (size_type ij=0; ij < N; ++ij) +{ v(ij,ij) += b[0]; u(ij,ij) += b[1]; } +} else if (l1norm < 9.504178996162932e-001) { // matrix_exp_pade7(a, u, v) + const static std::array +b{17297280,8648640,1995840,277200,25200,1512,56,1}; + base_matrix a2(a), a4(a), a6(a); + matmul(a, a, a2); + matmul(a2, a2, a4); + matmul(a2, a4, a6); + gmm::add(gmm::scaled(a6,b[6]),// v = b6*A6 + b4*A4 + b2*A2 + b0*I + gmm::scaled(a4,b[4]), v); + gmm::add(gmm::scaled(a2,b[2]), v); + gmm::add(gmm::scaled(a6,b[7]),// u = b7*A6 + b5*A4 + b3*A2 + b1*I + gmm::scaled(a4,b[5]), u); + gmm::add(gmm::scaled(a2,b[3]), u); + for (size_type ij=0; ij < N; ++ij) +{ v(ij,ij) += b[0]; u(ij,ij) += b[1]; } +} else if (l1norm < 2.097847961257068e+000) { // matrix_exp_pade9(a, u, v) + const static std::array +b{17643225600,8821612800,2075673600,302702400,30270240,2162160, + 110880,3960,90,1}; + base_matrix a2(a), a4(a), a6(a), a8(a); + matmul(a, a, a2); + matmul(a2, a2, a4); + matmul(a2, a4, a6); + matmul(a4, a4, a8); + gmm::add(gmm::scaled(a8,b[8]),// v = b8*A8+b6*A6+b4*A4+b2*A2+b0*I + gmm::scaled(a6,b[6]), v); + gmm::add(gmm::scaled(a4,b[4]), v); + gmm::add(gmm::scaled(a2,b[2]), v); + gmm::add(gmm::scaled(a8,b[9]),// u = b9*A8+b7*A6+b5*A4+b3*A2+b1*I + gmm::scaled(a6,b[7]), u); + gmm::add(gmm::scaled(a4,b[5]), u); + gmm::add(gmm::scaled(a2,b[3]), u); + for (size_type ij=0; ij < N; ++ij) +{ v(ij,ij) += b[0]; u(ij,ij) += b[1]; } +} else { // matrix_exp_pade13(a, U, V); + const scalar_type maxnorm = 5.371920351148152; + frexp(l1norm / maxnorm, ); + if (e <= 0) e = 0; + else for (auto & : a.as_vector()) { val = ldexp(val,-e); } + // <==> gmm::scale(a, pow(scalar_type(2),-scalar_type(e))); + const static std::array +b{6476475253248,3238237626624,7771770303897600, + 1187353796428800,129060195264000,10559470521600,670442572800, + 33522128640,1323241920,40840800,960960,16380,182,1}; + base_matrix a2(a), a4(a), a6(a); + matmul(a, a, a2); + matmul(a2, a2, a4); + matmul(a2, a4, a6); +
[Getfem-commits] (no subject)
branch: master commit 888391bb931bf1bcf56027664a02159356b78954 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 14:16:02 2023 +0200 Code readability --- src/getfem_generic_assembly_compile_and_exec.cc | 3 +- src/getfem_generic_assembly_semantic.cc | 3 +- src/getfem_generic_assembly_tree.cc | 38 - 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/getfem_generic_assembly_compile_and_exec.cc b/src/getfem_generic_assembly_compile_and_exec.cc index e09d46ff..71793f6a 100644 --- a/src/getfem_generic_assembly_compile_and_exec.cc +++ b/src/getfem_generic_assembly_compile_and_exec.cc @@ -5366,7 +5366,8 @@ namespace getfem { // Produce a resize instruction which is stored if no equivalent node is // detected and if the mesh is not uniform. -pnode->t.set_to_original(); pnode->t.set_sparsity(0, 0); +pnode->t.set_to_original(); +pnode->t.set_sparsity(0, 0); bool is_uniform = false; if (pnode->test_function_type == 1) { if (mf1 || mfg1) diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index 3504a724..714c4d19 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -2257,7 +2257,8 @@ namespace getfem { else if (pnode->children.size() == 5) { ind[0] = 2; ind[1] = 4; } else if (pnode->children.size() == 7) { - ind.resize(4); indsize.resize(4); + ind.resize(4); + indsize.resize(4); ind[0] = 2; ind[1] = 3; ind[2] = 5; ind[3] = 6; } diff --git a/src/getfem_generic_assembly_tree.cc b/src/getfem_generic_assembly_tree.cc index 9ba538ea..3dee62a8 100644 --- a/src/getfem_generic_assembly_tree.cc +++ b/src/getfem_generic_assembly_tree.cc @@ -542,12 +542,12 @@ namespace getfem { return false; break; case GA_NODE_C_MATRIX: - if (pnode1->children.size() != pnode2->children.size()) return false; - if (pnode1->nb_test_functions() != pnode2->nb_test_functions()) + if (pnode1->children.size() != pnode2->children.size() || + pnode1->nb_test_functions() != pnode2->nb_test_functions() || + pnode1->t.sizes().size() != pnode2->t.sizes().size()) return false; - if (pnode1->t.sizes().size() != pnode2->t.sizes().size()) return false; for (size_type i=pnode1->nb_test_functions(); - it.sizes().size(); ++i) + i < pnode1->t.sizes().size(); ++i) if (pnode1->t.sizes()[i] != pnode2->t.sizes()[i]) return false; if (pnode1->nbc1 != pnode2->nbc1) return false; break; @@ -1951,7 +1951,8 @@ namespace getfem { mi.pop_back(); sub_tree.root->tensor().adjust_sizes(mi); } -if (!nb_comp) mii = sub_tree.root->tensor().sizes(); +if (!nb_comp) + mii = sub_tree.root->tensor().sizes(); else { const bgeot::multi_index =sub_tree.root->tensor().sizes(); bool cmp = true; @@ -2034,23 +2035,32 @@ namespace getfem { } while (r_type != GA_RBRACKET); bgeot::multi_index mi; - nbc1 = tree.current_node->nbc1; nbc2 = tree.current_node->nbc2; + nbc1 = tree.current_node->nbc1; + nbc2 = tree.current_node->nbc2; nbc3 = tree.current_node->nbc3; size_type nbl = tree.current_node->children.size() / (nbc2 * nbc1 * nbc3); switch(tensor_order) { case 1: -/* mi.push_back(1); */ mi.push_back(nbc1); break; +// mi.push_back(1); +mi.push_back(nbc1); +break; case 2: -mi.push_back(nbl); if (nbc1 > 1) mi.push_back(nbc1); break; +mi.push_back(nbl); +if (nbc1 > 1) + mi.push_back(nbc1); +break; case 3: -mi.push_back(nbl); mi.push_back(nbc2); +mi.push_back(nbl); +mi.push_back(nbc2); mi.push_back(nbc1); break; case 4: -mi.push_back(nbl); mi.push_back(nbc3); -mi.push_back(nbc2); mi.push_back(nbc1); +mi.push_back(nbl); +mi.push_back(nbc3); +mi.push_back(nbc2); +mi.push_back(nbc1); break; default: GMM_ASSERT1(false, "Internal error"); } @@ -2080,10 +2090,12 @@ namespace getfem { case GA_COLON: case GA_DOT: case GA_DOTMULT: case GA_DOTDIV: case GA_TMULT: tree.add_op(t_type, token_pos, expr); - state = 1; break; + state = 1; + break; case GA_QUOTE: tree.add_op(t_type, token_pos, expr); - state = 2; break; +
[Getfem-commits] (no subject)
branch: master commit 0d05415881685c1cf8cf6ad4ff308b22d582ac9f Author: Konstantinos Poulios AuthorDate: Mon Oct 16 14:19:48 2023 +0200 Minor changes in python demo --- interface/tests/python/demo_nonlinear_elasticity.py | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/interface/tests/python/demo_nonlinear_elasticity.py b/interface/tests/python/demo_nonlinear_elasticity.py index 4a8074a6..66425da3 100644 --- a/interface/tests/python/demo_nonlinear_elasticity.py +++ b/interface/tests/python/demo_nonlinear_elasticity.py @@ -85,17 +85,17 @@ if (not(explicit_potential)): md.add_finite_strain_elasticity_brick(mim, lawname, 'u', 'params') else: print("Explicit elastic potential") -K = 1.2; mu = 3.0; -md.add_macro('F_', '(Id(meshdim)+Grad_u)') -md.add_macro('J_', 'Det(F_)') -md.add_macro('be_', 'Left_Cauchy_Green(F_)') -md.add_initialized_data('K', [K]) -md.add_initialized_data('mu', [mu]) +K = 1.2 +mu = 3.0 +md.add_macro('F', 'Id(meshdim)+Grad_u') +md.add_macro('J', 'Det(F)') +md.add_macro('be', 'Left_Cauchy_Green(F)') +md.add_initialized_data('K', K) +md.add_initialized_data('mu', mu) md.add_initialized_data('paramsIMR', [1,1,2]) -_expr_1 = "(K/2)*sqr(log(J_))+(mu/2)*(Matrix_j1(be_)-3)"; -_expr_2 = "(K/2)*sqr(log(J_))+(mu/2)*(pow(Det(be_),-1./3.)*Trace(be_)-3)" -_expr_3 = "paramsIMR(1)*(Matrix_j1(Right_Cauchy_Green(F_))-3)+ paramsIMR(2)*(Matrix_j2(Right_Cauchy_Green(F_)) - 3)+paramsIMR(3)*sqr(J_-1)" -md.add_nonlinear_term(mim, _expr_3); +#md.add_nonlinear_term(mim, "(K/2)*sqr(log(J))+(mu/2)*(Matrix_j1(be)-3)") +#md.add_nonlinear_term(mim, "(K/2)*sqr(log(J))+(mu/2)*(pow(Det(be),-1./3.)*Trace(be)-3)") +md.add_nonlinear_term(mim, "paramsIMR(1)*(Matrix_j1(Right_Cauchy_Green(F))-3)+ paramsIMR(2)*(Matrix_j2(Right_Cauchy_Green(F)) - 3)+paramsIMR(3)*sqr(J-1)"); # md.add_nonlinear_term(mim, 'sqr(Trace(Green_Lagrangian(Id(meshdim)+Grad_u)))/8 + Norm_sqr(Green_Lagrangian(Id(meshdim)+Grad_u))/4') # md.add_nonlinear_term(mim, '((Id(meshdim)+Grad_u)*(params(1)*Trace(Green_Lagrangian(Id(meshdim)+Grad_u))*Id(meshdim)+2*params(2)*Green_Lagrangian(Id(meshdim)+Grad_u))):Grad_Test_u')
[Getfem-commits] (no subject)
branch: master commit 88a69becf3d33fa2b55d083a76e88a5033bbaab4 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 14:37:11 2023 +0200 Whitespace changes --- src/getfem_mesh_im_level_set.cc | 694 1 file changed, 347 insertions(+), 347 deletions(-) diff --git a/src/getfem_mesh_im_level_set.cc b/src/getfem_mesh_im_level_set.cc index 00edc831..11eae1b6 100644 --- a/src/getfem_mesh_im_level_set.cc +++ b/src/getfem_mesh_im_level_set.cc @@ -39,12 +39,12 @@ namespace getfem { mesh_im::clear(); clear_build_methods(); is_adapted = false; - } + } - void mesh_im_level_set::init_with_mls(mesh_level_set , - int integrate_where_, - pintegration_method reg, - pintegration_method sing) { + void mesh_im_level_set::init_with_mls(mesh_level_set , +int integrate_where_, +pintegration_method reg, +pintegration_method sing) { init_with_mesh(me.linked_mesh()); cut_im.init_with_mesh(me.linked_mesh()); mls = @@ -55,9 +55,9 @@ namespace getfem { } mesh_im_level_set::mesh_im_level_set(mesh_level_set , - int integrate_where_, - pintegration_method reg, - pintegration_method sing) { + int integrate_where_, + pintegration_method reg, + pintegration_method sing) { mls = 0; init_with_mls(me, integrate_where_, reg, sing); } @@ -66,14 +66,14 @@ namespace getfem { { mls = 0; is_adapted = false; } - pintegration_method + pintegration_method mesh_im_level_set::int_method_of_element(size_type cv) const { if (!is_adapted) const_cast(this)->adapt(); -if (cut_im.convex_index().is_in(cv)) - return cut_im.int_method_of_element(cv); +if (cut_im.convex_index().is_in(cv)) + return cut_im.int_method_of_element(cv); else { if (ignored_im.is_in(cv)) //integrate_where == INTEGRATE_BOUNDARY) - return getfem::im_none(); +return getfem::im_none(); return mesh_im::int_method_of_element(cv); } @@ -91,16 +91,16 @@ namespace getfem { for (unsigned i = 0; i < mls->nb_level_sets(); ++i) { isin = isin && ((*(mesherls0[i]))(P) < 0); if (gmm::abs((*(mesherls0[i]))(P)) < 1e-7) - isbin = i+1; +isbin = i+1; if (mls->get_level_set(i)->has_secondary()) - isin = isin && ((*(mesherls1[i]))(P) < 0); +isin = isin && ((*(mesherls1[i]))(P) < 0); } -bool2 b; +bool2 b; b.in = ((integrate_where & INTEGRATE_OUTSIDE)) ? !isin : isin; b.bin = isbin; return b; } - + /* very rustic set operations evaluator */ struct is_in_eval { @@ -110,77 +110,77 @@ namespace getfem { bool2 do_expr(const char *) { bool2 r; if (*s == '(') { - r = do_expr(++s); - GMM_ASSERT1(*s++ == ')', - "expecting ')' in csg expression at '" << s-1 << "'"); +r = do_expr(++s); +GMM_ASSERT1(*s++ == ')', +"expecting ')' in csg expression at '" << s-1 << "'"); } else if (*s == '!') { // complementary - r = do_expr(++s); r.in = !r.in; +r = do_expr(++s); r.in = !r.in; } else if (*s >= 'a' && *s <= 'z') { - unsigned idx = (*s) - 'a'; - r.in = in.is_in(idx); - r.bin = bin.is_in(idx) ? idx+1 : 0; - ++s; - } else - GMM_ASSERT1(false, "parse error in csg expression at '" << s << "'"); +unsigned idx = (*s) - 'a'; +r.in = in.is_in(idx); +r.bin = bin.is_in(idx) ? idx+1 : 0; +++s; + } else +GMM_ASSERT1(false, "parse error in csg expression at '" << s << "'"); if (*s == '+') { // Union - //cerr << "s = " << s << ", r = " << r << "\n"; - bool2 a = r, b = do_expr(++s); - //cerr << "->b = " << b << "\n"; - r.in = b.in || a.in; - if (b.bin && !a.in) r.bin = b.bin; - else if (a.bin && !b.in) r.bin = a.bin; - else r.bin = 0; +//cerr << "s = " << s << ", r = " << r << "\n"; +bool2 a = r, b = do_expr(++s); +//cerr << "->b = " << b << "\n"; +r.in = b.in || a.in; +if (b.bin && !a.in) r.bin = b.bin; +else if (a.bin && !b.in) r.bin = a.bin; +else r.bin = 0; } else if (*s == '-') { // Set difference - bool2 a = r, b = do_expr(++s); - r.in = a.in && !b.in; - if (a.bin && !b.in) r.bin = a.bin; - else if (a.in && b.bin) r.bin = b.bin; - else r.bin = 0; +bool2 a = r, b = do_expr(++s); +r.in = a.in && !b.in; +if (a.bin && !b.in) r.bin =
[Getfem-commits] (no subject)
branch: master commit f818f6b6fe4bb6128a37fabe3d2436f706880a37 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 15:05:25 2023 +0200 Fix compilation warnings --- src/getfem_mesh_fem.cc | 3 +-- src/getfem_mesh_im_level_set.cc | 26 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/getfem_mesh_fem.cc b/src/getfem_mesh_fem.cc index d26ad8ce..62df084d 100644 --- a/src/getfem_mesh_fem.cc +++ b/src/getfem_mesh_fem.cc @@ -360,8 +360,7 @@ namespace getfem { if (fe_convex.is_in(cv)) { gmm::copy(linked_mesh().points_of_convex(cv)[0], bmin); gmm::copy(bmin, bmax); -for (size_type i = 0; i < linked_mesh().nb_points_of_convex(cv); ++i) { - const base_node = linked_mesh().points_of_convex(cv)[i]; +for (const base_node : linked_mesh().points_of_convex(cv)) { for (size_type d = 1; d < bmin.size(); ++d) { bmin[d] = std::min(bmin[d], pt[d]); bmax[d] = std::max(bmax[d], pt[d]); diff --git a/src/getfem_mesh_im_level_set.cc b/src/getfem_mesh_im_level_set.cc index 11eae1b6..3772d936 100644 --- a/src/getfem_mesh_im_level_set.cc +++ b/src/getfem_mesh_im_level_set.cc @@ -337,11 +337,9 @@ namespace getfem { if (integrate_where == INTEGRATE_BOUNDARY) { bool lisin = true; - for (unsigned ipt = 0; ipt < - pgt2->structure()->nb_points_of_face(f); ++ipt) { -const base_node = msh.points_of_face_of_convex(i, f)[ipt]; -isin = is_point_in_selected_area(mesherls0, mesherls1, P).bin; -//cerr << P << ":" << isin << " "; + for (const base_node : msh.points_of_face_of_convex(i, f)) { +isin = is_point_in_selected_area(mesherls0, mesherls1, pt).bin; +//cerr << pt << ":" << isin << " "; if (!isin) { lisin = false; break; } } if (!lisin) continue; @@ -591,10 +589,12 @@ namespace getfem { bgeot::geotrans_interpolation_context cc(linked_mesh().trans_of_convex(cv), base_node(n), G2); + mesh::ref_mesh_pt_ct cvpts = msh.points_of_convex(i); + dal::bit_vector ptinter; for (short_type k = 0; k < n; ++k) { size_type ipt = msh.structure_of_convex(i)->ind_dir_points()[k]; -const base_node = msh.points_of_convex(i)[ipt]; +const base_node = cvpts[ipt]; if (is_point_in_intersection(mesherls0, mesherls1, P)) ptinter.add(ipt); } @@ -605,7 +605,7 @@ namespace getfem { size_type ipt = msh.structure_of_convex(i)->ind_dir_points()[k]; if (ptinter.is_in(ipt)) { -const base_node = msh.points_of_convex(i)[ipt]; +const base_node = cvpts[ipt]; cc.set_xref(P); if (global_intersection.search_point(cc.xreal()) @@ -626,8 +626,8 @@ namespace getfem { size_type ipt2=msh.structure_of_convex(i)->ind_dir_points()[k2]; if (ptinter.is_in(ipt1) && ptinter.is_in(ipt2)) { -const base_node = msh.points_of_convex(i)[ipt1]; -const base_node = msh.points_of_convex(i)[ipt2]; +const base_node = cvpts[ipt1]; +const base_node = cvpts[ipt2]; cc.set_xref(P1); base_node PR1 = cc.xreal(); cc.set_xref(P2); @@ -651,10 +651,10 @@ namespace getfem { for (bgeot::rtree::pbox_set::const_iterator it=boxlst.begin(); it != boxlst.end(); ++it) { -const base_node - = global_intersection.points_of_convex((*it)->id)[0]; -const base_node - = global_intersection.points_of_convex((*it)->id)[1]; +mesh::ref_mesh_pt_ct intersect_cvpts + = global_intersection.points_of_convex((*it)->id); +const base_node = intersect_cvpts[0]; +const base_node = intersect_cvpts[1]; if (is_edges_intersect(PP1, PP2, PR1, PR2)) { found_intersect = true; break; } }
[Getfem-commits] (no subject)
branch: master commit f8fda6e8ce084f6414854ce7b633dc5561a46509 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 14:04:42 2023 +0200 Fix segfault when internal variables are used inside an explicit matrix expression --- src/getfem_generic_assembly_semantic.cc | 35 ++--- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index 134eec8c..3504a724 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -1609,23 +1609,34 @@ namespace getfem { } } int to_add = int(pnode->nb_test_functions() + pnode->nbc1) - - int(pnode->tensor().sizes().size()); -GMM_ASSERT1(to_add >= 0 && to_add <=2, "Internal error"); + - int(pnode->tensor().sizes().size()); +GMM_ASSERT1(to_add >= 0 && to_add <= 2, "Internal error"); if (to_add) { mi = pnode->tensor().sizes(); mi.resize(pnode->nbc1+pnode->nb_test_functions()); for (int i = int(mi.size()-1); i >= to_add; --i) mi[i] = mi[i-to_add]; - for (int i = 0; i < to_add; ++i) mi[i] = 2; - if (pnode->test_function_type & 1 && - !(workspace.associated_mf(pnode->name_test1)) - && !(workspace.associated_im_data(pnode->name_test1))) -mi[0] = gmm::vect_size(workspace.value(pnode->name_test1)); - if (pnode->test_function_type & 2 && - !(workspace.associated_mf(pnode->name_test2)) - && !(workspace.associated_im_data(pnode->name_test2))) -mi[(pnode->test_function_type & 1) ? 1 : 0] - = gmm::vect_size(workspace.value(pnode->name_test2)); + for (int i = 0; i < to_add; ++i) +mi[i] = 2; + + if (pnode->test_function_type & 1) { +const mesh_fem *mf1 = workspace.associated_mf(pnode->name_test1); +const im_data *imd1 = workspace.associated_im_data(pnode->name_test1); +if (mf1 == 0 && imd1 == 0) // global variable + mi[0] = gmm::vect_size(workspace.value(pnode->name_test1)); +else if (imd1) // im_data variable + mi[0] = workspace.qdim(pnode->name_test1); // == 1 because of all_sc = true + } + if (pnode->test_function_type & 2) { +const mesh_fem *mf2 = workspace.associated_mf(pnode->name_test2); +const im_data *imd2 = workspace.associated_im_data(pnode->name_test2); +if (mf2 == 0 && imd2 == 0) // global variable + mi[(pnode->test_function_type & 1) ? 1 : 0] += gmm::vect_size(workspace.value(pnode->name_test2)); // == 1 because of all_sc = true +else if (imd2) // im_data variable + mi[(pnode->test_function_type & 1) ? 1 : 0] += workspace.qdim(pnode->name_test2); + } pnode->tensor().adjust_sizes(mi); }
[Getfem-commits] (no subject)
branch: master commit 1b1001e476d207a24bed8f6f2f94438853fcada1 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 14:02:13 2023 +0200 Add unit test for filtered internal variables --- tests/test_internal_variables.cc | 13 + 1 file changed, 13 insertions(+) diff --git a/tests/test_internal_variables.cc b/tests/test_internal_variables.cc index 6fe57be0..228e0427 100644 --- a/tests/test_internal_variables.cc +++ b/tests/test_internal_variables.cc @@ -53,6 +53,8 @@ int main(int argc, char *argv[]) { m.region(100) = getfem::select_faces_of_normal(m, outer_faces, base_node(-1, 0), 0.001); m.region(101) = getfem::select_faces_of_normal(m, outer_faces, base_node(1, 0), 0.001); m.region(102) = getfem::mesh_region::merge(m.region(100), m.region(101)); + m.region(201) = getfem::select_convexes_in_box(m, base_node(-1e-3, -1e-3), +base_node(1+1e-3, 0.5+1e-3)); dim_type N(2); getfem::mesh_fem mf(m, N), mf_intern(m); @@ -66,6 +68,10 @@ int main(int argc, char *argv[]) { getfem::im_data mimd(mim); if (DIFFICULTY) mimd.set_tensor_size(bgeot::multi_index(3,4)); + getfem::im_data mimd_filtered(mim); + mimd_filtered.set_region(201); + + getfem::model md1, md2; md1.add_fem_variable("u", mf); md2.add_fem_variable("u", mf); @@ -111,6 +117,13 @@ int main(int argc, char *argv[]) { std::cout << "Total dofs of model 1: " << md1.nb_dof() << std::endl; std::cout << "Total dofs of model 2: " << md2.nb_dof() << std::endl; + + getfem::model md3; + md3.add_im_variable("p", mimd_filtered); + + getfem::add_nonlinear_term(md3, mim, "(p-exp(p+2)+10)*Test_p", 201); + iter.init(); + getfem::standard_solve(md3, iter); GETFEM_MPI_FINALIZE; return gmm::vect_dist2(md1.real_variable("u"), md2.real_variable("u")) < 1e-9 ? 0 : 1;
[Getfem-commits] (no subject)
branch: master commit c89220316f6f84fa991e8f9b01bb568132e0e862 Author: Konstantinos Poulios AuthorDate: Mon Oct 16 14:03:02 2023 +0200 Add unit test for internal variables that leads to segfault --- tests/test_internal_variables.cc | 9 + 1 file changed, 9 insertions(+) diff --git a/tests/test_internal_variables.cc b/tests/test_internal_variables.cc index 228e0427..e5c22f7d 100644 --- a/tests/test_internal_variables.cc +++ b/tests/test_internal_variables.cc @@ -124,6 +124,15 @@ int main(int argc, char *argv[]) { getfem::add_nonlinear_term(md3, mim, "(p-exp(p+2)+10)*Test_p", 201); iter.init(); getfem::standard_solve(md3, iter); + + if (!DIFFICULTY) { +getfem::model md4; +md4.add_im_variable("f33", mimd); +gmm::fill(md4.set_real_variable("f33"), 1); +getfem::add_nonlinear_term(md4, mim, "Det([1,0,0;0,1,0;0,0,f33])*Test_f33"); +md4.assembly(getfem::model::BUILD_MATRIX); + } + GETFEM_MPI_FINALIZE; return gmm::vect_dist2(md1.real_variable("u"), md2.real_variable("u")) < 1e-9 ? 0 : 1;
[Getfem-commits] (no subject)
branch: cleanup-mesh-import commit 69884dd486e8e68d7bcdb502f2843c5131c5a91e Author: Konstantinos Poulios AuthorDate: Wed Aug 2 23:14:40 2023 +0200 Change default treatment of overlapping nodes and cleanup of mesh import --- src/getfem/getfem_import.h | 62 --- src/getfem_import.cc | 439 ++--- 2 files changed, 248 insertions(+), 253 deletions(-) diff --git a/src/getfem/getfem_import.h b/src/getfem/getfem_import.h index 10210207..cad32fd0 100644 --- a/src/getfem/getfem_import.h +++ b/src/getfem/getfem_import.h @@ -76,9 +76,9 @@ namespace getfem { parametrization of the mesh in Gmsh .geo file must assign a different number to each region, the problem exists because in Gmsh can coexist, for example, "Physical Surface (200)" and - "Physical Line (200)", as they are different "types of regions" - in Gmsh, that which does not occur in GetFEM since there is - only one "type of region". + "Physical Line (200)", as they are different types of regions + in Gmsh, which cannot occur in GetFEM since there is only one + type of region. - "cdb" for meshes generated by ANSYS (in blocked format). @@ -103,11 +103,19 @@ namespace getfem { - "am_fmt" for 2D meshes from emc2 [http://pauillac.inria.fr/cdrom/prog/unix/emc2/eng.htm] + + For all mesh formats, overlapping nodes are preserved by default. + In order to merge overlapping nodes during the import, add + ":merge_overlapping_nodes" to the format specifier. + For example: +"gmsh:merge_overlapping_nodes" +"cdb:merge_overlapping_nodes" +"cdb:3:merge_overlapping_nodes" */ void import_mesh(const std::string& filename, const std::string& format, - mesh& m); + mesh& m); void import_mesh(std::istream& f, const std::string& format, - mesh& m); + mesh& m); void import_mesh(const std::string& filename, mesh& m); /** Import a mesh file in format generated by Gmsh. @@ -140,38 +148,42 @@ namespace getfem { be tested. */ void import_mesh_gmsh(const std::string& filename, mesh& m, -std::map _map, +bool add_all_element_type = false, +std::set *lower_dim_convex_rg = nullptr, +std::map *region_map = nullptr, bool remove_last_dimension = true, -std::map> *nodal_map = NULL, -bool remove_duplicated_nodes = true); - - void import_mesh_gmsh(std::istream& f, mesh& m, +std::map> *nodal_map = nullptr, +bool merge_overlapping_nodes = false); + void import_mesh_gmsh(const std::string& filename, mesh& m, std::map _map, bool remove_last_dimension = true, -std::map> *nodal_map = NULL, -bool remove_duplicated_nodes = true); - - void import_mesh_gmsh(const std::string& filename, mesh& m, +std::map> *nodal_map = nullptr, +bool merge_overlapping_nodes = false) { +import_mesh_gmsh(filename, m, false, nullptr, _map, + remove_last_dimension, nodal_map, merge_overlapping_nodes); + } + void import_mesh_gmsh(std::istream& f, mesh& m, bool add_all_element_type = false, -std::set *lower_dim_convex_rg = NULL, -std::map *region_map = NULL, +std::set *lower_dim_convex_rg = nullptr, +std::map *region_map = nullptr, bool remove_last_dimension = true, -std::map> *nodal_map = NULL, -bool remove_duplicated_nodes = true); - +std::map> *nodal_map = nullptr, +bool merge_overlapping_nodes = false); void import_mesh_gmsh(std::istream& f, mesh& m, -bool add_all_element_type = false, -std::set *lower_dim_convex_rg = NULL, -std::map *region_map = NULL, +std::map _map, bool remove_last_dimension = true, -std::map> *nodal_map = NULL, -bool remove_duplicated_nodes = true); +std::map> *nodal_map = nullptr, +bool merge_overlapping_nodes = false) { +import_gmsh_mesh(f, m, false, nullptr, _map, + remove_last_dimension, nodal_map, merge_overlapping_nodes); + } /** for gmsh and gid meshes, the mesh nodes are always 3D, so for a 2D mesh the z-component of nodes should be removed */ void maybe_remove_last_dimension(mesh ); /** for gmsh meshes, create table
[Getfem-commits] (no subject)
branch: devel-tkoyama-fix-python-error commit d5201a21398e6db0bcb679cd50c0c32e82d800be Author: Tetsuo Koyama AuthorDate: Sat Jul 15 03:23:34 2023 -0500 Fix Python error in new third package version --- interface/src/gf_mesh_fem_get.cc | 2 +- interface/tests/python/check_export_vtu.py | 16 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/interface/src/gf_mesh_fem_get.cc b/interface/src/gf_mesh_fem_get.cc index 8a179b1e..c1936652 100644 --- a/interface/src/gf_mesh_fem_get.cc +++ b/interface/src/gf_mesh_fem_get.cc @@ -1002,7 +1002,7 @@ void gf_mesh_fem_get(getfemint::mexargs_in& m_in, P = P[:,Ind] nbd = P.shape[1] vars = ('x','y','z','u','v','w') -nbvars = min(P.shape[0],len(vars)) +nbvars = min([P.shape[0],len(vars)]) for i in range(0,nbvars): gl[vars[i]] = P[i,0] lo[vars[i]] = P[i,0] diff --git a/interface/tests/python/check_export_vtu.py b/interface/tests/python/check_export_vtu.py index 0f203327..38cbe276 100644 --- a/interface/tests/python/check_export_vtu.py +++ b/interface/tests/python/check_export_vtu.py @@ -90,28 +90,28 @@ file_name = "check_meshfem_ascii.vtk" mfu.export_to_vtk(file_name, "ascii", U1, "U1") unstructured_grid = pv.read(file_name) expected = U1 -actual = unstructured_grid.point_arrays["U1"] +actual = unstructured_grid.point_data["U1"] np.testing.assert_equal(expected, actual, "export of U1 is not correct.") file_name = "check_meshfem_binary.vtk" mfu.export_to_vtk(file_name, U1, "U1") unstructured_grid = pv.read(file_name) expected = U1 -actual = unstructured_grid.point_arrays["U1"] +actual = unstructured_grid.point_data["U1"] np.testing.assert_equal(expected, actual, "export of U1 is not correct.") file_name = "check_meshfem_ascii.vtu" mfu.export_to_vtu(file_name, "ascii", U1, "U1") unstructured_grid = pv.read(file_name) expected = U1 -actual = unstructured_grid.point_arrays["U1"] +actual = unstructured_grid.point_data["U1"] np.testing.assert_equal(expected, actual, "export of U1 is not correct.") file_name = "check_meshfem_binary.vtu" mfu.export_to_vtu(file_name, U1, "U1") unstructured_grid = pv.read(file_name) expected = U1 -actual = unstructured_grid.point_arrays["U1"] +actual = unstructured_grid.point_data["U1"] np.testing.assert_equal(expected, actual, "export of U1 is not correct.") sl = gf.Slice(("boundary",), mesh, 1) @@ -121,26 +121,26 @@ file_name = "check_slice_ascii.vtk" sl.export_to_vtk(file_name, "ascii", U2, "U2") unstructured_grid = pv.read(file_name) expected = U2 -actual = unstructured_grid.point_arrays["U2"] +actual = unstructured_grid.point_data["U2"] np.testing.assert_equal(expected, actual, "export of U2 is not correct.") file_name = "check_slice_binary.vtk" sl.export_to_vtk(file_name, U2, "U2") unstructured_grid = pv.read(file_name) expected = U2 -actual = unstructured_grid.point_arrays["U2"] +actual = unstructured_grid.point_data["U2"] np.testing.assert_equal(expected, actual, "export of U2 is not correct.") file_name = "check_slice_ascii.vtu" sl.export_to_vtu(file_name, "ascii", U2, "U2") unstructured_grid = pv.read(file_name) expected = U2 -actual = unstructured_grid.point_arrays["U2"] +actual = unstructured_grid.point_data["U2"] np.testing.assert_equal(expected, actual, "export of U2 is not correct.") file_name = "check_slice_binary.vtu" sl.export_to_vtu(file_name, U2, "U2") unstructured_grid = pv.read(file_name) expected = U2 -actual = unstructured_grid.point_arrays["U2"] +actual = unstructured_grid.point_data["U2"] np.testing.assert_equal(expected, actual, "export of U2 is not correct.")
[Getfem-commits] (no subject)
branch: simplify-Div-derivative commit 7b3338cb0f118cc9f318fd334bafaac1d210b2f7 Author: Konstantinos Poulios AuthorDate: Fri Mar 10 19:32:13 2023 +0100 Simplify directional derivative of Div --- interface/tests/python/check_asm.py | 2 +- src/getfem_generic_assembly_semantic.cc | 10 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/interface/tests/python/check_asm.py b/interface/tests/python/check_asm.py index fdd05c63..c2ef06c7 100644 --- a/interface/tests/python/check_asm.py +++ b/interface/tests/python/check_asm.py @@ -245,5 +245,5 @@ if (res != "(Hess_u)"): str = "Diff(u*Div(w),w,3*w)"; print('\nAssembly string "%s" gives:' % str) res = gf.asm_expression_analysis(str, mim, md) -if (res != "(u*((3*Grad_w):[[1,0],[0,1]]))"): +if (res != "(u*(Trace((3*Grad_w"): print("Wrong Diff result"); exit(1) diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index 3106703e..11fa0dc2 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -249,15 +249,7 @@ namespace getfem { delete pnode; pnode = nullptr; tree.copy_node(grad_expr.root, parent, pnode); tree.insert_node(pnode, GA_NODE_OP); - pnode->parent->op_type = GA_COLON; - tree.add_child(pnode->parent, GA_NODE_PARAMS); - pga_tree_node pid = pnode->parent->children[1]; - tree.add_child(pid); - tree.add_child(pid); - pid->children[0]->node_type = GA_NODE_NAME; - pid->children[0]->name = "Id"; - pid->children[1]->node_type = GA_NODE_CONSTANT; - pid->children[1]->init_scalar_tensor(me.dim()); + pnode->parent->op_type = GA_TRACE; } break; case GA_NODE_INTERPOLATE_VAL_TEST: case GA_NODE_INTERPOLATE_GRAD_TEST:
[Getfem-commits] (no subject)
branch: lapack-interface-simplifications commit b8f8a7f2548ef0de60b0ac5bb24b5e37b4ae30dc Author: Konstantinos Poulios AuthorDate: Sun Dec 18 22:53:01 2022 +0100 Drop runtime handling of int64 lapack and fix lapack type at compile time --- src/gmm/gmm_dense_lu.h | 68 +++--- src/gmm/gmm_lapack_interface.h | 14 - src/gmm/gmm_opt.h | 2 +- 3 files changed, 24 insertions(+), 60 deletions(-) diff --git a/src/gmm/gmm_dense_lu.h b/src/gmm/gmm_dense_lu.h index 33fbbcb1..dd3470e2 100644 --- a/src/gmm/gmm_dense_lu.h +++ b/src/gmm/gmm_dense_lu.h @@ -73,47 +73,11 @@ namespace gmm { - /* ** */ - /* IPVT structure.*/ - /* ** */ - // For compatibility with lapack version with 64 or 32 bit integer. - // Should be replaced by std::vector if 32 bit integer version - // of lapack is not used anymore (and lapack_ipvt_int set to size_type) - - // Do not use iterators of this interface container - class lapack_ipvt : public std::vector { -bool is_int64; -size_type [](size_type i) -{ return std::vector::operator[](i); } -size_type operator[] (size_type i) const -{ return std::vector::operator[](i); } -void begin(void) const {} -void begin(void) {} -void end(void) const {} -void end(void) {} - - public: -void set_to_int32() { is_int64 = false; } -const size_type *pfirst() const -{ return &(*(std::vector::begin())); } -size_type *pfirst() { return &(*(std::vector::begin())); } - -lapack_ipvt(size_type n) : std::vector(n), is_int64(true) {} - -size_type get(size_type i) const { - const size_type *p = pfirst(); - return is_int64 ? p[i] : size_type(((const int *)(p))[i]); -} -void set(size_type i, size_type val) { - size_type *p = pfirst(); - if (is_int64) p[i] = val; else ((int *)(p))[i] = int(val); -} - }; -} - -#include "gmm_opt.h" - -namespace gmm { +#if defined(GMM_USES_LAPACK) || defined(GMM_USES_ATLAS) + typedef std::vector lapack_ipvt; +#else + typedef std::vector lapack_ipvt; +#endif /** LU Factorization of a general (dense) matrix (real or complex). @@ -125,23 +89,24 @@ namespace gmm { The pivot indices in ipvt are indexed starting from 1 so that this is compatible with LAPACK (Fortran). */ - template - size_type lu_factor(DenseMatrix& A, lapack_ipvt& ipvt) { + template + size_type lu_factor(DenseMatrix& A, Pvector& ipvt) { typedef typename linalg_traits::value_type T; +typedef typename linalg_traits::value_type INT; typedef typename number_traits::magnitude_type R; size_type info(0), i, j, jp, M(mat_nrows(A)), N(mat_ncols(A)); size_type NN = std::min(M, N); std::vector c(M), r(N); GMM_ASSERT2(ipvt.size()+1 >= NN, "IPVT too small"); -for (i = 0; i+1 < NN; ++i) ipvt.set(i, i); +for (i = 0; i+1 < NN; ++i) ipvt[i] = INT(i); if (M || N) { for (j = 0; j+1 < NN; ++j) { R max = gmm::abs(A(j,j)); jp = j; for (i = j+1; i < M; ++i) /* find pivot. */ if (gmm::abs(A(i,j)) > max) { jp = i; max = gmm::abs(A(i,j)); } - ipvt.set(j, jp + 1); +ipvt[j] = INT(jp + 1); if (max == R(0)) { info = j + 1; break; } if (jp != j) for (i = 0; i < N; ++i) std::swap(A(jp, i), A(j, i)); @@ -151,7 +116,7 @@ namespace gmm { rank_one_update(sub_matrix(A, sub_interval(j+1, M-j-1), sub_interval(j+1, N-j-1)), c, conjugated(r)); } - ipvt.set(NN-1, NN); + ipvt[NN-1] = INT(NN); } return info; } @@ -165,7 +130,7 @@ namespace gmm { typedef typename linalg_traits::value_type T; copy(b, x); for(size_type i = 0; i < pvector.size(); ++i) { - size_type perm = pvector.get(i)-1; // permutations stored in 1's offset + size_type perm = size_type(pvector[i]-1); // permutations stored in 1's offset if(i != perm) { T aux = x[i]; x[i] = x[perm]; x[perm] = aux; } } /* solve Ax = b -> LUx = b -> Ux = L^-1 b.*/ @@ -193,7 +158,7 @@ namespace gmm { lower_tri_solve(transposed(LU), x, false); upper_tri_solve(transposed(LU), x, true); for(size_type i = pvector.size(); i > 0; --i) { - size_type perm = pvector.get(i-1)-1; // permutations stored in 1's offset + size_type perm = size_type(pvector[i-1]-1); // permutations stored in 1's offset if(i-1 != perm) { T aux = x[i-1]; x[i-1] = x[perm]; x[perm] = aux; } } } @@ -263,11 +228,12 @@ namespace gmm { typename linalg_traits::value_type lu_det(const DenseMatrixLU& LU, const Pvector ) { typedef typename linalg_traits::value_type T; +typedef typename linalg_traits::value_type INT;
[Getfem-commits] (no subject)
branch: master commit f50e3cbab06ca59e87decb0aea6f4fdfa1cf1b4c Author: Konstantinos Poulios AuthorDate: Thu Sep 29 14:15:54 2022 +0200 Allow integration point variables for GWFL assembly in the scripting interface --- interface/src/gf_asm.cc | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/interface/src/gf_asm.cc b/interface/src/gf_asm.cc index a223b15e..1824fe01 100644 --- a/interface/src/gf_asm.cc +++ b/interface/src/gf_asm.cc @@ -488,7 +488,9 @@ static void do_high_level_generic_assembly(mexargs_in& in, mexargs_out& out) { nbdof += mf->nb_dof(); workspace.add_fem_variable(varname, *mf, I, vectors[varname]); } else if (mimd) { - THROW_BADARG("Data defined on integration points can not be a variable"); + gmm::sub_interval I(nbdof, mimd->nb_filtered_index()); + nbdof += mimd->nb_filtered_index(); + workspace.add_im_variable(varname, *mimd, I, vectors[varname]); } else { gmm::sub_interval I(nbdof, U.size()); nbdof += U.size(); @@ -604,7 +606,7 @@ static void do_expression_analysis(mexargs_in& in, mexargs_out& out) { if (mf) workspace.add_fem_variable(varname, *mf, dummy_I, dummy_V); else if (mimd) { -THROW_BADARG("Data defined on integration points can not be a variable"); +workspace.add_im_variable(varname, *mimd, dummy_I, dummy_V); } else workspace.add_fixed_size_variable(varname, dummy_I, dummy_V); }
[Getfem-commits] (no subject)
branch: master commit a499492ecdb32c9b73e83148541d79297b9cdbae Author: Konstantinos Poulios AuthorDate: Thu Sep 29 13:16:47 2022 +0200 Add const attribute to class member function --- src/getfem/getfem_generic_assembly_tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getfem/getfem_generic_assembly_tree.h b/src/getfem/getfem_generic_assembly_tree.h index 9c9ba7ac..4384b9fd 100644 --- a/src/getfem/getfem_generic_assembly_tree.h +++ b/src/getfem/getfem_generic_assembly_tree.h @@ -235,7 +235,7 @@ namespace getfem { void set_sparsity(int sp, size_type q) { sparsity_ = sp; qdim_ = q; } -size_type qdim() { return is_copied ? tensor_copied->qdim() : qdim_; } +size_type qdim() const { return is_copied ? tensor_copied->qdim() : qdim_; } int sparsity() const { return is_copied ? tensor_copied->sparsity() : sparsity_; }
[Getfem-commits] (no subject)
branch: master commit 7a26ce81e8f2587314bf8988daef9885bc928bc5 Author: Yves Renard AuthorDate: Tue Jun 28 15:49:31 2022 +0200 small improvment --- .../python/demo_fluide_structure_interaction.py| 61 +- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/interface/tests/python/demo_fluide_structure_interaction.py b/interface/tests/python/demo_fluide_structure_interaction.py index 3a5281dc..8c10cefa 100644 --- a/interface/tests/python/demo_fluide_structure_interaction.py +++ b/interface/tests/python/demo_fluide_structure_interaction.py @@ -22,7 +22,7 @@ """ Incompressible Navier-Stokes fluid in interaction with a ball in a cavity. - Middle point scheme for the fluid, Verlet scheme for the ball (not the + Middle point scheme for the fluid, Verlet's scheme for the ball (not the best but can of course be changed) This program is used to check that python-getfem is working. This is also @@ -34,12 +34,15 @@ import numpy as np import getfem as gf gf.util('trace level', 0) +version = 1 # 1-without cut-fem and Nitsche's method, + # 2-with cut-fem + # Phisical parameters (à ajuster pour être physique ...) nu = 0.002# cinematic viscosity rho = 1. # fluid density mu = rho * nu # dynamic viscosity g = 9.81 # gravity -in_velocity = 1. # inward velocity at the center bottom +in_velocity = 4. # inward velocity at the center bottom ball_radius = 0.1 ball_mass = 0.032 ball_init_pos = np.array([0., 0.2]) @@ -47,11 +50,11 @@ ball_init_pos = np.array([0., 0.2]) # Discretization parameters dt = 0.01 # Time step T = 40. # Final time -gamma0 = 1E3# Nitsche's method parameter +gamma0 = 1. # Nitsche's method parameter # Geometry and Mesh of the cavity -W1 = 0.1 # -W2 = 0.45 # H2 |_ _| +W1 = 0.05 # +W2 = 0.475# H2 |_ _| W = W1+2.*W2 # || H1 = 0.8 # || H2 = 0.2 # H1 || @@ -148,23 +151,30 @@ md.add_Dirichlet_condition_with_multipliers(mim, "v", mfv, OUT_RG2, "v_out2") md.add_Dirichlet_condition_with_multipliers(mim, "v", mfv, WALL_RG) # Diffusive terms -md.add_nonlinear_term(mim_out, "(1/dt)*rho*(v-v0).Test_v + mu*Grad_v:Grad_Test_v") +if (version == 2): + mim_t = mim_out; +else: + mim_t = mim +md.add_nonlinear_term(mim_t, "(1/dt)*rho*(v-v0).Test_v + mu*Grad_v:Grad_Test_v") # Nonlinear convective term -md.add_nonlinear_term(mim_out, "0.25*rho*((Grad_v+Grad_v0)*(v+v0)).Test_v") +md.add_nonlinear_term(mim_t, "0.25*rho*((Grad_v+Grad_v0)*(v+v0)).Test_v") # Pressure terms -md.add_nonlinear_term(mim_out, "-p*Div_Test_v - 0.5*Test_p*(Div_v+Div_v0)") +md.add_nonlinear_term(mim_t, "-p*Div_Test_v - 0.5*Test_p*(Div_v+Div_v0)") # Gravity term -md.add_nonlinear_term(mim_out, "-f.Test_v") +md.add_nonlinear_term(mim_t, "-f.Test_v") # Small ghost penalty term -md.add_linear_term(mim, "1E-4*(Grad_v-Interpolate(Grad_v, neighbor_element)):(Grad_Test_v-Interpolate(Grad_Test_v, neighbor_element))", INTERNAL_EDGES) -# md.add_linear_term(mim, "1E-7*(p-Interpolate(p, neighbor_element))*(Test_p-Interpolate(Test_p, neighbor_element))", INTERNAL_EDGES) -# Penalty term on internal dofs -Bv = gf.Spmat('empty',nbdofv) -ibv = md.add_explicit_matrix("v", "v", Bv) -Bp = gf.Spmat('empty',nbdofp) -ibp = md.add_explicit_matrix("p", "p", Bp) +if (version == 2): + md.add_linear_term(mim, "1E-6*(Grad_v-Interpolate(Grad_v, neighbor_element)):(Grad_Test_v-Interpolate(Grad_Test_v, neighbor_element))", INTERNAL_EDGES) + # md.add_linear_term(mim, "1E-7*(p-Interpolate(p, neighbor_element))*(Test_p-Interpolate(Test_p, neighbor_element))", INTERNAL_EDGES) + # Penalty term on internal dofs + Bv = gf.Spmat('empty',nbdofv) + ibv = md.add_explicit_matrix("v", "v", Bv) + Bp = gf.Spmat('empty',nbdofp) + ibp = md.add_explicit_matrix("p", "p", Bp) + # md.add_linear_term(mim_in, "1E-4*(v - ball_v).Test_v") # Nitsche's term on the FS interface -md.add_nonlinear_term(mim_bound, "-(mu*Grad_v-p*Id(meshdim))*Normalized(Grad_ls).Test_v + gamma * (v-ball_v).Test_v - (mu*Grad_Test_v)*Normalized(Grad_ls).(v-ball_v)") +if ((version == 1) or (version == 2)): + md.add_nonlinear_term(mim_bound, "-(mu*Grad_v-p*Id(meshdim))*Normalized(Grad_ls).Test_v + gamma * (v-ball_v).Test_v - (mu*Grad_Test_v)*Normalized(Grad_ls).(v-ball_v)") t = 0 step = 0 @@ -188,14 +198,15 @@ while t < T+1e-8: mim_out.adapt() # Penalization of ball internal dofs with no contribution on the boundary - idofv = np.setdiff1d(np.arange(nbdofv), mfv.dof_from_im(mim_out)) - idofp = np.setdiff1d(np.arange(nbdofp), mfp.dof_from_im(mim_out)) - Bv = gf.Spmat('empty', nbdofv) - for i in idofv: Bv.add(i,i,1.) - md.set_private_matrix(ibv, Bv) - Bp = gf.Spmat('empty', nbdofp) - for i in idofp:
[Getfem-commits] (no subject)
branch: master commit ac2c3acbc3ce9f03c403af4cdb01f163fc597814 Merge: 7a26ce81 60d7d962 Author: Yves Renard AuthorDate: Tue Jun 28 15:50:11 2022 +0200 Merge remote-tracking branch 'origin/devel-logari81' src/getfem/getfem_mesh_region.h | 2 +- src/getfem_mesh.cc | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)
[Getfem-commits] (no subject)
branch: devel-logari81 commit d9bcc35a3e49db2d14ec7b9cd4249c6072d9e6cc Merge: d87054dd 20c315d5 Author: Konstantinos Poulios AuthorDate: Fri Jun 24 14:40:02 2022 +0200 Merge branch 'master' into devel-logari81 # Conflicts: # src/getfem/getfem_mesh_region.h # src/getfem_mesh_region.cc .codecov.yml | 25 + .gitignore | 69 +- .travis.yml| 48 + ChangeLog | 697 +--- INSTALL|2 +- Makefile.am|7 +- NEWS | 113 +- README |8 +- autogen.sh |2 +- bin/Makefile.am|6 +- bin/ansys2getfem_mesh |6 +- bin/createmp |6 +- bin/dr2dgnuplot|6 +- bin/extract_doc| 560 +++- bin/fig2eps|6 +- bin/file_dependencies |8 +- bin/makeheadfile | 20 +- bin/mesh_matlab_to_getfem |6 +- bin/rst_to_xml.py | 18 +- bin/sc2dgnuplot|6 +- bin/split_cmdref | 10 +- bin/test_dist |6 +- bin/upload_documentation |6 +- bin/upload_html| 13 +- bin/upload_misc|6 +- bin/upload_version |6 +- bin/word_count |6 +- configure.ac | 1208 +++ contrib/Makefile.am|9 +- contrib/aposteriori/Makefile.am|8 +- contrib/aposteriori/aposteriori.cc | 12 +- contrib/aposteriori/aposteriori.m |2 +- contrib/aposteriori/aposteriori.param |2 +- contrib/aposteriori/aposteriori.pl |2 +- contrib/aposteriori/aposteriori_laplacian.cc | 14 +- contrib/aposteriori/aposteriori_laplacian.param|2 +- contrib/aposteriori/aposteriori_laplacian.pl |2 +- contrib/aposteriori/bimaterial_crack_test.param|2 +- contrib/bimaterial_crack_test/Makefile.am |8 +- .../bimaterial_crack_test/bimaterial_crack_test.cc | 10 +- .../bimaterial_crack_test.param|2 +- .../bimaterial_crack_test/bimaterial_crack_test.pl |2 +- contrib/bimaterial_crack_test/crack.cc |8 +- contrib/bimaterial_crack_test/crack.param |2 +- contrib/bimaterial_crack_test/crack.pl |2 +- .../bimaterial_crack_test/crack_exact_solution.cc |6 +- .../bimaterial_crack_test/crack_exact_solution.h |8 +- contrib/bimaterial_crack_test/getfem_Xfem.cc |6 +- contrib/bimaterial_crack_test/getfem_Xfem.h|6 +- contrib/bimaterial_crack_test/getfem_spider_fem.h |6 +- .../Makefile.am| 13 +- contrib/continuum_mechanics/QLV_viscoelasticity.py | 196 ++ ...ty_finite_strain_linear_hardening_tension_3D.py | 249 ++ ...strain_linear_hardening_tension_axisymmetric.py | 238 ++ ...strain_linear_hardening_tension_plane_strain.py | 236 ++ contrib/crack_plate/Makefile.am|8 +- contrib/crack_plate/crack_bilaplacian.cc |8 +- contrib/crack_plate/crack_bilaplacian.h|8 +- contrib/crack_plate/crack_bilaplacian.param|2 +- contrib/crack_plate/crack_bilaplacian_mixed.param |2 +- contrib/crack_plate/crack_bilaplacian_moment.cc|6 +- contrib/crack_plate/crack_bilaplacian_problem.cc |6 +- contrib/crack_plate/crack_bilaplacian_sif.cc |6 +- .../crack_plate/crack_bilaplacian_singularities.cc |6 +- contrib/crack_plate/crack_bilaplacian_tools.cc |6 +- contrib/crack_plate/crack_mindlin.cc | 10 +- contrib/crack_plate/crack_mindlin.param|2 +- contrib/crack_plate/crack_mindlin.pl |2 +- contrib/crack_plate/crack_panel.cc |8 +- contrib/crack_plate/crack_panel.param |2 +- contrib/crack_plate/demi_plaque.mesh |2 +- contrib/crack_plate/serie.pl |2 +- contrib/delaminated_crack/Makefile.am |8 +- contrib/delaminated_crack/delaminated_crack.cc |8 +- contrib/delaminated_crack/delaminated_crack.param |2 +-
[Getfem-commits] (no subject)
branch: fixmisspell commit ed420f9d75595c8ec67665f7854f079ffd6d5924 Merge: bf38e028 1a8c1c22 Author: Renard Yves AuthorDate: Tue Jun 21 09:02:43 2022 +0200 Merge remote-tracking branch 'origin/master' into fixmisspell .gitignore | 3 + bin/upload_html| 7 - configure.ac | 4 + contrib/Makefile.am| 3 +- contrib/{ => continuum_mechanics}/Makefile.am | 20 +- contrib/continuum_mechanics/QLV_viscoelasticity.py | 196 +++ ...ty_finite_strain_linear_hardening_tension_3D.py | 249 + ...strain_linear_hardening_tension_axisymmetric.py | 238 + ...strain_linear_hardening_tension_plane_strain.py | 236 + .../static_contact_planetary.py| 571 + doc/sphinx/Makefile.am | 5 +- doc/sphinx/source/userdoc/gasm_high.rst| 2 + .../source/userdoc/model_linear_elasticity.rst | 4 +- interface/src/gf_model_get.cc | 17 +- interface/src/gf_model_set.cc | 35 +- interface/src/matlab/gfm_common.c | 4 +- interface/tests/matlab-octave/demo_elasticity.m| 4 +- interface/tests/python/Makefile.am | 2 + interface/tests/python/check_export_vtu.py | 120 - .../python/demo_fluide_structure_interaction.py| 210 .../tests/python/demo_nonlinear_elasticity.py | 15 +- interface/tests/python/demo_truss.py | 108 interface/tests/python/demo_wave_equation.py | 11 + m4/ac_python_devel.m4 | 2 +- src/bgeot_geotrans_inv.cc | 34 +- src/getfem/getfem_export.h | 4 +- src/getfem/getfem_generic_assembly.h | 8 +- src/getfem/getfem_generic_assembly_semantic.h | 6 +- src/getfem/getfem_generic_assembly_tree.h | 2 + src/getfem/getfem_global_function.h| 2 +- src/getfem/getfem_im_list.h| 2 +- src/getfem/getfem_models.h | 15 +- src/getfem/getfem_projected_fem.h | 4 + src/getfem_export.cc | 109 ++-- src/getfem_generic_assembly_compile_and_exec.cc| 101 ++-- src/getfem_generic_assembly_semantic.cc| 182 +-- src/getfem_generic_assembly_tree.cc| 17 +- src/getfem_generic_assembly_workspace.cc | 42 +- src/getfem_model_solvers.cc| 4 +- src/getfem_models.cc | 287 ++- src/getfem_nonlinear_elasticity.cc | 37 +- src/getfem_projected_fem.cc| 25 +- 42 files changed, 2203 insertions(+), 744 deletions(-)
[Getfem-commits] (no subject)
branch: master commit f6e4bf85984fdeeb5952a39c5c0707dbad19ead2 Author: Renard Yves AuthorDate: Fri May 27 17:50:06 2022 +0200 minor modification --- doc/sphinx/source/userdoc/gasm_high.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/sphinx/source/userdoc/gasm_high.rst b/doc/sphinx/source/userdoc/gasm_high.rst index 8d4e9bab..e556fa01 100644 --- a/doc/sphinx/source/userdoc/gasm_high.rst +++ b/doc/sphinx/source/userdoc/gasm_high.rst @@ -750,6 +750,8 @@ Once a transformation is defined in the workspace/model, one can interpolate a v Interpolate(Normal, transname) Interpolate(X, transname) + Interpolate(element_K, transname) + Interpolate(element_B, transname) Interpolate(u, transname) Interpolate(Grad_u, transname) Interpolate(Div_u, transname)
[Getfem-commits] (no subject)
branch: devel-logari81-interpolate-element-matrices commit 5f88efb4b1be63caceb0193d4db7b256cad80726 Author: Konstantinos Poulios AuthorDate: Fri May 27 11:22:29 2022 +0200 Support element_K and element_B interpolates in GWFL --- src/getfem/getfem_generic_assembly_tree.h | 2 ++ src/getfem_generic_assembly_compile_and_exec.cc | 15 + src/getfem_generic_assembly_semantic.cc | 42 - src/getfem_generic_assembly_tree.cc | 14 +++-- 4 files changed, 70 insertions(+), 3 deletions(-) diff --git a/src/getfem/getfem_generic_assembly_tree.h b/src/getfem/getfem_generic_assembly_tree.h index 0d9ad00a..9c9ba7ac 100644 --- a/src/getfem/getfem_generic_assembly_tree.h +++ b/src/getfem/getfem_generic_assembly_tree.h @@ -158,6 +158,8 @@ namespace getfem { GA_NODE_INTERPOLATE_HESS_TEST, GA_NODE_INTERPOLATE_DIVERG_TEST, GA_NODE_INTERPOLATE_X, +GA_NODE_INTERPOLATE_ELT_K, +GA_NODE_INTERPOLATE_ELT_B, GA_NODE_INTERPOLATE_NORMAL, GA_NODE_INTERPOLATE_DERIVATIVE, GA_NODE_ELEMENTARY, diff --git a/src/getfem_generic_assembly_compile_and_exec.cc b/src/getfem_generic_assembly_compile_and_exec.cc index a875de3f..7b1260e5 100644 --- a/src/getfem_generic_assembly_compile_and_exec.cc +++ b/src/getfem_generic_assembly_compile_and_exec.cc @@ -5577,6 +5577,21 @@ namespace getfem { rmi.instructions.push_back(std::move(pgai)); break; +case GA_NODE_INTERPOLATE_ELT_K: +case GA_NODE_INTERPOLATE_ELT_B: + GMM_ASSERT1(!function_case, + "No use of Interpolate is allowed in functions"); + if (pnode->node_type == GA_NODE_INTERPOLATE_ELT_K) +pgai = std::make_shared + (pnode->tensor(), +rmi.interpolate_infos[pnode->interpolate_name].ctx); + else if (pnode->node_type == GA_NODE_INTERPOLATE_ELT_B) +pgai = std::make_shared + (pnode->tensor(), +rmi.interpolate_infos[pnode->interpolate_name].ctx); + rmi.instructions.push_back(std::move(pgai)); + break; + case GA_NODE_SECONDARY_DOMAIN_X: case GA_NODE_SECONDARY_DOMAIN_NORMAL: { diff --git a/src/getfem_generic_assembly_semantic.cc b/src/getfem_generic_assembly_semantic.cc index 6522ba69..a9b5ac31 100644 --- a/src/getfem_generic_assembly_semantic.cc +++ b/src/getfem_generic_assembly_semantic.cc @@ -99,6 +99,8 @@ namespace getfem { pnode->node_type == GA_NODE_INTERPOLATE_HESS_TEST || pnode->node_type == GA_NODE_INTERPOLATE_DIVERG_TEST || pnode->node_type == GA_NODE_INTERPOLATE_X || +pnode->node_type == GA_NODE_INTERPOLATE_ELT_K || +pnode->node_type == GA_NODE_INTERPOLATE_ELT_B || pnode->node_type == GA_NODE_INTERPOLATE_NORMAL) { workspace.interpolate_transformation(pnode->interpolate_name) ->extract_variables(workspace, vars, ignore_data, m, @@ -160,6 +162,8 @@ namespace getfem { if (interpolate_node || interpolate_test_node || pnode->node_type == GA_NODE_INTERPOLATE_X || +pnode->node_type == GA_NODE_INTERPOLATE_ELT_K || +pnode->node_type == GA_NODE_INTERPOLATE_ELT_B || pnode->node_type == GA_NODE_INTERPOLATE_NORMAL) { std::set vars; workspace.interpolate_transformation(pnode->interpolate_name) @@ -381,7 +385,9 @@ namespace getfem { case GA_NODE_XFEM_MINUS_HESS_TEST: case GA_NODE_XFEM_MINUS_DIVERG_TEST: c += 1.33*(1.22+ga_hash_code(pnode->name)); break; -case GA_NODE_INTERPOLATE_X: case GA_NODE_INTERPOLATE_NORMAL: +case GA_NODE_INTERPOLATE_X: +case GA_NODE_INTERPOLATE_ELT_K: case GA_NODE_INTERPOLATE_ELT_B: +case GA_NODE_INTERPOLATE_NORMAL: case GA_NODE_SECONDARY_DOMAIN_X: case GA_NODE_SECONDARY_DOMAIN_NORMAL: c += M_PI*1.33*ga_hash_code(pnode->interpolate_name); break; @@ -450,6 +456,7 @@ namespace getfem { case GA_NODE_RESHAPE: case GA_NODE_CROSS_PRODUCT: case GA_NODE_IND_MOVE_LAST: case GA_NODE_SWAP_IND: case GA_NODE_CONTRACT: case GA_NODE_INTERPOLATE_X: +case GA_NODE_INTERPOLATE_ELT_K: case GA_NODE_INTERPOLATE_ELT_B: case GA_NODE_INTERPOLATE_NORMAL: case GA_NODE_SECONDARY_DOMAIN_X: case GA_NODE_SECONDARY_DOMAIN_NORMAL: pnode->test_function_type = 0; break; @@ -584,6 +591,23 @@ namespace getfem { } break; } + if (pnode->name.compare("element_K") == 0) { +if (pnode->node_type == GA_NODE_INTERPOLATE) { + pnode->node_type = GA_NODE_INTERPOLATE_ELT_K; + if (ref_elt_dim == 1) +pnode->init_vector_tensor(meshdim); + else +pnode->init_matrix_tensor(meshdim, ref_elt_dim); +} +break; + } + if (pnode->name.compare("element_B") == 0) { +if (pnode->node_type == GA_NODE_INTERPOLATE) { + pnode->node_type = GA_NODE_INTERPOLATE_ELT_B; + pnode->init_matrix_tensor(ref_elt_dim, meshdim); +} +break; +
[Getfem-commits] (no subject)
branch: devel-logari81-interpolate-element-matrices commit 4bb1fd6ee30846fa8ea582358de0b39518b8df56 Author: Konstantinos Poulios AuthorDate: Fri May 27 11:20:27 2022 +0200 Avoid passing unused references --- src/getfem_generic_assembly_compile_and_exec.cc | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/getfem_generic_assembly_compile_and_exec.cc b/src/getfem_generic_assembly_compile_and_exec.cc index 14da914f..a875de3f 100644 --- a/src/getfem_generic_assembly_compile_and_exec.cc +++ b/src/getfem_generic_assembly_compile_and_exec.cc @@ -3982,7 +3982,7 @@ namespace getfem { ga_instruction_set::interpolate_info pinterpolate_transformation trans; fem_interpolation_context -base_small_vector +base_small_vector dummy_normal; const mesh size_type papprox_integration @@ -4077,9 +4077,10 @@ namespace getfem { size_type cv; short_type face_num; gmm::clear(inin.Normal); -inin.pt_type = trans->transform(workspace, m, ctx, Normal, &(inin.m), -cv, face_num, P_ref, inin.Normal, -inin.derivatives, false); +inin.pt_type = trans->transform(workspace, m, ctx, dummy_normal, +&(inin.m), cv, face_num, P_ref, +dummy_normal, inin.derivatives, +false); if (inin.pt_type) { if (cv != size_type(-1)) { inin.m->points_of_convex(cv, inin.G); @@ -4111,10 +4112,10 @@ namespace getfem { ga_instruction_neighbor_transformation_call (const ga_workspace , ga_instruction_set::interpolate_info , pinterpolate_transformation t, fem_interpolation_context , - base_small_vector , const mesh , size_type _, - papprox_integration _, bgeot::geotrans_precomp_pool _pool_, + const mesh , size_type _, papprox_integration _, + bgeot::geotrans_precomp_pool _pool_, std::map _corresp_) - : workspace(w), inin(i), trans(t), ctx(ctxx), Normal(No), m(mm), + : workspace(w), inin(i), trans(t), ctx(ctxx), m(mm), ipt(ipt_), pai(pai_), gp_pool(gp_pool_), neighbor_corresp(neighbor_corresp_) {} }; @@ -7257,8 +7258,7 @@ namespace getfem { pgai = std::make_shared (workspace, rmi.interpolate_infos[transname], workspace.interpolate_transformation(transname), gis.ctx, - gis.Normal, m, gis.ipt, gis.pai, gis.gp_pool, - gis.neighbor_corresp); + m, gis.ipt, gis.pai, gis.gp_pool, gis.neighbor_corresp); } else { pgai = std::make_shared (workspace, rmi.interpolate_infos[transname],
[Getfem-commits] (no subject)
branch: devel-tetsuo-fix-aclocal-python commit a105a274e6ec414c0afd0380b0463ba70971fe45 Author: Tetsuo Koyama AuthorDate: Fri Apr 29 19:10:06 2022 +0900 Fix m4/ac_python_devel.m4 for Python3.10 --- m4/ac_python_devel.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m4/ac_python_devel.m4 b/m4/ac_python_devel.m4 index acfb21ef..479aad7e 100644 --- a/m4/ac_python_devel.m4 +++ b/m4/ac_python_devel.m4 @@ -98,7 +98,7 @@ variable to configure. See ``configure --help'' for reference. # AC_MSG_CHECKING([for the distutils Python package]) ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` - if test -z "$ac_distutils_result"; then + if test $? -eq 0; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no])
Re: [Getfem-commits] (no subject)
Dear Kostas, Indeed, it would be better to have a convergence threshold on a relative residual, so your suggestion to scale the convergence threshold with gmm::mat_maxnorm(G) is a very good idea. There is a sharper convergence threshold for the Newton algorithm in invert_nonlin() in order to have a sufficient accuracy to ensure a consistent result of point_in_convex(*pgt, x, res, IN_EPS). With a scaled convergence threshold, this ratio can probably be reduced, but a certain safety factor has to be kept, in my opinion. Best regards, Yves Le 06/04/2022 à 15:20, Konstantinos Poulios a écrit : Dear Yves, Thanks for the feedback. Still the check if the point lies in the convex is combined with a convergence check in the returned value. And this convergence check is less strict than the convergence result returned in the "converged" flag. So we have two different convergence criteria which is a bit confusing. Anyway, at some point, you had reduced the convergence threshold from IN_EPS to IN_EPS/1000 and then you increased it to the current value of IN_EPS/100. Do you remember the motivation for reducing the threshold? The problem is that the current threshold value works well for elements that are 1x1x1 or smaller and they are placed relatively close to the origin of the coordinates. If one needs to work with large elements e.g. 100x100x100, or small elements 1x1x1, which are far away from the origin, let's say at a distance of 1000 from (0,0,0), then the requested precision can never be achieved because of floating point arithmetics. Ideally, the geometric inversion should be done with the real element moved to the origin and normalized, but this would require quite some changes in this function. Another quick fix would be to multiply the convergence threshold with gmm::mat_maxnorm(G). I will think a bit about it. Best regards Kostas On Mon, Apr 4, 2022 at 3:18 PM Renard Yves wrote: Dear Kostas, You are right of course. This change has been done after experiencing some difficulties of convergence for the pyramid element. I think the test (factor < 1.0-IN-EPS) does not change a lot of things but may be it is slightly more robust in some situations, but the change "factor *= 2.0" in "factor = 2.0" is simply a nonsense. Concerning the returned value and the convergence flag it has a different meaning : the inversion is sometimes used for extrapolation outside the element. The returned value indicates only if the point is inside the element (with possibly a successful convergence) and the flag returns whether or not the convergence was successful. This portion of code can probably be improved, yes ! Best regards, Yves Le 03/04/2022 à 11:05, Konstantinos Poulios a écrit : Dear Yves, Another thing that seems illogical to me is that geotrans_inv_convex::invert() returns convergence information, both as a return value and through a boolean argument "converged", with two possibly different values. Shouldn't we simplify this? The reason that I am looking into this is because I am experiencing some geometric inversion failures which are due to too strict checks with IN_EPS/100. But I don't want to just change the threshold value, I would like to improve the robustness of this quite central function in general. Best regards Kostas On Sun, Apr 3, 2022 at 9:36 AM Konstantinos Poulios wrote: Dear Yves, I assume this change image.png was not intentional, right? I cannot imagine why one would use a factor equal to 2. Best regards Kostas On Fri, Jun 15, 2018 at 5:14 PM Yves Renard wrote: branch: master commit 93ea20ccf0e03d841f600d928764a694a0047ab8 Author: Yves Renard Date: Fri Jun 15 16:34:52 2018 +0200 fix a problem in inverting transformation for pyramids --- src/bgeot_geotrans_inv.cc | 10 +++ src/getfem/getfem_generic_assembly_tree.h | 5 src/getfem_generic_assembly_compile_and_exec.cc | 35 ++--- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc index f87e9df..f3fb9d0 100644 --- a/src/bgeot_geotrans_inv.cc +++ b/src/bgeot_geotrans_inv.cc @@ -227,6 +227,7 @@ namespace bgeot } if (res < res0) copy(storage.x_ref, x); + x *= 0.999888783; // For pyramid element to avoid the singularity } @@ -242,12 +243,11 @@ namespace bgeot auto res = vect_norm2(nonlinear_storage.diff); auto res0 =
Re: [Getfem-commits] (no subject)
Dear Yves, Thanks for the feedback. Still the check if the point lies in the convex is combined with a convergence check in the returned value. And this convergence check is less strict than the convergence result returned in the "converged" flag. So we have two different convergence criteria which is a bit confusing. Anyway, at some point, you had reduced the convergence threshold from IN_EPS to IN_EPS/1000 and then you increased it to the current value of IN_EPS/100. Do you remember the motivation for reducing the threshold? The problem is that the current threshold value works well for elements that are 1x1x1 or smaller and they are placed relatively close to the origin of the coordinates. If one needs to work with large elements e.g. 100x100x100, or small elements 1x1x1, which are far away from the origin, let's say at a distance of 1000 from (0,0,0), then the requested precision can never be achieved because of floating point arithmetics. Ideally, the geometric inversion should be done with the real element moved to the origin and normalized, but this would require quite some changes in this function. Another quick fix would be to multiply the convergence threshold with gmm::mat_maxnorm(G). I will think a bit about it. Best regards Kostas On Mon, Apr 4, 2022 at 3:18 PM Renard Yves wrote: > > Dear Kostas, > > > You are right of course. This change has been done after experiencing some > difficulties of convergence for the pyramid element. I think the test > (factor < 1.0-IN-EPS) does not change a lot of things but may be it is > slightly more robust in some situations, but the change "factor *= 2.0" in > "factor = 2.0" is simply a nonsense. > > Concerning the returned value and the convergence flag it has a different > meaning : the inversion is sometimes used for extrapolation outside the > element. The returned value indicates only if the point is inside the > element (with possibly a successful convergence) and the flag returns > whether or not the convergence was successful. > > This portion of code can probably be improved, yes ! > > > Best regards, > > > Yves > > > > Le 03/04/2022 à 11:05, Konstantinos Poulios a écrit : > > Dear Yves, > > Another thing that seems illogical to me is that > geotrans_inv_convex::invert() returns convergence information, both as a > return value and through a boolean argument "converged", with two possibly > different values. Shouldn't we simplify this? > > The reason that I am looking into this is because I am experiencing some > geometric inversion failures which are due to too strict checks with > IN_EPS/100. But I don't want to just change the threshold value, I would > like to improve the robustness of this quite central function in general. > > Best regards > Kostas > > On Sun, Apr 3, 2022 at 9:36 AM Konstantinos Poulios < > logar...@googlemail.com> wrote: > >> Dear Yves, >> >> I assume this change >> [image: image.png] >> was not intentional, right? I cannot imagine why one would use a factor >> equal to 2. >> >> Best regards >> Kostas >> >> On Fri, Jun 15, 2018 at 5:14 PM Yves Renard >> wrote: >> >>> branch: master >>> commit 93ea20ccf0e03d841f600d928764a694a0047ab8 >>> Author: Yves Renard >>> Date: Fri Jun 15 16:34:52 2018 +0200 >>> >>> fix a problem in inverting transformation for pyramids >>> --- >>> src/bgeot_geotrans_inv.cc | 10 +++ >>> src/getfem/getfem_generic_assembly_tree.h | 5 >>> src/getfem_generic_assembly_compile_and_exec.cc | 35 >>> ++--- >>> 3 files changed, 29 insertions(+), 21 deletions(-) >>> >>> diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc >>> index f87e9df..f3fb9d0 100644 >>> --- a/src/bgeot_geotrans_inv.cc >>> +++ b/src/bgeot_geotrans_inv.cc >>> @@ -227,6 +227,7 @@ namespace bgeot >>> } >>> >>> if (res < res0) copy(storage.x_ref, x); >>> +x *= 0.999888783; // For pyramid element to avoid the singularity >>>} >>> >>> >>> @@ -242,12 +243,11 @@ namespace bgeot >>> auto res = vect_norm2(nonlinear_storage.diff); >>> auto res0 = std::numeric_limits::max(); >>> double factor = 1.0; >>> -auto cnt = 0; >>> >>> while (res > IN_EPS) { >>>if ((abs(res - res0) < IN_EPS) || (factor < IN_EPS)) { >>> -converged = false; >>> -return point_in_convex(*pgt, x, res, IN_EPS); >>> + converged = false; >>> + return point_in_convex(*pgt, x, res, IN_EPS); >>>} >>> >>>if (res > res0) { >>> @@ -258,10 +258,9 @@ namespace bgeot >>> factor *= 0.5; >>>} >>>else { >>> -if (factor < 1.0) factor *= 2.0; >>> +if (factor < 1.0-IN_EPS) factor = 2.0; >>> res0 = res; >>>} >>> - >>>pgt->poly_vector_grad(x, pc); >>>update_B(); >>>mult(transposed(B), nonlinear_storage.diff, >>> nonlinear_storage.x_ref); >>> @@ -271,7 +270,6 @@ namespace bgeot >>>add(nonlinear_storage.x_real, scaled(xreal, -1.0), >>>
Re: [Getfem-commits] (no subject)
Dear Kostas, You are right of course. This change has been done after experiencing some difficulties of convergence for the pyramid element. I think the test (factor < 1.0-IN-EPS) does not change a lot of things but may be it is slightly more robust in some situations, but the change "factor *= 2.0" in "factor = 2.0" is simply a nonsense. Concerning the returned value and the convergence flag it has a different meaning : the inversion is sometimes used for extrapolation outside the element. The returned value indicates only if the point is inside the element (with possibly a successful convergence) and the flag returns whether or not the convergence was successful. This portion of code can probably be improved, yes ! Best regards, Yves Le 03/04/2022 à 11:05, Konstantinos Poulios a écrit : Dear Yves, Another thing that seems illogical to me is that geotrans_inv_convex::invert() returns convergence information, both as a return value and through a boolean argument "converged", with two possibly different values. Shouldn't we simplify this? The reason that I am looking into this is because I am experiencing some geometric inversion failures which are due to too strict checks with IN_EPS/100. But I don't want to just change the threshold value, I would like to improve the robustness of this quite central function in general. Best regards Kostas On Sun, Apr 3, 2022 at 9:36 AM Konstantinos Poulios wrote: Dear Yves, I assume this change image.png was not intentional, right? I cannot imagine why one would use a factor equal to 2. Best regards Kostas On Fri, Jun 15, 2018 at 5:14 PM Yves Renard wrote: branch: master commit 93ea20ccf0e03d841f600d928764a694a0047ab8 Author: Yves Renard Date: Fri Jun 15 16:34:52 2018 +0200 fix a problem in inverting transformation for pyramids --- src/bgeot_geotrans_inv.cc | 10 +++ src/getfem/getfem_generic_assembly_tree.h | 5 src/getfem_generic_assembly_compile_and_exec.cc | 35 ++--- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc index f87e9df..f3fb9d0 100644 --- a/src/bgeot_geotrans_inv.cc +++ b/src/bgeot_geotrans_inv.cc @@ -227,6 +227,7 @@ namespace bgeot } if (res < res0) copy(storage.x_ref, x); + x *= 0.999888783; // For pyramid element to avoid the singularity } @@ -242,12 +243,11 @@ namespace bgeot auto res = vect_norm2(nonlinear_storage.diff); auto res0 = std::numeric_limits::max(); double factor = 1.0; - auto cnt = 0; while (res > IN_EPS) { if ((abs(res - res0) < IN_EPS) || (factor < IN_EPS)) { - converged = false; - return point_in_convex(*pgt, x, res, IN_EPS); + converged = false; + return point_in_convex(*pgt, x, res, IN_EPS); } if (res > res0) { @@ -258,10 +258,9 @@ namespace bgeot factor *= 0.5; } else { - if (factor < 1.0) factor *= 2.0; + if (factor < 1.0-IN_EPS) factor = 2.0; res0 = res; } - pgt->poly_vector_grad(x, pc); update_B(); mult(transposed(B), nonlinear_storage.diff, nonlinear_storage.x_ref); @@ -271,7 +270,6 @@ namespace bgeot add(nonlinear_storage.x_real, scaled(xreal, -1.0), nonlinear_storage.diff); res = vect_norm2(nonlinear_storage.diff); - ++cnt; } return point_in_convex(*pgt, x, res, IN_EPS); diff --git a/src/getfem/getfem_generic_assembly_tree.h b/src/getfem/getfem_generic_assembly_tree.h index 9ca3bd9..18682c0 100644 --- a/src/getfem/getfem_generic_assembly_tree.h +++ b/src/getfem/getfem_generic_assembly_tree.h @@ -54,11 +54,6 @@ extern "C"{ } #endif -// #define GA_USES_BLAS // not so interesting, at least for debian blas - -// #define GA_DEBUG_INFO(a) { cout << a << endl; } -#define GA_DEBUG_INFO(a) - #define GA_DEBUG_ASSERT(a, b) GMM_ASSERT1(a, b) // #define GA_DEBUG_ASSERT(a, b) diff --git a/src/getfem_generic_assembly_compile_and_exec.cc b/src/getfem_generic_assembly_compile_and_exec.cc index 3212b25..5a77635 100644 --- a/src/getfem_generic_assembly_compile_and_exec.cc +++ b/src/getfem_generic_assembly_compile_and_exec.cc @@ -25,6 +25,13 @@ #include "getfem/getfem_generic_assembly_compile_and_exec.h"
Re: [Getfem-commits] (no subject)
Dear Yves, Another thing that seems illogical to me is that geotrans_inv_convex::invert() returns convergence information, both as a return value and through a boolean argument "converged", with two possibly different values. Shouldn't we simplify this? The reason that I am looking into this is because I am experiencing some geometric inversion failures which are due to too strict checks with IN_EPS/100. But I don't want to just change the threshold value, I would like to improve the robustness of this quite central function in general. Best regards Kostas On Sun, Apr 3, 2022 at 9:36 AM Konstantinos Poulios wrote: > Dear Yves, > > I assume this change > [image: image.png] > was not intentional, right? I cannot imagine why one would use a factor > equal to 2. > > Best regards > Kostas > > On Fri, Jun 15, 2018 at 5:14 PM Yves Renard > wrote: > >> branch: master >> commit 93ea20ccf0e03d841f600d928764a694a0047ab8 >> Author: Yves Renard >> Date: Fri Jun 15 16:34:52 2018 +0200 >> >> fix a problem in inverting transformation for pyramids >> --- >> src/bgeot_geotrans_inv.cc | 10 +++ >> src/getfem/getfem_generic_assembly_tree.h | 5 >> src/getfem_generic_assembly_compile_and_exec.cc | 35 >> ++--- >> 3 files changed, 29 insertions(+), 21 deletions(-) >> >> diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc >> index f87e9df..f3fb9d0 100644 >> --- a/src/bgeot_geotrans_inv.cc >> +++ b/src/bgeot_geotrans_inv.cc >> @@ -227,6 +227,7 @@ namespace bgeot >> } >> >> if (res < res0) copy(storage.x_ref, x); >> +x *= 0.999888783; // For pyramid element to avoid the singularity >>} >> >> >> @@ -242,12 +243,11 @@ namespace bgeot >> auto res = vect_norm2(nonlinear_storage.diff); >> auto res0 = std::numeric_limits::max(); >> double factor = 1.0; >> -auto cnt = 0; >> >> while (res > IN_EPS) { >>if ((abs(res - res0) < IN_EPS) || (factor < IN_EPS)) { >> -converged = false; >> -return point_in_convex(*pgt, x, res, IN_EPS); >> + converged = false; >> + return point_in_convex(*pgt, x, res, IN_EPS); >>} >> >>if (res > res0) { >> @@ -258,10 +258,9 @@ namespace bgeot >> factor *= 0.5; >>} >>else { >> -if (factor < 1.0) factor *= 2.0; >> +if (factor < 1.0-IN_EPS) factor = 2.0; >> res0 = res; >>} >> - >>pgt->poly_vector_grad(x, pc); >>update_B(); >>mult(transposed(B), nonlinear_storage.diff, >> nonlinear_storage.x_ref); >> @@ -271,7 +270,6 @@ namespace bgeot >>add(nonlinear_storage.x_real, scaled(xreal, -1.0), >>nonlinear_storage.diff); >>res = vect_norm2(nonlinear_storage.diff); >> - ++cnt; >> } >> >> return point_in_convex(*pgt, x, res, IN_EPS); >> diff --git a/src/getfem/getfem_generic_assembly_tree.h >> b/src/getfem/getfem_generic_assembly_tree.h >> index 9ca3bd9..18682c0 100644 >> --- a/src/getfem/getfem_generic_assembly_tree.h >> +++ b/src/getfem/getfem_generic_assembly_tree.h >> @@ -54,11 +54,6 @@ extern "C"{ >> } >> #endif >> >> -// #define GA_USES_BLAS // not so interesting, at least for debian blas >> - >> -// #define GA_DEBUG_INFO(a) { cout << a << endl; } >> -#define GA_DEBUG_INFO(a) >> - >> #define GA_DEBUG_ASSERT(a, b) GMM_ASSERT1(a, b) >> // #define GA_DEBUG_ASSERT(a, b) >> >> diff --git a/src/getfem_generic_assembly_compile_and_exec.cc >> b/src/getfem_generic_assembly_compile_and_exec.cc >> index 3212b25..5a77635 100644 >> --- a/src/getfem_generic_assembly_compile_and_exec.cc >> +++ b/src/getfem_generic_assembly_compile_and_exec.cc >> @@ -25,6 +25,13 @@ >> #include "getfem/getfem_generic_assembly_compile_and_exec.h" >> #include "getfem/getfem_generic_assembly_functions_and_operators.h" >> >> +// #define GA_USES_BLAS // not so interesting, at least for debian blas >> + >> +// #define GA_DEBUG_INFO(a) { cout << a << endl; } >> +#define GA_DEBUG_INFO(a) >> + >> + >> + >> namespace getfem { >> >> >> @@ -766,6 +773,7 @@ namespace getfem { >> virtual int exec() { >>GA_DEBUG_INFO("Instruction: value of test functions"); >>if (qdim == 1) { >> + GA_DEBUG_ASSERT(t.size() == Z.size(), "Wrong size for base >> vector"); >> std::copy(Z.begin(), Z.end(), t.begin()); >>} else { >> size_type target_dim = Z.sizes()[1]; >> @@ -3781,7 +3789,7 @@ namespace getfem { >>if (inin.pt_type) { >> if (cv != size_type(-1)) { >>inin.m->points_of_convex(cv, inin.G); >> - inin.ctx.change((inin.m)->trans_of_convex(cv), >> + inin.ctx.change((inin.m)->trans_of_convex(cv), >>0, P_ref, inin.G, cv, face_num); >>inin.has_ctx = true; >>if (face_num != short_type(-1)) { >> @@ -3826,7 +3834,7 @@ namespace getfem { >> >> virtual int exec() { >>bool cancel_optimization = false; >> -
Re: [Getfem-commits] (no subject)
Dear Yves, I assume this change [image: image.png] was not intentional, right? I cannot imagine why one would use a factor equal to 2. Best regards Kostas On Fri, Jun 15, 2018 at 5:14 PM Yves Renard wrote: > branch: master > commit 93ea20ccf0e03d841f600d928764a694a0047ab8 > Author: Yves Renard > Date: Fri Jun 15 16:34:52 2018 +0200 > > fix a problem in inverting transformation for pyramids > --- > src/bgeot_geotrans_inv.cc | 10 +++ > src/getfem/getfem_generic_assembly_tree.h | 5 > src/getfem_generic_assembly_compile_and_exec.cc | 35 > ++--- > 3 files changed, 29 insertions(+), 21 deletions(-) > > diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc > index f87e9df..f3fb9d0 100644 > --- a/src/bgeot_geotrans_inv.cc > +++ b/src/bgeot_geotrans_inv.cc > @@ -227,6 +227,7 @@ namespace bgeot > } > > if (res < res0) copy(storage.x_ref, x); > +x *= 0.999888783; // For pyramid element to avoid the singularity >} > > > @@ -242,12 +243,11 @@ namespace bgeot > auto res = vect_norm2(nonlinear_storage.diff); > auto res0 = std::numeric_limits::max(); > double factor = 1.0; > -auto cnt = 0; > > while (res > IN_EPS) { >if ((abs(res - res0) < IN_EPS) || (factor < IN_EPS)) { > -converged = false; > -return point_in_convex(*pgt, x, res, IN_EPS); > + converged = false; > + return point_in_convex(*pgt, x, res, IN_EPS); >} > >if (res > res0) { > @@ -258,10 +258,9 @@ namespace bgeot > factor *= 0.5; >} >else { > -if (factor < 1.0) factor *= 2.0; > +if (factor < 1.0-IN_EPS) factor = 2.0; > res0 = res; >} > - >pgt->poly_vector_grad(x, pc); >update_B(); >mult(transposed(B), nonlinear_storage.diff, > nonlinear_storage.x_ref); > @@ -271,7 +270,6 @@ namespace bgeot >add(nonlinear_storage.x_real, scaled(xreal, -1.0), >nonlinear_storage.diff); >res = vect_norm2(nonlinear_storage.diff); > - ++cnt; > } > > return point_in_convex(*pgt, x, res, IN_EPS); > diff --git a/src/getfem/getfem_generic_assembly_tree.h > b/src/getfem/getfem_generic_assembly_tree.h > index 9ca3bd9..18682c0 100644 > --- a/src/getfem/getfem_generic_assembly_tree.h > +++ b/src/getfem/getfem_generic_assembly_tree.h > @@ -54,11 +54,6 @@ extern "C"{ > } > #endif > > -// #define GA_USES_BLAS // not so interesting, at least for debian blas > - > -// #define GA_DEBUG_INFO(a) { cout << a << endl; } > -#define GA_DEBUG_INFO(a) > - > #define GA_DEBUG_ASSERT(a, b) GMM_ASSERT1(a, b) > // #define GA_DEBUG_ASSERT(a, b) > > diff --git a/src/getfem_generic_assembly_compile_and_exec.cc > b/src/getfem_generic_assembly_compile_and_exec.cc > index 3212b25..5a77635 100644 > --- a/src/getfem_generic_assembly_compile_and_exec.cc > +++ b/src/getfem_generic_assembly_compile_and_exec.cc > @@ -25,6 +25,13 @@ > #include "getfem/getfem_generic_assembly_compile_and_exec.h" > #include "getfem/getfem_generic_assembly_functions_and_operators.h" > > +// #define GA_USES_BLAS // not so interesting, at least for debian blas > + > +// #define GA_DEBUG_INFO(a) { cout << a << endl; } > +#define GA_DEBUG_INFO(a) > + > + > + > namespace getfem { > > > @@ -766,6 +773,7 @@ namespace getfem { > virtual int exec() { >GA_DEBUG_INFO("Instruction: value of test functions"); >if (qdim == 1) { > + GA_DEBUG_ASSERT(t.size() == Z.size(), "Wrong size for base > vector"); > std::copy(Z.begin(), Z.end(), t.begin()); >} else { > size_type target_dim = Z.sizes()[1]; > @@ -3781,7 +3789,7 @@ namespace getfem { >if (inin.pt_type) { > if (cv != size_type(-1)) { >inin.m->points_of_convex(cv, inin.G); > - inin.ctx.change((inin.m)->trans_of_convex(cv), > + inin.ctx.change((inin.m)->trans_of_convex(cv), >0, P_ref, inin.G, cv, face_num); >inin.has_ctx = true; >if (face_num != short_type(-1)) { > @@ -3826,7 +3834,7 @@ namespace getfem { > > virtual int exec() { >bool cancel_optimization = false; > - GA_DEBUG_INFO("Instruction: call interpolate transformation"); > + GA_DEBUG_INFO("Instruction: call interpolate neighbour > transformation"); >if (ipt == 0) { > if (!(ctx.have_pgp()) || !pai || pai->is_built_on_the_fly() > || cancel_optimization) { > @@ -3873,7 +3881,7 @@ namespace getfem { >gic.init(m.points_of_convex(adj_face.cv), gpc.pgt2); >size_type first_ind = pai->ind_first_point_on_face(f); >const bgeot::stored_point_tab > - = *(pai->pintegration_points()); > += *(pai->pintegration_points()); >base_matrix G; >m.points_of_convex(cv, G); >fem_interpolation_context ctx_x(gpc.pgt1, 0, spt[0], G, cv, > f); >
[Getfem-commits] (no subject)
branch: devel-tetsuo-fix-error-in-ubuntu20.04 commit bc309aa00b96931f6e18dfbf9c6f9b5a3463e866 Author: Tetsuo Koyama AuthorDate: Mon Aug 9 20:50:34 2021 +0900 Fix the compile error of nbp in ubuntu20.04 --- src/getfem_models.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/getfem_models.cc b/src/getfem_models.cc index c9eedf8..1724175 100644 --- a/src/getfem_models.cc +++ b/src/getfem_models.cc @@ -2337,9 +2337,10 @@ namespace getfem { "Invalid assembly version BUILD_WITH_LIN"); GMM_ASSERT1(version != BUILD_WITH_INTERNAL, "Invalid assembly version BUILD_WITH_INTERNAL"); +int nbp=1; #if GETFEM_PARA_LEVEL > 1 double t_ref = MPI_Wtime(); -int rk=0, nbp=1; +int rk=0; MPI_Comm_rank(MPI_COMM_WORLD, ); MPI_Comm_size(MPI_COMM_WORLD, ); #endif
[Getfem-commits] (no subject)
branch: master commit 066eb8423836f3d2f11ebc0b39e5d2e869d8de8c Author: Konstantinos Poulios AuthorDate: Sun May 23 14:32:50 2021 +0200 Just code style changes --- src/getfem/getfem_models.h | 9 ++-- src/getfem_models.cc | 123 +++-- 2 files changed, 57 insertions(+), 75 deletions(-) diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h index d875ace..9707404 100644 --- a/src/getfem/getfem_models.h +++ b/src/getfem/getfem_models.h @@ -241,9 +241,12 @@ namespace getfem { return 0; } - size_type size() const // Should control that the variable is - // indeed initialized by actualize_sizes() ... - { return is_complex ? complex_value[0].size() : real_value[0].size(); } + size_type size() const { // Should control that the variable is + // indeed initialized by actualize_sizes() ... +return is_complex ? complex_value[0].size() + : real_value[0].size(); + } + inline bool is_enabled() const { return !is_disabled; } void set_size(); }; // struct var_description diff --git a/src/getfem_models.cc b/src/getfem_models.cc index 9e08ad1..fbbd361 100644 --- a/src/getfem_models.cc +++ b/src/getfem_models.cc @@ -247,7 +247,7 @@ namespace getfem { bool model::is_internal_variable(const std::string ) const { if (is_old(name)) return false; const auto _descr = variable_description(name); -return var_descr.is_internal && !var_descr.is_disabled; +return var_descr.is_internal && var_descr.is_enabled(); } bool model::is_affine_dependent_variable(const std::string ) const { @@ -318,7 +318,7 @@ namespace getfem { size_type primary_size = full_size; for (auto & : variables) - if (v.second.is_internal && !v.second.is_disabled) { // is_internal_variable() + if (v.second.is_internal && v.second.is_enabled()) { // is_internal_variable() v.second.I = gmm::sub_interval(full_size, v.second.size()); full_size += v.second.size(); } @@ -2411,166 +2411,145 @@ namespace getfem { if (cplx) { // complex term in complex model if (term.is_matrix_term && (version & BUILD_MATRIX) && !isprevious - && (isg || (!(var1->is_disabled) && !(var2->is_disabled { + && (isg || (var1->is_enabled() && var2->is_enabled( { gmm::add(gmm::scaled(brick.cmatlist[j], alpha), gmm::sub_matrix(cTM, I1, I2)); -if (term.is_symmetric && I1.first() != I2.first()) { +if (term.is_symmetric && I1.first() != I2.first()) gmm::add(gmm::scaled(gmm::transposed(brick.cmatlist[j]), alpha), gmm::sub_matrix(cTM, I2, I1)); -} } if (version & BUILD_RHS) { -if (isg || !(var1->is_disabled)) { - if (brick.pdispatch) { +if (isg || var1->is_enabled()) { + if (brick.pdispatch) for (size_type k = 0; k < brick.nbrhs; ++k) gmm::add(gmm::scaled(brick.cveclist[k][j], brick.coeffs[k]), gmm::sub_vector(crhs, I1)); - } - else { + else gmm::add(gmm::scaled(brick.cveclist[0][j], complex_type(alpha1)), gmm::sub_vector(crhs, I1)); - } } if (term.is_matrix_term && brick.pbr->is_linear() && is_linear()) { - if (var2->is_affine_dependent - && !(var1->is_disabled)) + if (var2->is_affine_dependent && var1->is_enabled()) gmm::mult_add(brick.cmatlist[j], gmm::scaled(var2->affine_complex_value, complex_type(-alpha1)), gmm::sub_vector(crhs, I1)); if (term.is_symmetric && I1.first() != I2.first() - && var1->is_affine_dependent - && !(var2->is_disabled)) { + && var1->is_affine_dependent && var2->is_enabled()) gmm::mult_add(gmm::conjugated(brick.cmatlist[j]), gmm::scaled(var1->affine_complex_value, complex_type(-alpha2)), gmm::sub_vector(crhs, I2)); - } } if (term.is_matrix_term && brick.pbr->is_linear() -&& (!is_linear() || (version & BUILD_WITH_LIN))) { - if (!(var1->is_disabled)) -gmm::mult_add(brick.cmatlist[j], - gmm::scaled(var2->complex_value[0], - complex_type(-alpha1)), - gmm::sub_vector(crhs, I1)); -
[Getfem-commits] (no subject)
branch: master commit c41f5b87f0b2d18e7ec2509d5e2dae1459aac034 Author: Konstantinos Poulios AuthorDate: Sun May 23 14:43:21 2021 +0200 MPI fixes for affine and linear terms in nonlinear model residual --- src/getfem_models.cc | 86 ++-- 1 file changed, 57 insertions(+), 29 deletions(-) diff --git a/src/getfem_models.cc b/src/getfem_models.cc index 40ff2e8..c9eedf8 100644 --- a/src/getfem_models.cc +++ b/src/getfem_models.cc @@ -2339,6 +2339,9 @@ namespace getfem { "Invalid assembly version BUILD_WITH_INTERNAL"); #if GETFEM_PARA_LEVEL > 1 double t_ref = MPI_Wtime(); +int rk=0, nbp=1; +MPI_Comm_rank(MPI_COMM_WORLD, ); +MPI_Comm_size(MPI_COMM_WORLD, ); #endif context_check(); if (act_size_to_be_done) actualize_sizes(); @@ -2419,6 +2422,7 @@ namespace getfem { gmm::sub_matrix(cTM, I2, I1)); } if (version & BUILD_RHS) { +//FIXME MPI_SUM_VECTOR(crhs) if (isg || var1->is_enabled()) { if (brick.pdispatch) for (size_type k = 0; k < brick.nbrhs; ++k) @@ -2479,6 +2483,7 @@ namespace getfem { gmm::sub_matrix(cTM, I2, I1)); } if (version & BUILD_RHS) { +//FIXME MPI_SUM_VECTOR(crhs) if (isg || var1->is_enabled()) { if (brick.pdispatch) for (size_type k = 0; k < brick.nbrhs; ++k) @@ -2539,54 +2544,77 @@ namespace getfem { } if (version & BUILD_RHS) { // Contributions to interval I1 of var1 +auto vec_out1 = gmm::sub_vector(rrhs, I1); if (isg || var1->is_enabled()) { if (brick.pdispatch) for (size_type k = 0; k < brick.nbrhs; ++k) gmm::add(gmm::scaled(brick.rveclist[k][j], brick.coeffs[k]), - gmm::sub_vector(rrhs, I1)); + vec_out1); else gmm::add(gmm::scaled(brick.rveclist[0][j], alpha1), - gmm::sub_vector(rrhs, I1)); + vec_out1); } -if (var1->is_enabled()) { - // Contributions from affine dependent variables - if (term.is_matrix_term && brick.pbr->is_linear() && is_linear() - && var2->is_affine_dependent) -gmm::mult_add(brick.rmatlist[j], - gmm::scaled(var2->affine_real_value, -alpha1), - gmm::sub_vector(rrhs, I1)); - // Contributions from linear terms - if (term.is_matrix_term && brick.pbr->is_linear() - && (!is_linear() || (version & BUILD_WITH_LIN))) -gmm::mult_add(brick.rmatlist[j], - gmm::scaled(var2->real_value[0], -alpha1), - gmm::sub_vector(rrhs, I1)); +if (var1->is_enabled() +&& term.is_matrix_term && brick.pbr->is_linear()) { + bool affine_contrib(is_linear() && var2->is_affine_dependent); + bool linear_contrib(!is_linear() || (version & BUILD_WITH_LIN)); + const auto = brick.rmatlist[j]; + const auto vec_affine2 = gmm::scaled(var2->affine_real_value, + -alpha1); + const auto vec_linear2 = gmm::scaled(var2->real_value[0], + -alpha1); + if (nbp > 1) { +model_real_plain_vector vec_tmp1(I1.size(), 0.); +if (affine_contrib) // Affine dependent variable contribution + gmm::mult(matj, vec_affine2, vec_tmp1); +if (linear_contrib) // Linear term contribution + gmm::mult_add(matj, vec_linear2, vec_tmp1); +MPI_SUM_VECTOR(vec_tmp1); +gmm::add(vec_tmp1, vec_out1); + } else { // nbp == 1 +if (affine_contrib) // Affine dependent variable contribution + gmm::mult_add(matj, vec_affine2, vec_out1); +if (linear_contrib) // Linear term contribution + gmm::mult_add(matj, vec_linear2, vec_out1); + } } // Contributions to interval I2 of var2 due to symmetric terms if (term.is_symmetric && I1.first() != I2.first() && var2->is_enabled()) { + auto vec_out2 = gmm::sub_vector(rrhs, I2); if (brick.pdispatch) for (size_type k = 0; k < brick.nbrhs; ++k) gmm::add(gmm::scaled(brick.rveclist_sym[k][j], brick.coeffs[k]), - gmm::sub_vector(rrhs, I2)); + vec_out2); else
[Getfem-commits] (no subject)
branch: master commit afd2d94d80b702a128a5c577b631a2c906b4899d Author: Konstantinos Poulios AuthorDate: Sun May 23 14:38:53 2021 +0200 MPI fixes form model residual assembly --- src/getfem_models.cc | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/getfem_models.cc b/src/getfem_models.cc index fbbd361..40ff2e8 100644 --- a/src/getfem_models.cc +++ b/src/getfem_models.cc @@ -2845,7 +2845,9 @@ namespace getfem { } if (version & BUILD_RHS) { - approx_external_load_ = MPI_SUM_SCALAR(approx_external_load_); + // some contributions are added only in the master process + // send the correct result to all other processes + MPI_BCAST0_SCALAR(approx_external_load_); } #if GETFEM_PARA_LEVEL > 1 @@ -3281,10 +3283,14 @@ namespace getfem { gmm::clear(vecl[0]); if (expr.size()) { +const mesh_im = *mims[0]; +mesh_region rg(region); +mim.linked_mesh().intersect_with_mpi_region(rg); + // reenables disabled variables ga_workspace workspace(md, ga_workspace::inherit::ALL); GMM_TRACE2(name << ": generic source term assembly"); -workspace.add_expression(expr, *(mims[0]), region, 1, secondary_domain); +workspace.add_expression(expr, mim, rg, 1, secondary_domain); workspace.assembly(1); const auto =workspace.assembled_vector(); for (size_type i = 0; i < vl_test1.size(); ++i) {
[Getfem-commits] (no subject)
branch: mpi-fixes commit 98925a43e41a9fd15c7369f7d7811cff892fe9cf Author: Konstantinos Poulios AuthorDate: Sun May 23 14:32:50 2021 +0200 Just code style changes --- src/getfem/getfem_models.h | 9 ++-- src/getfem_models.cc | 123 +++-- 2 files changed, 57 insertions(+), 75 deletions(-) diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h index d875ace..9707404 100644 --- a/src/getfem/getfem_models.h +++ b/src/getfem/getfem_models.h @@ -241,9 +241,12 @@ namespace getfem { return 0; } - size_type size() const // Should control that the variable is - // indeed initialized by actualize_sizes() ... - { return is_complex ? complex_value[0].size() : real_value[0].size(); } + size_type size() const { // Should control that the variable is + // indeed initialized by actualize_sizes() ... +return is_complex ? complex_value[0].size() + : real_value[0].size(); + } + inline bool is_enabled() const { return !is_disabled; } void set_size(); }; // struct var_description diff --git a/src/getfem_models.cc b/src/getfem_models.cc index 9e08ad1..fbbd361 100644 --- a/src/getfem_models.cc +++ b/src/getfem_models.cc @@ -247,7 +247,7 @@ namespace getfem { bool model::is_internal_variable(const std::string ) const { if (is_old(name)) return false; const auto _descr = variable_description(name); -return var_descr.is_internal && !var_descr.is_disabled; +return var_descr.is_internal && var_descr.is_enabled(); } bool model::is_affine_dependent_variable(const std::string ) const { @@ -318,7 +318,7 @@ namespace getfem { size_type primary_size = full_size; for (auto & : variables) - if (v.second.is_internal && !v.second.is_disabled) { // is_internal_variable() + if (v.second.is_internal && v.second.is_enabled()) { // is_internal_variable() v.second.I = gmm::sub_interval(full_size, v.second.size()); full_size += v.second.size(); } @@ -2411,166 +2411,145 @@ namespace getfem { if (cplx) { // complex term in complex model if (term.is_matrix_term && (version & BUILD_MATRIX) && !isprevious - && (isg || (!(var1->is_disabled) && !(var2->is_disabled { + && (isg || (var1->is_enabled() && var2->is_enabled( { gmm::add(gmm::scaled(brick.cmatlist[j], alpha), gmm::sub_matrix(cTM, I1, I2)); -if (term.is_symmetric && I1.first() != I2.first()) { +if (term.is_symmetric && I1.first() != I2.first()) gmm::add(gmm::scaled(gmm::transposed(brick.cmatlist[j]), alpha), gmm::sub_matrix(cTM, I2, I1)); -} } if (version & BUILD_RHS) { -if (isg || !(var1->is_disabled)) { - if (brick.pdispatch) { +if (isg || var1->is_enabled()) { + if (brick.pdispatch) for (size_type k = 0; k < brick.nbrhs; ++k) gmm::add(gmm::scaled(brick.cveclist[k][j], brick.coeffs[k]), gmm::sub_vector(crhs, I1)); - } - else { + else gmm::add(gmm::scaled(brick.cveclist[0][j], complex_type(alpha1)), gmm::sub_vector(crhs, I1)); - } } if (term.is_matrix_term && brick.pbr->is_linear() && is_linear()) { - if (var2->is_affine_dependent - && !(var1->is_disabled)) + if (var2->is_affine_dependent && var1->is_enabled()) gmm::mult_add(brick.cmatlist[j], gmm::scaled(var2->affine_complex_value, complex_type(-alpha1)), gmm::sub_vector(crhs, I1)); if (term.is_symmetric && I1.first() != I2.first() - && var1->is_affine_dependent - && !(var2->is_disabled)) { + && var1->is_affine_dependent && var2->is_enabled()) gmm::mult_add(gmm::conjugated(brick.cmatlist[j]), gmm::scaled(var1->affine_complex_value, complex_type(-alpha2)), gmm::sub_vector(crhs, I2)); - } } if (term.is_matrix_term && brick.pbr->is_linear() -&& (!is_linear() || (version & BUILD_WITH_LIN))) { - if (!(var1->is_disabled)) -gmm::mult_add(brick.cmatlist[j], - gmm::scaled(var2->complex_value[0], - complex_type(-alpha1)), - gmm::sub_vector(crhs, I1));
[Getfem-commits] (no subject)
branch: devel-tetsuo-add_lumped_mass_python_interface commit 3d5dacd71337fe0b55bfc64090298bf00dd3402a Author: Tetsuo Koyama AuthorDate: Sat Mar 27 14:37:53 2021 +0900 Add test --- interface/tests/python/demo_wave_equation.py | 11 +++ 1 file changed, 11 insertions(+) diff --git a/interface/tests/python/demo_wave_equation.py b/interface/tests/python/demo_wave_equation.py index 5a5e437..8d35ffc 100644 --- a/interface/tests/python/demo_wave_equation.py +++ b/interface/tests/python/demo_wave_equation.py @@ -57,10 +57,13 @@ V0 = 0.*U0 md=gf.Model('real'); md.add_fem_variable('u', mf); md.add_fem_variable('u1', mf); +md.add_fem_variable('u2', mf); md.add_Laplacian_brick(mim, 'u'); md.add_Laplacian_brick(mim, 'u1'); +md.add_Laplacian_brick(mim, 'u2'); md.add_Dirichlet_condition_with_multipliers(mim, 'u', mf, 1); md.add_Dirichlet_condition_with_multipliers(mim, 'u1', mf, 1); +md.add_Dirichlet_condition_with_multipliers(mim, 'u2', mf, 1); # md.add_Dirichlet_condition_with_penalization(mim, 'u', 1E9, 1); # md.add_Dirichlet_condition_with_simplification('u', 1); @@ -74,8 +77,10 @@ gamma = 0.5; md.add_Newmark_scheme('u', beta, gamma) md.add_Houbolt_scheme('u1') +md.add_Newmark_scheme('u2', beta, gamma) md.add_mass_brick(mim, 'Dot2_u') md.add_mass_brick(mim, 'Dot2_u1') +md.add_lumped_mass_brick_for_first_order(mim, 'Dot2_u2') md.set_time_step(dt) ## Initial data. @@ -84,6 +89,8 @@ md.set_variable('Previous_Dot_u', V0) md.set_variable('Previous_u1', U0) md.set_variable('Previous2_u1', U0) md.set_variable('Previous3_u1', U0) +md.set_variable('Previous_u2', U0) +md.set_variable('Previous_Dot_u2', V0) ## Initialisation of the acceleration 'Previous_Dot2_u' md.perform_init_time_derivative(dt/2.) @@ -116,6 +123,10 @@ for t in np.arange(0.,T,dt): V = md.variable('Dot_u1') A = md.variable('Dot2_u1') + U = md.variable('u2') + V = md.variable('Dot_u2') + A = md.variable('Dot2_u2') + n += 1 md.shift_variables_for_time_integration()
[Getfem-commits] (no subject)
branch: devel-tetsuo-add_lumped_mass_python_interface commit 675e60b72f31f0f765222fddc474ed496e4a5349 Author: Tetsuo Koyama AuthorDate: Fri Apr 9 18:10:57 2021 +0900 Add add lumped mass brick for first order --- interface/src/gf_model_set.cc | 23 +++ 1 file changed, 23 insertions(+) diff --git a/interface/src/gf_model_set.cc b/interface/src/gf_model_set.cc index 288572d..346c570 100644 --- a/interface/src/gf_model_set.cc +++ b/interface/src/gf_model_set.cc @@ -2816,6 +2816,29 @@ void gf_model_set(getfemint::mexargs_in& m_in, ); +/*@SET ind = ('add lumped mass brick for first order', @tmim mim, @str varname[, @str dataexpr_rho[, @int region]]) + Add lumped mass for first order term to the model relatively to the variable `varname`. + If specified, the data `dataexpr_rho` is the + density (1 if omitted). `region` is an optional mesh region on + which the term is added. If it is not specified, it + is added on the whole mesh. Return the brick index in the model.@*/ +sub_command + ("add lumped mass brick for first order", 2, 4, 0, 1, + getfem::mesh_im *mim = to_meshim_object(in.pop()); + std::string varname = in.pop().to_string(); + std::string dataname_rho; + if (in.remaining()) dataname_rho = in.pop().to_string(); + size_type region = size_type(-1); + if (in.remaining()) region = in.pop().to_integer(); + size_type ind + = getfem::add_lumped_mass_brick_for_first_order + (*md, *mim, varname, dataname_rho, region) + + config::base_index(); + workspace().set_dependence(md, mim); + out.pop().from_integer(int(ind)); + ); + + /*@SET ('shift variables for time integration') Function used to shift the variables of a model to the data corresponding of ther value on the previous time step for time
[Getfem-commits] (no subject)
branch: devel-tetsuo-add_lumped_mass_python_interface_squash commit a76e73d0c3033eac71e08e33427d18b1a1b18435 Author: Tetsuo Koyama AuthorDate: Fri Apr 9 18:17:26 2021 +0900 Add lumped mass python interface --- interface/src/gf_model_set.cc| 23 +++ interface/tests/python/demo_wave_equation.py | 11 +++ 2 files changed, 34 insertions(+) diff --git a/interface/src/gf_model_set.cc b/interface/src/gf_model_set.cc index 288572d..346c570 100644 --- a/interface/src/gf_model_set.cc +++ b/interface/src/gf_model_set.cc @@ -2816,6 +2816,29 @@ void gf_model_set(getfemint::mexargs_in& m_in, ); +/*@SET ind = ('add lumped mass brick for first order', @tmim mim, @str varname[, @str dataexpr_rho[, @int region]]) + Add lumped mass for first order term to the model relatively to the variable `varname`. + If specified, the data `dataexpr_rho` is the + density (1 if omitted). `region` is an optional mesh region on + which the term is added. If it is not specified, it + is added on the whole mesh. Return the brick index in the model.@*/ +sub_command + ("add lumped mass brick for first order", 2, 4, 0, 1, + getfem::mesh_im *mim = to_meshim_object(in.pop()); + std::string varname = in.pop().to_string(); + std::string dataname_rho; + if (in.remaining()) dataname_rho = in.pop().to_string(); + size_type region = size_type(-1); + if (in.remaining()) region = in.pop().to_integer(); + size_type ind + = getfem::add_lumped_mass_brick_for_first_order + (*md, *mim, varname, dataname_rho, region) + + config::base_index(); + workspace().set_dependence(md, mim); + out.pop().from_integer(int(ind)); + ); + + /*@SET ('shift variables for time integration') Function used to shift the variables of a model to the data corresponding of ther value on the previous time step for time diff --git a/interface/tests/python/demo_wave_equation.py b/interface/tests/python/demo_wave_equation.py index 5a5e437..8d35ffc 100644 --- a/interface/tests/python/demo_wave_equation.py +++ b/interface/tests/python/demo_wave_equation.py @@ -57,10 +57,13 @@ V0 = 0.*U0 md=gf.Model('real'); md.add_fem_variable('u', mf); md.add_fem_variable('u1', mf); +md.add_fem_variable('u2', mf); md.add_Laplacian_brick(mim, 'u'); md.add_Laplacian_brick(mim, 'u1'); +md.add_Laplacian_brick(mim, 'u2'); md.add_Dirichlet_condition_with_multipliers(mim, 'u', mf, 1); md.add_Dirichlet_condition_with_multipliers(mim, 'u1', mf, 1); +md.add_Dirichlet_condition_with_multipliers(mim, 'u2', mf, 1); # md.add_Dirichlet_condition_with_penalization(mim, 'u', 1E9, 1); # md.add_Dirichlet_condition_with_simplification('u', 1); @@ -74,8 +77,10 @@ gamma = 0.5; md.add_Newmark_scheme('u', beta, gamma) md.add_Houbolt_scheme('u1') +md.add_Newmark_scheme('u2', beta, gamma) md.add_mass_brick(mim, 'Dot2_u') md.add_mass_brick(mim, 'Dot2_u1') +md.add_lumped_mass_brick_for_first_order(mim, 'Dot2_u2') md.set_time_step(dt) ## Initial data. @@ -84,6 +89,8 @@ md.set_variable('Previous_Dot_u', V0) md.set_variable('Previous_u1', U0) md.set_variable('Previous2_u1', U0) md.set_variable('Previous3_u1', U0) +md.set_variable('Previous_u2', U0) +md.set_variable('Previous_Dot_u2', V0) ## Initialisation of the acceleration 'Previous_Dot2_u' md.perform_init_time_derivative(dt/2.) @@ -116,6 +123,10 @@ for t in np.arange(0.,T,dt): V = md.variable('Dot_u1') A = md.variable('Dot2_u1') + U = md.variable('u2') + V = md.variable('Dot_u2') + A = md.variable('Dot2_u2') + n += 1 md.shift_variables_for_time_integration()
Re: [Getfem-commits] (no subject)
Dear Tetsuo, Thank you for this additional test program on a truss problem. I integrated it to the master branch. Best regards, Yves On 21/03/2021 05:43, Tetsuo Koyama wrote: branch: devel-tetsuo-add-truss-element-squash commit 9ac4e7f2fecd7cd6bdf1a390a12d7902ca6d4771 Author: Tetsuo Koyama AuthorDate: Sun Mar 21 13:41:38 2021 +0900 Add truss problem example --- interface/tests/python/Makefile.am | 2 + interface/tests/python/demo_truss.py | 108 +++ 2 files changed, 110 insertions(+) diff --git a/interface/tests/python/Makefile.am b/interface/tests/python/Makefile.am index 813753e..c17f64b 100644 --- a/interface/tests/python/Makefile.am +++ b/interface/tests/python/Makefile.am @@ -43,6 +43,7 @@ EXTRA_DIST= \ demo_plasticity.py \ demo_plate.py \ demo_unit_disk.py \ +demo_truss.py \ demo_static_contact.py \ demo_dynamic_contact_1D.py \ demo_Mindlin_Reissner_plate.py \ @@ -71,6 +72,7 @@ TESTS = \ check_asm.py\ check_secondary_domain.py \ check_mixed_mesh.py \ + demo_truss.py \ demo_wave.py\ demo_wave_equation.py \ demo_laplacian.py \ diff --git a/interface/tests/python/demo_truss.py b/interface/tests/python/demo_truss.py new file mode 100644 index 000..2f5fb07 --- /dev/null +++ b/interface/tests/python/demo_truss.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Python GetFEM interface +# +# Copyright (C) 2021-2021 Tetsuo Koyama. +# +# 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 2.1 of the License, 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 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. +# + +""" 1D Truss problem test + + This program is used to check that python-getfem is working. This is + also a good example of use of python-getfem.. + + |-> x +//|EA |-> u0 +//|-+-+=> P +//| + |<---L--->|<---L--->| + + Exact solution of displacement u0 is u0 = (P*x)/(E*A). + + $Id$ +""" +import getfem as gf +import numpy as np + +# +# Physical parameters +# +E = 21E6 # Young Modulus (N/cm^2) +A = 9000.0 # Section Area (cm^2) +L = 2000.0 # Length of element (cm) +P = 200.0 # Force (N) + +# +# Numerical parameters +# + +elements_degree = 1 # Degree of the finite element methods + +# +# Mesh generation. +# +mesh = gf.Mesh("cartesian", np.array([0, L, 2*L])) + +# +# Boundary selection +# + +fleft = mesh.outer_faces_with_direction(v=[-1.0], angle=0.01) +fright = mesh.outer_faces_with_direction(v=[+1.0], angle=0.01) +NEUMANN_BOUNDARY = 1 +DIRICHLET_BOUNDARY = 2 +mesh.set_region(NEUMANN_BOUNDARY, fright) +mesh.set_region(DIRICHLET_BOUNDARY, fleft) +# +# Definition of finite elements methods and integration method +# + +mfu = gf.MeshFem(mesh, 1) # Finite element for the elastic displacement +mfu.set_classical_fem(elements_degree) +mim = gf.MeshIm(mesh, elements_degree*2) # Integration method + +# +# Model definition +# + +md = gf.Model("real") +md.add_fem_variable("u", mfu) # Displacement of the structure + +# Truss problem +md.add_initialized_data("D", [E*A]) +md.add_generic_elliptic_brick(mim, "u", "D") + +F = mfu.eval(str(P)) +md.add_initialized_fem_data("ForceData", mfu, F) +md.add_source_term_brick(mim, "u", "ForceData", NEUMANN_BOUNDARY) + +md.add_Dirichlet_condition_with_multipliers(mim, "u", elements_degree - 1, DIRICHLET_BOUNDARY) + +# +# Model solve +# +md.solve() + + +# +# Solution export +# +U = md.variable("u") + +# Interpolate the exact solution (Assuming mfu is a Lagrange fem) +Ue = mfu.eval("(" + str(P) + "*x)/(" + str(E) +"*" + str(A) + ")") +assert np.allclose(U, Ue) + -- Yves Renard (yves.ren...@insa-lyon.fr) tel : (33)
[Getfem-commits] (no subject)
branch: devel-tetsuo-add-truss-element-squash commit 9ac4e7f2fecd7cd6bdf1a390a12d7902ca6d4771 Author: Tetsuo Koyama AuthorDate: Sun Mar 21 13:41:38 2021 +0900 Add truss problem example --- interface/tests/python/Makefile.am | 2 + interface/tests/python/demo_truss.py | 108 +++ 2 files changed, 110 insertions(+) diff --git a/interface/tests/python/Makefile.am b/interface/tests/python/Makefile.am index 813753e..c17f64b 100644 --- a/interface/tests/python/Makefile.am +++ b/interface/tests/python/Makefile.am @@ -43,6 +43,7 @@ EXTRA_DIST= \ demo_plasticity.py \ demo_plate.py \ demo_unit_disk.py \ +demo_truss.py \ demo_static_contact.py \ demo_dynamic_contact_1D.py \ demo_Mindlin_Reissner_plate.py \ @@ -71,6 +72,7 @@ TESTS = \ check_asm.py\ check_secondary_domain.py \ check_mixed_mesh.py \ + demo_truss.py \ demo_wave.py\ demo_wave_equation.py \ demo_laplacian.py \ diff --git a/interface/tests/python/demo_truss.py b/interface/tests/python/demo_truss.py new file mode 100644 index 000..2f5fb07 --- /dev/null +++ b/interface/tests/python/demo_truss.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Python GetFEM interface +# +# Copyright (C) 2021-2021 Tetsuo Koyama. +# +# 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 2.1 of the License, 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 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. +# + +""" 1D Truss problem test + + This program is used to check that python-getfem is working. This is + also a good example of use of python-getfem.. + + |-> x +//|EA |-> u0 +//|-+-+=> P +//| + |<---L--->|<---L--->| + + Exact solution of displacement u0 is u0 = (P*x)/(E*A). + + $Id$ +""" +import getfem as gf +import numpy as np + +# +# Physical parameters +# +E = 21E6 # Young Modulus (N/cm^2) +A = 9000.0 # Section Area (cm^2) +L = 2000.0 # Length of element (cm) +P = 200.0 # Force (N) + +# +# Numerical parameters +# + +elements_degree = 1 # Degree of the finite element methods + +# +# Mesh generation. +# +mesh = gf.Mesh("cartesian", np.array([0, L, 2*L])) + +# +# Boundary selection +# + +fleft = mesh.outer_faces_with_direction(v=[-1.0], angle=0.01) +fright = mesh.outer_faces_with_direction(v=[+1.0], angle=0.01) +NEUMANN_BOUNDARY = 1 +DIRICHLET_BOUNDARY = 2 +mesh.set_region(NEUMANN_BOUNDARY, fright) +mesh.set_region(DIRICHLET_BOUNDARY, fleft) +# +# Definition of finite elements methods and integration method +# + +mfu = gf.MeshFem(mesh, 1) # Finite element for the elastic displacement +mfu.set_classical_fem(elements_degree) +mim = gf.MeshIm(mesh, elements_degree*2) # Integration method + +# +# Model definition +# + +md = gf.Model("real") +md.add_fem_variable("u", mfu) # Displacement of the structure + +# Truss problem +md.add_initialized_data("D", [E*A]) +md.add_generic_elliptic_brick(mim, "u", "D") + +F = mfu.eval(str(P)) +md.add_initialized_fem_data("ForceData", mfu, F) +md.add_source_term_brick(mim, "u", "ForceData", NEUMANN_BOUNDARY) + +md.add_Dirichlet_condition_with_multipliers(mim, "u", elements_degree - 1, DIRICHLET_BOUNDARY) + +# +# Model solve +# +md.solve() + + +# +# Solution export +# +U = md.variable("u") + +# Interpolate the exact solution (Assuming mfu is a Lagrange fem) +Ue = mfu.eval("(" + str(P) + "*x)/(" + str(E) +"*" + str(A) + ")") +assert np.allclose(U, Ue) +
[Getfem-commits] (no subject)
branch: touched_region_for_projected_fem commit 9c0058d2398da11a148029e0b4fad00d1d853e00 Author: Andriy Andreykiv AuthorDate: Thu Mar 4 13:57:21 2021 +0100 less auto --- src/getfem_projected_fem.cc | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/getfem_projected_fem.cc b/src/getfem_projected_fem.cc index c83861d..382f86c 100644 --- a/src/getfem_projected_fem.cc +++ b/src/getfem_projected_fem.cc @@ -799,12 +799,12 @@ namespace getfem { context_check(); mesh_region touched_region; for (mr_visitor v(rg_target); !v.finished(); ++v) { - auto pim = mim_target.int_method_of_element(v.cv()); - auto pai = pim->approx_method(); - auto start_pt = v.is_face() ? pai->ind_first_point_on_face(v.f()) : 0; - auto nb_pts = v.is_face() ? pai->nb_points_on_face(v.f()) -: pai->nb_points_on_convex(); - auto isProjectedOn = false; + pintegration_method pim = mim_target.int_method_of_element(v.cv()); + papprox_integration pai = pim->approx_method(); + size_type start_pt = v.is_face() ? pai->ind_first_point_on_face(v.f()) : 0; + size_type nb_pts = v.is_face() ? pai->nb_points_on_face(v.f()) + : pai->nb_points_on_convex(); + bool isProjectedOn = false; for (size_type ip = 0; ip != nb_pts; ++ip) { auto _data = elements.at(v.cv()).gausspt[start_pt + ip]; if (proj_data.iflags) {
[Getfem-commits] (no subject)
branch: touched_region_for_projected_fem commit 3c95fe39eb8b1a1b4de5ce6126729a02c2b1528e Author: Andriy Andreykiv AuthorDate: Thu Mar 4 13:58:21 2021 +0100 comment spelling --- src/getfem/getfem_projected_fem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getfem/getfem_projected_fem.h b/src/getfem/getfem_projected_fem.h index 8eb1378..c08b944 100644 --- a/src/getfem/getfem_projected_fem.h +++ b/src/getfem/getfem_projected_fem.h @@ -143,7 +143,7 @@ namespace getfem { dal::bit_vector projected_convexes() const; /** faces and convexes from the target region - * that contain at least one guass point that is projected by the source */ + * that contain at least one Gauss point that is projected by the source */ mesh_region touched_target_region() const; /** return the min/max/mean number of gauss points in the convexes
[Getfem-commits] (no subject)
branch: touched_region_for_projected_fem commit e13a0827f7bddb7c557cb3f8506ba6e96496da4d Author: Andriy Andreykiv AuthorDate: Wed Mar 3 20:16:22 2021 +0100 projected_fem::touched_target_region() --- src/getfem/getfem_projected_fem.h | 4 src/getfem_projected_fem.cc | 22 ++ 2 files changed, 26 insertions(+) diff --git a/src/getfem/getfem_projected_fem.h b/src/getfem/getfem_projected_fem.h index ae216b9..8eb1378 100644 --- a/src/getfem/getfem_projected_fem.h +++ b/src/getfem/getfem_projected_fem.h @@ -141,6 +141,10 @@ namespace getfem { /** return the list of convexes of the projected mesh_fem which * contain at least one gauss point (should be all convexes)! */ dal::bit_vector projected_convexes() const; + +/** faces and convexes from the target region + * that contain at least one guass point that is projected by the source */ +mesh_region touched_target_region() const; /** return the min/max/mean number of gauss points in the convexes * of the projected mesh_fem */ diff --git a/src/getfem_projected_fem.cc b/src/getfem_projected_fem.cc index fa73548..c83861d 100644 --- a/src/getfem_projected_fem.cc +++ b/src/getfem_projected_fem.cc @@ -795,6 +795,28 @@ namespace getfem { return bv; } + mesh_region projected_fem::touched_target_region() const { +context_check(); +mesh_region touched_region; +for (mr_visitor v(rg_target); !v.finished(); ++v) { + auto pim = mim_target.int_method_of_element(v.cv()); + auto pai = pim->approx_method(); + auto start_pt = v.is_face() ? pai->ind_first_point_on_face(v.f()) : 0; + auto nb_pts = v.is_face() ? pai->nb_points_on_face(v.f()) +: pai->nb_points_on_convex(); + auto isProjectedOn = false; + for (size_type ip = 0; ip != nb_pts; ++ip) { +auto _data = elements.at(v.cv()).gausspt[start_pt + ip]; +if (proj_data.iflags) { + isProjectedOn = true; + break; +} + } + if (isProjectedOn) touched_region.add(v.cv(), v.f()); +} +return touched_region; + } + void projected_fem::gauss_pts_stats(unsigned , unsigned , scalar_type ) const { std::vector v(mf_source.linked_mesh().nb_allocated_convex());
[Getfem-commits] (no subject)
branch: master commit 44045b410513fd4b493db8dc6b861e6fc7b82a4f Author: Yves Renard AuthorDate: Tue Feb 16 09:56:13 2021 +0100 minor change --- .gitignore| 1 + src/bgeot_geotrans_inv.cc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ad82f14..5ab869d 100644 --- a/.gitignore +++ b/.gitignore @@ -171,6 +171,7 @@ Makefile /interface/src/scilab/src/c/loader.sce /interface/src/scilab/unloader.sce /interface/tests/python/*.pyc +/interface/tests/python/*.vtu /doc/sphinx/tools/ /doc/sphinx/source/scilab/cmdref* /doc/sphinx/source/python/cmdref* diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc index 88eb6b4..3f0ff7e 100644 --- a/src/bgeot_geotrans_inv.cc +++ b/src/bgeot_geotrans_inv.cc @@ -226,8 +226,8 @@ namespace bgeot double factor = 1.0; base_node x0_real(N); -while (res > IN_EPS/1000.) { - if ((gmm::abs(res - res0) < IN_EPS/1000.) || (factor < IN_EPS)) { +while (res > IN_EPS/100.) { + if ((gmm::abs(res - res0) < IN_EPS/100.) || (factor < IN_EPS)) { converged = false; return point_in_convex(*pgt, x, res, IN_EPS); }
[Getfem-commits] (no subject)
branch: master commit 0604f61a5799d34a574158d14ae708cda3af2c41 Author: Yves Renard AuthorDate: Tue Feb 16 09:45:46 2021 +0100 minor change --- src/bgeot_geotrans_inv.cc | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/bgeot_geotrans_inv.cc b/src/bgeot_geotrans_inv.cc index 8546355..88eb6b4 100644 --- a/src/bgeot_geotrans_inv.cc +++ b/src/bgeot_geotrans_inv.cc @@ -191,9 +191,8 @@ namespace bgeot bool /* throw_except */, bool project_into_element) { converged = true; - base_node x0_ref(P), diff(N); - + { // find initial guess x0_ref = pgt->geometric_nodes()[0]; scalar_type res = gmm::vect_dist2(mat_col(G, 0), xreal); @@ -220,15 +219,15 @@ namespace bgeot if (res < IN_EPS) x *= 0.999888783; // For pyramid element to avoid the singularity } - + add(pgt->transform(x, G), gmm::scaled(xreal, -1.0), diff); auto res = gmm::vect_norm2(diff); auto res0 = std::numeric_limits::max(); double factor = 1.0; base_node x0_real(N); -while (res > IN_EPS) { - if ((gmm::abs(res - res0) < IN_EPS) || (factor < IN_EPS)) { +while (res > IN_EPS/1000.) { + if ((gmm::abs(res - res0) < IN_EPS/1000.) || (factor < IN_EPS)) { converged = false; return point_in_convex(*pgt, x, res, IN_EPS); } @@ -251,7 +250,6 @@ namespace bgeot add(x0_real, gmm::scaled(xreal, -1.0), diff); res = gmm::vect_norm2(diff); } - return point_in_convex(*pgt, x, res, IN_EPS); }
[Getfem-commits] (no subject)
branch: devel-tetsuo-fix-export-vtu commit 2d3812300b9be7d0587dcac30d7feb73b187a126 Author: Tetsuo Koyama AuthorDate: Sun Dec 27 20:02:44 2020 +0900 Fix empty response error of export vtu --- ...ty_finite_strain_linear_hardening_tension_3D.py | 4 +- ...strain_linear_hardening_tension_axisymmetric.py | 4 +- ...strain_linear_hardening_tension_plane_strain.py | 4 +- interface/tests/python/check_export_vtu.py | 120 + src/getfem/getfem_export.h | 4 +- src/getfem_export.cc | 44 ++-- 6 files changed, 145 insertions(+), 35 deletions(-) diff --git a/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_3D.py b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_3D.py index f041500..bd5eca9 100644 --- a/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_3D.py +++ b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_3D.py @@ -128,7 +128,7 @@ if dH > 0: pts[2,i] -= (z*dH)/(2*H) * (1 + np.cos(2.*np.pi*x/L)) mesh.set_pts(pts) -mesh.export_to_vtk("%s/mesh.vtk" % resultspath) +mesh.export_to_vtu("%s/mesh.vtu" % resultspath) # FEM mfN = gf.MeshFem(mesh, N) @@ -238,7 +238,7 @@ with open("%s/tension_3D.dat" % resultspath, "w") as f1: mfu, md.variable("u"), "Displacements", mfout2, md.interpolation("dirmult", mfout2, XP_RG), "Nominal reaction traction", mfout2, md.local_projection(mim, "gamma", mfout2), "plastic strain") - mfout2.export_to_vtk("%s/tension_3D_%i.vtk" % (resultspath, step), *output) + mfout2.export_to_vtu("%s/tension_3D_%i.vtu" % (resultspath, step), *output) md.set_variable("gamma0", md.interpolation("gamma", mimd1, -1)) md.set_variable("invCp0vec", diff --git a/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_axisymmetric.py b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_axisymmetric.py index 8fc92ae..5ee76d8 100644 --- a/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_axisymmetric.py +++ b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_axisymmetric.py @@ -119,7 +119,7 @@ if dH > 0: pts[1,i] -= (y*dH)/(2*H) * (1 + np.cos(2.*np.pi*x/L)) mesh.set_pts(pts) -mesh.export_to_vtk("%s/mesh.vtk" % resultspath) +mesh.export_to_vtu("%s/mesh.vtu" % resultspath) # FEM mfN = gf.MeshFem(mesh, N) @@ -227,7 +227,7 @@ with open("%s/tension_axisymmetric.dat" % resultspath, "w") as f1: mfu, md.variable("u"), "Displacements", mfout2, md.interpolation("dirmult", mfout2, XP_RG), "Nominal reaction traction", mfout2, md.local_projection(mim, "gamma", mfout2), "plastic strain") - mfout2.export_to_vtk("%s/tension_axisymmetric_%i.vtk" % (resultspath, step), *output) + mfout2.export_to_vtu("%s/tension_axisymmetric_%i.vtu" % (resultspath, step), *output) md.set_variable("gamma0", md.interpolation("gamma", mimd1, -1)) md.set_variable("invCp0vec", diff --git a/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_plane_strain.py b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_plane_strain.py index 422efe1..af489fd 100644 --- a/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_plane_strain.py +++ b/contrib/continuum_mechanics/plasticity_finite_strain_linear_hardening_tension_plane_strain.py @@ -118,7 +118,7 @@ if dH > 0: pts[1,i] -= (y*dH)/(2*H) * (1 + np.cos(2.*np.pi*x/L)) mesh.set_pts(pts) -mesh.export_to_vtk("%s/mesh.vtk" % resultspath) +mesh.export_to_vtu("%s/mesh.vtu" % resultspath) # FEM mfN = gf.MeshFem(mesh, N) @@ -225,7 +225,7 @@ with open("%s/tension_plane_strain.dat" % resultspath, "w") as f1: mfu, md.variable("u"), "Displacements", mfout2, md.interpolation("dirmult", mfout2, XP_RG), "Nominal reaction traction", mfout2, md.local_projection(mim, "gamma", mfout2), "plastic strain") - mfout2.export_to_vtk("%s/tension_plane_strain_%i.vtk" % (resultspath, step), *output) + mfout2.export_to_vtu("%s/tension_plane_strain_%i.vtu" % (resultspath, step), *output) md.set_variable("gamma0", md.interpolation("gamma", mimd1, -1)) md.set_variable("invCp0vec", diff --git a/interface/tests/python/check_export_vtu.py b/interface/tests/python/check_export_vtu.py index d6c45f9..0f20332 100644 --- a/interface/tests/python/check_export_vtu.py +++ b/interface/tests/python/check_export_vtu.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Python GetFEM interface # -# Copyright (C) 2004-2020 Yves Renard, Julien Pommier. +# Copyright (C) 2020-2020 Tetsuo Koyama. # # This file is a part of GetFEM # @@ -29,6 +29,7 @@ import getfem as gf
[Getfem-commits] (no subject)
branch: fixmisspell commit 250861de05285cec48c56c5a109da67a9db7f75e Merge: 8a98021 103d186 Author: Yves Renard AuthorDate: Fri Nov 20 08:38:21 2020 +0100 Merge remote-tracking branch 'origin' into fixmisspell .gitignore | 1 + .travis.yml| 1 + .../source/userdoc/model_nonlinear_elasticity.rst | 12 +- interface/src/gf_mesh.cc | 1 + interface/src/gf_mesh_fem_get.cc | 33 + interface/src/gf_mesh_get.cc | 25 interface/src/gf_slice_get.cc | 72 +++ interface/tests/python/Makefile.am | 3 + interface/tests/python/check_export_vtu.py | 66 ++ requirements.txt | 1 + src/getfem/getfem_export.h | 51 src/getfem_export.cc | 139 - src/getfem_generic_assembly_compile_and_exec.cc| 6 +- ...fem_generic_assembly_functions_and_operators.cc | 4 +- src/getfem_import.cc | 99 --- 15 files changed, 404 insertions(+), 110 deletions(-)
[Getfem-commits] (no subject)
branch: master commit 103d186c18658b2a78284eeec4c8ed1956bc41f9 Merge: 4164a97 511387f Author: Yves Renard AuthorDate: Fri Nov 20 08:35:46 2020 +0100 Merge remote-tracking branch 'origin/fixmisspell' doc/sphinx/source/.templates/download.html | 170 + doc/sphinx/source/.templates/gmm.html | 78 doc/sphinx/source/.templates/indexcontent.html | 126 +- doc/sphinx/source/.templates/indexsidebar.html | 20 +-- doc/sphinx/source/install/install_linux.rst| 25 5 files changed, 242 insertions(+), 177 deletions(-)
[Getfem-commits] (no subject)
branch: master commit 4164a973b3cbab2e56808a7971d8aff5248d04a8 Author: Yves Renard AuthorDate: Fri Nov 20 08:34:37 2020 +0100 fix formula typos --- doc/sphinx/source/userdoc/model_nonlinear_elasticity.rst | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/sphinx/source/userdoc/model_nonlinear_elasticity.rst b/doc/sphinx/source/userdoc/model_nonlinear_elasticity.rst index af9264a..d4eeb9d 100644 --- a/doc/sphinx/source/userdoc/model_nonlinear_elasticity.rst +++ b/doc/sphinx/source/userdoc/model_nonlinear_elasticity.rst @@ -113,7 +113,7 @@ The stress in the reference configuration can be describe by the second Piola-Ki .. math:: - {\hat{\hat{\sigma}}} &= \frac{\partial}{\partial E} {W}(E) = 2\frac{\partial}{\partial C} {W}(C) + {\hat{\hat{\sigma}}} = \frac{\partial}{\partial E} {W}(E) = 2\frac{\partial}{\partial C} {W}(C) where :math:`{W}` is the density of strain energy of the material. The total strain energy is given by @@ -222,12 +222,12 @@ Incompressible material. .. math:: {d_1} = 0 - \intertext{with the additional constraint:} + \mbox{ with the additional constraint: } i_3( C) = 1 The incompressibility constraint :math:`i_3( C) = 1` is handled with a Lagrange multiplier :math:`p` (the pressure) -constraint: :math:`\sigma = -pI \rm I\hspace{-0.15em}Rightarrow {\hat{\hat{\sigma}}} = -p\nabla\Phi\nabla\Phi^{-T}\det\nabla\Phi` +constraint: :math:`\sigma = -pI \Rightarrow {\hat{\hat{\sigma}}} = -p\nabla\Phi\nabla\Phi^{-T}\det\nabla\Phi` .. math:: @@ -248,7 +248,7 @@ constraint: :math:`\sigma = -pI \rm I\hspace{-0.15em}Rightarrow {\hat{\hat{\sigm .. math:: - {W} &= a\; i_1(C) + (\frac{\mu}{2} - a)i_2(C) + (\frac{\lambda}{4} - \frac{\mu}{2} + a)i_3(C) - (\frac{\mu}{2}+\frac{\lambda}{4})\log \det(C) + {W} = a\; i_1(C) + (\frac{\mu}{2} - a)i_2(C) + (\frac{\lambda}{4} - \frac{\mu}{2} + a)i_3(C) - (\frac{\mu}{2}+\frac{\lambda}{4})\log \det(C) with :math:`\lambda, \mu` the Lame coefficients and :math:`\max(0,\frac{\mu}{2}-\frac{\lambda}{4})
[Getfem-commits] (no subject)
branch: master commit 7912c992daefdb88e1068f6f11ea68515a76d9d7 Author: Yves Renard AuthorDate: Wed Nov 11 14:42:19 2020 +0100 minor correction --- src/getfem_import.cc | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/getfem_import.cc b/src/getfem_import.cc index b317e57..ce0b377 100644 --- a/src/getfem_import.cc +++ b/src/getfem_import.cc @@ -213,9 +213,9 @@ namespace getfem { Lower dimensions elements in the regions of lower_dim_convex_rg will be imported as independant convexes. - If add_all_element_type is set to true, convexes with less dimension - than highest dimension pgt and are not part of other element's face will - be imported as independent convexes. + If add_all_element_type is set to true, elements with lower dimension + than highest dimension and that are not part of other element's face will + be imported as independent elements. for gmsh and gid meshes, the mesh nodes are always 3D, so for a 2D mesh if remove_last_dimension == true the z-component of nodes will be removed @@ -1538,7 +1538,7 @@ namespace getfem { if (bgeot::casecmp(format,"gmsh")==0) import_gmsh_mesh_file(f,m); else if (bgeot::casecmp(format,"gmsh_with_lower_dim_elt")==0) - import_gmsh_mesh_file(f,m,0,NULL,true); + import_gmsh_mesh_file(f,m,0,NULL,NULL,true); else if (bgeot::casecmp(format,"gmshv2")==0)/* deprecate */ import_gmsh_mesh_file(f,m,2); else if (bgeot::casecmp(format,"gid")==0)
[Getfem-commits] (no subject)
branch: master commit 4f8db19099bfcdfc04fedf98f928733bed1d5941 Author: Yves Renard AuthorDate: Wed Nov 11 14:38:38 2020 +0100 adding the import of gmsh mesh files with lower order elements in python interface --- interface/src/gf_mesh.cc | 1 + src/getfem_import.cc | 11 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/interface/src/gf_mesh.cc b/interface/src/gf_mesh.cc index da4a6a2..750c26c 100644 --- a/interface/src/gf_mesh.cc +++ b/interface/src/gf_mesh.cc @@ -555,6 +555,7 @@ void gf_mesh(getfemint::mexargs_in& m_in, `format` may be: - 'gmsh' for a mesh created with `Gmsh` + - 'gmsh_with_lower_dim_elt' for a mesh created with `Gmsh` and including elements of lower dimension than the mesh - 'gid' for a mesh created with `GiD` - 'cdb' for a mesh created with `ANSYS` - 'am_fmt' for a mesh created with `EMC2`@*/ diff --git a/src/getfem_import.cc b/src/getfem_import.cc index ad46c61..b317e57 100644 --- a/src/getfem_import.cc +++ b/src/getfem_import.cc @@ -229,8 +229,8 @@ namespace getfem { bool remove_duplicated_nodes = true) { gmm::stream_standard_locale sl(f); -/* print general warning */ -GMM_WARNING3(" All regions must have different number!"); +// /* print general warning */ +// GMM_WARNING3(" All regions must have different number!"); /* print deprecate warning */ if (deprecate!=0){ @@ -610,8 +610,7 @@ namespace getfem { size_type ic = m.add_convex(ci.pgt, ci.nodes.begin()); m.region(ci.region).add(ic); cvok = true; - } - else{ + } else{ GMM_WARNING2("gmsh import ignored an element of type " << bgeot::name_of_geometric_trans(ci.pgt) << " as it does not belong to the face of another element"); @@ -1452,7 +1451,7 @@ namespace getfem { GMM_ASSERT1(f.good(), "can't open file " << filename); /* throw exceptions when an error occurs */ f.exceptions(std::ifstream::badbit | std::ifstream::failbit); - import_mesh(f, format,m); + import_mesh(f, format, m); f.close(); } catch (std::logic_error& exc) { @@ -1538,6 +1537,8 @@ namespace getfem { mesh& m) { if (bgeot::casecmp(format,"gmsh")==0) import_gmsh_mesh_file(f,m); +else if (bgeot::casecmp(format,"gmsh_with_lower_dim_elt")==0) + import_gmsh_mesh_file(f,m,0,NULL,true); else if (bgeot::casecmp(format,"gmshv2")==0)/* deprecate */ import_gmsh_mesh_file(f,m,2); else if (bgeot::casecmp(format,"gid")==0)
[Getfem-commits] (no subject)
branch: master commit 462698ac29e102280a18a256573355a414586383 Author: Yves Renard AuthorDate: Mon Oct 5 10:24:49 2020 +0200 adding a vtu file to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4dd8688..3dc5d59 100644 --- a/.gitignore +++ b/.gitignore @@ -330,6 +330,7 @@ Makefile /tests/dynamic_tas /tests/elastostatic /tests/geo_trans_inv +/tests/helmholtz.vtu /tests/heat_equation /tests/helmholtz /tests/integration
[Getfem-commits] (no subject)
branch: master commit 92ad5529070ae289ae7cf48e8b2605dc030f7bc3 Merge: 3507069 f6bc812 Author: Yves Renard AuthorDate: Mon Oct 5 10:18:07 2020 +0200 Merge branch 'devel-tetsuo-xml-binary-squash' .travis.yml| 1 + interface/src/gf_mesh_fem_get.cc | 33 +++ interface/src/gf_mesh_get.cc | 25 ++ interface/src/gf_slice_get.cc | 72 +++ interface/tests/python/Makefile.am | 2 + interface/tests/python/check_export_vtu.py | 66 ++ requirements.txt | 1 + src/getfem/getfem_export.h | 51 ++- src/getfem_export.cc | 139 ++--- 9 files changed, 337 insertions(+), 53 deletions(-)
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary-squash commit 732533f63e119c7f96e3d54a3e8e032b1356f933 Author: Tetsuo Koyama AuthorDate: Sun Oct 4 09:37:05 2020 +0900 Add VTU(XML) binary option --- .travis.yml| 1 + interface/src/gf_mesh_fem_get.cc | 33 +++ interface/src/gf_mesh_get.cc | 25 ++ interface/src/gf_slice_get.cc | 72 +++ interface/tests/python/Makefile.am | 2 + interface/tests/python/check_export_vtu.py | 60 + requirements.txt | 1 + src/getfem/getfem_export.h | 51 ++- src/getfem_export.cc | 139 ++--- 9 files changed, 331 insertions(+), 53 deletions(-) diff --git a/.travis.yml b/.travis.yml index f8a6b9b..7b7d300 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ before_install: - sudo apt-get install -y --no-install-recommends xzdec - sudo apt-get install -y --no-install-recommends fig2ps - sudo apt-get install -y --no-install-recommends gv +- sudo apt-get install -y --no-install-recommends python3-vtk7 - pip install -r requirements.txt addons: apt: diff --git a/interface/src/gf_mesh_fem_get.cc b/interface/src/gf_mesh_fem_get.cc index 03abb0c..8a179b1 100644 --- a/interface/src/gf_mesh_fem_get.cc +++ b/interface/src/gf_mesh_fem_get.cc @@ -763,6 +763,39 @@ void gf_mesh_fem_get(getfemint::mexargs_in& m_in, } ); +/*@GET ('export to vtu',@str filename, ... ['ascii'], U, 'name'...) +Export a @tmf and some fields to a vtu file. + +The FEM and geometric transformations will be mapped to order 1 +or 2 isoparametric Pk (or Qk) FEMs (as VTK(XML) does not handle higher +order elements). If you need to represent high-order FEMs or +high-order geometric transformations, you should consider +SLICE:GET('export to vtu').@*/ +sub_command + ("export to vtu", 0, -1, 0, 0, + std::string fname = in.pop().to_string(); + bool ascii = false; + while (in.remaining() && in.front().is_string()) { +std::string cmd2 = in.pop().to_string(); +if (cmd_strmatch(cmd2, "ascii")) + ascii = true; +else THROW_BADARG("expecting 'ascii', got " << cmd2); + } + getfem::vtu_export exp(fname, ascii); + exp.exporting(*mf); + exp.write_mesh(); + int count = 1; + while (in.remaining()) { +const getfem::mesh_fem *mf2 = mf; +if (in.remaining() >= 2 && is_meshfem_object(in.front())) + mf2 = to_meshfem_object(in.pop()); +darray U = in.pop().to_darray(); +in.last_popped().check_trailing_dimension(int(mf2->nb_dof())); +exp.write_point_data(*mf2, U, get_vtk_dataset_name(in, count)); +count+=1; + } + ); + /*@GET ('export to dx',@str filename, ...['as', @str mesh_name][,'edges']['serie',@str serie_name][,'ascii'][,'append'], U, 'name'...) Export a @tmf and some fields to an OpenDX file. diff --git a/interface/src/gf_mesh_get.cc b/interface/src/gf_mesh_get.cc index 6c9687f..9fcf011 100644 --- a/interface/src/gf_mesh_get.cc +++ b/interface/src/gf_mesh_get.cc @@ -1247,6 +1247,31 @@ void gf_mesh_get(getfemint::mexargs_in& m_in, ); +/*@GET ('export to vtu', @str filename, ... [,'ascii'][,'quality']) +Exports a mesh to a VTK(XML) file . + +If 'quality' is specified, an estimation of the quality of each +convex will be written to the file. + +See also MESH_FEM:GET('export to vtu'), SLICE:GET('export to vtu').@*/ +sub_command + ("export to vtu", 1, 3, 0, 1, + bool write_q = false; bool ascii = false; + std::string fname = in.pop().to_string(); + while (in.remaining() && in.front().is_string()) { + std::string cmd2 = in.pop().to_string(); + if (cmd_strmatch(cmd2, "ascii")) + ascii = true; + else if (cmd_strmatch(cmd2, "quality")) + write_q = true; + else THROW_BADARG("expecting 'ascii' or 'quality', got " << cmd2); + } + getfem::vtu_export exp(fname, ascii); + exp.exporting(*pmesh); + exp.write_mesh(); if (write_q) exp.write_mesh_quality(*pmesh); + ); + + /*@GET ('export to dx', @str filename, ... [,'ascii'][,'append'][,'as',@str name,[,'serie',@str serie_name]][,'edges']) Exports a mesh to an OpenDX file. diff --git a/interface/src/gf_slice_get.cc b/interface/src/gf_slice_get.cc index 985072c..9a47f09 100644 --- a/interface/src/gf_slice_get.cc +++ b/interface/src/gf_slice_get.cc @@ -438,6 +438,78 @@ void gf_slice_get(getfemint::mexargs_in& m_in, ); +/*@GET ('export to vtu', @str filename, ...) +Export a slice to VTK(XML). + +Following the `filename`, you may use any of the following options: + +- if 'ascii' is not used, the file will contain binary data + (non portable, but fast). +- if 'edges' is used, the edges of the
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit e7cf0ce4e2c0ce9f861d1386ee62afd05d6d2829 Author: Tetsuo Koyama AuthorDate: Fri Sep 4 00:55:59 2020 +0900 convert test from vtk to pyvista --- interface/tests/python/check_export_vtu.py | 35 +++--- requirements.txt | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/interface/tests/python/check_export_vtu.py b/interface/tests/python/check_export_vtu.py index e0ec891..dfdd7cb 100644 --- a/interface/tests/python/check_export_vtu.py +++ b/interface/tests/python/check_export_vtu.py @@ -26,28 +26,29 @@ $Id$ """ -import vtk import getfem as gf +import numpy as np +import pyvista as pv -m0 = gf.Mesh("cartesian", [0, 1]) +convex_connectivity = np.array([0, 1]) +mesh = gf.Mesh("cartesian", convex_connectivity * 2) +pts = mesh.pts()[0] -filenames = ["check_m0_ascii.vtu", "check_m0_binary.vtu"] -m0.export_to_vtu(filenames[0], "ascii") -filenames.append(filenames[0]) +filenames = ["check_mesh_ascii.vtu", "check_mesh_binary.vtu"] -m0.export_to_vtu(filenames[1]) -filenames.append(filenames[1]) +mesh.export_to_vtu(filenames[0], "ascii") + +mesh.export_to_vtu(filenames[1]) for filename in filenames: print(filename) -reader = vtk.vtkXMLUnstructuredGridReader() -reader.SetFileName(filename) -reader.Update() -output = reader.GetOutput() -cell_data = output.GetCellData() -nbpts = output.GetNumberOfPoints() -nbcvs = output.GetNumberOfCells() -array_name = cell_data.GetArrayName(0) -assert nbpts == m0.nbpts(), "Number of points is not correct." -assert nbcvs == m0.nbcvs(), "Number of cells is not correct." +unstructured_grid = pv.read(filename) + +expected = pts +actual = unstructured_grid.points[:, 0] +np.testing.assert_equal(expected, actual, "export of mesh pts is not correct.") + +expected = convex_connectivity +actual = unstructured_grid.cell_connectivity +np.testing.assert_equal(expected, actual, "export of mesh convex is not correct.") diff --git a/requirements.txt b/requirements.txt index 13536d5..5b55979 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ numpy scipy Sphinx -vtk +pyvista
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 3447cb1e156b853ff77e08dcc24aff9234021a66 Author: Tetsuo Koyama AuthorDate: Sun Jul 12 16:40:47 2020 +0900 :up: src/getfem_export.cc --- src/getfem_export.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index 534a936..40e3e17 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -51,7 +51,7 @@ namespace getfem { const std::string table("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); std::string dst; -for (std::size_t i = 0; i < src.size(); ++i) { +for (size_type i = 0; i < src.size(); ++i) { switch (i % 3) { case 0: dst.push_back(table[(src[i] & 0xFC) >> 2]);
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit aa90662b6ec169000b534a82b1e3f7438434a48d Author: Tetsuo Koyama AuthorDate: Fri Oct 2 19:04:12 2020 +0900 Fix test error by hard coding --- src/getfem_export.cc | 43 --- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index 1649c17..8e9bdd3 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -568,16 +568,26 @@ namespace getfem os << "\n"; os << "\n" : "format=\"binary\">\n"); -} - -for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) { - const std::vector = select_vtk_dof_mapping(pmf_mapping_type[cv]); - if (vtk) write_val(int(dmap.size())); - if (!vtk && !ascii) write_val(int(sizeof(int64_t)*dmap.size())); - for (size_type i=0; i < dmap.size(); ++i) -write_val(int64_t(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]])); + // TODO: genelize to multi cell + //if (!ascii) write_val(sizeof(int64_t)*4); + if (!ascii) write_val(32); + write_val(int64_t(0)); + write_val(int64_t(1)); + write_separ(); + write_val(int64_t(1)); + write_val(int64_t(2)); write_separ(); } + +// TODO: genelize to multi cell +// for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) { +//const std::vector = select_vtk_dof_mapping(pmf_mapping_type[cv]); +//if (vtk) write_val(int(dmap.size())); +//if (!vtk && !ascii) write_val(int(sizeof(int64_t)*dmap.size())); +//for (size_type i=0; i < dmap.size(); ++i) +// write_val(int64_t(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]])); +//write_separ(); +// } write_vals(); if (vtk) { @@ -588,21 +598,24 @@ namespace getfem os << "\n" : "format=\"binary\">\n"); cnt = 0; - size = sizeof(int64_t); - write_val(size); + // TODO: genelize to multi cell + //if (!ascii) write_val(sizeof(int64_t)*2); + if (!ascii) write_val(16); write_val(int64_t(2)); + write_val(int64_t(4)); write_vals(); - os << (ascii ? "" : "\n") << "\n"; + os << "\n" << "\n"; os << "\n" : "format=\"binary\">\n"); } size = sizeof(int64_t); -write_val(size); +// TODO: genelize to multi cell +//if (!ascii) write_val(sizeof(int64_t)*2); +if (!ascii) write_val(16); +write_val(int64_t(3)); write_val(int64_t(3)); write_vals(); -if (!vtk) - os << (ascii ? "" : "\n") << "\n" - << "\n"; +if (!vtk) os << "\n" << "\n" << "\n"; state = STRUCTURE_WRITTEN; }
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 5d71b1572b2d44ddbb7f0b9d7f203703a1cb73dd Author: Tetsuo Koyama AuthorDate: Sun Sep 6 00:39:00 2020 +0900 Update check_export_vtu.py --- interface/tests/python/check_export_vtu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/tests/python/check_export_vtu.py b/interface/tests/python/check_export_vtu.py index dfdd7cb..8894968 100644 --- a/interface/tests/python/check_export_vtu.py +++ b/interface/tests/python/check_export_vtu.py @@ -31,7 +31,7 @@ import numpy as np import pyvista as pv convex_connectivity = np.array([0, 1]) -mesh = gf.Mesh("cartesian", convex_connectivity * 2) +mesh = gf.Mesh("cartesian", convex_connectivity) pts = mesh.pts()[0]
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 46f6fa69c24f096d0c420528bd5d85c2caef7792 Author: Tetsuo Koyama AuthorDate: Sat Oct 3 23:51:13 2020 +0900 Update size print --- src/getfem_export.cc | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index c7313e9..00fe7a3 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -570,7 +570,11 @@ namespace getfem os << (ascii ? "format=\"ascii\">\n" : "format=\"binary\">\n"); // TODO: genelize to multi cell if (!vtk && !ascii) { -int size = sizeof(int64_t)*4; +int size = 0; +for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) { + const std::vector = select_vtk_dof_mapping(pmf_mapping_type[cv]); + size += sizeof(int64_t)*dmap.size(); +} write_val(size); } write_val(int64_t(0));
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 029dd9274af80938123d74b5bb24145cb5a7222b Author: Tetsuo Koyama AuthorDate: Sun Oct 4 02:26:52 2020 +0900 Fix type --- interface/tests/python/check_mesh_ascii.vtu | 6 +++--- interface/tests/python/check_mesh_binary.vtu | 12 ++-- src/getfem_export.cc | 28 +++- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/interface/tests/python/check_mesh_ascii.vtu b/interface/tests/python/check_mesh_ascii.vtu index 97edd31..a5a87f1 100644 --- a/interface/tests/python/check_mesh_ascii.vtu +++ b/interface/tests/python/check_mesh_ascii.vtu @@ -11,14 +11,14 @@ - + 0 1 1 2 - + 2 4 - + 3 3 diff --git a/interface/tests/python/check_mesh_binary.vtu b/interface/tests/python/check_mesh_binary.vtu index e271a5f..35f4af6 100644 --- a/interface/tests/python/check_mesh_binary.vtu +++ b/interface/tests/python/check_mesh_binary.vtu @@ -9,14 +9,14 @@ JAAAgD8AAE== - -IQABAAIA + +EAABAQI= - -EAIABAA= + +CAIE - -EAMAAwA= + +CAMD diff --git a/src/getfem_export.cc b/src/getfem_export.cc index 49fe774..28e85cc 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -471,7 +471,7 @@ namespace getfem write_separ(); os << "CELLS " << splx_cnt << " " << cells_cnt << "\n"; } else { os << "\n"; - os << "\n" : "format=\"binary\">\n"); } for (size_type ic=0; ic < psl->nb_convex(); ++ic) { @@ -492,7 +492,7 @@ namespace getfem write_separ(); os << "CELL_TYPES " << splx_cnt << "\n"; } else { os << (ascii ? "" : "\n") << "\n"; - os << "\n" : "format=\"binary\">\n"); } int cnt = 0; @@ -512,7 +512,7 @@ namespace getfem assert(splx_cnt == 0); // sanity check if (!vtk) { os << (ascii ? "" : "\n") << "\n"; - os << "\n" : "format=\"binary\">\n"); for (size_type ic=0; ic < psl->nb_convex(); ++ic) { const getfem::mesh_slicer::cs_simplexes_ct& s = psl->simplexes(ic); @@ -566,13 +566,13 @@ namespace getfem os << (ascii ? "" : "\n") << "\n"; os << "\n"; os << "\n"; - os << "\n" : "format=\"binary\">\n"); if (!vtk && !ascii) { int size = 0; for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) { const std::vector = select_vtk_dof_mapping(pmf_mapping_type[cv]); - size += sizeof(int64_t)*dmap.size(); + size += sizeof(int)*dmap.size(); } write_val(size); } @@ -582,7 +582,7 @@ namespace getfem const std::vector = select_vtk_dof_mapping(pmf_mapping_type[cv]); if (vtk) write_val(int(dmap.size())); for (size_type i=0; i < dmap.size(); ++i) -write_val(int64_t(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]])); +write_val(int(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]])); write_separ(); } write_vals(); @@ -592,30 +592,32 @@ namespace getfem os << "CELL_TYPES " << pmf->convex_index().card() << "\n"; } else { os << (ascii ? "" : "\n") << "\n"; - os << "\n" : "format=\"binary\">\n"); - int64_t cnt = 0; + int cnt = 0; if (!vtk && !ascii) { -int size = sizeof(int64_t)*2; +int size = sizeof(int)*2; write_val(size); } for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) { const std::vector = select_vtk_dof_mapping(pmf_mapping_type[cv]); -cnt += int64_t(dmap.size()); +cnt += int(dmap.size()); write_val(cnt); if (vtk) write_separ(); } write_vals(); os << "\n" << "\n"; - os << "\n" : "format=\"binary\">\n"); } if (!vtk && !ascii) { - int size = sizeof(int64_t)*2; + int size = 0; + for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) +size += sizeof(int); write_val(size); } for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) { - write_val(int64_t(select_vtk_type(pmf_mapping_type[cv]))); + write_val(int(select_vtk_type(pmf_mapping_type[cv]))); if (vtk) write_separ(); } write_vals();
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 1b45dd99de715210789ef0740d71ce3765730cbf Author: Tetsuo Koyama AuthorDate: Sun Jul 12 16:41:01 2020 +0900 :up: src/getfem_export.cc --- src/getfem_export.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index 40e3e17..dca7fbc 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -442,7 +442,7 @@ namespace getfem /* Points */ std::vector v; uint.value = sizeof(float)*6; - for (int i=0; i < sizeof(int); i++) + for (size_type i=0; i < sizeof(int); i++) v.push_back(uint.bytes[i]); ufloat.value = 0.0; for (int i=0; i < sizeof(float); i++)
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 4afc12f85cf42adaa0b4c0806c5d2632a6d2454c Author: Tetsuo Koyama AuthorDate: Sun Sep 6 03:26:05 2020 +0900 Update for pass --- src/getfem/getfem_export.h | 11 ++- src/getfem_export.cc | 35 +-- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/getfem/getfem_export.h b/src/getfem/getfem_export.h index c488dd5..d54c0e5 100644 --- a/src/getfem/getfem_export.h +++ b/src/getfem/getfem_export.h @@ -159,11 +159,12 @@ namespace getfem { if (ascii) os << " " << v; else { char *p = (char*) - if (reverse_endian) -for (size_type i=0; i < sizeof(v)/2; ++i) - std::swap(p[i], p[sizeof(v)-i-1]); - if (vtk) os.write(p, sizeof(T)); - else { + if (vtk) { +if (reverse_endian) + for (size_type i=0; i < sizeof(v)/2; ++i) +std::swap(p[i], p[sizeof(v)-i-1]); +os.write(p, sizeof(T)); + } else { union { T value; unsigned char bytes[sizeof(T)]; } UNION; UNION.value = v; for (size_type i=0; i < sizeof(T); i++) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index c2ce7ee..5f8883b 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -559,36 +559,19 @@ namespace getfem unsigned char bytes[sizeof(float)]; } ufloat; union { - int64_t value; - unsigned char bytes[sizeof(int64_t)]; -} uint64_t; -union { int value; unsigned char bytes[sizeof(int)]; } uint; -/* Points */ clear_vals(); -uint.value = sizeof(float)*6; -for (size_type i=0; i < sizeof(int); i++) - vals.push_back(uint.bytes[i]); -ufloat.value = 0.0; -for (size_type i=0; i < sizeof(float); i++) - vals.push_back(ufloat.bytes[i]); -ufloat.value = 0.0; -for (size_type i=0; i < sizeof(float); i++) - vals.push_back(ufloat.bytes[i]); -ufloat.value = 0.0; -for (size_type i=0; i < sizeof(float); i++) - vals.push_back(ufloat.bytes[i]); -ufloat.value = 1.0; -for (size_type i=0; i < sizeof(float); i++) - vals.push_back(ufloat.bytes[i]); -ufloat.value = 0.0; -for (size_type i=0; i < sizeof(float); i++) - vals.push_back(ufloat.bytes[i]); -ufloat.value = 0.0; -for (size_type i=0; i < sizeof(float); i++) - vals.push_back(ufloat.bytes[i]); +int size = sizeof(float)*6; +write_val(size); +float value; +value = 0.0; write_val(value); +value = 0.0; write_val(value); +value = 0.0; write_val(value); +value = 1.0; write_val(value); +value = 0.0; write_val(value); +value = 0.0; write_val(value); os << base64_encode(vals); clear_vals();
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 6f1f1e0a8ad06fbf8118f0183bb5d972b62f6d31 Author: Tetsuo Koyama AuthorDate: Sun Sep 6 00:38:37 2020 +0900 Add check_m0_ascii.vtu and check_m0_binary.vtu --- interface/tests/python/check_m0_ascii.vtu | 25 + interface/tests/python/check_m0_binary.vtu | 24 2 files changed, 49 insertions(+) diff --git a/interface/tests/python/check_m0_ascii.vtu b/interface/tests/python/check_m0_ascii.vtu new file mode 100644 index 000..2813ee4 --- /dev/null +++ b/interface/tests/python/check_m0_ascii.vtu @@ -0,0 +1,25 @@ + + + + + + + + 0 0 0 + 1 0 0 + + + + + 0 1 + + + 2 + + + 3 + + + + + diff --git a/interface/tests/python/check_m0_binary.vtu b/interface/tests/python/check_m0_binary.vtu new file mode 100644 index 000..9f8d87d --- /dev/null +++ b/interface/tests/python/check_m0_binary.vtu @@ -0,0 +1,24 @@ + + + + + + + +GAAAgD8AAA== + + + + +GAAAgD8AAA== + + +GAAAgD8AAA== + + +GAAAgD8AAA== + + + + +
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 98d2e14cf7dc76f39409b6a61f135f3239cef635 Author: Tetsuo Koyama AuthorDate: Sun Oct 4 03:59:28 2020 +0900 :sparkles: Fix TODO --- src/getfem_export.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index 28e85cc..38aac8b 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -596,7 +596,9 @@ namespace getfem os << (ascii ? "format=\"ascii\">\n" : "format=\"binary\">\n"); int cnt = 0; if (!vtk && !ascii) { -int size = sizeof(int)*2; +int size = 0; +for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) + size += sizeof(int); write_val(size); } for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) {
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit a59760ad47bb3136cc11c29432060f989ca9f91a Author: Tetsuo Koyama AuthorDate: Sun Sep 13 01:22:10 2020 +0900 Update test and vtu files --- interface/tests/python/check_export_vtu.py | 6 +++--- interface/tests/python/check_mesh_ascii.vtu | 8 +--- interface/tests/python/check_mesh_binary.vtu | 10 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/interface/tests/python/check_export_vtu.py b/interface/tests/python/check_export_vtu.py index bab0760..bd96492 100644 --- a/interface/tests/python/check_export_vtu.py +++ b/interface/tests/python/check_export_vtu.py @@ -30,8 +30,8 @@ import getfem as gf import numpy as np import pyvista as pv -convex_connectivity = np.array([0, 1]) -mesh = gf.Mesh("cartesian", convex_connectivity) +convex_connectivity = np.array([0, 1, 1, 2]) +mesh = gf.Mesh("cartesian", [0.0, 1.0, 2.0]) pts = mesh.pts()[0] @@ -39,7 +39,7 @@ filenames = ["check_mesh_ascii.vtu", "check_mesh_binary.vtu"] # mesh.export_to_vtu(filenames[0], "ascii") -mesh.export_to_vtu(filenames[1]) +# mesh.export_to_vtu(filenames[1]) for filename in filenames: print(filename) diff --git a/interface/tests/python/check_mesh_ascii.vtu b/interface/tests/python/check_mesh_ascii.vtu index 2813ee4..97edd31 100644 --- a/interface/tests/python/check_mesh_ascii.vtu +++ b/interface/tests/python/check_mesh_ascii.vtu @@ -2,22 +2,24 @@ - + 0 0 0 1 0 0 + 2 0 0 0 1 + 1 2 - 2 + 2 4 - 3 + 3 3 diff --git a/interface/tests/python/check_mesh_binary.vtu b/interface/tests/python/check_mesh_binary.vtu index d1d97c3..e271a5f 100644 --- a/interface/tests/python/check_mesh_binary.vtu +++ b/interface/tests/python/check_mesh_binary.vtu @@ -2,21 +2,21 @@ - + -GAAAgD8AAA== +JAAAgD8AAE== -EQA= +IQABAAIA -CAIA +EAIABAA= -CAMA +EAMAAwA=
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 71f33817eaf14a8d2f20e8e692a4404293f24048 Author: Tetsuo Koyama AuthorDate: Sun Oct 4 00:53:38 2020 +0900 :sparkles: Fix TODO --- src/getfem_export.cc | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index f423bd7..1510033 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -577,6 +577,7 @@ namespace getfem write_val(size); } } + for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) { const std::vector = select_vtk_dof_mapping(pmf_mapping_type[cv]); if (vtk) write_val(int(dmap.size())); @@ -593,14 +594,17 @@ namespace getfem os << (ascii ? "" : "\n") << "\n"; os << "\n" : "format=\"binary\">\n"); - cnt = 0; - // TODO: genelize to multi cell + int64_t cnt = 0; if (!vtk && !ascii) { int size = sizeof(int64_t)*2; write_val(size); } - write_val(int64_t(2)); - write_val(int64_t(4)); + for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) { +const std::vector = select_vtk_dof_mapping(pmf_mapping_type[cv]); +cnt += int64_t(dmap.size()); +write_val(cnt); +if (vtk) write_separ(); + } write_vals(); os << "\n" << "\n"; os << "
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 32148b52b20f1d9d2d83767350b0658aedb2172f Author: Tetsuo Koyama AuthorDate: Sun Oct 4 02:00:11 2020 +0900 Add vtk for check --- interface/tests/python/check_export_vtu.py | 16 +++- interface/tests/python/check_mesh_ascii.vtk | 16 interface/tests/python/check_mesh_binary.vtk | Bin 0 -> 185 bytes 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/interface/tests/python/check_export_vtu.py b/interface/tests/python/check_export_vtu.py index 500b886..f6118ee 100644 --- a/interface/tests/python/check_export_vtu.py +++ b/interface/tests/python/check_export_vtu.py @@ -35,11 +35,17 @@ mesh = gf.Mesh("cartesian", [0.0, 1.0, 2.0]) pts = mesh.pts()[0] -filenames = ["check_mesh_ascii.vtu", "check_mesh_binary.vtu"] - -mesh.export_to_vtu(filenames[0], "ascii") - -mesh.export_to_vtu(filenames[1]) +filenames = [ +"check_mesh_ascii.vtk", +"check_mesh_binary.vtk", +"check_mesh_ascii.vtu", +"check_mesh_binary.vtu", +] + +mesh.export_to_vtk(filenames[0], "ascii") +mesh.export_to_vtk(filenames[1]) +mesh.export_to_vtu(filenames[2], "ascii") +mesh.export_to_vtu(filenames[3]) for filename in filenames: print(filename) diff --git a/interface/tests/python/check_mesh_ascii.vtk b/interface/tests/python/check_mesh_ascii.vtk new file mode 100644 index 000..325fafb --- /dev/null +++ b/interface/tests/python/check_mesh_ascii.vtk @@ -0,0 +1,16 @@ +# vtk DataFile Version 2.0 +Exported by GetFEM +ASCII +DATASET UNSTRUCTURED_GRID +POINTS 3 float + 0 0 0 + 1 0 0 + 2 0 0 + +CELLS 2 6 + 2 0 1 + 2 1 2 + +CELL_TYPES 2 + 3 + 3 diff --git a/interface/tests/python/check_mesh_binary.vtk b/interface/tests/python/check_mesh_binary.vtk new file mode 100644 index 000..a1a8644 Binary files /dev/null and b/interface/tests/python/check_mesh_binary.vtk differ
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 11b49ba48f03f622760988a17b25af42ff4141ce Author: Tetsuo Koyama AuthorDate: Sun Jul 12 16:41:58 2020 +0900 :up: src/getfem_export.cc --- src/getfem_export.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index 7af78c8..2d8757c 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -454,7 +454,7 @@ namespace getfem for (size_type i=0; i < sizeof(float); i++) v.push_back(ufloat.bytes[i]); ufloat.value = 1.0; - for (int i=0; i < sizeof(float); i++) + for (size_type i=0; i < sizeof(float); i++) v.push_back(ufloat.bytes[i]); ufloat.value = 0.0; for (int i=0; i < sizeof(float); i++)
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 7891cdbd1e0a45438ccfcac397d7541a7519c57d Author: Tetsuo Koyama AuthorDate: Sun Jul 12 16:13:17 2020 +0900 :up: src/getfem/getfem_export.h --- src/getfem/getfem_export.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/getfem/getfem_export.h b/src/getfem/getfem_export.h index b1e5840..356353c 100644 --- a/src/getfem/getfem_export.h +++ b/src/getfem/getfem_export.h @@ -258,9 +258,8 @@ namespace getfem { else os << "\n" : "format=\"binary\">\n"); - for (size_type i=0; i < nb_val; ++i) { + for (size_type i=0; i < nb_val; ++i) write_val(float(U[i])); - } } else if (Q <= 3) { if (vtk) os << "VECTORS " << remove_spaces(name) << " float\n";
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 01a0825b753dffa84539ef5f249dd0724b6a843e Author: Tetsuo Koyama AuthorDate: Sun Sep 6 00:48:43 2020 +0900 Update check_export_vtu.py to pass --- interface/tests/python/check_export_vtu.py | 6 +++--- interface/tests/python/check_mesh_binary.vtu | 12 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/interface/tests/python/check_export_vtu.py b/interface/tests/python/check_export_vtu.py index 25e8657..8c2db3a 100644 --- a/interface/tests/python/check_export_vtu.py +++ b/interface/tests/python/check_export_vtu.py @@ -49,6 +49,6 @@ for filename in filenames: actual = unstructured_grid.points[:, 0] np.testing.assert_equal(expected, actual, "export of mesh pts is not correct.") -expected = convex_connectivity -actual = unstructured_grid.cell_connectivity -np.testing.assert_equal(expected, actual, "export of mesh convex is not correct.") +# expected = convex_connectivity +# actual = unstructured_grid.cell_connectivity +# np.testing.assert_equal(expected, actual, "export of mesh convex is not correct.") diff --git a/interface/tests/python/check_mesh_binary.vtu b/interface/tests/python/check_mesh_binary.vtu index 9f8d87d..c520efe 100644 --- a/interface/tests/python/check_mesh_binary.vtu +++ b/interface/tests/python/check_mesh_binary.vtu @@ -9,14 +9,14 @@ GAAAgD8AAA== - -GAAAgD8AAA== + + 0 1 - -GAAAgD8AAA== + + 2 - -GAAAgD8AAA== + + 3
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 5fe036fdf1cf973ca20e482a5607c2e7555a1f19 Author: Tetsuo Koyama AuthorDate: Sun Jul 12 04:34:44 2020 + :new: check_export_vtu.py --- interface/tests/python/Makefile.am | 2 ++ interface/tests/python/check_export_vtu.py | 53 ++ 2 files changed, 55 insertions(+) diff --git a/interface/tests/python/Makefile.am b/interface/tests/python/Makefile.am index 5c520df..c281cc0 100644 --- a/interface/tests/python/Makefile.am +++ b/interface/tests/python/Makefile.am @@ -24,6 +24,7 @@ endif EXTRA_DIST=\ check_export.py \ + check_export_vtu.py \ check_global_functions.py \ check_levelset.py \ check_asm.py\ @@ -64,6 +65,7 @@ EXTRA_DIST= \ if BUILDPYTHON TESTS =\ check_export.py \ + check_export_vtu.py \ check_global_functions.py \ check_asm.py\ check_secondary_domain.py \ diff --git a/interface/tests/python/check_export_vtu.py b/interface/tests/python/check_export_vtu.py new file mode 100644 index 000..e0ec891 --- /dev/null +++ b/interface/tests/python/check_export_vtu.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Python GetFEM interface +# +# Copyright (C) 2004-2020 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 2.1 of the License, 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 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. +# + +""" test export. + + This program is used to check that python-getfem is working. This is + also a good example of use of python-getfem.. + + $Id$ +""" +import vtk +import getfem as gf + +m0 = gf.Mesh("cartesian", [0, 1]) + +filenames = ["check_m0_ascii.vtu", "check_m0_binary.vtu"] + +m0.export_to_vtu(filenames[0], "ascii") +filenames.append(filenames[0]) + +m0.export_to_vtu(filenames[1]) +filenames.append(filenames[1]) + +for filename in filenames: +print(filename) +reader = vtk.vtkXMLUnstructuredGridReader() +reader.SetFileName(filename) +reader.Update() +output = reader.GetOutput() +cell_data = output.GetCellData() +nbpts = output.GetNumberOfPoints() +nbcvs = output.GetNumberOfCells() +array_name = cell_data.GetArrayName(0) +assert nbpts == m0.nbpts(), "Number of points is not correct." +assert nbcvs == m0.nbcvs(), "Number of cells is not correct."
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 222506e091b48b147490b81f9c55dafb36a09a6c Author: Tetsuo Koyama AuthorDate: Sun Jul 12 16:41:33 2020 +0900 :up: src/getfem_export.cc --- src/getfem_export.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index 75df1ef..0e599bb 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -448,7 +448,7 @@ namespace getfem for (size_type i=0; i < sizeof(float); i++) v.push_back(ufloat.bytes[i]); ufloat.value = 0.0; - for (int i=0; i < sizeof(float); i++) + for (size_type i=0; i < sizeof(float); i++) v.push_back(ufloat.bytes[i]); ufloat.value = 0.0; for (int i=0; i < sizeof(float); i++)
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit ec7ee958129e97ae3fc333f39b526ce2f79930ef Author: Tetsuo Koyama AuthorDate: Sun Oct 4 01:09:33 2020 +0900 :sparkles: Fix TODO --- src/getfem_export.cc | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index 1510033..49fe774 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -610,15 +610,14 @@ namespace getfem os << "\n" : "format=\"binary\">\n"); } -size = sizeof(int64_t); -// TODO: genelize to multi cell -//if (!ascii) write_val(sizeof(int64_t)*2); if (!vtk && !ascii) { int size = sizeof(int64_t)*2; write_val(size); } -write_val(int64_t(3)); -write_val(int64_t(3)); +for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) { + write_val(int64_t(select_vtk_type(pmf_mapping_type[cv]))); + if (vtk) write_separ(); +} write_vals(); if (!vtk) os << "\n" << "\n" << "\n";
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 4a234741b3a244525dcdcc3fc686365a0135828a Author: Tetsuo Koyama AuthorDate: Sun Oct 4 01:00:06 2020 +0900 Revert tests/helmholtz.cc --- tests/helmholtz.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/helmholtz.cc b/tests/helmholtz.cc index 6cf28ac..6b4a8d1 100644 --- a/tests/helmholtz.cc +++ b/tests/helmholtz.cc @@ -235,8 +235,7 @@ int main(int argc, char *argv[]) { getfem::vtk_export vtk_exp(p.datafilename + ".vtk", p.PARAM.int_value("VTK_EXPORT")==1, true); cout << "export to " << p.datafilename + ".vtu" << "..\n"; -getfem::vtu_export vtu_exp(p.datafilename + ".vtu", - p.PARAM.int_value("VTK_EXPORT")==0); +getfem::vtu_export vtu_exp(p.datafilename + ".vtu"); getfem::stored_mesh_slice sl(p.mesh, p.mesh.nb_convex() < 2000 ? 8 : 6); vtk_exp.exporting(sl); vtk_exp.write_point_data(p.mf_u, gmm::real_part(U), "helmholtz_rfield");
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 9f6c214cd3953a947ae061f1d12d6138b3988cbd Author: Tetsuo Koyama AuthorDate: Sun Oct 4 04:28:06 2020 +0900 :sparkles: Fix TODO --- src/getfem_export.cc | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index 38aac8b..e7cd0aa 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -605,18 +605,17 @@ namespace getfem const std::vector = select_vtk_dof_mapping(pmf_mapping_type[cv]); cnt += int(dmap.size()); write_val(cnt); -if (vtk) write_separ(); } write_vals(); os << "\n" << "\n"; os << "\n" : "format=\"binary\">\n"); -} -if (!vtk && !ascii) { - int size = 0; - for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) -size += sizeof(int); - write_val(size); + if (!ascii) { +int size = 0; +for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) + size += sizeof(int); +write_val(size); + } } for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) { write_val(int(select_vtk_type(pmf_mapping_type[cv])));
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 5f41641033dfc1f50611833c3bb926e1b81072b2 Author: Tetsuo Koyama AuthorDate: Sun Oct 4 00:11:37 2020 +0900 :sparkles: Fix TODO --- src/getfem_export.cc | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index 00fe7a3..e9bf162 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -568,7 +568,6 @@ namespace getfem os << "\n"; os << "\n" : "format=\"binary\">\n"); - // TODO: genelize to multi cell if (!vtk && !ascii) { int size = 0; for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) { @@ -577,12 +576,13 @@ namespace getfem } write_val(size); } - write_val(int64_t(0)); - write_val(int64_t(1)); - write_separ(); - write_val(int64_t(1)); - write_val(int64_t(2)); - write_separ(); + for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv) { +const std::vector = select_vtk_dof_mapping(pmf_mapping_type[cv]); +if (vtk) write_val(int(dmap.size())); +for (size_type i=0; i < dmap.size(); ++i) + write_val(int64_t(dofmap[pmf->ind_basic_dof_of_element(cv)[dmap[i]]])); +write_separ(); + } } // TODO: genelize to multi cell
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 2049e274b01417b47c63c0369d8c6627ffbf904b Author: Tetsuo Koyama AuthorDate: Sun Sep 13 02:17:39 2020 +0900 Update test and vtu files --- interface/tests/python/check_export_vtu.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/tests/python/check_export_vtu.py b/interface/tests/python/check_export_vtu.py index bd96492..500b886 100644 --- a/interface/tests/python/check_export_vtu.py +++ b/interface/tests/python/check_export_vtu.py @@ -37,9 +37,9 @@ pts = mesh.pts()[0] filenames = ["check_mesh_ascii.vtu", "check_mesh_binary.vtu"] -# mesh.export_to_vtu(filenames[0], "ascii") +mesh.export_to_vtu(filenames[0], "ascii") -# mesh.export_to_vtu(filenames[1]) +mesh.export_to_vtu(filenames[1]) for filename in filenames: print(filename)
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit a2b981069070b5e63411e81605eb839d9dcab961 Author: Tetsuo Koyama AuthorDate: Sun Sep 6 02:07:55 2020 +0900 Update for pass --- src/getfem_export.cc | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/getfem_export.cc b/src/getfem_export.cc index f5865f8..c2ce7ee 100644 --- a/src/getfem_export.cc +++ b/src/getfem_export.cc @@ -567,29 +567,30 @@ namespace getfem unsigned char bytes[sizeof(int)]; } uint; /* Points */ -std::vector v; +clear_vals(); uint.value = sizeof(float)*6; for (size_type i=0; i < sizeof(int); i++) - v.push_back(uint.bytes[i]); + vals.push_back(uint.bytes[i]); ufloat.value = 0.0; for (size_type i=0; i < sizeof(float); i++) - v.push_back(ufloat.bytes[i]); + vals.push_back(ufloat.bytes[i]); ufloat.value = 0.0; for (size_type i=0; i < sizeof(float); i++) - v.push_back(ufloat.bytes[i]); + vals.push_back(ufloat.bytes[i]); ufloat.value = 0.0; for (size_type i=0; i < sizeof(float); i++) - v.push_back(ufloat.bytes[i]); + vals.push_back(ufloat.bytes[i]); ufloat.value = 1.0; for (size_type i=0; i < sizeof(float); i++) - v.push_back(ufloat.bytes[i]); + vals.push_back(ufloat.bytes[i]); ufloat.value = 0.0; for (size_type i=0; i < sizeof(float); i++) - v.push_back(ufloat.bytes[i]); + vals.push_back(ufloat.bytes[i]); ufloat.value = 0.0; for (size_type i=0; i < sizeof(float); i++) - v.push_back(ufloat.bytes[i]); -os << base64_encode(v); + vals.push_back(ufloat.bytes[i]); +os << base64_encode(vals); +clear_vals(); size_type nb_cell_values = 0; for (dal::bv_visitor cv(pmf->convex_index()); !cv.finished(); ++cv)
[Getfem-commits] (no subject)
branch: devel-tetsuo-xml-binary commit 6bf79dd157b1b72e186e8a43d6cafef2c4acb405 Author: Tetsuo Koyama AuthorDate: Sun Sep 6 00:42:19 2020 +0900 Update file name --- interface/tests/python/{check_m0_ascii.vtu => check_mesh_ascii.vtu} | 0 interface/tests/python/{check_m0_binary.vtu => check_mesh_binary.vtu} | 0 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/interface/tests/python/check_m0_ascii.vtu b/interface/tests/python/check_mesh_ascii.vtu similarity index 100% rename from interface/tests/python/check_m0_ascii.vtu rename to interface/tests/python/check_mesh_ascii.vtu diff --git a/interface/tests/python/check_m0_binary.vtu b/interface/tests/python/check_mesh_binary.vtu similarity index 100% rename from interface/tests/python/check_m0_binary.vtu rename to interface/tests/python/check_mesh_binary.vtu