From d35b8a8c402a3e617bced992b59cccfb60f8233c Mon Sep 17 00:00:00 2001 From: kanschat Date: Mon, 25 Feb 2013 15:18:15 +0000 Subject: [PATCH] avoid deprecated functions git-svn-id: https://svn.dealii.org/trunk@28552 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-12/step-12.cc | 4 +- deal.II/examples/step-39/step-39.cc | 124 +++++++++++++--------------- 2 files changed, 61 insertions(+), 67 deletions(-) diff --git a/deal.II/examples/step-12/step-12.cc b/deal.II/examples/step-12/step-12.cc index 9963df8e81..2ad4fc7d51 100644 --- a/deal.II/examples/step-12/step-12.cc +++ b/deal.II/examples/step-12/step-12.cc @@ -2,7 +2,7 @@ /* $Id$ */ /* */ -/* Copyright (C) 2010-2012 by the deal.II authors */ +/* Copyright (C) 2010-2013 by the deal.II authors */ /* */ /* This file is subject to QPL and may not be distributed */ /* without copyright and license information. Please refer */ @@ -290,7 +290,7 @@ namespace Step12 // appropriate operator() implementations here, or the result of std::bind // if the local integrators were, for example, non-static member // functions. - MeshWorker::integration_loop + MeshWorker::loop, MeshWorker::IntegrationInfoBox > (dof_handler.begin_active(), dof_handler.end(), dof_info, info_box, &AdvectionProblem::integrate_cell_term, diff --git a/deal.II/examples/step-39/step-39.cc b/deal.II/examples/step-39/step-39.cc index 1df0b1fc8f..c1544a4d5c 100644 --- a/deal.II/examples/step-39/step-39.cc +++ b/deal.II/examples/step-39/step-39.cc @@ -84,17 +84,17 @@ namespace Step39 // cell and face matrices. It is used to assemble the global matrix as well // as the level matrices. template - class MatrixIntegrator : public Subscriptor + class MatrixIntegrator : public MeshWorker::LocalIntegrator { public: - static void cell(MeshWorker::DoFInfo &dinfo, - typename MeshWorker::IntegrationInfo &info); - static void boundary(MeshWorker::DoFInfo &dinfo, - typename MeshWorker::IntegrationInfo &info); - static void face(MeshWorker::DoFInfo &dinfo1, - MeshWorker::DoFInfo &dinfo2, - typename MeshWorker::IntegrationInfo &info1, - typename MeshWorker::IntegrationInfo &info2); + void cell(MeshWorker::DoFInfo &dinfo, + typename MeshWorker::IntegrationInfo &info) const; + void boundary(MeshWorker::DoFInfo &dinfo, + typename MeshWorker::IntegrationInfo &info) const; + void face(MeshWorker::DoFInfo &dinfo1, + MeshWorker::DoFInfo &dinfo2, + typename MeshWorker::IntegrationInfo &info1, + typename MeshWorker::IntegrationInfo &info2) const; }; @@ -110,7 +110,7 @@ namespace Step39 template void MatrixIntegrator::cell( MeshWorker::DoFInfo &dinfo, - typename MeshWorker::IntegrationInfo &info) + typename MeshWorker::IntegrationInfo &info) const { LocalIntegrators::Laplace::cell_matrix(dinfo.matrix(0,false).matrix, info.fe_values()); } @@ -119,7 +119,7 @@ namespace Step39 template void MatrixIntegrator::boundary( MeshWorker::DoFInfo &dinfo, - typename MeshWorker::IntegrationInfo &info) + typename MeshWorker::IntegrationInfo &info) const { const unsigned int deg = info.fe_values(0).get_fe().tensor_degree(); LocalIntegrators::Laplace::nitsche_matrix( @@ -133,7 +133,7 @@ namespace Step39 MeshWorker::DoFInfo &dinfo1, MeshWorker::DoFInfo &dinfo2, typename MeshWorker::IntegrationInfo &info1, - typename MeshWorker::IntegrationInfo &info2) + typename MeshWorker::IntegrationInfo &info2) const { const unsigned int deg = info1.fe_values(0).get_fe().tensor_degree(); LocalIntegrators::Laplace::ip_matrix( @@ -147,25 +147,25 @@ namespace Step39 // the right hand side function is zero, such that only the boundary // condition is set here in weak form. template - class RHSIntegrator : public Subscriptor + class RHSIntegrator : public MeshWorker::LocalIntegrator { public: - static void cell(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info); - static void boundary(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info); - static void face(MeshWorker::DoFInfo &dinfo1, - MeshWorker::DoFInfo &dinfo2, - typename MeshWorker::IntegrationInfo &info1, - typename MeshWorker::IntegrationInfo &info2); + void cell(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info) const; + void boundary(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info) const; + void face(MeshWorker::DoFInfo &dinfo1, + MeshWorker::DoFInfo &dinfo2, + typename MeshWorker::IntegrationInfo &info1, + typename MeshWorker::IntegrationInfo &info2) const; }; template - void RHSIntegrator::cell(MeshWorker::DoFInfo &, typename MeshWorker::IntegrationInfo &) + void RHSIntegrator::cell(MeshWorker::DoFInfo &, typename MeshWorker::IntegrationInfo &) const {} template - void RHSIntegrator::boundary(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info) + void RHSIntegrator::boundary(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info) const { const FEValuesBase &fe = info.fe_values(); Vector &local_vector = dinfo.vector(0).block(0); @@ -188,7 +188,7 @@ namespace Step39 void RHSIntegrator::face(MeshWorker::DoFInfo &, MeshWorker::DoFInfo &, typename MeshWorker::IntegrationInfo &, - typename MeshWorker::IntegrationInfo &) + typename MeshWorker::IntegrationInfo &) const {} @@ -196,22 +196,22 @@ namespace Step39 // error estimate. This is the standard energy estimator due to Karakashian // and Pascal (2003). template - class Estimator : public Subscriptor + class Estimator : public MeshWorker::LocalIntegrator { public: - static void cell(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info); - static void boundary(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info); - static void face(MeshWorker::DoFInfo &dinfo1, - MeshWorker::DoFInfo &dinfo2, - typename MeshWorker::IntegrationInfo &info1, - typename MeshWorker::IntegrationInfo &info2); + void cell(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info) const; + void boundary(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info) const; + void face(MeshWorker::DoFInfo &dinfo1, + MeshWorker::DoFInfo &dinfo2, + typename MeshWorker::IntegrationInfo &info1, + typename MeshWorker::IntegrationInfo &info2) const; }; // The cell contribution is the Laplacian of the discrete solution, since // the right hand side is zero. template - void Estimator::cell(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info) + void Estimator::cell(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info) const { const FEValuesBase &fe = info.fe_values(); @@ -228,7 +228,7 @@ namespace Step39 // namely the norm of the difference between the finite element solution and // the correct boundary condition. template - void Estimator::boundary(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info) + void Estimator::boundary(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info) const { const FEValuesBase &fe = info.fe_values(); @@ -253,7 +253,7 @@ namespace Step39 void Estimator::face(MeshWorker::DoFInfo &dinfo1, MeshWorker::DoFInfo &dinfo2, typename MeshWorker::IntegrationInfo &info1, - typename MeshWorker::IntegrationInfo &info2) + typename MeshWorker::IntegrationInfo &info2) const { const FEValuesBase &fe = info1.fe_values(); const std::vector &uh1 = info1.values[0][0]; @@ -292,15 +292,15 @@ namespace Step39 // 2\sigma_F\|u\|^2_F @f] template - class ErrorIntegrator : public Subscriptor + class ErrorIntegrator : public MeshWorker::LocalIntegrator { public: - static void cell(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info); - static void boundary(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info); - static void face(MeshWorker::DoFInfo &dinfo1, - MeshWorker::DoFInfo &dinfo2, - typename MeshWorker::IntegrationInfo &info1, - typename MeshWorker::IntegrationInfo &info2); + void cell(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info) const; + void boundary(MeshWorker::DoFInfo &dinfo, typename MeshWorker::IntegrationInfo &info) const; + void face(MeshWorker::DoFInfo &dinfo1, + MeshWorker::DoFInfo &dinfo2, + typename MeshWorker::IntegrationInfo &info1, + typename MeshWorker::IntegrationInfo &info2) const; }; // Here we have the integration on cells. There is currently no good @@ -318,7 +318,7 @@ namespace Step39 template void ErrorIntegrator::cell( MeshWorker::DoFInfo &dinfo, - typename MeshWorker::IntegrationInfo &info) + typename MeshWorker::IntegrationInfo &info) const { const FEValuesBase &fe = info.fe_values(); std::vector > exact_gradients(fe.n_quadrature_points); @@ -350,7 +350,7 @@ namespace Step39 template void ErrorIntegrator::boundary( MeshWorker::DoFInfo &dinfo, - typename MeshWorker::IntegrationInfo &info) + typename MeshWorker::IntegrationInfo &info) const { const FEValuesBase &fe = info.fe_values(); @@ -376,7 +376,7 @@ namespace Step39 MeshWorker::DoFInfo &dinfo1, MeshWorker::DoFInfo &dinfo2, typename MeshWorker::IntegrationInfo &info1, - typename MeshWorker::IntegrationInfo &info2) + typename MeshWorker::IntegrationInfo &info2) const { const FEValuesBase &fe = info1.fe_values(); const std::vector &uh1 = info1.values[0][0]; @@ -573,11 +573,16 @@ namespace Step39 // assembler to distribute the information into the global matrix. MeshWorker::DoFInfo dof_info(dof_handler); - // Finally, we need an object that assembles the local matrix into the - // global matrix. + // Furthermore, we need an object that assembles the local matrix into the + // global matrix. These assembler objects have all the knowledge + // of the structures of the target object, in this case a + // SparseMatrix, possible constraints and the mesh structure. MeshWorker::Assembler::MatrixSimple > assembler; assembler.initialize(matrix); + // Now comes the part we coded ourselves, the local + // integrator. This is the only part which is problem dependent. + MatrixIntegrator integrator; // Now, we throw everything into a MeshWorker::loop(), which here // traverses all active cells of the mesh, computes cell and face matrices // and assembles them into the global matrix. We use the variable @@ -586,10 +591,7 @@ namespace Step39 MeshWorker::integration_loop( dof_handler.begin_active(), dof_handler.end(), dof_info, info_box, - &MatrixIntegrator::cell, - &MatrixIntegrator::boundary, - &MatrixIntegrator::face, - assembler); + integrator, assembler); } @@ -612,7 +614,8 @@ namespace Step39 MeshWorker::Assembler::MGMatrixSimple > assembler; assembler.initialize(mg_matrix); assembler.initialize_fluxes(mg_matrix_dg_up, mg_matrix_dg_down); - + + MatrixIntegrator integrator; // Here is the other difference to the previous function: we run over all // cells, not only the active ones. And we use mg_dof_handler, // since we need the degrees of freedom on each level, not the global @@ -620,10 +623,7 @@ namespace Step39 MeshWorker::integration_loop ( mg_dof_handler.begin(), mg_dof_handler.end(), dof_info, info_box, - &MatrixIntegrator::cell, - &MatrixIntegrator::boundary, - &MatrixIntegrator::face, - assembler); + integrator, assembler); } @@ -651,13 +651,11 @@ namespace Step39 data.add(rhs, "RHS"); assembler.initialize(data); + RHSIntegrator integrator; MeshWorker::integration_loop( dof_handler.begin_active(), dof_handler.end(), dof_info, info_box, - &RHSIntegrator::cell, - &RHSIntegrator::boundary, - &RHSIntegrator::face, - assembler); + integrator, assembler); right_hand_side *= -1.; } @@ -790,13 +788,11 @@ namespace Step39 out_data.add(est, "cells"); assembler.initialize(out_data, false); + Estimator integrator; MeshWorker::integration_loop ( dof_handler.begin_active(), dof_handler.end(), dof_info, info_box, - &Estimator::cell, - &Estimator::boundary, - &Estimator::face, - assembler); + integrator, assembler); // Right before we return the result of the error estimate, we restore the // old user indices. @@ -847,13 +843,11 @@ namespace Step39 out_data.add(est, "cells"); assembler.initialize(out_data, false); + ErrorIntegrator integrator; MeshWorker::integration_loop ( dof_handler.begin_active(), dof_handler.end(), dof_info, info_box, - &ErrorIntegrator::cell, - &ErrorIntegrator::boundary, - &ErrorIntegrator::face, - assembler); + integrator, assembler); deallog << "energy-error: " << errors.block(0).l2_norm() << std::endl; deallog << "L2-error: " << errors.block(1).l2_norm() << std::endl; -- 2.39.5