[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Konstantinos Poulios |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Sat, 23 Mar 2019 05:23:35 -0400 (EDT) |
branch: master
commit 00f372b4b235ae08a5b07a1f820b8855a3a9f845
Author: Konstantinos Poulios <address@hidden>
Date: Sat Mar 23 10:23:26 2019 +0100
Add test for assembly assignment
---
tests/Makefile.am | 4 +++
tests/test_assembly_assignment.cc | 55 +++++++++++++++++++++++++++++++++++++++
tests/test_assembly_assignment.pl | 45 ++++++++++++++++++++++++++++++++
3 files changed, 104 insertions(+)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4e9d42f..385006a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -42,6 +42,7 @@ check_PROGRAMS = \
test_mat_elem \
test_interpolation \
test_assembly \
+ test_assembly_assignment \
test_interpolated_fem \
test_range_basis \
laplacian \
@@ -81,6 +82,7 @@ test_small_vector_SOURCES = test_small_vector.cc
test_kdtree_SOURCES = test_kdtree.cc
test_rtree_SOURCES = test_rtree.cc
test_assembly_SOURCES = test_assembly.cc
+test_assembly_assignment_SOURCES = test_assembly_assignment.cc
laplacian_SOURCES = laplacian.cc
laplacian_with_bricks_SOURCES = laplacian_with_bricks.cc
plate_SOURCES = plate.cc
@@ -134,6 +136,7 @@ TESTS = \
test_slice.pl \
integration.pl \
test_assembly.pl \
+ test_assembly_assignment.pl \
test_interpolated_fem.pl \
test_range_basis.pl \
laplacian.pl \
@@ -163,6 +166,7 @@ EXTRA_DIST =
\
test_rtree.pl \
test_interpolation.pl \
test_assembly.pl \
+ test_assembly_assignment.pl \
laplacian.pl \
laplacian_with_bricks.pl \
elastostatic.pl \
diff --git a/tests/test_assembly_assignment.cc
b/tests/test_assembly_assignment.cc
new file mode 100644
index 0000000..356312a
--- /dev/null
+++ b/tests/test_assembly_assignment.cc
@@ -0,0 +1,55 @@
+/*===========================================================================
+
+ Copyright (C) 2019-2019 Andriy Andreykiv, Konstantinos Poulios.
+
+ This file is a part of GetFEM++
+
+ GetFEM++ is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version along with the GCC Runtime Library
+ Exception either version 3.1 or (at your option) any later version.
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License and GCC Runtime Library Exception for more details.
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+===========================================================================*/
+#include "getfem/getfem_generic_assembly.h"
+#include "getfem/getfem_regular_meshes.h"
+
+int main(int argc, char *argv[]) {
+
+ GMM_SET_EXCEPTION_DEBUG; // Exceptions make a memory fault, to debug.
+ FE_ENABLE_EXCEPT; // Enable floating point exception for Nan.
+
+ bgeot::md_param PARAM;
+ PARAM.add_int_param("N", 10);
+ PARAM.add_real_param("RESULT", 0.04478308527);
+ PARAM.read_command_line(argc, argv);
+ size_t N = PARAM.int_value("N", "Number of elements");
+ double RESULT = PARAM.real_value("RESULT", "Expected result");
+
+ getfem::mesh m;
+ getfem::regular_unit_mesh(m, {N, N},
bgeot::geometric_trans_descriptor("GT_QK(2, 2)"));
+
+ getfem::mesh_fem mf(m);
+ mf.set_classical_finite_element(2);
+ getfem::mesh_im mim(m);
+ mim.set_integration_method(3);
+ bgeot::multi_index scalarSize(0);
+ getfem::im_data imd(mim, scalarSize, -1);
+ std::vector<double> v(mf.nb_dof()), u(mf.nb_dof()), d(imd.nb_index());
+
+ getfem::ga_workspace w;
+ w.set_assembled_vector(v);
+ w.add_fem_variable("u", mf, gmm::sub_interval(0, mf.nb_dof()), u);
+ w.add_im_data("d", imd, d);
+ w.add_assignment_expression("d", "Norm(X)", -1, 1, true);
+ w.add_expression("d * Test_u", mim, -1);
+ w.assembly(1);
+ return (gmm::abs(gmm::vect_norm2(v) - RESULT) < 1e-10) ? 0 : 1;
+}
diff --git a/tests/test_assembly_assignment.pl
b/tests/test_assembly_assignment.pl
new file mode 100644
index 0000000..9420685
--- /dev/null
+++ b/tests/test_assembly_assignment.pl
@@ -0,0 +1,45 @@
+# Copyright (C) 2001-2019 Yves Renard
+#
+# This file is a part of GetFEM++
+#
+# GetFEM++ is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version along with the GCC Runtime Library
+# Exception either version 3.1 or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+# License and GCC Runtime Library Exception for more details.
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+$er = 0;
+
+sub start_program
+{
+ my $def = $_[0];
+
+ # print ("def = $def\n");
+
+ open F, "./test_assembly_assignment $def 2>&1 |" or die;
+ while (<F>) {
+ if ($_ =~ /FAILED/) {
+ $er = 1;
+ print "============================================\n";
+ print $_, <F>;
+ }
+ print $_;
+ }
+ close(F); if ($?) { exit(1); }
+}
+
+start_program("-d N=10 -d RESULT=0.04478308527");
+print ".\n";
+start_program("-d N=15 -d RESULT=0.02998533866");
+print ".\n";
+
+if ($er == 1) { exit(1); }
+
+