From d678f8c17f7258cf0139ef005beef79b4de2bd88 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Wed, 2 Sep 2015 22:47:09 +0200 Subject: [PATCH] simplified Grid generation in hp_constraints_neither_dominate_01 Also fixed indentation. --- .../hp/hp_constraints_neither_dominate_01.cc | 133 +++++++++--------- 1 file changed, 68 insertions(+), 65 deletions(-) diff --git a/tests/hp/hp_constraints_neither_dominate_01.cc b/tests/hp/hp_constraints_neither_dominate_01.cc index 36824cecce..943696b68a 100644 --- a/tests/hp/hp_constraints_neither_dominate_01.cc +++ b/tests/hp/hp_constraints_neither_dominate_01.cc @@ -70,7 +70,8 @@ #include #include -// #define DEBUG_OUTPUT_VTK +//#define DEBUG_OUTPUT_VTK +unsigned int counter=0; const double eps = 1e-10; @@ -80,16 +81,19 @@ template void test2cells(const unsigned int p1=2, const unsigned int p2=1) { + Assert(dim>1,ExcInternalError()); Triangulation triangulation; { - Triangulation triangulationL; - Triangulation triangulationR; - GridGenerator::hyper_cube (triangulationL, -1,0); //create a square [-1,0]^d domain - GridGenerator::hyper_cube (triangulationR, -1,0); //create a square [-1,0]^d domain - Point shift_vector; - shift_vector[0] = 1.0; - GridTools::shift(shift_vector,triangulationR); - GridGenerator::merge_triangulations (triangulationL, triangulationR, triangulation); + Point p1,p2; + for (unsigned int d=0; d repetitoins(dim,1); + repetitoins[0]=2; + GridGenerator::subdivided_hyper_rectangle(triangulation, + repetitoins, + p1, + p2); } hp::DoFHandler dof_handler(triangulation); @@ -123,6 +127,7 @@ void test2cells(const unsigned int p1=2, #ifdef DEBUG_OUTPUT_VTK // output to check if all is good: + counter++; std::vector> shape_functions; std::vector names; for (unsigned int s=0; s < dof_handler.n_dofs(); s++) @@ -164,11 +169,9 @@ void test2cells(const unsigned int p1=2, for (unsigned int i = 0; i < shape_functions.size(); i++) data_out.add_data_vector (shape_functions[i], names[i]); - data_out.build_patches(15); - - std::string filename = "2cell-shape_functions_p1="+std::to_string(p1) - +"_p2="+std::to_string(p2) - +"_"+dealii::Utilities::int_to_string(dim)+"D.vtu"; + data_out.build_patches(0); + std::string filename = "shape_functions_"+dealii::Utilities::int_to_string(counter,1) + +"_"+dealii::Utilities::int_to_string(dim)+"D.vtu"; std::ofstream output (filename.c_str ()); data_out.write_vtu (output); #endif @@ -189,30 +192,30 @@ void test2cells(const unsigned int p1=2, std::vector local_face_dof_indices; std::vector > values; for (typename hp::DoFHandler::active_cell_iterator - cell = dof_handler.begin_active(); + cell = dof_handler.begin_active(); cell != dof_handler.end(); ++cell) - { - const unsigned int fe_index = cell->active_fe_index(); - local_face_dof_indices.resize(fe_collection[fe_index].dofs_per_face); - for (unsigned int f=0; f::faces_per_cell; ++f) - if (!cell->at_boundary(f)) // that's enough for our simple mesh - { - deallog << "cell="<active_fe_index(); + local_face_dof_indices.resize(fe_collection[fe_index].dofs_per_face); + for (unsigned int f=0; f::faces_per_cell; ++f) + if (!cell->at_boundary(f)) // that's enough for our simple mesh + { + deallog << "cell="<(1,2); // Q(1) x FE_Nothing vs Q(2) x Q(1) => common Q(1) x FE_Nothing - test2cells<2>(2,1); // Q(2) x FE_Nothing vs Q(1) x Q(1) => common Q(1) x FE_Nothing - test2cells<3>(1,2); // Q(1) x FE_Nothing vs Q(2) x Q(1) => common Q(1) x FE_Nothing - test2cells<3>(2,1); // Q(2) x FE_Nothing vs Q(1) x Q(1) => common Q(1) x FE_Nothing - } + { + test2cells<2>(1,2); // Q(1) x FE_Nothing vs Q(2) x Q(1) => common Q(1) x FE_Nothing + test2cells<2>(2,1); // Q(2) x FE_Nothing vs Q(1) x Q(1) => common Q(1) x FE_Nothing + test2cells<3>(1,2); // Q(1) x FE_Nothing vs Q(2) x Q(1) => common Q(1) x FE_Nothing + test2cells<3>(2,1); // Q(2) x FE_Nothing vs Q(1) x Q(1) => common Q(1) x FE_Nothing + } catch (std::exception &exc) - { - std::cerr << std::endl << std::endl - << "----------------------------------------------------" - << std::endl; - std::cerr << "Exception on processing: " << std::endl - << exc.what() << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" - << std::endl; - - return 1; - } + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } catch (...) - { - std::cerr << std::endl << std::endl - << "----------------------------------------------------" - << std::endl; - std::cerr << "Unknown exception!" << std::endl - << "Aborting!" << std::endl - << "----------------------------------------------------" - << std::endl; - return 1; - }; + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; } -- 2.39.5