From 78a6b3d76c275029061c78a64ca829d5583ded5a Mon Sep 17 00:00:00 2001 From: gtheler Date: Fri, 27 Dec 2024 07:23:03 -0300 Subject: [PATCH 1/5] tests --- Makefile.am | 170 +++++++++++++++++++++++++------------------------- configure.ac | 2 +- tests/reed.sh | 2 + 3 files changed, 89 insertions(+), 85 deletions(-) diff --git a/Makefile.am b/Makefile.am index d6328b66..e3e643d9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,92 +19,94 @@ dist_doc_DATA = AUTHORS \ dist_man_MANS = doc/feenox.1 +TESTS = tests/reed.sh -TESTS = \ - tests/abort.sh \ - tests/algebraic_expr.sh \ - tests/annulus-modal.sh \ - tests/uo2-pellet.sh \ - tests/airfoil.sh \ - tests/arguments.sh \ - tests/azmy.sh \ - tests/bc-groups.sh \ - tests/beam-modal.sh \ - tests/beam-ortho.sh \ - tests/bimetallic-strip.sh \ - tests/builtin.sh \ - tests/circle.sh \ - tests/cog.sh \ - tests/cylinder-traction-force.sh \ - tests/encased_rod.sh \ - tests/expressions.sh \ - tests/expressions_constants.sh \ - tests/exp.sh \ - tests/i-beam-euler-bernoulli.sh \ - tests/iaea-pwr.sh \ - tests/iterative.sh \ - tests/fit.sh \ - tests/file.sh \ - tests/func_min.sh \ - tests/function_algebraic.sh \ - tests/function_data.sh \ - tests/function_file.sh \ - tests/function_mesh.sh \ - tests/function_vectors.sh \ - tests/hello_mpi.sh \ - tests/integral.sh \ - tests/lag.sh \ - tests/laplace2d.sh \ - tests/lebesgue.sh \ - tests/los-alamos.sh \ - tests/map-cube.sh \ - tests/materials.sh \ - tests/mesh.sh \ - tests/moment-of-inertia.sh \ - tests/nafems-le1.sh \ - tests/nafems-le10.sh \ - tests/nafems-le11.sh \ - tests/nafems-t1-4.sh \ - tests/nafems-t2-3.sh \ - tests/neutron_diffusion_src.sh \ - tests/neutron_diffusion_keff.sh \ - tests/neutron-fully-mirrored.sh \ - tests/parallelepiped.sh \ - tests/petsc_options.sh \ - tests/pipe.sh \ - tests/point-kinetics.sh \ - tests/print.sh \ - tests/ray-effect.sh \ - tests/reactions.sh \ - tests/reactions-elastic.sh \ - tests/reed.sh \ - tests/solve.sh \ - tests/spinning-disk.sh \ - tests/statically_indeterminate_reaction.sh \ - tests/symmetry.sh \ - tests/t21.sh \ - tests/thermal-1d.sh \ - tests/thermal-2d.sh \ - tests/thermal-3d.sh \ - tests/thermal-slab-no-k.sh \ - tests/thermal-slab-wrong-bc.sh \ - tests/thermal-radiation.sh \ - tests/transient-mesh.sh \ - tests/trig.sh \ - tests/two-cubes-isotropic.sh \ - tests/two-cubes-orthotropic.sh \ - tests/vector.sh \ - tests/xfail-few-properties-ortho-young.sh \ - tests/xfail-few-properties-ortho-poisson.sh \ - tests/xfail-few-properties-ortho-shear.sh \ - tests/wilson.sh -XFAIL_TESTS = tests/abort.sh \ - tests/thermal-slab-no-k.sh \ - tests/thermal-slab-wrong-bc.sh \ - tests/xfail-few-properties-ortho-young.sh \ - tests/xfail-few-properties-ortho-poisson.sh \ - tests/xfail-few-properties-ortho-shear.sh +# TESTS = \ +# tests/abort.sh \ +# tests/algebraic_expr.sh \ +# tests/annulus-modal.sh \ +# tests/uo2-pellet.sh \ +# tests/airfoil.sh \ +# tests/arguments.sh \ +# tests/azmy.sh \ +# tests/bc-groups.sh \ +# tests/beam-modal.sh \ +# tests/beam-ortho.sh \ +# tests/bimetallic-strip.sh \ +# tests/builtin.sh \ +# tests/circle.sh \ +# tests/cog.sh \ +# tests/cylinder-traction-force.sh \ +# tests/encased_rod.sh \ +# tests/expressions.sh \ +# tests/expressions_constants.sh \ +# tests/exp.sh \ +# tests/i-beam-euler-bernoulli.sh \ +# tests/iaea-pwr.sh \ +# tests/iterative.sh \ +# tests/fit.sh \ +# tests/file.sh \ +# tests/func_min.sh \ +# tests/function_algebraic.sh \ +# tests/function_data.sh \ +# tests/function_file.sh \ +# tests/function_mesh.sh \ +# tests/function_vectors.sh \ +# tests/hello_mpi.sh \ +# tests/integral.sh \ +# tests/lag.sh \ +# tests/laplace2d.sh \ +# tests/lebesgue.sh \ +# tests/los-alamos.sh \ +# tests/map-cube.sh \ +# tests/materials.sh \ +# tests/mesh.sh \ +# tests/moment-of-inertia.sh \ +# tests/nafems-le1.sh \ +# tests/nafems-le10.sh \ +# tests/nafems-le11.sh \ +# tests/nafems-t1-4.sh \ +# tests/nafems-t2-3.sh \ +# tests/neutron_diffusion_src.sh \ +# tests/neutron_diffusion_keff.sh \ +# tests/neutron-fully-mirrored.sh \ +# tests/parallelepiped.sh \ +# tests/petsc_options.sh \ +# tests/pipe.sh \ +# tests/point-kinetics.sh \ +# tests/print.sh \ +# tests/ray-effect.sh \ +# tests/reactions.sh \ +# tests/reactions-elastic.sh \ +# tests/reed.sh \ +# tests/solve.sh \ +# tests/spinning-disk.sh \ +# tests/statically_indeterminate_reaction.sh \ +# tests/symmetry.sh \ +# tests/t21.sh \ +# tests/thermal-1d.sh \ +# tests/thermal-2d.sh \ +# tests/thermal-3d.sh \ +# tests/thermal-slab-no-k.sh \ +# tests/thermal-slab-wrong-bc.sh \ +# tests/thermal-radiation.sh \ +# tests/transient-mesh.sh \ +# tests/trig.sh \ +# tests/two-cubes-isotropic.sh \ +# tests/two-cubes-orthotropic.sh \ +# tests/vector.sh \ +# tests/xfail-few-properties-ortho-young.sh \ +# tests/xfail-few-properties-ortho-poisson.sh \ +# tests/xfail-few-properties-ortho-shear.sh \ +# tests/wilson.sh +# +# XFAIL_TESTS = tests/abort.sh \ +# tests/thermal-slab-no-k.sh \ +# tests/thermal-slab-wrong-bc.sh \ +# tests/xfail-few-properties-ortho-young.sh \ +# tests/xfail-few-properties-ortho-poisson.sh \ +# tests/xfail-few-properties-ortho-shear.sh # when getting # ERROR: files left in build directory after distclean: diff --git a/configure.ac b/configure.ac index 9b973793..4f2ee232 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ AC_PROG_INSTALL ###################### # default optimization flags -AS_IF([test "x$CFLAGS" = "x-g -O2"], [CFLAGS="-O2 -flto=auto -no-pie"]) +AS_IF([test "x$CFLAGS" = "x-g -O2"], [CFLAGS="-O3 -flto=auto -no-pie"]) # the CFLAGS are passed down to the linker as well # AS_IF([test "x$LDFLAGS" = "x"], [LDFLAGS="-flto=auto"]) diff --git a/tests/reed.sh b/tests/reed.sh index 1676dcee..c90c0a1b 100755 --- a/tests/reed.sh +++ b/tests/reed.sh @@ -14,6 +14,8 @@ checkpde neutron_sn gmsh -v 0 -1 ${dir}/reed.geo || exit $? +${dir}/../feenox -V +valgrind ${dir}/../feenox ${dir}/reed.fee 2 0.08 answer1zero reed.fee 2 0.08 exitifwrong $? From b6099e1d077e1418d46e409fc5ddc0bdf0be54ae Mon Sep 17 00:00:00 2001 From: gtheler Date: Fri, 27 Dec 2024 10:54:19 -0300 Subject: [PATCH 2/5] neighbors --- src/mesh/neighbors.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/mesh/neighbors.c b/src/mesh/neighbors.c index feb01484..11f0a7fe 100644 --- a/src/mesh/neighbors.c +++ b/src/mesh/neighbors.c @@ -1,7 +1,7 @@ /*------------ -------------- -------- --- ----- --- -- - - * feenox's mesh-related neighbor routines * - * Copyright (C) 2014--2018 Jeremy Theler + * Copyright (C) 2014--2024 Jeremy Theler * * This file is part of feenox. * @@ -61,26 +61,20 @@ element_t *feenox_mesh_find_element_volumetric_neighbor(element_t *this) { } int feenox_mesh_count_element_volumetric_neighbors(element_t *this) { - - // en mallas de primer orden esto sirve para mezclar elementos raros - // en segundo hay que hacerlo completo -// int target = (this->type->order == 1) ? this->type->dim : this->type->nodes; - int target = this->type->nodes; - size_t tags[this->type->faces]; - for (unsigned int k = 0; k < this->type->faces; k++) { + for (int k = 0; k < this->type->faces; k++) { tags[k] = 0; } element_ll_t *element_item = NULL; - unsigned int index = 0; + int index = 0; int n = 0; - for (unsigned int j = 0; j < this->type->nodes; j++) { + for (int j = 0; j < this->type->nodes; j++) { LL_FOREACH(this->node[j]->element_list, element_item) { if (this->type->dim == (element_item->element->type->dim-1)) { // los vecinos volumetricos - if (mesh_count_common_nodes(this, element_item->element, NULL) >= target) { + if (mesh_count_common_nodes(this, element_item->element, NULL) >= this->type->nodes) { int exists = 0; - for (unsigned int k = 0; exists == 0 && k < index; k++) { + for (int k = 0; exists == 0 && k < index; k++) { exists |= (element_item->element->tag == tags[k]); } if (exists == 0) { From 9828218d2916695e9a0cb860c5416a97f0846cd3 Mon Sep 17 00:00:00 2001 From: jeremy theler Date: Fri, 27 Dec 2024 11:40:40 -0300 Subject: [PATCH 3/5] do not inline neighbors --- src/feenox.h | 7 +++---- src/mesh/geometry.c | 44 ++++++++++++++++++++------------------------ 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/feenox.h b/src/feenox.h index 678102a7..dd675e42 100644 --- a/src/feenox.h +++ b/src/feenox.h @@ -2314,7 +2314,6 @@ extern int feenox_mesh_elements_info(void); extern int feenox_mesh_elements_info_geo(element_type_t *element_type); // geom.c -// TODO: rename mesh_* -> feenox_mesh_* extern void feenox_mesh_subtract(const double *a, const double *b, double *c); extern void feenox_mesh_cross(const double *a, const double *b, double *c); extern void feenox_mesh_normalized_cross(const double *a, const double *b, double *c); @@ -2327,7 +2326,7 @@ extern double feenox_mesh_subtract_module(const double *b, const double *a); extern double feenox_mesh_subtract_squared_module(const double *b, const double *a); extern double feenox_mesh_subtract_squared_module2d(const double *b, const double *a); -extern int feenox_mesh_compute_outward_normal(element_t *element, double n[3]); +extern int feenox_mesh_compute_outward_normal(element_t *element, double n[3]) __attribute__((noinline)); // element.c extern int feenox_mesh_compute_normal_2d(element_t *e); @@ -2348,8 +2347,8 @@ extern int feenox_mesh_write_data_vtk(mesh_write_t *, mesh_write_dist_t *dist); // neighbors.c -extern element_t *feenox_mesh_find_element_volumetric_neighbor(element_t *); -extern int feenox_mesh_count_element_volumetric_neighbors(element_t *this); +extern element_t *feenox_mesh_find_element_volumetric_neighbor(element_t *e) __attribute__((noinline)); +extern int feenox_mesh_count_element_volumetric_neighbors(element_t *e) __attribute__((noinline)); // init.c diff --git a/src/mesh/geometry.c b/src/mesh/geometry.c index 22ffdcf4..e04e4da7 100644 --- a/src/mesh/geometry.c +++ b/src/mesh/geometry.c @@ -92,25 +92,25 @@ double feenox_mesh_subtract_squared_module2d(const double *b, const double *a) return (b[0]-a[0])*(b[0]-a[0]) + (b[1]-a[1])*(b[1]-a[1]); } - // TODO: make a faster one assuming the elements are already oriented int feenox_mesh_compute_outward_normal(element_t *element, double n[3]) { - double local_n[3] = {n[0], n[1], n[2]}; - + // double local_n[3] = {n[0], n[1], n[2]}; + // element_t *local_element = calloc(1, sizeof(element_t)); + // memcpy(local_element, element, sizeof(element_t)); // TODO: a method linked to the element type if (element->type->dim == 0) { - local_n[0] = 1; - local_n[1] = 0; - local_n[2] = 0; - + n[0] = 1; + n[1] = 0; + n[2] = 0; + } else if (element->type->dim == 1) { // WATCH out! this does not work with lines which do not lie on the xy plane! double module = feenox_mesh_subtract_module(element->node[1]->x, element->node[0]->x); - local_n[0] = -(element->node[1]->x[1] - element->node[0]->x[1])/module; - local_n[1] = +(element->node[1]->x[0] - element->node[0]->x[0])/module; - local_n[2] = 0; + n[0] = -(element->node[1]->x[1] - element->node[0]->x[1])/module; + n[1] = +(element->node[1]->x[0] - element->node[0]->x[0])/module; + n[2] = 0; } else if (element->type->dim == 2) { @@ -118,7 +118,7 @@ int feenox_mesh_compute_outward_normal(element_t *element, double n[3]) { double b[3] = {0,0,0}; feenox_mesh_subtract(element->node[0]->x, element->node[1]->x, a); feenox_mesh_subtract(element->node[0]->x, element->node[2]->x, b); - feenox_mesh_normalized_cross(a, b, local_n); + feenox_mesh_normalized_cross(a, b, n); } else if (element->type->dim == 3) { feenox_push_error_message("trying to compute the outward normal of a volume (element %d)", element->tag); @@ -129,33 +129,29 @@ int feenox_mesh_compute_outward_normal(element_t *element, double n[3]) { // if there's none (or more than one) then we rely on the element orientation if (feenox_mesh_count_element_volumetric_neighbors(element) == 1) { // first compute the center of the surface element - double surface_center[3]; + double surface_center[3] = {0,0,0}; feenox_call(feenox_mesh_compute_element_barycenter(element, surface_center)); // then the center of the volume element element_t *volumetric_neighbor = NULL; volumetric_neighbor = feenox_mesh_find_element_volumetric_neighbor(element); - double volumetric_neighbor_center[3]; + double volumetric_neighbor_center[3] = {0,0,0}; feenox_call(feenox_mesh_compute_element_barycenter(volumetric_neighbor, volumetric_neighbor_center)); // compute the product between the proposed normal and the difference between these two // if the product is positive, invert the normal - if (feenox_mesh_subtract_dot(volumetric_neighbor_center, surface_center, local_n) > 0) { - local_n[0] = -local_n[0]; - local_n[1] = -local_n[1]; - local_n[2] = -local_n[2]; + if (feenox_mesh_subtract_dot(volumetric_neighbor_center, surface_center, n) > 0) { + n[0] = -n[0]; + n[1] = -n[1]; + n[2] = -n[2]; } } // update nx ny and nz - feenox_var_value(feenox.mesh.vars.arr_n[0]) = local_n[0]; - feenox_var_value(feenox.mesh.vars.arr_n[1]) = local_n[1]; - feenox_var_value(feenox.mesh.vars.arr_n[2]) = local_n[2]; - - n[0] = local_n[0]; - n[1] = local_n[1]; - n[2] = local_n[2]; + feenox_var_value(feenox.mesh.vars.arr_n[0]) = n[0]; + feenox_var_value(feenox.mesh.vars.arr_n[1]) = n[1]; + feenox_var_value(feenox.mesh.vars.arr_n[2]) = n[2]; return FEENOX_OK; } From e290859063d1bbcdd699603168e5ad7cf56f6f7f Mon Sep 17 00:00:00 2001 From: gtheler Date: Fri, 27 Dec 2024 11:43:32 -0300 Subject: [PATCH 4/5] restored makefiles --- Makefile.am | 171 ++++++++++++++++++++++++++-------------------------- 1 file changed, 84 insertions(+), 87 deletions(-) diff --git a/Makefile.am b/Makefile.am index e3e643d9..0a807d00 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,94 +19,91 @@ dist_doc_DATA = AUTHORS \ dist_man_MANS = doc/feenox.1 -TESTS = tests/reed.sh +TESTS = \ + tests/abort.sh \ + tests/algebraic_expr.sh \ + tests/annulus-modal.sh \ + tests/uo2-pellet.sh \ + tests/airfoil.sh \ + tests/arguments.sh \ + tests/azmy.sh \ + tests/bc-groups.sh \ + tests/beam-modal.sh \ + tests/beam-ortho.sh \ + tests/bimetallic-strip.sh \ + tests/builtin.sh \ + tests/circle.sh \ + tests/cog.sh \ + tests/cylinder-traction-force.sh \ + tests/encased_rod.sh \ + tests/expressions.sh \ + tests/expressions_constants.sh \ + tests/exp.sh \ + tests/i-beam-euler-bernoulli.sh \ + tests/iaea-pwr.sh \ + tests/iterative.sh \ + tests/fit.sh \ + tests/file.sh \ + tests/func_min.sh \ + tests/function_algebraic.sh \ + tests/function_data.sh \ + tests/function_file.sh \ + tests/function_mesh.sh \ + tests/function_vectors.sh \ + tests/hello_mpi.sh \ + tests/integral.sh \ + tests/lag.sh \ + tests/laplace2d.sh \ + tests/lebesgue.sh \ + tests/los-alamos.sh \ + tests/map-cube.sh \ + tests/materials.sh \ + tests/mesh.sh \ + tests/moment-of-inertia.sh \ + tests/nafems-le1.sh \ + tests/nafems-le10.sh \ + tests/nafems-le11.sh \ + tests/nafems-t1-4.sh \ + tests/nafems-t2-3.sh \ + tests/neutron_diffusion_src.sh \ + tests/neutron_diffusion_keff.sh \ + tests/neutron-fully-mirrored.sh \ + tests/parallelepiped.sh \ + tests/petsc_options.sh \ + tests/pipe.sh \ + tests/point-kinetics.sh \ + tests/print.sh \ + tests/ray-effect.sh \ + tests/reactions.sh \ + tests/reactions-elastic.sh \ + tests/reed.sh \ + tests/solve.sh \ + tests/spinning-disk.sh \ + tests/statically_indeterminate_reaction.sh \ + tests/symmetry.sh \ + tests/t21.sh \ + tests/thermal-1d.sh \ + tests/thermal-2d.sh \ + tests/thermal-3d.sh \ + tests/thermal-slab-no-k.sh \ + tests/thermal-slab-wrong-bc.sh \ + tests/thermal-radiation.sh \ + tests/transient-mesh.sh \ + tests/trig.sh \ + tests/two-cubes-isotropic.sh \ + tests/two-cubes-orthotropic.sh \ + tests/vector.sh \ + tests/xfail-few-properties-ortho-young.sh \ + tests/xfail-few-properties-ortho-poisson.sh \ + tests/xfail-few-properties-ortho-shear.sh \ + tests/wilson.sh - -# TESTS = \ -# tests/abort.sh \ -# tests/algebraic_expr.sh \ -# tests/annulus-modal.sh \ -# tests/uo2-pellet.sh \ -# tests/airfoil.sh \ -# tests/arguments.sh \ -# tests/azmy.sh \ -# tests/bc-groups.sh \ -# tests/beam-modal.sh \ -# tests/beam-ortho.sh \ -# tests/bimetallic-strip.sh \ -# tests/builtin.sh \ -# tests/circle.sh \ -# tests/cog.sh \ -# tests/cylinder-traction-force.sh \ -# tests/encased_rod.sh \ -# tests/expressions.sh \ -# tests/expressions_constants.sh \ -# tests/exp.sh \ -# tests/i-beam-euler-bernoulli.sh \ -# tests/iaea-pwr.sh \ -# tests/iterative.sh \ -# tests/fit.sh \ -# tests/file.sh \ -# tests/func_min.sh \ -# tests/function_algebraic.sh \ -# tests/function_data.sh \ -# tests/function_file.sh \ -# tests/function_mesh.sh \ -# tests/function_vectors.sh \ -# tests/hello_mpi.sh \ -# tests/integral.sh \ -# tests/lag.sh \ -# tests/laplace2d.sh \ -# tests/lebesgue.sh \ -# tests/los-alamos.sh \ -# tests/map-cube.sh \ -# tests/materials.sh \ -# tests/mesh.sh \ -# tests/moment-of-inertia.sh \ -# tests/nafems-le1.sh \ -# tests/nafems-le10.sh \ -# tests/nafems-le11.sh \ -# tests/nafems-t1-4.sh \ -# tests/nafems-t2-3.sh \ -# tests/neutron_diffusion_src.sh \ -# tests/neutron_diffusion_keff.sh \ -# tests/neutron-fully-mirrored.sh \ -# tests/parallelepiped.sh \ -# tests/petsc_options.sh \ -# tests/pipe.sh \ -# tests/point-kinetics.sh \ -# tests/print.sh \ -# tests/ray-effect.sh \ -# tests/reactions.sh \ -# tests/reactions-elastic.sh \ -# tests/reed.sh \ -# tests/solve.sh \ -# tests/spinning-disk.sh \ -# tests/statically_indeterminate_reaction.sh \ -# tests/symmetry.sh \ -# tests/t21.sh \ -# tests/thermal-1d.sh \ -# tests/thermal-2d.sh \ -# tests/thermal-3d.sh \ -# tests/thermal-slab-no-k.sh \ -# tests/thermal-slab-wrong-bc.sh \ -# tests/thermal-radiation.sh \ -# tests/transient-mesh.sh \ -# tests/trig.sh \ -# tests/two-cubes-isotropic.sh \ -# tests/two-cubes-orthotropic.sh \ -# tests/vector.sh \ -# tests/xfail-few-properties-ortho-young.sh \ -# tests/xfail-few-properties-ortho-poisson.sh \ -# tests/xfail-few-properties-ortho-shear.sh \ -# tests/wilson.sh -# -# XFAIL_TESTS = tests/abort.sh \ -# tests/thermal-slab-no-k.sh \ -# tests/thermal-slab-wrong-bc.sh \ -# tests/xfail-few-properties-ortho-young.sh \ -# tests/xfail-few-properties-ortho-poisson.sh \ -# tests/xfail-few-properties-ortho-shear.sh +XFAIL_TESTS = tests/abort.sh \ + tests/thermal-slab-no-k.sh \ + tests/thermal-slab-wrong-bc.sh \ + tests/xfail-few-properties-ortho-young.sh \ + tests/xfail-few-properties-ortho-poisson.sh \ + tests/xfail-few-properties-ortho-shear.sh # when getting # ERROR: files left in build directory after distclean: From b76d95f372a5daa73b54ce7a62efd1a3cedc0b96 Mon Sep 17 00:00:00 2001 From: gtheler Date: Fri, 27 Dec 2024 11:47:55 -0300 Subject: [PATCH 5/5] do not call valgrind in reed --- tests/reed.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/reed.sh b/tests/reed.sh index c90c0a1b..1676dcee 100755 --- a/tests/reed.sh +++ b/tests/reed.sh @@ -14,8 +14,6 @@ checkpde neutron_sn gmsh -v 0 -1 ${dir}/reed.geo || exit $? -${dir}/../feenox -V -valgrind ${dir}/../feenox ${dir}/reed.fee 2 0.08 answer1zero reed.fee 2 0.08 exitifwrong $?