From 835e9e9b20c6137bdd0511fedede116ac066e2f4 Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 16 Sep 2002 17:55:09 +0000 Subject: [PATCH] Add this test, complementing non_primitive_1, but this time with Nedelec-elements. It is presently failing due to a known bug in FESystem, but this way it is in CVS, and I can care about the bug next. git-svn-id: https://svn.dealii.org/trunk@6433 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/fe/Makefile | 4 +- tests/fe/non_primitive_2.cc | 270 ++++++++++++++++++++++++++++++++++++ 2 files changed, 273 insertions(+), 1 deletion(-) create mode 100644 tests/fe/non_primitive_2.cc diff --git a/tests/fe/Makefile b/tests/fe/Makefile index 5b272adc68..24b1ce1d59 100644 --- a/tests/fe/Makefile +++ b/tests/fe/Makefile @@ -34,6 +34,7 @@ nedelec.exe : nedelec.go $(libraries) nedelec_2.exe : nedelec_2.go $(libraries) nedelec_3.exe : nedelec_3.go $(libraries) non_primitive_1.exe : non_primitive_1.go $(libraries) +non_primitive_2.exe : non_primitive_2.go $(libraries) numbering.exe : numbering.go $(libraries) shapes.exe : shapes.go $(libraries) transfer.exe : transfer.go $(libraries) @@ -42,7 +43,8 @@ up_and_down.exe : up_and_down.go $(libraries) tests = derivatives fe_data_test fe_traits fe_tools_test mapping \ mapping_c1 shapes numbering mapping_q1_eulerian \ transfer internals \ - non_primitive_1 nedelec nedelec_2 nedelec_3 up_and_down + non_primitive_1 non_primitive_2 \ + nedelec nedelec_2 nedelec_3 up_and_down ############################################################ diff --git a/tests/fe/non_primitive_2.cc b/tests/fe/non_primitive_2.cc new file mode 100644 index 0000000000..f8f0b88423 --- /dev/null +++ b/tests/fe/non_primitive_2.cc @@ -0,0 +1,270 @@ +//---------------------------- non_primitive_1.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2001, 2002 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- non_primitive_1.cc --------------------------- + +// assemble a matrix for the stokes equation in different ways for +// non-primitive elements. this is the counterpart to the non_primitive_1 +// program, which did the same thing for actually primitive finite elements +// +// of course, it makes absolutely no sense to work the Stokes equation +// with a Nedelec element, but this is just to test the library, no? + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +// note: create_stokes_matrix_1 from non_primitive_1 does not work here, +// since the elements in use are actually non-primitive + + // create the matrix in the simple + // way that is necessary when you + // want to use non-primitive shape + // functions +template +void +create_stokes_matrix_2 (const DoFHandler &dof_handler, + SparseMatrix &A) +{ + const FiniteElement &fe = dof_handler.get_fe(); + const unsigned int dofs_per_cell = fe.dofs_per_cell; + + typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(), + endc = dof_handler.end(); + + std::vector local_dof_indices (dofs_per_cell); + FullMatrix local_matrix (dofs_per_cell, dofs_per_cell); + + QGauss quadrature (3); + const unsigned int n_q_points = quadrature.n_quadrature_points; + + FEValues fe_values (fe, quadrature, + update_values | update_gradients | + update_JxW_values); + + const double nu = 3.14159265358e-2; + + for (; cell!=endc; ++cell) + { + local_matrix.clear (); + fe_values.reinit (cell); + for (unsigned int i=0; iget_dof_indices (local_dof_indices); + for (unsigned int i=0; i +void +create_stokes_matrix_3 (const DoFHandler &dof_handler, + SparseMatrix &A) +{ + const FiniteElement &fe = dof_handler.get_fe(); + const unsigned int dofs_per_cell = fe.dofs_per_cell; + + typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(), + endc = dof_handler.end(); + + std::vector local_dof_indices (dofs_per_cell); + FullMatrix local_matrix (dofs_per_cell, dofs_per_cell); + + QGauss quadrature (3); + const unsigned int n_q_points = quadrature.n_quadrature_points; + + FEValues fe_values (fe, quadrature, + update_values | update_gradients | + update_JxW_values); + + const double nu = 3.14159265358e-2; + + for (; cell!=endc; ++cell) + { + local_matrix.clear (); + fe_values.reinit (cell); + for (unsigned int i=0; iget_dof_indices (local_dof_indices); + for (unsigned int i=0; i +void +test () +{ + Triangulation triangulation; + if (dim != 2) + GridGenerator::hyper_cube (triangulation); + else + GridGenerator::hyper_cube_slit (triangulation); + triangulation.refine_global (1); + triangulation.begin_active()->set_refine_flag(); + triangulation.execute_coarsening_and_refinement(); + triangulation.last_active()->set_refine_flag (); + triangulation.execute_coarsening_and_refinement(); + + if (dim < 3) + triangulation.refine_global (1); + + deallog << "dim=" << dim + << ", n_cells=" << triangulation.n_active_cells() + << std::endl; + + FESystem fe (FE_Nedelec(1), 1, + FE_Q(1), 1); + DoFHandler dof_handler (triangulation); + dof_handler.distribute_dofs (fe); + + SparsityPattern sparsity(dof_handler.n_dofs(), + dof_handler.n_dofs()); + + // have a mask that indicates that + // for the stokes equation the + // pressure does not couple to + // itself + std::vector > mask (dim+1, std::vector (dim+1, true)); + mask[dim][dim] = false; + + DoFTools::make_sparsity_pattern (dof_handler, mask, sparsity); + sparsity.compress (); + + SparseMatrix A2 (sparsity); + SparseMatrix A3 (sparsity); + + create_stokes_matrix_2 (dof_handler, A2); + create_stokes_matrix_3 (dof_handler, A3); + + // write out the contents of the + // matrix and compare for equality + // with the other matrices. to + // reduce the amount of data + // written out a little bit, only + // write every so-many-th element + for (unsigned int i=0; i (); + test<3> (); +}; + + + + -- 2.39.5