From 9f43ad7b80dd17e1b43bfcb858778b2259df261b Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Fri, 23 Aug 2013 21:37:05 +0000 Subject: [PATCH] text compiles git-svn-id: https://svn.dealii.org/trunk@30462 0785d39b-7218-0410-832d-ea1e28bc413d --- .../assembler_simple_mgmatrix_04.cc | 197 +++++------------- 1 file changed, 51 insertions(+), 146 deletions(-) diff --git a/tests/integrators/assembler_simple_mgmatrix_04.cc b/tests/integrators/assembler_simple_mgmatrix_04.cc index 3a0afec36d..a1d9d7a600 100644 --- a/tests/integrators/assembler_simple_mgmatrix_04.cc +++ b/tests/integrators/assembler_simple_mgmatrix_04.cc @@ -20,84 +20,31 @@ */ #include "../tests.h" +#include +#include #include #include +#include + #include #include #include #include -using namespace dealii; - -template -class LaplaceMatrix : public MeshWorker::LocalIntegrator -{ -public: - LaplaceMatrix(); - virtual void cell(MeshWorker::DoFInfo& dinfo, MeshWorker::IntegrationInfo& info) const; - virtual void boundary(MeshWorker::DoFInfo& dinfo, MeshWorker::IntegrationInfo& info) const; - virtual void face(MeshWorker::DoFInfo& dinfo1, MeshWorker::DoFInfo& dinfo2, - MeshWorker::IntegrationInfo& info1, MeshWorker::IntegrationInfo& info2) const; -}; - +#include -template -LaplaceMatrix::LaplaceMatrix() -{} - - -template -void LaplaceMatrix::cell(MeshWorker::DoFInfo& dinfo, MeshWorker::IntegrationInfo& info) const -{ - const unsigned int n_blocks = dinfo.block_info->local().size(); - AssertDimension (dinfo.n_matrices(), n_blocks*n_blocks); - for(unsigned int b=0; b +#include +#include +#include +#include +#include -template -void LaplaceMatrix::boundary(MeshWorker::DoFInfo& dinfo, - typename MeshWorker::IntegrationInfo& info) const -{ - const unsigned int n_blocks = dinfo.block_info->local().size(); - for(unsigned int b=0; b -void LaplaceMatrix::face( - MeshWorker::DoFInfo& dinfo1, MeshWorker::DoFInfo& dinfo2, - MeshWorker::IntegrationInfo& info1, MeshWorker::IntegrationInfo& info2) const -{ - const unsigned int n_blocks = dinfo1.block_info->local().size(); - for (unsigned int b=0;b::H1)) - continue; - - const unsigned int deg = info1.fe_values(b).get_fe().tensor_degree(); - - if (info1.fe_values(b).get_fe().conforms(FiniteElementData::Hdiv) && - !info1.fe_values(b).get_fe().conforms(FiniteElementData::Hcurl)) - Laplace::ip_tangential_matrix(dinfo1.matrix(diag,false).matrix, dinfo1.matrix(diag,true).matrix, - dinfo2.matrix(diag,true).matrix, dinfo2.matrix(diag,false).matrix, - info1.fe_values(b), info2.fe_values(b), - Laplace::compute_penalty(dinfo1, dinfo2, deg, deg)); - else - Laplace::ip_matrix(dinfo1.matrix(diag,false).matrix, dinfo1.matrix(diag,true).matrix, - dinfo2.matrix(diag,true).matrix, dinfo2.matrix(diag,false).matrix, - info1.fe_values(b), info2.fe_values(b), - Laplace::compute_penalty(dinfo1, dinfo2, deg, deg)); - } -} template class LaplaceMatrix : public MeshWorker::LocalIntegrator @@ -119,10 +66,7 @@ LaplaceMatrix::LaplaceMatrix() template void LaplaceMatrix::cell(MeshWorker::DoFInfo& dinfo, MeshWorker::IntegrationInfo& info) const { - const unsigned int n_blocks = dinfo.block_info->local().size(); - AssertDimension (dinfo.n_matrices(), n_blocks*n_blocks); - for(unsigned int b=0; b void LaplaceMatrix::boundary(MeshWorker::DoFInfo& dinfo, typename MeshWorker::IntegrationInfo& info) const { - const unsigned int n_blocks = dinfo.block_info->local().size(); - for(unsigned int b=0; b::face( MeshWorker::DoFInfo& dinfo1, MeshWorker::DoFInfo& dinfo2, MeshWorker::IntegrationInfo& info1, MeshWorker::IntegrationInfo& info2) const { - const unsigned int n_blocks = dinfo1.block_info->local().size(); - for (unsigned int b=0;b::H1)) - continue; - - const unsigned int deg = info1.fe_values(b).get_fe().tensor_degree(); - - if (info1.fe_values(b).get_fe().conforms(FiniteElementData::Hdiv) && - !info1.fe_values(b).get_fe().conforms(FiniteElementData::Hcurl)) - Laplace::ip_tangential_matrix(dinfo1.matrix(diag,false).matrix, dinfo1.matrix(diag,true).matrix, - dinfo2.matrix(diag,true).matrix, dinfo2.matrix(diag,false).matrix, - info1.fe_values(b), info2.fe_values(b), + if (info1.fe_values().get_fe().conforms(FiniteElementData::H1)) + return; + + const unsigned int deg = info1.fe_values().get_fe().tensor_degree(); + + if (info1.fe_values().get_fe().conforms(FiniteElementData::Hdiv) && + !info1.fe_values().get_fe().conforms(FiniteElementData::Hcurl)) + Laplace::ip_tangential_matrix(dinfo1.matrix(0,false).matrix, dinfo1.matrix(0,true).matrix, + dinfo2.matrix(0,true).matrix, dinfo2.matrix(0,false).matrix, + info1.fe_values(), info2.fe_values(), Laplace::compute_penalty(dinfo1, dinfo2, deg, deg)); else - Laplace::ip_matrix(dinfo1.matrix(diag,false).matrix, dinfo1.matrix(diag,true).matrix, - dinfo2.matrix(diag,true).matrix, dinfo2.matrix(diag,false).matrix, - info1.fe_values(b), info2.fe_values(b), + Laplace::ip_matrix(dinfo1.matrix(0,false).matrix, dinfo1.matrix(0,true).matrix, + dinfo2.matrix(0,true).matrix, dinfo2.matrix(0,false).matrix, + info1.fe_values(), info2.fe_values(), Laplace::compute_penalty(dinfo1, dinfo2, deg, deg)); - } } + template -void assemble_mg_matrix(FiniteElement &fe, Mapping& mapping, DoFHandler& dof_handler, +void assemble_mg_matrix(DoFHandler& dof_handler, MeshWorker::LocalIntegrator& matrix_integrator, mg::SparseMatrixCollection& mg) { + MGConstrainedDoFs mg_constraints; + mg_constraints.clear(); + mg_constraints.initialize(dof_handler); + mg.set_zero(); + + MappingQ1 mapping; MeshWorker::IntegrationInfoBox info_box; UpdateFlags update_flags = update_values | update_gradients | update_hessians; info_box.add_update_flags_all(update_flags); - info_box.initialize(fe, mapping, &dof_handler.block_info()); + info_box.initialize(dof_handler.get_fe(), mapping); - MeshWorker::DoFInfo dof_info(dof_handler.block_info()); + MeshWorker::DoFInfo dof_info(dof_handler); MeshWorker::Assembler::MGMatrixSimple > assembler; assembler.initialize(mg_constraints); @@ -188,13 +130,13 @@ void assemble_mg_matrix(FiniteElement &fe, Mapping& mapping, DoFHandle assembler.initialize_fluxes(mg.matrix_up, mg.matrix_down); MeshWorker::integration_loop ( - mg_dof_handler.begin(), mg_dof_handler.end(), + dof_handler.begin_mg(), dof_handler.end_mg(), dof_info, info_box, matrix_integrator, assembler); - const unsigned int nlevels = triangulation.n_levels(); + const unsigned int nlevels = dof_handler.get_tria().n_levels(); for (unsigned int level=0;level &fe) GridGenerator::subdivided_hyper_rectangle(tr, repititions, p1, p2); tr.begin_active()->set_refine_flag(); tr.execute_coarsening_and_refinement(); - -// MGDoFHandler dof(tr); -// dof.distribute_dofs(fe); -// dof.initialize_local_block_info(); -// DoFRenumbering::component_wise(dof); -// -// deallog << "DoFs " << dof.n_dofs() << std::endl; -// -// typename MGDoFHandler::cell_iterator cell = dof.begin_active(); -// typename MGDoFHandler::face_iterator face = cell->face(1); -// typename MGDoFHandler::cell_iterator neighbor = cell->neighbor(1); -// -// MGLevelObject sparsity(0, tr.n_levels()-1); -// MGLevelObject > matrix(0, tr.n_levels()-1); -// -// for (unsigned int level=0; level > ass; -// ass.initialize(matrix); -// ass.initialize_local_blocks(dof.block_info().local()); -// MeshWorker::DoFInfo info(dof.block_info()); -// ass.initialize_info(info, false); -// MeshWorker::DoFInfo infon(dof.block_info()); -// ass.initialize_info(infon, true); -// -// deallog << "cell" << std::endl; -// info.reinit(cell); -// fill_matrices(info, false); -// ass.assemble(info); -// matrix[1].print_formatted(deallog.get_file_stream(), 0, false, 6); -// matrix[1] = 0.; -// -// deallog << "face" << std::endl; -// ass.initialize_info(info, true); -// info.reinit(cell, face, 1); -// infon.reinit(neighbor, neighbor->face(0), 0); -// fill_matrices(info, true); -// fill_matrices(infon, true); -// ass.assemble(info, infon); -// matrix[1].print_formatted(deallog.get_file_stream(), 0, false, 6); + + LaplaceMatrix matrix_integrator; + + MGDoFHandler dof(tr); + dof.distribute_dofs(fe); + mg::SparseMatrixCollection mg; + mg.resize(0,tr.n_levels()-1); + mg.reinit(dof); + assemble_mg_matrix(dof, matrix_integrator, mg); } int main() -- 2.39.5