From f70b911ea2a18a1deb2c90ef1771ad4678544957 Mon Sep 17 00:00:00 2001 From: bangerth Date: Fri, 30 Mar 2012 21:44:32 +0000 Subject: [PATCH] Convert tabs into spaces so that editors with different notions how many spaces a tab corresponds to still all show our carefully indented code correctly. git-svn-id: https://svn.dealii.org/trunk@25343 0785d39b-7218-0410-832d-ea1e28bc413d --- .../source/base/auto_derivative_function.cc | 322 +- deal.II/source/base/boost_serialization.cc | 2 +- deal.II/source/base/boost_threads.cc | 2 +- deal.II/source/base/conditional_ostream.cc | 6 +- deal.II/source/base/config.cc | 22 +- deal.II/source/base/convergence_table.cc | 104 +- deal.II/source/base/data_out_base.cc | 5548 ++-- deal.II/source/base/event.cc | 14 +- deal.II/source/base/exceptions.cc | 360 +- deal.II/source/base/flow_function.cc | 572 +- deal.II/source/base/function.cc | 178 +- deal.II/source/base/function_derivative.cc | 168 +- deal.II/source/base/function_lib.cc | 2214 +- deal.II/source/base/function_lib_cutoff.cc | 224 +- deal.II/source/base/function_parser.cc | 170 +- deal.II/source/base/function_time.cc | 6 +- deal.II/source/base/geometry_info.cc | 1264 +- deal.II/source/base/index_set.cc | 300 +- deal.II/source/base/job_identifier.cc | 2 +- deal.II/source/base/logstream.cc | 132 +- deal.II/source/base/memory_consumption.cc | 6 +- deal.II/source/base/mpi.cc | 254 +- deal.II/source/base/multithread_info.cc | 46 +- deal.II/source/base/parallel.cc | 44 +- deal.II/source/base/parameter_handler.cc | 1682 +- deal.II/source/base/parsed_function.cc | 112 +- deal.II/source/base/partitioner.cc | 322 +- deal.II/source/base/path_search.cc | 112 +- deal.II/source/base/polynomial.cc | 546 +- deal.II/source/base/polynomial_space.cc | 142 +- deal.II/source/base/polynomials_abf.cc | 68 +- deal.II/source/base/polynomials_adini.cc | 4 +- deal.II/source/base/polynomials_bdm.cc | 376 +- deal.II/source/base/polynomials_nedelec.cc | 92 +- deal.II/source/base/polynomials_p.cc | 44 +- .../source/base/polynomials_raviart_thomas.cc | 104 +- deal.II/source/base/quadrature.cc | 1418 +- deal.II/source/base/quadrature_lib.cc | 398 +- deal.II/source/base/quadrature_selector.cc | 22 +- deal.II/source/base/subscriptor.cc | 142 +- deal.II/source/base/symmetric_tensor.cc | 74 +- deal.II/source/base/table_handler.cc | 472 +- deal.II/source/base/tensor_function.cc | 14 +- .../source/base/tensor_product_polynomials.cc | 38 +- deal.II/source/base/thread_management.cc | 150 +- deal.II/source/base/timer.cc | 346 +- deal.II/source/base/utilities.cc | 364 +- deal.II/source/distributed/grid_refinement.cc | 1088 +- .../source/distributed/solution_transfer.cc | 142 +- deal.II/source/distributed/tria.cc | 3722 +-- deal.II/source/dofs/block_info.cc | 6 +- deal.II/source/dofs/dof_accessor.cc | 74 +- deal.II/source/dofs/dof_faces.cc | 4 +- deal.II/source/dofs/dof_handler.cc | 1210 +- deal.II/source/dofs/dof_handler_policy.cc | 2838 +- deal.II/source/dofs/dof_levels.cc | 16 +- deal.II/source/dofs/dof_objects.cc | 20 +- deal.II/source/dofs/dof_renumbering.cc | 1476 +- deal.II/source/dofs/dof_tools.cc | 8964 +++---- deal.II/source/dofs/number_cache.cc | 18 +- deal.II/source/fe/fe.cc | 554 +- deal.II/source/fe/fe_abf.cc | 412 +- deal.II/source/fe/fe_bdm.cc | 238 +- deal.II/source/fe/fe_data.cc | 160 +- deal.II/source/fe/fe_dg_vector.cc | 38 +- deal.II/source/fe/fe_dgp.cc | 102 +- deal.II/source/fe/fe_dgp_monomial.cc | 208 +- deal.II/source/fe/fe_dgp_nonparametric.cc | 268 +- deal.II/source/fe/fe_dgq.cc | 546 +- deal.II/source/fe/fe_face.cc | 22 +- deal.II/source/fe/fe_nedelec.cc | 762 +- deal.II/source/fe/fe_nothing.cc | 74 +- deal.II/source/fe/fe_poly.cc | 60 +- deal.II/source/fe/fe_poly_tensor.cc | 1142 +- deal.II/source/fe/fe_q.cc | 1950 +- deal.II/source/fe/fe_q_hierarchical.cc | 2428 +- deal.II/source/fe/fe_raviart_thomas.cc | 348 +- deal.II/source/fe/fe_raviart_thomas_nodal.cc | 600 +- deal.II/source/fe/fe_system.cc | 3176 +-- deal.II/source/fe/fe_tools.cc | 2640 +- deal.II/source/fe/fe_values.cc | 4520 ++-- deal.II/source/fe/mapping.cc | 10 +- deal.II/source/fe/mapping_c1.cc | 262 +- deal.II/source/fe/mapping_cartesian.cc | 568 +- deal.II/source/fe/mapping_q.cc | 1282 +- deal.II/source/fe/mapping_q1.cc | 1898 +- deal.II/source/fe/mapping_q1_eulerian.cc | 88 +- deal.II/source/fe/mapping_q_eulerian.cc | 138 +- deal.II/source/grid/grid_generator.cc | 2566 +- deal.II/source/grid/grid_in.cc | 2022 +- deal.II/source/grid/grid_out.cc | 2614 +- deal.II/source/grid/grid_refinement.cc | 448 +- deal.II/source/grid/grid_reordering.cc | 1538 +- deal.II/source/grid/grid_tools.cc | 2274 +- deal.II/source/grid/intergrid_map.cc | 150 +- deal.II/source/grid/persistent_tria.cc | 56 +- deal.II/source/grid/tria.cc | 21574 ++++++++-------- deal.II/source/grid/tria_accessor.cc | 2286 +- deal.II/source/grid/tria_boundary.cc | 486 +- deal.II/source/grid/tria_boundary_lib.cc | 684 +- deal.II/source/grid/tria_faces.cc | 4 +- deal.II/source/grid/tria_levels.cc | 78 +- deal.II/source/grid/tria_objects.cc | 574 +- deal.II/source/hp/dof_faces.cc | 4 +- deal.II/source/hp/dof_handler.cc | 4562 ++-- deal.II/source/hp/dof_levels.cc | 6 +- deal.II/source/hp/dof_objects.cc | 8 +- deal.II/source/hp/fe_collection.cc | 2 +- deal.II/source/hp/fe_values.cc | 196 +- deal.II/source/hp/mapping_collection.cc | 4 +- deal.II/source/lac/block_matrix_array.cc | 168 +- deal.II/source/lac/block_sparse_matrix.cc | 2 +- deal.II/source/lac/block_sparse_matrix_ez.cc | 2 +- deal.II/source/lac/block_sparsity_pattern.cc | 342 +- deal.II/source/lac/block_vector.cc | 4 +- deal.II/source/lac/chunk_sparse_matrix.cc | 2 +- deal.II/source/lac/chunk_sparsity_pattern.cc | 368 +- .../lac/compressed_set_sparsity_pattern.cc | 64 +- .../lac/compressed_simple_sparsity_pattern.cc | 290 +- .../source/lac/compressed_sparsity_pattern.cc | 342 +- deal.II/source/lac/constraint_matrix.cc | 2596 +- deal.II/source/lac/full_matrix.cc | 4 +- deal.II/source/lac/lapack_full_matrix.cc | 518 +- deal.II/source/lac/matrix_lib.cc | 46 +- deal.II/source/lac/matrix_out.cc | 18 +- deal.II/source/lac/operator.cc | 2 +- deal.II/source/lac/parallel_vector.cc | 2 +- .../source/lac/petsc_block_sparse_matrix.cc | 10 +- deal.II/source/lac/petsc_full_matrix.cc | 2 +- deal.II/source/lac/petsc_matrix_base.cc | 18 +- .../lac/petsc_parallel_block_sparse_matrix.cc | 10 +- .../source/lac/petsc_parallel_block_vector.cc | 6 +- .../lac/petsc_parallel_sparse_matrix.cc | 290 +- deal.II/source/lac/petsc_parallel_vector.cc | 102 +- deal.II/source/lac/petsc_precondition.cc | 166 +- deal.II/source/lac/petsc_solver.cc | 66 +- deal.II/source/lac/petsc_sparse_matrix.cc | 80 +- deal.II/source/lac/petsc_vector.cc | 20 +- deal.II/source/lac/petsc_vector_base.cc | 300 +- deal.II/source/lac/precondition_block.cc | 2 +- deal.II/source/lac/precondition_block_ez.cc | 2 +- deal.II/source/lac/relaxation_block.cc | 2 +- deal.II/source/lac/slepc_solver.cc | 92 +- .../lac/slepc_spectral_transformation.cc | 10 +- deal.II/source/lac/solver.cc | 2 +- deal.II/source/lac/solver_control.cc | 152 +- deal.II/source/lac/sparse_decomposition.cc | 10 +- deal.II/source/lac/sparse_direct.cc | 860 +- deal.II/source/lac/sparse_ilu.cc | 26 +- deal.II/source/lac/sparse_matrix.cc | 2 +- deal.II/source/lac/sparse_matrix_ez.cc | 2 +- deal.II/source/lac/sparse_mic.cc | 10 +- deal.II/source/lac/sparse_vanka.cc | 10 +- deal.II/source/lac/sparsity_pattern.cc | 850 +- deal.II/source/lac/sparsity_tools.cc | 680 +- deal.II/source/lac/swappable_vector.cc | 2 +- deal.II/source/lac/timestep_control.cc | 46 +- deal.II/source/lac/tridiagonal_matrix.cc | 68 +- .../lac/trilinos_block_sparse_matrix.cc | 162 +- deal.II/source/lac/trilinos_block_vector.cc | 100 +- deal.II/source/lac/trilinos_precondition.cc | 408 +- deal.II/source/lac/trilinos_solver.cc | 324 +- deal.II/source/lac/trilinos_sparse_matrix.cc | 1602 +- .../source/lac/trilinos_sparsity_pattern.cc | 482 +- deal.II/source/lac/trilinos_vector.cc | 480 +- deal.II/source/lac/trilinos_vector_base.cc | 204 +- deal.II/source/lac/vector.cc | 6 +- deal.II/source/lac/vector_memory.cc | 84 +- deal.II/source/lac/vector_view.cc | 2 +- deal.II/source/multigrid/mg_base.cc | 2 +- deal.II/source/multigrid/mg_dof_accessor.cc | 382 +- deal.II/source/multigrid/mg_dof_handler.cc | 2128 +- deal.II/source/multigrid/mg_tools.cc | 2724 +- deal.II/source/multigrid/mg_transfer_block.cc | 592 +- .../source/multigrid/mg_transfer_component.cc | 658 +- .../source/multigrid/mg_transfer_prebuilt.cc | 336 +- deal.II/source/multigrid/multigrid.cc | 178 +- deal.II/source/numerics/data_out.cc | 1124 +- deal.II/source/numerics/data_out_faces.cc | 518 +- deal.II/source/numerics/data_out_rotation.cc | 724 +- deal.II/source/numerics/data_out_stack.cc | 404 +- deal.II/source/numerics/data_postprocessor.cc | 70 +- .../numerics/derivative_approximation.cc | 560 +- deal.II/source/numerics/error_estimator.cc | 1904 +- deal.II/source/numerics/fe_field_function.cc | 4 +- deal.II/source/numerics/histogram.cc | 332 +- deal.II/source/numerics/matrices.cc | 4332 ++-- deal.II/source/numerics/mesh_worker.cc | 16 +- deal.II/source/numerics/mesh_worker_info.cc | 2 +- .../numerics/mesh_worker_vector_selector.cc | 2 +- deal.II/source/numerics/operator.cc | 2 +- .../source/numerics/point_value_history.cc | 310 +- deal.II/source/numerics/solution_transfer.cc | 658 +- deal.II/source/numerics/time_dependent.cc | 1320 +- deal.II/source/numerics/vectors.cc | 14 +- 195 files changed, 68514 insertions(+), 68514 deletions(-) diff --git a/deal.II/source/base/auto_derivative_function.cc b/deal.II/source/base/auto_derivative_function.cc index f0875d561f..9e44a3c50d 100644 --- a/deal.II/source/base/auto_derivative_function.cc +++ b/deal.II/source/base/auto_derivative_function.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2005, 2006 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2005, 2006, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -26,10 +26,10 @@ AutoDerivativeFunction (const double hh, const unsigned int n_components, const double initial_time) : - Function(n_components, initial_time), - h(1), - ht(dim), - formula(Euler) + Function(n_components, initial_time), + h(1), + ht(dim), + formula(Euler) { set_h(hh); set_formula(); @@ -63,51 +63,51 @@ AutoDerivativeFunction::set_h (const double hh) template Tensor<1,dim> AutoDerivativeFunction::gradient (const Point &p, - const unsigned int comp) const + const unsigned int comp) const { Tensor<1,dim> grad; switch (formula) { case UpwindEuler: { - Point q1; - for (unsigned int i=0; ivalue(p, comp)-this->value(q1, comp))/h; - } - break; + Point q1; + for (unsigned int i=0; ivalue(p, comp)-this->value(q1, comp))/h; + } + break; } case Euler: { - Point q1, q2; - for (unsigned int i=0; ivalue(q1, comp)-this->value(q2, comp))/(2*h); - } - break; + Point q1, q2; + for (unsigned int i=0; ivalue(q1, comp)-this->value(q2, comp))/(2*h); + } + break; } case FourthOrder: { - Point q1, q2, q3, q4; - for (unsigned int i=0; ivalue(q1, comp) - +8*this->value(q2, comp) - -8*this->value(q3, comp) - + this->value(q4, comp))/(12*h); - - } - break; + Point q1, q2, q3, q4; + for (unsigned int i=0; ivalue(q1, comp) + +8*this->value(q2, comp) + -8*this->value(q3, comp) + + this->value(q4, comp))/(12*h); + + } + break; } default: - Assert(false, ExcInvalidFormula()); + Assert(false, ExcInvalidFormula()); } return grad; } @@ -120,71 +120,71 @@ vector_gradient (const Point &p, std::vector > &gradients) const { Assert (gradients.size() == this->n_components, - ExcDimensionMismatch(gradients.size(), this->n_components)); - + ExcDimensionMismatch(gradients.size(), this->n_components)); + switch (formula) { case UpwindEuler: { - Point q1; - Vector v(this->n_components), v1(this->n_components); - const double h_inv=1./h; - for (unsigned int i=0; ivector_value(p, v); - this->vector_value(q1, v1); - - for (unsigned int comp=0; compn_components; ++comp) - gradients[comp][i]=(v(comp)-v1(comp))*h_inv; - } - break; + Point q1; + Vector v(this->n_components), v1(this->n_components); + const double h_inv=1./h; + for (unsigned int i=0; ivector_value(p, v); + this->vector_value(q1, v1); + + for (unsigned int comp=0; compn_components; ++comp) + gradients[comp][i]=(v(comp)-v1(comp))*h_inv; + } + break; } case Euler: { - Point q1, q2; - Vector v1(this->n_components), v2(this->n_components); - const double h_inv_2=1./(2*h); - for (unsigned int i=0; ivector_value(q1, v1); - this->vector_value(q2, v2); - - for (unsigned int comp=0; compn_components; ++comp) - gradients[comp][i]=(v1(comp)-v2(comp))*h_inv_2; - } - break; + Point q1, q2; + Vector v1(this->n_components), v2(this->n_components); + const double h_inv_2=1./(2*h); + for (unsigned int i=0; ivector_value(q1, v1); + this->vector_value(q2, v2); + + for (unsigned int comp=0; compn_components; ++comp) + gradients[comp][i]=(v1(comp)-v2(comp))*h_inv_2; + } + break; } case FourthOrder: { - Point q1, q2, q3, q4; - Vector - v1(this->n_components), v2(this->n_components), - v3(this->n_components), v4(this->n_components); - const double h_inv_12=1./(12*h); - for (unsigned int i=0; ivector_value(q1, v1); - this->vector_value(q2, v2); - this->vector_value(q3, v3); - this->vector_value(q4, v4); - - for (unsigned int comp=0; compn_components; ++comp) - gradients[comp][i]=(-v1(comp)+8*v2(comp)-8*v3(comp)+v4(comp))*h_inv_12; - } - break; + Point q1, q2, q3, q4; + Vector + v1(this->n_components), v2(this->n_components), + v3(this->n_components), v4(this->n_components); + const double h_inv_12=1./(12*h); + for (unsigned int i=0; ivector_value(q1, v1); + this->vector_value(q2, v2); + this->vector_value(q3, v3); + this->vector_value(q4, v4); + + for (unsigned int comp=0; compn_components; ++comp) + gradients[comp][i]=(-v1(comp)+8*v2(comp)-8*v3(comp)+v4(comp))*h_inv_12; + } + break; } default: - Assert(false, ExcInvalidFormula()); + Assert(false, ExcInvalidFormula()); } } @@ -197,123 +197,123 @@ gradient_list (const std::vector > &points, const unsigned int comp) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); + ExcDimensionMismatch(gradients.size(), points.size())); switch (formula) { case UpwindEuler: { - Point q1; - for (unsigned p=0; pvalue(points[p], comp)-this->value(q1, comp))/h; - } - break; + Point q1; + for (unsigned p=0; pvalue(points[p], comp)-this->value(q1, comp))/h; + } + break; } case Euler: { - Point q1, q2; - for (unsigned p=0; pvalue(q1, comp)-this->value(q2, comp))/(2*h); - } - break; + Point q1, q2; + for (unsigned p=0; pvalue(q1, comp)-this->value(q2, comp))/(2*h); + } + break; } case FourthOrder: { - Point q1, q2, q3, q4; - for (unsigned p=0; pvalue(q1, comp) - +8*this->value(q2, comp) - -8*this->value(q3, comp) - + this->value(q4, comp))/(12*h); - } - break; + Point q1, q2, q3, q4; + for (unsigned p=0; pvalue(q1, comp) + +8*this->value(q2, comp) + -8*this->value(q3, comp) + + this->value(q4, comp))/(12*h); + } + break; } default: - Assert(false, ExcInvalidFormula()); + Assert(false, ExcInvalidFormula()); } } template -void +void AutoDerivativeFunction:: vector_gradient_list (const std::vector > &points, - std::vector > > &gradients) const + std::vector > > &gradients) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); + ExcDimensionMismatch(gradients.size(), points.size())); for (unsigned p=0; pn_components, - ExcDimensionMismatch(gradients.size(), this->n_components)); - + ExcDimensionMismatch(gradients.size(), this->n_components)); + switch (formula) { case UpwindEuler: { - Point q1; - for (unsigned p=0; pn_components; ++comp) - gradients[p][comp][i]=(this->value(points[p], comp)-this->value(q1, comp))/h; - } - break; + Point q1; + for (unsigned p=0; pn_components; ++comp) + gradients[p][comp][i]=(this->value(points[p], comp)-this->value(q1, comp))/h; + } + break; } case Euler: { - Point q1, q2; - for (unsigned p=0; pn_components; ++comp) - gradients[p][comp][i]=(this->value(q1, comp) - + Point q1, q2; + for (unsigned p=0; pn_components; ++comp) + gradients[p][comp][i]=(this->value(q1, comp) - this->value(q2, comp))/(2*h); - } - break; + } + break; } case FourthOrder: { - Point q1, q2, q3, q4; - for (unsigned p=0; pn_components; ++comp) - gradients[p][comp][i]=(- this->value(q1, comp) - +8*this->value(q2, comp) - -8*this->value(q3, comp) - + this->value(q4, comp))/(12*h); - } - break; + Point q1, q2, q3, q4; + for (unsigned p=0; pn_components; ++comp) + gradients[p][comp][i]=(- this->value(q1, comp) + +8*this->value(q2, comp) + -8*this->value(q3, comp) + + this->value(q4, comp))/(12*h); + } + break; } - + default: - Assert(false, ExcInvalidFormula()); + Assert(false, ExcInvalidFormula()); } } @@ -330,7 +330,7 @@ AutoDerivativeFunction::get_formula_of_order(const unsigned int ord) case 3: case 4: return FourthOrder; default: - Assert(false, ExcNotImplemented()); + Assert(false, ExcNotImplemented()); } return Euler; } diff --git a/deal.II/source/base/boost_serialization.cc b/deal.II/source/base/boost_serialization.cc index a9fb070f6e..b196db3253 100644 --- a/deal.II/source/base/boost_serialization.cc +++ b/deal.II/source/base/boost_serialization.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer diff --git a/deal.II/source/base/boost_threads.cc b/deal.II/source/base/boost_threads.cc index bb06118038..ad83f5d26c 100644 --- a/deal.II/source/base/boost_threads.cc +++ b/deal.II/source/base/boost_threads.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer diff --git a/deal.II/source/base/conditional_ostream.cc b/deal.II/source/base/conditional_ostream.cc index 7c3905cb1c..a43a1f8041 100644 --- a/deal.II/source/base/conditional_ostream.cc +++ b/deal.II/source/base/conditional_ostream.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -18,8 +18,8 @@ DEAL_II_NAMESPACE_OPEN ConditionalOStream::ConditionalOStream(std::ostream &stream, const bool active) : - output_stream (stream), - active_flag(active) + output_stream (stream), + active_flag(active) {} diff --git a/deal.II/source/base/config.cc b/deal.II/source/base/config.cc index 2a8f0043b4..a136b22d7f 100644 --- a/deal.II/source/base/config.cc +++ b/deal.II/source/base/config.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2006, 2007, 2010 by the deal.II authors +// Copyright (C) 2006, 2007, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -26,12 +26,12 @@ namespace numbers #ifdef DEAL_II_HAVE_ISFINITE return std::isfinite (x); #else - // Check against infinities. Note - // that if x is a NaN, then both - // comparisons will be false + // Check against infinities. Note + // that if x is a NaN, then both + // comparisons will be false return ((x >= -std::numeric_limits::max()) - && - (x <= std::numeric_limits::max())); + && + (x <= std::numeric_limits::max())); #endif } @@ -39,8 +39,8 @@ namespace numbers bool is_finite (const std::complex &x) { - // Check complex numbers for infinity - // by testing real and imaginary part + // Check complex numbers for infinity + // by testing real and imaginary part return ( is_finite (x.real()) && is_finite (x.imag()) ); @@ -50,8 +50,8 @@ namespace numbers bool is_finite (const std::complex &x) { - // Check complex numbers for infinity - // by testing real and imaginary part + // Check complex numbers for infinity + // by testing real and imaginary part return ( is_finite (x.real()) && is_finite (x.imag()) ); @@ -61,7 +61,7 @@ namespace numbers bool is_finite (const std::complex &x) { - // Same for std::complex + // Same for std::complex return ( is_finite (x.real()) && is_finite (x.imag()) ); diff --git a/deal.II/source/base/convergence_table.cc b/deal.II/source/base/convergence_table.cc index ceb48abf24..56c06f85ed 100644 --- a/deal.II/source/base/convergence_table.cc +++ b/deal.II/source/base/convergence_table.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2011 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -22,20 +22,20 @@ ConvergenceTable::ConvergenceTable() void ConvergenceTable::evaluate_convergence_rates(const std::string &data_column_key, - const std::string &reference_column_key, - const RateMode rate_mode) + const std::string &reference_column_key, + const RateMode rate_mode) { Assert(columns.count(data_column_key), - ExcColumnNotExistent(data_column_key)); + ExcColumnNotExistent(data_column_key)); Assert(columns.count(reference_column_key), - ExcColumnNotExistent(reference_column_key)); + ExcColumnNotExistent(reference_column_key)); if (rate_mode==none) return; - // reset the auto fill mode flag since we - // are going to fill columns from the top - // that don't yet exist + // reset the auto fill mode flag since we + // are going to fill columns from the top + // that don't yet exist set_auto_fill_mode (false); std::vector &entries=columns[data_column_key].entries; @@ -58,29 +58,29 @@ void ConvergenceTable::evaluate_convergence_rates(const std::string &data_column switch (rate_mode) { case none: - break; + break; case reduction_rate: - rate_key+="red.rate"; - Assert(columns.count(rate_key)==0, ExcRateColumnAlreadyExists(rate_key)); - // no value available for the - // first row - add_value(rate_key, std::string("-")); - for (unsigned int i=1; i &entries = columns[data_column_key].entries; @@ -122,40 +122,40 @@ ConvergenceTable::evaluate_convergence_rates(const std::string &data_column_key, switch (rate_mode) { case none: - break; + break; case reduction_rate: - rate_key+="red.rate"; - Assert(columns.count(rate_key)==0, ExcRateColumnAlreadyExists(rate_key)); - // no value available for the - // first row - add_value(rate_key, std::string("-")); - for (unsigned int i=1; i\nbut got\n <" - << arg2 << ">"); + std::string, std::string, + << "Unexpected input: expected line\n <" + << arg1 + << ">\nbut got\n <" + << arg2 << ">"); } namespace { - // the functions in this namespace are - // taken from the libb64 project, see - // http://sourceforge.net/projects/libb64 - // - // libb64 has been placed in the public - // domain + // the functions in this namespace are + // taken from the libb64 project, see + // http://sourceforge.net/projects/libb64 + // + // libb64 has been placed in the public + // domain namespace base64 { typedef enum { - step_A, step_B, step_C + step_A, step_B, step_C } base64_encodestep; typedef struct { - base64_encodestep step; - char result; + base64_encodestep step; + char result; } base64_encodestate; void base64_init_encodestate(base64_encodestate* state_in) @@ -97,15 +97,15 @@ namespace char base64_encode_value(char value_in) { static const char* encoding - = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; if (value_in > 63) return '='; return encoding[(int)value_in]; } int base64_encode_block(const char* plaintext_in, - int length_in, - char* code_out, - base64_encodestate *state_in) + int length_in, + char* code_out, + base64_encodestate *state_in) { const char* plainchar = plaintext_in; const char* const plaintextend = plaintext_in + length_in; @@ -116,46 +116,46 @@ namespace result = state_in->result; switch (state_in->step) - { - while (1) - { - case step_A: - if (plainchar == plaintextend) - { - state_in->result = result; - state_in->step = step_A; - return codechar - code_out; - } - fragment = *plainchar++; - result = (fragment & 0x0fc) >> 2; - *codechar++ = base64_encode_value(result); - result = (fragment & 0x003) << 4; - case step_B: - if (plainchar == plaintextend) - { - state_in->result = result; - state_in->step = step_B; - return codechar - code_out; - } - fragment = *plainchar++; - result |= (fragment & 0x0f0) >> 4; - *codechar++ = base64_encode_value(result); - result = (fragment & 0x00f) << 2; - case step_C: - if (plainchar == plaintextend) - { - state_in->result = result; - state_in->step = step_C; - return codechar - code_out; - } - fragment = *plainchar++; - result |= (fragment & 0x0c0) >> 6; - *codechar++ = base64_encode_value(result); - result = (fragment & 0x03f) >> 0; - *codechar++ = base64_encode_value(result); - } - } - /* control should not reach here */ + { + while (1) + { + case step_A: + if (plainchar == plaintextend) + { + state_in->result = result; + state_in->step = step_A; + return codechar - code_out; + } + fragment = *plainchar++; + result = (fragment & 0x0fc) >> 2; + *codechar++ = base64_encode_value(result); + result = (fragment & 0x003) << 4; + case step_B: + if (plainchar == plaintextend) + { + state_in->result = result; + state_in->step = step_B; + return codechar - code_out; + } + fragment = *plainchar++; + result |= (fragment & 0x0f0) >> 4; + *codechar++ = base64_encode_value(result); + result = (fragment & 0x00f) << 2; + case step_C: + if (plainchar == plaintextend) + { + state_in->result = result; + state_in->step = step_C; + return codechar - code_out; + } + fragment = *plainchar++; + result |= (fragment & 0x0c0) >> 6; + *codechar++ = base64_encode_value(result); + result = (fragment & 0x03f) >> 0; + *codechar++ = base64_encode_value(result); + } + } + /* control should not reach here */ return codechar - code_out; } @@ -164,19 +164,19 @@ namespace char* codechar = code_out; switch (state_in->step) - { - case step_B: - *codechar++ = base64_encode_value(state_in->result); - *codechar++ = '='; - *codechar++ = '='; - break; - case step_C: - *codechar++ = base64_encode_value(state_in->result); - *codechar++ = '='; - break; - case step_A: - break; - } + { + case step_B: + *codechar++ = base64_encode_value(state_in->result); + *codechar++ = '='; + *codechar++ = '='; + break; + case step_C: + *codechar++ = base64_encode_value(state_in->result); + *codechar++ = '='; + break; + case step_A: + break; + } *codechar++ = '\0'; return codechar - code_out; @@ -184,17 +184,17 @@ namespace } - /** - * Do a base64 encoding of the given data. - * - * The function allocates memory as - * necessary and returns a pointer to - * it. The calling function must release - * this memory again. - */ + /** + * Do a base64 encoding of the given data. + * + * The function allocates memory as + * necessary and returns a pointer to + * it. The calling function must release + * this memory again. + */ char * encode_block (const char *data, - const int data_size) + const int data_size) { base64::base64_encodestate state; base64::base64_init_encodestate(&state); @@ -203,9 +203,9 @@ namespace const int encoded_length_data = base64::base64_encode_block (data, data_size, - encoded_data, &state); + encoded_data, &state); base64::base64_encode_blockend (encoded_data + encoded_length_data, - &state); + &state); return encoded_data; } @@ -213,50 +213,50 @@ namespace #ifdef HAVE_LIBZ - /** - * Do a zlib compression followed - * by a base64 encoding of the - * given data. The result is then - * written to the given stream. - */ + /** + * Do a zlib compression followed + * by a base64 encoding of the + * given data. The result is then + * written to the given stream. + */ template void write_compressed_block (const std::vector &data, - std::ostream &output_stream) + std::ostream &output_stream) { if (data.size() != 0) { - // allocate a buffer for compressing - // data and do so - uLongf compressed_data_length - = compressBound (data.size() * sizeof(T)); - char *compressed_data = new char[compressed_data_length]; - int err = compress2 ((Bytef *) compressed_data, - &compressed_data_length, - (const Bytef *) &data[0], - data.size() * sizeof(T), - Z_BEST_COMPRESSION); - Assert (err == Z_OK, ExcInternalError()); - - // now encode the compression header - const uint32_t compression_header[4] - = { 1, /* number of blocks */ - (uint32_t)(data.size() * sizeof(T)), /* size of block */ - (uint32_t)(data.size() * sizeof(T)), /* size of last block */ - (uint32_t)compressed_data_length }; /* list of compressed sizes of blocks */ - - char *encoded_header = encode_block ((char*)&compression_header[0], - 4 * sizeof(compression_header[0])); - output_stream << encoded_header; - delete[] encoded_header; - - // next do the compressed - // data encoding in base64 - char *encoded_data = encode_block (compressed_data, - compressed_data_length); - delete[] compressed_data; - - output_stream << encoded_data; - delete[] encoded_data; + // allocate a buffer for compressing + // data and do so + uLongf compressed_data_length + = compressBound (data.size() * sizeof(T)); + char *compressed_data = new char[compressed_data_length]; + int err = compress2 ((Bytef *) compressed_data, + &compressed_data_length, + (const Bytef *) &data[0], + data.size() * sizeof(T), + Z_BEST_COMPRESSION); + Assert (err == Z_OK, ExcInternalError()); + + // now encode the compression header + const uint32_t compression_header[4] + = { 1, /* number of blocks */ + (uint32_t)(data.size() * sizeof(T)), /* size of block */ + (uint32_t)(data.size() * sizeof(T)), /* size of last block */ + (uint32_t)compressed_data_length }; /* list of compressed sizes of blocks */ + + char *encoded_header = encode_block ((char*)&compression_header[0], + 4 * sizeof(compression_header[0])); + output_stream << encoded_header; + delete[] encoded_header; + + // next do the compressed + // data encoding in base64 + char *encoded_data = encode_block (compressed_data, + compressed_data_length); + delete[] compressed_data; + + output_stream << encoded_data; + delete[] encoded_data; } } #endif @@ -273,29 +273,29 @@ namespace static const char* gmv_cell_type[4] = { - "", "line 2", "quad 4", "hex 8" + "", "line 2", "quad 4", "hex 8" }; static const char* ucd_cell_type[4] = { - "", "line", "quad", "hex" + "", "line", "quad", "hex" }; static const char* tecplot_cell_type[4] = { - "", "lineseg", "quadrilateral", "brick" + "", "lineseg", "quadrilateral", "brick" }; #ifdef DEAL_II_HAVE_TECPLOT static unsigned int tecplot_binary_cell_type[4] = { - 0, 0, 1, 3 + 0, 0, 1, 3 }; #endif static unsigned int vtk_cell_type[4] = { - 0, 3, 9, 12 + 0, 3, 9, 12 }; //----------------------------------------------------------------------// @@ -318,51 +318,51 @@ namespace { if (patch->points_are_available) { - unsigned int point_no=0; - // note: switch without break ! - switch (dim) - { - case 3: - Assert (zstepdata(patch->data.size(0)-spacedim+d,point_no); + unsigned int point_no=0; + // note: switch without break ! + switch (dim) + { + case 3: + Assert (zstepdata(patch->data.size(0)-spacedim+d,point_no); } else { - // perform a dim-linear interpolation - const double stepsize=1./n_subdivisions, - xfrac=xstep*stepsize; - - node = (patch->vertices[1] * xfrac) + (patch->vertices[0] * (1-xfrac)); - if (dim>1) - { - const double yfrac=ystep*stepsize; - node*= 1-yfrac; - node += ((patch->vertices[3] * xfrac) + (patch->vertices[2] * (1-xfrac))) * yfrac; - if (dim>2) - { - const double zfrac=zstep*stepsize; - node *= (1-zfrac); - node += (((patch->vertices[5] * xfrac) + (patch->vertices[4] * (1-xfrac))) - * (1-yfrac) + - ((patch->vertices[7] * xfrac) + (patch->vertices[6] * (1-xfrac))) - * yfrac) * zfrac; - } - } + // perform a dim-linear interpolation + const double stepsize=1./n_subdivisions, + xfrac=xstep*stepsize; + + node = (patch->vertices[1] * xfrac) + (patch->vertices[0] * (1-xfrac)); + if (dim>1) + { + const double yfrac=ystep*stepsize; + node*= 1-yfrac; + node += ((patch->vertices[3] * xfrac) + (patch->vertices[2] * (1-xfrac))) * yfrac; + if (dim>2) + { + const double zfrac=zstep*stepsize; + node *= (1-zfrac); + node += (((patch->vertices[5] * xfrac) + (patch->vertices[4] * (1-xfrac))) + * (1-yfrac) + + ((patch->vertices[7] * xfrac) + (patch->vertices[6] * (1-xfrac))) + * yfrac) * zfrac; + } + } } } @@ -372,16 +372,16 @@ namespace static void compute_sizes(const std::vector >& patches, - unsigned int& n_nodes, - unsigned int& n_cells) + unsigned int& n_nodes, + unsigned int& n_cells) { n_nodes = 0; n_cells = 0; for (typename std::vector >::const_iterator patch=patches.begin(); - patch!=patches.end(); ++patch) + patch!=patches.end(); ++patch) { - n_nodes += Utilities::fixed_power(patch->n_subdivisions+1); - n_cells += Utilities::fixed_power(patch->n_subdivisions); + n_nodes += Utilities::fixed_power(patch->n_subdivisions+1); + n_cells += Utilities::fixed_power(patch->n_subdivisions); } } @@ -389,471 +389,471 @@ namespace - /** - * Class for writing basic - * entities in @ref - * SoftwareOpenDX format, - * depending on the flags. - */ + /** + * Class for writing basic + * entities in @ref + * SoftwareOpenDX format, + * depending on the flags. + */ class DXStream { public: - /** - * Constructor, storing - * persistent values for - * later use. - */ + /** + * Constructor, storing + * persistent values for + * later use. + */ DXStream (std::ostream& stream, - const DataOutBase::DXFlags flags); + const DataOutBase::DXFlags flags); - /** - * Output operator for points. - */ + /** + * Output operator for points. + */ template void write_point (const unsigned int index, - const Point&); + const Point&); - /** - * Do whatever is necessary to - * terminate the list of points. - */ + /** + * Do whatever is necessary to + * terminate the list of points. + */ void flush_points (); - /** - * Write dim-dimensional cell - * with first vertex at - * number start and further - * vertices offset by the - * specified values. Values - * not needed are ignored. - * - * The order of vertices for - * these cells in different - * dimensions is - *
    - *
  1. [0,1] - *
  2. [0,2,1,3] - *
  3. [0,4,2,6,1,5,3,7] - *
- */ + /** + * Write dim-dimensional cell + * with first vertex at + * number start and further + * vertices offset by the + * specified values. Values + * not needed are ignored. + * + * The order of vertices for + * these cells in different + * dimensions is + *
    + *
  1. [0,1] + *
  2. [0,2,1,3] + *
  3. [0,4,2,6,1,5,3,7] + *
+ */ template void write_cell (const unsigned int index, - const unsigned int start, - const unsigned int x_offset, - const unsigned int y_offset, - const unsigned int z_offset); - - /** - * Do whatever is necessary to - * terminate the list of cells. - */ + const unsigned int start, + const unsigned int x_offset, + const unsigned int y_offset, + const unsigned int z_offset); + + /** + * Do whatever is necessary to + * terminate the list of cells. + */ void flush_cells (); - /** - * Write a complete set of - * data for a single node. - * - * The index given as first - * argument indicates the - * number of a data set, as - * some output formats require - * this number to be printed. - */ + /** + * Write a complete set of + * data for a single node. + * + * The index given as first + * argument indicates the + * number of a data set, as + * some output formats require + * this number to be printed. + */ template void write_dataset (const unsigned int index, - const std::vector& values); + const std::vector& values); - /** - * Forwarding of output stream - */ + /** + * Forwarding of output stream + */ template std::ostream& operator<< (const T&); private: - /** - * The ostream to use. Since - * the life span of these - * objects is small, we use a - * very simple storage - * technique. - */ + /** + * The ostream to use. Since + * the life span of these + * objects is small, we use a + * very simple storage + * technique. + */ std::ostream& stream; - /** - * The flags controlling the output - */ + /** + * The flags controlling the output + */ const DataOutBase::DXFlags flags; }; - /** - * Class for writing basic - * entities in @ref SoftwareGMV - * format, depending on the - * flags. - */ + /** + * Class for writing basic + * entities in @ref SoftwareGMV + * format, depending on the + * flags. + */ class GmvStream { public: - /** - * Constructor, storing - * persistent values for - * later use. - */ + /** + * Constructor, storing + * persistent values for + * later use. + */ GmvStream (std::ostream& stream, - const DataOutBase::GmvFlags flags); + const DataOutBase::GmvFlags flags); - /** - * Output operator for points. - */ + /** + * Output operator for points. + */ template void write_point (const unsigned int index, - const Point&); + const Point&); - /** - * Do whatever is necessary to - * terminate the list of points. - */ + /** + * Do whatever is necessary to + * terminate the list of points. + */ void flush_points (); - /** - * Write dim-dimensional cell - * with first vertex at - * number start and further - * vertices offset by the - * specified values. Values - * not needed are ignored. - * - * The order of vertices for - * these cells in different - * dimensions is - *
    - *
  1. [0,1] - *
  2. [0,1,3,2] - *
  3. [0,1,3,2,4,5,7,6] - *
- */ + /** + * Write dim-dimensional cell + * with first vertex at + * number start and further + * vertices offset by the + * specified values. Values + * not needed are ignored. + * + * The order of vertices for + * these cells in different + * dimensions is + *
    + *
  1. [0,1] + *
  2. [0,1,3,2] + *
  3. [0,1,3,2,4,5,7,6] + *
+ */ template void write_cell(const unsigned int index, - const unsigned int start, - const unsigned int x_offset, - const unsigned int y_offset, - const unsigned int z_offset); - - /** - * Do whatever is necessary to - * terminate the list of cells. - */ + const unsigned int start, + const unsigned int x_offset, + const unsigned int y_offset, + const unsigned int z_offset); + + /** + * Do whatever is necessary to + * terminate the list of cells. + */ void flush_cells (); - /** - * Forwarding of output stream - */ + /** + * Forwarding of output stream + */ template std::ostream& operator<< (const T&); - /** - * Since GMV reads the x, y - * and z coordinates in - * separate fields, we enable - * write() to output only a - * single selected component - * at once and do this dim - * times for the whole set of - * nodes. This integer can be - * used to select the - * component written. - */ + /** + * Since GMV reads the x, y + * and z coordinates in + * separate fields, we enable + * write() to output only a + * single selected component + * at once and do this dim + * times for the whole set of + * nodes. This integer can be + * used to select the + * component written. + */ unsigned int selected_component; private: - /** - * The ostream to use. Since - * the life span of these - * objects is small, we use a - * very simple storage - * technique. - */ + /** + * The ostream to use. Since + * the life span of these + * objects is small, we use a + * very simple storage + * technique. + */ std::ostream& stream; - /** - * The flags controlling the output - */ + /** + * The flags controlling the output + */ const DataOutBase::GmvFlags flags; }; - /** - * Class for writing basic - * entities in @ref - * SoftwareTecplot format, - * depending on the flags. - */ + /** + * Class for writing basic + * entities in @ref + * SoftwareTecplot format, + * depending on the flags. + */ class TecplotStream { public: - /** - * Constructor, storing - * persistent values for - * later use. - */ + /** + * Constructor, storing + * persistent values for + * later use. + */ TecplotStream (std::ostream& stream, const DataOutBase::TecplotFlags flags); - /** - * Output operator for points. - */ + /** + * Output operator for points. + */ template void write_point (const unsigned int index, - const Point&); + const Point&); - /** - * Do whatever is necessary to - * terminate the list of points. - */ + /** + * Do whatever is necessary to + * terminate the list of points. + */ void flush_points (); - /** - * Write dim-dimensional cell - * with first vertex at - * number start and further - * vertices offset by the - * specified values. Values - * not needed are ignored. - * - * The order of vertices for - * these cells in different - * dimensions is - *
    - *
  1. [0,1] - *
  2. [0,1,3,2] - *
  3. [0,1,3,2,4,5,7,6] - *
- */ + /** + * Write dim-dimensional cell + * with first vertex at + * number start and further + * vertices offset by the + * specified values. Values + * not needed are ignored. + * + * The order of vertices for + * these cells in different + * dimensions is + *
    + *
  1. [0,1] + *
  2. [0,1,3,2] + *
  3. [0,1,3,2,4,5,7,6] + *
+ */ template void write_cell(const unsigned int index, - const unsigned int start, - const unsigned int x_offset, - const unsigned int y_offset, - const unsigned int z_offset); - - /** - * Do whatever is necessary to - * terminate the list of cells. - */ + const unsigned int start, + const unsigned int x_offset, + const unsigned int y_offset, + const unsigned int z_offset); + + /** + * Do whatever is necessary to + * terminate the list of cells. + */ void flush_cells (); - /** - * Forwarding of output stream - */ + /** + * Forwarding of output stream + */ template std::ostream& operator<< (const T&); - /** - * Since TECPLOT reads the x, y - * and z coordinates in - * separate fields, we enable - * write() to output only a - * single selected component - * at once and do this dim - * times for the whole set of - * nodes. This integer can be - * used to select the - * component written. - */ + /** + * Since TECPLOT reads the x, y + * and z coordinates in + * separate fields, we enable + * write() to output only a + * single selected component + * at once and do this dim + * times for the whole set of + * nodes. This integer can be + * used to select the + * component written. + */ unsigned int selected_component; private: - /** - * The ostream to use. Since - * the life span of these - * objects is small, we use a - * very simple storage - * technique. - */ + /** + * The ostream to use. Since + * the life span of these + * objects is small, we use a + * very simple storage + * technique. + */ std::ostream& stream; - /** - * The flags controlling the output - */ + /** + * The flags controlling the output + */ const DataOutBase::TecplotFlags flags; }; - /** - * Class for writing basic - * entities in UCD format for - * @ref SoftwareAVS, depending on - * the flags. - */ + /** + * Class for writing basic + * entities in UCD format for + * @ref SoftwareAVS, depending on + * the flags. + */ class UcdStream { public: - /** - * Constructor, storing - * persistent values for - * later use. - */ + /** + * Constructor, storing + * persistent values for + * later use. + */ UcdStream (std::ostream& stream, - const DataOutBase::UcdFlags flags); + const DataOutBase::UcdFlags flags); - /** - * Output operator for points. - */ + /** + * Output operator for points. + */ template void write_point (const unsigned int index, - const Point&); + const Point&); - /** - * Do whatever is necessary to - * terminate the list of points. - */ + /** + * Do whatever is necessary to + * terminate the list of points. + */ void flush_points (); - /** - * Write dim-dimensional cell - * with first vertex at - * number start and further - * vertices offset by the - * specified values. Values - * not needed are ignored. - * - * The additional offset 1 is - * added inside this - * function. - * - * The order of vertices for - * these cells in different - * dimensions is - *
    - *
  1. [0,1] - *
  2. [0,1,3,2] - *
  3. [0,1,5,4,2,3,7,6] - *
- */ + /** + * Write dim-dimensional cell + * with first vertex at + * number start and further + * vertices offset by the + * specified values. Values + * not needed are ignored. + * + * The additional offset 1 is + * added inside this + * function. + * + * The order of vertices for + * these cells in different + * dimensions is + *
    + *
  1. [0,1] + *
  2. [0,1,3,2] + *
  3. [0,1,5,4,2,3,7,6] + *
+ */ template void write_cell(const unsigned int index, - const unsigned int start, - const unsigned int x_offset, - const unsigned int y_offset, - const unsigned int z_offset); - - /** - * Do whatever is necessary to - * terminate the list of cells. - */ + const unsigned int start, + const unsigned int x_offset, + const unsigned int y_offset, + const unsigned int z_offset); + + /** + * Do whatever is necessary to + * terminate the list of cells. + */ void flush_cells (); - /** - * Write a complete set of - * data for a single node. - * - * The index given as first - * argument indicates the - * number of a data set, as - * some output formats require - * this number to be printed. - */ + /** + * Write a complete set of + * data for a single node. + * + * The index given as first + * argument indicates the + * number of a data set, as + * some output formats require + * this number to be printed. + */ template void write_dataset (const unsigned int index, - const std::vector &values); + const std::vector &values); - /** - * Forwarding of output stream - */ + /** + * Forwarding of output stream + */ template std::ostream& operator<< (const T&); private: - /** - * The ostream to use. Since - * the life span of these - * objects is small, we use a - * very simple storage - * technique. - */ + /** + * The ostream to use. Since + * the life span of these + * objects is small, we use a + * very simple storage + * technique. + */ std::ostream& stream; - /** - * The flags controlling the output - */ + /** + * The flags controlling the output + */ const DataOutBase::UcdFlags flags; }; - /** - * Class for writing basic - * entities in @ref SoftwareVTK - * format, depending on the - * flags. - */ + /** + * Class for writing basic + * entities in @ref SoftwareVTK + * format, depending on the + * flags. + */ class VtkStream { public: - /** - * Constructor, storing - * persistent values for - * later use. - */ + /** + * Constructor, storing + * persistent values for + * later use. + */ VtkStream (std::ostream& stream, - const DataOutBase::VtkFlags flags); + const DataOutBase::VtkFlags flags); - /** - * Output operator for points. - */ + /** + * Output operator for points. + */ template void write_point (const unsigned int index, - const Point&); + const Point&); - /** - * Do whatever is necessary to - * terminate the list of points. - */ + /** + * Do whatever is necessary to + * terminate the list of points. + */ void flush_points (); - /** - * Write dim-dimensional cell - * with first vertex at - * number start and further - * vertices offset by the - * specified values. Values - * not needed are ignored. - * - * The order of vertices for - * these cells in different - * dimensions is - *
    - *
  1. [0,1] - *
  2. [] - *
  3. [] - *
- */ + /** + * Write dim-dimensional cell + * with first vertex at + * number start and further + * vertices offset by the + * specified values. Values + * not needed are ignored. + * + * The order of vertices for + * these cells in different + * dimensions is + *
    + *
  1. [0,1] + *
  2. [] + *
  3. [] + *
+ */ template void write_cell(const unsigned int index, - const unsigned int start, - const unsigned int x_offset, - const unsigned int y_offset, - const unsigned int z_offset); - - /** - * Do whatever is necessary to - * terminate the list of cells. - */ + const unsigned int start, + const unsigned int x_offset, + const unsigned int y_offset, + const unsigned int z_offset); + + /** + * Do whatever is necessary to + * terminate the list of cells. + */ void flush_cells (); - /** - * Forwarding of output stream - */ + /** + * Forwarding of output stream + */ template std::ostream& operator<< (const T&); private: - /** - * The ostream to use. Since - * the life span of these - * objects is small, we use a - * very simple storage - * technique. - */ + /** + * The ostream to use. Since + * the life span of these + * objects is small, we use a + * very simple storage + * technique. + */ std::ostream& stream; - /** - * The flags controlling the output - */ + /** + * The flags controlling the output + */ const DataOutBase::VtkFlags flags; }; @@ -861,104 +861,104 @@ namespace class VtuStream { public: - /** - * Constructor, storing - * persistent values for - * later use. - */ + /** + * Constructor, storing + * persistent values for + * later use. + */ VtuStream (std::ostream& stream, - const DataOutBase::VtkFlags flags); + const DataOutBase::VtkFlags flags); - /** - * Output operator for points. - */ + /** + * Output operator for points. + */ template void write_point (const unsigned int index, - const Point&); + const Point&); - /** - * Do whatever is necessary to - * terminate the list of points. - */ + /** + * Do whatever is necessary to + * terminate the list of points. + */ void flush_points (); - /** - * Write dim-dimensional cell - * with first vertex at - * number start and further - * vertices offset by the - * specified values. Values - * not needed are ignored. - * - * The order of vertices for - * these cells in different - * dimensions is - *
    - *
  1. [0,1] - *
  2. [] - *
  3. [] - *
- */ + /** + * Write dim-dimensional cell + * with first vertex at + * number start and further + * vertices offset by the + * specified values. Values + * not needed are ignored. + * + * The order of vertices for + * these cells in different + * dimensions is + *
    + *
  1. [0,1] + *
  2. [] + *
  3. [] + *
+ */ template void write_cell(const unsigned int index, - const unsigned int start, - const unsigned int x_offset, - const unsigned int y_offset, - const unsigned int z_offset); - - /** - * Do whatever is necessary to - * terminate the list of cells. - */ + const unsigned int start, + const unsigned int x_offset, + const unsigned int y_offset, + const unsigned int z_offset); + + /** + * Do whatever is necessary to + * terminate the list of cells. + */ void flush_cells (); - /** - * Forwarding of output stream - */ + /** + * Forwarding of output stream + */ template std::ostream& operator<< (const T&); - /** - * Forwarding of output stream. - * - * If libz was found during - * configuration, this operator - * compresses and encodes the - * entire data - * block. Otherwise, it simply - * writes it element by - * element. - */ + /** + * Forwarding of output stream. + * + * If libz was found during + * configuration, this operator + * compresses and encodes the + * entire data + * block. Otherwise, it simply + * writes it element by + * element. + */ template std::ostream& operator<< (const std::vector&); private: - /** - * The ostream to use. Since - * the life span of these - * objects is small, we use a - * very simple storage - * technique. - */ + /** + * The ostream to use. Since + * the life span of these + * objects is small, we use a + * very simple storage + * technique. + */ std::ostream& stream; - /** - * The flags controlling the output - */ + /** + * The flags controlling the output + */ const DataOutBase::VtkFlags flags; - /** - * A list of vertices and - * cells, to be used in case we - * want to compress the data. - * - * The data types of these - * arrays needs to match what - * we print in the XML-preamble - * to the respective parts of - * VTU files (e.g. Float64 and - * Int32) - */ + /** + * A list of vertices and + * cells, to be used in case we + * want to compress the data. + * + * The data types of these + * arrays needs to match what + * we print in the XML-preamble + * to the respective parts of + * VTU files (e.g. Float64 and + * Int32) + */ std::vector vertices; std::vector cells; }; @@ -967,30 +967,30 @@ namespace //----------------------------------------------------------------------// DXStream::DXStream(std::ostream& out, - const DataOutBase::DXFlags f) - : - stream(out), flags(f) + const DataOutBase::DXFlags f) + : + stream(out), flags(f) {} template void DXStream::write_point (const unsigned int, - const Point& p) + const Point& p) { if (flags.coordinates_binary) { - float data[dim]; - for (unsigned int d=0; d(data), - dim * sizeof(*data)); + float data[dim]; + for (unsigned int d=0; d(data), + dim * sizeof(*data)); } else { - for (unsigned int d=0; d::dx_to_deal[1]] = start+d1; if (dim>=2) { - // Add shifted line in y direction - nodes[GeometryInfo::dx_to_deal[2]] = start+d2; - nodes[GeometryInfo::dx_to_deal[3]] = start+d2+d1; - if (dim>=3) - { - // Add shifted quad in z direction - nodes[GeometryInfo::dx_to_deal[4]] = start+d3; - nodes[GeometryInfo::dx_to_deal[5]] = start+d3+d1; - nodes[GeometryInfo::dx_to_deal[6]] = start+d3+d2; - nodes[GeometryInfo::dx_to_deal[7]] = start+d3+d2+d1; - } + // Add shifted line in y direction + nodes[GeometryInfo::dx_to_deal[2]] = start+d2; + nodes[GeometryInfo::dx_to_deal[3]] = start+d2+d1; + if (dim>=3) + { + // Add shifted quad in z direction + nodes[GeometryInfo::dx_to_deal[4]] = start+d3; + nodes[GeometryInfo::dx_to_deal[5]] = start+d3+d1; + nodes[GeometryInfo::dx_to_deal[6]] = start+d3+d2; + nodes[GeometryInfo::dx_to_deal[7]] = start+d3+d2+d1; + } } if (flags.int_binary) stream.write(reinterpret_cast(nodes), - (1< &values) + const std::vector &values) { if (flags.data_binary) { - stream.write(reinterpret_cast(&values[0]), - values.size()*sizeof(data)); + stream.write(reinterpret_cast(&values[0]), + values.size()*sizeof(data)); } else { - for (unsigned int i=0;i void GmvStream::write_point (const unsigned int, - const Point& p) + const Point& p) { Assert(selected_component != numbers::invalid_unsigned_int, - ExcNotInitialized()); + ExcNotInitialized()); stream << p(selected_component) << ' '; } @@ -1101,24 +1101,24 @@ namespace unsigned int d2, unsigned int d3) { - // Vertices are numbered starting - // with one. + // Vertices are numbered starting + // with one. const unsigned int start=s+1; stream << gmv_cell_type[dim] << '\n'; stream << start << '\t' - << start+d1; + << start+d1; if (dim>=2) { - stream << '\t' << start+d2+d1 - << '\t' << start+d2; - if (dim>=3) - { - stream << '\t' << start+d3 - << '\t' << start+d3+d1 - << '\t' << start+d3+d2+d1 - << '\t' << start+d3+d2; - } + stream << '\t' << start+d2+d1 + << '\t' << start+d2; + if (dim>=3) + { + stream << '\t' << start+d3 + << '\t' << start+d3+d1 + << '\t' << start+d3+d2+d1 + << '\t' << start+d3+d2; + } } stream << '\n'; } @@ -1133,19 +1133,19 @@ namespace //----------------------------------------------------------------------// TecplotStream::TecplotStream(std::ostream& out, const DataOutBase::TecplotFlags f) - : - selected_component(numbers::invalid_unsigned_int), - stream(out), flags(f) + : + selected_component(numbers::invalid_unsigned_int), + stream(out), flags(f) {} template void TecplotStream::write_point (const unsigned int, - const Point& p) + const Point& p) { Assert(selected_component != numbers::invalid_unsigned_int, - ExcNotInitialized()); + ExcNotInitialized()); stream << p(selected_component) << '\n'; } @@ -1167,18 +1167,18 @@ namespace const unsigned int start = s+1; stream << start << '\t' - << start+d1; + << start+d1; if (dim>=2) { - stream << '\t' << start+d2+d1 - << '\t' << start+d2; - if (dim>=3) - { - stream << '\t' << start+d3 - << '\t' << start+d3+d1 - << '\t' << start+d3+d2+d1 - << '\t' << start+d3+d2; - } + stream << '\t' << start+d2+d1 + << '\t' << start+d2; + if (dim>=3) + { + stream << '\t' << start+d3 + << '\t' << start+d3+d1 + << '\t' << start+d3+d2+d1 + << '\t' << start+d3+d2; + } } stream << '\n'; } @@ -1194,22 +1194,22 @@ namespace //----------------------------------------------------------------------// UcdStream::UcdStream(std::ostream& out, const DataOutBase::UcdFlags f) - : - stream(out), flags(f) + : + stream(out), flags(f) {} template void UcdStream::write_point (const unsigned int index, - const Point& p) + const Point& p) { stream << index+1 - << " "; - // write out coordinates + << " "; + // write out coordinates for (unsigned int i=0; i::ucd_to_deal[1]] = start+d1; if (dim>=2) { - // Add shifted line in y direction - nodes[GeometryInfo::ucd_to_deal[2]] = start+d2; - nodes[GeometryInfo::ucd_to_deal[3]] = start+d2+d1; - if (dim>=3) - { - // Add shifted quad in z direction - nodes[GeometryInfo::ucd_to_deal[4]] = start+d3; - nodes[GeometryInfo::ucd_to_deal[5]] = start+d3+d1; - nodes[GeometryInfo::ucd_to_deal[6]] = start+d3+d2; - nodes[GeometryInfo::ucd_to_deal[7]] = start+d3+d2+d1; - } + // Add shifted line in y direction + nodes[GeometryInfo::ucd_to_deal[2]] = start+d2; + nodes[GeometryInfo::ucd_to_deal[3]] = start+d2+d1; + if (dim>=3) + { + // Add shifted quad in z direction + nodes[GeometryInfo::ucd_to_deal[4]] = start+d3; + nodes[GeometryInfo::ucd_to_deal[5]] = start+d3+d1; + nodes[GeometryInfo::ucd_to_deal[6]] = start+d3+d2; + nodes[GeometryInfo::ucd_to_deal[7]] = start+d3+d2+d1; + } } - // Write out all cells and remember - // that all indices must be shifted - // by one. + // Write out all cells and remember + // that all indices must be shifted + // by one. stream << index+1 << "\t0 " << ucd_cell_type[dim]; const unsigned int final = (1< &values) + const std::vector &values) { stream << index+1; for (unsigned int i=0;i void VtkStream::write_point (const unsigned int, - const Point& p) + const Point& p) { - // write out coordinates + // write out coordinates stream << p; - // fill with zeroes + // fill with zeroes for (unsigned int i=dim; i<3; ++i) stream << " 0"; stream << '\n'; @@ -1318,19 +1318,19 @@ namespace unsigned int d3) { stream << GeometryInfo::vertices_per_cell << '\t' - << start << '\t' - << start+d1; + << start << '\t' + << start+d1; if (dim>=2) { - stream << '\t' << start+d2+d1 - << '\t' << start+d2; - if (dim>=3) - { - stream << '\t' << start+d3 - << '\t' << start+d3+d1 - << '\t' << start+d3+d2+d1 - << '\t' << start+d3+d2; - } + stream << '\t' << start+d2+d1 + << '\t' << start+d2; + if (dim>=3) + { + stream << '\t' << start+d3 + << '\t' << start+d3+d1 + << '\t' << start+d3+d2+d1 + << '\t' << start+d3+d2; + } } stream << '\n'; } @@ -1343,27 +1343,27 @@ namespace VtuStream::VtuStream(std::ostream& out, const DataOutBase::VtkFlags f) - : - stream(out), flags(f) + : + stream(out), flags(f) {} template void VtuStream::write_point (const unsigned int, - const Point& p) + const Point& p) { #if !defined(HAVE_LIBZ) - // write out coordinates + // write out coordinates stream << p; - // fill with zeroes + // fill with zeroes for (unsigned int i=dim; i<3; ++i) stream << " 0"; stream << '\n'; #else - // if we want to compress, then - // first collect all the data in - // an array + // if we want to compress, then + // first collect all the data in + // an array for (unsigned int i=0; i=2) { - stream << '\t' << start+d2+d1 - << '\t' << start+d2; - if (dim>=3) - { - stream << '\t' << start+d3 - << '\t' << start+d3+d1 - << '\t' << start+d3+d2+d1 - << '\t' << start+d3+d2; - } + stream << '\t' << start+d2+d1 + << '\t' << start+d2; + if (dim>=3) + { + stream << '\t' << start+d3 + << '\t' << start+d3+d1 + << '\t' << start+d3+d2+d1 + << '\t' << start+d3+d2; + } } stream << '\n'; #else @@ -1415,15 +1415,15 @@ namespace cells.push_back (start+d1); if (dim>=2) { - cells.push_back (start+d2+d1); - cells.push_back (start+d2); - if (dim>=3) - { - cells.push_back (start+d3); - cells.push_back (start+d3+d1); - cells.push_back (start+d3+d2+d1); - cells.push_back (start+d3+d2); - } + cells.push_back (start+d2+d1); + cells.push_back (start+d2); + if (dim>=3) + { + cells.push_back (start+d3); + cells.push_back (start+d3+d1); + cells.push_back (start+d3+d2+d1); + cells.push_back (start+d3+d2); + } } #endif } @@ -1434,9 +1434,9 @@ namespace VtuStream::flush_cells () { #ifdef HAVE_LIBZ - // compress the data we have in - // memory and write them to the - // stream. then release the data + // compress the data we have in + // memory and write them to the + // stream. then release the data *this << cells << '\n'; cells.clear (); #endif @@ -1448,9 +1448,9 @@ namespace VtuStream::operator<< (const std::vector &data) { #ifdef HAVE_LIBZ - // compress the data we have in - // memory and write them to the - // stream. then release the data + // compress the data we have in + // memory and write them to the + // stream. then release the data write_compressed_block (data, stream); #else for (unsigned int i=0; i::no_neighbor; template DataOutBase::Patch::Patch () : - patch_index(no_neighbor), - n_subdivisions (1), - points_are_available(false) - // all the other data has a - // constructor of its own, except - // for the "neighbors" field, which - // we set to invalid values. + patch_index(no_neighbor), + n_subdivisions (1), + points_are_available(false) + // all the other data has a + // constructor of its own, except + // for the "neighbors" field, which + // we set to invalid values. { for (unsigned int i=0;i::faces_per_cell;++i) neighbors[i] = no_neighbor; @@ -1562,7 +1562,7 @@ DataOutBase::Patch::operator == (const Patch &patch) const for (unsigned int i=0; i::memory_consumption () const { return (sizeof(vertices) / sizeof(vertices[0]) * - MemoryConsumption::memory_consumption(vertices[0]) - + - MemoryConsumption::memory_consumption(n_subdivisions) - + - MemoryConsumption::memory_consumption(data) - + - MemoryConsumption::memory_consumption(points_are_available)); + MemoryConsumption::memory_consumption(vertices[0]) + + + MemoryConsumption::memory_consumption(n_subdivisions) + + + MemoryConsumption::memory_consumption(data) + + + MemoryConsumption::memory_consumption(points_are_available)); } DataOutBase::UcdFlags::UcdFlags (const bool write_preamble) : - write_preamble (write_preamble) + write_preamble (write_preamble) {} DataOutBase::PovrayFlags::PovrayFlags (const bool smooth, - const bool bicubic_patch, - const bool external_data) + const bool bicubic_patch, + const bool external_data) : - smooth (smooth), - bicubic_patch(bicubic_patch), - external_data(external_data) + smooth (smooth), + bicubic_patch(bicubic_patch), + external_data(external_data) {} DataOutBase::DXFlags::DXFlags (const bool write_neighbors, - const bool int_binary, - const bool coordinates_binary, - const bool data_binary) + const bool int_binary, + const bool coordinates_binary, + const bool data_binary) : - write_neighbors(write_neighbors), - int_binary(int_binary), - coordinates_binary(coordinates_binary), - data_binary(data_binary), - data_double(false) + write_neighbors(write_neighbors), + int_binary(int_binary), + coordinates_binary(coordinates_binary), + data_binary(data_binary), + data_double(false) {} @@ -1625,18 +1625,18 @@ void DataOutBase::DXFlags::declare_parameters (ParameterHandler &prm) prm.declare_entry ("Integer format", "ascii", Patterns::Selection("ascii|32|64"), "Output format of integer numbers, which is " - "either a text representation (ascii) or binary integer " - "values of 32 or 64 bits length"); + "either a text representation (ascii) or binary integer " + "values of 32 or 64 bits length"); prm.declare_entry ("Coordinates format", "ascii", Patterns::Selection("ascii|32|64"), "Output format of vertex coordinates, which is " - "either a text representation (ascii) or binary " - "floating point values of 32 or 64 bits length"); + "either a text representation (ascii) or binary " + "floating point values of 32 or 64 bits length"); prm.declare_entry ("Data format", "ascii", Patterns::Selection("ascii|32|64"), "Output format of data values, which is " - "either a text representation (ascii) or binary " - "floating point values of 32 or 64 bits length"); + "either a text representation (ascii) or binary " + "floating point values of 32 or 64 bits length"); } @@ -1652,8 +1652,8 @@ void DataOutBase::DXFlags::parse_parameters (const ParameterHandler &prm) std::size_t DataOutBase::DXFlags::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } @@ -1681,16 +1681,16 @@ void DataOutBase::UcdFlags::parse_parameters (const ParameterHandler &prm) std::size_t DataOutBase::UcdFlags::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } DataOutBase::GnuplotFlags::GnuplotFlags () - : - dummy (0) + : + dummy (0) {} @@ -1708,8 +1708,8 @@ void DataOutBase::GnuplotFlags::parse_parameters (const ParameterHandler &/*prm* size_t DataOutBase::GnuplotFlags::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } @@ -1719,14 +1719,14 @@ DataOutBase::GnuplotFlags::memory_consumption () const void DataOutBase::PovrayFlags::declare_parameters (ParameterHandler &prm) { prm.declare_entry ("Use smooth triangles", "false", - Patterns::Bool(), + Patterns::Bool(), "A flag indicating whether POVRAY should use smoothed " "triangles instead of the usual ones"); prm.declare_entry ("Use bicubic patches", "false", - Patterns::Bool(), + Patterns::Bool(), "Whether POVRAY should use bicubic patches"); prm.declare_entry ("Include external file", "true", - Patterns::Bool (), + Patterns::Bool (), "Whether camera and lightling information should " "be put into an external file \"data.inc\" or into " "the POVRAY input file"); @@ -1746,46 +1746,46 @@ void DataOutBase::PovrayFlags::parse_parameters (const ParameterHandler &prm) std::size_t DataOutBase::PovrayFlags::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } DataOutBase::EpsFlags::EpsFlags (const unsigned int height_vector, - const unsigned int color_vector, - const SizeType size_type, - const unsigned int size, - const double line_width, - const double azimut_angle, - const double turn_angle, - const double z_scaling, - const bool draw_mesh, - const bool draw_cells, - const bool shade_cells, - const ColorFunction color_function) + const unsigned int color_vector, + const SizeType size_type, + const unsigned int size, + const double line_width, + const double azimut_angle, + const double turn_angle, + const double z_scaling, + const bool draw_mesh, + const bool draw_cells, + const bool shade_cells, + const ColorFunction color_function) : - height_vector(height_vector), - color_vector(color_vector), - size_type(size_type), - size(size), - line_width(line_width), - azimut_angle(azimut_angle), - turn_angle(turn_angle), - z_scaling(z_scaling), - draw_mesh(draw_mesh), - draw_cells(draw_cells), - shade_cells(shade_cells), - color_function(color_function) + height_vector(height_vector), + color_vector(color_vector), + size_type(size_type), + size(size), + line_width(line_width), + azimut_angle(azimut_angle), + turn_angle(turn_angle), + z_scaling(z_scaling), + draw_mesh(draw_mesh), + draw_cells(draw_cells), + shade_cells(shade_cells), + color_function(color_function) {} DataOutBase::EpsFlags::RgbValues DataOutBase::EpsFlags::default_color_function (const double x, - const double xmin, - const double xmax) + const double xmin, + const double xmax) { RgbValues rgb_values = { 0,0,0 }; @@ -1837,29 +1837,29 @@ DataOutBase::EpsFlags::default_color_function (const double x, if (dif!=0) { switch (where) - { - case 0: - rgb_values.red = 0; - rgb_values.green = 0; - rgb_values.blue = (x-xmin)*4.*rezdif; - break; - case 1: - rgb_values.red = 0; - rgb_values.green = (4*x-3*xmin-xmax)*rezdif; - rgb_values.blue = (sum22-4.*x)*rezdif; - break; - case 2: - rgb_values.red = (4*x-2*sum)*rezdif; - rgb_values.green = (xmin+3*xmax-4*x)*rezdif; - rgb_values.blue = 0; - break; - case 3: - rgb_values.red = 1; - rgb_values.green = (4*x-xmin-3*xmax)*rezdif; - rgb_values.blue = (4.*x-sum13)*rezdif; - default: - break; - } + { + case 0: + rgb_values.red = 0; + rgb_values.green = 0; + rgb_values.blue = (x-xmin)*4.*rezdif; + break; + case 1: + rgb_values.red = 0; + rgb_values.green = (4*x-3*xmin-xmax)*rezdif; + rgb_values.blue = (sum22-4.*x)*rezdif; + break; + case 2: + rgb_values.red = (4*x-2*sum)*rezdif; + rgb_values.green = (xmin+3*xmax-4*x)*rezdif; + rgb_values.blue = 0; + break; + case 3: + rgb_values.red = 1; + rgb_values.green = (4*x-xmin-3*xmax)*rezdif; + rgb_values.blue = (4.*x-sum13)*rezdif; + default: + break; + } } else // White rgb_values.red = rgb_values.green = rgb_values.blue = 1; @@ -1871,12 +1871,12 @@ DataOutBase::EpsFlags::default_color_function (const double x, DataOutBase::EpsFlags::RgbValues DataOutBase::EpsFlags::grey_scale_color_function (const double x, - const double xmin, - const double xmax) + const double xmin, + const double xmax) { DataOutBase::EpsFlags::RgbValues rgb_values; rgb_values.red = rgb_values.blue = rgb_values.green - = (x-xmin)/(xmax-xmin); + = (x-xmin)/(xmax-xmin); return rgb_values; } @@ -1884,12 +1884,12 @@ DataOutBase::EpsFlags::grey_scale_color_function (const double x, DataOutBase::EpsFlags::RgbValues DataOutBase::EpsFlags::reverse_grey_scale_color_function (const double x, - const double xmin, - const double xmax) + const double xmin, + const double xmax) { DataOutBase::EpsFlags::RgbValues rgb_values; rgb_values.red = rgb_values.blue = rgb_values.green - = 1-(x-xmin)/(xmax-xmin); + = 1-(x-xmin)/(xmax-xmin); return rgb_values; } @@ -1897,8 +1897,8 @@ DataOutBase::EpsFlags::reverse_grey_scale_color_function (const double x, bool DataOutBase::EpsCell2d::operator < (const EpsCell2d &e) const { - // note the "wrong" order in - // which we sort the elements + // note the "wrong" order in + // which we sort the elements return depth > e.depth; } @@ -1907,50 +1907,50 @@ bool DataOutBase::EpsCell2d::operator < (const EpsCell2d &e) const void DataOutBase::EpsFlags::declare_parameters (ParameterHandler &prm) { prm.declare_entry ("Index of vector for height", "0", - Patterns::Integer(), + Patterns::Integer(), "Number of the input vector that is to be used to " "generate height information"); prm.declare_entry ("Index of vector for color", "0", - Patterns::Integer(), + Patterns::Integer(), "Number of the input vector that is to be used to " "generate color information"); prm.declare_entry ("Scale to width or height", "width", - Patterns::Selection ("width|height"), + Patterns::Selection ("width|height"), "Whether width or height should be scaled to match " "the given size"); prm.declare_entry ("Size (width or height) in eps units", "300", - Patterns::Integer(), + Patterns::Integer(), "The size (width or height) to which the eps output " "file is to be scaled"); prm.declare_entry ("Line widths in eps units", "0.5", - Patterns::Double(), + Patterns::Double(), "The width in which the postscript renderer is to " "plot lines"); prm.declare_entry ("Azimut angle", "60", - Patterns::Double(0,180), + Patterns::Double(0,180), "Angle of the viewing position against the vertical " "axis"); prm.declare_entry ("Turn angle", "30", - Patterns::Double(0,360), + Patterns::Double(0,360), "Angle of the viewing direction against the y-axis"); prm.declare_entry ("Scaling for z-axis", "1", - Patterns::Double (), + Patterns::Double (), "Scaling for the z-direction relative to the scaling " "used in x- and y-directions"); prm.declare_entry ("Draw mesh lines", "true", - Patterns::Bool(), + Patterns::Bool(), "Whether the mesh lines, or only the surface should be " "drawn"); prm.declare_entry ("Fill interior of cells", "true", - Patterns::Bool(), + Patterns::Bool(), "Whether only the mesh lines, or also the interior of " "cells should be plotted. If this flag is false, then " "one can see through the mesh"); prm.declare_entry ("Color shading of interior of cells", "true", - Patterns::Bool(), + Patterns::Bool(), "Whether the interior of cells shall be shaded"); prm.declare_entry ("Color function", "default", - Patterns::Selection ("default|grey scale|reverse grey scale"), + Patterns::Selection ("default|grey scale|reverse grey scale"), "Name of a color function used to colorize mesh lines " "and/or cell interiors"); } @@ -1980,10 +1980,10 @@ void DataOutBase::EpsFlags::parse_parameters (const ParameterHandler &prm) else if (prm.get("Color function") == "reverse grey scale") color_function = &reverse_grey_scale_color_function; else - // we shouldn't get here, since - // the parameter object should - // already have checked that the - // given value is valid + // we shouldn't get here, since + // the parameter object should + // already have checked that the + // given value is valid Assert (false, ExcInternalError()); } @@ -1992,8 +1992,8 @@ void DataOutBase::EpsFlags::parse_parameters (const ParameterHandler &prm) std::size_t DataOutBase::EpsFlags::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } @@ -2016,8 +2016,8 @@ void DataOutBase::GmvFlags::parse_parameters (const ParameterHandler &/*prm*/) c std::size_t DataOutBase::GmvFlags::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } @@ -2025,10 +2025,10 @@ DataOutBase::GmvFlags::memory_consumption () const DataOutBase::TecplotFlags:: TecplotFlags (const char* tecplot_binary_file_name, - const char* zone_name) + const char* zone_name) : tecplot_binary_file_name(tecplot_binary_file_name), - zone_name(zone_name) + zone_name(zone_name) {} @@ -2045,8 +2045,8 @@ void DataOutBase::TecplotFlags::parse_parameters (const ParameterHandler &/*prm* std::size_t DataOutBase::TecplotFlags::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } @@ -2070,16 +2070,16 @@ void DataOutBase::VtkFlags::parse_parameters (const ParameterHandler &/*prm*/) c std::size_t DataOutBase::VtkFlags::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } DataOutBase::Deal_II_IntermediateFlags::Deal_II_IntermediateFlags () - : - dummy (0) + : + dummy (0) {} @@ -2096,8 +2096,8 @@ void DataOutBase::Deal_II_IntermediateFlags::parse_parameters (const ParameterHa std::size_t DataOutBase::Deal_II_IntermediateFlags::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } @@ -2155,7 +2155,7 @@ parse_output_format (const std::string &format_name) AssertThrow (false, ExcMessage ("The given file format name is not recognized.")); - // return something invalid + // return something invalid return OutputFormat(-1); } @@ -2176,32 +2176,32 @@ default_suffix (const OutputFormat output_format) switch (output_format) { case none: - return ""; + return ""; case dx: - return ".dx"; + return ".dx"; case ucd: - return ".inp"; + return ".inp"; case gnuplot: - return ".gnuplot"; + return ".gnuplot"; case povray: - return ".pov"; + return ".pov"; case eps: - return ".eps"; + return ".eps"; case gmv: - return ".gmv"; + return ".gmv"; case tecplot: - return ".dat"; + return ".dat"; case tecplot_binary: - return ".plt"; + return ".plt"; case vtk: - return ".vtk"; + return ".vtk"; case vtu: - return ".vtu"; + return ".vtu"; case deal_II_intermediate: - return ".d2"; + return ".d2"; default: - Assert (false, ExcNotImplemented()); - return ""; + Assert (false, ExcNotImplemented()); + return ""; } } @@ -2211,40 +2211,40 @@ default_suffix (const OutputFormat output_format) template void DataOutBase::write_nodes (const std::vector >& patches, - STREAM& out) + STREAM& out) { Assert (dim<=3, ExcNotImplemented()); unsigned int count = 0; - // We only need this point below, - // but it does not harm to declare - // it here. + // We only need this point below, + // but it does not harm to declare + // it here. Point node; for (typename std::vector >::const_iterator - patch=patches.begin(); + patch=patches.begin(); patch!=patches.end(); ++patch) { const unsigned int n_subdivisions = patch->n_subdivisions; const unsigned int n = n_subdivisions+1; - // Length of loops in all - // dimensions. If a dimension - // is not used, a loop of - // length one will do the job. + // Length of loops in all + // dimensions. If a dimension + // is not used, a loop of + // length one will do the job. const unsigned int n1 = (dim>0) ? n : 1; const unsigned int n2 = (dim>1) ? n : 1; const unsigned int n3 = (dim>2) ? n : 1; for (unsigned int i3=0; i3 >& patches, template void DataOutBase::write_cells (const std::vector >& patches, - STREAM& out) + STREAM& out) { Assert (dim<=3, ExcNotImplemented()); unsigned int count = 0; unsigned int first_vertex_of_patch = 0; - // Array to hold all the node - // numbers of a cell. 8 is - // sufficient for 3D + // Array to hold all the node + // numbers of a cell. 8 is + // sufficient for 3D for (typename std::vector >::const_iterator - patch=patches.begin(); + patch=patches.begin(); patch!=patches.end(); ++patch) { const unsigned int n_subdivisions = patch->n_subdivisions; const unsigned int n = n_subdivisions+1; - // Length of loops in all dimensons + // Length of loops in all dimensons const unsigned int n1 = (dim>0) ? n_subdivisions : 1; const unsigned int n2 = (dim>1) ? n_subdivisions : 1; const unsigned int n3 = (dim>2) ? n_subdivisions : 1; - // Offsets of outer loops + // Offsets of outer loops unsigned int d1 = 1; unsigned int d2 = n; unsigned int d3 = n*n; for (unsigned int i3=0; i3(count++, offset, d1, d2, d3); - } - // finally update the number - // of the first vertex of this patch + for (unsigned int i2=0; i2(count++, offset, d1, d2, d3); + } + // finally update the number + // of the first vertex of this patch first_vertex_of_patch += Utilities::fixed_power(n_subdivisions+1); } @@ -2303,68 +2303,68 @@ DataOutBase::write_data ( unsigned int count = 0; for (typename std::vector >::const_iterator patch - = patches.begin(); + = patches.begin(); patch != patches.end(); ++patch) { const unsigned int n_subdivisions = patch->n_subdivisions; const unsigned int n = n_subdivisions+1; - // Length of loops in all dimensions + // Length of loops in all dimensions Assert ((patch->data.n_rows() == n_data_sets && !patch->points_are_available) || - (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available), - ExcDimensionMismatch (patch->points_are_available - ? - (n_data_sets + spacedim) - : - n_data_sets, - patch->data.n_rows())); + (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available), + ExcDimensionMismatch (patch->points_are_available + ? + (n_data_sets + spacedim) + : + n_data_sets, + patch->data.n_rows())); Assert (patch->data.n_cols() == Utilities::fixed_power(n), - ExcInvalidDatasetSize (patch->data.n_cols(), n)); + ExcInvalidDatasetSize (patch->data.n_cols(), n)); std::vector floats(n_data_sets); std::vector doubles(n_data_sets); - // Data is already in - // lexicographic ordering + // Data is already in + // lexicographic ordering for (unsigned int i=0; i(n); ++i, ++count) - if (double_precision) - { - for (unsigned int data_set=0; data_setdata(data_set, i); - out.write_dataset(count, doubles); - } - else - { - for (unsigned int data_set=0; data_setdata(data_set, i); - out.write_dataset(count, floats); - } + if (double_precision) + { + for (unsigned int data_set=0; data_setdata(data_set, i); + out.write_dataset(count, doubles); + } + else + { + for (unsigned int data_set=0; data_setdata(data_set, i); + out.write_dataset(count, floats); + } } } template void DataOutBase::write_ucd (const std::vector > &patches, - const std::vector &data_names, - const std::vector > &, - const UcdFlags &flags, - std::ostream &out) + const std::vector &data_names, + const std::vector > &, + const UcdFlags &flags, + std::ostream &out) { AssertThrow (out, ExcIO()); #ifndef DEAL_II_COMPILER_SUPPORTS_MPI - // verify that there are indeed - // patches to be written out. most - // of the times, people just forget - // to call build_patches when there - // are no patches, so a warning is - // in order. that said, the - // assertion is disabled if we - // support MPI since then it can - // happen that on the coarsest - // mesh, a processor simply has no - // cells it actually owns, and in - // that case it is legit if there - // are no patches + // verify that there are indeed + // patches to be written out. most + // of the times, people just forget + // to call build_patches when there + // are no patches, so a warning is + // in order. that said, the + // assertion is disabled if we + // support MPI since then it can + // happen that on the coarsest + // mesh, a processor simply has no + // cells it actually owns, and in + // that case it is legit if there + // are no patches Assert (patches.size() > 0, ExcNoPatches()); #else if (patches.size() == 0) @@ -2375,33 +2375,33 @@ void DataOutBase::write_ucd (const std::vector > &patches, UcdStream ucd_out(out, flags); - // first count the number of cells - // and cells for later use + // first count the number of cells + // and cells for later use unsigned int n_nodes; unsigned int n_cells; compute_sizes (patches, n_nodes, n_cells); - /////////////////////// - // preamble + /////////////////////// + // preamble if (flags.write_preamble) { std::time_t time1= std::time (0); std::tm *time = std::localtime(&time1); out << "# This file was generated by the deal.II library." << '\n' - << "# Date = " - << time->tm_year+1900 << "/" - << time->tm_mon+1 << "/" - << time->tm_mday << '\n' - << "# Time = " - << time->tm_hour << ":" - << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << '\n' - << "#" << '\n' - << "# For a description of the UCD format see the AVS Developer's guide." - << '\n' - << "#" << '\n'; + << "# Date = " + << time->tm_year+1900 << "/" + << time->tm_mon+1 << "/" + << time->tm_mday << '\n' + << "# Time = " + << time->tm_hour << ":" + << std::setw(2) << time->tm_min << ":" + << std::setw(2) << time->tm_sec << '\n' + << "#" << '\n' + << "# For a description of the UCD format see the AVS Developer's guide." + << '\n' + << "#" << '\n'; } - // start with ucd data + // start with ucd data out << n_nodes << ' ' << n_cells << ' ' << n_data_sets << ' ' @@ -2415,77 +2415,77 @@ void DataOutBase::write_ucd (const std::vector > &patches, write_cells(patches, ucd_out); out << '\n'; - ///////////////////////////// - // now write data + ///////////////////////////// + // now write data if (n_data_sets != 0) { out << n_data_sets << " "; // number of vectors for (unsigned int i=0; i void DataOutBase::write_dx (const std::vector > &patches, - const std::vector &data_names, - const std::vector > &, - const DXFlags &flags, - std::ostream &out) + const std::vector &data_names, + const std::vector > &, + const DXFlags &flags, + std::ostream &out) { AssertThrow (out, ExcIO()); #ifndef DEAL_II_COMPILER_SUPPORTS_MPI - // verify that there are indeed - // patches to be written out. most - // of the times, people just forget - // to call build_patches when there - // are no patches, so a warning is - // in order. that said, the - // assertion is disabled if we - // support MPI since then it can - // happen that on the coarsest - // mesh, a processor simply has no - // cells it actually owns, and in - // that case it is legit if there - // are no patches + // verify that there are indeed + // patches to be written out. most + // of the times, people just forget + // to call build_patches when there + // are no patches, so a warning is + // in order. that said, the + // assertion is disabled if we + // support MPI since then it can + // happen that on the coarsest + // mesh, a processor simply has no + // cells it actually owns, and in + // that case it is legit if there + // are no patches Assert (patches.size() > 0, ExcNoPatches()); #else if (patches.size() == 0) return; #endif - // Stream with special features for dx output + // Stream with special features for dx output DXStream dx_out(out, flags); - // Variable counting the offset of - // binary data. + // Variable counting the offset of + // binary data. unsigned int offset = 0; const unsigned int n_data_sets = data_names.size(); - // first count the number of cells - // and cells for later use + // first count the number of cells + // and cells for later use unsigned int n_nodes; unsigned int n_cells; compute_sizes(patches, n_nodes, n_cells); - // start with vertices order is - // lexicographical, x varying - // fastest + // start with vertices order is + // lexicographical, x varying + // fastest out << "object \"vertices\" class array type float rank 1 shape " << spacedim << " items " << n_nodes; @@ -2500,11 +2500,11 @@ void DataOutBase::write_dx (const std::vector > &patches, write_nodes(patches, dx_out); } - /////////////////////////////// - // first write the coordinates of all vertices + /////////////////////////////// + // first write the coordinates of all vertices - ///////////////////////////////////////// - // write cells + ///////////////////////////////////////// + // write cells out << "object \"cells\" class array type int rank 1 shape " << GeometryInfo::vertices_per_cell << " items " << n_cells; @@ -2530,159 +2530,159 @@ void DataOutBase::write_dx (const std::vector > &patches, << "attribute \"ref\" string \"positions\"" << '\n'; //TODO:[GK] Patches must be of same size! - ///////////////////////////// - // write neighbor information + ///////////////////////////// + // write neighbor information if (flags.write_neighbors) { out << "object \"neighbors\" class array type int rank 1 shape " - << GeometryInfo::faces_per_cell - << " items " << n_cells - << " data follows"; + << GeometryInfo::faces_per_cell + << " items " << n_cells + << " data follows"; for (typename std::vector >::const_iterator - patch=patches.begin(); - patch!=patches.end(); ++patch) - { - const unsigned int n = patch->n_subdivisions; - const unsigned int n1 = (dim>0) ? n : 1; - const unsigned int n2 = (dim>1) ? n : 1; - const unsigned int n3 = (dim>2) ? n : 1; - unsigned int cells_per_patch = Utilities::fixed_power(n); - unsigned int dx = 1; - unsigned int dy = n; - unsigned int dz = n*n; - - const unsigned int patch_start = patch->patch_index * cells_per_patch; - - for (unsigned int i3=0;i3neighbors[0]; - out << '\t'; - if (nn != patch->no_neighbor) - out << (nn*cells_per_patch+ny+nz+dx*(n-1)); - else - out << "-1"; - } else { - out << '\t' - << patch_start+nx-dx+ny+nz; - } - // Direction +x - // First cell in row - // of other patch - if (i1 == n-1) - { - const unsigned int nn = patch->neighbors[1]; - out << '\t'; - if (nn != patch->no_neighbor) - out << (nn*cells_per_patch+ny+nz); - else - out << "-1"; - } else { - out << '\t' - << patch_start+nx+dx+ny+nz; - } - if (dim<2) - continue; - // Direction -y - if (i2==0) - { - const unsigned int nn = patch->neighbors[2]; - out << '\t'; - if (nn != patch->no_neighbor) - out << (nn*cells_per_patch+nx+nz+dy*(n-1)); - else - out << "-1"; - } else { - out << '\t' - << patch_start+nx+ny-dy+nz; - } - // Direction +y - if (i2 == n-1) - { - const unsigned int nn = patch->neighbors[3]; - out << '\t'; - if (nn != patch->no_neighbor) - out << (nn*cells_per_patch+nx+nz); - else - out << "-1"; - } else { - out << '\t' - << patch_start+nx+ny+dy+nz; - } - if (dim<3) - continue; - - // Direction -z - if (i3==0) - { - const unsigned int nn = patch->neighbors[4]; - out << '\t'; - if (nn != patch->no_neighbor) - out << (nn*cells_per_patch+nx+ny+dz*(n-1)); - else - out << "-1"; - } else { - out << '\t' - << patch_start+nx+ny+nz-dz; - } - // Direction +z - if (i3 == n-1) - { - const unsigned int nn = patch->neighbors[5]; - out << '\t'; - if (nn != patch->no_neighbor) - out << (nn*cells_per_patch+nx+ny); - else - out << "-1"; - } else { - out << '\t' - << patch_start+nx+ny+nz+dz; - } - } - out << '\n'; - } + patch=patches.begin(); + patch!=patches.end(); ++patch) + { + const unsigned int n = patch->n_subdivisions; + const unsigned int n1 = (dim>0) ? n : 1; + const unsigned int n2 = (dim>1) ? n : 1; + const unsigned int n3 = (dim>2) ? n : 1; + unsigned int cells_per_patch = Utilities::fixed_power(n); + unsigned int dx = 1; + unsigned int dy = n; + unsigned int dz = n*n; + + const unsigned int patch_start = patch->patch_index * cells_per_patch; + + for (unsigned int i3=0;i3neighbors[0]; + out << '\t'; + if (nn != patch->no_neighbor) + out << (nn*cells_per_patch+ny+nz+dx*(n-1)); + else + out << "-1"; + } else { + out << '\t' + << patch_start+nx-dx+ny+nz; + } + // Direction +x + // First cell in row + // of other patch + if (i1 == n-1) + { + const unsigned int nn = patch->neighbors[1]; + out << '\t'; + if (nn != patch->no_neighbor) + out << (nn*cells_per_patch+ny+nz); + else + out << "-1"; + } else { + out << '\t' + << patch_start+nx+dx+ny+nz; + } + if (dim<2) + continue; + // Direction -y + if (i2==0) + { + const unsigned int nn = patch->neighbors[2]; + out << '\t'; + if (nn != patch->no_neighbor) + out << (nn*cells_per_patch+nx+nz+dy*(n-1)); + else + out << "-1"; + } else { + out << '\t' + << patch_start+nx+ny-dy+nz; + } + // Direction +y + if (i2 == n-1) + { + const unsigned int nn = patch->neighbors[3]; + out << '\t'; + if (nn != patch->no_neighbor) + out << (nn*cells_per_patch+nx+nz); + else + out << "-1"; + } else { + out << '\t' + << patch_start+nx+ny+dy+nz; + } + if (dim<3) + continue; + + // Direction -z + if (i3==0) + { + const unsigned int nn = patch->neighbors[4]; + out << '\t'; + if (nn != patch->no_neighbor) + out << (nn*cells_per_patch+nx+ny+dz*(n-1)); + else + out << "-1"; + } else { + out << '\t' + << patch_start+nx+ny+nz-dz; + } + // Direction +z + if (i3 == n-1) + { + const unsigned int nn = patch->neighbors[5]; + out << '\t'; + if (nn != patch->no_neighbor) + out << (nn*cells_per_patch+nx+ny); + else + out << "-1"; + } else { + out << '\t' + << patch_start+nx+ny+nz+dz; + } + } + out << '\n'; + } } - ///////////////////////////// - // now write data + ///////////////////////////// + // now write data if (n_data_sets != 0) { out << "object \"data\" class array type float rank 1 shape " - << n_data_sets - << " items " << n_nodes; + << n_data_sets + << " items " << n_nodes; if (flags.data_binary) - { - out << " lsb ieee data " << offset << '\n'; - offset += n_data_sets * n_nodes * ((flags.data_double) - ? sizeof(double) - : sizeof(float)); - } + { + out << " lsb ieee data " << offset << '\n'; + offset += n_data_sets * n_nodes * ((flags.data_double) + ? sizeof(double) + : sizeof(float)); + } else - { - out << " data follows" << '\n'; - write_data(patches, n_data_sets, flags.data_double, dx_out); - } + { + out << " data follows" << '\n'; + write_data(patches, n_data_sets, flags.data_double, dx_out); + } - // loop over all patches + // loop over all patches out << "attribute \"dep\" string \"positions\"" << '\n'; } else { out << "object \"data\" class constantarray type float rank 0 items " << n_nodes << " data follows" - << '\n' << '0' << '\n'; + << '\n' << '0' << '\n'; } - // no model data + // no model data out << "object \"deal data\" class field" << '\n' << "component \"positions\" value \"vertices\"" << '\n' @@ -2697,17 +2697,17 @@ void DataOutBase::write_dx (const std::vector > &patches, std::time_t time1= std::time (0); std::tm *time = std::localtime(&time1); out << "attribute \"created\" string \"" - << time->tm_year+1900 << "/" - << time->tm_mon+1 << "/" - << time->tm_mday - << ' ' - << time->tm_hour << ":" - << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << '"' << '\n'; + << time->tm_year+1900 << "/" + << time->tm_mon+1 << "/" + << time->tm_mday + << ' ' + << time->tm_hour << ":" + << std::setw(2) << time->tm_min << ":" + << std::setw(2) << time->tm_sec << '"' << '\n'; } out << "end" << '\n'; - // Write all binary data now + // Write all binary data now if (flags.coordinates_binary) write_nodes(patches, dx_out); if (flags.int_binary) @@ -2715,11 +2715,11 @@ void DataOutBase::write_dx (const std::vector > &patches, if (flags.data_binary) write_data(patches, n_data_sets, flags.data_double, dx_out); - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); - // assert the stream is still ok + // assert the stream is still ok AssertThrow (out, ExcIO()); } @@ -2727,27 +2727,27 @@ void DataOutBase::write_dx (const std::vector > &patches, template void DataOutBase::write_gnuplot (const std::vector > &patches, - const std::vector &data_names, - const std::vector > &, - const GnuplotFlags &/*flags*/, - std::ostream &out) + const std::vector &data_names, + const std::vector > &, + const GnuplotFlags &/*flags*/, + std::ostream &out) { AssertThrow (out, ExcIO()); #ifndef DEAL_II_COMPILER_SUPPORTS_MPI - // verify that there are indeed - // patches to be written out. most - // of the times, people just forget - // to call build_patches when there - // are no patches, so a warning is - // in order. that said, the - // assertion is disabled if we - // support MPI since then it can - // happen that on the coarsest - // mesh, a processor simply has no - // cells it actually owns, and in - // that case it is legit if there - // are no patches + // verify that there are indeed + // patches to be written out. most + // of the times, people just forget + // to call build_patches when there + // are no patches, so a warning is + // in order. that said, the + // assertion is disabled if we + // support MPI since then it can + // happen that on the coarsest + // mesh, a processor simply has no + // cells it actually owns, and in + // that case it is legit if there + // are no patches Assert (patches.size() > 0, ExcNoPatches()); #else if (patches.size() == 0) @@ -2756,58 +2756,58 @@ void DataOutBase::write_gnuplot (const std::vector > &patche const unsigned int n_data_sets = data_names.size(); - // write preamble + // write preamble if (true) { - // block this to have local - // variables destroyed after - // use + // block this to have local + // variables destroyed after + // use const std::time_t time1= std::time (0); const std::tm *time = std::localtime(&time1); out << "# This file was generated by the deal.II library." << '\n' - << "# Date = " - << time->tm_year+1900 << "/" - << time->tm_mon+1 << "/" - << time->tm_mday << '\n' - << "# Time = " - << time->tm_hour << ":" - << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << '\n' - << "#" << '\n' - << "# For a description of the GNUPLOT format see the GNUPLOT manual." - << '\n' - << "#" << '\n' - << "# "; + << "# Date = " + << time->tm_year+1900 << "/" + << time->tm_mon+1 << "/" + << time->tm_mday << '\n' + << "# Time = " + << time->tm_hour << ":" + << std::setw(2) << time->tm_min << ":" + << std::setw(2) << time->tm_sec << '\n' + << "#" << '\n' + << "# For a description of the GNUPLOT format see the GNUPLOT manual." + << '\n' + << "#" << '\n' + << "# "; switch (spacedim) - { - case 1: - out << " "; - break; - case 2: - out << " "; - break; - case 3: - out << " "; - break; - - default: - Assert (false, ExcNotImplemented()); - } + { + case 1: + out << " "; + break; + case 2: + out << " "; + break; + case 3: + out << " "; + break; + + default: + Assert (false, ExcNotImplemented()); + } for (unsigned int i=0; i "; + out << '<' << data_names[i] << "> "; out << '\n'; } - // loop over all patches + // loop over all patches for (typename std::vector >::const_iterator patch=patches.begin(); patch != patches.end(); ++patch) { const unsigned int n_subdivisions = patch->n_subdivisions; const unsigned int n = n_subdivisions+1; - // Length of loops in all dimensions + // Length of loops in all dimensions const unsigned int n1 = (dim>0) ? n : 1; const unsigned int n2 = (dim>1) ? n : 1; const unsigned int n3 = (dim>2) ? n : 1; @@ -2816,143 +2816,143 @@ void DataOutBase::write_gnuplot (const std::vector > &patche unsigned int d3 = n*n; Assert ((patch->data.n_rows() == n_data_sets && !patch->points_are_available) || - (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available), - ExcDimensionMismatch (patch->points_are_available - ? - (n_data_sets + spacedim) - : - n_data_sets, - patch->data.n_rows())); + (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available), + ExcDimensionMismatch (patch->points_are_available + ? + (n_data_sets + spacedim) + : + n_data_sets, + patch->data.n_rows())); Assert (patch->data.n_cols() == Utilities::fixed_power(n), - ExcInvalidDatasetSize (patch->data.n_cols(), n_subdivisions+1)); + ExcInvalidDatasetSize (patch->data.n_cols(), n_subdivisions+1)); Point this_point; Point node; if (dim<3) - { - for (unsigned int i2=0; i2data(data_set,i1*d1+i2*d2) << ' '; - out << '\n'; - } - // end of row in patch - if (dim>1) - out << '\n'; - } - // end of patch - if (dim==1) - out << '\n'; - out << '\n'; - } + { + for (unsigned int i2=0; i2data(data_set,i1*d1+i2*d2) << ' '; + out << '\n'; + } + // end of row in patch + if (dim>1) + out << '\n'; + } + // end of patch + if (dim==1) + out << '\n'; + out << '\n'; + } else if (dim==3) - { - // for all grid points: draw - // lines into all positive - // coordinate directions if - // there is another grid point - // there - for (unsigned int i3=0; i3data(data_set,i1*d1+i2*d2+i3*d3); - out << '\n'; - - // write point there - // and its data - compute_node(node, &*patch, i1+1, i2, i3, n_subdivisions); - out << node; - - for (unsigned int data_set=0; data_setdata(data_set,(i1+1)*d1+i2*d2+i3*d3); - out << '\n'; - - // end of line - out << '\n' - << '\n'; - } - - // line into positive y-direction - // if possible - if (i2 < n_subdivisions) - { - // write point here - // and its data - out << this_point; - for (unsigned int data_set=0; data_setdata(data_set, i1*d1+i2*d2+i3*d3); - out << '\n'; - - // write point there - // and its data - compute_node(node, &*patch, i1, i2+1, i3, n_subdivisions); - out << node; - - for (unsigned int data_set=0; data_setdata(data_set,i1*d1+(i2+1)*d2+i3*d3); - out << '\n'; - - // end of line - out << '\n' - << '\n'; - } - - // line into positive z-direction - // if possible - if (i3 < n_subdivisions) - { - // write point here - // and its data - out << this_point; - for (unsigned int data_set=0; data_setdata(data_set,i1*d1+i2*d2+i3*d3); - out << '\n'; - - // write point there - // and its data - compute_node(node, &*patch, i1, i2, i3+1, n_subdivisions); - out << node; - - for (unsigned int data_set=0; data_setdata(data_set,i1*d1+i2*d2+(i3+1)*d3); - out << '\n'; - // end of line - out << '\n' - << '\n'; - } - - } - } + { + // for all grid points: draw + // lines into all positive + // coordinate directions if + // there is another grid point + // there + for (unsigned int i3=0; i3data(data_set,i1*d1+i2*d2+i3*d3); + out << '\n'; + + // write point there + // and its data + compute_node(node, &*patch, i1+1, i2, i3, n_subdivisions); + out << node; + + for (unsigned int data_set=0; data_setdata(data_set,(i1+1)*d1+i2*d2+i3*d3); + out << '\n'; + + // end of line + out << '\n' + << '\n'; + } + + // line into positive y-direction + // if possible + if (i2 < n_subdivisions) + { + // write point here + // and its data + out << this_point; + for (unsigned int data_set=0; data_setdata(data_set, i1*d1+i2*d2+i3*d3); + out << '\n'; + + // write point there + // and its data + compute_node(node, &*patch, i1, i2+1, i3, n_subdivisions); + out << node; + + for (unsigned int data_set=0; data_setdata(data_set,i1*d1+(i2+1)*d2+i3*d3); + out << '\n'; + + // end of line + out << '\n' + << '\n'; + } + + // line into positive z-direction + // if possible + if (i3 < n_subdivisions) + { + // write point here + // and its data + out << this_point; + for (unsigned int data_set=0; data_setdata(data_set,i1*d1+i2*d2+i3*d3); + out << '\n'; + + // write point there + // and its data + compute_node(node, &*patch, i1, i2, i3+1, n_subdivisions); + out << node; + + for (unsigned int data_set=0; data_setdata(data_set,i1*d1+i2*d2+(i3+1)*d3); + out << '\n'; + // end of line + out << '\n' + << '\n'; + } + + } + } else - Assert (false, ExcNotImplemented()); + Assert (false, ExcNotImplemented()); } - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); AssertThrow (out, ExcIO()); @@ -2962,27 +2962,27 @@ void DataOutBase::write_gnuplot (const std::vector > &patche template void DataOutBase::write_povray (const std::vector > &patches, - const std::vector &data_names, - const std::vector > &, - const PovrayFlags &flags, - std::ostream &out) + const std::vector &data_names, + const std::vector > &, + const PovrayFlags &flags, + std::ostream &out) { AssertThrow (out, ExcIO()); #ifndef DEAL_II_COMPILER_SUPPORTS_MPI - // verify that there are indeed - // patches to be written out. most - // of the times, people just forget - // to call build_patches when there - // are no patches, so a warning is - // in order. that said, the - // assertion is disabled if we - // support MPI since then it can - // happen that on the coarsest - // mesh, a processor simply has no - // cells it actually owns, and in - // that case it is legit if there - // are no patches + // verify that there are indeed + // patches to be written out. most + // of the times, people just forget + // to call build_patches when there + // are no patches, so a warning is + // in order. that said, the + // assertion is disabled if we + // support MPI since then it can + // happen that on the coarsest + // mesh, a processor simply has no + // cells it actually owns, and in + // that case it is legit if there + // are no patches Assert (patches.size() > 0, ExcNoPatches()); #else if (patches.size() == 0) @@ -2993,61 +2993,61 @@ void DataOutBase::write_povray (const std::vector > &patches const unsigned int n_data_sets = data_names.size(); - // write preamble + // write preamble if (true) { - // block this to have local - // variables destroyed after use + // block this to have local + // variables destroyed after use const std::time_t time1= std::time (0); const std::tm *time = std::localtime(&time1); out << "/* This file was generated by the deal.II library." << '\n' - << " Date = " - << time->tm_year+1900 << "/" - << time->tm_mon+1 << "/" - << time->tm_mday << '\n' - << " Time = " - << time->tm_hour << ":" - << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << '\n' - << '\n' - << " For a description of the POVRAY format see the POVRAY manual." - << '\n' - << "*/ " << '\n'; - - // include files + << " Date = " + << time->tm_year+1900 << "/" + << time->tm_mon+1 << "/" + << time->tm_mday << '\n' + << " Time = " + << time->tm_hour << ":" + << std::setw(2) << time->tm_min << ":" + << std::setw(2) << time->tm_sec << '\n' + << '\n' + << " For a description of the POVRAY format see the POVRAY manual." + << '\n' + << "*/ " << '\n'; + + // include files out << "#include \"colors.inc\" " << '\n' - << "#include \"textures.inc\" " << '\n'; + << "#include \"textures.inc\" " << '\n'; - // use external include file for textures, - // camera and light + // use external include file for textures, + // camera and light if (flags.external_data) - out << "#include \"data.inc\" " << '\n'; + out << "#include \"data.inc\" " << '\n'; else // all definitions in data file - { - // camera - out << '\n' << '\n' - << "camera {" << '\n' - << " location <1,4,-7>" << '\n' - << " look_at <0,0,0>" << '\n' - << " angle 30" << '\n' - << "}" << '\n'; - - // light - out << '\n' - << "light_source {" << '\n' - << " <1,4,-7>" << '\n' - << " color Grey" << '\n' - << "}" << '\n'; - out << '\n' - << "light_source {" << '\n' - << " <0,20,0>" << '\n' - << " color White" << '\n' - << "}" << '\n'; - } + { + // camera + out << '\n' << '\n' + << "camera {" << '\n' + << " location <1,4,-7>" << '\n' + << " look_at <0,0,0>" << '\n' + << " angle 30" << '\n' + << "}" << '\n'; + + // light + out << '\n' + << "light_source {" << '\n' + << " <1,4,-7>" << '\n' + << " color Grey" << '\n' + << "}" << '\n'; + out << '\n' + << "light_source {" << '\n' + << " <0,20,0>" << '\n' + << " color White" << '\n' + << "}" << '\n'; + } } - // max. and min. heigth of solution + // max. and min. heigth of solution typename std::vector >::const_iterator patch=patches.begin(); Assert(patch!=patches.end(), ExcInternalError()); double hmin=patch->data(0,0); @@ -3058,25 +3058,25 @@ void DataOutBase::write_povray (const std::vector > &patches const unsigned int n_subdivisions = patch->n_subdivisions; Assert ((patch->data.n_rows() == n_data_sets && !patch->points_are_available) || - (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available), - ExcDimensionMismatch (patch->points_are_available - ? - (n_data_sets + spacedim) - : - n_data_sets, - patch->data.n_rows())); + (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available), + ExcDimensionMismatch (patch->points_are_available + ? + (n_data_sets + spacedim) + : + n_data_sets, + patch->data.n_rows())); Assert (patch->data.n_cols() == Utilities::fixed_power(n_subdivisions+1), - ExcInvalidDatasetSize (patch->data.n_cols(), n_subdivisions+1)); + ExcInvalidDatasetSize (patch->data.n_cols(), n_subdivisions+1)); for (unsigned int i=0; idata(0,dl)data(0,dl); - if (patch->data(0,dl)>hmax) - hmax=patch->data(0,dl); - } + for (unsigned int j=0; jdata(0,dl)data(0,dl); + if (patch->data(0,dl)>hmax) + hmax=patch->data(0,dl); + } } out << "#declare HMIN=" << hmin << ";" << '\n' @@ -3084,26 +3084,26 @@ void DataOutBase::write_povray (const std::vector > &patches if (!flags.external_data) { - // texture with scaled niveau lines - // 10 lines in the surface + // texture with scaled niveau lines + // 10 lines in the surface out << "#declare Tex=texture{" << '\n' - << " pigment {" << '\n' - << " gradient y" << '\n' - << " scale y*(HMAX-HMIN)*" << 0.1 << '\n' - << " color_map {" << '\n' - << " [0.00 color Light_Purple] " << '\n' - << " [0.95 color Light_Purple] " << '\n' - << " [1.00 color White] " << '\n' - << "} } }" << '\n' << '\n'; + << " pigment {" << '\n' + << " gradient y" << '\n' + << " scale y*(HMAX-HMIN)*" << 0.1 << '\n' + << " color_map {" << '\n' + << " [0.00 color Light_Purple] " << '\n' + << " [0.95 color Light_Purple] " << '\n' + << " [1.00 color White] " << '\n' + << "} } }" << '\n' << '\n'; } if (!flags.bicubic_patch) { // start of mesh header out << '\n' - << "mesh {" << '\n'; + << "mesh {" << '\n'; } - // loop over all patches + // loop over all patches for (typename std::vector >::const_iterator patch=patches.begin(); patch != patches.end(); ++patch) { @@ -3113,210 +3113,210 @@ void DataOutBase::write_povray (const std::vector > &patches const unsigned int d2=n; Assert ((patch->data.n_rows() == n_data_sets && !patch->points_are_available) || - (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available), - ExcDimensionMismatch (patch->points_are_available - ? - (n_data_sets + spacedim) - : - n_data_sets, - patch->data.n_rows())); + (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available), + ExcDimensionMismatch (patch->points_are_available + ? + (n_data_sets + spacedim) + : + n_data_sets, + patch->data.n_rows())); Assert (patch->data.n_cols() == Utilities::fixed_power(n), - ExcInvalidDatasetSize (patch->data.n_cols(), n_subdivisions+1)); + ExcInvalidDatasetSize (patch->data.n_cols(), n_subdivisions+1)); std::vector > ver(n*n); for (unsigned int i2=0; i2 > nrml; - // only if smooth triangles are used - if (flags.smooth) - { - nrml.resize(n*n); - // These are - // difference - // quotients of - // the surface - // mapping. We - // take them - // symmetric - // inside the - // patch and - // one-sided at - // the edges - Point<3> h1,h2; - // Now compute normals in every point - for (unsigned int i=0; idata(0,ir*d1+j*d2)- - patch->data(0,il*d1+j*d2); - h1(2)=ver[ir*d1+j*d2](1) - ver[il*d1+j*d2](1); - - h2(0)=ver[i*d1+jr*d2](0) - ver[i*d1+jl*d2](0); - h2(1)=patch->data(0,i*d1+jr*d2)- - patch->data(0,i*d1+jl*d2); - h2(2)=ver[i*d1+jr*d2](1) - ver[i*d1+jl*d2](1); - - nrml[i*d1+j*d2](0)=h1(1)*h2(2)-h1(2)*h2(1); - nrml[i*d1+j*d2](1)=h1(2)*h2(0)-h1(0)*h2(2); - nrml[i*d1+j*d2](2)=h1(0)*h2(1)-h1(1)*h2(0); - - // normalize Vector - double norm=std::sqrt( - std::pow(nrml[i*d1+j*d2](0),2.)+ - std::pow(nrml[i*d1+j*d2](1),2.)+ - std::pow(nrml[i*d1+j*d2](2),2.)); - - if (nrml[i*d1+j*d2](1)<0) - norm*=-1.; - - for (unsigned int k=0;k<3;++k) - nrml[i*d1+j*d2](k)/=norm; - } - } - - // setting up triangles - for (unsigned int i=0; idata(0,dl) << "," - << ver[dl](1) << ">, <" - << nrml[dl](0) << ", " - << nrml[dl](1) << ", " - << nrml[dl](2) - << ">," << '\n'; - out << " \t<" - << ver[dl+d1](0) << "," - << patch->data(0,dl+d1) << "," - << ver[dl+d1](1) << ">, <" - << nrml[dl+d1](0) << ", " - << nrml[dl+d1](1) << ", " - << nrml[dl+d1](2) - << ">," << '\n'; - out << "\t<" - << ver[dl+d1+d2](0) << "," - << patch->data(0,dl+d1+d2) << "," - << ver[dl+d1+d2](1) << ">, <" - << nrml[dl+d1+d2](0) << ", " - << nrml[dl+d1+d2](1) << ", " - << nrml[dl+d1+d2](2) - << ">}" << '\n'; - - // upper/left triangle - out << "smooth_triangle {" << '\n' << "\t<" - << ver[dl](0) << "," - << patch->data(0,dl) << "," - << ver[dl](1) << ">, <" - << nrml[dl](0) << ", " - << nrml[dl](1) << ", " - << nrml[dl](2) - << ">," << '\n'; - out << "\t<" - << ver[dl+d1+d2](0) << "," - << patch->data(0,dl+d1+d2) << "," - << ver[dl+d1+d2](1) << ">, <" - << nrml[dl+d1+d2](0) << ", " - << nrml[dl+d1+d2](1) << ", " - << nrml[dl+d1+d2](2) - << ">," << '\n'; - out << "\t<" - << ver[dl+d2](0) << "," - << patch->data(0,dl+d2) << "," - << ver[dl+d2](1) << ">, <" - << nrml[dl+d2](0) << ", " - << nrml[dl+d2](1) << ", " - << nrml[dl+d2](2) - << ">}" << '\n'; - } - else - { - // writing standard triangles - // down/right triangle - out << "triangle {" << '\n' << "\t<" - << ver[dl](0) << "," - << patch->data(0,dl) << "," - << ver[dl](1) << ">," << '\n'; - out << "\t<" - << ver[dl+d1](0) << "," - << patch->data(0,dl+d1) << "," - << ver[dl+d1](1) << ">," << '\n'; - out << "\t<" - << ver[dl+d1+d2](0) << "," - << patch->data(0,dl+d1+d2) << "," - << ver[dl+d1+d2](1) << ">}" << '\n'; - - // upper/left triangle - out << "triangle {" << '\n' << "\t<" - << ver[dl](0) << "," - << patch->data(0,dl) << "," - << ver[dl](1) << ">," << '\n'; - out << "\t<" - << ver[dl+d1+d2](0) << "," - << patch->data(0,dl+d1+d2) << "," - << ver[dl+d1+d2](1) << ">," << '\n'; - out << "\t<" - << ver[dl+d2](0) << "," - << patch->data(0,dl+d2) << "," - << ver[dl+d2](1) << ">}" << '\n'; - } - } - } + { + // aproximate normal + // vectors in patch + std::vector > nrml; + // only if smooth triangles are used + if (flags.smooth) + { + nrml.resize(n*n); + // These are + // difference + // quotients of + // the surface + // mapping. We + // take them + // symmetric + // inside the + // patch and + // one-sided at + // the edges + Point<3> h1,h2; + // Now compute normals in every point + for (unsigned int i=0; idata(0,ir*d1+j*d2)- + patch->data(0,il*d1+j*d2); + h1(2)=ver[ir*d1+j*d2](1) - ver[il*d1+j*d2](1); + + h2(0)=ver[i*d1+jr*d2](0) - ver[i*d1+jl*d2](0); + h2(1)=patch->data(0,i*d1+jr*d2)- + patch->data(0,i*d1+jl*d2); + h2(2)=ver[i*d1+jr*d2](1) - ver[i*d1+jl*d2](1); + + nrml[i*d1+j*d2](0)=h1(1)*h2(2)-h1(2)*h2(1); + nrml[i*d1+j*d2](1)=h1(2)*h2(0)-h1(0)*h2(2); + nrml[i*d1+j*d2](2)=h1(0)*h2(1)-h1(1)*h2(0); + + // normalize Vector + double norm=std::sqrt( + std::pow(nrml[i*d1+j*d2](0),2.)+ + std::pow(nrml[i*d1+j*d2](1),2.)+ + std::pow(nrml[i*d1+j*d2](2),2.)); + + if (nrml[i*d1+j*d2](1)<0) + norm*=-1.; + + for (unsigned int k=0;k<3;++k) + nrml[i*d1+j*d2](k)/=norm; + } + } + + // setting up triangles + for (unsigned int i=0; idata(0,dl) << "," + << ver[dl](1) << ">, <" + << nrml[dl](0) << ", " + << nrml[dl](1) << ", " + << nrml[dl](2) + << ">," << '\n'; + out << " \t<" + << ver[dl+d1](0) << "," + << patch->data(0,dl+d1) << "," + << ver[dl+d1](1) << ">, <" + << nrml[dl+d1](0) << ", " + << nrml[dl+d1](1) << ", " + << nrml[dl+d1](2) + << ">," << '\n'; + out << "\t<" + << ver[dl+d1+d2](0) << "," + << patch->data(0,dl+d1+d2) << "," + << ver[dl+d1+d2](1) << ">, <" + << nrml[dl+d1+d2](0) << ", " + << nrml[dl+d1+d2](1) << ", " + << nrml[dl+d1+d2](2) + << ">}" << '\n'; + + // upper/left triangle + out << "smooth_triangle {" << '\n' << "\t<" + << ver[dl](0) << "," + << patch->data(0,dl) << "," + << ver[dl](1) << ">, <" + << nrml[dl](0) << ", " + << nrml[dl](1) << ", " + << nrml[dl](2) + << ">," << '\n'; + out << "\t<" + << ver[dl+d1+d2](0) << "," + << patch->data(0,dl+d1+d2) << "," + << ver[dl+d1+d2](1) << ">, <" + << nrml[dl+d1+d2](0) << ", " + << nrml[dl+d1+d2](1) << ", " + << nrml[dl+d1+d2](2) + << ">," << '\n'; + out << "\t<" + << ver[dl+d2](0) << "," + << patch->data(0,dl+d2) << "," + << ver[dl+d2](1) << ">, <" + << nrml[dl+d2](0) << ", " + << nrml[dl+d2](1) << ", " + << nrml[dl+d2](2) + << ">}" << '\n'; + } + else + { + // writing standard triangles + // down/right triangle + out << "triangle {" << '\n' << "\t<" + << ver[dl](0) << "," + << patch->data(0,dl) << "," + << ver[dl](1) << ">," << '\n'; + out << "\t<" + << ver[dl+d1](0) << "," + << patch->data(0,dl+d1) << "," + << ver[dl+d1](1) << ">," << '\n'; + out << "\t<" + << ver[dl+d1+d2](0) << "," + << patch->data(0,dl+d1+d2) << "," + << ver[dl+d1+d2](1) << ">}" << '\n'; + + // upper/left triangle + out << "triangle {" << '\n' << "\t<" + << ver[dl](0) << "," + << patch->data(0,dl) << "," + << ver[dl](1) << ">," << '\n'; + out << "\t<" + << ver[dl+d1+d2](0) << "," + << patch->data(0,dl+d1+d2) << "," + << ver[dl+d1+d2](1) << ">," << '\n'; + out << "\t<" + << ver[dl+d2](0) << "," + << patch->data(0,dl+d2) << "," + << ver[dl+d2](1) << ">}" << '\n'; + } + } + } else - { // writing bicubic_patch - Assert (n_subdivisions==3, ExcDimensionMismatch(n_subdivisions,3)); - out << '\n' - << "bicubic_patch {" << '\n' - << " type 0" << '\n' - << " flatness 0" << '\n' - << " u_steps 0" << '\n' - << " v_steps 0" << '\n'; - for (int i=0;i<16;++i) - { - out << "\t<" << ver[i](0) << "," << patch->data(0,i) << "," << ver[i](1) << ">"; - if (i!=15) out << ","; - out << '\n'; - } - out << " texture {Tex}" << '\n' - << "}" << '\n'; - } + { // writing bicubic_patch + Assert (n_subdivisions==3, ExcDimensionMismatch(n_subdivisions,3)); + out << '\n' + << "bicubic_patch {" << '\n' + << " type 0" << '\n' + << " flatness 0" << '\n' + << " u_steps 0" << '\n' + << " v_steps 0" << '\n'; + for (int i=0;i<16;++i) + { + out << "\t<" << ver[i](0) << "," << patch->data(0,i) << "," << ver[i](1) << ">"; + if (i!=15) out << ","; + out << '\n'; + } + out << " texture {Tex}" << '\n' + << "}" << '\n'; + } } if (!flags.bicubic_patch) { // the end of the mesh out << " texture {Tex}" << '\n' - << "}" << '\n' - << '\n'; + << "}" << '\n' + << '\n'; } - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); AssertThrow (out, ExcIO()); @@ -3326,70 +3326,70 @@ void DataOutBase::write_povray (const std::vector > &patches template void DataOutBase::write_eps (const std::vector > &patches, - const std::vector &/*data_names*/, - const std::vector > &, - const EpsFlags &flags, - std::ostream &out) + const std::vector &/*data_names*/, + const std::vector > &, + const EpsFlags &flags, + std::ostream &out) { Assert (out, ExcIO()); #ifndef DEAL_II_COMPILER_SUPPORTS_MPI - // verify that there are indeed - // patches to be written out. most - // of the times, people just forget - // to call build_patches when there - // are no patches, so a warning is - // in order. that said, the - // assertion is disabled if we - // support MPI since then it can - // happen that on the coarsest - // mesh, a processor simply has no - // cells it actually owns, and in - // that case it is legit if there - // are no patches + // verify that there are indeed + // patches to be written out. most + // of the times, people just forget + // to call build_patches when there + // are no patches, so a warning is + // in order. that said, the + // assertion is disabled if we + // support MPI since then it can + // happen that on the coarsest + // mesh, a processor simply has no + // cells it actually owns, and in + // that case it is legit if there + // are no patches Assert (patches.size() > 0, ExcNoPatches()); #else if (patches.size() == 0) return; #endif - // Do not allow volume rendering + // Do not allow volume rendering AssertThrow (dim==2, ExcNotImplemented()); const unsigned int old_precision = out.precision(); - // set up an array of cells to be - // written later. this array holds the - // cells of all the patches as - // projected to the plane perpendicular - // to the line of sight. - // - // note that they are kept sorted by - // the set, where we chose the value - // of the center point of the cell - // along the line of sight as value - // for sorting + // set up an array of cells to be + // written later. this array holds the + // cells of all the patches as + // projected to the plane perpendicular + // to the line of sight. + // + // note that they are kept sorted by + // the set, where we chose the value + // of the center point of the cell + // along the line of sight as value + // for sorting std::multiset cells; - // two variables in which we - // will store the minimum and - // maximum values of the field - // to be used for colorization - // - // preset them by 0 to calm down the - // compiler; they are initialized later + // two variables in which we + // will store the minimum and + // maximum values of the field + // to be used for colorization + // + // preset them by 0 to calm down the + // compiler; they are initialized later double min_color_value=0, max_color_value=0; - // Array for z-coordinates of points. - // The elevation determined by a function if spacedim=2 - // or the z-cooridate of the grid point if spacedim=3 + // Array for z-coordinates of points. + // The elevation determined by a function if spacedim=2 + // or the z-cooridate of the grid point if spacedim=3 double heights[4] = { 0, 0, 0, 0 }; - // compute the cells for output and - // enter them into the set above - // note that since dim==2, we - // have exactly four vertices per - // patch and per cell + // compute the cells for output and + // enter them into the set above + // note that since dim==2, we + // have exactly four vertices per + // patch and per cell for (typename std::vector >::const_iterator patch=patches.begin(); patch!=patches.end(); ++patch) { @@ -3399,303 +3399,303 @@ void DataOutBase::write_eps (const std::vector > &patches, const unsigned int d2 = n; for (unsigned int i2=0; i2 points[4]; - compute_node(points[0], &*patch, i1, i2, 0, n_subdivisions); - compute_node(points[1], &*patch, i1+1, i2, 0, n_subdivisions); - compute_node(points[2], &*patch, i1, i2+1, 0, n_subdivisions); - compute_node(points[3], &*patch, i1+1, i2+1, 0, n_subdivisions); - - switch (spacedim) - { - case 2: - Assert ((flags.height_vector < patch->data.n_rows()) || - patch->data.n_rows() == 0, - ExcIndexRange (flags.height_vector, 0, - patch->data.n_rows())); - heights[0] = patch->data.n_rows() != 0 ? - patch->data(flags.height_vector,i1*d1 + i2*d2) * flags.z_scaling - : 0; - heights[1] = patch->data.n_rows() != 0 ? - patch->data(flags.height_vector,(i1+1)*d1 + i2*d2) * flags.z_scaling - : 0; - heights[2] = patch->data.n_rows() != 0 ? - patch->data(flags.height_vector,i1*d1 + (i2+1)*d2) * flags.z_scaling - : 0; - heights[3] = patch->data.n_rows() != 0 ? - patch->data(flags.height_vector,(i1+1)*d1 + (i2+1)*d2) * flags.z_scaling - : 0; - - break; - case 3: - // Copy z-coordinates into the height vector - for (unsigned int i=0;i<4;++i) - heights[i] = points[i](2); - break; - default: - Assert(false, ExcNotImplemented()); - } - - - // now compute the projection of - // the bilinear cell given by the - // four vertices and their heights - // and write them to a proper - // cell object. note that we only - // need the first two components - // of the projected position for - // output, but we need the value - // along the line of sight for - // sorting the cells for back-to- - // front-output - // - // this computation was first written - // by Stefan Nauber. please no-one - // ask me why it works that way (or - // may be not), especially not about - // the angles and the sign of - // the height field, I don't know - // it. - EpsCell2d eps_cell; - const double pi = numbers::PI; - const double cx = -std::cos(pi-flags.azimut_angle * 2*pi / 360.), - cz = -std::cos(flags.turn_angle * 2*pi / 360.), - sx = std::sin(pi-flags.azimut_angle * 2*pi / 360.), - sz = std::sin(flags.turn_angle * 2*pi / 360.); - for (unsigned int vertex=0; vertex<4; ++vertex) - { - const double x = points[vertex](0), - y = points[vertex](1), - z = -heights[vertex]; - - eps_cell.vertices[vertex](0) = - cz*x+ sz*y; - eps_cell.vertices[vertex](1) = -cx*sz*x-cx*cz*y-sx*z; - - // ( 1 0 0 ) - // D1 = ( 0 cx -sx ) - // ( 0 sx cx ) - - // ( cy 0 sy ) - // Dy = ( 0 1 0 ) - // (-sy 0 cy ) - - // ( cz -sz 0 ) - // Dz = ( sz cz 0 ) - // ( 0 0 1 ) + for (unsigned int i1=0; i1 points[4]; + compute_node(points[0], &*patch, i1, i2, 0, n_subdivisions); + compute_node(points[1], &*patch, i1+1, i2, 0, n_subdivisions); + compute_node(points[2], &*patch, i1, i2+1, 0, n_subdivisions); + compute_node(points[3], &*patch, i1+1, i2+1, 0, n_subdivisions); + + switch (spacedim) + { + case 2: + Assert ((flags.height_vector < patch->data.n_rows()) || + patch->data.n_rows() == 0, + ExcIndexRange (flags.height_vector, 0, + patch->data.n_rows())); + heights[0] = patch->data.n_rows() != 0 ? + patch->data(flags.height_vector,i1*d1 + i2*d2) * flags.z_scaling + : 0; + heights[1] = patch->data.n_rows() != 0 ? + patch->data(flags.height_vector,(i1+1)*d1 + i2*d2) * flags.z_scaling + : 0; + heights[2] = patch->data.n_rows() != 0 ? + patch->data(flags.height_vector,i1*d1 + (i2+1)*d2) * flags.z_scaling + : 0; + heights[3] = patch->data.n_rows() != 0 ? + patch->data(flags.height_vector,(i1+1)*d1 + (i2+1)*d2) * flags.z_scaling + : 0; + + break; + case 3: + // Copy z-coordinates into the height vector + for (unsigned int i=0;i<4;++i) + heights[i] = points[i](2); + break; + default: + Assert(false, ExcNotImplemented()); + } + + + // now compute the projection of + // the bilinear cell given by the + // four vertices and their heights + // and write them to a proper + // cell object. note that we only + // need the first two components + // of the projected position for + // output, but we need the value + // along the line of sight for + // sorting the cells for back-to- + // front-output + // + // this computation was first written + // by Stefan Nauber. please no-one + // ask me why it works that way (or + // may be not), especially not about + // the angles and the sign of + // the height field, I don't know + // it. + EpsCell2d eps_cell; + const double pi = numbers::PI; + const double cx = -std::cos(pi-flags.azimut_angle * 2*pi / 360.), + cz = -std::cos(flags.turn_angle * 2*pi / 360.), + sx = std::sin(pi-flags.azimut_angle * 2*pi / 360.), + sz = std::sin(flags.turn_angle * 2*pi / 360.); + for (unsigned int vertex=0; vertex<4; ++vertex) + { + const double x = points[vertex](0), + y = points[vertex](1), + z = -heights[vertex]; + + eps_cell.vertices[vertex](0) = - cz*x+ sz*y; + eps_cell.vertices[vertex](1) = -cx*sz*x-cx*cz*y-sx*z; + + // ( 1 0 0 ) + // D1 = ( 0 cx -sx ) + // ( 0 sx cx ) + + // ( cy 0 sy ) + // Dy = ( 0 1 0 ) + // (-sy 0 cy ) + + // ( cz -sz 0 ) + // Dz = ( sz cz 0 ) + // ( 0 0 1 ) // ( cz -sz 0 )( 1 0 0 )(x) ( cz*x-sz*(cx*y-sx*z)+0*(sx*y+cx*z) ) // Dxz = ( sz cz 0 )( 0 cx -sx )(y) = ( sz*x+cz*(cx*y-sx*z)+0*(sx*y+cx*z) ) -// ( 0 0 1 )( 0 sx cx )(z) ( 0*x+ *(cx*y-sx*z)+1*(sx*y+cx*z) ) - } - - // compute coordinates of - // center of cell - const Point center_point - = (points[0] + points[1] + points[2] + points[3]) / 4; - const double center_height - = -(heights[0] + heights[1] + heights[2] + heights[3]) / 4; - - // compute the depth into - // the picture - eps_cell.depth = -sx*sz*center_point(0) - -sx*cz*center_point(1) - +cx*center_height; - - if (flags.draw_cells && flags.shade_cells) - { - Assert ((flags.color_vector < patch->data.n_rows()) || - patch->data.n_rows() == 0, - ExcIndexRange (flags.color_vector, 0, - patch->data.n_rows())); - const double color_values[4] - = { patch->data.n_rows() != 0 ? - patch->data(flags.color_vector,i1*d1 + i2*d2) : 1, - - patch->data.n_rows() != 0 ? - patch->data(flags.color_vector,(i1+1)*d1 + i2*d2) : 1, - - patch->data.n_rows() != 0 ? - patch->data(flags.color_vector,i1*d1 + (i2+1)*d2) : 1, - - patch->data.n_rows() != 0 ? - patch->data(flags.color_vector,(i1+1)*d1 + (i2+1)*d2) : 1}; - - // set color value to average of the value - // at the vertices - eps_cell.color_value = (color_values[0] + - color_values[1] + - color_values[3] + - color_values[2]) / 4; - - // update bounds of color - // field - if (patch == patches.begin()) - min_color_value = max_color_value = eps_cell.color_value; - else - { - min_color_value = (min_color_value < eps_cell.color_value ? - min_color_value : eps_cell.color_value); - max_color_value = (max_color_value > eps_cell.color_value ? - max_color_value : eps_cell.color_value); - } - } - - // finally add this cell - cells.insert (eps_cell); - } +// ( 0 0 1 )( 0 sx cx )(z) ( 0*x+ *(cx*y-sx*z)+1*(sx*y+cx*z) ) + } + + // compute coordinates of + // center of cell + const Point center_point + = (points[0] + points[1] + points[2] + points[3]) / 4; + const double center_height + = -(heights[0] + heights[1] + heights[2] + heights[3]) / 4; + + // compute the depth into + // the picture + eps_cell.depth = -sx*sz*center_point(0) + -sx*cz*center_point(1) + +cx*center_height; + + if (flags.draw_cells && flags.shade_cells) + { + Assert ((flags.color_vector < patch->data.n_rows()) || + patch->data.n_rows() == 0, + ExcIndexRange (flags.color_vector, 0, + patch->data.n_rows())); + const double color_values[4] + = { patch->data.n_rows() != 0 ? + patch->data(flags.color_vector,i1*d1 + i2*d2) : 1, + + patch->data.n_rows() != 0 ? + patch->data(flags.color_vector,(i1+1)*d1 + i2*d2) : 1, + + patch->data.n_rows() != 0 ? + patch->data(flags.color_vector,i1*d1 + (i2+1)*d2) : 1, + + patch->data.n_rows() != 0 ? + patch->data(flags.color_vector,(i1+1)*d1 + (i2+1)*d2) : 1}; + + // set color value to average of the value + // at the vertices + eps_cell.color_value = (color_values[0] + + color_values[1] + + color_values[3] + + color_values[2]) / 4; + + // update bounds of color + // field + if (patch == patches.begin()) + min_color_value = max_color_value = eps_cell.color_value; + else + { + min_color_value = (min_color_value < eps_cell.color_value ? + min_color_value : eps_cell.color_value); + max_color_value = (max_color_value > eps_cell.color_value ? + max_color_value : eps_cell.color_value); + } + } + + // finally add this cell + cells.insert (eps_cell); + } } - // find out minimum and maximum x and - // y coordinates to compute offsets - // and scaling factors + // find out minimum and maximum x and + // y coordinates to compute offsets + // and scaling factors double x_min = cells.begin()->vertices[0](0); double x_max = x_min; double y_min = cells.begin()->vertices[0](1); double y_max = y_min; for (typename std::multiset::const_iterator - cell=cells.begin(); + cell=cells.begin(); cell!=cells.end(); ++cell) for (unsigned int vertex=0; vertex<4; ++vertex) { - x_min = std::min (x_min, cell->vertices[vertex](0)); - x_max = std::max (x_max, cell->vertices[vertex](0)); - y_min = std::min (y_min, cell->vertices[vertex](1)); - y_max = std::max (y_max, cell->vertices[vertex](1)); + x_min = std::min (x_min, cell->vertices[vertex](0)); + x_max = std::max (x_max, cell->vertices[vertex](0)); + y_min = std::min (y_min, cell->vertices[vertex](1)); + y_max = std::max (y_max, cell->vertices[vertex](1)); } - // scale in x-direction such that - // in the output 0 <= x <= 300. - // don't scale in y-direction to - // preserve the shape of the - // triangulation + // scale in x-direction such that + // in the output 0 <= x <= 300. + // don't scale in y-direction to + // preserve the shape of the + // triangulation const double scale = (flags.size / - (flags.size_type==EpsFlags::width ? - x_max - x_min : - y_min - y_max)); + (flags.size_type==EpsFlags::width ? + x_max - x_min : + y_min - y_max)); const Point<2> offset(x_min, y_min); - // now write preamble + // now write preamble if (true) { - // block this to have local - // variables destroyed after - // use + // block this to have local + // variables destroyed after + // use std::time_t time1= std::time (0); std::tm *time = std::localtime(&time1); out << "%!PS-Adobe-2.0 EPSF-1.2" << '\n' - << "%%Title: deal.II Output" << '\n' - << "%%Creator: the deal.II library" << '\n' - << "%%Creation Date: " - << time->tm_year+1900 << "/" - << time->tm_mon+1 << "/" - << time->tm_mday << " - " - << time->tm_hour << ":" - << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << '\n' - << "%%BoundingBox: " - // lower left corner - << "0 0 " - // upper right corner - << static_cast( (x_max-x_min) * scale + 0.5) - << ' ' - << static_cast( (y_max-y_min) * scale + 0.5) - << '\n'; - - // define some abbreviations to keep - // the output small: - // m=move turtle to - // l=define a line - // s=set rgb color - // sg=set gray value - // lx=close the line and plot the line - // lf=close the line and fill the interior + << "%%Title: deal.II Output" << '\n' + << "%%Creator: the deal.II library" << '\n' + << "%%Creation Date: " + << time->tm_year+1900 << "/" + << time->tm_mon+1 << "/" + << time->tm_mday << " - " + << time->tm_hour << ":" + << std::setw(2) << time->tm_min << ":" + << std::setw(2) << time->tm_sec << '\n' + << "%%BoundingBox: " + // lower left corner + << "0 0 " + // upper right corner + << static_cast( (x_max-x_min) * scale + 0.5) + << ' ' + << static_cast( (y_max-y_min) * scale + 0.5) + << '\n'; + + // define some abbreviations to keep + // the output small: + // m=move turtle to + // l=define a line + // s=set rgb color + // sg=set gray value + // lx=close the line and plot the line + // lf=close the line and fill the interior out << "/m {moveto} bind def" << '\n' - << "/l {lineto} bind def" << '\n' - << "/s {setrgbcolor} bind def" << '\n' - << "/sg {setgray} bind def" << '\n' - << "/lx {lineto closepath stroke} bind def" << '\n' - << "/lf {lineto closepath fill} bind def" << '\n'; + << "/l {lineto} bind def" << '\n' + << "/s {setrgbcolor} bind def" << '\n' + << "/sg {setgray} bind def" << '\n' + << "/lx {lineto closepath stroke} bind def" << '\n' + << "/lf {lineto closepath fill} bind def" << '\n'; out << "%%EndProlog" << '\n' - << '\n'; - // set fine lines + << '\n'; + // set fine lines out << flags.line_width << " setlinewidth" << '\n'; - // allow only five digits - // for output (instead of the - // default six); this should suffice - // even for fine grids, but reduces - // the file size significantly + // allow only five digits + // for output (instead of the + // default six); this should suffice + // even for fine grids, but reduces + // the file size significantly out << std::setprecision (5); } - // check if min and max - // values for the color are - // actually different. If - // that is not the case (such - // things happen, for - // example, in the very first - // time step of a time - // dependent problem, if the - // initial values are zero), - // all values are equal, and - // then we can draw - // everything in an arbitrary - // color. Thus, change one of - // the two values arbitrarily + // check if min and max + // values for the color are + // actually different. If + // that is not the case (such + // things happen, for + // example, in the very first + // time step of a time + // dependent problem, if the + // initial values are zero), + // all values are equal, and + // then we can draw + // everything in an arbitrary + // color. Thus, change one of + // the two values arbitrarily if (max_color_value == min_color_value) max_color_value = min_color_value+1; - // now we've got all the information - // we need. write the cells. - // note: due to the ordering, we - // traverse the list of cells - // back-to-front + // now we've got all the information + // we need. write the cells. + // note: due to the ordering, we + // traverse the list of cells + // back-to-front for (typename std::multiset::const_iterator - cell=cells.begin(); + cell=cells.begin(); cell!=cells.end(); ++cell) { if (flags.draw_cells) - { - if (flags.shade_cells) - { - const EpsFlags::RgbValues rgb_values - = (*flags.color_function) (cell->color_value, - min_color_value, - max_color_value); - - // write out color - if (rgb_values.is_grey()) - out << rgb_values.red << " sg "; - else - out << rgb_values.red << ' ' - << rgb_values.green << ' ' - << rgb_values.blue << " s "; - } - else - out << "1 sg "; - - out << (cell->vertices[0]-offset) * scale << " m " - << (cell->vertices[1]-offset) * scale << " l " - << (cell->vertices[3]-offset) * scale << " l " - << (cell->vertices[2]-offset) * scale << " lf" - << '\n'; - } + { + if (flags.shade_cells) + { + const EpsFlags::RgbValues rgb_values + = (*flags.color_function) (cell->color_value, + min_color_value, + max_color_value); + + // write out color + if (rgb_values.is_grey()) + out << rgb_values.red << " sg "; + else + out << rgb_values.red << ' ' + << rgb_values.green << ' ' + << rgb_values.blue << " s "; + } + else + out << "1 sg "; + + out << (cell->vertices[0]-offset) * scale << " m " + << (cell->vertices[1]-offset) * scale << " l " + << (cell->vertices[3]-offset) * scale << " l " + << (cell->vertices[2]-offset) * scale << " lf" + << '\n'; + } if (flags.draw_mesh) - out << "0 sg " // draw lines in black - << (cell->vertices[0]-offset) * scale << " m " - << (cell->vertices[1]-offset) * scale << " l " - << (cell->vertices[3]-offset) * scale << " l " - << (cell->vertices[2]-offset) * scale << " lx" - << '\n'; + out << "0 sg " // draw lines in black + << (cell->vertices[0]-offset) * scale << " m " + << (cell->vertices[1]-offset) * scale << " l " + << (cell->vertices[3]-offset) * scale << " l " + << (cell->vertices[2]-offset) * scale << " lx" + << '\n'; } out << "showpage" << '\n'; - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out << std::setprecision(old_precision); out.flush (); @@ -3706,28 +3706,28 @@ void DataOutBase::write_eps (const std::vector > &patches, template void DataOutBase::write_gmv (const std::vector > &patches, - const std::vector &data_names, - const std::vector > &, - const GmvFlags &flags, - std::ostream &out) + const std::vector &data_names, + const std::vector > &, + const GmvFlags &flags, + std::ostream &out) { Assert(dim<=3, ExcNotImplemented()); AssertThrow (out, ExcIO()); #ifndef DEAL_II_COMPILER_SUPPORTS_MPI - // verify that there are indeed - // patches to be written out. most - // of the times, people just forget - // to call build_patches when there - // are no patches, so a warning is - // in order. that said, the - // assertion is disabled if we - // support MPI since then it can - // happen that on the coarsest - // mesh, a processor simply has no - // cells it actually owns, and in - // that case it is legit if there - // are no patches + // verify that there are indeed + // patches to be written out. most + // of the times, people just forget + // to call build_patches when there + // are no patches, so a warning is + // in order. that said, the + // assertion is disabled if we + // support MPI since then it can + // happen that on the coarsest + // mesh, a processor simply has no + // cells it actually owns, and in + // that case it is legit if there + // are no patches Assert (patches.size() > 0, ExcNoPatches()); #else if (patches.size() == 0) @@ -3736,65 +3736,65 @@ void DataOutBase::write_gmv (const std::vector > &patches, GmvStream gmv_out(out, flags); const unsigned int n_data_sets = data_names.size(); - // check against # of data sets in - // first patch. checks against all - // other patches are made in - // write_gmv_reorder_data_vectors + // check against # of data sets in + // first patch. checks against all + // other patches are made in + // write_gmv_reorder_data_vectors Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) || - (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available), - ExcDimensionMismatch (patches[0].points_are_available - ? - (n_data_sets + spacedim) - : - n_data_sets, - patches[0].data.n_rows())); - - /////////////////////// - // preamble + (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available), + ExcDimensionMismatch (patches[0].points_are_available + ? + (n_data_sets + spacedim) + : + n_data_sets, + patches[0].data.n_rows())); + + /////////////////////// + // preamble out << "gmvinput ascii" << '\n' << '\n'; - // first count the number of cells - // and cells for later use + // first count the number of cells + // and cells for later use unsigned int n_nodes; unsigned int n_cells; compute_sizes(patches, n_nodes, n_cells); - // in gmv format the vertex - // coordinates and the data have an - // order that is a bit unpleasant - // (first all x coordinates, then - // all y coordinate, ...; first all - // data of variable 1, then - // variable 2, etc), so we have to - // copy the data vectors a bit around - // - // note that we copy vectors when - // looping over the patches since we - // have to write them one variable - // at a time and don't want to use - // more than one loop - // - // this copying of data vectors can - // be done while we already output - // the vertices, so do this on a - // separate task and when wanting - // to write out the data, we wait - // for that task to finish + // in gmv format the vertex + // coordinates and the data have an + // order that is a bit unpleasant + // (first all x coordinates, then + // all y coordinate, ...; first all + // data of variable 1, then + // variable 2, etc), so we have to + // copy the data vectors a bit around + // + // note that we copy vectors when + // looping over the patches since we + // have to write them one variable + // at a time and don't want to use + // more than one loop + // + // this copying of data vectors can + // be done while we already output + // the vertices, so do this on a + // separate task and when wanting + // to write out the data, we wait + // for that task to finish Table<2,double> data_vectors (n_data_sets, n_nodes); void (*fun_ptr) (const std::vector > &, - Table<2,double> &) + Table<2,double> &) = &DataOutBase::template write_gmv_reorder_data_vectors; Threads::Task<> reorder_task = Threads::new_task (fun_ptr, patches, data_vectors); - /////////////////////////////// - // first make up a list of used - // vertices along with their - // coordinates - // - // note that we have to print - // 3 dimensions + /////////////////////////////// + // first make up a list of used + // vertices along with their + // coordinates + // + // note that we have to print + // 3 dimensions out << "nodes " << n_nodes << '\n'; for (unsigned int d=0;d > &patches, for (unsigned int d=spacedim;d<3;++d) { for (unsigned int i=0;i(out, " ")); + data_vectors[data_set].end(), + std::ostream_iterator(out, " ")); out << '\n' - << '\n'; + << '\n'; } - // end of variable section + // end of variable section out << "endvars" << '\n'; - // end of output + // end of output out << "endgmv" << '\n'; - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); - // assert the stream is still ok + // assert the stream is still ok AssertThrow (out, ExcIO()); } @@ -3861,27 +3861,27 @@ void DataOutBase::write_gmv (const std::vector > &patches, template void DataOutBase::write_tecplot (const std::vector > &patches, - const std::vector &data_names, - const std::vector > &, - const TecplotFlags &flags, - std::ostream &out) + const std::vector &data_names, + const std::vector > &, + const TecplotFlags &flags, + std::ostream &out) { AssertThrow (out, ExcIO()); #ifndef DEAL_II_COMPILER_SUPPORTS_MPI - // verify that there are indeed - // patches to be written out. most - // of the times, people just forget - // to call build_patches when there - // are no patches, so a warning is - // in order. that said, the - // assertion is disabled if we - // support MPI since then it can - // happen that on the coarsest - // mesh, a processor simply has no - // cells it actually owns, and in - // that case it is legit if there - // are no patches + // verify that there are indeed + // patches to be written out. most + // of the times, people just forget + // to call build_patches when there + // are no patches, so a warning is + // in order. that said, the + // assertion is disabled if we + // support MPI since then it can + // happen that on the coarsest + // mesh, a processor simply has no + // cells it actually owns, and in + // that case it is legit if there + // are no patches Assert (patches.size() > 0, ExcNoPatches()); #else if (patches.size() == 0) @@ -3891,43 +3891,43 @@ void DataOutBase::write_tecplot (const std::vector > &patche TecplotStream tecplot_out(out, flags); const unsigned int n_data_sets = data_names.size(); - // check against # of data sets in - // first patch. checks against all - // other patches are made in - // write_gmv_reorder_data_vectors + // check against # of data sets in + // first patch. checks against all + // other patches are made in + // write_gmv_reorder_data_vectors Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) || - (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available), - ExcDimensionMismatch (patches[0].points_are_available - ? - (n_data_sets + spacedim) - : - n_data_sets, - patches[0].data.n_rows())); - - // first count the number of cells - // and cells for later use + (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available), + ExcDimensionMismatch (patches[0].points_are_available + ? + (n_data_sets + spacedim) + : + n_data_sets, + patches[0].data.n_rows())); + + // first count the number of cells + // and cells for later use unsigned int n_nodes; unsigned int n_cells; compute_sizes(patches, n_nodes, n_cells); - /////////// - // preamble + /////////// + // preamble { std::time_t time1= std::time (0); std::tm *time = std::localtime(&time1); out << "# This file was generated by the deal.II library." << '\n' - << "# Date = " - << time->tm_year+1900 << "/" - << time->tm_mon+1 << "/" - << time->tm_mday << '\n' - << "# Time = " - << time->tm_hour << ":" - << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << '\n' - << "#" << '\n' - << "# For a description of the Tecplot format see the Tecplot documentation." - << '\n' - << "#" << '\n'; + << "# Date = " + << time->tm_year+1900 << "/" + << time->tm_mon+1 << "/" + << time->tm_mday << '\n' + << "# Time = " + << time->tm_hour << ":" + << std::setw(2) << time->tm_min << ":" + << std::setw(2) << time->tm_sec << '\n' + << "#" << '\n' + << "# For a description of the Tecplot format see the Tecplot documentation." + << '\n' + << "#" << '\n'; out << "Variables="; @@ -3935,16 +3935,16 @@ void DataOutBase::write_tecplot (const std::vector > &patche switch (spacedim) { case 1: - out << "\"x\""; - break; + out << "\"x\""; + break; case 2: - out << "\"x\", \"y\""; - break; + out << "\"x\", \"y\""; + break; case 3: - out << "\"x\", \"y\", \"z\""; - break; - default: - Assert (false, ExcNotImplemented()); + out << "\"x\", \"y\", \"z\""; + break; + default: + Assert (false, ExcNotImplemented()); } for (unsigned int data_set=0; data_set > &patche out << "t=\"" << flags.zone_name << "\" "; out << "f=feblock, n=" << n_nodes << ", e=" << n_cells - << ", et=" << tecplot_cell_type[dim] << '\n'; + << ", et=" << tecplot_cell_type[dim] << '\n'; } @@ -4016,15 +4016,15 @@ void DataOutBase::write_tecplot (const std::vector > &patche for (unsigned int data_set=0; data_set(out, "\n")); + data_vectors[data_set].end(), + std::ostream_iterator(out, "\n")); out << '\n'; } write_cells(patches, tecplot_out); - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); // assert the stream is still ok @@ -4066,14 +4066,14 @@ namespace inline TecplotMacros::TecplotMacros(const unsigned int n_nodes, - const unsigned int n_vars, - const unsigned int n_cells, - const unsigned int n_vert) + const unsigned int n_vars, + const unsigned int n_cells, + const unsigned int n_vert) : - n_nodes(n_nodes), - n_vars(n_vars), - n_cells(n_cells), - n_vert(n_vert) + n_nodes(n_nodes), + n_vars(n_vars), + n_cells(n_cells), + n_vert(n_vert) { nodalData.resize(n_nodes*n_vars); connData.resize(n_cells*n_vert); @@ -4113,10 +4113,10 @@ namespace template void DataOutBase::write_tecplot_binary (const std::vector > &patches, - const std::vector &data_names, - const std::vector > &vector_data_ranges, - const TecplotFlags &flags, - std::ostream &out) + const std::vector &data_names, + const std::vector > &vector_data_ranges, + const TecplotFlags &flags, + std::ostream &out) { #ifndef DEAL_II_HAVE_TECPLOT @@ -4146,12 +4146,12 @@ void DataOutBase::write_tecplot_binary (const std::vector > if (file_name == NULL) { - // At least in debug mode we - // should tell users why they - // don't get tecplot binary - // output + // At least in debug mode we + // should tell users why they + // don't get tecplot binary + // output Assert(false, ExcMessage("Specify the name of the tecplot_binary" - " file through the TecplotFlags interface.")); + " file through the TecplotFlags interface.")); write_tecplot (patches, data_names, vector_data_ranges, flags, out); return; } @@ -4160,19 +4160,19 @@ void DataOutBase::write_tecplot_binary (const std::vector > AssertThrow (out, ExcIO()); #ifndef DEAL_II_COMPILER_SUPPORTS_MPI - // verify that there are indeed - // patches to be written out. most - // of the times, people just forget - // to call build_patches when there - // are no patches, so a warning is - // in order. that said, the - // assertion is disabled if we - // support MPI since then it can - // happen that on the coarsest - // mesh, a processor simply has no - // cells it actually owns, and in - // that case it is legit if there - // are no patches + // verify that there are indeed + // patches to be written out. most + // of the times, people just forget + // to call build_patches when there + // are no patches, so a warning is + // in order. that said, the + // assertion is disabled if we + // support MPI since then it can + // happen that on the coarsest + // mesh, a processor simply has no + // cells it actually owns, and in + // that case it is legit if there + // are no patches Assert (patches.size() > 0, ExcNoPatches()); #else if (patches.size() == 0) @@ -4180,26 +4180,26 @@ void DataOutBase::write_tecplot_binary (const std::vector > #endif const unsigned int n_data_sets = data_names.size(); - // check against # of data sets in - // first patch. checks against all - // other patches are made in - // write_gmv_reorder_data_vectors + // check against # of data sets in + // first patch. checks against all + // other patches are made in + // write_gmv_reorder_data_vectors Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) || - (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available), - ExcDimensionMismatch (patches[0].points_are_available - ? - (n_data_sets + spacedim) - : - n_data_sets, - patches[0].data.n_rows())); - - // first count the number of cells - // and cells for later use + (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available), + ExcDimensionMismatch (patches[0].points_are_available + ? + (n_data_sets + spacedim) + : + n_data_sets, + patches[0].data.n_rows())); + + // first count the number of cells + // and cells for later use unsigned int n_nodes; unsigned int n_cells; compute_sizes(patches, n_nodes, n_cells); - // local variables only needed to write Tecplot - // binary output files + // local variables only needed to write Tecplot + // binary output files const unsigned int vars_per_node = (spacedim+n_data_sets), nodes_per_cell = GeometryInfo::vertices_per_cell; @@ -4217,11 +4217,11 @@ void DataOutBase::write_tecplot_binary (const std::vector > switch (spacedim) { case 2: - tec_var_names = "x y"; - break; + tec_var_names = "x y"; + break; case 3: - tec_var_names = "x y z"; - break; + tec_var_names = "x y z"; + break; default: Assert(false, ExcNotImplemented()); } @@ -4231,27 +4231,27 @@ void DataOutBase::write_tecplot_binary (const std::vector > tec_var_names += " "; tec_var_names += data_names[data_set]; } - // in Tecplot FEBLOCK format the vertex - // coordinates and the data have an - // order that is a bit unpleasant - // (first all x coordinates, then - // all y coordinate, ...; first all - // data of variable 1, then - // variable 2, etc), so we have to - // copy the data vectors a bit around - // - // note that we copy vectors when - // looping over the patches since we - // have to write them one variable - // at a time and don't want to use - // more than one loop - // - // this copying of data vectors can - // be done while we already output - // the vertices, so do this on a - // separate task and when wanting - // to write out the data, we wait - // for that task to finish + // in Tecplot FEBLOCK format the vertex + // coordinates and the data have an + // order that is a bit unpleasant + // (first all x coordinates, then + // all y coordinate, ...; first all + // data of variable 1, then + // variable 2, etc), so we have to + // copy the data vectors a bit around + // + // note that we copy vectors when + // looping over the patches since we + // have to write them one variable + // at a time and don't want to use + // more than one loop + // + // this copying of data vectors can + // be done while we already output + // the vertices, so do this on a + // separate task and when wanting + // to write out the data, we wait + // for that task to finish Table<2,double> data_vectors (n_data_sets, n_nodes); void (*fun_ptr) (const std::vector > &, @@ -4259,80 +4259,80 @@ void DataOutBase::write_tecplot_binary (const std::vector > = &DataOutBase::template write_gmv_reorder_data_vectors; Threads::Task<> reorder_task = Threads::new_task (fun_ptr, patches, data_vectors); - /////////////////////////////// - // first make up a list of used - // vertices along with their - // coordinates + /////////////////////////////// + // first make up a list of used + // vertices along with their + // coordinates for (unsigned int d=1; d<=spacedim; ++d) { unsigned int entry=0; for (typename std::vector >::const_iterator patch=patches.begin(); - patch!=patches.end(); ++patch) - { - const unsigned int n_subdivisions = patch->n_subdivisions; - - switch (dim) - { - case 2: - { - for (unsigned int j=0; j( - (((patch->vertices[1](d-1) * x_frac) + - (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) + - ((patch->vertices[3](d-1) * x_frac) + - (patch->vertices[2](d-1) * (1-x_frac))) * y_frac) - ); - entry++; - } - break; - } - - case 3: - { - for (unsigned int j=0; j( - ((((patch->vertices[1](d-1) * x_frac) + - (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) + - ((patch->vertices[3](d-1) * x_frac) + - (patch->vertices[2](d-1) * (1-x_frac))) * y_frac) * (1-z_frac) + - (((patch->vertices[5](d-1) * x_frac) + - (patch->vertices[4](d-1) * (1-x_frac))) * (1-y_frac) + - ((patch->vertices[7](d-1) * x_frac) + - (patch->vertices[6](d-1) * (1-x_frac))) * y_frac) * z_frac) - ); - entry++; - } - break; - } - - default: - Assert (false, ExcNotImplemented()); - } - } + patch!=patches.end(); ++patch) + { + const unsigned int n_subdivisions = patch->n_subdivisions; + + switch (dim) + { + case 2: + { + for (unsigned int j=0; j( + (((patch->vertices[1](d-1) * x_frac) + + (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) + + ((patch->vertices[3](d-1) * x_frac) + + (patch->vertices[2](d-1) * (1-x_frac))) * y_frac) + ); + entry++; + } + break; + } + + case 3: + { + for (unsigned int j=0; j( + ((((patch->vertices[1](d-1) * x_frac) + + (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) + + ((patch->vertices[3](d-1) * x_frac) + + (patch->vertices[2](d-1) * (1-x_frac))) * y_frac) * (1-z_frac) + + (((patch->vertices[5](d-1) * x_frac) + + (patch->vertices[4](d-1) * (1-x_frac))) * (1-y_frac) + + ((patch->vertices[7](d-1) * x_frac) + + (patch->vertices[6](d-1) * (1-x_frac))) * y_frac) * z_frac) + ); + entry++; + } + break; + } + + default: + Assert (false, ExcNotImplemented()); + } + } } - /////////////////////////////////////// - // data output. - // + /////////////////////////////////////// + // data output. + // reorder_task.join (); - // then write data. + // then write data. for (unsigned int data_set=0; data_set(data_vectors[data_set][entry]); @@ -4340,9 +4340,9 @@ void DataOutBase::write_tecplot_binary (const std::vector > - ///////////////////////////////// - // now for the cells. note that - // vertices are counted from 1 onwards + ///////////////////////////////// + // now for the cells. note that + // vertices are counted from 1 onwards unsigned int first_vertex_of_patch = 0; unsigned int elem=0; @@ -4354,96 +4354,96 @@ void DataOutBase::write_tecplot_binary (const std::vector > const unsigned int d1=1; const unsigned int d2=n; const unsigned int d3=n*n; - // write out the cells making - // up this patch + // write out the cells making + // up this patch switch (dim) - { - case 2: - { - for (unsigned int i2=0; i2(n); } { int ierr = 0, - num_nodes = static_cast(n_nodes), - num_cells = static_cast(n_cells); + num_nodes = static_cast(n_nodes), + num_cells = static_cast(n_cells); char dot[2] = {'.', 0}; - // Unfortunately, TECINI takes a - // char *, but c_str() gives a - // const char *. As we don't do - // anything else with - // tec_var_names following - // const_cast is ok + // Unfortunately, TECINI takes a + // char *, but c_str() gives a + // const char *. As we don't do + // anything else with + // tec_var_names following + // const_cast is ok char *var_names=const_cast (tec_var_names.c_str()); ierr = TECINI (NULL, - var_names, - file_name, - dot, - &tec_debug, - &is_double); + var_names, + file_name, + dot, + &tec_debug, + &is_double); Assert (ierr == 0, ExcErrorOpeningTecplotFile(file_name)); char FEBLOCK[] = {'F','E','B','L','O','C','K',0}; ierr = TECZNE (NULL, - &num_nodes, - &num_cells, - &cell_type, - FEBLOCK, - NULL); + &num_nodes, + &num_cells, + &cell_type, + FEBLOCK, + NULL); Assert (ierr == 0, ExcTecplotAPIError()); int total = (vars_per_node*num_nodes); ierr = TECDAT (&total, - &tm.nodalData[0], - &is_double); + &tm.nodalData[0], + &is_double); Assert (ierr == 0, ExcTecplotAPIError()); @@ -4463,27 +4463,27 @@ void DataOutBase::write_tecplot_binary (const std::vector > template void DataOutBase::write_vtk (const std::vector > &patches, - const std::vector &data_names, - const std::vector > &vector_data_ranges, - const VtkFlags &flags, - std::ostream &out) + const std::vector &data_names, + const std::vector > &vector_data_ranges, + const VtkFlags &flags, + std::ostream &out) { AssertThrow (out, ExcIO()); #ifndef DEAL_II_COMPILER_SUPPORTS_MPI - // verify that there are indeed - // patches to be written out. most - // of the times, people just forget - // to call build_patches when there - // are no patches, so a warning is - // in order. that said, the - // assertion is disabled if we - // support MPI since then it can - // happen that on the coarsest - // mesh, a processor simply has no - // cells it actually owns, and in - // that case it is legit if there - // are no patches + // verify that there are indeed + // patches to be written out. most + // of the times, people just forget + // to call build_patches when there + // are no patches, so a warning is + // in order. that said, the + // assertion is disabled if we + // support MPI since then it can + // happen that on the coarsest + // mesh, a processor simply has no + // cells it actually owns, and in + // that case it is legit if there + // are no patches Assert (patches.size() > 0, ExcNoPatches()); #else if (patches.size() == 0) @@ -4493,220 +4493,220 @@ DataOutBase::write_vtk (const std::vector > &patches, VtkStream vtk_out(out, flags); const unsigned int n_data_sets = data_names.size(); - // check against # of data sets in - // first patch. checks against all - // other patches are made in - // write_gmv_reorder_data_vectors + // check against # of data sets in + // first patch. checks against all + // other patches are made in + // write_gmv_reorder_data_vectors Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) || - (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available), - ExcDimensionMismatch (patches[0].points_are_available - ? - (n_data_sets + spacedim) - : - n_data_sets, - patches[0].data.n_rows())); - - /////////////////////// - // preamble + (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available), + ExcDimensionMismatch (patches[0].points_are_available + ? + (n_data_sets + spacedim) + : + n_data_sets, + patches[0].data.n_rows())); + + /////////////////////// + // preamble if (true) { std::time_t time1= std::time (0); std::tm *time = std::localtime(&time1); out << "# vtk DataFile Version 3.0" - << '\n' - << "#This file was generated by the deal.II library on " - << time->tm_year+1900 << "/" - << time->tm_mon+1 << "/" - << time->tm_mday << " at " - << time->tm_hour << ":" - << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec - << '\n' - << "ASCII" - << '\n' - << "DATASET UNSTRUCTURED_GRID\n" - << '\n'; + << '\n' + << "#This file was generated by the deal.II library on " + << time->tm_year+1900 << "/" + << time->tm_mon+1 << "/" + << time->tm_mday << " at " + << time->tm_hour << ":" + << std::setw(2) << time->tm_min << ":" + << std::setw(2) << time->tm_sec + << '\n' + << "ASCII" + << '\n' + << "DATASET UNSTRUCTURED_GRID\n" + << '\n'; } - // first count the number of cells - // and cells for later use + // first count the number of cells + // and cells for later use unsigned int n_nodes; unsigned int n_cells; compute_sizes(patches, n_nodes, n_cells); - // in gmv format the vertex - // coordinates and the data have an - // order that is a bit unpleasant - // (first all x coordinates, then - // all y coordinate, ...; first all - // data of variable 1, then - // variable 2, etc), so we have to - // copy the data vectors a bit around - // - // note that we copy vectors when - // looping over the patches since we - // have to write them one variable - // at a time and don't want to use - // more than one loop - // - // this copying of data vectors can - // be done while we already output - // the vertices, so do this on a - // separate task and when wanting - // to write out the data, we wait - // for that task to finish + // in gmv format the vertex + // coordinates and the data have an + // order that is a bit unpleasant + // (first all x coordinates, then + // all y coordinate, ...; first all + // data of variable 1, then + // variable 2, etc), so we have to + // copy the data vectors a bit around + // + // note that we copy vectors when + // looping over the patches since we + // have to write them one variable + // at a time and don't want to use + // more than one loop + // + // this copying of data vectors can + // be done while we already output + // the vertices, so do this on a + // separate task and when wanting + // to write out the data, we wait + // for that task to finish Table<2,double> data_vectors (n_data_sets, n_nodes); void (*fun_ptr) (const std::vector > &, - Table<2,double> &) + Table<2,double> &) = &DataOutBase::template write_gmv_reorder_data_vectors; Threads::Task<> reorder_task = Threads::new_task (fun_ptr, patches, data_vectors); - /////////////////////////////// - // first make up a list of used - // vertices along with their - // coordinates - // - // note that we have to print - // d=1..3 dimensions + /////////////////////////////// + // first make up a list of used + // vertices along with their + // coordinates + // + // note that we have to print + // d=1..3 dimensions out << "POINTS " << n_nodes << " double" << '\n'; write_nodes(patches, vtk_out); out << '\n'; - ///////////////////////////////// - // now for the cells + ///////////////////////////////// + // now for the cells out << "CELLS " << n_cells << ' ' << n_cells*(GeometryInfo::vertices_per_cell+1) << '\n'; write_cells(patches, vtk_out); out << '\n'; - // next output the types of the - // cells. since all cells are - // the same, this is simple + // next output the types of the + // cells. since all cells are + // the same, this is simple out << "CELL_TYPES " << n_cells << '\n'; for (unsigned int i=0; i data_set_written (n_data_sets, false); for (unsigned int n_th_vector=0; n_th_vector(vector_data_ranges[n_th_vector]) >= - std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), - ExcLowerRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), - std_cxx1x::get<0>(vector_data_ranges[n_th_vector]))); + std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), + ExcLowerRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), + std_cxx1x::get<0>(vector_data_ranges[n_th_vector]))); AssertThrow (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets, - ExcIndexRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), - 0, n_data_sets)); + ExcIndexRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), + 0, n_data_sets)); AssertThrow (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) + 1 - - std_cxx1x::get<0>(vector_data_ranges[n_th_vector]) <= 3, - ExcMessage ("Can't declare a vector with more than 3 components " - "in VTK")); + - std_cxx1x::get<0>(vector_data_ranges[n_th_vector]) <= 3, + ExcMessage ("Can't declare a vector with more than 3 components " + "in VTK")); - // mark these components as already written: + // mark these components as already written: for (unsigned int i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]); - i<=std_cxx1x::get<1>(vector_data_ranges[n_th_vector]); - ++i) - data_set_written[i] = true; - - // write the - // header. concatenate all the - // component names with double - // underscores unless a vector - // name has been specified + i<=std_cxx1x::get<1>(vector_data_ranges[n_th_vector]); + ++i) + data_set_written[i] = true; + + // write the + // header. concatenate all the + // component names with double + // underscores unless a vector + // name has been specified out << "VECTORS "; if (std_cxx1x::get<2>(vector_data_ranges[n_th_vector]) != "") - out << std_cxx1x::get<2>(vector_data_ranges[n_th_vector]); + out << std_cxx1x::get<2>(vector_data_ranges[n_th_vector]); else - { - for (unsigned int i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]); - i(vector_data_ranges[n_th_vector]); - ++i) - out << data_names[i] << "__"; - out << data_names[std_cxx1x::get<1>(vector_data_ranges[n_th_vector])]; - } + { + for (unsigned int i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]); + i(vector_data_ranges[n_th_vector]); + ++i) + out << data_names[i] << "__"; + out << data_names[std_cxx1x::get<1>(vector_data_ranges[n_th_vector])]; + } out << " double" - << '\n'; + << '\n'; - // now write data. pad all - // vectors to have three - // components + // now write data. pad all + // vectors to have three + // components for (unsigned int n=0; n(vector_data_ranges[n_th_vector]) - - std_cxx1x::get<0>(vector_data_ranges[n_th_vector])) - { - case 0: - out << data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), n) << " 0 0" - << '\n'; - break; - - case 1: - out << data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), n) << ' ' - << data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+1, n) << " 0" - << '\n'; - break; - case 2: - out << data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), n) << ' ' - << data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+1, n) << ' ' - << data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+2, n) - << '\n'; - break; - - default: - // VTK doesn't - // support - // anything else - // than vectors - // with 1, 2, or - // 3 components - Assert (false, ExcInternalError()); - } - } + { + switch (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) - + std_cxx1x::get<0>(vector_data_ranges[n_th_vector])) + { + case 0: + out << data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), n) << " 0 0" + << '\n'; + break; + + case 1: + out << data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), n) << ' ' + << data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+1, n) << " 0" + << '\n'; + break; + case 2: + out << data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), n) << ' ' + << data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+1, n) << ' ' + << data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+2, n) + << '\n'; + break; + + default: + // VTK doesn't + // support + // anything else + // than vectors + // with 1, 2, or + // 3 components + Assert (false, ExcInternalError()); + } + } } - // now do the left over scalar data sets + // now do the left over scalar data sets for (unsigned int data_set=0; data_set(out, " ")); - out << '\n'; + out << "SCALARS " + << data_names[data_set] + << " double 1" + << '\n' + << "LOOKUP_TABLE default" + << '\n'; + std::copy (data_vectors[data_set].begin(), + data_vectors[data_set].end(), + std::ostream_iterator(out, " ")); + out << '\n'; } - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); - // assert the stream is still ok + // assert the stream is still ok AssertThrow (out, ExcIO()); } @@ -4775,19 +4775,19 @@ void DataOutBase::write_vtu_main (const std::vector > &patch AssertThrow (out, ExcIO()); #ifndef DEAL_II_COMPILER_SUPPORTS_MPI - // verify that there are indeed - // patches to be written out. most - // of the times, people just forget - // to call build_patches when there - // are no patches, so a warning is - // in order. that said, the - // assertion is disabled if we - // support MPI since then it can - // happen that on the coarsest - // mesh, a processor simply has no - // cells it actually owns, and in - // that case it is legit if there - // are no patches + // verify that there are indeed + // patches to be written out. most + // of the times, people just forget + // to call build_patches when there + // are no patches, so a warning is + // in order. that said, the + // assertion is disabled if we + // support MPI since then it can + // happen that on the coarsest + // mesh, a processor simply has no + // cells it actually owns, and in + // that case it is legit if there + // are no patches Assert (patches.size() > 0, ExcNoPatches()); #else if (patches.size() == 0) @@ -4851,18 +4851,18 @@ void DataOutBase::write_vtu_main (const std::vector > &patch VtuStream vtu_out(out, flags); const unsigned int n_data_sets = data_names.size(); - // check against # of data sets in - // first patch. checks against all - // other patches are made in - // write_gmv_reorder_data_vectors + // check against # of data sets in + // first patch. checks against all + // other patches are made in + // write_gmv_reorder_data_vectors Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) || - (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available), - ExcDimensionMismatch (patches[0].points_are_available - ? - (n_data_sets + spacedim) - : - n_data_sets, - patches[0].data.n_rows())); + (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available), + ExcDimensionMismatch (patches[0].points_are_available + ? + (n_data_sets + spacedim) + : + n_data_sets, + patches[0].data.n_rows())); #ifdef HAVE_LIBZ @@ -4872,48 +4872,48 @@ void DataOutBase::write_vtu_main (const std::vector > &patch #endif - // first count the number of cells - // and cells for later use + // first count the number of cells + // and cells for later use unsigned int n_nodes; unsigned int n_cells; compute_sizes(patches, n_nodes, n_cells); - // in gmv format the vertex - // coordinates and the data have an - // order that is a bit unpleasant - // (first all x coordinates, then - // all y coordinate, ...; first all - // data of variable 1, then - // variable 2, etc), so we have to - // copy the data vectors a bit around - // - // note that we copy vectors when - // looping over the patches since we - // have to write them one variable - // at a time and don't want to use - // more than one loop - // - // this copying of data vectors can - // be done while we already output - // the vertices, so do this on a - // separate task and when wanting - // to write out the data, we wait - // for that task to finish + // in gmv format the vertex + // coordinates and the data have an + // order that is a bit unpleasant + // (first all x coordinates, then + // all y coordinate, ...; first all + // data of variable 1, then + // variable 2, etc), so we have to + // copy the data vectors a bit around + // + // note that we copy vectors when + // looping over the patches since we + // have to write them one variable + // at a time and don't want to use + // more than one loop + // + // this copying of data vectors can + // be done while we already output + // the vertices, so do this on a + // separate task and when wanting + // to write out the data, we wait + // for that task to finish Table<2,double> data_vectors (n_data_sets, n_nodes); void (*fun_ptr) (const std::vector > &, - Table<2,double> &) + Table<2,double> &) = &DataOutBase::template write_gmv_reorder_data_vectors; Threads::Task<> reorder_task = Threads::new_task (fun_ptr, patches, - data_vectors); - - /////////////////////////////// - // first make up a list of used - // vertices along with their - // coordinates - // - // note that according to the standard, we - // have to print d=1..3 dimensions, even if - // we are in reality in 2d, for example + data_vectors); + + /////////////////////////////// + // first make up a list of used + // vertices along with their + // coordinates + // + // note that according to the standard, we + // have to print d=1..3 dimensions, even if + // we are in reality in 2d, for example out << "\n"; out << " \n"; @@ -4922,18 +4922,18 @@ void DataOutBase::write_vtu_main (const std::vector > &patch write_nodes(patches, vtu_out); out << " \n"; out << " \n\n"; - ///////////////////////////////// - // now for the cells + ///////////////////////////////// + // now for the cells out << " \n"; out << " \n"; write_cells(patches, vtu_out); out << " \n"; - // XML VTU format uses offsets; this is - // different than the VTK format, which - // puts the number of nodes per cell in - // front of the connectivity list. + // XML VTU format uses offsets; this is + // different than the VTK format, which + // puts the number of nodes per cell in + // front of the connectivity list. out << " \n"; @@ -4944,24 +4944,24 @@ void DataOutBase::write_vtu_main (const std::vector > &patch out << "\n"; out << " \n"; - // next output the types of the - // cells. since all cells are - // the same, this is simple + // next output the types of the + // cells. since all cells are + // the same, this is simple out << " \n"; { - // uint8_t might be a typedef to unsigned - // char which is then not printed as - // ascii integers + // uint8_t might be a typedef to unsigned + // char which is then not printed as + // ascii integers #ifdef HAVE_LIBZ std::vector cell_types (n_cells, - static_cast(vtk_cell_type[dim])); + static_cast(vtk_cell_type[dim])); #else std::vector cell_types (n_cells, - vtk_cell_type[dim]); + vtk_cell_type[dim]); #endif - // this should compress well :-) + // this should compress well :-) vtu_out << cell_types; } out << "\n"; @@ -4969,136 +4969,136 @@ void DataOutBase::write_vtu_main (const std::vector > &patch out << " \n"; - /////////////////////////////////////// - // data output. + /////////////////////////////////////// + // data output. - // now write the data vectors to - // @p{out} first make sure that all - // data is in place + // now write the data vectors to + // @p{out} first make sure that all + // data is in place reorder_task.join (); - // then write data. the - // 'POINT_DATA' means: node data - // (as opposed to cell data, which - // we do not support explicitly - // here). all following data sets - // are point data + // then write data. the + // 'POINT_DATA' means: node data + // (as opposed to cell data, which + // we do not support explicitly + // here). all following data sets + // are point data out << " \n"; - // when writing, first write out - // all vector data, then handle the - // scalar data sets that have been - // left over + // when writing, first write out + // all vector data, then handle the + // scalar data sets that have been + // left over std::vector data_set_written (n_data_sets, false); for (unsigned int n_th_vector=0; n_th_vector(vector_data_ranges[n_th_vector]) >= - std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), - ExcLowerRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), - std_cxx1x::get<0>(vector_data_ranges[n_th_vector]))); + std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), + ExcLowerRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), + std_cxx1x::get<0>(vector_data_ranges[n_th_vector]))); AssertThrow (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets, - ExcIndexRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), - 0, n_data_sets)); + ExcIndexRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), + 0, n_data_sets)); AssertThrow (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) + 1 - - std_cxx1x::get<0>(vector_data_ranges[n_th_vector]) <= 3, - ExcMessage ("Can't declare a vector with more than 3 components " - "in VTK")); + - std_cxx1x::get<0>(vector_data_ranges[n_th_vector]) <= 3, + ExcMessage ("Can't declare a vector with more than 3 components " + "in VTK")); - // mark these components as already - // written: + // mark these components as already + // written: for (unsigned int i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]); - i<=std_cxx1x::get<1>(vector_data_ranges[n_th_vector]); - ++i) - data_set_written[i] = true; - - // write the - // header. concatenate all the - // component names with double - // underscores unless a vector - // name has been specified + i<=std_cxx1x::get<1>(vector_data_ranges[n_th_vector]); + ++i) + data_set_written[i] = true; + + // write the + // header. concatenate all the + // component names with double + // underscores unless a vector + // name has been specified out << " (vector_data_ranges[n_th_vector]) != "") - out << std_cxx1x::get<2>(vector_data_ranges[n_th_vector]); + out << std_cxx1x::get<2>(vector_data_ranges[n_th_vector]); else - { - for (unsigned int i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]); - i(vector_data_ranges[n_th_vector]); - ++i) - out << data_names[i] << "__"; - out << data_names[std_cxx1x::get<1>(vector_data_ranges[n_th_vector])]; - } + { + for (unsigned int i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]); + i(vector_data_ranges[n_th_vector]); + ++i) + out << data_names[i] << "__"; + out << data_names[std_cxx1x::get<1>(vector_data_ranges[n_th_vector])]; + } out << "\" NumberOfComponents=\"3\" format=\"" - << ascii_or_binary << "\">\n"; + << ascii_or_binary << "\">\n"; - // now write data. pad all - // vectors to have three - // components + // now write data. pad all + // vectors to have three + // components std::vector data; data.reserve (n_nodes*dim); for (unsigned int n=0; n(vector_data_ranges[n_th_vector]) - - std_cxx1x::get<0>(vector_data_ranges[n_th_vector])) - { - case 0: - data.push_back (data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), n)); - data.push_back (0); - data.push_back (0); - break; - - case 1: - data.push_back (data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), n)); - data.push_back (data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+1, n)); - data.push_back (0); - break; - case 2: - data.push_back (data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), n)); - data.push_back (data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+1, n)); - data.push_back (data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+2, n)); - break; - - default: - // VTK doesn't - // support - // anything else - // than vectors - // with 1, 2, or - // 3 components - Assert (false, ExcInternalError()); - } - } + { + switch (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) - + std_cxx1x::get<0>(vector_data_ranges[n_th_vector])) + { + case 0: + data.push_back (data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), n)); + data.push_back (0); + data.push_back (0); + break; + + case 1: + data.push_back (data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), n)); + data.push_back (data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+1, n)); + data.push_back (0); + break; + case 2: + data.push_back (data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), n)); + data.push_back (data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+1, n)); + data.push_back (data_vectors(std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+2, n)); + break; + + default: + // VTK doesn't + // support + // anything else + // than vectors + // with 1, 2, or + // 3 components + Assert (false, ExcInternalError()); + } + } vtu_out << data; out << " \n"; } - // now do the left over scalar data sets + // now do the left over scalar data sets for (unsigned int data_set=0; data_set\n"; - - std::vector data (data_vectors[data_set].begin(), - data_vectors[data_set].end()); - vtu_out << data; - out << " \n"; + out << " \n"; + + std::vector data (data_vectors[data_set].begin(), + data_vectors[data_set].end()); + vtu_out << data; + out << " \n"; } out << " \n"; - // Finish up writing a valid XML file + // Finish up writing a valid XML file out << " \n"; - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); - // assert the stream is still ok + // assert the stream is still ok AssertThrow (out, ExcIO()); } @@ -5108,10 +5108,10 @@ template void DataOutBase:: write_deal_II_intermediate (const std::vector > &patches, - const std::vector &data_names, - const std::vector > &vector_data_ranges, - const Deal_II_IntermediateFlags &/*flags*/, - std::ostream &out) + const std::vector &data_names, + const std::vector > &vector_data_ranges, + const Deal_II_IntermediateFlags &/*flags*/, + std::ostream &out) { AssertThrow (out, ExcIO()); @@ -5138,12 +5138,12 @@ write_deal_II_intermediate (const std::vector > &patches, out << vector_data_ranges.size() << '\n'; for (unsigned int i=0; i(vector_data_ranges[i]) << ' ' - << std_cxx1x::get<1>(vector_data_ranges[i]) << '\n' - << std_cxx1x::get<2>(vector_data_ranges[i]) << '\n'; + << std_cxx1x::get<1>(vector_data_ranges[i]) << '\n' + << std_cxx1x::get<2>(vector_data_ranges[i]) << '\n'; out << '\n'; - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); } @@ -5166,26 +5166,26 @@ determine_intermediate_format_dimensions (std::istream &input) template void DataOutBase::write_gmv_reorder_data_vectors (const std::vector > &patches, - Table<2,double> &data_vectors) + Table<2,double> &data_vectors) { - // unlike in the main function, we - // don't have here the data_names - // field, so we initialize it with - // the number of data sets in the - // first patch. the equivalence of - // these two definitions is checked - // in the main function. - - // we have to take care, however, whether the - // points are appended to the end of the - // patch->data table + // unlike in the main function, we + // don't have here the data_names + // field, so we initialize it with + // the number of data sets in the + // first patch. the equivalence of + // these two definitions is checked + // in the main function. + + // we have to take care, however, whether the + // points are appended to the end of the + // patch->data table const unsigned int n_data_sets =patches[0].points_are_available ? (patches[0].data.n_rows() - spacedim) : patches[0].data.n_rows(); Assert (data_vectors.size()[0] == n_data_sets, - ExcInternalError()); + ExcInternalError()); - // loop over all patches + // loop over all patches unsigned int next_value = 0; for (typename std::vector >::const_iterator patch=patches.begin(); patch != patches.end(); ++patch) @@ -5193,24 +5193,24 @@ DataOutBase::write_gmv_reorder_data_vectors (const std::vectorn_subdivisions; Assert ((patch->data.n_rows() == n_data_sets && !patch->points_are_available) || - (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available), - ExcDimensionMismatch (patch->points_are_available - ? - (n_data_sets + spacedim) - : - n_data_sets, - patch->data.n_rows())); + (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available), + ExcDimensionMismatch (patch->points_are_available + ? + (n_data_sets + spacedim) + : + n_data_sets, + patch->data.n_rows())); Assert (patch->data.n_cols() == Utilities::fixed_power(n_subdivisions+1), - ExcInvalidDatasetSize (patch->data.n_cols(), n_subdivisions+1)); + ExcInvalidDatasetSize (patch->data.n_cols(), n_subdivisions+1)); for (unsigned int i=0;idata.n_cols();++i, ++next_value) - for (unsigned int data_set=0; data_setdata(data_set,i); + for (unsigned int data_set=0; data_setdata(data_set,i); } for (unsigned int data_set=0; data_set DataOutInterface::DataOutInterface () - : default_subdivisions(1) + : default_subdivisions(1) {} @@ -5235,8 +5235,8 @@ template void DataOutInterface::write_dx (std::ostream &out) const { DataOutBase::write_dx (get_patches(), get_dataset_names(), - get_vector_data_ranges(), - dx_flags, out); + get_vector_data_ranges(), + dx_flags, out); } @@ -5245,8 +5245,8 @@ template void DataOutInterface::write_ucd (std::ostream &out) const { DataOutBase::write_ucd (get_patches(), get_dataset_names(), - get_vector_data_ranges(), - ucd_flags, out); + get_vector_data_ranges(), + ucd_flags, out); } @@ -5255,8 +5255,8 @@ template void DataOutInterface::write_gnuplot (std::ostream &out) const { DataOutBase::write_gnuplot (get_patches(), get_dataset_names(), - get_vector_data_ranges(), - gnuplot_flags, out); + get_vector_data_ranges(), + gnuplot_flags, out); } @@ -5265,8 +5265,8 @@ template void DataOutInterface::write_povray (std::ostream &out) const { DataOutBase::write_povray (get_patches(), get_dataset_names(), - get_vector_data_ranges(), - povray_flags, out); + get_vector_data_ranges(), + povray_flags, out); } @@ -5275,8 +5275,8 @@ template void DataOutInterface::write_eps (std::ostream &out) const { DataOutBase::write_eps (get_patches(), get_dataset_names(), - get_vector_data_ranges(), - eps_flags, out); + get_vector_data_ranges(), + eps_flags, out); } @@ -5285,8 +5285,8 @@ template void DataOutInterface::write_gmv (std::ostream &out) const { DataOutBase::write_gmv (get_patches(), get_dataset_names(), - get_vector_data_ranges(), - gmv_flags, out); + get_vector_data_ranges(), + gmv_flags, out); } @@ -5295,8 +5295,8 @@ template void DataOutInterface::write_tecplot (std::ostream &out) const { DataOutBase::write_tecplot (get_patches(), get_dataset_names(), - get_vector_data_ranges(), - tecplot_flags, out); + get_vector_data_ranges(), + tecplot_flags, out); } @@ -5305,8 +5305,8 @@ template void DataOutInterface::write_tecplot_binary (std::ostream &out) const { DataOutBase::write_tecplot_binary (get_patches(), get_dataset_names(), - get_vector_data_ranges(), - tecplot_flags, out); + get_vector_data_ranges(), + tecplot_flags, out); } @@ -5315,16 +5315,16 @@ template void DataOutInterface::write_vtk (std::ostream &out) const { DataOutBase::write_vtk (get_patches(), get_dataset_names(), - get_vector_data_ranges(), - vtk_flags, out); + get_vector_data_ranges(), + vtk_flags, out); } template void DataOutInterface::write_vtu (std::ostream &out) const { DataOutBase::write_vtu (get_patches(), get_dataset_names(), - get_vector_data_ranges(), - vtk_flags, out); + get_vector_data_ranges(), + vtk_flags, out); } template @@ -5392,7 +5392,7 @@ void DataOutInterface::write_vtu_in_parallel (const char* filename template void DataOutInterface::write_pvtu_record (std::ostream &out, - const std::vector &piece_names) const + const std::vector &piece_names) const { AssertThrow (out, ExcIO()); @@ -5420,47 +5420,47 @@ DataOutInterface::write_pvtu_record (std::ostream &out, out << " \n"; out << " \n"; - // We need to output in the same order as - // the write_vtu function does: + // We need to output in the same order as + // the write_vtu function does: std::vector data_set_written (n_data_sets, false); for (unsigned int n_th_vector=0; n_th_vector(vector_data_ranges[n_th_vector]) >= - std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), - ExcLowerRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), - std_cxx1x::get<0>(vector_data_ranges[n_th_vector]))); + std_cxx1x::get<0>(vector_data_ranges[n_th_vector]), + ExcLowerRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), + std_cxx1x::get<0>(vector_data_ranges[n_th_vector]))); AssertThrow (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets, - ExcIndexRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), - 0, n_data_sets)); + ExcIndexRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), + 0, n_data_sets)); AssertThrow (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) + 1 - - std_cxx1x::get<0>(vector_data_ranges[n_th_vector]) <= 3, - ExcMessage ("Can't declare a vector with more than 3 components " - "in VTK")); + - std_cxx1x::get<0>(vector_data_ranges[n_th_vector]) <= 3, + ExcMessage ("Can't declare a vector with more than 3 components " + "in VTK")); - // mark these components as already - // written: + // mark these components as already + // written: for (unsigned int i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]); - i<=std_cxx1x::get<1>(vector_data_ranges[n_th_vector]); - ++i) - data_set_written[i] = true; - - // write the - // header. concatenate all the - // component names with double - // underscores unless a vector - // name has been specified + i<=std_cxx1x::get<1>(vector_data_ranges[n_th_vector]); + ++i) + data_set_written[i] = true; + + // write the + // header. concatenate all the + // component names with double + // underscores unless a vector + // name has been specified out << " (vector_data_ranges[n_th_vector]) != "") - out << std_cxx1x::get<2>(vector_data_ranges[n_th_vector]); + out << std_cxx1x::get<2>(vector_data_ranges[n_th_vector]); else - { - for (unsigned int i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]); - i(vector_data_ranges[n_th_vector]); - ++i) - out << data_names[i] << "__"; - out << data_names[std_cxx1x::get<1>(vector_data_ranges[n_th_vector])]; - } + { + for (unsigned int i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]); + i(vector_data_ranges[n_th_vector]); + ++i) + out << data_names[i] << "__"; + out << data_names[std_cxx1x::get<1>(vector_data_ranges[n_th_vector])]; + } out << "\" NumberOfComponents=\"3\" format=\"ascii\"/>\n"; } @@ -5468,9 +5468,9 @@ DataOutInterface::write_pvtu_record (std::ostream &out, for (unsigned int data_set=0; data_set\n"; + out << " \n"; } out << " \n"; @@ -5487,7 +5487,7 @@ DataOutInterface::write_pvtu_record (std::ostream &out, out.flush(); - // assert the stream is still ok + // assert the stream is still ok AssertThrow (out, ExcIO()); } @@ -5496,7 +5496,7 @@ DataOutInterface::write_pvtu_record (std::ostream &out, template void DataOutInterface::write_visit_record (std::ostream &out, - const std::vector &piece_names) const + const std::vector &piece_names) const { out << "!NBLOCKS " << piece_names.size() << std::endl; for (unsigned int i=0; i:: write_deal_II_intermediate (std::ostream &out) const { DataOutBase::write_deal_II_intermediate (get_patches(), get_dataset_names(), - get_vector_data_ranges(), - deal_II_intermediate_flags, out); + get_vector_data_ranges(), + deal_II_intermediate_flags, out); } @@ -5519,7 +5519,7 @@ write_deal_II_intermediate (std::ostream &out) const template void DataOutInterface::write (std::ostream &out, - const OutputFormat output_format_) const + const OutputFormat output_format_) const { OutputFormat output_format = output_format_; if (output_format == default_format) @@ -5528,54 +5528,54 @@ DataOutInterface::write (std::ostream &out, switch (output_format) { case none: - break; + break; case dx: - write_dx (out); - break; + write_dx (out); + break; case ucd: - write_ucd (out); - break; + write_ucd (out); + break; case gnuplot: - write_gnuplot (out); - break; + write_gnuplot (out); + break; case povray: - write_povray (out); - break; + write_povray (out); + break; case eps: - write_eps(out); - break; + write_eps(out); + break; case gmv: - write_gmv (out); - break; + write_gmv (out); + break; case tecplot: - write_tecplot (out); - break; + write_tecplot (out); + break; case tecplot_binary: - write_tecplot_binary (out); - break; + write_tecplot_binary (out); + break; case vtk: - write_vtk (out); - break; + write_vtk (out); + break; case vtu: - write_vtu (out); - break; + write_vtu (out); + break; case deal_II_intermediate: - write_deal_II_intermediate (out); - break; + write_deal_II_intermediate (out); + break; default: - Assert (false, ExcNotImplemented()); + Assert (false, ExcNotImplemented()); } } @@ -5690,10 +5690,10 @@ void DataOutInterface::declare_parameters (ParameterHandler &prm) { prm.declare_entry ("Output format", "gnuplot", - Patterns::Selection (get_output_format_names ()), + Patterns::Selection (get_output_format_names ()), "A name for the output format to be used"); prm.declare_entry("Subdivisions", "1", Patterns::Integer(), - "Number of subdivisions of each mesh cell"); + "Number of subdivisions of each mesh cell"); prm.enter_subsection ("DX output parameters"); DXFlags::declare_parameters (prm); @@ -5787,15 +5787,15 @@ std::size_t DataOutInterface::memory_consumption () const { return (sizeof (default_fmt) + - MemoryConsumption::memory_consumption (dx_flags) + - MemoryConsumption::memory_consumption (ucd_flags) + - MemoryConsumption::memory_consumption (gnuplot_flags) + - MemoryConsumption::memory_consumption (povray_flags) + - MemoryConsumption::memory_consumption (eps_flags) + - MemoryConsumption::memory_consumption (gmv_flags) + - MemoryConsumption::memory_consumption (tecplot_flags) + - MemoryConsumption::memory_consumption (vtk_flags) + - MemoryConsumption::memory_consumption (deal_II_intermediate_flags)); + MemoryConsumption::memory_consumption (dx_flags) + + MemoryConsumption::memory_consumption (ucd_flags) + + MemoryConsumption::memory_consumption (gnuplot_flags) + + MemoryConsumption::memory_consumption (povray_flags) + + MemoryConsumption::memory_consumption (eps_flags) + + MemoryConsumption::memory_consumption (gmv_flags) + + MemoryConsumption::memory_consumption (tecplot_flags) + + MemoryConsumption::memory_consumption (vtk_flags) + + MemoryConsumption::memory_consumption (deal_II_intermediate_flags)); } @@ -5818,7 +5818,7 @@ DataOutReader::read (std::istream &in) { Assert (in, ExcIO()); - // first empty previous content + // first empty previous content { std::vector > tmp; @@ -5833,14 +5833,14 @@ DataOutReader::read (std::istream &in) tmp.swap (vector_data_ranges); } - // then check that we have the - // correct header of this - // file. both the first and second - // real lines have to match, as - // well as the dimension - // information written before that - // and the Version information - // written in the third line + // then check that we have the + // correct header of this + // file. both the first and second + // real lines have to match, as + // well as the dimension + // information written before that + // and the Version information + // written in the third line { std::pair dimension_info @@ -5881,12 +5881,12 @@ DataOutReader::read (std::istream &in) s << "[Version: " << dealii::DataOutBase::Deal_II_IntermediateFlags::format_version << "]"; Assert (header == s.str(), - ExcMessage("Invalid or incompatible file format. Intermediate format " - "files can only be read by the same deal.II version as they " - "are written by.")); + ExcMessage("Invalid or incompatible file format. Intermediate format " + "files can only be read by the same deal.II version as they " + "are written by.")); } - // then read the rest of the data + // then read the rest of the data unsigned int n_datasets; in >> n_datasets; dataset_names.resize (n_datasets); @@ -5905,16 +5905,16 @@ DataOutReader::read (std::istream &in) for (unsigned int i=0; i> std_cxx1x::get<0>(vector_data_ranges[i]) - >> std_cxx1x::get<1>(vector_data_ranges[i]); - - // read in the name of that vector - // range. because it is on a separate - // line, we first need to read to the - // end of the previous line (nothing - // should be there any more after we've - // read the previous two integers) and - // then read the entire next line for - // the name + >> std_cxx1x::get<1>(vector_data_ranges[i]); + + // read in the name of that vector + // range. because it is on a separate + // line, we first need to read to the + // end of the previous line (nothing + // should be there any more after we've + // read the previous two integers) and + // then read the entire next line for + // the name std::string name; getline(in, name); getline(in, name); @@ -5942,26 +5942,26 @@ merge (const DataOutReader &source) Assert (get_dataset_names() == source.get_dataset_names(), ExcIncompatibleDatasetNames()); - // check equality of the vector data - // specifications + // check equality of the vector data + // specifications Assert (get_vector_data_ranges().size() == - source.get_vector_data_ranges().size(), - ExcMessage ("Both sources need to declare the same components " - "as vectors.")); + source.get_vector_data_ranges().size(), + ExcMessage ("Both sources need to declare the same components " + "as vectors.")); for (unsigned int i=0; i(get_vector_data_ranges()[i]) == - std_cxx1x::get<0>(source.get_vector_data_ranges()[i]), - ExcMessage ("Both sources need to declare the same components " - "as vectors.")); + std_cxx1x::get<0>(source.get_vector_data_ranges()[i]), + ExcMessage ("Both sources need to declare the same components " + "as vectors.")); Assert (std_cxx1x::get<1>(get_vector_data_ranges()[i]) == - std_cxx1x::get<1>(source.get_vector_data_ranges()[i]), - ExcMessage ("Both sources need to declare the same components " - "as vectors.")); + std_cxx1x::get<1>(source.get_vector_data_ranges()[i]), + ExcMessage ("Both sources need to declare the same components " + "as vectors.")); Assert (std_cxx1x::get<2>(get_vector_data_ranges()[i]) == - std_cxx1x::get<2>(source.get_vector_data_ranges()[i]), - ExcMessage ("Both sources need to declare the same components " - "as vectors.")); + std_cxx1x::get<2>(source.get_vector_data_ranges()[i]), + ExcMessage ("Both sources need to declare the same components " + "as vectors.")); } // make sure patches are compatible @@ -6025,14 +6025,14 @@ DataOutReader::get_vector_data_ranges () const template std::ostream & operator << (std::ostream &out, - const DataOutBase::Patch &patch) + const DataOutBase::Patch &patch) { - // write a header line + // write a header line out << "[deal.II intermediate Patch<" << dim << ',' << spacedim << ">]" << '\n'; - // then write all the data that is - // in this patch + // then write all the data that is + // in this patch for (unsigned int i=0; i::vertices_per_cell; ++i) out << patch.vertices[GeometryInfo::ucd_to_deal[i]] << ' '; out << '\n'; @@ -6061,22 +6061,22 @@ operator << (std::ostream &out, template std::istream & operator >> (std::istream &in, - DataOutBase::Patch &patch) + DataOutBase::Patch &patch) { Assert (in, ExcIO()); - // read a header line and compare - // it to what we usually - // write. skip all lines that - // contain only blanks at the start + // read a header line and compare + // it to what we usually + // write. skip all lines that + // contain only blanks at the start { std::string header; do { - getline (in, header); - while ((header.size() != 0) && - (header[header.size()-1] == ' ')) - header.erase(header.size()-1); + getline (in, header); + while ((header.size() != 0) && + (header[header.size()-1] == ' ')) + header.erase(header.size()-1); } while ((header == "") && in); @@ -6087,8 +6087,8 @@ operator >> (std::istream &in, } - // then read all the data that is - // in this patch + // then read all the data that is + // in this patch for (unsigned int i=0; i::vertices_per_cell; ++i) in >> patch.vertices[GeometryInfo::ucd_to_deal[i]]; @@ -6122,11 +6122,11 @@ operator >> (std::istream &in, template \ std::ostream & \ operator << (std::ostream &out, \ - const DataOutBase::Patch &patch); \ + const DataOutBase::Patch &patch); \ template \ std::istream & \ operator >> (std::istream &in, \ - DataOutBase::Patch &patch) + DataOutBase::Patch &patch) INSTANTIATE(1,1); INSTANTIATE(2,2); diff --git a/deal.II/source/base/event.cc b/deal.II/source/base/event.cc index 693885a9cf..a5c4a76ebe 100644 --- a/deal.II/source/base/event.cc +++ b/deal.II/source/base/event.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2010 by the deal.II authors +// Copyright (C) 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -28,9 +28,9 @@ namespace Algorithms names.push_back(name); Event result; - // The constructor generated an - // object with all flags equal - // zero. Now we set the new one. + // The constructor generated an + // object with all flags equal + // zero. Now we set the new one. result.flags[index] = true; return result; @@ -38,9 +38,9 @@ namespace Algorithms Event::Event () - : - all_true(false), - flags(names.size(), false) + : + all_true(false), + flags(names.size(), false) {} diff --git a/deal.II/source/base/exceptions.cc b/deal.II/source/base/exceptions.cc index a1ccefa8a6..b95683f1e8 100644 --- a/deal.II/source/base/exceptions.cc +++ b/deal.II/source/base/exceptions.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 2000, 2001, 2002, 2003, 2005, 2006, 2009 by the deal.II authors +// Copyright (C) 1998, 2000, 2001, 2002, 2003, 2005, 2006, 2009, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -62,19 +62,19 @@ namespace deal_II_exceptions ExceptionBase::ExceptionBase () : - file(""), line(0), function(""), cond(""), exc(""), - stacktrace (0), - n_stacktrace_frames (0) + file(""), line(0), function(""), cond(""), exc(""), + stacktrace (0), + n_stacktrace_frames (0) {} ExceptionBase::ExceptionBase (const char* f, const int l, const char *func, - const char* c, const char *e) + const char* c, const char *e) : - file(f), line(l), function(func), cond(c), exc(e), - stacktrace (0), - n_stacktrace_frames (0) + file(f), line(l), function(func), cond(c), exc(e), + stacktrace (0), + n_stacktrace_frames (0) {} @@ -82,13 +82,13 @@ ExceptionBase::ExceptionBase (const char* f, const int l, const char *func, ExceptionBase::ExceptionBase (const ExceptionBase &exc) : std::exception (exc), - file(exc.file), line(exc.line), + file(exc.file), line(exc.line), function(exc.function), cond(exc.cond), exc(exc.exc), // don't copy stacktrace to // avoid double de-allocation // problem - stacktrace (0), - n_stacktrace_frames (0) + stacktrace (0), + n_stacktrace_frames (0) {} @@ -105,10 +105,10 @@ ExceptionBase::~ExceptionBase () throw () void ExceptionBase::set_fields (const char* f, - const int l, - const char *func, - const char *c, - const char *e) + const int l, + const char *func, + const char *c, + const char *e) { file = f; line = l; @@ -116,13 +116,13 @@ void ExceptionBase::set_fields (const char* f, cond = c; exc = e; - // if the system supports this, get - // a stacktrace how we got here + // if the system supports this, get + // a stacktrace how we got here #ifdef HAVE_GLIBC_STACKTRACE void * array[25]; n_stacktrace_frames = backtrace(array, 25); stacktrace = backtrace_symbols(array, n_stacktrace_frames); -#endif +#endif } @@ -134,117 +134,117 @@ void ExceptionBase::print_stack_trace (std::ostream &out) const if (deal_II_exceptions::show_stacktrace == false) return; - - - // if there is a stackframe stored, print it + + + // if there is a stackframe stored, print it out << std::endl; out << "Stacktrace:" << std::endl << "-----------" << std::endl; - - // print the stacktrace. first - // omit all those frames that have - // ExceptionBase or - // deal_II_exceptions in their - // names, as these correspond to - // the exception raising mechanism - // themselves, rather than the - // place where the exception was - // triggered + + // print the stacktrace. first + // omit all those frames that have + // ExceptionBase or + // deal_II_exceptions in their + // names, as these correspond to + // the exception raising mechanism + // themselves, rather than the + // place where the exception was + // triggered int frame = 0; while ((frame < n_stacktrace_frames) - && - ((std::string(stacktrace[frame]).find ("ExceptionBase") != std::string::npos) - || - (std::string(stacktrace[frame]).find ("deal_II_exceptions") != std::string::npos))) + && + ((std::string(stacktrace[frame]).find ("ExceptionBase") != std::string::npos) + || + (std::string(stacktrace[frame]).find ("deal_II_exceptions") != std::string::npos))) ++frame; - // output the rest + // output the rest const unsigned int first_significant_frame = frame; for (; frame < n_stacktrace_frames; ++frame) { out << '#' << frame - first_significant_frame - << " "; - - // the stacktrace frame is - // actually of the format - // "filename(functionname+offset) - // [address]". let's try to - // get the mangled - // functionname out: + << " "; + + // the stacktrace frame is + // actually of the format + // "filename(functionname+offset) + // [address]". let's try to + // get the mangled + // functionname out: std::string stacktrace_entry (stacktrace[frame]); const unsigned int pos_start = stacktrace_entry.find('('), - pos_end = stacktrace_entry.find('+'); + pos_end = stacktrace_entry.find('+'); std::string functionname = stacktrace_entry.substr (pos_start+1, - pos_end-pos_start-1); - - // demangle, and if successful - // replace old mangled string - // by unmangled one (skipping - // address and offset). treat - // "main" differently, since - // it is apparently demangled - // as "unsigned int" for - // unknown reasons :-) - // if we can, demangle the - // function name + pos_end-pos_start-1); + + // demangle, and if successful + // replace old mangled string + // by unmangled one (skipping + // address and offset). treat + // "main" differently, since + // it is apparently demangled + // as "unsigned int" for + // unknown reasons :-) + // if we can, demangle the + // function name #ifdef HAVE_LIBSTDCXX_DEMANGLER int status; char *p = abi::__cxa_demangle(functionname.c_str(), 0, 0, &status); - + if ((status == 0) && (functionname != "main")) - { - std::string realname(p); - // in MT mode, one often - // gets backtraces - // spanning several lines - // because we have so many - // boost::tuple arguments - // in the MT calling - // functions. most of the - // trailing arguments of - // these tuples are - // actually unused - // boost::tuples::null_type, - // so we should split them - // off if they are - // trailing a template - // argument list - while (realname.find (", boost::tuples::null_type>") - != std::string::npos) - realname.erase (realname.find (", boost::tuples::null_type>"), - std::string (", boost::tuples::null_type").size()); - - stacktrace_entry = stacktrace_entry.substr(0, pos_start) - + - ": " - + - realname; - } + { + std::string realname(p); + // in MT mode, one often + // gets backtraces + // spanning several lines + // because we have so many + // boost::tuple arguments + // in the MT calling + // functions. most of the + // trailing arguments of + // these tuples are + // actually unused + // boost::tuples::null_type, + // so we should split them + // off if they are + // trailing a template + // argument list + while (realname.find (", boost::tuples::null_type>") + != std::string::npos) + realname.erase (realname.find (", boost::tuples::null_type>"), + std::string (", boost::tuples::null_type").size()); + + stacktrace_entry = stacktrace_entry.substr(0, pos_start) + + + ": " + + + realname; + } else - stacktrace_entry = stacktrace_entry.substr(0, pos_start) - + - ": " - + - functionname; + stacktrace_entry = stacktrace_entry.substr(0, pos_start) + + + ": " + + + functionname; free (p); - -#else + +#else stacktrace_entry = stacktrace_entry.substr(0, pos_start) - + - ": " - + - functionname; + + + ": " + + + functionname; #endif - - // then output what we have + + // then output what we have out << stacktrace_entry - << std::endl; + << std::endl; - // stop if we're in main() + // stop if we're in main() if (functionname == "main") - break; + break; } } @@ -260,8 +260,8 @@ void ExceptionBase::print_exc_data (std::ostream &out) const << "The name and call sequence of the exception was:" << std::endl << " " << exc << std::endl << "Additional Information: " << std::endl; - // Additionally, leave a trace in - // deallog if we do not stop here + // Additionally, leave a trace in + // deallog if we do not stop here if (deal_II_exceptions::abort_on_exception == false) deallog << exc << std::endl; } @@ -278,7 +278,7 @@ const char * ExceptionBase::what () const throw () // if we say that this function // does not throw exceptions, we // better make sure it does not - try + try { // have a place where to store the // description of the exception as @@ -316,7 +316,7 @@ const char * ExceptionBase::what () const throw () return description.c_str(); } - catch (std::exception &exc) + catch (std::exception &exc) { std::cerr << "*** Exception encountered in exception handling routines ***" << std::endl @@ -341,94 +341,94 @@ const char * ExceptionBase::what () const throw () namespace deal_II_exceptions { - namespace internals + namespace internals { - - /** - * Number of exceptions dealt - * with so far. Zero at program - * start. Messages are only - * displayed if the value is - * zero. - */ + + /** + * Number of exceptions dealt + * with so far. Zero at program + * start. Messages are only + * displayed if the value is + * zero. + */ unsigned int n_treated_exceptions; ExceptionBase *last_exception; - + void issue_error_assert (const char *file, - int line, - const char *function, - const char *cond, - const char *exc_name, - ExceptionBase &e) + int line, + const char *function, + const char *cond, + const char *exc_name, + ExceptionBase &e) { // fill the fields of the - // exception object + // exception object e.set_fields (file, line, function, cond, exc_name); - - // if no other exception has - // been displayed before, show - // this one + + // if no other exception has + // been displayed before, show + // this one if (n_treated_exceptions == 0) - { + { std::cerr << "--------------------------------------------------------" - << std::endl; - // print out general data - e.print_exc_data (std::cerr); - // print out exception - // specific data - e.print_info (std::cerr); - e.print_stack_trace (std::cerr); - std::cerr << "--------------------------------------------------------" - << std::endl; - - // if there is more to say, - // do so - if (!additional_assert_output.empty()) - std::cerr << additional_assert_output << std::endl; - } + << std::endl; + // print out general data + e.print_exc_data (std::cerr); + // print out exception + // specific data + e.print_info (std::cerr); + e.print_stack_trace (std::cerr); + std::cerr << "--------------------------------------------------------" + << std::endl; + + // if there is more to say, + // do so + if (!additional_assert_output.empty()) + std::cerr << additional_assert_output << std::endl; + } else - { - // if this is the first - // follow-up message, - // display a message that - // further exceptions are - // suppressed - if (n_treated_exceptions == 1) - std::cerr << "******** More assertions fail but messages are suppressed! ********" - << std::endl; - }; - - // increase number of treated - // exceptions by one + { + // if this is the first + // follow-up message, + // display a message that + // further exceptions are + // suppressed + if (n_treated_exceptions == 1) + std::cerr << "******** More assertions fail but messages are suppressed! ********" + << std::endl; + }; + + // increase number of treated + // exceptions by one n_treated_exceptions++; last_exception = &e; - - - // abort the program now since - // something has gone horribly - // wrong. however, there is one - // case where we do not want to - // do that, namely when another - // exception, possibly thrown - // by AssertThrow is active, - // since in that case we will - // not come to see the original - // exception. in that case - // indicate that the program is - // not aborted due to this - // reason. + + + // abort the program now since + // something has gone horribly + // wrong. however, there is one + // case where we do not want to + // do that, namely when another + // exception, possibly thrown + // by AssertThrow is active, + // since in that case we will + // not come to see the original + // exception. in that case + // indicate that the program is + // not aborted due to this + // reason. if (std::uncaught_exception() == true) - { - // only display message once - if (n_treated_exceptions <= 1) - std::cerr << "******** Program is not aborted since another exception is active! ********" - << std::endl; - } + { + // only display message once + if (n_treated_exceptions <= 1) + std::cerr << "******** Program is not aborted since another exception is active! ********" + << std::endl; + } else if(deal_II_exceptions::abort_on_exception == true) std::abort (); else - --n_treated_exceptions; + --n_treated_exceptions; } @@ -438,9 +438,9 @@ namespace deal_II_exceptions if (deal_II_exceptions::abort_on_exception == true) std::abort (); } - + } - + } @@ -463,7 +463,7 @@ namespace __gnu_cxx extern void __verbose_terminate_handler (); } -namespace +namespace { struct preload_terminate_dummy { diff --git a/deal.II/source/base/flow_function.cc b/deal.II/source/base/flow_function.cc index 772a65465c..3dad8e5e89 100644 --- a/deal.II/source/base/flow_function.cc +++ b/deal.II/source/base/flow_function.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2007, 2008, 2010, 2011 by the deal.II authors +// Copyright (C) 2007, 2008, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -28,11 +28,11 @@ namespace Functions template FlowFunction::FlowFunction() - : - Function(dim+1), - mean_pressure(0), - aux_values(dim+1), - aux_gradients(dim+1) + : + Function(dim+1), + mean_pressure(0), + aux_values(dim+1), + aux_gradients(dim+1) {} @@ -57,8 +57,8 @@ namespace Functions const unsigned int n_points = points.size(); Assert(values.size() == n_points, ExcDimensionMismatch(values.size(), n_points)); - // guard access to the aux_* - // variables in multithread mode + // guard access to the aux_* + // variables in multithread mode Threads::Mutex::ScopedLock lock (mutex); for (unsigned int d=0;d > points(1); points[0] = point; - // guard access to the aux_* - // variables in multithread mode + // guard access to the aux_* + // variables in multithread mode Threads::Mutex::ScopedLock lock (mutex); for (unsigned int d=0;d > points(1); points[0] = point; - // guard access to the aux_* - // variables in multithread mode + // guard access to the aux_* + // variables in multithread mode Threads::Mutex::ScopedLock lock (mutex); for (unsigned int d=0;d PoisseuilleFlow::PoisseuilleFlow(const double r, - const double Re) - : - radius(r), Reynolds(Re) + const double Re) + : + radius(r), Reynolds(Re) { Assert(Reynolds != 0., ExcMessage("Reynolds number cannot be zero")); } @@ -210,22 +210,22 @@ namespace Functions for (unsigned int k=0;k& p = points[k]; - // First, compute the - // square of the distance to - // the x-axis divided by the - // radius. - double r2 = 0; - for (unsigned int d=1;dmean_pressure; + const Point& p = points[k]; + // First, compute the + // square of the distance to + // the x-axis divided by the + // radius. + double r2 = 0; + for (unsigned int d=1;dmean_pressure; } } @@ -245,18 +245,18 @@ namespace Functions for (unsigned int k=0;k& p = points[k]; - // x-velocity - values[0][k][0] = 0.; - for (unsigned int d=1;d& p = points[k]; + // x-velocity + values[0][k][0] = 0.; + for (unsigned int d=1;d StokesCosine::StokesCosine(const double nu, const double r) - : - viscosity(nu), reaction(r) + : + viscosity(nu), reaction(r) {} @@ -313,35 +313,35 @@ namespace Functions for (unsigned int k=0;k& p = points[k]; - const double x = numbers::PI/2. * p(0); - const double y = numbers::PI/2. * p(1); - const double cx = cos(x); - const double cy = cos(y); - const double sx = sin(x); - const double sy = sin(y); - - if (dim==2) - { - values[0][k] = cx*cx*cy*sy; - values[1][k] = -cx*sx*cy*cy; - values[2][k] = cx*sx*cy*sy + this->mean_pressure; - } - else if (dim==3) - { - const double z = numbers::PI/2. * p(2); - const double cz = cos(z); - const double sz = sin(z); - - values[0][k] = cx*cx*cy*sy*cz*sz; - values[1][k] = cx*sx*cy*cy*cz*sz; - values[2][k] = -2.*cx*sx*cy*sy*cz*cz; - values[3][k] = cx*sx*cy*sy*cz*sz + this->mean_pressure; - } - else - { - Assert(false, ExcNotImplemented()); - } + const Point& p = points[k]; + const double x = numbers::PI/2. * p(0); + const double y = numbers::PI/2. * p(1); + const double cx = cos(x); + const double cy = cos(y); + const double sx = sin(x); + const double sy = sin(y); + + if (dim==2) + { + values[0][k] = cx*cx*cy*sy; + values[1][k] = -cx*sx*cy*cy; + values[2][k] = cx*sx*cy*sy + this->mean_pressure; + } + else if (dim==3) + { + const double z = numbers::PI/2. * p(2); + const double cz = cos(z); + const double sz = sin(z); + + values[0][k] = cx*cx*cy*sy*cz*sz; + values[1][k] = cx*sx*cy*cy*cz*sz; + values[2][k] = -2.*cx*sx*cy*sy*cz*cz; + values[3][k] = cx*sx*cy*sy*cz*sz + this->mean_pressure; + } + else + { + Assert(false, ExcNotImplemented()); + } } } @@ -360,52 +360,52 @@ namespace Functions for (unsigned int k=0;k& p = points[k]; - const double x = numbers::PI/2. * p(0); - const double y = numbers::PI/2. * p(1); - const double c2x = cos(2*x); - const double c2y = cos(2*y); - const double s2x = sin(2*x); - const double s2y = sin(2*y); - const double cx2 = .5+.5*c2x; // cos^2 x - const double cy2 = .5+.5*c2y; // cos^2 y - - if (dim==2) - { - values[0][k][0] = -.25*numbers::PI * s2x*s2y; - values[0][k][1] = .5 *numbers::PI * cx2*c2y; - values[1][k][0] = -.5 *numbers::PI * c2x*cy2; - values[1][k][1] = .25*numbers::PI * s2x*s2y; - values[2][k][0] = .25*numbers::PI * c2x*s2y; - values[2][k][1] = .25*numbers::PI * s2x*c2y; - } - else if (dim==3) - { - const double z = numbers::PI/2. * p(2); - const double c2z = cos(2*z); - const double s2z = sin(2*z); - const double cz2 = .5+.5*c2z; // cos^2 z - - values[0][k][0] = -.125*numbers::PI * s2x*s2y*s2z; - values[0][k][1] = .25 *numbers::PI * cx2*c2y*s2z; - values[0][k][2] = .25 *numbers::PI * cx2*s2y*c2z; - - values[1][k][0] = .25 *numbers::PI * c2x*cy2*s2z; - values[1][k][1] = -.125*numbers::PI * s2x*s2y*s2z; - values[1][k][2] = .25 *numbers::PI * s2x*cy2*c2z; - - values[2][k][0] = -.5 *numbers::PI * c2x*s2y*cz2; - values[2][k][1] = -.5 *numbers::PI * s2x*c2y*cz2; - values[2][k][2] = .25 *numbers::PI * s2x*s2y*s2z; - - values[3][k][0] = .125*numbers::PI * c2x*s2y*s2z; - values[3][k][1] = .125*numbers::PI * s2x*c2y*s2z; - values[3][k][2] = .125*numbers::PI * s2x*s2y*c2z; - } - else - { - Assert(false, ExcNotImplemented()); - } + const Point& p = points[k]; + const double x = numbers::PI/2. * p(0); + const double y = numbers::PI/2. * p(1); + const double c2x = cos(2*x); + const double c2y = cos(2*y); + const double s2x = sin(2*x); + const double s2y = sin(2*y); + const double cx2 = .5+.5*c2x; // cos^2 x + const double cy2 = .5+.5*c2y; // cos^2 y + + if (dim==2) + { + values[0][k][0] = -.25*numbers::PI * s2x*s2y; + values[0][k][1] = .5 *numbers::PI * cx2*c2y; + values[1][k][0] = -.5 *numbers::PI * c2x*cy2; + values[1][k][1] = .25*numbers::PI * s2x*s2y; + values[2][k][0] = .25*numbers::PI * c2x*s2y; + values[2][k][1] = .25*numbers::PI * s2x*c2y; + } + else if (dim==3) + { + const double z = numbers::PI/2. * p(2); + const double c2z = cos(2*z); + const double s2z = sin(2*z); + const double cz2 = .5+.5*c2z; // cos^2 z + + values[0][k][0] = -.125*numbers::PI * s2x*s2y*s2z; + values[0][k][1] = .25 *numbers::PI * cx2*c2y*s2z; + values[0][k][2] = .25 *numbers::PI * cx2*s2y*c2z; + + values[1][k][0] = .25 *numbers::PI * c2x*cy2*s2z; + values[1][k][1] = -.125*numbers::PI * s2x*s2y*s2z; + values[1][k][2] = .25 *numbers::PI * s2x*cy2*c2z; + + values[2][k][0] = -.5 *numbers::PI * c2x*s2y*cz2; + values[2][k][1] = -.5 *numbers::PI * s2x*c2y*cz2; + values[2][k][2] = .25 *numbers::PI * s2x*s2y*s2z; + + values[3][k][0] = .125*numbers::PI * c2x*s2y*s2z; + values[3][k][1] = .125*numbers::PI * s2x*c2y*s2z; + values[3][k][2] = .125*numbers::PI * s2x*s2y*c2z; + } + else + { + Assert(false, ExcNotImplemented()); + } } } @@ -424,51 +424,51 @@ namespace Functions if (reaction != 0.) { - vector_values(points, values); - for (unsigned int d=0;d& p = points[k]; - const double x = numbers::PI/2. * p(0); - const double y = numbers::PI/2. * p(1); - const double c2x = cos(2*x); - const double c2y = cos(2*y); - const double s2x = sin(2*x); - const double s2y = sin(2*y); - const double pi2 = .25 * numbers::PI * numbers::PI; - - if (dim==2) - { - values[0][k] += - viscosity*pi2 * (1.+2.*c2x) * s2y - numbers::PI/4. * c2x*s2y; - values[1][k] += viscosity*pi2 * s2x * (1.+2.*c2y) - numbers::PI/4. * s2x*c2y; - values[2][k] = 0.; - } - else if (dim==3) - { - const double z = numbers::PI * p(2); - const double c2z = cos(2*z); - const double s2z = sin(2*z); - - values[0][k] += - .5*viscosity*pi2 * (1.+2.*c2x) * s2y * s2z - numbers::PI/8. * c2x * s2y * s2z; - values[1][k] += .5*viscosity*pi2 * s2x * (1.+2.*c2y) * s2z - numbers::PI/8. * s2x * c2y * s2z; - values[2][k] += - .5*viscosity*pi2 * s2x * s2y * (1.+2.*c2z) - numbers::PI/8. * s2x * s2y * c2z; - values[3][k] = 0.; - } - else - { - Assert(false, ExcNotImplemented()); - } + const Point& p = points[k]; + const double x = numbers::PI/2. * p(0); + const double y = numbers::PI/2. * p(1); + const double c2x = cos(2*x); + const double c2y = cos(2*y); + const double s2x = sin(2*x); + const double s2y = sin(2*y); + const double pi2 = .25 * numbers::PI * numbers::PI; + + if (dim==2) + { + values[0][k] += - viscosity*pi2 * (1.+2.*c2x) * s2y - numbers::PI/4. * c2x*s2y; + values[1][k] += viscosity*pi2 * s2x * (1.+2.*c2y) - numbers::PI/4. * s2x*c2y; + values[2][k] = 0.; + } + else if (dim==3) + { + const double z = numbers::PI * p(2); + const double c2z = cos(2*z); + const double s2z = sin(2*z); + + values[0][k] += - .5*viscosity*pi2 * (1.+2.*c2x) * s2y * s2z - numbers::PI/8. * c2x * s2y * s2z; + values[1][k] += .5*viscosity*pi2 * s2x * (1.+2.*c2y) * s2z - numbers::PI/8. * s2x * c2y * s2z; + values[2][k] += - .5*viscosity*pi2 * s2x * s2y * (1.+2.*c2z) - numbers::PI/8. * s2x * s2y * c2z; + values[3][k] = 0.; + } + else + { + Assert(false, ExcNotImplemented()); + } } } @@ -478,11 +478,11 @@ namespace Functions const double StokesLSingularity::lambda = 0.54448373678246; StokesLSingularity::StokesLSingularity() - : - omega (3./2.*numbers::PI), - coslo (cos(lambda*omega)), - lp(1.+lambda), - lm(1.-lambda) + : + omega (3./2.*numbers::PI), + coslo (cos(lambda*omega)), + lp(1.+lambda), + lm(1.-lambda) {} @@ -543,25 +543,25 @@ namespace Functions for (unsigned int k=0;k& p = points[k]; - const double x = p(0); - const double y = p(1); - - if ((x<0) || (y<0)) - { - const double phi = std::atan2(y,-x)+numbers::PI; - const double r2 = x*x+y*y; - const double rl = pow(r2,lambda/2.); - const double rl1 = pow(r2,lambda/2.-.5); - values[0][k] = rl * (lp*sin(phi)*Psi(phi) + cos(phi)*Psi_1(phi)); - values[1][k] = rl * (lp*cos(phi)*Psi(phi) - sin(phi)*Psi_1(phi)); - values[2][k] = -rl1 * (lp*lp*Psi_1(phi) + Psi_3(phi)) / lm + this->mean_pressure; - } - else - { - for (unsigned int d=0;d<3;++d) - values[d][k] = 0.; - } + const Point<2>& p = points[k]; + const double x = p(0); + const double y = p(1); + + if ((x<0) || (y<0)) + { + const double phi = std::atan2(y,-x)+numbers::PI; + const double r2 = x*x+y*y; + const double rl = pow(r2,lambda/2.); + const double rl1 = pow(r2,lambda/2.-.5); + values[0][k] = rl * (lp*sin(phi)*Psi(phi) + cos(phi)*Psi_1(phi)); + values[1][k] = rl * (lp*cos(phi)*Psi(phi) - sin(phi)*Psi_1(phi)); + values[2][k] = -rl1 * (lp*lp*Psi_1(phi) + Psi_3(phi)) / lm + this->mean_pressure; + } + else + { + for (unsigned int d=0;d<3;++d) + values[d][k] = 0.; + } } } @@ -579,45 +579,45 @@ namespace Functions for (unsigned int k=0;k& p = points[k]; - const double x = p(0); - const double y = p(1); - - if ((x<0) || (y<0)) - { - const double phi = std::atan2(y,-x)+numbers::PI; - const double r2 = x*x+y*y; - const double r = sqrt(r2); - const double rl = pow(r2,lambda/2.); - const double rl1 = pow(r2,lambda/2.-.5); - const double rl2 = pow(r2,lambda/2.-1.); - const double psi =Psi(phi); - const double psi1=Psi_1(phi); - const double psi2=Psi_2(phi); - const double cosp= cos(phi); - const double sinp= sin(phi); - - // Derivatives of u with respect to r, phi - const double udr = lambda * rl1 * (lp*sinp*psi + cosp*psi1); - const double udp = rl * (lp*cosp*psi + lp*sinp*psi1 - sinp*psi1 + cosp*psi2); - // Derivatives of v with respect to r, phi - const double vdr = lambda * rl1 * (lp*cosp*psi - sinp*psi1); - const double vdp = rl * (lp*(cosp*psi1 - sinp*psi) - cosp*psi1 - sinp*psi2); - // Derivatives of p with respect to r, phi - const double pdr = -(lambda-1.) * rl2 * (lp*lp*psi1+Psi_3(phi)) / lm; - const double pdp = -rl1 * (lp*lp*psi2+Psi_4(phi)) / lm; - values[0][k][0] = cosp*udr - sinp/r*udp; - values[0][k][1] = - sinp*udr - cosp/r*udp; - values[1][k][0] = cosp*vdr - sinp/r*vdp; - values[1][k][1] = - sinp*vdr - cosp/r*vdp; - values[2][k][0] = cosp*pdr - sinp/r*pdp; - values[2][k][1] = - sinp*pdr - cosp/r*pdp; - } - else - { - for (unsigned int d=0;d<3;++d) - values[d][k] = 0.; - } + const Point<2>& p = points[k]; + const double x = p(0); + const double y = p(1); + + if ((x<0) || (y<0)) + { + const double phi = std::atan2(y,-x)+numbers::PI; + const double r2 = x*x+y*y; + const double r = sqrt(r2); + const double rl = pow(r2,lambda/2.); + const double rl1 = pow(r2,lambda/2.-.5); + const double rl2 = pow(r2,lambda/2.-1.); + const double psi =Psi(phi); + const double psi1=Psi_1(phi); + const double psi2=Psi_2(phi); + const double cosp= cos(phi); + const double sinp= sin(phi); + + // Derivatives of u with respect to r, phi + const double udr = lambda * rl1 * (lp*sinp*psi + cosp*psi1); + const double udp = rl * (lp*cosp*psi + lp*sinp*psi1 - sinp*psi1 + cosp*psi2); + // Derivatives of v with respect to r, phi + const double vdr = lambda * rl1 * (lp*cosp*psi - sinp*psi1); + const double vdp = rl * (lp*(cosp*psi1 - sinp*psi) - cosp*psi1 - sinp*psi2); + // Derivatives of p with respect to r, phi + const double pdr = -(lambda-1.) * rl2 * (lp*lp*psi1+Psi_3(phi)) / lm; + const double pdp = -rl1 * (lp*lp*psi2+Psi_4(phi)) / lm; + values[0][k][0] = cosp*udr - sinp/r*udp; + values[0][k][1] = - sinp*udr - cosp/r*udp; + values[1][k][0] = cosp*vdr - sinp/r*vdp; + values[1][k][1] = - sinp*vdr - cosp/r*vdp; + values[2][k][0] = cosp*pdr - sinp/r*pdp; + values[2][k][1] = - sinp*pdr - cosp/r*pdp; + } + else + { + for (unsigned int d=0;d<3;++d) + values[d][k] = 0.; + } } } @@ -634,24 +634,24 @@ namespace Functions for (unsigned int d=0;d& p = points[k]; - const double x = p(0); - const double y = 2. * numbers::PI * p(1); - const double elx = std::exp(lbda*x); - - values[0][k] = 1. - elx * cos(y); - values[1][k] = .5 / numbers::PI * lbda * elx * sin(y); - values[2][k] = -.5 * elx * elx + p_average + this->mean_pressure; + const Point<2>& p = points[k]; + const double x = p(0); + const double y = 2. * numbers::PI * p(1); + const double elx = std::exp(lbda*x); + + values[0][k] = 1. - elx * cos(y); + values[1][k] = .5 / numbers::PI * lbda * elx * sin(y); + values[2][k] = -.5 * elx * elx + p_average + this->mean_pressure; } } @@ -692,25 +692,25 @@ namespace Functions Assert (gradients.size() == 3, ExcDimensionMismatch(gradients.size(), 3)); Assert (gradients[0].size() == n, - ExcDimensionMismatch(gradients[0].size(), n)); + ExcDimensionMismatch(gradients[0].size(), n)); for (unsigned int i=0;i& p = points[k]; - const double x = p(0); - const double y = zp * p(1); - const double elx = std::exp(lbda*x); - const double u = 1. - elx * cos(y); - const double ux = -lbda * elx * cos(y); - const double uy = elx * zp * sin(y); - const double v = lbda/zp * elx * sin(y); - const double vx = lbda*lbda/zp * elx * sin(y); - const double vy = zp*lbda/zp * elx * cos(y); - - values[0][k] = u*ux+v*uy; - values[1][k] = u*vx+v*vy; - values[2][k] = 0.; - } + const double zp = 2. * numbers::PI; + for (unsigned int k=0;k& p = points[k]; + const double x = p(0); + const double y = zp * p(1); + const double elx = std::exp(lbda*x); + const double u = 1. - elx * cos(y); + const double ux = -lbda * elx * cos(y); + const double uy = elx * zp * sin(y); + const double v = lbda/zp * elx * sin(y); + const double vx = lbda*lbda/zp * elx * sin(y); + const double vy = zp*lbda/zp * elx * cos(y); + + values[0][k] = u*ux+v*uy; + values[1][k] = u*vx+v*vy; + values[2][k] = 0.; + } } else { - for (unsigned int d=0;d::dimension; template Function::Function (const unsigned int n_components, - const double initial_time) + const double initial_time) : - FunctionTime(initial_time), - n_components(n_components) + FunctionTime(initial_time), + n_components(n_components) { // avoid the construction of function // objects that don't return any @@ -58,7 +58,7 @@ Function & Function::operator= (const Function &f) template double Function::value (const Point &, - const unsigned int) const + const unsigned int) const { Assert (false, ExcPureFunctionCalled()); return 0; @@ -77,14 +77,14 @@ void Function::vector_value (const Point& p, template void Function::value_list (const std::vector > &points, - std::vector &values, - const unsigned int component) const + std::vector &values, + const unsigned int component) const { - // check whether component is in - // the valid range is up to the - // derived class + // check whether component is in + // the valid range is up to the + // derived class Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); for (unsigned int i=0; ivalue (points[i], component); @@ -93,13 +93,13 @@ void Function::value_list (const std::vector > &points, template void Function::vector_value_list (const std::vector > &points, - std::vector > &values) const + std::vector > &values) const { - // check whether component is in - // the valid range is up to the - // derived class + // check whether component is in + // the valid range is up to the + // derived class Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); for (unsigned int i=0; ivector_value (points[i], values[i]); @@ -120,7 +120,7 @@ void Function::vector_values ( template Tensor<1,dim> Function::gradient (const Point &, - const unsigned int) const + const unsigned int) const { Assert (false, ExcPureFunctionCalled()); return Point(); @@ -140,11 +140,11 @@ void Function::vector_gradient ( template void Function::gradient_list (const std::vector > &points, - std::vector > &gradients, - const unsigned int component) const + std::vector > &gradients, + const unsigned int component) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); + ExcDimensionMismatch(gradients.size(), points.size())); for (unsigned int i=0; i::gradient_list (const std::vector > &points, template void Function::vector_gradient_list (const std::vector > &points, - std::vector > > &gradients) const + std::vector > > &gradients) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); + ExcDimensionMismatch(gradients.size(), points.size())); for (unsigned int i=0; i::vector_gradients ( template double Function::laplacian (const Point &, - const unsigned int) const + const unsigned int) const { Assert (false, ExcPureFunctionCalled()); return 0; @@ -191,7 +191,7 @@ double Function::laplacian (const Point &, template void Function::vector_laplacian (const Point &, - Vector &) const + Vector &) const { Assert (false, ExcPureFunctionCalled()); } @@ -200,14 +200,14 @@ void Function::vector_laplacian (const Point &, template void Function::laplacian_list (const std::vector > &points, - std::vector &laplacians, - const unsigned int component) const + std::vector &laplacians, + const unsigned int component) const { - // check whether component is in - // the valid range is up to the - // derived class + // check whether component is in + // the valid range is up to the + // derived class Assert (laplacians.size() == points.size(), - ExcDimensionMismatch(laplacians.size(), points.size())); + ExcDimensionMismatch(laplacians.size(), points.size())); for (unsigned int i=0; ilaplacian (points[i], component); @@ -216,13 +216,13 @@ void Function::laplacian_list (const std::vector > &points, template void Function::vector_laplacian_list (const std::vector > &points, - std::vector > &laplacians) const + std::vector > &laplacians) const { - // check whether component is in - // the valid range is up to the - // derived class + // check whether component is in + // the valid range is up to the + // derived class Assert (laplacians.size() == points.size(), - ExcDimensionMismatch(laplacians.size(), points.size())); + ExcDimensionMismatch(laplacians.size(), points.size())); for (unsigned int i=0; ivector_laplacian (points[i], laplacians[i]); @@ -234,8 +234,8 @@ template std::size_t Function::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } @@ -245,7 +245,7 @@ Function::memory_consumption () const template ZeroFunction::ZeroFunction (const unsigned int n_components) : - Function (n_components) + Function (n_components) {} @@ -256,7 +256,7 @@ ZeroFunction::~ZeroFunction () template double ZeroFunction::value (const Point &, - const unsigned int) const + const unsigned int) const { return 0.; } @@ -264,10 +264,10 @@ double ZeroFunction::value (const Point &, template void ZeroFunction::vector_value (const Point &, - Vector &return_value) const + Vector &return_value) const { Assert (return_value.size() == this->n_components, - ExcDimensionMismatch (return_value.size(), this->n_components)); + ExcDimensionMismatch (return_value.size(), this->n_components)); std::fill (return_value.begin(), return_value.end(), 0.0); } @@ -275,10 +275,10 @@ void ZeroFunction::vector_value (const Point &, template void ZeroFunction::value_list (const std::vector > &points, - std::vector &values, - const unsigned int /*component*/) const { + std::vector &values, + const unsigned int /*component*/) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); std::fill (values.begin(), values.end(), 0.); } @@ -286,15 +286,15 @@ void ZeroFunction::value_list (const std::vector > &points, template void ZeroFunction::vector_value_list (const std::vector > &points, - std::vector > &values) const + std::vector > &values) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); for (unsigned int i=0; in_components, - ExcDimensionMismatch(values[i].size(), this->n_components)); + ExcDimensionMismatch(values[i].size(), this->n_components)); std::fill (values[i].begin(), values[i].end(), 0.); }; } @@ -302,7 +302,7 @@ void ZeroFunction::vector_value_list (const std::vector > &point template Tensor<1,dim> ZeroFunction::gradient (const Point &, - const unsigned int) const + const unsigned int) const { return Tensor<1,dim>(); } @@ -310,10 +310,10 @@ Tensor<1,dim> ZeroFunction::gradient (const Point &, template void ZeroFunction::vector_gradient (const Point &, - std::vector > &gradients) const + std::vector > &gradients) const { Assert (gradients.size() == this->n_components, - ExcDimensionMismatch(gradients.size(), this->n_components)); + ExcDimensionMismatch(gradients.size(), this->n_components)); for (unsigned int c=0; cn_components; ++c) gradients[c].clear (); @@ -322,11 +322,11 @@ void ZeroFunction::vector_gradient (const Point &, template void ZeroFunction::gradient_list (const std::vector > &points, - std::vector > &gradients, - const unsigned int /*component*/) const + std::vector > &gradients, + const unsigned int /*component*/) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); + ExcDimensionMismatch(gradients.size(), points.size())); for (unsigned int i=0; i::gradient_list (const std::vector > &points, template void ZeroFunction::vector_gradient_list (const std::vector > &points, - std::vector > > &gradients) const + std::vector > > &gradients) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); + ExcDimensionMismatch(gradients.size(), points.size())); for (unsigned int i=0; in_components, - ExcDimensionMismatch(gradients[i].size(), this->n_components)); + ExcDimensionMismatch(gradients[i].size(), this->n_components)); for (unsigned int c=0; cn_components; ++c) - gradients[i][c].clear (); + gradients[i][c].clear (); }; } @@ -353,10 +353,10 @@ void ZeroFunction::vector_gradient_list (const std::vector > template ConstantFunction::ConstantFunction (const double value, - const unsigned int n_components) + const unsigned int n_components) : - ZeroFunction (n_components), - function_value (value) + ZeroFunction (n_components), + function_value (value) {} @@ -368,10 +368,10 @@ ConstantFunction::~ConstantFunction () {} template double ConstantFunction::value (const Point &, - const unsigned int component) const + const unsigned int component) const { Assert (component < this->n_components, - ExcIndexRange (component, 0, this->n_components)); + ExcIndexRange (component, 0, this->n_components)); return function_value; } @@ -379,10 +379,10 @@ double ConstantFunction::value (const Point &, template void ConstantFunction::vector_value (const Point &, - Vector &return_value) const + Vector &return_value) const { Assert (return_value.size() == this->n_components, - ExcDimensionMismatch (return_value.size(), this->n_components)); + ExcDimensionMismatch (return_value.size(), this->n_components)); std::fill (return_value.begin(), return_value.end(), function_value); } @@ -391,13 +391,13 @@ void ConstantFunction::vector_value (const Point &, template void ConstantFunction::value_list (const std::vector > &points, - std::vector &values, - const unsigned int component) const + std::vector &values, + const unsigned int component) const { Assert (component < this->n_components, - ExcIndexRange (component, 0, this->n_components)); + ExcIndexRange (component, 0, this->n_components)); Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); std::fill (values.begin(), values.end(), function_value); } @@ -406,15 +406,15 @@ void ConstantFunction::value_list (const std::vector > &points, template void ConstantFunction::vector_value_list (const std::vector > &points, - std::vector > &values) const + std::vector > &values) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); for (unsigned int i=0; in_components, - ExcDimensionMismatch(values[i].size(), this->n_components)); + ExcDimensionMismatch(values[i].size(), this->n_components)); std::fill (values[i].begin(), values[i].end(), function_value); }; } @@ -425,8 +425,8 @@ template std::size_t ConstantFunction::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } @@ -437,8 +437,8 @@ ComponentSelectFunction:: ComponentSelectFunction (const unsigned int selected, const double value, const unsigned int n_components) - : - ConstantFunction (value, n_components), + : + ConstantFunction (value, n_components), selected_components(std::make_pair(selected,selected+1)) {} @@ -448,12 +448,12 @@ template ComponentSelectFunction:: ComponentSelectFunction (const unsigned int selected, const unsigned int n_components) - : - ConstantFunction (1., n_components), + : + ConstantFunction (1., n_components), selected_components(std::make_pair(selected,selected+1)) { Assert (selected < n_components, - ExcIndexRange (selected, 0, n_components)); + ExcIndexRange (selected, 0, n_components)); } @@ -462,8 +462,8 @@ template ComponentSelectFunction:: ComponentSelectFunction (const std::pair &selected, const unsigned int n_components) - : - ConstantFunction (1., n_components), + : + ConstantFunction (1., n_components), selected_components(selected) { Assert (selected_components.first < selected_components.second, @@ -478,10 +478,10 @@ ComponentSelectFunction (const std::pair &selected, template void ComponentSelectFunction::vector_value (const Point &, - Vector &return_value) const + Vector &return_value) const { Assert (return_value.size() == this->n_components, - ExcDimensionMismatch (return_value.size(), this->n_components)); + ExcDimensionMismatch (return_value.size(), this->n_components)); return_value = 0; std::fill (return_value.begin()+selected_components.first, @@ -493,10 +493,10 @@ void ComponentSelectFunction::vector_value (const Point &, template void ComponentSelectFunction::vector_value_list (const std::vector > &points, - std::vector > &values) const + std::vector > &values) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); for (unsigned int i=0; i::vector_value (points[i], @@ -509,8 +509,8 @@ template std::size_t ComponentSelectFunction::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } @@ -528,10 +528,10 @@ function_object (function_object) template double ScalarFunctionFromFunctionObject::value (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component == 0, - ExcMessage ("This object represents only scalar functions")); + ExcMessage ("This object represents only scalar functions")); return function_object (p); } diff --git a/deal.II/source/base/function_derivative.cc b/deal.II/source/base/function_derivative.cc index 3e967451a8..eb4959702c 100644 --- a/deal.II/source/base/function_derivative.cc +++ b/deal.II/source/base/function_derivative.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2011 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -22,10 +22,10 @@ DEAL_II_NAMESPACE_OPEN template FunctionDerivative::FunctionDerivative (const Function &f, - const Point &dir, - const double h) - : - AutoDerivativeFunction (h, f.n_components, f.get_time()), + const Point &dir, + const double h) + : + AutoDerivativeFunction (h, f.n_components, f.get_time()), f(f), h(h), incr(1, h*dir) @@ -37,10 +37,10 @@ FunctionDerivative::FunctionDerivative (const Function &f, template FunctionDerivative::FunctionDerivative (const Function& f, - const std::vector >& dir, - const double h) - : - AutoDerivativeFunction (h, f.n_components, f.get_time()), + const std::vector >& dir, + const double h) + : + AutoDerivativeFunction (h, f.n_components, f.get_time()), f(f), h(h), incr(dir.size()) @@ -75,22 +75,22 @@ FunctionDerivative::set_h (const double new_h) template double FunctionDerivative::value (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (incr.size() == 1, - ExcMessage ("FunctionDerivative was not initialized for constant direction")); + ExcMessage ("FunctionDerivative was not initialized for constant direction")); switch (formula) { case AutoDerivativeFunction::Euler: - return (f.value(p+incr[0], component)-f.value(p-incr[0], component))/(2*h); + return (f.value(p+incr[0], component)-f.value(p-incr[0], component))/(2*h); case AutoDerivativeFunction::UpwindEuler: - return (f.value(p, component)-f.value(p-incr[0], component))/h; + return (f.value(p, component)-f.value(p-incr[0], component))/h; case AutoDerivativeFunction::FourthOrder: - return (-f.value(p+2*incr[0], component) + 8*f.value(p+incr[0], component) - -8*f.value(p-incr[0], component) + f.value(p-2*incr[0], component))/(12*h); + return (-f.value(p+2*incr[0], component) + 8*f.value(p+incr[0], component) + -8*f.value(p-incr[0], component) + f.value(p-2*incr[0], component))/(12*h); default: - Assert(false, ExcInvalidFormula()); + Assert(false, ExcInvalidFormula()); } return 0.; } @@ -104,36 +104,36 @@ FunctionDerivative::vector_value ( Vector& result) const { Assert (incr.size() == 1, - ExcMessage ("FunctionDerivative was not initialized for constant direction")); + ExcMessage ("FunctionDerivative was not initialized for constant direction")); Vector aux(result.size()); - // Formulas are the same as in - // value, but here we have to use - // Vector arithmetic + // Formulas are the same as in + // value, but here we have to use + // Vector arithmetic switch (formula) { case AutoDerivativeFunction::Euler: - f.vector_value(p+incr[0], result); - f.vector_value(p-incr[0], aux); - result.sadd(1./(2*h), -1./(2*h), aux); - return; + f.vector_value(p+incr[0], result); + f.vector_value(p-incr[0], aux); + result.sadd(1./(2*h), -1./(2*h), aux); + return; case AutoDerivativeFunction::UpwindEuler: - f.vector_value(p, result); - f.vector_value(p-incr[0], aux); - result.sadd(1./h, -1./h, aux); - return; + f.vector_value(p, result); + f.vector_value(p-incr[0], aux); + result.sadd(1./h, -1./h, aux); + return; case AutoDerivativeFunction::FourthOrder: - f.vector_value(p-2*incr[0], result); - f.vector_value(p+2*incr[0], aux); - result.add(-1., aux); - f.vector_value(p-incr[0], aux); - result.add(-8., aux); - f.vector_value(p+incr[0], aux); - result.add(8., aux); - result.scale(1./(12*h)); - return; + f.vector_value(p-2*incr[0], result); + f.vector_value(p+2*incr[0], aux); + result.add(-1., aux); + f.vector_value(p-incr[0], aux); + result.add(-8., aux); + f.vector_value(p+incr[0], aux); + result.add(8., aux); + result.scale(1./(12*h)); + return; default: - Assert(false, ExcInvalidFormula()); + Assert(false, ExcInvalidFormula()); } } @@ -142,64 +142,64 @@ FunctionDerivative::vector_value ( template void FunctionDerivative::value_list (const std::vector > &points, - std::vector &values, - const unsigned int component) const + std::vector &values, + const unsigned int component) const { const unsigned int n = points.size(); const bool variable_direction = (incr.size() == 1) ? false : true; if (variable_direction) Assert (incr.size() == points.size(), - ExcDimensionMismatch(incr.size(), points.size())); + ExcDimensionMismatch(incr.size(), points.size())); - // Vector of auxiliary values + // Vector of auxiliary values std::vector aux(n); - // Vector of auxiliary points + // Vector of auxiliary points std::vector > paux(n); - // Use the same formulas as in - // value, but with vector - // arithmetic + // Use the same formulas as in + // value, but with vector + // arithmetic switch (formula) { case AutoDerivativeFunction::Euler: - for (unsigned int i=0; i::UpwindEuler: - f.value_list(points, values, component); - for (unsigned int i=0; i::FourthOrder: - for (unsigned int i=0; i std::size_t FunctionDerivative::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } diff --git a/deal.II/source/base/function_lib.cc b/deal.II/source/base/function_lib.cc index 6868b93d67..977b4d2acd 100644 --- a/deal.II/source/base/function_lib.cc +++ b/deal.II/source/base/function_lib.cc @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -25,32 +25,32 @@ DEAL_II_NAMESPACE_OPEN // in strict ANSI C mode, the following constants are not defined by // default, so we do it ourselves #ifndef M_PI -# define M_PI 3.14159265358979323846 +# define M_PI 3.14159265358979323846 #endif #ifndef M_PI_2 -# define M_PI_2 1.57079632679489661923 +# define M_PI_2 1.57079632679489661923 #endif namespace Functions { - - + + template double SquareFunction::value (const Point &p, - const unsigned int) const + const unsigned int) const { return p.square(); } - + template void SquareFunction::vector_value (const Point &p, - Vector &values) const + Vector &values) const { AssertDimension(values.size(), 1); values(0) = p.square(); @@ -60,53 +60,53 @@ namespace Functions template void SquareFunction::value_list (const std::vector > &points, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - values[i] = p.square(); + const Point& p = points[i]; + values[i] = p.square(); } } - - + + template double SquareFunction::laplacian (const Point &, - const unsigned int) const + const unsigned int) const { return 2*dim; } - - + + template void SquareFunction::laplacian_list (const std::vector > &points, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i Tensor<1,dim> SquareFunction::gradient (const Point &p, - const unsigned int) const + const unsigned int) const { return p*2.; } - - + + template void SquareFunction::vector_gradient ( @@ -118,53 +118,53 @@ namespace Functions } - + template void SquareFunction::gradient_list (const std::vector > &points, - std::vector > &gradients, - const unsigned int) const + std::vector > &gradients, + const unsigned int) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - + ExcDimensionMismatch(gradients.size(), points.size())); + for (unsigned int i=0; i double Q1WedgeFunction::value (const Point &p, - const unsigned int) const + const unsigned int) const { Assert (dim>=2, ExcInternalError()); return p(0)*p(1); } - - - + + + template void Q1WedgeFunction::value_list (const std::vector > &points, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (dim>=2, ExcInternalError()); Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - values[i] = p(0)*p(1); + const Point& p = points[i]; + values[i] = p(0)*p(1); } } - - + + template void Q1WedgeFunction::vector_value_list ( @@ -173,47 +173,47 @@ namespace Functions { Assert (dim>=2, ExcInternalError()); Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); Assert(values[0].size() == 1, ExcDimensionMismatch(values[0].size(), 1)); - + for (unsigned int i=0;i& p = points[i]; - values[i](0) = p(0)*p(1); + const Point& p = points[i]; + values[i](0) = p(0)*p(1); } } - - + + template double Q1WedgeFunction::laplacian (const Point &, - const unsigned int) const + const unsigned int) const { Assert (dim>=2, ExcInternalError()); return 0.; } - - + + template void Q1WedgeFunction::laplacian_list (const std::vector > &points, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (dim>=2, ExcInternalError()); Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i Tensor<1,dim> Q1WedgeFunction::gradient (const Point &p, - const unsigned int) const + const unsigned int) const { Assert (dim>=2, ExcInternalError()); Tensor<1,dim> erg; @@ -221,27 +221,27 @@ namespace Functions erg[1] = p(0); return erg; } - - - + + + template void Q1WedgeFunction::gradient_list (const std::vector > &points, - std::vector > &gradients, - const unsigned int) const + std::vector > &gradients, + const unsigned int) const { Assert (dim>=2, ExcInternalError()); Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - + ExcDimensionMismatch(gradients.size(), points.size())); + for (unsigned int i=0; i void Q1WedgeFunction::vector_gradient_list ( @@ -250,194 +250,194 @@ namespace Functions { Assert (dim>=2, ExcInternalError()); Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); + ExcDimensionMismatch(gradients.size(), points.size())); Assert(gradients[0].size() == 1, - ExcDimensionMismatch(gradients[0].size(), 1)); - + ExcDimensionMismatch(gradients[0].size(), 1)); + for (unsigned int i=0; i PillowFunction::PillowFunction (const double offset) - : - offset(offset) + : + offset(offset) {} - - + + template double PillowFunction::value (const Point &p, - const unsigned int) const + const unsigned int) const { switch(dim) { - case 1: - return 1.-p(0)*p(0)+offset; - case 2: - return (1.-p(0)*p(0))*(1.-p(1)*p(1))+offset; - case 3: - return (1.-p(0)*p(0))*(1.-p(1)*p(1))*(1.-p(2)*p(2))+offset; - default: - Assert(false, ExcNotImplemented()); + case 1: + return 1.-p(0)*p(0)+offset; + case 2: + return (1.-p(0)*p(0))*(1.-p(1)*p(1))+offset; + case 3: + return (1.-p(0)*p(0))*(1.-p(1)*p(1))*(1.-p(2)*p(2))+offset; + default: + Assert(false, ExcNotImplemented()); } return 0.; } - + template void PillowFunction::value_list (const std::vector > &points, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - values[i] = 1.-p(0)*p(0)+offset; - break; - case 2: - values[i] = (1.-p(0)*p(0))*(1.-p(1)*p(1))+offset; - break; - case 3: - values[i] = (1.-p(0)*p(0))*(1.-p(1)*p(1))*(1.-p(2)*p(2))+offset; - break; - default: - Assert(false, ExcNotImplemented()); - } + const Point& p = points[i]; + switch(dim) + { + case 1: + values[i] = 1.-p(0)*p(0)+offset; + break; + case 2: + values[i] = (1.-p(0)*p(0))*(1.-p(1)*p(1))+offset; + break; + case 3: + values[i] = (1.-p(0)*p(0))*(1.-p(1)*p(1))*(1.-p(2)*p(2))+offset; + break; + default: + Assert(false, ExcNotImplemented()); + } } } - - - + + + template double PillowFunction::laplacian (const Point &p, - const unsigned int) const + const unsigned int) const { switch(dim) { - case 1: - return -2.; - case 2: - return -2.*((1.-p(0)*p(0))+(1.-p(1)*p(1))); - case 3: - return -2.*((1.-p(0)*p(0))*(1.-p(1)*p(1)) - +(1.-p(1)*p(1))*(1.-p(2)*p(2)) - +(1.-p(2)*p(2))*(1.-p(0)*p(0))); - default: - Assert(false, ExcNotImplemented()); + case 1: + return -2.; + case 2: + return -2.*((1.-p(0)*p(0))+(1.-p(1)*p(1))); + case 3: + return -2.*((1.-p(0)*p(0))*(1.-p(1)*p(1)) + +(1.-p(1)*p(1))*(1.-p(2)*p(2)) + +(1.-p(2)*p(2))*(1.-p(0)*p(0))); + default: + Assert(false, ExcNotImplemented()); } return 0.; } - + template void PillowFunction::laplacian_list (const std::vector > &points, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - values[i] = -2.; - break; - case 2: - values[i] = -2.*((1.-p(0)*p(0))+(1.-p(1)*p(1))); - break; - case 3: - values[i] = -2.*((1.-p(0)*p(0))*(1.-p(1)*p(1)) - +(1.-p(1)*p(1))*(1.-p(2)*p(2)) - +(1.-p(2)*p(2))*(1.-p(0)*p(0))); - break; - default: - Assert(false, ExcNotImplemented()); - } + const Point& p = points[i]; + switch(dim) + { + case 1: + values[i] = -2.; + break; + case 2: + values[i] = -2.*((1.-p(0)*p(0))+(1.-p(1)*p(1))); + break; + case 3: + values[i] = -2.*((1.-p(0)*p(0))*(1.-p(1)*p(1)) + +(1.-p(1)*p(1))*(1.-p(2)*p(2)) + +(1.-p(2)*p(2))*(1.-p(0)*p(0))); + break; + default: + Assert(false, ExcNotImplemented()); + } } } - + template Tensor<1,dim> PillowFunction::gradient (const Point &p, - const unsigned int) const + const unsigned int) const { Tensor<1,dim> result; switch(dim) { - case 1: - result[0] = -2.*p(0); - break; - case 2: - result[0] = -2.*p(0)*(1.-p(1)*p(1)); - result[1] = -2.*p(1)*(1.-p(0)*p(0)); - break; - case 3: - result[0] = -2.*p(0)*(1.-p(1)*p(1))*(1.-p(2)*p(2)); - result[1] = -2.*p(1)*(1.-p(0)*p(0))*(1.-p(2)*p(2)); - result[2] = -2.*p(2)*(1.-p(0)*p(0))*(1.-p(1)*p(1)); - break; - default: - Assert(false, ExcNotImplemented()); + case 1: + result[0] = -2.*p(0); + break; + case 2: + result[0] = -2.*p(0)*(1.-p(1)*p(1)); + result[1] = -2.*p(1)*(1.-p(0)*p(0)); + break; + case 3: + result[0] = -2.*p(0)*(1.-p(1)*p(1))*(1.-p(2)*p(2)); + result[1] = -2.*p(1)*(1.-p(0)*p(0))*(1.-p(2)*p(2)); + result[2] = -2.*p(2)*(1.-p(0)*p(0))*(1.-p(1)*p(1)); + break; + default: + Assert(false, ExcNotImplemented()); } return result; } - + template void PillowFunction::gradient_list (const std::vector > &points, - std::vector > &gradients, - const unsigned int) const + std::vector > &gradients, + const unsigned int) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - + ExcDimensionMismatch(gradients.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - gradients[i][0] = -2.*p(0); - break; - case 2: - gradients[i][0] = -2.*p(0)*(1.-p(1)*p(1)); - gradients[i][1] = -2.*p(1)*(1.-p(0)*p(0)); - break; - case 3: - gradients[i][0] = -2.*p(0)*(1.-p(1)*p(1))*(1.-p(2)*p(2)); - gradients[i][1] = -2.*p(1)*(1.-p(0)*p(0))*(1.-p(2)*p(2)); - gradients[i][2] = -2.*p(2)*(1.-p(0)*p(0))*(1.-p(1)*p(1)); - break; - default: - Assert(false, ExcNotImplemented()); - } + const Point& p = points[i]; + switch(dim) + { + case 1: + gradients[i][0] = -2.*p(0); + break; + case 2: + gradients[i][0] = -2.*p(0)*(1.-p(1)*p(1)); + gradients[i][1] = -2.*p(1)*(1.-p(0)*p(0)); + break; + case 3: + gradients[i][0] = -2.*p(0)*(1.-p(1)*p(1))*(1.-p(2)*p(2)); + gradients[i][1] = -2.*p(1)*(1.-p(0)*p(0))*(1.-p(2)*p(2)); + gradients[i][2] = -2.*p(2)*(1.-p(0)*p(0))*(1.-p(1)*p(1)); + break; + default: + Assert(false, ExcNotImplemented()); + } } } - + ////////////////////////////////////////////////////////////////////// template CosineFunction::CosineFunction (const unsigned int n_components) - : - Function (n_components) + : + Function (n_components) {} @@ -445,36 +445,36 @@ namespace Functions template double CosineFunction::value (const Point &p, - const unsigned int) const + const unsigned int) const { switch(dim) { - case 1: - return std::cos(M_PI_2*p(0)); - case 2: - return std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - case 3: - return std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - default: - Assert(false, ExcNotImplemented()); + case 1: + return std::cos(M_PI_2*p(0)); + case 2: + return std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + case 3: + return std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + default: + Assert(false, ExcNotImplemented()); } return 0.; } - + template void CosineFunction::value_list (const std::vector > &points, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i void CosineFunction::vector_value_list ( @@ -482,220 +482,220 @@ namespace Functions std::vector > &values) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i double CosineFunction::laplacian (const Point &p, - const unsigned int) const + const unsigned int) const { switch(dim) { - case 1: - return -M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)); - case 2: - return -2*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - case 3: - return -3*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - default: - Assert(false, ExcNotImplemented()); + case 1: + return -M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)); + case 2: + return -2*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + case 3: + return -3*M_PI_2*M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + default: + Assert(false, ExcNotImplemented()); } return 0.; } - + template void CosineFunction::laplacian_list (const std::vector > &points, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i Tensor<1,dim> CosineFunction::gradient (const Point &p, - const unsigned int) const + const unsigned int) const { Tensor<1,dim> result; switch(dim) { - case 1: - result[0] = -M_PI_2* std::sin(M_PI_2*p(0)); - break; - case 2: - result[0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - result[1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); - break; - case 3: - result[0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - result[1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - result[2] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - break; - default: - Assert(false, ExcNotImplemented()); + case 1: + result[0] = -M_PI_2* std::sin(M_PI_2*p(0)); + break; + case 2: + result[0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + result[1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); + break; + case 3: + result[0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + result[1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + result[2] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + break; + default: + Assert(false, ExcNotImplemented()); } return result; } - + template void CosineFunction::gradient_list (const std::vector > &points, - std::vector > &gradients, - const unsigned int) const + std::vector > &gradients, + const unsigned int) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - + ExcDimensionMismatch(gradients.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - gradients[i][0] = -M_PI_2* std::sin(M_PI_2*p(0)); - break; - case 2: - gradients[i][0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - gradients[i][1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); - break; - case 3: - gradients[i][0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - gradients[i][1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - gradients[i][2] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - break; - default: - Assert(false, ExcNotImplemented()); - } + const Point& p = points[i]; + switch(dim) + { + case 1: + gradients[i][0] = -M_PI_2* std::sin(M_PI_2*p(0)); + break; + case 2: + gradients[i][0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + gradients[i][1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); + break; + case 3: + gradients[i][0] = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + gradients[i][1] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + gradients[i][2] = -M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + break; + default: + Assert(false, ExcNotImplemented()); + } } } - + template Tensor<2,dim> CosineFunction::hessian (const Point &p, - const unsigned int) const + const unsigned int) const { const double pi2 = M_PI_2*M_PI_2; - + Tensor<2,dim> result; switch(dim) { - case 1: - result[0][0] = -pi2* std::cos(M_PI_2*p(0)); - break; - case 2: - if (true) - { - const double coco = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - const double sisi = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); - result[0][0] = coco; - result[1][1] = coco; - result[0][1] = sisi; - result[1][0] = sisi; - } - break; - case 3: - if (true) - { - const double cococo = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - const double sisico = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - const double sicosi = pi2*std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - const double cosisi = pi2*std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - - result[0][0] = cococo; - result[1][1] = cococo; - result[2][2] = cococo; - result[0][1] = sisico; - result[1][0] = sisico; - result[0][2] = sicosi; - result[2][0] = sicosi; - result[1][2] = cosisi; - result[2][1] = cosisi; - } - break; - default: - Assert(false, ExcNotImplemented()); + case 1: + result[0][0] = -pi2* std::cos(M_PI_2*p(0)); + break; + case 2: + if (true) + { + const double coco = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + const double sisi = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); + result[0][0] = coco; + result[1][1] = coco; + result[0][1] = sisi; + result[1][0] = sisi; + } + break; + case 3: + if (true) + { + const double cococo = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + const double sisico = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + const double sicosi = pi2*std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + const double cosisi = pi2*std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + + result[0][0] = cococo; + result[1][1] = cococo; + result[2][2] = cococo; + result[0][1] = sisico; + result[1][0] = sisico; + result[0][2] = sicosi; + result[2][0] = sicosi; + result[1][2] = cosisi; + result[2][1] = cosisi; + } + break; + default: + Assert(false, ExcNotImplemented()); } return result; } - + template void CosineFunction::hessian_list (const std::vector > &points, - std::vector > &hessians, - const unsigned int) const + std::vector > &hessians, + const unsigned int) const { Assert (hessians.size() == points.size(), - ExcDimensionMismatch(hessians.size(), points.size())); - + ExcDimensionMismatch(hessians.size(), points.size())); + const double pi2 = M_PI_2*M_PI_2; - + for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - hessians[i][0][0] = -pi2* std::cos(M_PI_2*p(0)); - break; - case 2: - if (true) - { - const double coco = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - const double sisi = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); - hessians[i][0][0] = coco; - hessians[i][1][1] = coco; - hessians[i][0][1] = sisi; - hessians[i][1][0] = sisi; - } - break; - case 3: - if (true) - { - const double cococo = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - const double sisico = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - const double sicosi = pi2*std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - const double cosisi = pi2*std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - - hessians[i][0][0] = cococo; - hessians[i][1][1] = cococo; - hessians[i][2][2] = cococo; - hessians[i][0][1] = sisico; - hessians[i][1][0] = sisico; - hessians[i][0][2] = sicosi; - hessians[i][2][0] = sicosi; - hessians[i][1][2] = cosisi; - hessians[i][2][1] = cosisi; - } - break; - default: - Assert(false, ExcNotImplemented()); - } + const Point& p = points[i]; + switch(dim) + { + case 1: + hessians[i][0][0] = -pi2* std::cos(M_PI_2*p(0)); + break; + case 2: + if (true) + { + const double coco = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + const double sisi = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); + hessians[i][0][0] = coco; + hessians[i][1][1] = coco; + hessians[i][0][1] = sisi; + hessians[i][1][0] = sisi; + } + break; + case 3: + if (true) + { + const double cococo = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + const double sisico = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + const double sicosi = pi2*std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + const double cosisi = pi2*std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + + hessians[i][0][0] = cococo; + hessians[i][1][1] = cococo; + hessians[i][2][2] = cococo; + hessians[i][0][1] = sisico; + hessians[i][1][0] = sisico; + hessians[i][0][2] = sicosi; + hessians[i][2][0] = sicosi; + hessians[i][1][2] = cosisi; + hessians[i][2][1] = cosisi; + } + break; + default: + Assert(false, ExcNotImplemented()); + } } } - + ////////////////////////////////////////////////////////////////////// - + template CosineGradFunction::CosineGradFunction () - : - Function (dim) + : + Function (dim) {} - - + + template double CosineGradFunction::value ( @@ -707,19 +707,19 @@ namespace Functions const unsigned int d2 = (d+2) % dim; switch(dim) { - case 1: - return (-M_PI_2* std::sin(M_PI_2*p(0))); - case 2: - return (-M_PI_2* std::sin(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1))); - case 3: - return (-M_PI_2* std::sin(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)) * std::cos(M_PI_2*p(d2))); - default: - Assert(false, ExcNotImplemented()); + case 1: + return (-M_PI_2* std::sin(M_PI_2*p(0))); + case 2: + return (-M_PI_2* std::sin(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1))); + case 3: + return (-M_PI_2* std::sin(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)) * std::cos(M_PI_2*p(d2))); + default: + Assert(false, ExcNotImplemented()); } return 0.; } - + template void CosineGradFunction::vector_value ( @@ -729,23 +729,23 @@ namespace Functions AssertDimension(result.size(), dim); switch(dim) { - case 1: - result(0) = -M_PI_2* std::sin(M_PI_2*p(0)); - break; - case 2: - result(0) = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - result(1) = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); - break; - case 3: - result(0) = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - result(1) = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - result(2) = -M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - break; - default: - Assert(false, ExcNotImplemented()); + case 1: + result(0) = -M_PI_2* std::sin(M_PI_2*p(0)); + break; + case 2: + result(0) = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + result(1) = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); + break; + case 3: + result(0) = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + result(1) = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + result(2) = -M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + break; + default: + Assert(false, ExcNotImplemented()); } } - + template void @@ -755,32 +755,32 @@ namespace Functions const unsigned int d) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); AssertIndexRange(d, dim); const unsigned int d1 = (d+1) % dim; const unsigned int d2 = (d+2) % dim; - + for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - values[i] = -M_PI_2* std::sin(M_PI_2*p(d)); - break; - case 2: - values[i] = -M_PI_2* std::sin(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)); - break; - case 3: - values[i] = -M_PI_2* std::sin(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)) * std::cos(M_PI_2*p(d2)); - break; - default: - Assert(false, ExcNotImplemented()); - } + const Point& p = points[i]; + switch(dim) + { + case 1: + values[i] = -M_PI_2* std::sin(M_PI_2*p(d)); + break; + case 2: + values[i] = -M_PI_2* std::sin(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)); + break; + case 3: + values[i] = -M_PI_2* std::sin(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)) * std::cos(M_PI_2*p(d2)); + break; + default: + Assert(false, ExcNotImplemented()); + } } } - - + + template void CosineGradFunction::vector_value_list ( @@ -788,32 +788,32 @@ namespace Functions std::vector > &values) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - values[i](0) = -M_PI_2* std::sin(M_PI_2*p(0)); - break; - case 2: - values[i](0) = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - values[i](1) = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); - break; - case 3: - values[i](0) = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - values[i](1) = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - values[i](2) = -M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - break; - default: - Assert(false, ExcNotImplemented()); - } + const Point& p = points[i]; + switch(dim) + { + case 1: + values[i](0) = -M_PI_2* std::sin(M_PI_2*p(0)); + break; + case 2: + values[i](0) = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + values[i](1) = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); + break; + case 3: + values[i](0) = -M_PI_2* std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + values[i](1) = -M_PI_2* std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + values[i](2) = -M_PI_2* std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + break; + default: + Assert(false, ExcNotImplemented()); + } } } - - + + template double CosineGradFunction::laplacian ( @@ -834,29 +834,29 @@ namespace Functions const unsigned int d1 = (d+1) % dim; const unsigned int d2 = (d+2) % dim; const double pi2 = M_PI_2*M_PI_2; - + Tensor<1,dim> result; switch(dim) { - case 1: - result[0] = -pi2* std::cos(M_PI_2*p(0)); - break; - case 2: - result[d ] = -pi2*std::cos(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)); - result[d1] = pi2*std::sin(M_PI_2*p(d)) * std::sin(M_PI_2*p(d1)); - break; - case 3: - result[d ] = -pi2*std::cos(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)) * std::cos(M_PI_2*p(d2)); - result[d1] = pi2*std::sin(M_PI_2*p(d)) * std::sin(M_PI_2*p(d1)) * std::cos(M_PI_2*p(d2)); - result[d2] = pi2*std::sin(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)) * std::sin(M_PI_2*p(d2)); - break; - default: - Assert(false, ExcNotImplemented()); + case 1: + result[0] = -pi2* std::cos(M_PI_2*p(0)); + break; + case 2: + result[d ] = -pi2*std::cos(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)); + result[d1] = pi2*std::sin(M_PI_2*p(d)) * std::sin(M_PI_2*p(d1)); + break; + case 3: + result[d ] = -pi2*std::cos(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)) * std::cos(M_PI_2*p(d2)); + result[d1] = pi2*std::sin(M_PI_2*p(d)) * std::sin(M_PI_2*p(d1)) * std::cos(M_PI_2*p(d2)); + result[d2] = pi2*std::sin(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)) * std::sin(M_PI_2*p(d2)); + break; + default: + Assert(false, ExcNotImplemented()); } return result; } - + template void CosineGradFunction::gradient_list ( @@ -868,428 +868,428 @@ namespace Functions const unsigned int d1 = (d+1) % dim; const unsigned int d2 = (d+2) % dim; const double pi2 = M_PI_2*M_PI_2; - + Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); + ExcDimensionMismatch(gradients.size(), points.size())); for (unsigned int i=0;i& p = points[i]; - Tensor<1,dim>& result = gradients[i]; - - switch(dim) - { - case 1: - result[0] = -pi2* std::cos(M_PI_2*p(0)); - break; - case 2: - result[d ] = -pi2*std::cos(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)); - result[d1] = pi2*std::sin(M_PI_2*p(d)) * std::sin(M_PI_2*p(d1)); - break; - case 3: - result[d ] = -pi2*std::cos(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)) * std::cos(M_PI_2*p(d2)); - result[d1] = pi2*std::sin(M_PI_2*p(d)) * std::sin(M_PI_2*p(d1)) * std::cos(M_PI_2*p(d2)); - result[d2] = pi2*std::sin(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)) * std::sin(M_PI_2*p(d2)); - break; - default: - Assert(false, ExcNotImplemented()); - } + const Point& p = points[i]; + Tensor<1,dim>& result = gradients[i]; + + switch(dim) + { + case 1: + result[0] = -pi2* std::cos(M_PI_2*p(0)); + break; + case 2: + result[d ] = -pi2*std::cos(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)); + result[d1] = pi2*std::sin(M_PI_2*p(d)) * std::sin(M_PI_2*p(d1)); + break; + case 3: + result[d ] = -pi2*std::cos(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)) * std::cos(M_PI_2*p(d2)); + result[d1] = pi2*std::sin(M_PI_2*p(d)) * std::sin(M_PI_2*p(d1)) * std::cos(M_PI_2*p(d2)); + result[d2] = pi2*std::sin(M_PI_2*p(d)) * std::cos(M_PI_2*p(d1)) * std::sin(M_PI_2*p(d2)); + break; + default: + Assert(false, ExcNotImplemented()); + } } } - - + + template void CosineGradFunction::vector_gradient_list ( const std::vector > &points, std::vector > >& gradients) const { - AssertVectorVectorDimension(gradients, points.size(), dim); + AssertVectorVectorDimension(gradients, points.size(), dim); const double pi2 = M_PI_2*M_PI_2; - + for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - gradients[i][0][0] = -pi2* std::cos(M_PI_2*p(0)); - break; - case 2: - if (true) - { - const double coco = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); - const double sisi = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); - gradients[i][0][0] = coco; - gradients[i][1][1] = coco; - gradients[i][0][1] = sisi; - gradients[i][1][0] = sisi; - } - break; - case 3: - if (true) - { - const double cococo = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - const double sisico = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); - const double sicosi = pi2*std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - const double cosisi = pi2*std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); - - gradients[i][0][0] = cococo; - gradients[i][1][1] = cococo; - gradients[i][2][2] = cococo; - gradients[i][0][1] = sisico; - gradients[i][1][0] = sisico; - gradients[i][0][2] = sicosi; - gradients[i][2][0] = sicosi; - gradients[i][1][2] = cosisi; - gradients[i][2][1] = cosisi; - } - break; - default: - Assert(false, ExcNotImplemented()); - } + const Point& p = points[i]; + switch(dim) + { + case 1: + gradients[i][0][0] = -pi2* std::cos(M_PI_2*p(0)); + break; + case 2: + if (true) + { + const double coco = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)); + const double sisi = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)); + gradients[i][0][0] = coco; + gradients[i][1][1] = coco; + gradients[i][0][1] = sisi; + gradients[i][1][0] = sisi; + } + break; + case 3: + if (true) + { + const double cococo = -pi2*std::cos(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + const double sisico = pi2*std::sin(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::cos(M_PI_2*p(2)); + const double sicosi = pi2*std::sin(M_PI_2*p(0)) * std::cos(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + const double cosisi = pi2*std::cos(M_PI_2*p(0)) * std::sin(M_PI_2*p(1)) * std::sin(M_PI_2*p(2)); + + gradients[i][0][0] = cococo; + gradients[i][1][1] = cococo; + gradients[i][2][2] = cococo; + gradients[i][0][1] = sisico; + gradients[i][1][0] = sisico; + gradients[i][0][2] = sicosi; + gradients[i][2][0] = sicosi; + gradients[i][1][2] = cosisi; + gradients[i][2][1] = cosisi; + } + break; + default: + Assert(false, ExcNotImplemented()); + } } } - - + + ////////////////////////////////////////////////////////////////////// - + template double ExpFunction::value (const Point &p, - const unsigned int) const + const unsigned int) const { switch(dim) { - case 1: - return std::exp(p(0)); - case 2: - return std::exp(p(0)) * std::exp(p(1)); - case 3: - return std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - default: - Assert(false, ExcNotImplemented()); + case 1: + return std::exp(p(0)); + case 2: + return std::exp(p(0)) * std::exp(p(1)); + case 3: + return std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + default: + Assert(false, ExcNotImplemented()); } return 0.; } - + template void ExpFunction::value_list (const std::vector > &points, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - values[i] = std::exp(p(0)); - break; - case 2: - values[i] = std::exp(p(0)) * std::exp(p(1)); - break; - case 3: - values[i] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - break; - default: - Assert(false, ExcNotImplemented()); - } + const Point& p = points[i]; + switch(dim) + { + case 1: + values[i] = std::exp(p(0)); + break; + case 2: + values[i] = std::exp(p(0)) * std::exp(p(1)); + break; + case 3: + values[i] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + break; + default: + Assert(false, ExcNotImplemented()); + } } } - + template double ExpFunction::laplacian (const Point &p, - const unsigned int) const + const unsigned int) const { switch(dim) { - case 1: - return std::exp(p(0)); - case 2: - return 2 * std::exp(p(0)) * std::exp(p(1)); - case 3: - return 3 * std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - default: - Assert(false, ExcNotImplemented()); + case 1: + return std::exp(p(0)); + case 2: + return 2 * std::exp(p(0)) * std::exp(p(1)); + case 3: + return 3 * std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + default: + Assert(false, ExcNotImplemented()); } return 0.; } - + template void ExpFunction::laplacian_list (const std::vector > &points, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - values[i] = std::exp(p(0)); - break; - case 2: - values[i] = 2 * std::exp(p(0)) * std::exp(p(1)); - break; - case 3: - values[i] = 3 * std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - break; - default: - Assert(false, ExcNotImplemented()); - } + const Point& p = points[i]; + switch(dim) + { + case 1: + values[i] = std::exp(p(0)); + break; + case 2: + values[i] = 2 * std::exp(p(0)) * std::exp(p(1)); + break; + case 3: + values[i] = 3 * std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + break; + default: + Assert(false, ExcNotImplemented()); + } } } - + template Tensor<1,dim> ExpFunction::gradient (const Point &p, - const unsigned int) const + const unsigned int) const { Tensor<1,dim> result; switch(dim) { - case 1: - result[0] = std::exp(p(0)); - break; - case 2: - result[0] = std::exp(p(0)) * std::exp(p(1)); - result[1] = std::exp(p(0)) * std::exp(p(1)); - break; - case 3: - result[0] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - result[1] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - result[2] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - break; - default: - Assert(false, ExcNotImplemented()); + case 1: + result[0] = std::exp(p(0)); + break; + case 2: + result[0] = std::exp(p(0)) * std::exp(p(1)); + result[1] = std::exp(p(0)) * std::exp(p(1)); + break; + case 3: + result[0] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + result[1] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + result[2] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + break; + default: + Assert(false, ExcNotImplemented()); } return result; } - + template void ExpFunction::gradient_list (const std::vector > &points, - std::vector > &gradients, - const unsigned int) const + std::vector > &gradients, + const unsigned int) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - + ExcDimensionMismatch(gradients.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - switch(dim) - { - case 1: - gradients[i][0] = std::exp(p(0)); - break; - case 2: - gradients[i][0] = std::exp(p(0)) * std::exp(p(1)); - gradients[i][1] = std::exp(p(0)) * std::exp(p(1)); - break; - case 3: - gradients[i][0] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - gradients[i][1] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - gradients[i][2] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); - break; - default: - Assert(false, ExcNotImplemented()); - } + const Point& p = points[i]; + switch(dim) + { + case 1: + gradients[i][0] = std::exp(p(0)); + break; + case 2: + gradients[i][0] = std::exp(p(0)) * std::exp(p(1)); + gradients[i][1] = std::exp(p(0)) * std::exp(p(1)); + break; + case 3: + gradients[i][0] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + gradients[i][1] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + gradients[i][2] = std::exp(p(0)) * std::exp(p(1)) * std::exp(p(2)); + break; + default: + Assert(false, ExcNotImplemented()); + } } } - + ////////////////////////////////////////////////////////////////////// - - + + double LSingularityFunction::value (const Point<2> &p, - const unsigned int) const + const unsigned int) const { double x = p(0); double y = p(1); - + if ((x>=0) && (y>=0)) return 0.; - + double phi = std::atan2(y,-x)+M_PI; double r2 = x*x+y*y; - + return std::pow(r2,1./3.) * std::sin(2./3.*phi); } - - + + void LSingularityFunction::value_list (const std::vector > &points, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i=0) && (y>=0)) - values[i] = 0.; - else - { - double phi = std::atan2(y,-x)+M_PI; - double r2 = x*x+y*y; - - values[i] = std::pow(r2,1./3.) * std::sin(2./3.*phi); - } + double x = points[i](0); + double y = points[i](1); + + if ((x>=0) && (y>=0)) + values[i] = 0.; + else + { + double phi = std::atan2(y,-x)+M_PI; + double r2 = x*x+y*y; + + values[i] = std::pow(r2,1./3.) * std::sin(2./3.*phi); + } } } - - + + void LSingularityFunction::vector_value_list ( const std::vector >& points, std::vector >& values) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i=0) && (y>=0)) - values[i](0) = 0.; - else - { - double phi = std::atan2(y,-x)+M_PI; - double r2 = x*x+y*y; - - values[i](0) = std::pow(r2,1./3.) * std::sin(2./3.*phi); - } + Assert (values[i].size() == 1, + ExcDimensionMismatch(values[i].size(), 1)); + double x = points[i](0); + double y = points[i](1); + + if ((x>=0) && (y>=0)) + values[i](0) = 0.; + else + { + double phi = std::atan2(y,-x)+M_PI; + double r2 = x*x+y*y; + + values[i](0) = std::pow(r2,1./3.) * std::sin(2./3.*phi); + } } } - - + + double LSingularityFunction::laplacian (const Point<2> &, - const unsigned int) const + const unsigned int) const { return 0.; } - - + + void LSingularityFunction::laplacian_list (const std::vector > &points, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i LSingularityFunction::gradient (const Point<2> &p, - const unsigned int) const + const unsigned int) const { double x = p(0); double y = p(1); double phi = std::atan2(y,-x)+M_PI; double r43 = std::pow(x*x+y*y,2./3.); - + Tensor<1,2> result; result[0] = 2./3.*(std::sin(2./3.*phi)*x + std::cos(2./3.*phi)*y)/r43; result[1] = 2./3.*(std::sin(2./3.*phi)*y - std::cos(2./3.*phi)*x)/r43; return result; } - - + + void LSingularityFunction::gradient_list (const std::vector > &points, - std::vector > &gradients, - const unsigned int) const + std::vector > &gradients, + const unsigned int) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - + ExcDimensionMismatch(gradients.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - double x = p(0); - double y = p(1); - double phi = std::atan2(y,-x)+M_PI; - double r43 = std::pow(x*x+y*y,2./3.); - - gradients[i][0] = 2./3.*(std::sin(2./3.*phi)*x + std::cos(2./3.*phi)*y)/r43; - gradients[i][1] = 2./3.*(std::sin(2./3.*phi)*y - std::cos(2./3.*phi)*x)/r43; + const Point<2>& p = points[i]; + double x = p(0); + double y = p(1); + double phi = std::atan2(y,-x)+M_PI; + double r43 = std::pow(x*x+y*y,2./3.); + + gradients[i][0] = 2./3.*(std::sin(2./3.*phi)*x + std::cos(2./3.*phi)*y)/r43; + gradients[i][1] = 2./3.*(std::sin(2./3.*phi)*y - std::cos(2./3.*phi)*x)/r43; } } - - + + void LSingularityFunction::vector_gradient_list ( const std::vector >& points, std::vector > >& gradients) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - + ExcDimensionMismatch(gradients.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - double x = p(0); - double y = p(1); - double phi = std::atan2(y,-x)+M_PI; - double r43 = std::pow(x*x+y*y,2./3.); - - gradients[i][0][0] = 2./3.*(std::sin(2./3.*phi)*x + std::cos(2./3.*phi)*y)/r43; - gradients[i][0][1] = 2./3.*(std::sin(2./3.*phi)*y - std::cos(2./3.*phi)*x)/r43; + Assert(gradients[i].size() == 1, + ExcDimensionMismatch(gradients[i].size(), 1)); + const Point<2>& p = points[i]; + double x = p(0); + double y = p(1); + double phi = std::atan2(y,-x)+M_PI; + double r43 = std::pow(x*x+y*y,2./3.); + + gradients[i][0][0] = 2./3.*(std::sin(2./3.*phi)*x + std::cos(2./3.*phi)*y)/r43; + gradients[i][0][1] = 2./3.*(std::sin(2./3.*phi)*y - std::cos(2./3.*phi)*x)/r43; } } - + ////////////////////////////////////////////////////////////////////// - + LSingularityGradFunction::LSingularityGradFunction () - : - Function<2> (2) + : + Function<2> (2) {} - + double LSingularityGradFunction::value (const Point<2> &p, - const unsigned int d) const + const unsigned int d) const { AssertIndexRange(d,2); - + const double x = p(0); const double y = p(1); const double phi = std::atan2(y,-x)+M_PI; const double r43 = std::pow(x*x+y*y,2./3.); return 2./3.*(std::sin(2./3.*phi)*p(d) + - (d==0 - ? (std::cos(2./3.*phi)*y) - : (-std::cos(2./3.*phi)*x))) + (d==0 + ? (std::cos(2./3.*phi)*y) + : (-std::cos(2./3.*phi)*x))) /r43; } - - + + void LSingularityGradFunction::value_list ( const std::vector >& points, @@ -1298,69 +1298,69 @@ namespace Functions { AssertIndexRange(d, 2); AssertDimension(values.size(), points.size()); - + for (unsigned int i=0;i& p = points[i]; - const double x = p(0); - const double y = p(1); - const double phi = std::atan2(y,-x)+M_PI; - const double r43 = std::pow(x*x+y*y,2./3.); - - values[i] = 2./3.*(std::sin(2./3.*phi)*p(d) + - (d==0 - ? (std::cos(2./3.*phi)*y) - : (-std::cos(2./3.*phi)*x))) - /r43; + const Point<2>& p = points[i]; + const double x = p(0); + const double y = p(1); + const double phi = std::atan2(y,-x)+M_PI; + const double r43 = std::pow(x*x+y*y,2./3.); + + values[i] = 2./3.*(std::sin(2./3.*phi)*p(d) + + (d==0 + ? (std::cos(2./3.*phi)*y) + : (-std::cos(2./3.*phi)*x))) + /r43; } } - - + + void LSingularityGradFunction::vector_value_list ( const std::vector >& points, std::vector >& values) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - const double x = p(0); - const double y = p(1); - const double phi = std::atan2(y,-x)+M_PI; - const double r43 = std::pow(x*x+y*y,2./3.); - - values[i](0) = 2./3.*(std::sin(2./3.*phi)*x + std::cos(2./3.*phi)*y)/r43; - values[i](1) = 2./3.*(std::sin(2./3.*phi)*y - std::cos(2./3.*phi)*x)/r43; + AssertDimension(values[i].size(), 2); + const Point<2>& p = points[i]; + const double x = p(0); + const double y = p(1); + const double phi = std::atan2(y,-x)+M_PI; + const double r43 = std::pow(x*x+y*y,2./3.); + + values[i](0) = 2./3.*(std::sin(2./3.*phi)*x + std::cos(2./3.*phi)*y)/r43; + values[i](1) = 2./3.*(std::sin(2./3.*phi)*y - std::cos(2./3.*phi)*x)/r43; } } - - + + double LSingularityGradFunction::laplacian (const Point<2> &, - const unsigned int) const + const unsigned int) const { return 0.; } - - + + void LSingularityGradFunction::laplacian_list (const std::vector > &points, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i LSingularityGradFunction::gradient ( const Point<2> &/*p*/, @@ -1369,8 +1369,8 @@ namespace Functions Assert(false, ExcNotImplemented()); return Tensor<1,2>(); } - - + + void LSingularityGradFunction::gradient_list ( const std::vector >& /*points*/, @@ -1379,8 +1379,8 @@ namespace Functions { Assert(false, ExcNotImplemented()); } - - + + void LSingularityGradFunction::vector_gradient_list ( const std::vector >& /*points*/, @@ -1388,9 +1388,9 @@ namespace Functions { Assert(false, ExcNotImplemented()); } - + ////////////////////////////////////////////////////////////////////// - + template double SlitSingularityFunction::value ( @@ -1399,14 +1399,14 @@ namespace Functions { double x = p(0); double y = p(1); - + double phi = std::atan2(x,y)+M_PI; double r2 = x*x+y*y; - + return std::pow(r2,.25) * std::sin(.5*phi); } - - + + template void SlitSingularityFunction::value_list ( @@ -1415,21 +1415,21 @@ namespace Functions const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i void SlitSingularityFunction::vector_value_list ( @@ -1437,33 +1437,33 @@ namespace Functions std::vector >& values) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i double SlitSingularityFunction::laplacian (const Point &, - const unsigned int) const + const unsigned int) const { return 0.; } - - + + template void SlitSingularityFunction::laplacian_list ( @@ -1472,54 +1472,54 @@ namespace Functions const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i Tensor<1,dim> SlitSingularityFunction::gradient (const Point &p, - const unsigned int) const + const unsigned int) const { double x = p(0); double y = p(1); double phi = std::atan2(x,y)+M_PI; double r64 = std::pow(x*x+y*y,3./4.); - + Tensor<1,dim> result; result[0] = 1./2.*(std::sin(1./2.*phi)*x + std::cos(1./2.*phi)*y)/r64; result[1] = 1./2.*(std::sin(1./2.*phi)*y - std::cos(1./2.*phi)*x)/r64; return result; } - - + + template void SlitSingularityFunction::gradient_list (const std::vector > &points, - std::vector > &gradients, - const unsigned int) const + std::vector > &gradients, + const unsigned int) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - + ExcDimensionMismatch(gradients.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - double x = p(0); - double y = p(1); - double phi = std::atan2(x,y)+M_PI; - double r64 = std::pow(x*x+y*y,3./4.); - - gradients[i][0] = 1./2.*(std::sin(1./2.*phi)*x + std::cos(1./2.*phi)*y)/r64; - gradients[i][1] = 1./2.*(std::sin(1./2.*phi)*y - std::cos(1./2.*phi)*x)/r64; - for (unsigned int d=2;d& p = points[i]; + double x = p(0); + double y = p(1); + double phi = std::atan2(x,y)+M_PI; + double r64 = std::pow(x*x+y*y,3./4.); + + gradients[i][0] = 1./2.*(std::sin(1./2.*phi)*x + std::cos(1./2.*phi)*y)/r64; + gradients[i][1] = 1./2.*(std::sin(1./2.*phi)*y - std::cos(1./2.*phi)*x)/r64; + for (unsigned int d=2;d void SlitSingularityFunction::vector_gradient_list ( @@ -1527,43 +1527,43 @@ namespace Functions std::vector > >& gradients) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - + ExcDimensionMismatch(gradients.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - double x = p(0); - double y = p(1); - double phi = std::atan2(x,y)+M_PI; - double r64 = std::pow(x*x+y*y,3./4.); - - gradients[i][0][0] = 1./2.*(std::sin(1./2.*phi)*x + std::cos(1./2.*phi)*y)/r64; - gradients[i][0][1] = 1./2.*(std::sin(1./2.*phi)*y - std::cos(1./2.*phi)*x)/r64; - for (unsigned int d=2;d& p = points[i]; + double x = p(0); + double y = p(1); + double phi = std::atan2(x,y)+M_PI; + double r64 = std::pow(x*x+y*y,3./4.); + + gradients[i][0][0] = 1./2.*(std::sin(1./2.*phi)*x + std::cos(1./2.*phi)*y)/r64; + gradients[i][0][1] = 1./2.*(std::sin(1./2.*phi)*y - std::cos(1./2.*phi)*x)/r64; + for (unsigned int d=2;d &p, - const unsigned int) const + const unsigned int) const { double x = p(0); double y = p(1); - + double phi = std::atan2(x,y)+M_PI; double r2 = x*x+y*y; - + return std::pow(r2,.125) * std::sin(.25*phi); } - - + + void SlitHyperSingularityFunction::value_list ( const std::vector > &points, @@ -1571,45 +1571,45 @@ namespace Functions const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i >& points, std::vector >& values) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i &, @@ -1617,8 +1617,8 @@ namespace Functions { return 0.; } - - + + void SlitHyperSingularityFunction::laplacian_list ( const std::vector > &points, @@ -1626,13 +1626,13 @@ namespace Functions const unsigned int) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); - + ExcDimensionMismatch(values.size(), points.size())); + for (unsigned int i=0;i SlitHyperSingularityFunction::gradient ( const Point<2> &p, @@ -1642,15 +1642,15 @@ namespace Functions double y = p(1); double phi = std::atan2(x,y)+M_PI; double r78 = std::pow(x*x+y*y,7./8.); - - + + Tensor<1,2> result; result[0] = 1./4.*(std::sin(1./4.*phi)*x + std::cos(1./4.*phi)*y)/r78; result[1] = 1./4.*(std::sin(1./4.*phi)*y - std::cos(1./4.*phi)*x)/r78; return result; } - - + + void SlitHyperSingularityFunction::gradient_list ( const std::vector > &points, @@ -1658,136 +1658,136 @@ namespace Functions const unsigned int) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - + ExcDimensionMismatch(gradients.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - double x = p(0); - double y = p(1); - double phi = std::atan2(x,y)+M_PI; - double r78 = std::pow(x*x+y*y,7./8.); - - gradients[i][0] = 1./4.*(std::sin(1./4.*phi)*x + std::cos(1./4.*phi)*y)/r78; - gradients[i][1] = 1./4.*(std::sin(1./4.*phi)*y - std::cos(1./4.*phi)*x)/r78; + const Point<2>& p = points[i]; + double x = p(0); + double y = p(1); + double phi = std::atan2(x,y)+M_PI; + double r78 = std::pow(x*x+y*y,7./8.); + + gradients[i][0] = 1./4.*(std::sin(1./4.*phi)*x + std::cos(1./4.*phi)*y)/r78; + gradients[i][1] = 1./4.*(std::sin(1./4.*phi)*y - std::cos(1./4.*phi)*x)/r78; } } - - + + void SlitHyperSingularityFunction::vector_gradient_list ( const std::vector > &points, std::vector > >& gradients) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); - + ExcDimensionMismatch(gradients.size(), points.size())); + for (unsigned int i=0;i& p = points[i]; - double x = p(0); - double y = p(1); - double phi = std::atan2(x,y)+M_PI; - double r78 = std::pow(x*x+y*y,7./8.); - - gradients[i][0][0] = 1./4.*(std::sin(1./4.*phi)*x + std::cos(1./4.*phi)*y)/r78; - gradients[i][0][1] = 1./4.*(std::sin(1./4.*phi)*y - std::cos(1./4.*phi)*x)/r78; + Assert(gradients[i].size() == 1, + ExcDimensionMismatch(gradients[i].size(), 1)); + + const Point<2>& p = points[i]; + double x = p(0); + double y = p(1); + double phi = std::atan2(x,y)+M_PI; + double r78 = std::pow(x*x+y*y,7./8.); + + gradients[i][0][0] = 1./4.*(std::sin(1./4.*phi)*x + std::cos(1./4.*phi)*y)/r78; + gradients[i][0][1] = 1./4.*(std::sin(1./4.*phi)*y - std::cos(1./4.*phi)*x)/r78; } } - + ////////////////////////////////////////////////////////////////////// - + template JumpFunction::JumpFunction(const Point &direction, - const double steepness) - : - direction(direction), - steepness(steepness) + const double steepness) + : + direction(direction), + steepness(steepness) { switch (dim) { - case 1: - angle = 0; - break; - case 2: - angle = std::atan2(direction(0),direction(1)); - break; - case 3: - Assert(false, ExcNotImplemented()); + case 1: + angle = 0; + break; + case 2: + angle = std::atan2(direction(0),direction(1)); + break; + case 3: + Assert(false, ExcNotImplemented()); } sine = std::sin(angle); cosine = std::cos(angle); } - - - + + + template double JumpFunction::value (const Point &p, - const unsigned int) const + const unsigned int) const { double x = steepness*(-cosine*p(0)+sine*p(1)); return -std::atan(x); } - - - + + + template void JumpFunction::value_list (const std::vector > &p, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (values.size() == p.size(), - ExcDimensionMismatch(values.size(), p.size())); - + ExcDimensionMismatch(values.size(), p.size())); + for (unsigned int i=0;i double JumpFunction::laplacian (const Point &p, - const unsigned int) const + const unsigned int) const { double x = steepness*(-cosine*p(0)+sine*p(1)); double r = 1+x*x; return 2*steepness*steepness*x/(r*r); } - - + + template void JumpFunction::laplacian_list (const std::vector > &p, - std::vector &values, - const unsigned int) const + std::vector &values, + const unsigned int) const { Assert (values.size() == p.size(), - ExcDimensionMismatch(values.size(), p.size())); - + ExcDimensionMismatch(values.size(), p.size())); + double f = 2*steepness*steepness; - + for (unsigned int i=0;i Tensor<1,dim> JumpFunction::gradient (const Point &p, - const unsigned int) const + const unsigned int) const { double x = steepness*(-cosine*p(0)+sine*p(1)); double r = -steepness*(1+x*x); @@ -1796,162 +1796,162 @@ namespace Functions erg[1] = sine*r; return erg; } - - - + + + template void JumpFunction::gradient_list (const std::vector > &p, - std::vector > &gradients, - const unsigned int) const + std::vector > &gradients, + const unsigned int) const { Assert (gradients.size() == p.size(), - ExcDimensionMismatch(gradients.size(), p.size())); - + ExcDimensionMismatch(gradients.size(), p.size())); + for (unsigned int i=0; i std::size_t JumpFunction::memory_consumption () const { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (*this); } - - - - - + + + + + /* ---------------------- FourierCosineFunction ----------------------- */ - - + + template FourierCosineFunction:: FourierCosineFunction (const Point &fourier_coefficients) - : - Function (1), - fourier_coefficients (fourier_coefficients) + : + Function (1), + fourier_coefficients (fourier_coefficients) {} - - - + + + template double FourierCosineFunction::value (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component==0, ExcIndexRange(component,0,1)); return std::cos(fourier_coefficients * p); } - - - + + + template Tensor<1,dim> FourierCosineFunction::gradient (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component==0, ExcIndexRange(component,0,1)); return -fourier_coefficients * std::sin(fourier_coefficients * p); } - - - + + + template double FourierCosineFunction::laplacian (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component==0, ExcIndexRange(component,0,1)); return fourier_coefficients.square() * (-std::cos(fourier_coefficients * p)); } - - - - + + + + /* ---------------------- FourierSineFunction ----------------------- */ - - - + + + template FourierSineFunction:: FourierSineFunction (const Point &fourier_coefficients) - : - Function (1), - fourier_coefficients (fourier_coefficients) + : + Function (1), + fourier_coefficients (fourier_coefficients) {} - - - + + + template double FourierSineFunction::value (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component==0, ExcIndexRange(component,0,1)); return std::sin(fourier_coefficients * p); } - - - + + + template Tensor<1,dim> FourierSineFunction::gradient (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component==0, ExcIndexRange(component,0,1)); return fourier_coefficients * std::cos(fourier_coefficients * p); } - - - + + + template double FourierSineFunction::laplacian (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component==0, ExcIndexRange(component,0,1)); return fourier_coefficients.square() * (-std::sin(fourier_coefficients * p)); } - + /* ---------------------- FourierSineSum ----------------------- */ - - - + + + template FourierSineSum:: FourierSineSum (const std::vector > &fourier_coefficients, - const std::vector &weights) - : - Function (1), - fourier_coefficients (fourier_coefficients), - weights (weights) + const std::vector &weights) + : + Function (1), + fourier_coefficients (fourier_coefficients), + weights (weights) { Assert (fourier_coefficients.size() > 0, ExcZero()); Assert (fourier_coefficients.size() == weights.size(), - ExcDimensionMismatch(fourier_coefficients.size(), - weights.size())); + ExcDimensionMismatch(fourier_coefficients.size(), + weights.size())); } - - - + + + template double FourierSineSum::value (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component==0, ExcIndexRange(component,0,1)); @@ -1959,16 +1959,16 @@ namespace Functions double sum = 0; for (unsigned int s=0; s Tensor<1,dim> FourierSineSum::gradient (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component==0, ExcIndexRange(component,0,1)); @@ -1976,16 +1976,16 @@ namespace Functions Tensor<1,dim> sum; for (unsigned int s=0; s double FourierSineSum::laplacian (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component==0, ExcIndexRange(component,0,1)); @@ -1993,37 +1993,37 @@ namespace Functions double sum = 0; for (unsigned int s=0; s FourierCosineSum:: FourierCosineSum (const std::vector > &fourier_coefficients, - const std::vector &weights) - : - Function (1), - fourier_coefficients (fourier_coefficients), - weights (weights) + const std::vector &weights) + : + Function (1), + fourier_coefficients (fourier_coefficients), + weights (weights) { Assert (fourier_coefficients.size() > 0, ExcZero()); Assert (fourier_coefficients.size() == weights.size(), - ExcDimensionMismatch(fourier_coefficients.size(), - weights.size())); + ExcDimensionMismatch(fourier_coefficients.size(), + weights.size())); } - - - + + + template double FourierCosineSum::value (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component==0, ExcIndexRange(component,0,1)); @@ -2031,16 +2031,16 @@ namespace Functions double sum = 0; for (unsigned int s=0; s Tensor<1,dim> FourierCosineSum::gradient (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component==0, ExcIndexRange(component,0,1)); @@ -2048,16 +2048,16 @@ namespace Functions Tensor<1,dim> sum; for (unsigned int s=0; s double FourierCosineSum::laplacian (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component==0, ExcIndexRange(component,0,1)); @@ -2065,7 +2065,7 @@ namespace Functions double sum = 0; for (unsigned int s=0; s Monomial:: Monomial (const Tensor<1,dim> &exponents, - const unsigned int n_components) - : - Function (n_components), - exponents (exponents) + const unsigned int n_components) + : + Function (n_components), + exponents (exponents) {} - - - + + + template double Monomial::value (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (componentn_components, - ExcIndexRange(component, 0, this->n_components)) ; + ExcIndexRange(component, 0, this->n_components)) ; double prod = 1; for (unsigned int s=0; s void Monomial::vector_value (const Point &p, - Vector &values) const + Vector &values) const { Assert (values.size() == this->n_components, - ExcDimensionMismatch (values.size(), this->n_components)); + ExcDimensionMismatch (values.size(), this->n_components)); for (unsigned int i=0; i::value(p,i); } - - - + + + template Tensor<1,dim> Monomial::gradient (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (component==0, ExcIndexRange(component,0,1)) ; Tensor<1,dim> r; for (unsigned int d=0; d void Monomial::value_list (const std::vector > &points, - std::vector &values, - const unsigned int component) const + std::vector &values, + const unsigned int component) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); for (unsigned int i=0; i::value (points[i], component); } - - + + template Bessel1::Bessel1( const unsigned int order, const double wave_number, const Point center) - : - order(order), - wave_number(wave_number), - center(center) + : + order(order), + wave_number(wave_number), + center(center) {} - + template double Bessel1::value(const Point& p, const unsigned int) const @@ -2182,8 +2182,8 @@ namespace Functions return r; #endif } - - + + template void Bessel1::value_list ( @@ -2196,28 +2196,28 @@ namespace Functions for (unsigned int k=0;k Tensor<1,dim> Bessel1::gradient (const Point &p, - const unsigned int) const + const unsigned int) const { Assert(dim==2, ExcNotImplemented()); const double r = p.distance(center); const double co = (r==0.) ? 0. : (p(0)-center(0))/r; const double si = (r==0.) ? 0. : (p(1)-center(1))/r; - + const double dJn = (order==0) - ? (-jn(1, r*wave_number)) - : (.5*(jn(order-1, wave_number*r) -jn(order+1, wave_number*r))); + ? (-jn(1, r*wave_number)) + : (.5*(jn(order-1, wave_number*r) -jn(order+1, wave_number*r))); Tensor<1,dim> result; result[0] = wave_number * co * dJn; result[1] = wave_number * si * dJn; @@ -2228,9 +2228,9 @@ namespace Functions return Tensor<1,dim>(); #endif } - - + + template void Bessel1::gradient_list ( @@ -2242,27 +2242,27 @@ namespace Functions AssertDimension(points.size(), gradients.size()); for (unsigned int k=0;k& p = points[k]; - const double r = p.distance(center); - const double co = (r==0.) ? 0. : (p(0)-center(0))/r; - const double si = (r==0.) ? 0. : (p(1)-center(1))/r; - + const Point& p = points[k]; + const double r = p.distance(center); + const double co = (r==0.) ? 0. : (p(0)-center(0))/r; + const double si = (r==0.) ? 0. : (p(1)-center(1))/r; + #ifdef HAVE_JN_ - const double dJn = (order==0) - ? (-jn(1, r*wave_number)) - : (.5*(jn(order-1, wave_number*r) -jn(order+1, wave_number*r))); + const double dJn = (order==0) + ? (-jn(1, r*wave_number)) + : (.5*(jn(order-1, wave_number*r) -jn(order+1, wave_number*r))); #else - const double dJn = 0.; - Assert(false, ExcMessage("Bessel function jn was not found by configure")); + const double dJn = 0.; + Assert(false, ExcMessage("Bessel function jn was not found by configure")); #endif - Tensor<1,dim>& result = gradients[k]; - result[0] = wave_number * co * dJn; - result[1] = wave_number * si * dJn; + Tensor<1,dim>& result = gradients[k]; + result[0] = wave_number * co * dJn; + result[1] = wave_number * si * dJn; } } - -// explicit instantiations + +// explicit instantiations template class SquareFunction<1>; template class SquareFunction<2>; template class SquareFunction<3>; diff --git a/deal.II/source/base/function_lib_cutoff.cc b/deal.II/source/base/function_lib_cutoff.cc index caa885874b..64aae930f6 100644 --- a/deal.II/source/base/function_lib_cutoff.cc +++ b/deal.II/source/base/function_lib_cutoff.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2010 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -26,11 +26,11 @@ namespace Functions { template CutOffFunctionBase::CutOffFunctionBase (const double r, - const Point p, - const unsigned int n_components, - const unsigned int select) - : - Function (n_components), + const Point p, + const unsigned int n_components, + const unsigned int select) + : + Function (n_components), center(p), radius(r), selected(select) @@ -56,22 +56,22 @@ namespace Functions template CutOffFunctionLinfty::CutOffFunctionLinfty (const double r, - const Point p, - const unsigned int n_components, - const unsigned int select) - : - CutOffFunctionBase (r, p, n_components, select) + const Point p, + const unsigned int n_components, + const unsigned int select) + : + CutOffFunctionBase (r, p, n_components, select) {} template double CutOffFunctionLinfty::value (const Point &p, - const unsigned int component) const + const unsigned int component) const { if (this->selected==CutOffFunctionBase::no_component - || - component==this->selected) + || + component==this->selected) return ((this->center.distance(p)radius) ? 1. : 0.); return 0.; } @@ -80,20 +80,20 @@ namespace Functions template void CutOffFunctionLinfty::value_list (const std::vector > &points, - std::vector &values, - const unsigned int component) const + std::vector &values, + const unsigned int component) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); Assert (component < this->n_components, - ExcIndexRange(component,0,this->n_components)); + ExcIndexRange(component,0,this->n_components)); if (this->selected==CutOffFunctionBase::no_component - || - component==this->selected) + || + component==this->selected) for (unsigned int k=0;kcenter.distance(points[k])radius) ? 1. : 0.; + values[k] = (this->center.distance(points[k])radius) ? 1. : 0.; else std::fill (values.begin(), values.end(), 0.); } @@ -106,44 +106,44 @@ namespace Functions std::vector > &values) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); for (unsigned int k=0;kcenter.distance(points[k])radius) ? 1. : 0.; - if (this->selected==CutOffFunctionBase::no_component) - values[k] = val; - else - { - values[k] = 0; - values[k](this->selected) = val; - } + const double + val = (this->center.distance(points[k])radius) ? 1. : 0.; + if (this->selected==CutOffFunctionBase::no_component) + values[k] = val; + else + { + values[k] = 0; + values[k](this->selected) = val; + } } } template CutOffFunctionW1::CutOffFunctionW1 (const double r, - const Point p, - const unsigned int n_components, - const unsigned int select) - : - CutOffFunctionBase (r, p, n_components, select) + const Point p, + const unsigned int n_components, + const unsigned int select) + : + CutOffFunctionBase (r, p, n_components, select) {} template double CutOffFunctionW1::value (const Point &p, - const unsigned int component) const + const unsigned int component) const { if (this->selected==CutOffFunctionBase::no_component - || - component==this->selected) + || + component==this->selected) { - const double d = this->center.distance(p); - return ((dradius) ? (this->radius-d) : 0.); + const double d = this->center.distance(p); + return ((dradius) ? (this->radius-d) : 0.); } return 0.; } @@ -152,20 +152,20 @@ namespace Functions template void CutOffFunctionW1::value_list (const std::vector > &points, - std::vector &values, - const unsigned int component) const + std::vector &values, + const unsigned int component) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); if (this->selected==CutOffFunctionBase::no_component - || - component==this->selected) + || + component==this->selected) for (unsigned int i=0;icenter.distance(points[i]); - values[i] = ((dradius) ? (this->radius-d) : 0.); - } + { + const double d = this->center.distance(points[i]); + values[i] = ((dradius) ? (this->radius-d) : 0.); + } else std::fill (values.begin(), values.end(), 0.); } @@ -179,49 +179,49 @@ namespace Functions std::vector > &values) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); for (unsigned int k=0;kcenter.distance(points[k]); - const double - val = (dradius) ? (this->radius-d) : 0.; - if (this->selected==CutOffFunctionBase::no_component) - values[k] = val; - else - { - values[k] = 0; - values[k](this->selected) = val; - } + const double d = this->center.distance(points[k]); + const double + val = (dradius) ? (this->radius-d) : 0.; + if (this->selected==CutOffFunctionBase::no_component) + values[k] = val; + else + { + values[k] = 0; + values[k](this->selected) = val; + } } } template CutOffFunctionCinfty::CutOffFunctionCinfty (const double r, - const Point p, - const unsigned int n_components, - const unsigned int select) - : - CutOffFunctionBase (r, p, n_components, select) + const Point p, + const unsigned int n_components, + const unsigned int select) + : + CutOffFunctionBase (r, p, n_components, select) {} template double CutOffFunctionCinfty::value (const Point &p, - const unsigned int component) const + const unsigned int component) const { if (this->selected==CutOffFunctionBase::no_component - || - component==this->selected) + || + component==this->selected) { - const double d = this->center.distance(p); - const double r = this->radius; - if (d>=r) - return 0.; - const double e = -r*r/(r*r-d*d); - return ((e<-50) ? 0. : numbers::E * exp(e)); + const double d = this->center.distance(p); + const double r = this->radius; + if (d>=r) + return 0.; + const double e = -r*r/(r*r-d*d); + return ((e<-50) ? 0. : numbers::E * exp(e)); } return 0.; } @@ -230,28 +230,28 @@ namespace Functions template void CutOffFunctionCinfty::value_list (const std::vector > &points, - std::vector &values, - const unsigned int component) const + std::vector &values, + const unsigned int component) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); const double r = this->radius; if (this->selected==CutOffFunctionBase::no_component - || - component==this->selected) + || + component==this->selected) for (unsigned int i=0; icenter.distance(points[i]); - if (d>=r) - { - values[i] = 0.; - } else { - const double e = -r*r/(r*r-d*d); - values[i] = (e<-50) ? 0. : numbers::E * exp(e); - } - } + { + const double d = this->center.distance(points[i]); + if (d>=r) + { + values[i] = 0.; + } else { + const double e = -r*r/(r*r-d*d); + values[i] = (e<-50) ? 0. : numbers::E * exp(e); + } + } else std::fill (values.begin(), values.end(), 0.); } @@ -264,28 +264,28 @@ namespace Functions std::vector > &values) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); for (unsigned int k=0;kcenter.distance(points[k]); - const double r = this->radius; - double e = 0.; - double val = 0.; - if (dradius) - { - e = -r*r/(r*r-d*d); - if (e>-50) - val = numbers::E * exp(e); - } - - if (this->selected==CutOffFunctionBase::no_component) - values[k] = val; - else - { - values[k] = 0; - values[k](this->selected) = val; - } + const double d = this->center.distance(points[k]); + const double r = this->radius; + double e = 0.; + double val = 0.; + if (dradius) + { + e = -r*r/(r*r-d*d); + if (e>-50) + val = numbers::E * exp(e); + } + + if (this->selected==CutOffFunctionBase::no_component) + values[k] = val; + else + { + values[k] = 0; + values[k](this->selected) = val; + } } } @@ -294,7 +294,7 @@ namespace Functions template Tensor<1,dim> CutOffFunctionCinfty::gradient (const Point &p, - const unsigned int) const + const unsigned int) const { const double d = this->center.distance(p); const double r = this->radius; @@ -302,8 +302,8 @@ namespace Functions return Tensor<1,dim>(); const double e = -d*d/(r-d)/(r+d); return ((e<-50) ? - Point() : - (p-this->center)/d*(-2.0*r*r/pow(-r*r+d*d,2.0)*d*exp(e))); + Point() : + (p-this->center)/d*(-2.0*r*r/pow(-r*r+d*d,2.0)*d*exp(e))); } diff --git a/deal.II/source/base/function_parser.cc b/deal.II/source/base/function_parser.cc index 3b08e510be..694936ad40 100644 --- a/deal.II/source/base/function_parser.cc +++ b/deal.II/source/base/function_parser.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2005, 2006, 2007, 2009 by the deal.II authors +// Copyright (C) 2005, 2006, 2007, 2009, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -33,7 +33,7 @@ DEAL_II_NAMESPACE_OPEN template FunctionParser::FunctionParser(const unsigned int n_components, - const double initial_time) + const double initial_time) : Function(n_components, initial_time), fp (0) @@ -70,20 +70,20 @@ void FunctionParser::initialize (const std::string &varia template void FunctionParser::initialize (const std::string &variables, - const std::vector &expressions, - const std::map &constants, - const std::map &units, - const bool time_dependent, - const bool use_degrees) + const std::vector &expressions, + const std::map &constants, + const std::map &units, + const bool time_dependent, + const bool use_degrees) { - // We check that the number of - // components of this function - // matches the number of components - // passed in as a vector of - // strings. + // We check that the number of + // components of this function + // matches the number of components + // passed in as a vector of + // strings. AssertThrow(this->n_components == expressions.size(), - ExcInvalidExpressionSize(this->n_components, - expressions.size()) ); + ExcInvalidExpressionSize(this->n_components, + expressions.size()) ); @@ -104,55 +104,55 @@ void FunctionParser::initialize (const std::string &variables, - // Add the various constants to - // the parser. + // Add the various constants to + // the parser. std::map< std::string, double >::const_iterator - constant = constants.begin(), - endc = constants.end(); + constant = constants.begin(), + endc = constants.end(); for(; constant != endc; ++constant) - { - const bool success = fp[i].AddConstant(constant->first, constant->second); - AssertThrow (success, ExcMessage("Invalid Constant Name")); - } + { + const bool success = fp[i].AddConstant(constant->first, constant->second); + AssertThrow (success, ExcMessage("Invalid Constant Name")); + } const int ret_value = fp[i].Parse(expressions[i], - variables, - use_degrees); + variables, + use_degrees); AssertThrow (ret_value == -1, - ExcParseError(ret_value, fp[i].ErrorMsg())); - - // The fact that the parser did - // not throw an error does not - // mean that everything went - // ok... we can still have - // problems with the number of - // variables... + ExcParseError(ret_value, fp[i].ErrorMsg())); + + // The fact that the parser did + // not throw an error does not + // mean that everything went + // ok... we can still have + // problems with the number of + // variables... } - // Now we define how many variables - // we expect to read in. We - // distinguish between two cases: - // Time dependent problems, and not - // time dependent problems. In the - // first case the number of - // variables is given by the - // dimension plus one. In the other - // case, the number of variables is - // equal to the dimension. Once we - // parsed the variables string, if - // none of this is the case, then - // an exception is thrown. + // Now we define how many variables + // we expect to read in. We + // distinguish between two cases: + // Time dependent problems, and not + // time dependent problems. In the + // first case the number of + // variables is given by the + // dimension plus one. In the other + // case, the number of variables is + // equal to the dimension. Once we + // parsed the variables string, if + // none of this is the case, then + // an exception is thrown. if (time_dependent) n_vars = dim+1; else n_vars = dim; - // Let's check if the number of - // variables is correct... + // Let's check if the number of + // variables is correct... AssertThrow (n_vars == fp[0].NVars(), - ExcDimensionMismatch(n_vars,fp[0].NVars())); + ExcDimensionMismatch(n_vars,fp[0].NVars())); - // Now set the initialization bit. + // Now set the initialization bit. initialized = true; } @@ -160,13 +160,13 @@ void FunctionParser::initialize (const std::string &variables, template void FunctionParser::initialize (const std::string &variables, - const std::string &expression, - const std::map &constants, - const bool time_dependent, - const bool use_degrees) + const std::string &expression, + const std::map &constants, + const bool time_dependent, + const bool use_degrees) { - // initialize with the things - // we got. + // initialize with the things + // we got. initialize (variables, Utilities::split_string_list (expression, ';'), constants, @@ -198,32 +198,32 @@ void FunctionParser::initialize (const std::string &variables, template double FunctionParser::value (const Point &p, - const unsigned int component) const + const unsigned int component) const { Assert (initialized==true, ExcNotInitialized()); Assert (component < this->n_components, - ExcIndexRange(component, 0, this->n_components)); + ExcIndexRange(component, 0, this->n_components)); - // Statically allocate dim+1 - // double variables. + // Statically allocate dim+1 + // double variables. double vars[dim+1]; for (unsigned int i=0; iget_time(); double my_value = fp[component].Eval((double*)vars); AssertThrow (fp[component].EvalError() == 0, - ExcMessage(fp[component].ErrorMsg())); + ExcMessage(fp[component].ErrorMsg())); return my_value; } @@ -231,25 +231,25 @@ double FunctionParser::value (const Point &p, template void FunctionParser::vector_value (const Point &p, - Vector &values) const + Vector &values) const { Assert (initialized==true, ExcNotInitialized()); Assert (values.size() == this->n_components, - ExcDimensionMismatch (values.size(), this->n_components)); + ExcDimensionMismatch (values.size(), this->n_components)); - // Statically allocates dim+1 - // double variables. + // Statically allocates dim+1 + // double variables. double vars[dim+1]; for(unsigned int i=0; iget_time(); @@ -258,7 +258,7 @@ void FunctionParser::vector_value (const Point &p, { values(component) = fp[component].Eval((double*)vars); AssertThrow(fp[component].EvalError() == 0, - ExcMessage(fp[component].ErrorMsg())); + ExcMessage(fp[component].ErrorMsg())); } } @@ -268,10 +268,10 @@ void FunctionParser::vector_value (const Point &p, template void FunctionParser::initialize(const std::string &, - const std::vector &, - const std::map &, - const bool, - const bool) + const std::vector &, + const std::map &, + const bool, + const bool) { Assert(false, ExcDisabled("parser")); } @@ -280,10 +280,10 @@ FunctionParser::initialize(const std::string &, template void FunctionParser::initialize(const std::string &, - const std::string &, - const std::map &, - const bool, - const bool) + const std::string &, + const std::map &, + const bool, + const bool) { Assert(false, ExcDisabled("parser")); } diff --git a/deal.II/source/base/function_time.cc b/deal.II/source/base/function_time.cc index 4ed189b65b..9cc7356a6c 100644 --- a/deal.II/source/base/function_time.cc +++ b/deal.II/source/base/function_time.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -18,8 +18,8 @@ DEAL_II_NAMESPACE_OPEN FunctionTime::FunctionTime(const double initial_time) - : - time(initial_time) + : + time(initial_time) {} diff --git a/deal.II/source/base/geometry_info.cc b/deal.II/source/base/geometry_info.cc index 6456bd13f6..d941c7416d 100644 --- a/deal.II/source/base/geometry_info.cc +++ b/deal.II/source/base/geometry_info.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -278,7 +278,7 @@ GeometryInfo<3>::n_subfaces(const internal::SubfaceCase<3> &subface_case) template<> double GeometryInfo<1>::subface_ratio(const internal::SubfaceCase<1> &, - const unsigned int) + const unsigned int) { return 1; } @@ -287,7 +287,7 @@ GeometryInfo<1>::subface_ratio(const internal::SubfaceCase<1> &, template<> double GeometryInfo<2>::subface_ratio(const internal::SubfaceCase<2> &subface_case, - const unsigned int) + const unsigned int) { const unsigned int dim=2; @@ -295,31 +295,31 @@ GeometryInfo<2>::subface_ratio(const internal::SubfaceCase<2> &subface_case, switch (subface_case) { case internal::SubfaceCase::case_none: - // Here, an - // Assert(false,ExcInternalError()) - // would be the right - // choice, but - // unfortunately the - // current function is - // also called for faces - // without children (see - // tests/fe/mapping.cc). -// Assert(false, ExcMessage("Face has no subfaces.")); - // Furthermore, assign - // following value as - // otherwise the - // bits/volume_x tests - // break - ratio=1./GeometryInfo::max_children_per_face; - break; + // Here, an + // Assert(false,ExcInternalError()) + // would be the right + // choice, but + // unfortunately the + // current function is + // also called for faces + // without children (see + // tests/fe/mapping.cc). +// Assert(false, ExcMessage("Face has no subfaces.")); + // Furthermore, assign + // following value as + // otherwise the + // bits/volume_x tests + // break + ratio=1./GeometryInfo::max_children_per_face; + break; case internal::SubfaceCase::case_x: - ratio=0.5; - break; + ratio=0.5; + break; default: - // there should be no - // cases left - Assert(false, ExcInternalError()); - break; + // there should be no + // cases left + Assert(false, ExcInternalError()); + break; } return ratio; @@ -329,7 +329,7 @@ GeometryInfo<2>::subface_ratio(const internal::SubfaceCase<2> &subface_case, template<> double GeometryInfo<3>::subface_ratio(const internal::SubfaceCase<3> &subface_case, - const unsigned int subface_no) + const unsigned int subface_no) { const unsigned int dim=3; @@ -337,48 +337,48 @@ GeometryInfo<3>::subface_ratio(const internal::SubfaceCase<3> &subface_case, switch (subface_case) { case internal::SubfaceCase::case_none: - // Here, an - // Assert(false,ExcInternalError()) - // would be the right - // choice, but - // unfortunately the - // current function is - // also called for faces - // without children (see - // tests/bits/mesh_3d_16.cc). Add - // following switch to - // avoid diffs in - // tests/bits/mesh_3d_16 - ratio=1./GeometryInfo::max_children_per_face; - break; + // Here, an + // Assert(false,ExcInternalError()) + // would be the right + // choice, but + // unfortunately the + // current function is + // also called for faces + // without children (see + // tests/bits/mesh_3d_16.cc). Add + // following switch to + // avoid diffs in + // tests/bits/mesh_3d_16 + ratio=1./GeometryInfo::max_children_per_face; + break; case internal::SubfaceCase::case_x: case internal::SubfaceCase::case_y: - ratio=0.5; - break; + ratio=0.5; + break; case internal::SubfaceCase::case_xy: case internal::SubfaceCase::case_x1y2y: case internal::SubfaceCase::case_y1x2x: - ratio=0.25; - break; + ratio=0.25; + break; case internal::SubfaceCase::case_x1y: case internal::SubfaceCase::case_y1x: - if (subface_no<2) - ratio=0.25; - else - ratio=0.5; - break; + if (subface_no<2) + ratio=0.25; + else + ratio=0.5; + break; case internal::SubfaceCase::case_x2y: case internal::SubfaceCase::case_y2x: - if (subface_no==0) - ratio=0.5; - else - ratio=0.25; - break; + if (subface_no==0) + ratio=0.5; + else + ratio=0.25; + break; default: - // there should be no - // cases left - Assert(false, ExcInternalError()); - break; + // there should be no + // cases left + Assert(false, ExcInternalError()); + break; } return ratio; @@ -389,10 +389,10 @@ GeometryInfo<3>::subface_ratio(const internal::SubfaceCase<3> &subface_case, template<> RefinementCase<0> GeometryInfo<1>::face_refinement_case(const RefinementCase<1> &, - const unsigned int, - const bool, - const bool, - const bool) + const unsigned int, + const bool, + const bool, + const bool) { Assert(false, ExcImpossibleInDim(1)); @@ -403,16 +403,16 @@ GeometryInfo<1>::face_refinement_case(const RefinementCase<1> &, template<> RefinementCase<1> GeometryInfo<2>::face_refinement_case(const RefinementCase<2> &cell_refinement_case, - const unsigned int face_no, - const bool, - const bool, - const bool) + const unsigned int face_no, + const bool, + const bool, + const bool) { const unsigned int dim=2; Assert(cell_refinement_case::isotropic_refinement+1, - ExcIndexRange(cell_refinement_case, 0, RefinementCase::isotropic_refinement+1)); + ExcIndexRange(cell_refinement_case, 0, RefinementCase::isotropic_refinement+1)); Assert(face_no::faces_per_cell, - ExcIndexRange(face_no, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange(face_no, 0, GeometryInfo::faces_per_cell)); static const RefinementCase ref_cases[RefinementCase::isotropic_refinement+1][GeometryInfo::faces_per_cell/2]= @@ -436,16 +436,16 @@ GeometryInfo<2>::face_refinement_case(const RefinementCase<2> &cell_refinement_c template<> RefinementCase<2> GeometryInfo<3>::face_refinement_case(const RefinementCase<3> &cell_refinement_case, - const unsigned int face_no, - const bool face_orientation, - const bool /*face_flip*/, - const bool face_rotation) + const unsigned int face_no, + const bool face_orientation, + const bool /*face_flip*/, + const bool face_rotation) { const unsigned int dim=3; Assert(cell_refinement_case::isotropic_refinement+1, - ExcIndexRange(cell_refinement_case, 0, RefinementCase::isotropic_refinement+1)); + ExcIndexRange(cell_refinement_case, 0, RefinementCase::isotropic_refinement+1)); Assert(face_no::faces_per_cell, - ExcIndexRange(face_no, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange(face_no, 0, GeometryInfo::faces_per_cell)); static const RefinementCase ref_cases[RefinementCase::isotropic_refinement+1][GeometryInfo::faces_per_cell/2]= @@ -490,18 +490,18 @@ GeometryInfo<3>::face_refinement_case(const RefinementCase<3> &cell_refinement_c RefinementCase::cut_x, RefinementCase::cut_xy}; - // correct the ref_case for face_orientation - // and face_rotation. for face_orientation, - // 'true' is the default value whereas for - // face_rotation, 'false' is standard. If - // face_rotation==face_orientation, - // then one of them is non-standard and we - // have to swap cut_x and cut_y, otherwise no - // change is necessary. face_flip has no - // influence. however, in order to keep the - // interface consistent with other functions, - // we still include it as an argument to this - // function + // correct the ref_case for face_orientation + // and face_rotation. for face_orientation, + // 'true' is the default value whereas for + // face_rotation, 'false' is standard. If + // face_rotation==face_orientation, + // then one of them is non-standard and we + // have to swap cut_x and cut_y, otherwise no + // change is necessary. face_flip has no + // influence. however, in order to keep the + // interface consistent with other functions, + // we still include it as an argument to this + // function return (face_orientation==face_rotation) ? flip[ref_case] : ref_case; } @@ -510,13 +510,13 @@ GeometryInfo<3>::face_refinement_case(const RefinementCase<3> &cell_refinement_c template<> RefinementCase<1> GeometryInfo<1>::line_refinement_case(const RefinementCase<1> &cell_refinement_case, - const unsigned int line_no) + const unsigned int line_no) { const unsigned int dim = 1; Assert(cell_refinement_case::isotropic_refinement+1, - ExcIndexRange(cell_refinement_case, 0, RefinementCase::isotropic_refinement+1)); + ExcIndexRange(cell_refinement_case, 0, RefinementCase::isotropic_refinement+1)); Assert(line_no::lines_per_cell, - ExcIndexRange(line_no, 0, GeometryInfo::lines_per_cell)); + ExcIndexRange(line_no, 0, GeometryInfo::lines_per_cell)); return cell_refinement_case; } @@ -525,9 +525,9 @@ GeometryInfo<1>::line_refinement_case(const RefinementCase<1> &cell_refinement_c template<> RefinementCase<1> GeometryInfo<2>::line_refinement_case(const RefinementCase<2> &cell_refinement_case, - const unsigned int line_no) + const unsigned int line_no) { - // Assertions are in face_refinement_case() + // Assertions are in face_refinement_case() return face_refinement_case(cell_refinement_case, line_no); } @@ -535,28 +535,28 @@ GeometryInfo<2>::line_refinement_case(const RefinementCase<2> &cell_refinement_c template<> RefinementCase<1> GeometryInfo<3>::line_refinement_case(const RefinementCase<3> &cell_refinement_case, - const unsigned int line_no) + const unsigned int line_no) { const unsigned int dim=3; Assert(cell_refinement_case::isotropic_refinement+1, - ExcIndexRange(cell_refinement_case, 0, RefinementCase::isotropic_refinement+1)); + ExcIndexRange(cell_refinement_case, 0, RefinementCase::isotropic_refinement+1)); Assert(line_no::lines_per_cell, - ExcIndexRange(line_no, 0, GeometryInfo::lines_per_cell)); - - // array indicating, which simple refine - // case cuts a line in dirextion x, y or - // z. For example, cut_y and everything - // containing cut_y (cut_xy, cut_yz, - // cut_xyz) cuts lines, which are in y - // direction. + ExcIndexRange(line_no, 0, GeometryInfo::lines_per_cell)); + + // array indicating, which simple refine + // case cuts a line in dirextion x, y or + // z. For example, cut_y and everything + // containing cut_y (cut_xy, cut_yz, + // cut_xyz) cuts lines, which are in y + // direction. static const RefinementCase cut_one[dim] = {RefinementCase::cut_x, RefinementCase::cut_y, RefinementCase::cut_z}; - // order the direction of lines - // 0->x, 1->y, 2->z + // order the direction of lines + // 0->x, 1->y, 2->z static const unsigned int direction[lines_per_cell]= {1,1,0,0,1,1,0,0,2,2,2,2}; @@ -569,10 +569,10 @@ GeometryInfo<3>::line_refinement_case(const RefinementCase<3> &cell_refinement_c template<> RefinementCase<1> GeometryInfo<1>::min_cell_refinement_case_for_face_refinement(const RefinementCase<0> &, - const unsigned int, - const bool, - const bool, - const bool) + const unsigned int, + const bool, + const bool, + const bool) { const unsigned int dim = 1; Assert(false, ExcImpossibleInDim(dim)); @@ -584,16 +584,16 @@ GeometryInfo<1>::min_cell_refinement_case_for_face_refinement(const RefinementCa template<> RefinementCase<2> GeometryInfo<2>::min_cell_refinement_case_for_face_refinement(const RefinementCase<1> &face_refinement_case, - const unsigned int face_no, - const bool, - const bool, - const bool) + const unsigned int face_no, + const bool, + const bool, + const bool) { const unsigned int dim = 2; Assert(face_refinement_case::isotropic_refinement+1, - ExcIndexRange(face_refinement_case, 0, RefinementCase::isotropic_refinement+1)); + ExcIndexRange(face_refinement_case, 0, RefinementCase::isotropic_refinement+1)); Assert(face_no::faces_per_cell, - ExcIndexRange(face_no, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange(face_no, 0, GeometryInfo::faces_per_cell)); if (face_refinement_case==RefinementCase::cut_x) return (face_no/2) ? RefinementCase::cut_x : RefinementCase::cut_y; @@ -605,16 +605,16 @@ GeometryInfo<2>::min_cell_refinement_case_for_face_refinement(const RefinementCa template<> RefinementCase<3> GeometryInfo<3>::min_cell_refinement_case_for_face_refinement(const RefinementCase<2> &face_refinement_case, - const unsigned int face_no, - const bool face_orientation, - const bool /*face_flip*/, - const bool face_rotation) + const unsigned int face_no, + const bool face_orientation, + const bool /*face_flip*/, + const bool face_rotation) { const unsigned int dim=3; Assert(face_refinement_case::isotropic_refinement+1, - ExcIndexRange(face_refinement_case, 0, RefinementCase::isotropic_refinement+1)); + ExcIndexRange(face_refinement_case, 0, RefinementCase::isotropic_refinement+1)); Assert(face_no::faces_per_cell, - ExcIndexRange(face_no, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange(face_no, 0, GeometryInfo::faces_per_cell)); static const RefinementCase<2> flip[4]= {RefinementCase<2>::no_refinement, @@ -622,19 +622,19 @@ GeometryInfo<3>::min_cell_refinement_case_for_face_refinement(const RefinementCa RefinementCase<2>::cut_x, RefinementCase<2>::cut_xy}; - // correct the face_refinement_case for - // face_orientation and face_rotation. for - // face_orientation, 'true' is the default - // value whereas for face_rotation, 'false' - // is standard. If - // face_rotation==face_orientation, - // then one of them is non-standard and we - // have to swap cut_x and cut_y, otherwise no - // change is necessary. face_flip has no - // influence. however, in order to keep the - // interface consistent with other functions, - // we still include it as an argument to this - // function + // correct the face_refinement_case for + // face_orientation and face_rotation. for + // face_orientation, 'true' is the default + // value whereas for face_rotation, 'false' + // is standard. If + // face_rotation==face_orientation, + // then one of them is non-standard and we + // have to swap cut_x and cut_y, otherwise no + // change is necessary. face_flip has no + // influence. however, in order to keep the + // interface consistent with other functions, + // we still include it as an argument to this + // function const RefinementCase std_face_ref = (face_orientation==face_rotation) ? flip[face_refinement_case] : face_refinement_case; static const RefinementCase face_to_cell[3][4]= @@ -674,7 +674,7 @@ GeometryInfo<2>::min_cell_refinement_case_for_line_refinement(const unsigned int { const unsigned int dim = 2; Assert(line_no::lines_per_cell, - ExcIndexRange(line_no, 0, GeometryInfo::lines_per_cell)); + ExcIndexRange(line_no, 0, GeometryInfo::lines_per_cell)); return (line_no/2) ? RefinementCase<2>::cut_x : RefinementCase<2>::cut_y; } @@ -686,7 +686,7 @@ GeometryInfo<3>::min_cell_refinement_case_for_line_refinement(const unsigned int { const unsigned int dim=3; Assert(line_no::lines_per_cell, - ExcIndexRange(line_no, 0, GeometryInfo::lines_per_cell)); + ExcIndexRange(line_no, 0, GeometryInfo::lines_per_cell)); static const RefinementCase ref_cases[6]= {RefinementCase::cut_y, // lines 0 and 1 @@ -704,51 +704,51 @@ GeometryInfo<3>::min_cell_refinement_case_for_line_refinement(const unsigned int template <> unsigned int GeometryInfo<3>::standard_to_real_face_vertex(const unsigned int vertex, - const bool face_orientation, - const bool face_flip, - const bool face_rotation) + const bool face_orientation, + const bool face_flip, + const bool face_rotation) { Assert(vertex::vertices_per_face, - ExcIndexRange(vertex,0,GeometryInfo<3>::vertices_per_face)); + ExcIndexRange(vertex,0,GeometryInfo<3>::vertices_per_face)); - // set up a table to make sure that - // we handle non-standard faces correctly + // set up a table to make sure that + // we handle non-standard faces correctly // // so set up a table that for each vertex (of // a quad in standard position) describes // which vertex to take - // - // first index: four vertices 0...3 - // - // second index: face_orientation; 0: - // opposite normal, 1: standard - // - // third index: face_flip; 0: standard, 1: - // face rotated by 180 degrees - // - // forth index: face_rotation: 0: standard, - // 1: face rotated by 90 degrees + // + // first index: four vertices 0...3 + // + // second index: face_orientation; 0: + // opposite normal, 1: standard + // + // third index: face_flip; 0: standard, 1: + // face rotated by 180 degrees + // + // forth index: face_rotation: 0: standard, + // 1: face rotated by 90 degrees static const unsigned int vertex_translation[4][2][2][2] = { { { { 0, 2 }, // vertex 0, face_orientation=false, face_flip=false, face_rotation=false and true - { 3, 1 }}, // vertex 0, face_orientation=false, face_flip=true, face_rotation=false and true - { { 0, 2 }, // vertex 0, face_orientation=true, face_flip=false, face_rotation=false and true - { 3, 1 }}},// vertex 0, face_orientation=true, face_flip=true, face_rotation=false and true + { 3, 1 }}, // vertex 0, face_orientation=false, face_flip=true, face_rotation=false and true + { { 0, 2 }, // vertex 0, face_orientation=true, face_flip=false, face_rotation=false and true + { 3, 1 }}},// vertex 0, face_orientation=true, face_flip=true, face_rotation=false and true { { { 2, 3 }, // vertex 1 ... - { 1, 0 }}, - { { 1, 0 }, - { 2, 3 }}}, + { 1, 0 }}, + { { 1, 0 }, + { 2, 3 }}}, { { { 1, 0 }, // vertex 2 ... - { 2, 3 }}, - { { 2, 3 }, - { 1, 0 }}}, + { 2, 3 }}, + { { 2, 3 }, + { 1, 0 }}}, { { { 3, 1 }, // vertex 3 ... - { 0, 2 }}, - { { 3, 1 }, - { 0, 2 }}}}; + { 0, 2 }}, + { { 3, 1 }, + { 0, 2 }}}}; return vertex_translation[vertex][face_orientation][face_flip][face_rotation]; } @@ -758,13 +758,13 @@ GeometryInfo<3>::standard_to_real_face_vertex(const unsigned int vertex, template unsigned int GeometryInfo::standard_to_real_face_vertex(const unsigned int vertex, - const bool, - const bool, - const bool) + const bool, + const bool, + const bool) { Assert(dim>1, ExcImpossibleInDim(dim)); Assert(vertex::vertices_per_face, - ExcIndexRange(vertex,0,GeometryInfo::vertices_per_face)); + ExcIndexRange(vertex,0,GeometryInfo::vertices_per_face)); return vertex; } @@ -773,51 +773,51 @@ GeometryInfo::standard_to_real_face_vertex(const unsigned int vertex, template <> unsigned int GeometryInfo<3>::real_to_standard_face_vertex(const unsigned int vertex, - const bool face_orientation, - const bool face_flip, - const bool face_rotation) + const bool face_orientation, + const bool face_flip, + const bool face_rotation) { Assert(vertex::vertices_per_face, - ExcIndexRange(vertex,0,GeometryInfo<3>::vertices_per_face)); + ExcIndexRange(vertex,0,GeometryInfo<3>::vertices_per_face)); - // set up a table to make sure that - // we handle non-standard faces correctly + // set up a table to make sure that + // we handle non-standard faces correctly // // so set up a table that for each vertex (of // a quad in standard position) describes // which vertex to take - // - // first index: four vertices 0...3 - // - // second index: face_orientation; 0: - // opposite normal, 1: standard - // - // third index: face_flip; 0: standard, 1: - // face rotated by 180 degrees - // - // forth index: face_rotation: 0: standard, - // 1: face rotated by 90 degrees + // + // first index: four vertices 0...3 + // + // second index: face_orientation; 0: + // opposite normal, 1: standard + // + // third index: face_flip; 0: standard, 1: + // face rotated by 180 degrees + // + // forth index: face_rotation: 0: standard, + // 1: face rotated by 90 degrees static const unsigned int vertex_translation[4][2][2][2] = { { { { 0, 2 }, // vertex 0, face_orientation=false, face_flip=false, face_rotation=false and true - { 3, 1 }}, // vertex 0, face_orientation=false, face_flip=true, face_rotation=false and true - { { 0, 1 }, // vertex 0, face_orientation=true, face_flip=false, face_rotation=false and true - { 3, 2 }}},// vertex 0, face_orientation=true, face_flip=true, face_rotation=false and true + { 3, 1 }}, // vertex 0, face_orientation=false, face_flip=true, face_rotation=false and true + { { 0, 1 }, // vertex 0, face_orientation=true, face_flip=false, face_rotation=false and true + { 3, 2 }}},// vertex 0, face_orientation=true, face_flip=true, face_rotation=false and true { { { 2, 3 }, // vertex 1 ... - { 1, 0 }}, - { { 1, 3 }, - { 2, 0 }}}, + { 1, 0 }}, + { { 1, 3 }, + { 2, 0 }}}, { { { 1, 0 }, // vertex 2 ... - { 2, 3 }}, - { { 2, 0 }, - { 1, 3 }}}, + { 2, 3 }}, + { { 2, 0 }, + { 1, 3 }}}, { { { 3, 1 }, // vertex 3 ... - { 0, 2 }}, - { { 3, 2 }, - { 0, 1 }}}}; + { 0, 2 }}, + { { 3, 2 }, + { 0, 1 }}}}; return vertex_translation[vertex][face_orientation][face_flip][face_rotation]; } @@ -827,13 +827,13 @@ GeometryInfo<3>::real_to_standard_face_vertex(const unsigned int vertex, template unsigned int GeometryInfo::real_to_standard_face_vertex(const unsigned int vertex, - const bool, - const bool, - const bool) + const bool, + const bool, + const bool) { Assert(dim>1, ExcImpossibleInDim(dim)); Assert(vertex::vertices_per_face, - ExcIndexRange(vertex,0,GeometryInfo::vertices_per_face)); + ExcIndexRange(vertex,0,GeometryInfo::vertices_per_face)); return vertex; } @@ -842,51 +842,51 @@ GeometryInfo::real_to_standard_face_vertex(const unsigned int vertex, template <> unsigned int GeometryInfo<3>::standard_to_real_face_line(const unsigned int line, - const bool face_orientation, - const bool face_flip, - const bool face_rotation) + const bool face_orientation, + const bool face_flip, + const bool face_rotation) { Assert(line::lines_per_face, - ExcIndexRange(line,0,GeometryInfo<3>::lines_per_face)); + ExcIndexRange(line,0,GeometryInfo<3>::lines_per_face)); - // make sure we handle + // make sure we handle // non-standard faces correctly // // so set up a table that for each line (of a // quad) describes which line to take - // - // first index: four lines 0...3 - // - // second index: face_orientation; 0: - // opposite normal, 1: standard - // - // third index: face_flip; 0: standard, 1: - // face rotated by 180 degrees - // - // forth index: face_rotation: 0: standard, - // 1: face rotated by 90 degrees + // + // first index: four lines 0...3 + // + // second index: face_orientation; 0: + // opposite normal, 1: standard + // + // third index: face_flip; 0: standard, 1: + // face rotated by 180 degrees + // + // forth index: face_rotation: 0: standard, + // 1: face rotated by 90 degrees static const unsigned int line_translation[4][2][2][2] = { { { { 2, 0 }, // line 0, face_orientation=false, face_flip=false, face_rotation=false and true - { 3, 1 }}, // line 0, face_orientation=false, face_flip=true, face_rotation=false and true - { { 0, 3 }, // line 0, face_orientation=true, face_flip=false, face_rotation=false and true - { 1, 2 }}},// line 0, face_orientation=true, face_flip=true, face_rotation=false and true + { 3, 1 }}, // line 0, face_orientation=false, face_flip=true, face_rotation=false and true + { { 0, 3 }, // line 0, face_orientation=true, face_flip=false, face_rotation=false and true + { 1, 2 }}},// line 0, face_orientation=true, face_flip=true, face_rotation=false and true { { { 3, 1 }, // line 1 ... - { 2, 0 }}, - { { 1, 2 }, - { 0, 3 }}}, + { 2, 0 }}, + { { 1, 2 }, + { 0, 3 }}}, { { { 0, 3 }, // line 2 ... - { 1, 2 }}, - { { 2, 0 }, - { 3, 1 }}}, + { 1, 2 }}, + { { 2, 0 }, + { 3, 1 }}}, { { { 1, 2 }, // line 3 ... - { 0, 3 }}, - { { 3, 1 }, - { 2, 0 }}}}; + { 0, 3 }}, + { { 3, 1 }, + { 2, 0 }}}}; return line_translation[line][face_orientation][face_flip][face_rotation]; } @@ -896,9 +896,9 @@ GeometryInfo<3>::standard_to_real_face_line(const unsigned int line, template unsigned int GeometryInfo::standard_to_real_face_line(const unsigned int line, - const bool, - const bool, - const bool) + const bool, + const bool, + const bool) { Assert(false, ExcNotImplemented()); return line; @@ -909,51 +909,51 @@ GeometryInfo::standard_to_real_face_line(const unsigned int line, template <> unsigned int GeometryInfo<3>::real_to_standard_face_line(const unsigned int line, - const bool face_orientation, - const bool face_flip, - const bool face_rotation) + const bool face_orientation, + const bool face_flip, + const bool face_rotation) { Assert(line::lines_per_face, - ExcIndexRange(line,0,GeometryInfo<3>::lines_per_face)); + ExcIndexRange(line,0,GeometryInfo<3>::lines_per_face)); - // make sure we handle + // make sure we handle // non-standard faces correctly // // so set up a table that for each line (of a // quad) describes which line to take - // - // first index: four lines 0...3 - // - // second index: face_orientation; 0: - // opposite normal, 1: standard - // - // third index: face_flip; 0: standard, 1: - // face rotated by 180 degrees - // - // forth index: face_rotation: 0: standard, - // 1: face rotated by 90 degrees + // + // first index: four lines 0...3 + // + // second index: face_orientation; 0: + // opposite normal, 1: standard + // + // third index: face_flip; 0: standard, 1: + // face rotated by 180 degrees + // + // forth index: face_rotation: 0: standard, + // 1: face rotated by 90 degrees static const unsigned int line_translation[4][2][2][2] = { { { { 2, 0 }, // line 0, face_orientation=false, face_flip=false, face_rotation=false and true - { 3, 1 }}, // line 0, face_orientation=false, face_flip=true, face_rotation=false and true - { { 0, 2 }, // line 0, face_orientation=true, face_flip=false, face_rotation=false and true - { 1, 3 }}},// line 0, face_orientation=true, face_flip=true, face_rotation=false and true + { 3, 1 }}, // line 0, face_orientation=false, face_flip=true, face_rotation=false and true + { { 0, 2 }, // line 0, face_orientation=true, face_flip=false, face_rotation=false and true + { 1, 3 }}},// line 0, face_orientation=true, face_flip=true, face_rotation=false and true { { { 3, 1 }, // line 1 ... - { 2, 0 }}, - { { 1, 3 }, - { 0, 2 }}}, + { 2, 0 }}, + { { 1, 3 }, + { 0, 2 }}}, { { { 0, 3 }, // line 2 ... - { 1, 2 }}, - { { 2, 1 }, - { 3, 0 }}}, + { 1, 2 }}, + { { 2, 1 }, + { 3, 0 }}}, { { { 1, 2 }, // line 3 ... - { 0, 3 }}, - { { 3, 0 }, - { 2, 1 }}}}; + { 0, 3 }}, + { { 3, 0 }, + { 2, 1 }}}}; return line_translation[line][face_orientation][face_flip][face_rotation]; } @@ -963,9 +963,9 @@ GeometryInfo<3>::real_to_standard_face_line(const unsigned int line, template unsigned int GeometryInfo::real_to_standard_face_line(const unsigned int line, - const bool, - const bool, - const bool) + const bool, + const bool, + const bool) { Assert(false, ExcNotImplemented()); return line; @@ -976,14 +976,14 @@ GeometryInfo::real_to_standard_face_line(const unsigned int line, template <> unsigned int GeometryInfo<1>::child_cell_on_face (const RefinementCase<1> &, - const unsigned int face, + const unsigned int face, const unsigned int subface, - const bool, const bool, const bool, - const RefinementCase<0> &) + const bool, const bool, const bool, + const RefinementCase<0> &) { Assert (face::child_cell_on_face (const RefinementCase<1> &, template <> unsigned int GeometryInfo<2>::child_cell_on_face (const RefinementCase<2> &ref_case, - const unsigned int face, + const unsigned int face, const unsigned int subface, - const bool, const bool, const bool, - const RefinementCase<1> &) + const bool, const bool, const bool, + const RefinementCase<1> &) { Assert (face::isotropic_refinement][faces_per_cell][max_children_per_face] = {{{0,0},{1,1},{0,1},{0,1}}, // cut_x @@ -1023,229 +1023,229 @@ GeometryInfo<2>::child_cell_on_face (const RefinementCase<2> &ref_case, template <> unsigned int GeometryInfo<3>::child_cell_on_face (const RefinementCase<3> &ref_case, - const unsigned int face, - const unsigned int subface, - const bool face_orientation, - const bool face_flip, - const bool face_rotation, - const RefinementCase<2> &face_ref_case) + const unsigned int face, + const unsigned int subface, + const bool face_orientation, + const bool face_flip, + const bool face_rotation, + const RefinementCase<2> &face_ref_case) { const unsigned int dim = 3; Assert (ref_case>RefinementCase::no_refinement, ExcMessage("Cell has no children.")); Assert (face::n_children(face_ref_case) || - (subface==0 && face_ref_case==RefinementCase::no_refinement), - ExcIndexRange(subface, 0, GeometryInfo<2>::n_children(face_ref_case))); + (subface==0 && face_ref_case==RefinementCase::no_refinement), + ExcIndexRange(subface, 0, GeometryInfo<2>::n_children(face_ref_case))); - // invalid number used for invalid cases, - // e.g. when the children are more refined at - // a given face than the face itself + // invalid number used for invalid cases, + // e.g. when the children are more refined at + // a given face than the face itself static const unsigned int e=invalid_unsigned_int; - // the whole process of finding a child cell - // at a given subface considering the - // possibly anisotropic refinement cases of - // the cell and the face as well as - // orientation, flip and rotation of the face - // is quite complicated. thus, we break it - // down into several steps. - - // first step: convert the given face refine - // case to a face refine case concerning the - // face in standard orientation (, flip and - // rotation). This only affects cut_x and - // cut_y + // the whole process of finding a child cell + // at a given subface considering the + // possibly anisotropic refinement cases of + // the cell and the face as well as + // orientation, flip and rotation of the face + // is quite complicated. thus, we break it + // down into several steps. + + // first step: convert the given face refine + // case to a face refine case concerning the + // face in standard orientation (, flip and + // rotation). This only affects cut_x and + // cut_y static const RefinementCase flip[4]= {RefinementCase::no_refinement, RefinementCase::cut_y, RefinementCase::cut_x, RefinementCase::cut_xy}; - // for face_orientation, 'true' is the - // default value whereas for face_rotation, - // 'false' is standard. If - // face_rotation==face_orientation, - // then one of them is non-standard and we - // have to swap cut_x and cut_y, otherwise no - // change is necessary. + // for face_orientation, 'true' is the + // default value whereas for face_rotation, + // 'false' is standard. If + // face_rotation==face_orientation, + // then one of them is non-standard and we + // have to swap cut_x and cut_y, otherwise no + // change is necessary. const RefinementCase std_face_ref = (face_orientation==face_rotation) ? flip[face_ref_case] : face_ref_case; - // second step: convert the given subface - // index to the one for a standard face - // respecting face_orientation, face_flip and - // face_rotation + // second step: convert the given subface + // index to the one for a standard face + // respecting face_orientation, face_flip and + // face_rotation - // first index: face_ref_case - // second index: face_orientation - // third index: face_flip - // forth index: face_rotation - // fifth index: subface index + // first index: face_ref_case + // second index: face_orientation + // third index: face_flip + // forth index: face_rotation + // fifth index: subface index static const unsigned int subface_exchange[4][2][2][2][4]= { - // no_refinement (subface 0 stays 0, - // all others are invalid) - {{{{0,e,e,e}, - {0,e,e,e}}, - {{0,e,e,e}, - {0,e,e,e}}}, - {{{0,e,e,e}, - {0,e,e,e}}, - {{0,e,e,e}, - {0,e,e,e}}}}, - // cut_x (here, if the face is only - // rotated OR only falsely oriented, - // then subface 0 of the non-standard - // face does NOT correspond to one of - // the subfaces of a standard - // face. Thus we indicate the subface - // which is located at the lower left - // corner (the origin of the face's - // local coordinate system) with - // '0'. The rest of this issue is - // taken care of using the above - // conversion to a 'standard face - // refine case') - {{{{0,1,e,e}, - {0,1,e,e}}, - {{1,0,e,e}, - {1,0,e,e}}}, - {{{0,1,e,e}, - {0,1,e,e}}, - {{1,0,e,e}, - {1,0,e,e}}}}, - // cut_y (the same applies as for - // cut_x) - {{{{0,1,e,e}, - {1,0,e,e}}, - {{1,0,e,e}, - {0,1,e,e}}}, - {{{0,1,e,e}, - {1,0,e,e}}, - {{1,0,e,e}, - {0,1,e,e}}}}, - // cut_xyz: this information is - // identical to the information - // returned by - // GeometryInfo<3>::real_to_standard_face_vertex() - {{{{0,2,1,3}, // face_orientation=false, face_flip=false, face_rotation=false, subfaces 0,1,2,3 - {2,3,0,1}}, // face_orientation=false, face_flip=false, face_rotation=true, subfaces 0,1,2,3 - {{3,1,2,0}, // face_orientation=false, face_flip=true, face_rotation=false, subfaces 0,1,2,3 - {1,0,3,2}}}, // face_orientation=false, face_flip=true, face_rotation=true, subfaces 0,1,2,3 - {{{0,1,2,3}, // face_orientation=true, face_flip=false, face_rotation=false, subfaces 0,1,2,3 - {1,3,0,2}}, // face_orientation=true, face_flip=false, face_rotation=true, subfaces 0,1,2,3 - {{3,2,1,0}, // face_orientation=true, face_flip=true, face_rotation=false, subfaces 0,1,2,3 - {2,0,3,1}}}}};// face_orientation=true, face_flip=true, face_rotation=true, subfaces 0,1,2,3 + // no_refinement (subface 0 stays 0, + // all others are invalid) + {{{{0,e,e,e}, + {0,e,e,e}}, + {{0,e,e,e}, + {0,e,e,e}}}, + {{{0,e,e,e}, + {0,e,e,e}}, + {{0,e,e,e}, + {0,e,e,e}}}}, + // cut_x (here, if the face is only + // rotated OR only falsely oriented, + // then subface 0 of the non-standard + // face does NOT correspond to one of + // the subfaces of a standard + // face. Thus we indicate the subface + // which is located at the lower left + // corner (the origin of the face's + // local coordinate system) with + // '0'. The rest of this issue is + // taken care of using the above + // conversion to a 'standard face + // refine case') + {{{{0,1,e,e}, + {0,1,e,e}}, + {{1,0,e,e}, + {1,0,e,e}}}, + {{{0,1,e,e}, + {0,1,e,e}}, + {{1,0,e,e}, + {1,0,e,e}}}}, + // cut_y (the same applies as for + // cut_x) + {{{{0,1,e,e}, + {1,0,e,e}}, + {{1,0,e,e}, + {0,1,e,e}}}, + {{{0,1,e,e}, + {1,0,e,e}}, + {{1,0,e,e}, + {0,1,e,e}}}}, + // cut_xyz: this information is + // identical to the information + // returned by + // GeometryInfo<3>::real_to_standard_face_vertex() + {{{{0,2,1,3}, // face_orientation=false, face_flip=false, face_rotation=false, subfaces 0,1,2,3 + {2,3,0,1}}, // face_orientation=false, face_flip=false, face_rotation=true, subfaces 0,1,2,3 + {{3,1,2,0}, // face_orientation=false, face_flip=true, face_rotation=false, subfaces 0,1,2,3 + {1,0,3,2}}}, // face_orientation=false, face_flip=true, face_rotation=true, subfaces 0,1,2,3 + {{{0,1,2,3}, // face_orientation=true, face_flip=false, face_rotation=false, subfaces 0,1,2,3 + {1,3,0,2}}, // face_orientation=true, face_flip=false, face_rotation=true, subfaces 0,1,2,3 + {{3,2,1,0}, // face_orientation=true, face_flip=true, face_rotation=false, subfaces 0,1,2,3 + {2,0,3,1}}}}};// face_orientation=true, face_flip=true, face_rotation=true, subfaces 0,1,2,3 const unsigned int std_subface=subface_exchange - [face_ref_case] - [face_orientation] - [face_flip] - [face_rotation] - [subface]; + [face_ref_case] + [face_orientation] + [face_flip] + [face_rotation] + [subface]; Assert (std_subface!=e, ExcInternalError()); - // third step: these are the children, which - // can be found at the given subfaces of an - // isotropically refined (standard) face - // - // first index: (refinement_case-1) - // second index: face_index - // third index: subface_index (isotropic refinement) + // third step: these are the children, which + // can be found at the given subfaces of an + // isotropically refined (standard) face + // + // first index: (refinement_case-1) + // second index: face_index + // third index: subface_index (isotropic refinement) static const unsigned int iso_children[RefinementCase::cut_xyz][faces_per_cell][max_children_per_face] = { - // cut_x - {{0, 0, 0, 0}, // face 0, subfaces 0,1,2,3 - {1, 1, 1, 1}, // face 1, subfaces 0,1,2,3 - {0, 0, 1, 1}, // face 2, subfaces 0,1,2,3 - {0, 0, 1, 1}, // face 3, subfaces 0,1,2,3 - {0, 1, 0, 1}, // face 4, subfaces 0,1,2,3 - {0, 1, 0, 1}}, // face 5, subfaces 0,1,2,3 - // cut_y - {{0, 1, 0, 1}, - {0, 1, 0, 1}, - {0, 0, 0, 0}, - {1, 1, 1, 1}, - {0, 0, 1, 1}, - {0, 0, 1, 1}}, - // cut_xy - {{0, 2, 0, 2}, - {1, 3, 1, 3}, - {0, 0, 1, 1}, - {2, 2, 3, 3}, - {0, 1, 2, 3}, - {0, 1, 2, 3}}, - // cut_z - {{0, 0, 1, 1}, - {0, 0, 1, 1}, - {0, 1, 0, 1}, - {0, 1, 0, 1}, - {0, 0, 0, 0}, - {1, 1, 1, 1}}, - // cut_xz - {{0, 0, 1, 1}, - {2, 2, 3, 3}, - {0, 1, 2, 3}, - {0, 1, 2, 3}, - {0, 2, 0, 2}, - {1, 3, 1, 3}}, - // cut_yz - {{0, 1, 2, 3}, - {0, 1, 2, 3}, - {0, 2, 0, 2}, - {1, 3, 1, 3}, - {0, 0, 1, 1}, - {2, 2, 3, 3}}, - // cut_xyz - {{0, 2, 4, 6}, - {1, 3, 5, 7}, - {0, 4, 1, 5}, - {2, 6, 3, 7}, - {0, 1, 2, 3}, - {4, 5, 6, 7}}}; - - // forth step: check, whether the given face - // refine case is valid for the given cell - // refine case. this is the case, if the - // given face refine case is at least as - // refined as the face is for the given cell - // refine case - - // note, that we are considering standard - // face refinement cases here and thus must - // not pass the given orientation, flip and - // rotation flags + // cut_x + {{0, 0, 0, 0}, // face 0, subfaces 0,1,2,3 + {1, 1, 1, 1}, // face 1, subfaces 0,1,2,3 + {0, 0, 1, 1}, // face 2, subfaces 0,1,2,3 + {0, 0, 1, 1}, // face 3, subfaces 0,1,2,3 + {0, 1, 0, 1}, // face 4, subfaces 0,1,2,3 + {0, 1, 0, 1}}, // face 5, subfaces 0,1,2,3 + // cut_y + {{0, 1, 0, 1}, + {0, 1, 0, 1}, + {0, 0, 0, 0}, + {1, 1, 1, 1}, + {0, 0, 1, 1}, + {0, 0, 1, 1}}, + // cut_xy + {{0, 2, 0, 2}, + {1, 3, 1, 3}, + {0, 0, 1, 1}, + {2, 2, 3, 3}, + {0, 1, 2, 3}, + {0, 1, 2, 3}}, + // cut_z + {{0, 0, 1, 1}, + {0, 0, 1, 1}, + {0, 1, 0, 1}, + {0, 1, 0, 1}, + {0, 0, 0, 0}, + {1, 1, 1, 1}}, + // cut_xz + {{0, 0, 1, 1}, + {2, 2, 3, 3}, + {0, 1, 2, 3}, + {0, 1, 2, 3}, + {0, 2, 0, 2}, + {1, 3, 1, 3}}, + // cut_yz + {{0, 1, 2, 3}, + {0, 1, 2, 3}, + {0, 2, 0, 2}, + {1, 3, 1, 3}, + {0, 0, 1, 1}, + {2, 2, 3, 3}}, + // cut_xyz + {{0, 2, 4, 6}, + {1, 3, 5, 7}, + {0, 4, 1, 5}, + {2, 6, 3, 7}, + {0, 1, 2, 3}, + {4, 5, 6, 7}}}; + + // forth step: check, whether the given face + // refine case is valid for the given cell + // refine case. this is the case, if the + // given face refine case is at least as + // refined as the face is for the given cell + // refine case + + // note, that we are considering standard + // face refinement cases here and thus must + // not pass the given orientation, flip and + // rotation flags if ((std_face_ref & face_refinement_case(ref_case, face)) == face_refinement_case(ref_case, face)) { - // all is fine. for anisotropic face - // refine cases, select one of the - // isotropic subfaces which neighbors the - // same child + // all is fine. for anisotropic face + // refine cases, select one of the + // isotropic subfaces which neighbors the + // same child - // first index: (standard) face refine case - // second index: subface index + // first index: (standard) face refine case + // second index: subface index static const unsigned int equivalent_iso_subface[4][4]= - {{0,e,e,e}, // no_refinement - {0,3,e,e}, // cut_x - {0,3,e,e}, // cut_y - {0,1,2,3}}; // cut_xy + {{0,e,e,e}, // no_refinement + {0,3,e,e}, // cut_x + {0,3,e,e}, // cut_y + {0,1,2,3}}; // cut_xy const unsigned int equ_std_subface - =equivalent_iso_subface[std_face_ref][std_subface]; + =equivalent_iso_subface[std_face_ref][std_subface]; Assert (equ_std_subface!=e, ExcInternalError()); return iso_children[ref_case-1][face][equ_std_subface]; } else { - // the face_ref_case was too coarse, - // throw an error + // the face_ref_case was too coarse, + // throw an error Assert(false, - ExcMessage("The face RefineCase is too coarse " - "for the given cell RefineCase.")); + ExcMessage("The face RefineCase is too coarse " + "for the given cell RefineCase.")); } - // we only get here in case of an error + // we only get here in case of an error return e; } @@ -1254,10 +1254,10 @@ GeometryInfo<3>::child_cell_on_face (const RefinementCase<3> &ref_case, template <> unsigned int GeometryInfo<4>::child_cell_on_face (const RefinementCase<4> &, - const unsigned int, - const unsigned int, - const bool, const bool, const bool, - const RefinementCase<3> &) + const unsigned int, + const unsigned int, + const bool, const bool, const bool, + const RefinementCase<3> &) { Assert(false, ExcNotImplemented()); return invalid_unsigned_int; @@ -1268,7 +1268,7 @@ GeometryInfo<4>::child_cell_on_face (const RefinementCase<4> &, template <> unsigned int GeometryInfo<1>::line_to_cell_vertices (const unsigned int line, - const unsigned int vertex) + const unsigned int vertex) { Assert (line::line_to_cell_vertices (const unsigned int line, template <> unsigned int GeometryInfo<2>::line_to_cell_vertices (const unsigned int line, - const unsigned int vertex) + const unsigned int vertex) { return child_cell_on_face(RefinementCase<2>::isotropic_refinement, line, vertex); } @@ -1290,24 +1290,24 @@ GeometryInfo<2>::line_to_cell_vertices (const unsigned int line, template <> unsigned int GeometryInfo<3>::line_to_cell_vertices (const unsigned int line, - const unsigned int vertex) + const unsigned int vertex) { Assert (line::line_to_cell_vertices (const unsigned int, template <> unsigned int GeometryInfo<1>::face_to_cell_lines (const unsigned int face, - const unsigned int line, - const bool, const bool, const bool) + const unsigned int line, + const bool, const bool, const bool) { Assert (face+1::face_to_cell_lines (const unsigned int face, template <> unsigned int GeometryInfo<2>::face_to_cell_lines (const unsigned int face, - const unsigned int line, - const bool, const bool, const bool) + const unsigned int line, + const bool, const bool, const bool) { Assert (face::face_to_cell_lines (const unsigned int face, template <> unsigned int GeometryInfo<3>::face_to_cell_lines (const unsigned int face, - const unsigned int line, - const bool face_orientation, - const bool face_flip, - const bool face_rotation) + const unsigned int line, + const bool face_orientation, + const bool face_flip, + const bool face_rotation) { Assert (face::face_to_cell_lines (const unsigned int face, template unsigned int GeometryInfo::face_to_cell_lines (const unsigned int, - const unsigned int, - const bool, const bool, const bool) + const unsigned int, + const bool, const bool, const bool) { Assert(false, ExcNotImplemented()); return invalid_unsigned_int; @@ -1394,13 +1394,13 @@ GeometryInfo::face_to_cell_lines (const unsigned int, template unsigned int GeometryInfo::face_to_cell_vertices (const unsigned int face, - const unsigned int vertex, - const bool face_orientation, - const bool face_flip, - const bool face_rotation) + const unsigned int vertex, + const bool face_orientation, + const bool face_flip, + const bool face_rotation) { return child_cell_on_face(RefinementCase::isotropic_refinement, face, vertex, - face_orientation, face_flip, face_rotation); + face_orientation, face_flip, face_rotation); } @@ -1440,70 +1440,70 @@ template double GeometryInfo:: d_linear_shape_function (const Point &xi, - const unsigned int i) + const unsigned int i) { Assert (i < GeometryInfo::vertices_per_cell, - ExcIndexRange (i, 0, GeometryInfo::vertices_per_cell)); + ExcIndexRange (i, 0, GeometryInfo::vertices_per_cell)); switch (dim) { case 1: { - const double x = xi[0]; - switch (i) - { - case 0: - return 1-x; - case 1: - return x; - } + const double x = xi[0]; + switch (i) + { + case 0: + return 1-x; + case 1: + return x; + } } case 2: { - const double x = xi[0]; - const double y = xi[1]; - switch (i) - { - case 0: - return (1-x)*(1-y); - case 1: - return x*(1-y); - case 2: - return (1-x)*y; - case 3: - return x*y; - } + const double x = xi[0]; + const double y = xi[1]; + switch (i) + { + case 0: + return (1-x)*(1-y); + case 1: + return x*(1-y); + case 2: + return (1-x)*y; + case 3: + return x*y; + } } case 3: { - const double x = xi[0]; - const double y = xi[1]; - const double z = xi[2]; - switch (i) - { - case 0: - return (1-x)*(1-y)*(1-z); - case 1: - return x*(1-y)*(1-z); - case 2: - return (1-x)*y*(1-z); - case 3: - return x*y*(1-z); - case 4: - return (1-x)*(1-y)*z; - case 5: - return x*(1-y)*z; - case 6: - return (1-x)*y*z; - case 7: - return x*y*z; - } + const double x = xi[0]; + const double y = xi[1]; + const double z = xi[2]; + switch (i) + { + case 0: + return (1-x)*(1-y)*(1-z); + case 1: + return x*(1-y)*(1-z); + case 2: + return (1-x)*y*(1-z); + case 3: + return x*y*(1-z); + case 4: + return (1-x)*(1-y)*z; + case 5: + return x*(1-y)*z; + case 6: + return (1-x)*y*z; + case 7: + return x*y*z; + } } default: - Assert (false, ExcNotImplemented()); + Assert (false, ExcNotImplemented()); } return -1e9; } @@ -1514,17 +1514,17 @@ template <> Tensor<1,1> GeometryInfo<1>:: d_linear_shape_function_gradient (const Point<1> &, - const unsigned int i) + const unsigned int i) { Assert (i < GeometryInfo<1>::vertices_per_cell, - ExcIndexRange (i, 0, GeometryInfo<1>::vertices_per_cell)); + ExcIndexRange (i, 0, GeometryInfo<1>::vertices_per_cell)); switch (i) { case 0: - return Point<1>(-1.); + return Point<1>(-1.); case 1: - return Point<1>(1.); + return Point<1>(1.); } return Point<1>(-1e9); @@ -1536,23 +1536,23 @@ template <> Tensor<1,2> GeometryInfo<2>:: d_linear_shape_function_gradient (const Point<2> &xi, - const unsigned int i) + const unsigned int i) { Assert (i < GeometryInfo<2>::vertices_per_cell, - ExcIndexRange (i, 0, GeometryInfo<2>::vertices_per_cell)); + ExcIndexRange (i, 0, GeometryInfo<2>::vertices_per_cell)); const double x = xi[0]; const double y = xi[1]; switch (i) { case 0: - return Point<2>(-(1-y),-(1-x)); + return Point<2>(-(1-y),-(1-x)); case 1: - return Point<2>(1-y,-x); + return Point<2>(1-y,-x); case 2: - return Point<2>(-y, 1-x); + return Point<2>(-y, 1-x); case 3: - return Point<2>(y,x); + return Point<2>(y,x); } return Point<2> (-1e9, -1e9); } @@ -1563,10 +1563,10 @@ template <> Tensor<1,3> GeometryInfo<3>:: d_linear_shape_function_gradient (const Point<3> &xi, - const unsigned int i) + const unsigned int i) { Assert (i < GeometryInfo<3>::vertices_per_cell, - ExcIndexRange (i, 0, GeometryInfo<3>::vertices_per_cell)); + ExcIndexRange (i, 0, GeometryInfo<3>::vertices_per_cell)); const double x = xi[0]; const double y = xi[1]; @@ -1574,35 +1574,35 @@ d_linear_shape_function_gradient (const Point<3> &xi, switch (i) { case 0: - return Point<3>(-(1-y)*(1-z), - -(1-x)*(1-z), - -(1-x)*(1-y)); + return Point<3>(-(1-y)*(1-z), + -(1-x)*(1-z), + -(1-x)*(1-y)); case 1: - return Point<3>((1-y)*(1-z), - -x*(1-z), - -x*(1-y)); + return Point<3>((1-y)*(1-z), + -x*(1-z), + -x*(1-y)); case 2: - return Point<3>(-y*(1-z), - (1-x)*(1-z), - -(1-x)*y); + return Point<3>(-y*(1-z), + (1-x)*(1-z), + -(1-x)*y); case 3: - return Point<3>(y*(1-z), - x*(1-z), - -x*y); + return Point<3>(y*(1-z), + x*(1-z), + -x*y); case 4: - return Point<3>(-(1-y)*z, - -(1-x)*z, - (1-x)*(1-y)); + return Point<3>(-(1-y)*z, + -(1-x)*z, + (1-x)*(1-y)); case 5: - return Point<3>((1-y)*z, - -x*z, - x*(1-y)); + return Point<3>((1-y)*z, + -x*z, + x*(1-y)); case 6: - return Point<3>(-y*z, - (1-x)*z, - (1-x)*y); + return Point<3>(-y*z, + (1-x)*z, + (1-x)*y); case 7: - return Point<3>(y*z, x*z, x*y); + return Point<3>(y*z, x*z, x*y); } return Point<3> (-1e9, -1e9, -1e9); @@ -1614,7 +1614,7 @@ template Tensor<1,dim> GeometryInfo:: d_linear_shape_function_gradient (const Point &, - const unsigned int) + const unsigned int) { Assert (false, ExcNotImplemented()); return Tensor<1,dim>(); @@ -1628,10 +1628,10 @@ namespace internal { namespace GeometryInfo { - // wedge product of a single - // vector in 2d: we just have to - // rotate it by 90 degrees to the - // right + // wedge product of a single + // vector in 2d: we just have to + // rotate it by 90 degrees to the + // right inline Tensor<1,2> wedge_product (const Tensor<1,2> (&derivative)[1]) @@ -1644,8 +1644,8 @@ namespace internal } - // wedge product of 2 vectors in - // 3d is the cross product + // wedge product of 2 vectors in + // 3d is the cross product inline Tensor<1,3> wedge_product (const Tensor<1,3> (&derivative)[2]) @@ -1657,9 +1657,9 @@ namespace internal } - // wedge product of dim vectors - // in dim-d: that's the - // determinant of the matrix + // wedge product of dim vectors + // in dim-d: that's the + // determinant of the matrix template inline Tensor<0,dim> @@ -1667,7 +1667,7 @@ namespace internal { Tensor<2,dim> jacobian; for (unsigned int i=0; i *forms) #endif { - // for each of the vertices, - // compute the alternating form - // of the mapped unit - // vectors. consider for - // example the case of a quad - // in spacedim==3: to do so, we - // need to see how the - // infinitesimal vectors - // (d\xi_1,0) and (0,d\xi_2) - // are transformed into - // spacedim-dimensional space - // and then form their cross - // product (i.e. the wedge product - // of two vectors). to this end, note - // that - // \vec x = sum_i \vec v_i phi_i(\vec xi) - // so the transformed vectors are - // [x(\xi+(d\xi_1,0))-x(\xi)]/d\xi_1 - // and - // [x(\xi+(0,d\xi_2))-x(\xi)]/d\xi_2 - // which boils down to the columns - // of the 3x2 matrix \grad_\xi x(\xi) - // - // a similar reasoning would - // hold for all dim,spacedim - // pairs -- we only have to - // compute the wedge product of - // the columns of the - // derivatives + // for each of the vertices, + // compute the alternating form + // of the mapped unit + // vectors. consider for + // example the case of a quad + // in spacedim==3: to do so, we + // need to see how the + // infinitesimal vectors + // (d\xi_1,0) and (0,d\xi_2) + // are transformed into + // spacedim-dimensional space + // and then form their cross + // product (i.e. the wedge product + // of two vectors). to this end, note + // that + // \vec x = sum_i \vec v_i phi_i(\vec xi) + // so the transformed vectors are + // [x(\xi+(d\xi_1,0))-x(\xi)]/d\xi_1 + // and + // [x(\xi+(0,d\xi_2))-x(\xi)]/d\xi_2 + // which boils down to the columns + // of the 3x2 matrix \grad_\xi x(\xi) + // + // a similar reasoning would + // hold for all dim,spacedim + // pairs -- we only have to + // compute the wedge product of + // the columns of the + // derivatives for (unsigned int i=0; i derivatives[dim]; for (unsigned int j=0; j grad_phi_j - = d_linear_shape_function_gradient (unit_cell_vertex(i), - j); - for (unsigned int l=0; l grad_phi_j + = d_linear_shape_function_gradient (unit_cell_vertex(i), + j); + for (unsigned int l=0; l::iterator - i = ranges.begin(); + i = ranges.begin(); i != ranges.end(); ) { std::vector::iterator - next = i; + next = i; ++next; unsigned int first_index = i->begin; unsigned int last_index = i->end; - // see if we can merge any of - // the following ranges + // see if we can merge any of + // the following ranges bool can_merge = false; while (next != ranges.end() && - (next->begin <= last_index)) - { - last_index = std::max (last_index, next->end); - ++next; - can_merge = true; - } + (next->begin <= last_index)) + { + last_index = std::max (last_index, next->end); + ++next; + can_merge = true; + } if (can_merge == true) - { - // delete the old ranges - // and insert the new range - // in place of the previous - // one - *i = Range(first_index, last_index); - i = ranges.erase (i+1, next); - } + { + // delete the old ranges + // and insert the new range + // in place of the previous + // one + *i = Range(first_index, last_index); + i = ranges.erase (i+1, next); + } else - ++i; + ++i; } - // now compute indices within set and the - // range with most elements + // now compute indices within set and the + // range with most elements unsigned int next_index = 0, largest_range_size = 0; for (std::vector::iterator - i = ranges.begin(); + i = ranges.begin(); i != ranges.end(); ++i) { @@ -83,18 +83,18 @@ IndexSet::do_compress () const i->nth_index_in_set = next_index; next_index += (i->end - i->begin); if (i->end - i->begin > largest_range_size) - { - largest_range_size = i->end - i->begin; - largest_range = i - ranges.begin(); - } + { + largest_range_size = i->end - i->begin; + largest_range = i - ranges.begin(); + } } is_compressed = true; - // check that next_index is - // correct. needs to be after the - // previous statement because we - // otherwise will get into an - // endless loop + // check that next_index is + // correct. needs to be after the + // previous statement because we + // otherwise will get into an + // endless loop Assert (next_index == n_elements(), ExcInternalError()); } @@ -104,58 +104,58 @@ IndexSet IndexSet::operator & (const IndexSet &is) const { Assert (size() == is.size(), - ExcDimensionMismatch (size(), is.size())); + ExcDimensionMismatch (size(), is.size())); compress (); is.compress (); std::vector::const_iterator r1 = ranges.begin(), - r2 = is.ranges.begin(); + r2 = is.ranges.begin(); IndexSet result (size()); while ((r1 != ranges.end()) - && - (r2 != is.ranges.end())) + && + (r2 != is.ranges.end())) { - // if r1 and r2 do not overlap - // at all, then move the - // pointer that sits to the - // left of the other up by one + // if r1 and r2 do not overlap + // at all, then move the + // pointer that sits to the + // left of the other up by one if (r1->end <= r2->begin) - ++r1; + ++r1; else if (r2->end <= r1->begin) - ++r2; + ++r2; else - { - // the ranges must overlap - // somehow - Assert (((r1->begin <= r2->begin) && - (r1->end > r2->begin)) - || - ((r2->begin <= r1->begin) && - (r2->end > r1->begin)), - ExcInternalError()); - - // add the overlapping - // range to the result - result.add_range (std::max (r1->begin, - r2->begin), - std::min (r1->end, - r2->end)); - - // now move that iterator - // that ends earlier one - // up. note that it has to - // be this one because a - // subsequent range may - // still have a chance of - // overlapping with the - // range that ends later - if (r1->end <= r2->end) - ++r1; - else - ++r2; - } + { + // the ranges must overlap + // somehow + Assert (((r1->begin <= r2->begin) && + (r1->end > r2->begin)) + || + ((r2->begin <= r1->begin) && + (r2->end > r1->begin)), + ExcInternalError()); + + // add the overlapping + // range to the result + result.add_range (std::max (r1->begin, + r2->begin), + std::min (r1->end, + r2->end)); + + // now move that iterator + // that ends earlier one + // up. note that it has to + // be this one because a + // subsequent range may + // still have a chance of + // overlapping with the + // range that ends later + if (r1->end <= r2->end) + ++r1; + else + ++r2; + } } result.compress (); @@ -175,12 +175,12 @@ IndexSet::n_intervals () const IndexSet IndexSet::get_view (const unsigned int begin, - const unsigned int end) const + const unsigned int end) const { Assert (begin <= end, - ExcMessage ("End index needs to be larger or equal to begin index!")); + ExcMessage ("End index needs to be larger or equal to begin index!")); Assert (end <= size(), - ExcMessage ("Given range exceeds index set dimension")); + ExcMessage ("Given range exceeds index set dimension")); IndexSet result (end-begin); std::vector::const_iterator r1 = ranges.begin(); @@ -188,16 +188,16 @@ IndexSet::get_view (const unsigned int begin, while (r1 != ranges.end()) { if ((r1->end > begin) - && - (r1->begin < end)) - { - result.add_range (std::max(r1->begin, begin)-begin, - std::min(r1->end, end)-begin); + && + (r1->begin < end)) + { + result.add_range (std::max(r1->begin, begin)-begin, + std::min(r1->end, end)-begin); - } + } else - if (r1->begin >= end) - break; + if (r1->begin >= end) + break; ++r1; } @@ -243,13 +243,13 @@ IndexSet::block_write(std::ostream & out) const { Assert (out, ExcIO()); out.write(reinterpret_cast(&index_space_size), - sizeof(index_space_size)); + sizeof(index_space_size)); size_t n_ranges = ranges.size(); out.write(reinterpret_cast(&n_ranges), - sizeof(n_ranges)); + sizeof(n_ranges)); if (ranges.empty() == false) out.write (reinterpret_cast(&*ranges.begin()), - ranges.size() * sizeof(Range)); + ranges.size() * sizeof(Range)); Assert (out, ExcIO()); } @@ -260,13 +260,13 @@ IndexSet::block_read(std::istream & in) size_t n_ranges; in.read(reinterpret_cast(&size), sizeof(size)); in.read(reinterpret_cast(&n_ranges), sizeof(n_ranges)); - // we have to clear ranges first + // we have to clear ranges first ranges.clear(); set_size(size); ranges.resize(n_ranges, Range(0,0)); if (n_ranges) in.read(reinterpret_cast(&*ranges.begin()), - ranges.size() * sizeof(Range)); + ranges.size() * sizeof(Range)); } @@ -279,11 +279,11 @@ IndexSet::subtract_set (const IndexSet & other) is_compressed = false; - // we save new ranges to be added to our - // IndexSet in an temporary list and add - // all of them in one go at the end. This - // is necessary because a growing ranges - // vector invalidates iterators. + // we save new ranges to be added to our + // IndexSet in an temporary list and add + // all of them in one go at the end. This + // is necessary because a growing ranges + // vector invalidates iterators. std::list temp_list; std::vector::iterator own_it = ranges.begin(); @@ -291,58 +291,58 @@ IndexSet::subtract_set (const IndexSet & other) while (own_it != ranges.end() && other_it != other.ranges.end()) { - //advance own iterator until we get an - //overlap + //advance own iterator until we get an + //overlap if (own_it->end <= other_it->begin) - { - ++own_it; - continue; - } - //we are done with other_it, so advance + { + ++own_it; + continue; + } + //we are done with other_it, so advance if (own_it->begin >= other_it->end) - { - ++other_it; - continue; - } - - //Now own_it and other_it overlap. - //First save the part of own_it that is - //before other_it (if not empty). + { + ++other_it; + continue; + } + + //Now own_it and other_it overlap. + //First save the part of own_it that is + //before other_it (if not empty). if (own_it->begin < other_it->begin) - { - Range r(own_it->begin, other_it->begin); - r.nth_index_in_set = 0; //fix warning of unused variable - temp_list.push_back(r); - } - // change own_it to the sub range - // behind other_it. Do not delete - // own_it in any case. As removal would - // invalidate iterators, we just shrink - // the range to an empty one. + { + Range r(own_it->begin, other_it->begin); + r.nth_index_in_set = 0; //fix warning of unused variable + temp_list.push_back(r); + } + // change own_it to the sub range + // behind other_it. Do not delete + // own_it in any case. As removal would + // invalidate iterators, we just shrink + // the range to an empty one. own_it->begin = other_it->end; if (own_it->begin > own_it->end) - { - own_it->begin = own_it->end; - ++own_it; - } - - // continue without advancing - // iterators, the right one will be - // advanced next. + { + own_it->begin = own_it->end; + ++own_it; + } + + // continue without advancing + // iterators, the right one will be + // advanced next. } - // Now delete all empty ranges we might - // have created. + // Now delete all empty ranges we might + // have created. for (std::vector::iterator it = ranges.begin(); it != ranges.end(); ) { if (it->begin >= it->end) - it = ranges.erase(it); + it = ranges.erase(it); else - ++it; + ++it; } - // done, now add the temporary ranges + // done, now add the temporary ranges for (std::list::iterator it = temp_list.begin(); it != temp_list.end(); ++it) @@ -376,18 +376,18 @@ void IndexSet::fill_index_vector(std::vector & indices) const Epetra_Map IndexSet::make_trilinos_map (const MPI_Comm &communicator, - const bool overlapping) const + const bool overlapping) const { compress (); if ((is_contiguous() == true) && (!overlapping)) return Epetra_Map (size(), - n_elements(), - 0, + n_elements(), + 0, #ifdef DEAL_II_COMPILER_SUPPORTS_MPI - Epetra_MpiComm(communicator)); + Epetra_MpiComm(communicator)); #else - Epetra_SerialComm()); + Epetra_SerialComm()); #endif else { @@ -395,17 +395,17 @@ IndexSet::make_trilinos_map (const MPI_Comm &communicator, fill_index_vector(indices); return Epetra_Map (-1, - n_elements(), - (n_elements() > 0 - ? - reinterpret_cast(&indices[0]) - : - 0), - 0, + n_elements(), + (n_elements() > 0 + ? + reinterpret_cast(&indices[0]) + : + 0), + 0, #ifdef DEAL_II_COMPILER_SUPPORTS_MPI - Epetra_MpiComm(communicator)); + Epetra_MpiComm(communicator)); #else - Epetra_SerialComm()); + Epetra_SerialComm()); (void)communicator; #endif } diff --git a/deal.II/source/base/job_identifier.cc b/deal.II/source/base/job_identifier.cc index 4e6bdd2913..899e87ea89 100644 --- a/deal.II/source/base/job_identifier.cc +++ b/deal.II/source/base/job_identifier.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2009, 2010 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2009, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer diff --git a/deal.II/source/base/logstream.cc b/deal.II/source/base/logstream.cc index f5a3728a96..9ea801edcd 100644 --- a/deal.II/source/base/logstream.cc +++ b/deal.II/source/base/logstream.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -51,12 +51,12 @@ LogStream deallog; LogStream::LogStream() - : - std_out(&std::cerr), file(0), - std_depth(10000), file_depth(10000), - print_utime(false), diff_utime(false), - last_time (0.), double_threshold(0.), float_threshold(0.), - offset(0), old_cerr(0) + : + std_out(&std::cerr), file(0), + std_depth(10000), file_depth(10000), + print_utime(false), diff_utime(false), + last_time (0.), double_threshold(0.), float_threshold(0.), + offset(0), old_cerr(0) { prefixes.push("DEAL:"); std_out->setf(std::ios::showpoint | std::ios::left); @@ -68,35 +68,35 @@ LogStream::LogStream() LogStream::~LogStream() { - // if there was anything left in - // the stream that is current to - // this thread, make sure we flush - // it before it gets lost + // if there was anything left in + // the stream that is current to + // this thread, make sure we flush + // it before it gets lost { const unsigned int id = Threads::this_thread_id(); if ((outstreams.find(id) != outstreams.end()) - && - (*outstreams[id] != 0) - && - (outstreams[id]->str().length() > 0)) + && + (*outstreams[id] != 0) + && + (outstreams[id]->str().length() > 0)) *this << std::endl; } if (old_cerr) std::cerr.rdbuf(old_cerr); - // on some systems, destroying the - // outstreams objects of deallog - // triggers some sort of memory - // corruption, in particular when - // we also link with Trilinos; - // since this happens at the very - // end of the program, we take the - // liberty to simply not do it by - // putting that object into a - // deliberate memory leak and - // instead destroying an empty - // object + // on some systems, destroying the + // outstreams objects of deallog + // triggers some sort of memory + // corruption, in particular when + // we also link with Trilinos; + // since this happens at the very + // end of the program, we take the + // liberty to simply not do it by + // putting that object into a + // deliberate memory leak and + // instead destroying an empty + // object #ifdef DEAL_II_USE_TRILINOS if (this == &deallog) { @@ -123,20 +123,20 @@ LogStream::test_mode(bool on) double_threshold = 0.; float_threshold = 0.; offset = 0.; - } + } } LogStream & LogStream::operator<< (std::ostream& (*p) (std::ostream&)) { - // do the work that is common to - // the operator<< functions + // do the work that is common to + // the operator<< functions print (p); - // next check whether this is the - // endl manipulator, and if so - // set a flag + // next check whether this is the + // endl manipulator, and if so + // set a flag std::ostream & (* const p_endl) (std::ostream&) = &std::endl; if (p == p_endl) { @@ -144,12 +144,12 @@ LogStream::operator<< (std::ostream& (*p) (std::ostream&)) print_line_head(); std::ostringstream& stream = get_stream(); if (prefixes.size() <= std_depth) - *std_out << stream.str(); + *std_out << stream.str(); if (file && (prefixes.size() <= file_depth)) - *file << stream.str() << std::flush; + *file << stream.str() << std::flush; - // Start a new string + // Start a new string stream.str(""); } return *this; @@ -163,7 +163,7 @@ LogStream::get_stream() Threads::ThreadMutex::ScopedLock lock(log_lock); const unsigned int id = Threads::this_thread_id(); - // if necessary allocate a stream object + // if necessary allocate a stream object if (outstreams.find (id) == outstreams.end()) { outstreams[id].reset (new std::ostringstream()); @@ -328,11 +328,11 @@ LogStream::print_line_head() getrusage(RUSAGE_SELF, &usage); utime = usage.ru_utime.tv_sec + 1.e-6 * usage.ru_utime.tv_usec; if (diff_utime) - { - double diff = utime - last_time; - last_time = utime; - utime = diff; - } + { + double diff = utime - last_time; + last_time = utime; + utime = diff; + } } /* @@ -359,7 +359,7 @@ LogStream::print_line_head() static long size; static string dummy; ifstream stat(statname.str()); - // ignore 22 values + // ignore 22 values stat >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> @@ -372,16 +372,16 @@ LogStream::print_line_head() if (prefixes.size() <= std_depth) { if (print_utime) - { - int p = std_out->width(5); - *std_out << utime << ':'; + { + int p = std_out->width(5); + *std_out << utime << ':'; #ifdef DEALII_MEMORY_DEBUG - *std_out << size << ':'; + *std_out << size << ':'; #endif - std_out->width(p); - } + std_out->width(p); + } if (print_thread_id) - *std_out << '[' << thread << ']'; + *std_out << '[' << thread << ']'; *std_out << head << ':'; } @@ -389,16 +389,16 @@ LogStream::print_line_head() if (file && (prefixes.size() <= file_depth)) { if (print_utime) - { - int p = file->width(6); - *file << utime << ':'; + { + int p = file->width(6); + *file << utime << ':'; #ifdef DEALII_MEMORY_DEBUG - *file << size << ':'; + *file << size << ':'; #endif - file->width(p); - } + file->width(p); + } if (print_thread_id) - *file << '[' << thread << ']'; + *file << '[' << thread << ']'; *file << head << ':'; } @@ -417,11 +417,11 @@ LogStream::timestamp () const unsigned int tick = 100; #endif (*this) << "Wall: " << time - reference_time_val - << " User: " << 1./tick * (current_tms.tms_utime - reference_tms.tms_utime) - << " System: " << 1./tick * (current_tms.tms_stime - reference_tms.tms_stime) - << " Child-User: " << 1./tick * (current_tms.tms_cutime - reference_tms.tms_cutime) - << " Child-System: " << 1./tick * (current_tms.tms_cstime - reference_tms.tms_cstime) - << std::endl; + << " User: " << 1./tick * (current_tms.tms_utime - reference_tms.tms_utime) + << " System: " << 1./tick * (current_tms.tms_stime - reference_tms.tms_stime) + << " Child-User: " << 1./tick * (current_tms.tms_cutime - reference_tms.tms_cutime) + << " Child-System: " << 1./tick * (current_tms.tms_cstime - reference_tms.tms_cstime) + << std::endl; } @@ -429,10 +429,10 @@ std::size_t LogStream::memory_consumption () const { std::size_t mem = sizeof(*this); - // to determine size of stack - // elements, we have to copy the - // stack since we can't access - // elements from further below + // to determine size of stack + // elements, we have to copy the + // stack since we can't access + // elements from further below std::stack tmp = prefixes; while (tmp.empty() == false) { diff --git a/deal.II/source/base/memory_consumption.cc b/deal.II/source/base/memory_consumption.cc index 7936d8b2a2..8ecaa085f6 100644 --- a/deal.II/source/base/memory_consumption.cc +++ b/deal.II/source/base/memory_consumption.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006, 2011 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -17,7 +17,7 @@ DEAL_II_NAMESPACE_OPEN -namespace MemoryConsumption +namespace MemoryConsumption { std::size_t memory_consumption (const std::vector &v) @@ -27,7 +27,7 @@ namespace MemoryConsumption mem += memory_consumption(v[i]); return mem; } - + } diff --git a/deal.II/source/base/mpi.cc b/deal.II/source/base/mpi.cc index 4dd124399e..fe721b947e 100644 --- a/deal.II/source/base/mpi.cc +++ b/deal.II/source/base/mpi.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2005, 2006, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 2005, 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -97,65 +97,65 @@ namespace Utilities std::vector compute_point_to_point_communication_pattern (const MPI_Comm & mpi_comm, - const std::vector & destinations) + const std::vector & destinations) { unsigned int myid = Utilities::MPI::this_mpi_process(mpi_comm); unsigned int n_procs = Utilities::MPI::n_mpi_processes(mpi_comm); for (unsigned int i=0; i my_destinations(max_n_destinations, - numbers::invalid_unsigned_int); + numbers::invalid_unsigned_int); std::copy (destinations.begin(), destinations.end(), - my_destinations.begin()); - - // now exchange these (we could - // communicate less data if we - // used MPI_Allgatherv, but - // we'd have to communicate - // my_n_destinations to all - // processors in this case, - // which is more expensive than - // the reduction operation - // above in MPI_Allreduce) + my_destinations.begin()); + + // now exchange these (we could + // communicate less data if we + // used MPI_Allgatherv, but + // we'd have to communicate + // my_n_destinations to all + // processors in this case, + // which is more expensive than + // the reduction operation + // above in MPI_Allreduce) std::vector all_destinations (max_n_destinations * n_procs); MPI_Allgather (&my_destinations[0], max_n_destinations, MPI_UNSIGNED, - &all_destinations[0], max_n_destinations, MPI_UNSIGNED, - mpi_comm); + &all_destinations[0], max_n_destinations, MPI_UNSIGNED, + mpi_comm); - // now we know who is going to - // communicate with - // whom. collect who is going - // to communicate with us! + // now we know who is going to + // communicate with + // whom. collect who is going + // to communicate with us! std::vector origins; for (unsigned int i=0; i(in_lhs_); - MinMaxAvg * inout_rhs = static_cast(inout_rhs_); - - Assert(*len==1, ExcInternalError()); - - inout_rhs->sum += in_lhs->sum; - if (inout_rhs->min>in_lhs->min) - { - inout_rhs->min = in_lhs->min; - inout_rhs->min_index = in_lhs->min_index; - } - else if (inout_rhs->min == in_lhs->min) - { // choose lower cpu index when tied to make operator cumutative - if (inout_rhs->min_index > in_lhs->min_index) - inout_rhs->min_index = in_lhs->min_index; - } - - if (inout_rhs->max < in_lhs->max) - { - inout_rhs->max = in_lhs->max; - inout_rhs->max_index = in_lhs->max_index; - } - else if (inout_rhs->max == in_lhs->max) - { // choose lower cpu index when tied to make operator cumutative - if (inout_rhs->max_index > in_lhs->max_index) - inout_rhs->max_index = in_lhs->max_index; - } + const MinMaxAvg * in_lhs = static_cast(in_lhs_); + MinMaxAvg * inout_rhs = static_cast(inout_rhs_); + + Assert(*len==1, ExcInternalError()); + + inout_rhs->sum += in_lhs->sum; + if (inout_rhs->min>in_lhs->min) + { + inout_rhs->min = in_lhs->min; + inout_rhs->min_index = in_lhs->min_index; + } + else if (inout_rhs->min == in_lhs->min) + { // choose lower cpu index when tied to make operator cumutative + if (inout_rhs->min_index > in_lhs->min_index) + inout_rhs->min_index = in_lhs->min_index; + } + + if (inout_rhs->max < in_lhs->max) + { + inout_rhs->max = in_lhs->max; + inout_rhs->max_index = in_lhs->max_index; + } + else if (inout_rhs->max == in_lhs->max) + { // choose lower cpu index when tied to make operator cumutative + if (inout_rhs->max_index > in_lhs->max_index) + inout_rhs->max_index = in_lhs->max_index; + } } } @@ -204,14 +204,14 @@ namespace Utilities MinMaxAvg min_max_avg(const double my_value, - const MPI_Comm &mpi_communicator) + const MPI_Comm &mpi_communicator) { MinMaxAvg result; const unsigned int my_id - = dealii::Utilities::MPI::this_mpi_process(mpi_communicator); + = dealii::Utilities::MPI::this_mpi_process(mpi_communicator); const unsigned int numproc - = dealii::Utilities::MPI::n_mpi_processes(mpi_communicator); + = dealii::Utilities::MPI::n_mpi_processes(mpi_communicator); MPI_Op op; int ierr = MPI_Op_create((MPI_User_function *)&max_reduce, true, &op); @@ -269,7 +269,7 @@ namespace Utilities MinMaxAvg min_max_avg(const double my_value, - const MPI_Comm &) + const MPI_Comm &) { MinMaxAvg result; @@ -289,28 +289,28 @@ namespace Utilities MPI_InitFinalize::MPI_InitFinalize (int &argc, - char** &argv) - : - owns_mpi (true) + char** &argv) + : + owns_mpi (true) { static bool constructor_has_already_run = false; Assert (constructor_has_already_run == false, - ExcMessage ("You can only create a single object of this class " - "in a program since it initializes the MPI system.")); + ExcMessage ("You can only create a single object of this class " + "in a program since it initializes the MPI system.")); #ifdef DEAL_II_COMPILER_SUPPORTS_MPI int MPI_has_been_started = 0; MPI_Initialized(&MPI_has_been_started); AssertThrow (MPI_has_been_started == 0, - ExcMessage ("MPI error. You can only start MPI once!")); + ExcMessage ("MPI error. You can only start MPI once!")); int mpi_err; mpi_err = MPI_Init (&argc, &argv); AssertThrow (mpi_err == 0, - ExcMessage ("MPI could not be initialized.")); + ExcMessage ("MPI could not be initialized.")); #else - // make sure the compiler doesn't warn - // about these variables + // make sure the compiler doesn't warn + // about these variables (void)argc; (void)argv; #endif @@ -324,30 +324,30 @@ namespace Utilities #ifdef DEAL_II_COMPILER_SUPPORTS_MPI # if defined(DEAL_II_USE_TRILINOS) && !defined(__APPLE__) - // make memory pool release all - // vectors that are no longer - // used at this point. this is - // relevant because the static - // object destructors run for - // these vectors at the end of - // the program would run after - // MPI_Finalize is called, - // leading to errors - // - // TODO: On Mac OS X, shared libs can - // only depend on other libs listed - // later on the command line. This - // means that libbase can't depend on - // liblac, and we can't destroy the - // memory pool here as long as we have - // separate libraries. Consequently, - // the #ifdef above. Deal will then - // just continue to seg fault upon - // completion of main() + // make memory pool release all + // vectors that are no longer + // used at this point. this is + // relevant because the static + // object destructors run for + // these vectors at the end of + // the program would run after + // MPI_Finalize is called, + // leading to errors + // + // TODO: On Mac OS X, shared libs can + // only depend on other libs listed + // later on the command line. This + // means that libbase can't depend on + // liblac, and we can't destroy the + // memory pool here as long as we have + // separate libraries. Consequently, + // the #ifdef above. Deal will then + // just continue to seg fault upon + // completion of main() GrowingVectorMemory - ::release_unused_memory (); + ::release_unused_memory (); GrowingVectorMemory - ::release_unused_memory (); + ::release_unused_memory (); # endif int mpi_err = 0; @@ -355,22 +355,22 @@ namespace Utilities int MPI_has_been_started = 0; MPI_Initialized(&MPI_has_been_started); if (Utilities::System::program_uses_mpi() == true && owns_mpi == true && - MPI_has_been_started != 0) - { - if (std::uncaught_exception()) - { - std::cerr << "ERROR: Uncaught exception in MPI_InitFinalize on proc " - << this_mpi_process(MPI_COMM_WORLD) - << ". Skipping MPI_Finalize() to avoid a deadlock." - << std::endl; - } - else - mpi_err = MPI_Finalize(); - } + MPI_has_been_started != 0) + { + if (std::uncaught_exception()) + { + std::cerr << "ERROR: Uncaught exception in MPI_InitFinalize on proc " + << this_mpi_process(MPI_COMM_WORLD) + << ". Skipping MPI_Finalize() to avoid a deadlock." + << std::endl; + } + else + mpi_err = MPI_Finalize(); + } AssertThrow (mpi_err == 0, - ExcMessage ("An error occurred while calling MPI_Finalize()")); + ExcMessage ("An error occurred while calling MPI_Finalize()")); #endif } diff --git a/deal.II/source/base/multithread_info.cc b/deal.II/source/base/multithread_info.cc index ae5da10516..aab89d8c79 100644 --- a/deal.II/source/base/multithread_info.cc +++ b/deal.II/source/base/multithread_info.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2011 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -50,26 +50,26 @@ DEAL_II_NAMESPACE_OPEN unsigned int MultithreadInfo::get_n_cpus() { - // on linux, we simply count the - // number of lines listing - // individual processors when - // reading from /proc/cpuinfo + // on linux, we simply count the + // number of lines listing + // individual processors when + // reading from /proc/cpuinfo std::ifstream cpuinfo; std::string search; unsigned int nCPU = 0; - + cpuinfo.open("/proc/cpuinfo"); AssertThrow(cpuinfo,ExcProcNotPresent()); - + while(cpuinfo) { cpuinfo >> search; if (search.find("processor") != std::string::npos) - nCPU++; + nCPU++; } cpuinfo.close(); - + return nCPU; } @@ -89,21 +89,21 @@ unsigned int MultithreadInfo::get_n_cpus() } # elif defined(__MACH__) && defined(__APPLE__) -// This is only tested on a dual G5 2.5GHz running MacOSX 10.3.6 +// This is only tested on a dual G5 2.5GHz running MacOSX 10.3.6 // and on an Intel Mac Book Pro. // If it doesnt work please contact the mailinglist. unsigned int MultithreadInfo::get_n_cpus() { - int mib[2]; - int n_cpus; - size_t len; - - mib[0] = CTL_HW; - mib[1] = HW_NCPU; - len = sizeof(n_cpus); - sysctl(mib, 2, &n_cpus, &len, NULL, 0); - - return n_cpus; + int mib[2]; + int n_cpus; + size_t len; + + mib[0] = CTL_HW; + mib[1] = HW_NCPU; + len = sizeof(n_cpus); + sysctl(mib, 2, &n_cpus, &len, NULL, 0); + + return n_cpus; } @@ -138,7 +138,7 @@ unsigned int MultithreadInfo::get_n_cpus() # endif -#else // not in MT mode +#else // not in MT mode unsigned int MultithreadInfo::get_n_cpus() { @@ -159,8 +159,8 @@ MultithreadInfo::MultithreadInfo () std::size_t MultithreadInfo::memory_consumption () { - // only simple data elements, so - // use sizeof operator + // only simple data elements, so + // use sizeof operator return sizeof (MultithreadInfo); } diff --git a/deal.II/source/base/parallel.cc b/deal.II/source/base/parallel.cc index a71eefe1df..c25970dce2 100644 --- a/deal.II/source/base/parallel.cc +++ b/deal.II/source/base/parallel.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2009 by the deal.II authors +// Copyright (C) 2009, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -20,33 +20,33 @@ namespace internal { namespace Vector { - // set minimum grain size. this value is - // roughly in accordance with the curve - // in the TBB book (fig 3.2) that shows - // run time as a function of grain size - // -- there, values from 200 upward are - // so that the scheduling overhead - // amortizes well (for very large values - // in that example, the grain size is too - // large to split the work load into - // enough chunks and the problem becomes - // badly balanced) + // set minimum grain size. this value is + // roughly in accordance with the curve + // in the TBB book (fig 3.2) that shows + // run time as a function of grain size + // -- there, values from 200 upward are + // so that the scheduling overhead + // amortizes well (for very large values + // in that example, the grain size is too + // large to split the work load into + // enough chunks and the problem becomes + // badly balanced) unsigned int minimum_parallel_grain_size = 1000; } namespace SparseMatrix { - // set this value to 1/5 of the value of - // the minimum grain size of - // vectors. this rests on the fact that - // we have to do a lot more work per row - // of a matrix than per element of a - // vector. it could possibly be reduced - // even further but that doesn't appear - // worth it any more for anything but - // very small matrices that we don't care - // that much about anyway. + // set this value to 1/5 of the value of + // the minimum grain size of + // vectors. this rests on the fact that + // we have to do a lot more work per row + // of a matrix than per element of a + // vector. it could possibly be reduced + // even further but that doesn't appear + // worth it any more for anything but + // very small matrices that we don't care + // that much about anyway. unsigned int minimum_parallel_grain_size = 200; } } diff --git a/deal.II/source/base/parameter_handler.cc b/deal.II/source/base/parameter_handler.cc index bd05601c82..0aa2e390d5 100644 --- a/deal.II/source/base/parameter_handler.cc +++ b/deal.II/source/base/parameter_handler.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -45,26 +45,26 @@ namespace Patterns namespace { - /** - * Read to the end of the stream and - * return whether all there is is - * whitespace or whether there are other - * characters as well. - */ + /** + * Read to the end of the stream and + * return whether all there is is + * whitespace or whether there are other + * characters as well. + */ bool has_only_whitespace (std::istream &in) { while (in) - { - char c; + { + char c; - // skip if we've reached the end of - // the line - if (!(in >> c)) - break; + // skip if we've reached the end of + // the line + if (!(in >> c)) + break; - if ((c != ' ') && (c != '\t')) - return false; - } + if ((c != ' ') && (c != '\t')) + return false; + } return true; } } @@ -157,10 +157,10 @@ namespace Patterns const char* Integer::description_init = "[Integer"; Integer::Integer (const int lower_bound, - const int upper_bound) + const int upper_bound) : - lower_bound (lower_bound), - upper_bound (upper_bound) + lower_bound (lower_bound), + upper_bound (upper_bound) {} @@ -175,12 +175,12 @@ namespace Patterns if (!has_only_whitespace (str)) return false; - // check whether valid bounds - // were specified, and if so - // enforce their values + // check whether valid bounds + // were specified, and if so + // enforce their values if (lower_bound <= upper_bound) return ((lower_bound <= i) && - (upper_bound >= i)); + (upper_bound >= i)); else return true; } @@ -189,22 +189,22 @@ namespace Patterns std::string Integer::description () const { - // check whether valid bounds - // were specified, and if so - // output their values + // check whether valid bounds + // were specified, and if so + // output their values if (lower_bound <= upper_bound) { - std::ostringstream description; + std::ostringstream description; - description << description_init - <<" range " - << lower_bound << "..." << upper_bound - << " (inclusive)]"; - return description.str(); + description << description_init + <<" range " + << lower_bound << "..." << upper_bound + << " (inclusive)]"; + return description.str(); } else - // if no bounds were given, then - // return generic string + // if no bounds were given, then + // return generic string return "[Integer]"; } @@ -267,10 +267,10 @@ namespace Patterns const char* Double::description_init = "[Double"; Double::Double (const double lower_bound, - const double upper_bound) + const double upper_bound) : - lower_bound (lower_bound), - upper_bound (upper_bound) + lower_bound (lower_bound), + upper_bound (upper_bound) {} @@ -285,12 +285,12 @@ namespace Patterns if (!has_only_whitespace (str)) return false; - // check whether valid bounds - // were specified, and if so - // enforce their values + // check whether valid bounds + // were specified, and if so + // enforce their values if (lower_bound <= upper_bound) return ((lower_bound <= d) && - (upper_bound >= d)); + (upper_bound >= d)); else return true; } @@ -299,26 +299,26 @@ namespace Patterns std::string Double::description () const { - std::ostringstream description; + std::ostringstream description; - // check whether valid bounds - // were specified, and if so - // output their values + // check whether valid bounds + // were specified, and if so + // output their values if (lower_bound <= upper_bound) { - description << description_init - << " " - << lower_bound << "..." << upper_bound - << " (inclusive)]"; - return description.str(); + description << description_init + << " " + << lower_bound << "..." << upper_bound + << " (inclusive)]"; + return description.str(); } else - // if no bounds were given, then - // return generic string + // if no bounds were given, then + // return generic string { - description << description_init - << "]"; - return description.str(); + description << description_init + << "]"; + return description.str(); } } @@ -381,19 +381,19 @@ namespace Patterns { std::vector choices; std::string tmp(sequence); - // check the different possibilities + // check the different possibilities while (tmp.find('|') != std::string::npos) { - if (test_string == std::string(tmp, 0, tmp.find('|'))) - return true; + if (test_string == std::string(tmp, 0, tmp.find('|'))) + return true; - tmp.erase (0, tmp.find('|')+1); + tmp.erase (0, tmp.find('|')+1); }; - // check last choice, not finished by | + // check last choice, not finished by | if (test_string == tmp) return true; - // not found + // not found return false; } @@ -424,7 +424,7 @@ namespace Patterns Selection::memory_consumption () const { return (sizeof(PatternBase) + - MemoryConsumption::memory_consumption(sequence)); + MemoryConsumption::memory_consumption(sequence)); } @@ -485,38 +485,38 @@ namespace Patterns std::vector split_list; split_list.reserve (std::count (tmp.begin(), tmp.end(), ',')+1); - // first split the input list + // first split the input list while (tmp.length() != 0) { std::string name; - name = tmp; + name = tmp; - if (name.find(",") != std::string::npos) - { - name.erase (name.find(","), std::string::npos); - tmp.erase (0, tmp.find(",")+1); - } - else - tmp = ""; + if (name.find(",") != std::string::npos) + { + name.erase (name.find(","), std::string::npos); + tmp.erase (0, tmp.find(",")+1); + } + else + tmp = ""; - while ((name.length() != 0) && - (std::isspace (name[0]))) - name.erase (0,1); + while ((name.length() != 0) && + (std::isspace (name[0]))) + name.erase (0,1); - while (std::isspace (name[name.length()-1])) - name.erase (name.length()-1, 1); + while (std::isspace (name[name.length()-1])) + name.erase (name.length()-1, 1); - split_list.push_back (name); + split_list.push_back (name); }; if ((split_list.size() < min_elements) || (split_list.size() > max_elements)) return false; - // check the different possibilities + // check the different possibilities for (std::vector::const_iterator test_string = split_list.begin(); - test_string != split_list.end(); ++test_string) + test_string != split_list.end(); ++test_string) if (pattern->match (*test_string) == false) return false; @@ -551,7 +551,7 @@ namespace Patterns List::memory_consumption () const { return (sizeof(PatternBase) + - MemoryConsumption::memory_consumption(*pattern)); + MemoryConsumption::memory_consumption(*pattern)); } @@ -608,58 +608,58 @@ namespace Patterns std::string tmp = test_string_list; std::list split_list; - // first split the input list + // first split the input list while (tmp.length() != 0) { - std::string name; - name = tmp; - - if (name.find(",") != std::string::npos) - { - name.erase (name.find(","), std::string::npos); - tmp.erase (0, tmp.find(",")+1); - } - else - tmp = ""; - - while ((name.length() != 0) && - (std::isspace (name[0]))) - name.erase (0,1); - while (std::isspace (name[name.length()-1])) - name.erase (name.length()-1, 1); - - split_list.push_back (name); + std::string name; + name = tmp; + + if (name.find(",") != std::string::npos) + { + name.erase (name.find(","), std::string::npos); + tmp.erase (0, tmp.find(",")+1); + } + else + tmp = ""; + + while ((name.length() != 0) && + (std::isspace (name[0]))) + name.erase (0,1); + while (std::isspace (name[name.length()-1])) + name.erase (name.length()-1, 1); + + split_list.push_back (name); }; - // check the different possibilities + // check the different possibilities for (std::list::const_iterator test_string = split_list.begin(); - test_string != split_list.end(); ++test_string) + test_string != split_list.end(); ++test_string) { - bool string_found = false; - - tmp = sequence; - while (tmp.find('|') != std::string::npos) - { - if (*test_string == std::string(tmp, 0, tmp.find('|'))) - { - // string found, quit - // loop. don't change - // tmp, since we don't - // need it anymore. - string_found = true; - break; - }; - - tmp.erase (0, tmp.find('|')+1); - }; - // check last choice, not finished by | - if (!string_found) - if (*test_string == tmp) - string_found = true; - - if (!string_found) - return false; + bool string_found = false; + + tmp = sequence; + while (tmp.find('|') != std::string::npos) + { + if (*test_string == std::string(tmp, 0, tmp.find('|'))) + { + // string found, quit + // loop. don't change + // tmp, since we don't + // need it anymore. + string_found = true; + break; + }; + + tmp.erase (0, tmp.find('|')+1); + }; + // check last choice, not finished by | + if (!string_found) + if (*test_string == tmp) + string_found = true; + + if (!string_found) + return false; }; return true; @@ -692,7 +692,7 @@ namespace Patterns MultipleSelection::memory_consumption () const { return (sizeof(PatternBase) + - MemoryConsumption::memory_consumption(sequence)); + MemoryConsumption::memory_consumption(sequence)); } @@ -719,7 +719,7 @@ namespace Patterns Bool::Bool () : - Selection ("true|false") + Selection ("true|false") {} @@ -911,8 +911,8 @@ namespace Patterns ParameterHandler::ParameterHandler () - : - entries (new boost::property_tree::ptree()) + : + entries (new boost::property_tree::ptree()) {} @@ -931,19 +931,19 @@ ParameterHandler::mangle (const std::string &s) static const std::string allowed_characters ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); - // for all parts of the string, see - // if it is an allowed character or - // not + // for all parts of the string, see + // if it is an allowed character or + // not for (unsigned int i=0; i(s[i])/16]); - u.push_back (hex[static_cast(s[i])%16]); + u.push_back ('_'); + static const char hex[16] + = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; + u.push_back (hex[static_cast(s[i])/16]); + u.push_back (hex[static_cast(s[i])%16]); } return u; @@ -962,57 +962,57 @@ ParameterHandler::demangle (const std::string &s) u.push_back (s[i]); else { - Assert (i+2 < s.size(), - ExcMessage ("Trying to demangle an invalid string.")); - - unsigned char c = 0; - switch (s[i+1]) - { - case '0': c = 0 * 16; break; - case '1': c = 1 * 16; break; - case '2': c = 2 * 16; break; - case '3': c = 3 * 16; break; - case '4': c = 4 * 16; break; - case '5': c = 5 * 16; break; - case '6': c = 6 * 16; break; - case '7': c = 7 * 16; break; - case '8': c = 8 * 16; break; - case '9': c = 9 * 16; break; - case 'a': c = 10 * 16; break; - case 'b': c = 11 * 16; break; - case 'c': c = 12 * 16; break; - case 'd': c = 13 * 16; break; - case 'e': c = 14 * 16; break; - case 'f': c = 15 * 16; break; - default: - Assert (false, ExcInternalError()); - } - switch (s[i+2]) - { - case '0': c += 0; break; - case '1': c += 1; break; - case '2': c += 2; break; - case '3': c += 3; break; - case '4': c += 4; break; - case '5': c += 5; break; - case '6': c += 6; break; - case '7': c += 7; break; - case '8': c += 8; break; - case '9': c += 9; break; - case 'a': c += 10; break; - case 'b': c += 11; break; - case 'c': c += 12; break; - case 'd': c += 13; break; - case 'e': c += 14; break; - case 'f': c += 15; break; - default: - Assert (false, ExcInternalError()); - } - - u.push_back (static_cast(c)); - - // skip the two characters - i += 2; + Assert (i+2 < s.size(), + ExcMessage ("Trying to demangle an invalid string.")); + + unsigned char c = 0; + switch (s[i+1]) + { + case '0': c = 0 * 16; break; + case '1': c = 1 * 16; break; + case '2': c = 2 * 16; break; + case '3': c = 3 * 16; break; + case '4': c = 4 * 16; break; + case '5': c = 5 * 16; break; + case '6': c = 6 * 16; break; + case '7': c = 7 * 16; break; + case '8': c = 8 * 16; break; + case '9': c = 9 * 16; break; + case 'a': c = 10 * 16; break; + case 'b': c = 11 * 16; break; + case 'c': c = 12 * 16; break; + case 'd': c = 13 * 16; break; + case 'e': c = 14 * 16; break; + case 'f': c = 15 * 16; break; + default: + Assert (false, ExcInternalError()); + } + switch (s[i+2]) + { + case '0': c += 0; break; + case '1': c += 1; break; + case '2': c += 2; break; + case '3': c += 3; break; + case '4': c += 4; break; + case '5': c += 5; break; + case '6': c += 6; break; + case '7': c += 7; break; + case '8': c += 8; break; + case '9': c += 9; break; + case 'a': c += 10; break; + case 'b': c += 11; break; + case 'c': c += 12; break; + case 'd': c += 13; break; + case 'e': c += 14; break; + case 'f': c += 15; break; + default: + Assert (false, ExcInternalError()); + } + + u.push_back (static_cast(c)); + + // skip the two characters + i += 2; } return u; @@ -1035,10 +1035,10 @@ ParameterHandler::get_current_path () const { std::string p = mangle(subsection_path[0]); for (unsigned int i=1; i for reading." << std::endl; + << filename << "> for reading." << std::endl; if (!optional) - { - std:: cerr << "Trying to make file <" - << filename << "> with default values for you." << std::endl; - std::ofstream output (filename.c_str()); - if (output) - print_parameters (output, (write_compact ? ShortText : Text)); - } + { + std:: cerr << "Trying to make file <" + << filename << "> with default values for you." << std::endl; + std::ofstream output (filename.c_str()); + if (output) + print_parameters (output, (write_compact ? ShortText : Text)); + } } return false; } @@ -1116,31 +1116,31 @@ bool ParameterHandler::read_input (const std::string &filename, bool ParameterHandler::read_input_from_string (const char *s) { - // if empty std::string then exit - // with success + // if empty std::string then exit + // with success if ((s == 0) || ((*s) == 0)) return true; std::string line; std::string input (s); int lineno=0; - // if necessary append a newline char - // to make all lines equal + // if necessary append a newline char + // to make all lines equal if (input[input.length()-1] != '\n') input += '\n'; bool status = true; while (input.size() != 0) { - // get one line from Input (=s) + // get one line from Input (=s) line.assign (input, 0, input.find('\n')); - // delete this part including - // the backspace + // delete this part including + // the backspace input.erase (0, input.find('\n')+1); ++lineno; if (!scan_line (line, lineno)) - status = false; + status = false; } return status; @@ -1150,110 +1150,110 @@ bool ParameterHandler::read_input_from_string (const char *s) namespace { - // Recursively go through the 'source' tree - // and see if we can find corresponding - // entries in the 'destination' tree. If - // not, error out (i.e. we have just read - // an XML file that has entries that - // weren't declared in the ParameterHandler - // object); if so, copy the value of these - // nodes into the destination object + // Recursively go through the 'source' tree + // and see if we can find corresponding + // entries in the 'destination' tree. If + // not, error out (i.e. we have just read + // an XML file that has entries that + // weren't declared in the ParameterHandler + // object); if so, copy the value of these + // nodes into the destination object bool read_xml_recursively (const boost::property_tree::ptree &source, - const std::string ¤t_path, - const char path_separator, - const std::vector > & - patterns, - boost::property_tree::ptree &destination) + const std::string ¤t_path, + const char path_separator, + const std::vector > & + patterns, + boost::property_tree::ptree &destination) { for (boost::property_tree::ptree::const_iterator p = source.begin(); - p != source.end(); ++p) + p != source.end(); ++p) { - // a sub-tree must either be a - // parameter node or a subsection - if (p->second.get_optional("value")) - { - // make sure we have a - // corresponding entry in the - // destination object as well - const std::string full_path - = (current_path == "" - ? - p->first - : - current_path + path_separator + p->first); - if (destination.get_optional (full_path) - && - destination.get_optional (full_path + - path_separator + - "value")) - { - // first make sure that the - // new entry actually - // satisfies its constraints - const std::string new_value - = p->second.get("value"); - - const unsigned int pattern_index - = destination.get (full_path + - path_separator + - "pattern"); - if (patterns[pattern_index]->match(new_value) == false) - { - std::cerr << " The entry value" << std::endl - << " " << new_value << std::endl - << " for the entry named" << std::endl - << " " << full_path << std::endl - << " does not match the given pattern" << std::endl - << " " << patterns[pattern_index]->description() - << std::endl; - return false; - } - - // set the found parameter in - // the destination argument - destination.put (full_path + path_separator + "value", - new_value); - - // this node might have - // sub-nodes in addition to - // "value", such as - // "default_value", - // "documentation", etc. we - // might at some point in the - // future want to make sure - // that if they exist that - // they match the ones in the - // 'destination' tree - } - else - { - std::cerr << "The entry <" << full_path - << "> with value <" - << p->second.get("value") - << "> has not been declared." - << std::endl; - return false; - } - } - else - { - // it must be a subsection - const bool result - = read_xml_recursively (p->second, - (current_path == "" ? - p->first : - current_path + path_separator + p->first), - path_separator, - patterns, - destination); - - // see if the recursive read - // succeeded. if yes, continue, - // otherwise exit now - if (result == false) - return false; - } + // a sub-tree must either be a + // parameter node or a subsection + if (p->second.get_optional("value")) + { + // make sure we have a + // corresponding entry in the + // destination object as well + const std::string full_path + = (current_path == "" + ? + p->first + : + current_path + path_separator + p->first); + if (destination.get_optional (full_path) + && + destination.get_optional (full_path + + path_separator + + "value")) + { + // first make sure that the + // new entry actually + // satisfies its constraints + const std::string new_value + = p->second.get("value"); + + const unsigned int pattern_index + = destination.get (full_path + + path_separator + + "pattern"); + if (patterns[pattern_index]->match(new_value) == false) + { + std::cerr << " The entry value" << std::endl + << " " << new_value << std::endl + << " for the entry named" << std::endl + << " " << full_path << std::endl + << " does not match the given pattern" << std::endl + << " " << patterns[pattern_index]->description() + << std::endl; + return false; + } + + // set the found parameter in + // the destination argument + destination.put (full_path + path_separator + "value", + new_value); + + // this node might have + // sub-nodes in addition to + // "value", such as + // "default_value", + // "documentation", etc. we + // might at some point in the + // future want to make sure + // that if they exist that + // they match the ones in the + // 'destination' tree + } + else + { + std::cerr << "The entry <" << full_path + << "> with value <" + << p->second.get("value") + << "> has not been declared." + << std::endl; + return false; + } + } + else + { + // it must be a subsection + const bool result + = read_xml_recursively (p->second, + (current_path == "" ? + p->first : + current_path + path_separator + p->first), + path_separator, + patterns, + destination); + + // see if the recursive read + // succeeded. if yes, continue, + // otherwise exit now + if (result == false) + return false; + } } return true; @@ -1264,10 +1264,10 @@ namespace bool ParameterHandler::read_input_from_xml (std::istream &in) { - // read the XML tree assuming that (as we - // do in print_parameters(XML) it has only - // a single top-level node called - // "ParameterHandler" + // read the XML tree assuming that (as we + // do in print_parameters(XML) it has only + // a single top-level node called + // "ParameterHandler" boost::property_tree::ptree single_node_tree; try { @@ -1276,40 +1276,40 @@ bool ParameterHandler::read_input_from_xml (std::istream &in) catch (...) { std::cerr << "This input stream appears not to be valid XML" - << std::endl; + << std::endl; return false; } - // make sure there is a top-level element - // called "ParameterHandler" + // make sure there is a top-level element + // called "ParameterHandler" if (!single_node_tree.get_optional("ParameterHandler")) { std::cerr << "There is no top-level XML element called \"ParameterHandler\"." - << std::endl; + << std::endl; return false; } - // ensure that there is only a single - // top-level element + // ensure that there is only a single + // top-level element if (std::distance (single_node_tree.begin(), single_node_tree.end()) != 1) { std::cerr << "The top-level XML element \"ParameterHandler\" is " - << "not the only one." - << std::endl; + << "not the only one." + << std::endl; std::cerr << "(There are " - << std::distance (single_node_tree.begin(), - single_node_tree.end()) - << " top-level elements.)" - << std::endl; + << std::distance (single_node_tree.begin(), + single_node_tree.end()) + << " top-level elements.)" + << std::endl; return false; } - // read the child elements recursively + // read the child elements recursively const boost::property_tree::ptree &my_entries = single_node_tree.get_child("ParameterHandler"); return read_xml_recursively (my_entries, "", path_separator, patterns, - *entries); + *entries); } @@ -1328,30 +1328,30 @@ ParameterHandler::declare_entry (const std::string &entry, const std::string &documentation) { entries->put (get_current_full_path(entry) + path_separator + "value", - default_value); + default_value); entries->put (get_current_full_path(entry) + path_separator + "default_value", - default_value); + default_value); entries->put (get_current_full_path(entry) + path_separator + "documentation", - documentation); + documentation); - // clone the pattern and store its - // index in the node + // clone the pattern and store its + // index in the node patterns.push_back (std_cxx1x::shared_ptr - (pattern.clone())); + (pattern.clone())); entries->put (get_current_full_path(entry) + path_separator + "pattern", - static_cast(patterns.size()-1)); - // also store the description of - // the pattern. we do so because we - // may wish to export the whole - // thing as XML or any other format - // so that external tools can work - // on the parameter file; in that - // case, they will have to be able - // to re-create the patterns as far - // as possible + static_cast(patterns.size()-1)); + // also store the description of + // the pattern. we do so because we + // may wish to export the whole + // thing as XML or any other format + // so that external tools can work + // on the parameter file; in that + // case, they will have to be able + // to re-create the patterns as far + // as possible entries->put (get_current_full_path(entry) + path_separator + - "pattern_description", - patterns.back()->description()); + "pattern_description", + patterns.back()->description()); } @@ -1360,12 +1360,12 @@ void ParameterHandler::enter_subsection (const std::string &subsection) { const std::string current_path = get_current_path (); - // if necessary create subsection + // if necessary create subsection if (!entries->get_child_optional (get_current_full_path(subsection))) entries->add_child (get_current_full_path(subsection), - boost::property_tree::ptree()); + boost::property_tree::ptree()); - // then enter it + // then enter it subsection_path.push_back (subsection); } @@ -1373,12 +1373,12 @@ void ParameterHandler::enter_subsection (const std::string &subsection) bool ParameterHandler::leave_subsection () { - // assert there is a subsection that - // we may leave - // (use assert since this is a logical - // error in a program. When reading input - // the scan_line function has to check - // whether there is a subsection to be left!) + // assert there is a subsection that + // we may leave + // (use assert since this is a logical + // error in a program. When reading input + // the scan_line function has to check + // whether there is a subsection to be left!) Assert (subsection_path.size() != 0, ExcAlreadyAtTopLevel()); if (subsection_path.size() == 0) @@ -1393,8 +1393,8 @@ bool ParameterHandler::leave_subsection () std::string ParameterHandler::get (const std::string &entry_string) const { - // assert that the entry is indeed - // declared + // assert that the entry is indeed + // declared if (boost::optional value = entries->get_optional (get_current_full_path(entry_string) + path_separator + "value")) return value.get(); @@ -1412,7 +1412,7 @@ long int ParameterHandler::get_integer (const std::string &entry_string) const std::string s = get (entry_string); char *endptr; long int i = std::strtol (s.c_str(), &endptr, 10); - // assert there was no error + // assert there was no error AssertThrow (*endptr == '\0', ExcConversionError(s)); return i; @@ -1425,9 +1425,9 @@ double ParameterHandler::get_double (const std::string &entry_string) const std::string s = get (entry_string); char *endptr; double d = std::strtod (s.c_str(), &endptr); - // assert there was no error + // assert there was no error AssertThrow ((s.c_str()!='\0') || (*endptr == '\0'), - ExcConversionError(s)); + ExcConversionError(s)); return d; } @@ -1453,22 +1453,22 @@ void ParameterHandler::set (const std::string &entry_string, const std::string &new_value) { - // assert that the entry is indeed - // declared + // assert that the entry is indeed + // declared if (entries->get_optional (get_current_full_path(entry_string) + path_separator + "value")) { const unsigned int pattern_index - = entries->get (get_current_full_path(entry_string) + path_separator + "pattern"); + = entries->get (get_current_full_path(entry_string) + path_separator + "pattern"); AssertThrow (patterns[pattern_index]->match(new_value), - ExcValueDoesNotMatchPattern (new_value, - entries->get - (get_current_full_path(entry_string) + - path_separator + - "pattern_description"))); + ExcValueDoesNotMatchPattern (new_value, + entries->get + (get_current_full_path(entry_string) + + path_separator + + "pattern_description"))); entries->put (get_current_full_path(entry_string) + path_separator + "value", - new_value); + new_value); } else AssertThrow (false, ExcEntryUndeclared(entry_string)); @@ -1537,61 +1537,61 @@ ParameterHandler::print_parameters (std::ostream &out, { case XML: { - // call the writer - // function and exit as - // there is nothing - // further to do down in - // this function - // - // XML has a requirement that - // there can only be one - // single top-level entry, - // but we may have multiple - // entries and sections. we - // work around this by - // creating a tree just for - // this purpose with the - // single top-level node - // "ParameterHandler" and - // assign the existing tree - // under it - boost::property_tree::ptree single_node_tree; - single_node_tree.add_child("ParameterHandler", - *entries); - - write_xml (out, single_node_tree); - return out; + // call the writer + // function and exit as + // there is nothing + // further to do down in + // this function + // + // XML has a requirement that + // there can only be one + // single top-level entry, + // but we may have multiple + // entries and sections. we + // work around this by + // creating a tree just for + // this purpose with the + // single top-level node + // "ParameterHandler" and + // assign the existing tree + // under it + boost::property_tree::ptree single_node_tree; + single_node_tree.add_child("ParameterHandler", + *entries); + + write_xml (out, single_node_tree); + return out; } case JSON: - // call the writer - // function and exit as - // there is nothing - // further to do down in - // this function - write_json (out, *entries); - return out; + // call the writer + // function and exit as + // there is nothing + // further to do down in + // this function + write_json (out, *entries); + return out; case Text: - out << "# Listing of Parameters" << std::endl - << "# ---------------------" << std::endl; - break; + out << "# Listing of Parameters" << std::endl + << "# ---------------------" << std::endl; + break; case LaTeX: - out << "\\subsection{Global parameters}" << std::endl; - out << "\\label{parameters:global}" << std::endl; - out << std::endl << std::endl; - break; + out << "\\subsection{Global parameters}" << std::endl; + out << "\\label{parameters:global}" << std::endl; + out << std::endl << std::endl; + break; case Description: - out << "Listing of Parameters:" << std::endl << std::endl; - break; + out << "Listing of Parameters:" << std::endl << std::endl; + break; case ShortText: - break; + break; default: - Assert (false, ExcNotImplemented()); + Assert (false, ExcNotImplemented()); }; - // dive recursively into the subsections + // dive recursively into the subsections print_parameters_section (out, style, 0); switch (style) @@ -1599,11 +1599,11 @@ ParameterHandler::print_parameters (std::ostream &out, case Text: case Description: case ShortText: - break; + break; case LaTeX: - break; + break; default: - Assert (false, ExcNotImplemented()); + Assert (false, ExcNotImplemented()); }; return out; @@ -1631,23 +1631,23 @@ ParameterHandler::print_parameters_section (std::ostream &out, case Text: case ShortText: { - // first find out the longest - // entry name to be able to - // align the equal signs - // - // to do this loop over all - // nodes of the current tree, - // select the parameter nodes - // (and discard sub-tree - // nodes) and take the - // maximum of their lengths + // first find out the longest + // entry name to be able to + // align the equal signs + // + // to do this loop over all + // nodes of the current tree, + // select the parameter nodes + // (and discard sub-tree + // nodes) and take the + // maximum of their lengths std::size_t longest_name = 0; - for (boost::property_tree::ptree::const_iterator - p = current_section.begin(); - p != current_section.end(); ++p) - if (is_parameter_node (p->second) == true) - longest_name = std::max (longest_name, - demangle(p->first).length()); + for (boost::property_tree::ptree::const_iterator + p = current_section.begin(); + p != current_section.end(); ++p) + if (is_parameter_node (p->second) == true) + longest_name = std::max (longest_name, + demangle(p->first).length()); // likewise find the longest // actual value string to @@ -1655,181 +1655,181 @@ ParameterHandler::print_parameters_section (std::ostream &out, // default and documentation // strings std::size_t longest_value = 0; - for (boost::property_tree::ptree::const_iterator - p = current_section.begin(); - p != current_section.end(); ++p) - if (is_parameter_node (p->second) == true) - longest_value = std::max (longest_value, - p->second.get("value").length()); - - - // print entries one by - // one. make sure they are - // sorted by using the - // appropriate iterators - bool first_entry = true; - for (boost::property_tree::ptree::const_assoc_iterator - p = current_section.ordered_begin(); - p != current_section.not_found(); ++p) - if (is_parameter_node (p->second) == true) - { - const std::string value = p->second.get("value"); - - // if there is documentation, - // then add an empty line (unless - // this is the first entry in a - // subsection), print the - // documentation, and then the - // actual entry; break the - // documentation into readable - // chunks such that the whole - // thing is at most 78 characters - // wide - if ((!(style & 128)) && - !p->second.get("documentation").empty()) - { - if (first_entry == false) - out << std::endl; - else - first_entry = false; - - const std::vector doc_lines - = Utilities:: - break_text_into_lines (p->second.get("documentation"), - 78 - indent_level*2 - 2); - - for (unsigned int i=0; ifirst) - << std::setw(longest_name-demangle(p->first).length()+1) << " " - << "= " << value; - - // finally print the - // default value, but - // only if it differs - // from the actual value - if ((!(style & 64)) && value != p->second.get("default_value")) - { - out << std::setw(longest_value-value.length()+1) << ' ' - << "# "; - out << "default: " << p->second.get("default_value"); - } - - out << std::endl; - } + for (boost::property_tree::ptree::const_iterator + p = current_section.begin(); + p != current_section.end(); ++p) + if (is_parameter_node (p->second) == true) + longest_value = std::max (longest_value, + p->second.get("value").length()); + + + // print entries one by + // one. make sure they are + // sorted by using the + // appropriate iterators + bool first_entry = true; + for (boost::property_tree::ptree::const_assoc_iterator + p = current_section.ordered_begin(); + p != current_section.not_found(); ++p) + if (is_parameter_node (p->second) == true) + { + const std::string value = p->second.get("value"); + + // if there is documentation, + // then add an empty line (unless + // this is the first entry in a + // subsection), print the + // documentation, and then the + // actual entry; break the + // documentation into readable + // chunks such that the whole + // thing is at most 78 characters + // wide + if ((!(style & 128)) && + !p->second.get("documentation").empty()) + { + if (first_entry == false) + out << std::endl; + else + first_entry = false; + + const std::vector doc_lines + = Utilities:: + break_text_into_lines (p->second.get("documentation"), + 78 - indent_level*2 - 2); + + for (unsigned int i=0; ifirst) + << std::setw(longest_name-demangle(p->first).length()+1) << " " + << "= " << value; + + // finally print the + // default value, but + // only if it differs + // from the actual value + if ((!(style & 64)) && value != p->second.get("default_value")) + { + out << std::setw(longest_value-value.length()+1) << ' ' + << "# "; + out << "default: " << p->second.get("default_value"); + } + + out << std::endl; + } break; } case LaTeX: { - out << "\\begin{itemize}" - << std::endl; - - // print entries one by - // one. make sure they are - // sorted by using the - // appropriate iterators - for (boost::property_tree::ptree::const_assoc_iterator - p = current_section.ordered_begin(); - p != current_section.not_found(); ++p) - if (is_parameter_node (p->second) == true) - { - const std::string value = p->second.get("value"); - - // print name and value - out << "\\item {\\it Parameter name:} {\\tt " << demangle(p->first) << "}\n\n" - << std::endl - << "{\\it Value:} " << value << "\n\n" - << std::endl - << "{\\it Default:} " - << p->second.get("default_value") << "\n\n" - << std::endl; - - // if there is a - // documenting string, - // print it as well - if (!p->second.get("documentation").empty()) - out << "{\\it Description:} " - << p->second.get("documentation") << "\n\n" - << std::endl; - - // also output possible values - out << "{\\it Possible values:} " - << p->second.get ("pattern_description") - << std::endl; - } - out << "\\end{itemize}" << std::endl; + out << "\\begin{itemize}" + << std::endl; + + // print entries one by + // one. make sure they are + // sorted by using the + // appropriate iterators + for (boost::property_tree::ptree::const_assoc_iterator + p = current_section.ordered_begin(); + p != current_section.not_found(); ++p) + if (is_parameter_node (p->second) == true) + { + const std::string value = p->second.get("value"); + + // print name and value + out << "\\item {\\it Parameter name:} {\\tt " << demangle(p->first) << "}\n\n" + << std::endl + << "{\\it Value:} " << value << "\n\n" + << std::endl + << "{\\it Default:} " + << p->second.get("default_value") << "\n\n" + << std::endl; + + // if there is a + // documenting string, + // print it as well + if (!p->second.get("documentation").empty()) + out << "{\\it Description:} " + << p->second.get("documentation") << "\n\n" + << std::endl; + + // also output possible values + out << "{\\it Possible values:} " + << p->second.get ("pattern_description") + << std::endl; + } + out << "\\end{itemize}" << std::endl; break; } case Description: { - // first find out the longest - // entry name to be able to - // align the equal signs + // first find out the longest + // entry name to be able to + // align the equal signs std::size_t longest_name = 0; - for (boost::property_tree::ptree::const_iterator - p = current_section.begin(); - p != current_section.end(); ++p) - if (is_parameter_node (p->second) == true) - longest_name = std::max (longest_name, - demangle(p->first).length()); - - // print entries one by - // one. make sure they are - // sorted by using the - // appropriate iterators - for (boost::property_tree::ptree::const_assoc_iterator - p = current_section.ordered_begin(); - p != current_section.not_found(); ++p) - if (is_parameter_node (p->second) == true) - { - const std::string value = p->second.get("value"); - - // print name and value - out << std::setw(indent_level*2) << "" - << "set " - << demangle(p->first) - << std::setw(longest_name-demangle(p->first).length()+1) << " " - << " = "; - - // print possible values: - const std::vector description_str - = Utilities::break_text_into_lines (p->second.get - ("pattern_description"), - 78 - indent_level*2 - 2, '|'); - if (description_str.size() > 1) - { - out << std::endl; - for (unsigned int i=0; isecond.get("documentation").length() != 0) - out << std::setw(indent_level*2 + longest_name + 10) << "" - << "(" << p->second.get("documentation") << ")" << std::endl; - } + for (boost::property_tree::ptree::const_iterator + p = current_section.begin(); + p != current_section.end(); ++p) + if (is_parameter_node (p->second) == true) + longest_name = std::max (longest_name, + demangle(p->first).length()); + + // print entries one by + // one. make sure they are + // sorted by using the + // appropriate iterators + for (boost::property_tree::ptree::const_assoc_iterator + p = current_section.ordered_begin(); + p != current_section.not_found(); ++p) + if (is_parameter_node (p->second) == true) + { + const std::string value = p->second.get("value"); + + // print name and value + out << std::setw(indent_level*2) << "" + << "set " + << demangle(p->first) + << std::setw(longest_name-demangle(p->first).length()+1) << " " + << " = "; + + // print possible values: + const std::vector description_str + = Utilities::break_text_into_lines (p->second.get + ("pattern_description"), + 78 - indent_level*2 - 2, '|'); + if (description_str.size() > 1) + { + out << std::endl; + for (unsigned int i=0; isecond.get("documentation").length() != 0) + out << std::setw(indent_level*2 + longest_name + 10) << "" + << "(" << p->second.get("documentation") << ")" << std::endl; + } break; } @@ -1839,7 +1839,7 @@ ParameterHandler::print_parameters_section (std::ostream &out, } - // if there was text before and there are + // if there was text before and there are // sections to come, put two newlines // between the last entry and the first // subsection @@ -1847,27 +1847,27 @@ ParameterHandler::print_parameters_section (std::ostream &out, unsigned int n_parameters = 0; unsigned int n_sections = 0; for (boost::property_tree::ptree::const_iterator - p = current_section.begin(); - p != current_section.end(); ++p) + p = current_section.begin(); + p != current_section.end(); ++p) if (is_parameter_node (p->second) == true) - ++n_parameters; + ++n_parameters; else - ++n_sections; + ++n_sections; if ((style != Description) - && - (!(style & 128)) - && - (n_parameters != 0) - && - (n_sections != 0)) + && + (!(style & 128)) + && + (n_parameters != 0) + && + (n_sections != 0)) out << std::endl << std::endl; } - // now traverse subsections tree, - // in alphabetical order + // now traverse subsections tree, + // in alphabetical order for (boost::property_tree::ptree::const_assoc_iterator - p = current_section.ordered_begin(); + p = current_section.ordered_begin(); p != current_section.not_found(); ++p) if (is_parameter_node (p->second) == false) { @@ -1875,34 +1875,34 @@ ParameterHandler::print_parameters_section (std::ostream &out, switch (style) { case Text: - case Description: - case ShortText: + case Description: + case ShortText: out << std::setw(indent_level*2) << "" << "subsection " << demangle(p->first) << std::endl; break; case LaTeX: - { - out << std::endl - << "\\subsection{Parameters in section \\tt "; - - // find the path to the - // current section so that we - // can print it in the - // \subsection{...} heading - for (unsigned int i=0; ifirst); - - out << "}" << std::endl; - out << "\\label{parameters:"; - for (unsigned int i=0; ifirst << "}"; - out << std::endl; - - out << std::endl; - break; - } + { + out << std::endl + << "\\subsection{Parameters in section \\tt "; + + // find the path to the + // current section so that we + // can print it in the + // \subsection{...} heading + for (unsigned int i=0; ifirst); + + out << "}" << std::endl; + out << "\\label{parameters:"; + for (unsigned int i=0; ifirst << "}"; + out << std::endl; + + out << std::endl; + break; + } default: Assert (false, ExcNotImplemented()); @@ -1915,29 +1915,29 @@ ParameterHandler::print_parameters_section (std::ostream &out, leave_subsection (); switch (style) { - case Text: - // write end of - // subsection. one - // blank line after - // each subsection - out << std::setw(indent_level*2) << "" - << "end" << std::endl - << std::endl; - - // if this is a toplevel - // subsection, then have two - // newlines - if (indent_level == 0) - out << std::endl; - - break; - case Description: - break; - case ShortText: - // write end of - // subsection. - out << std::setw(indent_level*2) << "" - << "end" << std::endl; + case Text: + // write end of + // subsection. one + // blank line after + // each subsection + out << std::setw(indent_level*2) << "" + << "end" << std::endl + << std::endl; + + // if this is a toplevel + // subsection, then have two + // newlines + if (indent_level == 0) + out << std::endl; + + break; + case Description: + break; + case ShortText: + // write end of + // subsection. + out << std::setw(indent_level*2) << "" + << "end" << std::endl; break; case LaTeX: break; @@ -1953,8 +1953,8 @@ void ParameterHandler::log_parameters (LogStream &out) { out.push("parameters"); - // dive recursively into the - // subsections + // dive recursively into the + // subsections log_parameters_section (out); out.pop(); @@ -1968,30 +1968,30 @@ ParameterHandler::log_parameters_section (LogStream &out) const boost::property_tree::ptree ¤t_section = entries->get_child (get_current_path()); - // print entries one by - // one. make sure they are - // sorted by using the - // appropriate iterators + // print entries one by + // one. make sure they are + // sorted by using the + // appropriate iterators for (boost::property_tree::ptree::const_assoc_iterator - p = current_section.ordered_begin(); + p = current_section.ordered_begin(); p != current_section.not_found(); ++p) if (is_parameter_node (p->second) == true) out << demangle(p->first) << ": " << p->second.get("value") << std::endl; - // now transverse subsections tree - // now traverse subsections tree, - // in alphabetical order + // now transverse subsections tree + // now traverse subsections tree, + // in alphabetical order for (boost::property_tree::ptree::const_assoc_iterator - p = current_section.ordered_begin(); + p = current_section.ordered_begin(); p != current_section.not_found(); ++p) if (is_parameter_node (p->second) == false) { - out.push (demangle(p->first)); + out.push (demangle(p->first)); enter_subsection (demangle(p->first)); log_parameters_section (out); leave_subsection (); - out.pop (); + out.pop (); } } @@ -2001,136 +2001,136 @@ bool ParameterHandler::scan_line (std::string line, const unsigned int lineno) { - // if there is a comment, delete it + // if there is a comment, delete it if (line.find('#') != std::string::npos) line.erase (line.find("#"), std::string::npos); - // replace every whitespace sequence - // by " " + // replace every whitespace sequence + // by " " while (line.find('\t') != std::string::npos) line.replace (line.find('\t'), 1, " "); while (line.find(" ") != std::string::npos) line.erase (line.find(" "), 1); - // now every existing whitespace - // should be exactly one ' '; - // if at end or beginning: delete + // now every existing whitespace + // should be exactly one ' '; + // if at end or beginning: delete if ((line.length() != 0) && (std::isspace (line[0]))) line.erase (0, 1); - // if line is now empty: leave + // if line is now empty: leave if (line.length() == 0) return true; if (std::isspace (line[line.length()-1])) line.erase (line.size()-1, 1); - // enter subsection + // enter subsection if ((line.find ("SUBSECTION ") == 0) || (line.find ("subsection ") == 0)) { - // delete this prefix + // delete this prefix line.erase (0, std::string("subsection").length()+1); const std::string subsection = line; - // check whether subsection exists + // check whether subsection exists if (!entries->get_child_optional (get_current_full_path(subsection))) - { - std::cerr << "Line " << lineno + { + std::cerr << "Line " << lineno << ": There is no such subsection to be entered: " << demangle(get_current_full_path(subsection)) << std::endl; - for (unsigned int i=0; iget_optional (get_current_full_path(entry_name) + path_separator + "value")) - { - // if entry was declared: - // does it match the regex? if not, - // don't enter it into the database - // exception: if it contains characters - // which specify it as a multiple loop - // entry, then ignore content - if (entry_value.find ('{') == std::string::npos) - { - const unsigned int pattern_index - = entries->get (get_current_full_path(entry_name) + path_separator + "pattern"); - if (!patterns[pattern_index]->match(entry_value)) - { - std::cerr << "Line " << lineno << ":" << std::endl - << " The entry value" << std::endl - << " " << entry_value << std::endl - << " for the entry named" << std::endl - << " " << entry_name << std::endl - << " does not match the given pattern" << std::endl - << " " << patterns[pattern_index]->description() - << std::endl; - return false; - } - } - - entries->put (get_current_full_path(entry_name) + path_separator + "value", - entry_value); - return true; - } + { + // if entry was declared: + // does it match the regex? if not, + // don't enter it into the database + // exception: if it contains characters + // which specify it as a multiple loop + // entry, then ignore content + if (entry_value.find ('{') == std::string::npos) + { + const unsigned int pattern_index + = entries->get (get_current_full_path(entry_name) + path_separator + "pattern"); + if (!patterns[pattern_index]->match(entry_value)) + { + std::cerr << "Line " << lineno << ":" << std::endl + << " The entry value" << std::endl + << " " << entry_value << std::endl + << " for the entry named" << std::endl + << " " << entry_name << std::endl + << " does not match the given pattern" << std::endl + << " " << patterns[pattern_index]->description() + << std::endl; + return false; + } + } + + entries->put (get_current_full_path(entry_name) + path_separator + "value", + entry_value); + return true; + } else - { - std::cerr << "Line " << lineno - << ": No such entry was declared:" << std::endl - << " " << entry_name << std::endl - << " " << std::endl; - - return false; - } + { + std::cerr << "Line " << lineno + << ": No such entry was declared:" << std::endl + << " " << entry_name << std::endl + << " " << std::endl; + + return false; + } } - // this line matched nothing known + // this line matched nothing known std::cerr << "Line " << lineno << ": This line matched nothing known ('set' or 'subsection' missing!?):" << std::endl - << " " << line << std::endl; + << " " << line << std::endl; return false; } @@ -2155,13 +2155,13 @@ ParameterHandler::operator == (const ParameterHandler & prm2) const if (patterns[j]->description() != prm2.patterns[j]->description()) return false; - // instead of walking through all - // the nodes of the two trees - // entries and prm2.entries and - // comparing them for equality, - // simply dump the content of the - // entire structure into a string - // and compare those for equality + // instead of walking through all + // the nodes of the two trees + // entries and prm2.entries and + // comparing them for equality, + // simply dump the content of the + // entire structure into a string + // and compare those for equality std::ostringstream o1, o2; write_json (o1, *entries); write_json (o2, *prm2.entries); @@ -2178,7 +2178,7 @@ MultipleParameterLoop::UserClass::~UserClass () MultipleParameterLoop::MultipleParameterLoop() : - n_branches(0) + n_branches(0) {} @@ -2201,14 +2201,14 @@ bool MultipleParameterLoop::read_input (std::istream &input) bool MultipleParameterLoop::read_input (const std::string &filename, - bool optional, - bool write_compact) + bool optional, + bool write_compact) { return ParameterHandler::read_input (filename, optional, write_compact); - // don't call init_branches, since this read_input - // function calls - // MultipleParameterLoop::Readinput(std::istream &, std::ostream &) - // which itself calls init_branches. + // don't call init_branches, since this read_input + // function calls + // MultipleParameterLoop::Readinput(std::istream &, std::ostream &) + // which itself calls init_branches. } @@ -2226,7 +2226,7 @@ void MultipleParameterLoop::loop (MultipleParameterLoop::UserClass &uc) { for (unsigned int run_no=0; run_noget_child (get_current_path()); - // check all entries in the present - // subsection whether they are - // multiple entries - // - // we loop over entries in sorted - // order to guarantee backward - // compatibility to an earlier - // implementation + // check all entries in the present + // subsection whether they are + // multiple entries + // + // we loop over entries in sorted + // order to guarantee backward + // compatibility to an earlier + // implementation for (boost::property_tree::ptree::const_assoc_iterator - p = current_section.ordered_begin(); + p = current_section.ordered_begin(); p != current_section.not_found(); ++p) if (is_parameter_node (p->second) == true) { - const std::string value = p->second.get("value"); - if (value.find('{') != std::string::npos) - multiple_choices.push_back (Entry(subsection_path, - demangle(p->first), - value)); + const std::string value = p->second.get("value"); + if (value.find('{') != std::string::npos) + multiple_choices.push_back (Entry(subsection_path, + demangle(p->first), + value)); } - // then loop over all subsections + // then loop over all subsections for (boost::property_tree::ptree::const_iterator - p = current_section.begin(); + p = current_section.begin(); p != current_section.end(); ++p) if (is_parameter_node (p->second) == false) { - enter_subsection (demangle(p->first)); - init_branches_current_section (); - leave_subsection (); + enter_subsection (demangle(p->first)); + init_branches_current_section (); + leave_subsection (); } } @@ -2324,39 +2324,39 @@ void MultipleParameterLoop::fill_entry_values (const unsigned int run_no) ++choice) { const unsigned int selection - = (run_no/possibilities) % choice->different_values.size(); + = (run_no/possibilities) % choice->different_values.size(); std::string entry_value; if (choice->type == Entry::variant) - entry_value = choice->different_values[selection]; + entry_value = choice->different_values[selection]; else - { - if (run_no>=choice->different_values.size()) - { - std::cerr << "The given array for entry <" - << choice->entry_name - << "> does not contain enough elements! Taking empty string instead." + { + if (run_no>=choice->different_values.size()) + { + std::cerr << "The given array for entry <" + << choice->entry_name + << "> does not contain enough elements! Taking empty string instead." << std::endl; - entry_value = ""; - } - else - entry_value = choice->different_values[run_no]; - } - - // temporarily enter the - // subsection tree of this - // multiple entry, set the - // value, and get out - // again. the set() operation - // also tests for the - // correctness of the value - // with regard to the pattern + entry_value = ""; + } + else + entry_value = choice->different_values[run_no]; + } + + // temporarily enter the + // subsection tree of this + // multiple entry, set the + // value, and get out + // again. the set() operation + // also tests for the + // correctness of the value + // with regard to the pattern subsection_path.swap (choice->subsection_path); set (choice->entry_name, entry_value); subsection_path.swap (choice->subsection_path); - // move ahead if it was a variant entry + // move ahead if it was a variant entry if (choice->type == Entry::variant) - possibilities *= choice->different_values.size(); + possibilities *= choice->different_values.size(); } } @@ -2376,36 +2376,36 @@ MultipleParameterLoop::memory_consumption () const MultipleParameterLoop::Entry::Entry (const std::vector &ssp, - const std::string &Name, - const std::string &Value) + const std::string &Name, + const std::string &Value) : - subsection_path (ssp), entry_name(Name), entry_value(Value), type (Entry::array) + subsection_path (ssp), entry_name(Name), entry_value(Value), type (Entry::array) {} void MultipleParameterLoop::Entry::split_different_values () { - // split string into three parts: - // part before the opening "{", - // the selection itself, final - // part after "}" + // split string into three parts: + // part before the opening "{", + // the selection itself, final + // part after "}" std::string prefix (entry_value, 0, entry_value.find('{')); std::string multiple(entry_value, entry_value.find('{')+1, - entry_value.rfind('}')-entry_value.find('{')-1); + entry_value.rfind('}')-entry_value.find('{')-1); std::string postfix (entry_value, entry_value.rfind('}')+1, std::string::npos); - // if array entry {{..}}: delete inner - // pair of braces + // if array entry {{..}}: delete inner + // pair of braces if (multiple[0]=='{') multiple.erase (0,1); if (multiple[multiple.size()-1] == '}') multiple.erase (multiple.size()-1, 1); - // erase leading and trailing spaces - // in multiple + // erase leading and trailing spaces + // in multiple while (std::isspace (multiple[0])) multiple.erase (0,1); while (std::isspace (multiple[multiple.size()-1])) multiple.erase (multiple.size()-1,1); - // delete spaces around '|' + // delete spaces around '|' while (multiple.find(" |") != std::string::npos) multiple.replace (multiple.find(" |"), 2, "|"); while (multiple.find("| ") != std::string::npos) @@ -2414,15 +2414,15 @@ void MultipleParameterLoop::Entry::split_different_values () while (multiple.find('|') != std::string::npos) { different_values.push_back (prefix + - std::string(multiple, 0, multiple.find('|'))+ - postfix); + std::string(multiple, 0, multiple.find('|'))+ + postfix); multiple.erase (0, multiple.find('|')+1); }; - // make up the last selection ("while" broke - // because there was no '|' any more + // make up the last selection ("while" broke + // because there was no '|' any more different_values.push_back (prefix+multiple+postfix); - // finally check whether this was a variant - // entry ({...}) or an array ({{...}}) + // finally check whether this was a variant + // entry ({...}) or an array ({{...}}) if ((entry_value.find("{{") != std::string::npos) && (entry_value.find("}}") != std::string::npos)) type = Entry::array; @@ -2435,10 +2435,10 @@ std::size_t MultipleParameterLoop::Entry::memory_consumption () const { return (MemoryConsumption::memory_consumption (subsection_path) + - MemoryConsumption::memory_consumption (entry_name) + - MemoryConsumption::memory_consumption (entry_value) + - MemoryConsumption::memory_consumption (different_values) + - sizeof (type)); + MemoryConsumption::memory_consumption (entry_name) + + MemoryConsumption::memory_consumption (entry_value) + + MemoryConsumption::memory_consumption (different_values) + + sizeof (type)); } DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/base/parsed_function.cc b/deal.II/source/base/parsed_function.cc index 53d2224dae..bba1fda6cb 100644 --- a/deal.II/source/base/parsed_function.cc +++ b/deal.II/source/base/parsed_function.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2007, 2008, 2009 by the deal.II authors +// Copyright (C) 2007, 2008, 2009, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -20,123 +20,123 @@ DEAL_II_NAMESPACE_OPEN namespace Functions { template ParsedFunction::ParsedFunction (const unsigned int n_components, const double h) - : - AutoDerivativeFunction(h, n_components), - function_object(n_components) + : + AutoDerivativeFunction(h, n_components), + function_object(n_components) {} - + template void ParsedFunction::declare_parameters(ParameterHandler &prm, - const unsigned int n_components) + const unsigned int n_components) { Assert(n_components > 0, ExcZero()); std::string vnames; switch (dim) { - case 1: - vnames = "x,t"; - break; - case 2: - vnames = "x,y,t"; - break; - case 3: - vnames = "x,y,z,t"; - break; - default: - AssertThrow(false, ExcNotImplemented()); - break; + case 1: + vnames = "x,t"; + break; + case 2: + vnames = "x,y,t"; + break; + case 3: + vnames = "x,y,z,t"; + break; + default: + AssertThrow(false, ExcNotImplemented()); + break; } - prm.declare_entry("Variable names", vnames, Patterns::Anything(), - "The name of the variables as they will be used in the " - "function, separated by ','."); + prm.declare_entry("Variable names", vnames, Patterns::Anything(), + "The name of the variables as they will be used in the " + "function, separated by ','."); - // The expression of the function + // The expression of the function std::string expr = "0"; for (unsigned int i=1; i - void ParsedFunction::parse_parameters(ParameterHandler &prm) + void ParsedFunction::parse_parameters(ParameterHandler &prm) { std::string vnames = prm.get("Variable names"); std::string expression = prm.get("Function expression"); std::string constants_list = prm.get("Function constants"); - std::vector const_list = + std::vector const_list = Utilities::split_string_list(constants_list, ','); std::map constants; for(unsigned int i = 0; i < const_list.size(); ++i) { - std::vector this_c = - Utilities::split_string_list(const_list[i], '='); - AssertThrow(this_c.size() == 2, ExcMessage("Invalid format")); - double tmp; - AssertThrow( std::sscanf(this_c[1].c_str(), "%lf", &tmp), - ExcMessage("Double number?")); - constants[this_c[0]] = tmp; + std::vector this_c = + Utilities::split_string_list(const_list[i], '='); + AssertThrow(this_c.size() == 2, ExcMessage("Invalid format")); + double tmp; + AssertThrow( std::sscanf(this_c[1].c_str(), "%lf", &tmp), + ExcMessage("Double number?")); + constants[this_c[0]] = tmp; } - + constants["pi"] = numbers::PI; constants["Pi"] = numbers::PI; unsigned int nn = (Utilities::split_string_list(vnames)).size(); switch (nn) { - case dim: - // Time independent function - function_object.initialize(vnames, expression, constants); - break; - case dim+1: - // Time dependent function - function_object.initialize(vnames, expression, constants, true); - break; - default: - AssertThrow(false, ExcMessage("Not the correct size. Check your code.")); + case dim: + // Time independent function + function_object.initialize(vnames, expression, constants); + break; + case dim+1: + // Time dependent function + function_object.initialize(vnames, expression, constants, true); + break; + default: + AssertThrow(false, ExcMessage("Not the correct size. Check your code.")); } } - + template void ParsedFunction::vector_value (const Point &p, - Vector &values) const - { + Vector &values) const + { function_object.vector_value(p, values); } - + template double ParsedFunction::value (const Point &p, - unsigned int comp) const - { + unsigned int comp) const + { return function_object.value(p, comp); } - + template void ParsedFunction::set_time (const double newtime) - { + { function_object.set_time(newtime); AutoDerivativeFunction::set_time(newtime); } - + // Explicit instantiations template class ParsedFunction<1>; template class ParsedFunction<2>; diff --git a/deal.II/source/base/partitioner.cc b/deal.II/source/base/partitioner.cc index d8bab357c8..ebeaa14876 100644 --- a/deal.II/source/base/partitioner.cc +++ b/deal.II/source/base/partitioner.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -47,8 +47,8 @@ namespace Utilities Partitioner::Partitioner (const IndexSet &locally_owned_indices, - const IndexSet &ghost_indices_in, - const MPI_Comm communicator_in) + const IndexSet &ghost_indices_in, + const MPI_Comm communicator_in) : global_size (static_cast(locally_owned_indices.size())), n_ghost_indices_data (0), @@ -64,7 +64,7 @@ namespace Utilities Partitioner::Partitioner (const IndexSet &locally_owned_indices, - const MPI_Comm communicator_in) + const MPI_Comm communicator_in) : global_size (static_cast(locally_owned_indices.size())), n_ghost_indices_data (0), @@ -83,25 +83,25 @@ namespace Utilities { if (Utilities::System::job_supports_mpi() == true) { - my_pid = Utilities::MPI::this_mpi_process(communicator); - n_procs = Utilities::MPI::n_mpi_processes(communicator); + my_pid = Utilities::MPI::this_mpi_process(communicator); + n_procs = Utilities::MPI::n_mpi_processes(communicator); } else { - my_pid = 0; - n_procs = 1; + my_pid = 0; + n_procs = 1; } - // set the local range + // set the local range Assert (locally_owned_indices.is_contiguous() == 1, - ExcMessage ("The index set specified in locally_owned_indices " - "is not contiguous.")); + ExcMessage ("The index set specified in locally_owned_indices " + "is not contiguous.")); locally_owned_indices.compress(); if (locally_owned_indices.n_elements()>0) local_range_data = std::pair - (locally_owned_indices.nth_index_in_set(0), - locally_owned_indices.nth_index_in_set(0)+ - locally_owned_indices.n_elements()); + (locally_owned_indices.nth_index_in_set(0), + locally_owned_indices.nth_index_in_set(0)+ + locally_owned_indices.n_elements()); locally_owned_range_data.set_size (locally_owned_indices.size()); locally_owned_range_data.add_range (local_range_data.first,local_range_data.second); locally_owned_range_data.compress(); @@ -114,205 +114,205 @@ namespace Utilities void Partitioner::set_ghost_indices (const IndexSet &ghost_indices_in) { - // Set ghost indices from input. To be sure - // that no entries from the locally owned - // range are present, subtract the locally - // owned indices in any case. + // Set ghost indices from input. To be sure + // that no entries from the locally owned + // range are present, subtract the locally + // owned indices in any case. Assert (ghost_indices_in.n_elements() == 0 || - ghost_indices_in.size() == locally_owned_range_data.size(), - ExcDimensionMismatch (ghost_indices_in.size(), - locally_owned_range_data.size())); + ghost_indices_in.size() == locally_owned_range_data.size(), + ExcDimensionMismatch (ghost_indices_in.size(), + locally_owned_range_data.size())); ghost_indices_data = ghost_indices_in; ghost_indices_data.subtract_set (locally_owned_range_data); ghost_indices_data.compress(); n_ghost_indices_data = ghost_indices_data.n_elements(); - // In the rest of this function, we determine - // the point-to-point communication pattern of - // the partitioner. We make up a list with - // both the processors the ghost indices - // actually belong to, and the indices that - // are locally held but ghost indices of other - // processors. This allows then to import and - // export data very easily. - - // find out the end index for each processor - // and communicate it (this implies the start - // index for the next processor) + // In the rest of this function, we determine + // the point-to-point communication pattern of + // the partitioner. We make up a list with + // both the processors the ghost indices + // actually belong to, and the indices that + // are locally held but ghost indices of other + // processors. This allows then to import and + // export data very easily. + + // find out the end index for each processor + // and communicate it (this implies the start + // index for the next processor) #ifdef DEAL_II_COMPILER_SUPPORTS_MPI if (n_procs < 2) { - Assert (ghost_indices_data.n_elements() == 0, ExcInternalError()); - Assert (n_import_indices_data == 0, ExcInternalError()); - Assert (n_ghost_indices_data == 0, ExcInternalError()); - return; + Assert (ghost_indices_data.n_elements() == 0, ExcInternalError()); + Assert (n_import_indices_data == 0, ExcInternalError()); + Assert (n_ghost_indices_data == 0, ExcInternalError()); + return; } std::vector first_index (n_procs+1); first_index[0] = 0; MPI_Allgather(&local_range_data.second, sizeof(types::global_dof_index), - MPI_BYTE, &first_index[1], sizeof(types::global_dof_index), - MPI_BYTE, communicator); + MPI_BYTE, &first_index[1], sizeof(types::global_dof_index), + MPI_BYTE, communicator); first_index[n_procs] = global_size; - // fix case when there are some processors - // without any locally owned indices: then - // there might be a zero in some entries + // fix case when there are some processors + // without any locally owned indices: then + // there might be a zero in some entries if (global_size > 0) { - unsigned int first_proc_with_nonzero_dofs = 0; - for (unsigned int i=0; i0) - { - first_proc_with_nonzero_dofs = i; - break; - } - for (unsigned int i=first_proc_with_nonzero_dofs+1; i0) + { + first_proc_with_nonzero_dofs = i; + break; + } + for (unsigned int i=first_proc_with_nonzero_dofs+1; i expanded_ghost_indices (n_ghost_indices_data); unsigned int n_ghost_targets = 0; if (n_ghost_indices_data > 0) { - // Create first a vector of ghost_targets from - // the list of ghost indices and then push - // back new values. When we are done, copy the - // data to that field of the partitioner. This - // way, the variable ghost_targets will have - // exactly the size we need, whereas the - // vector filled with push_back might actually - // be too long. - unsigned int current_proc = 0; - ghost_indices_data.fill_index_vector (expanded_ghost_indices); - unsigned int current_index = expanded_ghost_indices[0]; - while(current_index >= first_index[current_proc+1]) - current_proc++; - std::vector > ghost_targets_temp - (1, std::pair(current_proc, 0)); - n_ghost_targets++; - - for (unsigned int iterator=1; iterator= first_index[current_proc+1]) - current_proc++; - AssertIndexRange (current_proc, n_procs); - if( ghost_targets_temp[n_ghost_targets-1].first < current_proc) - { - ghost_targets_temp[n_ghost_targets-1].second = - iterator - ghost_targets_temp[n_ghost_targets-1].second; - ghost_targets_temp.push_back(std::pair(current_proc,iterator)); - n_ghost_targets++; - } - } - ghost_targets_temp[n_ghost_targets-1].second = - n_ghost_indices_data - ghost_targets_temp[n_ghost_targets-1].second; - ghost_targets_data = ghost_targets_temp; + // Create first a vector of ghost_targets from + // the list of ghost indices and then push + // back new values. When we are done, copy the + // data to that field of the partitioner. This + // way, the variable ghost_targets will have + // exactly the size we need, whereas the + // vector filled with push_back might actually + // be too long. + unsigned int current_proc = 0; + ghost_indices_data.fill_index_vector (expanded_ghost_indices); + unsigned int current_index = expanded_ghost_indices[0]; + while(current_index >= first_index[current_proc+1]) + current_proc++; + std::vector > ghost_targets_temp + (1, std::pair(current_proc, 0)); + n_ghost_targets++; + + for (unsigned int iterator=1; iterator= first_index[current_proc+1]) + current_proc++; + AssertIndexRange (current_proc, n_procs); + if( ghost_targets_temp[n_ghost_targets-1].first < current_proc) + { + ghost_targets_temp[n_ghost_targets-1].second = + iterator - ghost_targets_temp[n_ghost_targets-1].second; + ghost_targets_temp.push_back(std::pair(current_proc,iterator)); + n_ghost_targets++; + } + } + ghost_targets_temp[n_ghost_targets-1].second = + n_ghost_indices_data - ghost_targets_temp[n_ghost_targets-1].second; + ghost_targets_data = ghost_targets_temp; } - // find the processes that want to import to - // me + // find the processes that want to import to + // me { std::vector send_buffer (n_procs, 0); std::vector receive_buffer (n_procs, 0); for (unsigned int i=0; i > import_targets_temp; n_import_indices_data = 0; for (unsigned int i=0; i 0) - { - n_import_indices_data += receive_buffer[i]; - import_targets_temp.push_back(std::pair (i, receive_buffer[i])); - } + if (receive_buffer[i] > 0) + { + n_import_indices_data += receive_buffer[i]; + import_targets_temp.push_back(std::pair (i, receive_buffer[i])); + } import_targets_data = import_targets_temp; } - // send and receive indices for import - // data. non-blocking receives and blocking - // sends + // send and receive indices for import + // data. non-blocking receives and blocking + // sends std::vector expanded_import_indices (n_import_indices_data); { unsigned int current_index_start = 0; std::vector import_requests (import_targets_data.size()); for (unsigned int i=0; i > compressed_import_indices; - for (unsigned int i=0;i= local_range_data.first && - expanded_import_indices[i] < local_range_data.second, - ExcIndexRange(expanded_import_indices[i], local_range_data.first, - local_range_data.second)); - unsigned int new_index = (expanded_import_indices[i] - - local_range_data.first); - if (new_index == last_index+1) - compressed_import_indices.back().second++; - else - { - compressed_import_indices.push_back - (std::pair(new_index,new_index+1)); - } - last_index = new_index; - } - import_indices_data = compressed_import_indices; - - // sanity check + unsigned int last_index = numbers::invalid_unsigned_int-1; + std::vector > compressed_import_indices; + for (unsigned int i=0;i= local_range_data.first && + expanded_import_indices[i] < local_range_data.second, + ExcIndexRange(expanded_import_indices[i], local_range_data.first, + local_range_data.second)); + unsigned int new_index = (expanded_import_indices[i] - + local_range_data.first); + if (new_index == last_index+1) + compressed_import_indices.back().second++; + else + { + compressed_import_indices.push_back + (std::pair(new_index,new_index+1)); + } + last_index = new_index; + } + import_indices_data = compressed_import_indices; + + // sanity check #ifdef DEBUG - const unsigned int n_local_dofs = local_range_data.second-local_range_data.first; - for (unsigned int i=0; isecond; } std::vector& PathSearch::get_suffix_list(const std::string& cls) -{ +{ // This is redundant. The constructor should have already called the // add_path function with the path_list bit... // Modified by Luca Heltai. If a class is not there, add it if(suffix_lists.count(cls) == 0) add_class(cls); - + // Assert(suffix_lists.count(cls) != 0, ExcNoClass(cls)); Assert(suffix_lists.count(cls) != 0, ExcInternalError()); - + return suffix_lists.find(cls)->second; } PathSearch::PathSearch(const std::string& cls, - const unsigned int debug) - : - cls(cls), - my_path_list(get_path_list(cls)), - my_suffix_list(get_suffix_list(cls)), - debug(debug) + const unsigned int debug) + : + cls(cls), + my_path_list(get_path_list(cls)), + my_suffix_list(get_suffix_list(cls)), + debug(debug) {} std::string PathSearch::find (const std::string& filename, - const std::string& suffix, - const char* open_mode) + const std::string& suffix, + const char* open_mode) { std::vector::const_iterator path; const std::vector::const_iterator endp = my_path_list.end(); std::string real_name; - + if (debug > 2) deallog << "PathSearch[" << cls << "] " - << my_path_list.size() << " directories " - << std::endl; - - // Try to open file + << my_path_list.size() << " directories " + << std::endl; + + // Try to open file for (path = my_path_list.begin(); path != endp; ++path) { real_name = *path + filename + suffix; if (debug > 1) - deallog << "PathSearch[" << cls << "] trying " - << real_name << std::endl; + deallog << "PathSearch[" << cls << "] trying " + << real_name << std::endl; FILE* fp = fopen(real_name.c_str(), open_mode); if (fp != 0) - { - if (debug > 0) - deallog << "PathSearch[" << cls << "] opened " - << real_name << std::endl; - fclose(fp); - return real_name; - } + { + if (debug > 0) + deallog << "PathSearch[" << cls << "] opened " + << real_name << std::endl; + fclose(fp); + return real_name; + } } AssertThrow(false, ExcFileNotFound(filename, cls)); return std::string(""); @@ -137,28 +137,28 @@ PathSearch::find (const std::string& filename, std::string PathSearch::find (const std::string& filename, - const char* open_mode) + const char* open_mode) { std::vector::const_iterator suffix; const std::vector::const_iterator ends = my_suffix_list.end(); if (debug > 2) deallog << "PathSearch[" << cls << "] " - << my_path_list.size() << " directories " - << my_suffix_list.size() << " suffixes" - << std::endl; - + << my_path_list.size() << " directories " + << my_suffix_list.size() << " suffixes" + << std::endl; + for (suffix = my_suffix_list.begin(); suffix != ends; ++suffix) { try - { - return find(filename, *suffix, open_mode); - } + { + return find(filename, *suffix, open_mode); + } catch (ExcFileNotFound) - { - continue; - } - + { + continue; + } + } AssertThrow(false, ExcFileNotFound(filename, cls)); return std::string(""); @@ -168,12 +168,12 @@ PathSearch::find (const std::string& filename, void PathSearch::add_class (const std::string& cls) { - // Make sure standard classes are - // initialized first + // Make sure standard classes are + // initialized first if (path_lists.empty()) initialize_classes(); - // Add empty path and empty suffix - // for new class + // Add empty path and empty suffix + // for new class std::vector v; v.push_back(empty); path_lists.insert(map_type(cls, v)); @@ -183,7 +183,7 @@ PathSearch::add_class (const std::string& cls) void PathSearch::add_path (const std::string& path, - Position pos) + Position pos) { if (pos == back) my_path_list.push_back(path); @@ -192,9 +192,9 @@ PathSearch::add_path (const std::string& path, else if (pos == after_none) { std::vector::iterator - i = std::find(my_path_list.begin(), my_path_list.end(), empty); + i = std::find(my_path_list.begin(), my_path_list.end(), empty); if (i != my_path_list.end()) - ++i; + ++i; my_path_list.insert(i, path); } } @@ -202,7 +202,7 @@ PathSearch::add_path (const std::string& path, void PathSearch::add_suffix (const std::string& suffix, - Position pos) + Position pos) { if (pos == back) my_suffix_list.push_back(suffix); @@ -211,9 +211,9 @@ PathSearch::add_suffix (const std::string& suffix, else if (pos == after_none) { std::vector::iterator - i = std::find(my_suffix_list.begin(), my_suffix_list.end(), empty); + i = std::find(my_suffix_list.begin(), my_suffix_list.end(), empty); if (i != my_suffix_list.end()) - ++i; + ++i; my_suffix_list.insert(i, suffix); } } diff --git a/deal.II/source/base/polynomial.cc b/deal.II/source/base/polynomial.cc index b15144ff82..df17c1af5f 100644 --- a/deal.II/source/base/polynomial.cc +++ b/deal.II/source/base/polynomial.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2011 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -50,9 +50,9 @@ namespace Polynomials template Polynomial::Polynomial (const std::vector &a) : - coefficients (a), - in_lagrange_product_form (false), - lagrange_weight (1.) + coefficients (a), + in_lagrange_product_form (false), + lagrange_weight (1.) {} @@ -61,15 +61,15 @@ namespace Polynomials Polynomial::Polynomial (const unsigned int n) : coefficients (n+1, 0.), - in_lagrange_product_form (false), - lagrange_weight (1.) + in_lagrange_product_form (false), + lagrange_weight (1.) {} template Polynomial::Polynomial (const std::vector > &supp, - const unsigned int center) + const unsigned int center) : in_lagrange_product_form (true) { @@ -80,17 +80,17 @@ namespace Polynomials number tmp_lagrange_weight = 1.; for (unsigned int i=0; i std::numeric_limits::min(), - ExcMessage ("Underflow in computation of Lagrange denominator.")); + ExcMessage ("Underflow in computation of Lagrange denominator.")); Assert (std::fabs(tmp_lagrange_weight) < std::numeric_limits::max(), - ExcMessage ("Overflow in computation of Lagrange denominator.")); + ExcMessage ("Overflow in computation of Lagrange denominator.")); #endif lagrange_weight = static_cast(1.)/tmp_lagrange_weight; } @@ -105,106 +105,106 @@ namespace Polynomials Assert (values.size() > 0, ExcZero()); const unsigned int values_size=values.size(); - // evaluate Lagrange polynomial and - // derivatives + // evaluate Lagrange polynomial and + // derivatives if (in_lagrange_product_form == true) { - // to compute the value and all derivatives of - // a polynomial of the form - // (x-x_1)*(x-x_2)*...*(x-x_n), expand the - // derivatives like automatic differentiation - // does. - const unsigned int n_supp = lagrange_support_points.size(); - switch (values_size) - { - default: - values[0] = 1; - for (unsigned int d=1; d0; --k) - values[k] = (values[k] * v + values[k-1]); - values[0] *= v; - } - // finally, multiply by the weight in the - // Lagrange denominator. Could be done instead - // of setting values[0] = 1 above, but that - // gives different accumulation of round-off - // errors (multiplication is not associative) - // compared to when we computed the weight, - // and hence a basis function might not be - // exactly one at the center point, which is - // nice to have. We also multiply derivatives - // by k! to transform the product p_n = - // p^(n)(x)/k! into the actual form of the - // derivative - { - number k_faculty = 1; - for (unsigned int k=0; k(k+1); - } - } - break; - - // manually implement size 1 (values only), - // size 2 (value + first derivative), and size - // 3 (up to second derivative) since they - // might be called often. then, we can unroll - // the loop. - case 1: - values[0] = 1; - for (unsigned int i=0; i(2) * lagrange_weight; - break; - } - return; + // to compute the value and all derivatives of + // a polynomial of the form + // (x-x_1)*(x-x_2)*...*(x-x_n), expand the + // derivatives like automatic differentiation + // does. + const unsigned int n_supp = lagrange_support_points.size(); + switch (values_size) + { + default: + values[0] = 1; + for (unsigned int d=1; d0; --k) + values[k] = (values[k] * v + values[k-1]); + values[0] *= v; + } + // finally, multiply by the weight in the + // Lagrange denominator. Could be done instead + // of setting values[0] = 1 above, but that + // gives different accumulation of round-off + // errors (multiplication is not associative) + // compared to when we computed the weight, + // and hence a basis function might not be + // exactly one at the center point, which is + // nice to have. We also multiply derivatives + // by k! to transform the product p_n = + // p^(n)(x)/k! into the actual form of the + // derivative + { + number k_faculty = 1; + for (unsigned int k=0; k(k+1); + } + } + break; + + // manually implement size 1 (values only), + // size 2 (value + first derivative), and size + // 3 (up to second derivative) since they + // might be called often. then, we can unroll + // the loop. + case 1: + values[0] = 1; + for (unsigned int i=0; i(2) * lagrange_weight; + break; + } + return; } Assert (coefficients.size() > 0, ExcEmptyObject()); @@ -257,33 +257,33 @@ namespace Polynomials void Polynomial::transform_into_standard_form () { - // should only be called when the product form - // is active + // should only be called when the product form + // is active Assert (in_lagrange_product_form == true, ExcInternalError()); Assert (coefficients.size() == 0, ExcInternalError()); - // compute coefficients by expanding the - // product (x-x_i) term by term + // compute coefficients by expanding the + // product (x-x_i) term by term coefficients.resize (lagrange_support_points.size()+1); if (lagrange_support_points.size() == 0) coefficients[0] = 1.; else { - coefficients[0] = -lagrange_support_points[0]; - coefficients[1] = 1.; - for (unsigned int i=1; i0; --j) - coefficients[j] = (-lagrange_support_points[i]*coefficients[j] + - coefficients[j-1]); - coefficients[0] *= -lagrange_support_points[i]; - } + coefficients[0] = -lagrange_support_points[0]; + coefficients[1] = 1.; + for (unsigned int i=1; i0; --j) + coefficients[j] = (-lagrange_support_points[i]*coefficients[j] + + coefficients[j-1]); + coefficients[0] *= -lagrange_support_points[i]; + } } for (unsigned int i=0; i new_points; lagrange_support_points.swap(new_points); in_lagrange_product_form = false; @@ -312,21 +312,21 @@ namespace Polynomials void Polynomial::scale (const number factor) { - // to scale (x-x_0)*(x-x_1)*...*(x-x_n), scale - // support points by 1./factor and the weight - // likewise + // to scale (x-x_0)*(x-x_1)*...*(x-x_n), scale + // support points by 1./factor and the weight + // likewise if (in_lagrange_product_form == true) { - number inv_fact = number(1.)/factor; - number accumulated_fact = 1.; - for (unsigned int i=0; i::iterator c = coefficients.begin(); - c != coefficients.end(); ++c) - *c *= s; + for (typename std::vector::iterator c = coefficients.begin(); + c != coefficients.end(); ++c) + *c *= s; } return *this; } @@ -366,30 +366,30 @@ namespace Polynomials Polynomial& Polynomial::operator *= (const Polynomial& p) { - // if we are in Lagrange form, just append the - // new points + // if we are in Lagrange form, just append the + // new points if (in_lagrange_product_form == true && p.in_lagrange_product_form == true) { - lagrange_weight *= p.lagrange_weight; - lagrange_support_points.insert (lagrange_support_points.end(), - p.lagrange_support_points.begin(), - p.lagrange_support_points.end()); + lagrange_weight *= p.lagrange_weight; + lagrange_support_points.insert (lagrange_support_points.end(), + p.lagrange_support_points.begin(), + p.lagrange_support_points.end()); } - // cannot retain product form, recompute... + // cannot retain product form, recompute... else if (in_lagrange_product_form == true) transform_into_standard_form(); - // need to transform p into standard form as - // well if necessary. copy the polynomial to - // do this + // need to transform p into standard form as + // well if necessary. copy the polynomial to + // do this std_cxx1x::shared_ptr > q_data; const Polynomial * q = 0; if (p.in_lagrange_product_form == true) { - q_data.reset (new Polynomial(p)); - q_data->transform_into_standard_form(); - q = q_data.get(); + q_data.reset (new Polynomial(p)); + q_data->transform_into_standard_form(); + q = q_data.get(); } else q = &p; @@ -401,7 +401,7 @@ namespace Polynomials for (unsigned int i=0; icoefficients.size(); ++i) for (unsigned int j=0; jcoefficients.size(); ++j) - new_coefficients[i+j] += this->coefficients[j]*q->coefficients[i]; + new_coefficients[i+j] += this->coefficients[j]*q->coefficients[i]; this->coefficients = new_coefficients; return *this; @@ -413,27 +413,27 @@ namespace Polynomials Polynomial& Polynomial::operator += (const Polynomial& p) { - // Lagrange product form cannot reasonably be - // retained after polynomial addition. we - // could in theory check if either this - // polynomial or the other is a zero - // polynomial and retain it, but we actually - // currently (r23974) assume that the addition - // of a zero polynomial changes the state and - // tests equivalence. + // Lagrange product form cannot reasonably be + // retained after polynomial addition. we + // could in theory check if either this + // polynomial or the other is a zero + // polynomial and retain it, but we actually + // currently (r23974) assume that the addition + // of a zero polynomial changes the state and + // tests equivalence. if (in_lagrange_product_form == true) transform_into_standard_form(); - // need to transform p into standard form as - // well if necessary. copy the polynomial to - // do this + // need to transform p into standard form as + // well if necessary. copy the polynomial to + // do this std_cxx1x::shared_ptr > q_data; const Polynomial * q = 0; if (p.in_lagrange_product_form == true) { - q_data.reset (new Polynomial(p)); - q_data->transform_into_standard_form(); - q = q_data.get(); + q_data.reset (new Polynomial(p)); + q_data->transform_into_standard_form(); + q = q_data.get(); } else q = &p; @@ -455,21 +455,21 @@ namespace Polynomials Polynomial& Polynomial::operator -= (const Polynomial& p) { - // Lagrange product form cannot reasonably be - // retained after polynomial addition + // Lagrange product form cannot reasonably be + // retained after polynomial addition if (in_lagrange_product_form == true) transform_into_standard_form(); - // need to transform p into standard form as - // well if necessary. copy the polynomial to - // do this + // need to transform p into standard form as + // well if necessary. copy the polynomial to + // do this std_cxx1x::shared_ptr > q_data; const Polynomial * q = 0; if (p.in_lagrange_product_form == true) { - q_data.reset (new Polynomial(p)); - q_data->transform_into_standard_form(); - q = q_data.get(); + q_data.reset (new Polynomial(p)); + q_data->transform_into_standard_form(); + q = q_data.get(); } else q = &p; @@ -491,26 +491,26 @@ namespace Polynomials bool Polynomial::operator == (const Polynomial & p) const { - // need to distinguish a few cases based on - // whether we are in product form or not. two - // polynomials can still be the same when they - // are on different forms, but the expansion - // is the same + // need to distinguish a few cases based on + // whether we are in product form or not. two + // polynomials can still be the same when they + // are on different forms, but the expansion + // is the same if (in_lagrange_product_form == true && - p.in_lagrange_product_form == true) + p.in_lagrange_product_form == true) return ((lagrange_weight == p.lagrange_weight) && - (lagrange_support_points == p.lagrange_support_points)); + (lagrange_support_points == p.lagrange_support_points)); else if (in_lagrange_product_form == true) { - Polynomial q = *this; - q.transform_into_standard_form(); - return (q.coefficients == p.coefficients); + Polynomial q = *this; + q.transform_into_standard_form(); + return (q.coefficients == p.coefficients); } else if (p.in_lagrange_product_form == true) { - Polynomial q = p; - q.transform_into_standard_form(); - return (q.coefficients == coefficients); + Polynomial q = p; + q.transform_into_standard_form(); + return (q.coefficients == coefficients); } else return (p.coefficients == coefficients); @@ -537,8 +537,8 @@ namespace Polynomials coefficients[0] = offset; #else - // too many coefficients cause overflow in - // the binomial coefficient used below + // too many coefficients cause overflow in + // the binomial coefficient used below Assert (coefficients.size() < 31, ExcNotImplemented()); // Copy coefficients to a vector of @@ -600,16 +600,16 @@ namespace Polynomials void Polynomial::shift (const number2 offset) { - // shift is simple for a polynomial in product - // form, (x-x_0)*(x-x_1)*...*(x-x_n). just add - // offset to all shifts + // shift is simple for a polynomial in product + // form, (x-x_0)*(x-x_1)*...*(x-x_n). just add + // offset to all shifts if (in_lagrange_product_form == true) { - for (unsigned int i=0; i Polynomial::derivative () const { - // no simple form possible for Lagrange - // polynomial on product form + // no simple form possible for Lagrange + // polynomial on product form if (degree() == 0) return Monomial(0, 0.); @@ -628,9 +628,9 @@ namespace Polynomials const Polynomial * q = 0; if (in_lagrange_product_form == true) { - q_data.reset (new Polynomial(*this)); - q_data->transform_into_standard_form(); - q = q_data.get(); + q_data.reset (new Polynomial(*this)); + q_data->transform_into_standard_form(); + q = q_data.get(); } else q = this; @@ -648,15 +648,15 @@ namespace Polynomials Polynomial Polynomial::primitive () const { - // no simple form possible for Lagrange - // polynomial on product form + // no simple form possible for Lagrange + // polynomial on product form std_cxx1x::shared_ptr > q_data; const Polynomial * q = 0; if (in_lagrange_product_form == true) { - q_data.reset (new Polynomial(*this)); - q_data->transform_into_standard_form(); - q = q_data.get(); + q_data.reset (new Polynomial(*this)); + q_data->transform_into_standard_form(); + q = q_data.get(); } else q = this; @@ -677,16 +677,16 @@ namespace Polynomials { if (in_lagrange_product_form == true) { - out << lagrange_weight; - for (unsigned int i=0; i=0;--i) - { - out << coefficients[i] << " x^" << i << std::endl; - } + { + out << coefficients[i] << " x^" << i << std::endl; + } } @@ -735,11 +735,11 @@ namespace Polynomials std::vector > generate_equidistant_unit_points (const unsigned int n) { - std::vector > points (n+1); - const double one_over_n = 1./n; + std::vector > points (n+1); + const double one_over_n = 1./n; for (unsigned int k=0;k<=n;++k) - points[k](0) = static_cast(k)*one_over_n; - return points; + points[k](0) = static_cast(k)*one_over_n; + return points; } } } @@ -750,21 +750,21 @@ namespace Polynomials const unsigned int support_point) : Polynomial (internal::LagrangeEquidistant:: - generate_equidistant_unit_points (n), - support_point) + generate_equidistant_unit_points (n), + support_point) { Assert (coefficients.size() == 0, ExcInternalError()); - // For polynomial order up to 3, we have - // precomputed weights. Use these weights - // instead of the product form + // For polynomial order up to 3, we have + // precomputed weights. Use these weights + // instead of the product form if (n <= 3) { - this->in_lagrange_product_form = false; - this->lagrange_weight = 1.; - std::vector new_support_points; - this->lagrange_support_points.swap(new_support_points); - this->coefficients.resize (n+1); + this->in_lagrange_product_form = false; + this->lagrange_weight = 1.; + std::vector new_support_points; + this->lagrange_support_points.swap(new_support_points); + this->coefficients.resize (n+1); compute_coefficients(n, support_point, this->coefficients); } } @@ -919,25 +919,25 @@ namespace Polynomials // no, then generate the // respective coefficients { - // make sure that there is enough - // space in the array for the - // coefficients, so we have to resize - // it to size k+1 - - // but it's more complicated than - // that: we call this function - // recursively, so if we simply - // resize it to k+1 here, then - // compute the coefficients for - // degree k-1 by calling this - // function recursively, then it will - // reset the size to k -- not enough - // for what we want to do below. the - // solution therefore is to only - // resize the size if we are going to - // *increase* it - if (recursive_coefficients.size() < k+1) - recursive_coefficients.resize (k+1); + // make sure that there is enough + // space in the array for the + // coefficients, so we have to resize + // it to size k+1 + + // but it's more complicated than + // that: we call this function + // recursively, so if we simply + // resize it to k+1 here, then + // compute the coefficients for + // degree k-1 by calling this + // function recursively, then it will + // reset the size to k -- not enough + // for what we want to do below. the + // solution therefore is to only + // resize the size if we are going to + // *increase* it + if (recursive_coefficients.size() < k+1) + recursive_coefficients.resize (k+1); if (k<=1) { @@ -1175,25 +1175,25 @@ std::vector > Lobatto::generate_complete_basis (const unsigne // no, then generate the // respective coefficients { - // make sure that there is enough - // space in the array for the - // coefficients, so we have to resize - // it to size k+1 - - // but it's more complicated than - // that: we call this function - // recursively, so if we simply - // resize it to k+1 here, then - // compute the coefficients for - // degree k-1 by calling this - // function recursively, then it will - // reset the size to k -- not enough - // for what we want to do below. the - // solution therefore is to only - // resize the size if we are going to - // *increase* it - if (recursive_coefficients.size() < k+1) - recursive_coefficients.resize (k+1); + // make sure that there is enough + // space in the array for the + // coefficients, so we have to resize + // it to size k+1 + + // but it's more complicated than + // that: we call this function + // recursively, so if we simply + // resize it to k+1 here, then + // compute the coefficients for + // degree k-1 by calling this + // function recursively, then it will + // reset the size to k -- not enough + // for what we want to do below. the + // solution therefore is to only + // resize the size if we are going to + // *increase* it + if (recursive_coefficients.size() < k+1) + recursive_coefficients.resize (k+1); if (k<=1) { @@ -1216,9 +1216,9 @@ std::vector > Lobatto::generate_complete_basis (const unsigne // now make these arrays // const recursive_coefficients[0] = - std_cxx1x::shared_ptr >(c0); + std_cxx1x::shared_ptr >(c0); recursive_coefficients[1] = - std_cxx1x::shared_ptr >(c1); + std_cxx1x::shared_ptr >(c1); } else if (k==2) { @@ -1235,7 +1235,7 @@ std::vector > Lobatto::generate_complete_basis (const unsigne (*c2)[2] = 4.*a; recursive_coefficients[2] = - std_cxx1x::shared_ptr >(c2); + std_cxx1x::shared_ptr >(c2); } else { @@ -1279,7 +1279,7 @@ std::vector > Lobatto::generate_complete_basis (const unsigne // const pointer in the // coefficients array recursive_coefficients[k] = - std_cxx1x::shared_ptr >(ck); + std_cxx1x::shared_ptr >(ck); }; }; } @@ -1295,7 +1295,7 @@ std::vector > Lobatto::generate_complete_basis (const unsigne // then get a pointer to the array // of coefficients. do that in a MT - // safe way + // safe way Threads::ThreadMutex::ScopedLock lock (coefficients_lock); return *recursive_coefficients[k]; } diff --git a/deal.II/source/base/polynomial_space.cc b/deal.II/source/base/polynomial_space.cc index 521876d3fd..ce3fdb3bd8 100644 --- a/deal.II/source/base/polynomial_space.cc +++ b/deal.II/source/base/polynomial_space.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -40,7 +40,7 @@ compute_index (const unsigned int i, unsigned int (&index)[1]) const { Assert(i::set_numbering( const std::vector &renumber) { Assert(renumber.size()==index_map.size(), - ExcDimensionMismatch(renumber.size(), index_map.size())); + ExcDimensionMismatch(renumber.size(), index_map.size())); index_map=renumber; for (unsigned int i=0; i::compute_grad (const unsigned int i, { unsigned int ix[dim]; compute_index(i,ix); - + Tensor<1,dim> result; for (unsigned int d=0; d::compute_grad (const unsigned int i, polynomials[ix[d]].value(p(d), v); result[d] *= v[1]; for (unsigned int d1=0; d1::compute_grad_grad (const unsigned int i, { unsigned int ix[dim]; compute_index(i,ix); - + Tensor<2,dim> result; for (unsigned int d=0; d v(3); @@ -187,16 +187,16 @@ PolynomialSpace::compute_grad_grad (const unsigned int i, polynomials[ix[d]].value(p(d), v); result[d][d] *= v[2]; for (unsigned int d1=0; d1::compute (const Point &p, std::vector > &grad_grads) const { const unsigned int n_1d=polynomials.size(); - + Assert(values.size()==n_pols || values.size()==0, - ExcDimensionMismatch2(values.size(), n_pols, 0)); + ExcDimensionMismatch2(values.size(), n_pols, 0)); Assert(grads.size()==n_pols|| grads.size()==0, - ExcDimensionMismatch2(grads.size(), n_pols, 0)); + ExcDimensionMismatch2(grads.size(), n_pols, 0)); Assert(grad_grads.size()==n_pols|| grad_grads.size()==0, - ExcDimensionMismatch2(grad_grads.size(), n_pols, 0)); + ExcDimensionMismatch2(grad_grads.size(), n_pols, 0)); unsigned int v_size=0; bool update_values=false, update_grads=false, update_grad_grads=false; @@ -238,12 +238,12 @@ PolynomialSpace::compute (const Point &p, v_size=3; } - // Store data in a single - // object. Access is by - // v[d][n][o] - // d: coordinate direction - // n: number of 1d polynomial - // o: order of derivative + // Store data in a single + // object. Access is by + // v[d][n][o] + // d: coordinate direction + // n: number of 1d polynomial + // o: order of derivative Table<2,std::vector > v(dim, n_1d); for (unsigned int d=0; d::compute (const Point &p, if (update_values) { unsigned int k = 0; - + for (unsigned int iz=0;iz<((dim>2) ? n_1d : 1);++iz) - for (unsigned int iy=0;iy<((dim>1) ? n_1d-iz : 1);++iy) - for (unsigned int ix=0; ix1) ? v[1][iy][0] : 1.) - * ((dim>2) ? v[2][iz][0] : 1.); + for (unsigned int iy=0;iy<((dim>1) ? n_1d-iz : 1);++iy) + for (unsigned int ix=0; ix1) ? v[1][iy][0] : 1.) + * ((dim>2) ? v[2][iz][0] : 1.); } - + if (update_grads) { unsigned int k = 0; - + for (unsigned int iz=0;iz<((dim>2) ? n_1d : 1);++iz) - for (unsigned int iy=0;iy<((dim>1) ? n_1d-iz : 1);++iy) - for (unsigned int ix=0; ix1) ? n_1d-iz : 1);++iy) + for (unsigned int ix=0; ix1) ? v[1][iy][(d==1) ? 1 : 0] : 1.) * ((dim>2) ? v[2][iz][(d==2) ? 1 : 0] : 1.); - } + } } if (update_grad_grads) { unsigned int k = 0; - + for (unsigned int iz=0;iz<((dim>2) ? n_1d : 1);++iz) - for (unsigned int iy=0;iy<((dim>1) ? n_1d-iz : 1);++iy) - for (unsigned int ix=0; ix1) ? v[1][iy][j1] : 1.) - * ((dim>2) ? v[2][iz][j2] : 1.); - } - } + for (unsigned int iy=0;iy<((dim>1) ? n_1d-iz : 1);++iy) + for (unsigned int ix=0; ix1) ? v[1][iy][j1] : 1.) + * ((dim>2) ? v[2][iz][j2] : 1.); + } + } } } diff --git a/deal.II/source/base/polynomials_abf.cc b/deal.II/source/base/polynomials_abf.cc index 4c9c91396a..51b120266f 100644 --- a/deal.II/source/base/polynomials_abf.cc +++ b/deal.II/source/base/polynomials_abf.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006, 2010 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -22,9 +22,9 @@ DEAL_II_NAMESPACE_OPEN template PolynomialsABF::PolynomialsABF (const unsigned int k) - : - my_degree(k), - n_pols(compute_n_pols(k)) + : + my_degree(k), + n_pols(compute_n_pols(k)) { std::vector > > pols(dim); pols[0] = Polynomials::LagrangeEquidistant::generate_complete_basis(k+2); @@ -48,23 +48,23 @@ PolynomialsABF::~PolynomialsABF () template void PolynomialsABF::compute (const Point &unit_point, - std::vector > &values, - std::vector > &grads, - std::vector > &grad_grads) const + std::vector > &values, + std::vector > &grads, + std::vector > &grad_grads) const { Assert(values.size()==n_pols || values.size()==0, - ExcDimensionMismatch(values.size(), n_pols)); + ExcDimensionMismatch(values.size(), n_pols)); Assert(grads.size()==n_pols|| grads.size()==0, - ExcDimensionMismatch(grads.size(), n_pols)); + ExcDimensionMismatch(grads.size(), n_pols)); Assert(grad_grads.size()==n_pols|| grad_grads.size()==0, - ExcDimensionMismatch(grad_grads.size(), n_pols)); + ExcDimensionMismatch(grad_grads.size(), n_pols)); const unsigned int n_sub = polynomial_space->n(); - // guard access to the scratch - // arrays in the following block - // using a mutex to make sure they - // are not used by multiple threads - // at once + // guard access to the scratch + // arrays in the following block + // using a mutex to make sure they + // are not used by multiple threads + // at once Threads::Mutex::ScopedLock lock(mutex); p_values.resize((values.size() == 0) ? 0 : n_sub); @@ -73,35 +73,35 @@ PolynomialsABF::compute (const Point &unit_point, for (unsigned int d=0;d p; for (unsigned int c=0;ccompute (p, p_values, p_grads, p_grad_grads); for (unsigned int i=0;i -#define ENTER_COEFFICIENTS(koefs,z,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \ +#define ENTER_COEFFICIENTS(koefs,z,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \ koefs(0, z)= a0; koefs(1, z)=a1; koefs(2, z)=a2; koefs(3, z)=a3; koefs( 4, z)=a4 ; koefs( 5, z)=a5 ; \ koefs(6, z)= a6; koefs(7, z)=a7; koefs(8, z)=a8; koefs(9, z)=a9; koefs(10, z)=a10; koefs(11, z)=a11; diff --git a/deal.II/source/base/polynomials_bdm.cc b/deal.II/source/base/polynomials_bdm.cc index 6f018ae0a5..70f96f0a80 100644 --- a/deal.II/source/base/polynomials_bdm.cc +++ b/deal.II/source/base/polynomials_bdm.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -21,25 +21,25 @@ DEAL_II_NAMESPACE_OPEN template PolynomialsBDM::PolynomialsBDM (const unsigned int k) - : - polynomial_space (Polynomials::Legendre::generate_complete_basis(k)), - monomials((dim==2) ? (1) : (k+2)), - n_pols(compute_n_pols(k)), - p_values(polynomial_space.n()), - p_grads(polynomial_space.n()), - p_grad_grads(polynomial_space.n()) + : + polynomial_space (Polynomials::Legendre::generate_complete_basis(k)), + monomials((dim==2) ? (1) : (k+2)), + n_pols(compute_n_pols(k)), + p_values(polynomial_space.n()), + p_grads(polynomial_space.n()), + p_grad_grads(polynomial_space.n()) { switch(dim) { case 2: - monomials[0] = Polynomials::Monomial (k+1); - break; + monomials[0] = Polynomials::Monomial (k+1); + break; case 3: - for (unsigned int i=0;i (i); - break; + for (unsigned int i=0;i (i); + break; default: - Assert(false, ExcNotImplemented()); + Assert(false, ExcNotImplemented()); } } @@ -48,24 +48,24 @@ PolynomialsBDM::PolynomialsBDM (const unsigned int k) template void PolynomialsBDM::compute (const Point &unit_point, - std::vector > &values, - std::vector > &grads, - std::vector > &grad_grads) const + std::vector > &values, + std::vector > &grads, + std::vector > &grad_grads) const { Assert(values.size()==n_pols || values.size()==0, - ExcDimensionMismatch(values.size(), n_pols)); + ExcDimensionMismatch(values.size(), n_pols)); Assert(grads.size()==n_pols|| grads.size()==0, - ExcDimensionMismatch(grads.size(), n_pols)); + ExcDimensionMismatch(grads.size(), n_pols)); Assert(grad_grads.size()==n_pols|| grad_grads.size()==0, - ExcDimensionMismatch(grad_grads.size(), n_pols)); + ExcDimensionMismatch(grad_grads.size(), n_pols)); const unsigned int n_sub = polynomial_space.n(); - // guard access to the scratch - // arrays in the following block - // using a mutex to make sure they - // are not used by multiple threads - // at once + // guard access to the scratch + // arrays in the following block + // using a mutex to make sure they + // are not used by multiple threads + // at once { Threads::Mutex::ScopedLock lock(mutex); @@ -73,160 +73,160 @@ PolynomialsBDM::compute (const Point &unit_point, p_grads.resize((grads.size() == 0) ? 0 : n_sub); p_grad_grads.resize((grad_grads.size() == 0) ? 0 : n_sub); - // Compute values of complete space - // and insert into tensors. Result - // will have first all polynomials - // in the x-component, then y and - // z. + // Compute values of complete space + // and insert into tensors. Result + // will have first all polynomials + // in the x-component, then y and + // z. polynomial_space.compute (unit_point, p_values, p_grads, p_grad_grads); std::fill(values.begin(), values.end(), Tensor<1,dim>()); for (unsigned int i=0;i()); for (unsigned int i=0;i()); for (unsigned int i=0;i > monovali(dim, std::vector(4)); std::vector > monovalk(dim, std::vector(4)); if (dim == 2) { for (unsigned int d=0;d::compute_node_matrix (Table<2,double>& A) const { double orientation = 1.; if ((face==0) || (face==3)) - orientation = -1.; + orientation = -1.; for (unsigned int k=0;k p; - switch (face) - { - case 2: - p(1) = 1.; - case 0: - p(0) = x; - break; - case 1: - p(0) = 1.; - case 3: - p(1) = x; - break; - } -// std::cerr << p -// << '\t' << moment_weight[0].value(x) -// << '\t' << moment_weight[1].value(x) -// ; - - compute (p, values, grads, grad_grads); - - for (unsigned int i=0;i p; + switch (face) + { + case 2: + p(1) = 1.; + case 0: + p(0) = x; + break; + case 1: + p(0) = 1.; + case 3: + p(1) = x; + break; + } +// std::cerr << p +// << '\t' << moment_weight[0].value(x) +// << '\t' << moment_weight[1].value(x) +// ; + + compute (p, values, grads, grad_grads); + + for (unsigned int i=0;i::create_polynomials (const unsigned int k) } - // Compute the values, gradients - // and double gradients of the - // polynomial at the given point. + // Compute the values, gradients + // and double gradients of the + // polynomial at the given point. template void PolynomialsNedelec::compute (const Point &unit_point, @@ -47,11 +47,11 @@ const ExcDimensionMismatch(grads.size (), n_pols)); Assert(grad_grads.size () == n_pols || grad_grads.size () == 0, ExcDimensionMismatch(grad_grads.size (), n_pols)); - - // Declare the values, derivatives - // and second derivatives vectors of - // polynomial_space at - // unit_point + + // Declare the values, derivatives + // and second derivatives vectors of + // polynomial_space at + // unit_point const unsigned int& n_basis = polynomial_space.n (); std::vector unit_point_values ((values.size () == 0) ? 0 : n_basis); std::vector > @@ -65,9 +65,9 @@ const { polynomial_space.compute (unit_point, unit_point_values, unit_point_grads, unit_point_grad_grads); - - // Assign the correct values to the - // corresponding shape functions. + + // Assign the correct values to the + // corresponding shape functions. if (values.size () > 0) for (unsigned int i = 0; i < unit_point_values.size (); ++i) values[i][0] = unit_point_values[i]; @@ -87,27 +87,27 @@ const { polynomial_space.compute (unit_point, unit_point_values, unit_point_grads, unit_point_grad_grads); - - // Declare the values, derivatives and - // second derivatives vectors of - // polynomial_space at - // unit_point with coordinates - // shifted one step in positive direction + + // Declare the values, derivatives and + // second derivatives vectors of + // polynomial_space at + // unit_point with coordinates + // shifted one step in positive direction Point p; p (0) = unit_point (1); p (1) = unit_point (0); - + std::vector p_values ((values.size () == 0) ? 0 : n_basis); std::vector > p_grads ((grads.size () == 0) ? 0 : n_basis); std::vector > p_grad_grads ((grad_grads.size () == 0) ? 0 : n_basis); - + polynomial_space.compute (p, p_values, p_grads, p_grad_grads); - - // Assign the correct values to the - // corresponding shape functions. + + // Assign the correct values to the + // corresponding shape functions. if (values.size () > 0) { for (unsigned int i = 0; i <= my_degree; ++i) @@ -152,7 +152,7 @@ const = unit_point_grads[i + j * (my_degree + 1)][k]; grads[i + (j + 2) * (my_degree + 1)][1][k] = 0.0; } - + grads[i + j * (my_degree + 1)][1][0] = p_grads[i + j * (my_degree + 1)][1]; grads[i + j * (my_degree + 1)][1][1] @@ -178,7 +178,7 @@ const + GeometryInfo::lines_per_cell) * (my_degree + 1)][0][k] = 0.0; } - + grads[i + (j + my_degree + GeometryInfo::lines_per_cell) * (my_degree + 1)][1][0] @@ -205,7 +205,7 @@ const grad_grads[i + (j + 2) * (my_degree + 1)][1][k][l] = 0.0; } - + grad_grads[i + j * (my_degree + 1)][1][0][0] = p_grad_grads[i + j * (my_degree + 1)][1][1]; grad_grads[i + j * (my_degree + 1)][1][0][1] @@ -237,7 +237,7 @@ const + GeometryInfo::lines_per_cell) * (my_degree + 1)][0][k][l] = 0.0; } - + grad_grads[i + (j + my_degree + GeometryInfo::lines_per_cell) * (my_degree + 1)][1][0][0] @@ -264,13 +264,13 @@ const { polynomial_space.compute (unit_point, unit_point_values, unit_point_grads, unit_point_grad_grads); - - // Declare the values, derivatives - // and second derivatives vectors of - // polynomial_space at - // unit_point with coordinates - // shifted two steps in positive - // direction + + // Declare the values, derivatives + // and second derivatives vectors of + // polynomial_space at + // unit_point with coordinates + // shifted two steps in positive + // direction Point p1, p2; std::vector p1_values ((values.size () == 0) ? 0 : n_basis); std::vector > @@ -291,9 +291,9 @@ const p2 (1) = unit_point (0); p2 (2) = unit_point (1); polynomial_space.compute (p2, p2_values, p2_grads, p2_grad_grads); - - // Assign the correct values to the - // corresponding shape functions. + + // Assign the correct values to the + // corresponding shape functions. if (values.size () > 0) { for (unsigned int i = 0; i <= my_degree; ++i) @@ -432,7 +432,7 @@ const * my_degree + j + GeometryInfo::lines_per_cell][2] = p2_values[i + (j + k * (my_degree + 2) + 2) - * (my_degree + 1)]; + * (my_degree + 1)]; values[i + (j + (2 * k + 5) * my_degree + GeometryInfo::lines_per_cell) * (my_degree + 1)][0] @@ -476,7 +476,7 @@ const grads[i + (j + 4 * k + 2) * (my_degree + 1)][0][l] = unit_point_grads[i + (j + k * (my_degree + 2)) * (my_degree + 1)][l]; - + grads[i + (j + 2 * (k + 4)) * (my_degree + 1)][2][0] = p2_grads[i + (j + k * (my_degree + 2)) * (my_degree + 1)][1]; @@ -556,7 +556,7 @@ const * (my_degree + 2) + 2) * (my_degree + 1)][l]; } - + grads[(i + (j + 2 * GeometryInfo::faces_per_cell + my_degree) * (my_degree + 1) + GeometryInfo::lines_per_cell) @@ -607,8 +607,8 @@ const for (unsigned int l = 0; l < 2; ++l) for (unsigned int m = 0; m < dim; ++m) { - for (unsigned int n = 0; n < 2; ++n) - { + for (unsigned int n = 0; n < 2; ++n) + { grads[i + (j + (2 * (k + 2 * l) + 1) * my_degree + GeometryInfo::lines_per_cell) @@ -750,7 +750,7 @@ const * (my_degree + 1)][l] [m]; } - + grad_grads[i + (j + 2 * (k + 4)) * (my_degree + 1)] [2][0][0] = p2_grad_grads[i + (j + k * (my_degree + 2)) @@ -916,7 +916,7 @@ const + 2) * (my_degree + 1)][l][m]; } - + grad_grads[(i + (j + 2 * GeometryInfo::faces_per_cell + my_degree) @@ -1099,7 +1099,7 @@ const * (my_degree + 1)][2 * n][l][m] = 0.0; } - + grad_grads[i + (j + (2 * k + 5) * my_degree + GeometryInfo::lines_per_cell) * (my_degree + 1)] @@ -1331,10 +1331,10 @@ const } } } - + break; } - + default: Assert (false, ExcNotImplemented ()); } diff --git a/deal.II/source/base/polynomials_p.cc b/deal.II/source/base/polynomials_p.cc index 36664e09fc..e589e7123a 100644 --- a/deal.II/source/base/polynomials_p.cc +++ b/deal.II/source/base/polynomials_p.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -18,9 +18,9 @@ DEAL_II_NAMESPACE_OPEN template PolynomialsP::PolynomialsP (const unsigned int p) - : - PolynomialSpace(Polynomials::Monomial::generate_complete_basis(p)), - p(p) + : + PolynomialSpace(Polynomials::Monomial::generate_complete_basis(p)), + p(p) { std::vector index_map(this->n()); create_polynomial_ordering(index_map); @@ -33,9 +33,9 @@ void PolynomialsP<1>::create_polynomial_ordering( std::vector &index_map) const { Assert(index_map.size()==this->n(), - ExcDimensionMismatch(index_map.size(), this->n())); + ExcDimensionMismatch(index_map.size(), this->n())); - // identity + // identity for (unsigned int i=0; in(); ++i) index_map[i]=i; } @@ -57,15 +57,15 @@ void PolynomialsP<2>::create_polynomial_ordering( std::vector &index_map) const { Assert(index_map.size()==this->n(), - ExcDimensionMismatch(index_map.size(), this->n())); + ExcDimensionMismatch(index_map.size(), this->n())); Assert(p<=5, ExcNotImplemented()); - - // Given the number i of the - // polynomial in - // $1,x,y,xy,x2,y2,...$, - // index_map[i] gives the number of - // the polynomial in - // PolynomialSpace. + + // Given the number i of the + // polynomial in + // $1,x,y,xy,x2,y2,...$, + // index_map[i] gives the number of + // the polynomial in + // PolynomialSpace. for (unsigned int i=0; in(); ++i) index_map[i]=imap2[p][i]; } @@ -83,15 +83,15 @@ void PolynomialsP<3>::create_polynomial_ordering( std::vector &index_map) const { Assert(index_map.size()==this->n(), - ExcDimensionMismatch(index_map.size(), this->n())); + ExcDimensionMismatch(index_map.size(), this->n())); Assert(p<=3, ExcNotImplemented()); - - // Given the number i of the - // polynomial in - // $1,x,y,xy,x2,y2,...$, - // index_map[i] gives the number of - // the polynomial in - // PolynomialSpace. + + // Given the number i of the + // polynomial in + // $1,x,y,xy,x2,y2,...$, + // index_map[i] gives the number of + // the polynomial in + // PolynomialSpace. for (unsigned int i=0; in(); ++i) index_map[i]=imap3[p][i]; } diff --git a/deal.II/source/base/polynomials_raviart_thomas.cc b/deal.II/source/base/polynomials_raviart_thomas.cc index b5091c4f1d..f9c7e0f7c0 100644 --- a/deal.II/source/base/polynomials_raviart_thomas.cc +++ b/deal.II/source/base/polynomials_raviart_thomas.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -26,10 +26,10 @@ DEAL_II_NAMESPACE_OPEN template PolynomialsRaviartThomas::PolynomialsRaviartThomas (const unsigned int k) - : - my_degree(k), - polynomial_space (create_polynomials (k)), - n_pols(compute_n_pols(k)) + : + my_degree(k), + polynomial_space (create_polynomials (k)), + n_pols(compute_n_pols(k)) {} @@ -54,73 +54,73 @@ PolynomialsRaviartThomas::create_polynomials (const unsigned int k) template void PolynomialsRaviartThomas::compute (const Point &unit_point, - std::vector > &values, - std::vector > &grads, - std::vector > &grad_grads) const + std::vector > &values, + std::vector > &grads, + std::vector > &grad_grads) const { Assert(values.size()==n_pols || values.size()==0, - ExcDimensionMismatch(values.size(), n_pols)); + ExcDimensionMismatch(values.size(), n_pols)); Assert(grads.size()==n_pols|| grads.size()==0, - ExcDimensionMismatch(grads.size(), n_pols)); + ExcDimensionMismatch(grads.size(), n_pols)); Assert(grad_grads.size()==n_pols|| grad_grads.size()==0, - ExcDimensionMismatch(grad_grads.size(), n_pols)); - - // have a few scratch - // arrays. because we don't want to - // re-allocate them every time this - // function is called, we make them - // static. however, in return we - // have to ensure that the calls to - // the use of these variables is - // locked with a mutex. if the - // mutex is removed, several tests - // (notably - // deal.II/create_mass_matrix_05) - // will start to produce random - // results in multithread mode + ExcDimensionMismatch(grad_grads.size(), n_pols)); + + // have a few scratch + // arrays. because we don't want to + // re-allocate them every time this + // function is called, we make them + // static. however, in return we + // have to ensure that the calls to + // the use of these variables is + // locked with a mutex. if the + // mutex is removed, several tests + // (notably + // deal.II/create_mass_matrix_05) + // will start to produce random + // results in multithread mode static Threads::ThreadMutex mutex; Threads::ThreadMutex::ScopedLock lock(mutex); - static std::vector p_values; + static std::vector p_values; static std::vector > p_grads; static std::vector > p_grad_grads; - const unsigned int n_sub = polynomial_space.n(); + const unsigned int n_sub = polynomial_space.n(); p_values.resize((values.size() == 0) ? 0 : n_sub); p_grads.resize((grads.size() == 0) ? 0 : n_sub); p_grad_grads.resize((grad_grads.size() == 0) ? 0 : n_sub); - + for (unsigned int d=0;d p; for (unsigned int c=0;c::compute_n_pols(unsigned int k) if (dim == 1) return k+1; if (dim == 2) return 2*(k+1)*(k+2); if (dim == 3) return 3*(k+1)*(k+1)*(k+2); - + Assert(false, ExcNotImplemented()); return 0; } diff --git a/deal.II/source/base/quadrature.cc b/deal.II/source/base/quadrature.cc index 57a07f443a..cb51865e7c 100644 --- a/deal.II/source/base/quadrature.cc +++ b/deal.II/source/base/quadrature.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -42,9 +42,9 @@ namespace template <> Quadrature<0>::Quadrature (const unsigned int n_q) - : - quadrature_points (n_q), - weights (n_q, 0) + : + quadrature_points (n_q), + weights (n_q, 0) {} @@ -57,9 +57,9 @@ Quadrature<0>::~Quadrature () template Quadrature::Quadrature (const unsigned int n_q) - : - quadrature_points (n_q, Point()), - weights (n_q, 0) + : + quadrature_points (n_q, Point()), + weights (n_q, 0) {} @@ -67,7 +67,7 @@ Quadrature::Quadrature (const unsigned int n_q) template void Quadrature::initialize (const std::vector > &p, - const std::vector &w) + const std::vector &w) { AssertDimension (w.size(), p.size()); quadrature_points = p; @@ -78,10 +78,10 @@ Quadrature::initialize (const std::vector > &p, template Quadrature::Quadrature (const std::vector > &points, - const std::vector &weights) - : - quadrature_points(points), - weights(weights) + const std::vector &weights) + : + quadrature_points(points), + weights(weights) { Assert (weights.size() == points.size(), ExcDimensionMismatch(weights.size(), points.size())); @@ -91,12 +91,12 @@ Quadrature::Quadrature (const std::vector > &points, template Quadrature::Quadrature (const std::vector > &points) - : - quadrature_points(points), - weights(points.size(), std::atof("Inf")) + : + quadrature_points(points), + weights(points.size(), std::atof("Inf")) { Assert(weights.size() == points.size(), - ExcDimensionMismatch(weights.size(), points.size())); + ExcDimensionMismatch(weights.size(), points.size())); } @@ -104,14 +104,14 @@ Quadrature::Quadrature (const std::vector > &points) template Quadrature::Quadrature (const Point &point) : - quadrature_points(std::vector > (1, point)), - weights(std::vector (1, 1.)) + quadrature_points(std::vector > (1, point)), + weights(std::vector (1, 1.)) {} template <> Quadrature<0>::Quadrature (const SubQuadrature&, - const Quadrature<1>&) + const Quadrature<1>&) { Assert(false, ExcImpossibleInDim(0)); } @@ -120,27 +120,27 @@ Quadrature<0>::Quadrature (const SubQuadrature&, template Quadrature::Quadrature (const SubQuadrature &q1, - const Quadrature<1> &q2) - : - quadrature_points (q1.size() * q2.size()), - weights (q1.size() * q2.size()) + const Quadrature<1> &q2) + : + quadrature_points (q1.size() * q2.size()), + weights (q1.size() * q2.size()) { unsigned int present_index = 0; for (unsigned int i2=0; i2::Quadrature (const SubQuadrature &q1, { double sum = 0; for (unsigned int i=0; i0.999999) && (sum<1.000001), ExcInternalError()); } #endif @@ -161,19 +161,19 @@ Quadrature::Quadrature (const SubQuadrature &q1, template <> Quadrature<1>::Quadrature (const SubQuadrature&, - const Quadrature<1>& q2) - : - quadrature_points (q2.size()), - weights (q2.size()) + const Quadrature<1>& q2) + : + quadrature_points (q2.size()), + weights (q2.size()) { unsigned int present_index = 0; for (unsigned int i2=0; i2::Quadrature (const SubQuadrature&, { double sum = 0; for (unsigned int i=0; i0.999999) && (sum<1.000001), ExcInternalError()); } #endif @@ -198,17 +198,17 @@ Quadrature<1>::Quadrature (const SubQuadrature&, template <> Quadrature<0>::Quadrature (const Quadrature<1> &) - : - Subscriptor(), -// quadrature_points(1), - weights(1,1.) + : + Subscriptor(), +// quadrature_points(1), + weights(1,1.) {} template <> Quadrature<1>::Quadrature (const Quadrature<0> &) - : - Subscriptor() + : + Subscriptor() { // this function should never be // called -- this should be the @@ -220,10 +220,10 @@ Quadrature<1>::Quadrature (const Quadrature<0> &) template Quadrature::Quadrature (const Quadrature &q) - : - Subscriptor(), - quadrature_points (dimpow(q.size())), - weights (dimpow(q.size())) + : + Subscriptor(), + quadrature_points (dimpow(q.size())), + weights (dimpow(q.size())) { Assert (dim <= 3, ExcNotImplemented()); @@ -235,29 +235,29 @@ Quadrature::Quadrature (const Quadrature &q) for (unsigned int i2=0;i21) - quadrature_points[k](1) = q.point(i1)(0); - if (dim>2) - quadrature_points[k](2) = q.point(i2)(0); - weights[k] = q.weight(i0); - if (dim>1) - weights[k] *= q.weight(i1); - if (dim>2) - weights[k] *= q.weight(i2); - ++k; - } + { + quadrature_points[k](0) = q.point(i0)(0); + if (dim>1) + quadrature_points[k](1) = q.point(i1)(0); + if (dim>2) + quadrature_points[k](2) = q.point(i2)(0); + weights[k] = q.weight(i0); + if (dim>1) + weights[k] *= q.weight(i1); + if (dim>2) + weights[k] *= q.weight(i2); + ++k; + } } template Quadrature::Quadrature (const Quadrature &q) - : - Subscriptor(), - quadrature_points (q.quadrature_points), - weights (q.weights) + : + Subscriptor(), + quadrature_points (q.quadrature_points), + weights (q.weights) {} @@ -294,14 +294,14 @@ std::size_t Quadrature::memory_consumption () const { return (MemoryConsumption::memory_consumption (quadrature_points) + - MemoryConsumption::memory_consumption (weights)); + MemoryConsumption::memory_consumption (weights)); } //--------------------------------------------------------------------------- template QAnisotropic::QAnisotropic(const Quadrature<1>& qx) - : Quadrature(qx.size()) + : Quadrature(qx.size()) { Assert (dim==1, ExcImpossibleInDim(dim)); unsigned int k=0; @@ -317,9 +317,9 @@ QAnisotropic::QAnisotropic(const Quadrature<1>& qx) template QAnisotropic::QAnisotropic(const Quadrature<1>& qx, - const Quadrature<1>& qy) - : Quadrature(qx.size() - *qy.size()) + const Quadrature<1>& qy) + : Quadrature(qx.size() + *qy.size()) { Assert (dim==2, ExcImpossibleInDim(dim)); unsigned int k=0; @@ -337,23 +337,23 @@ QAnisotropic::QAnisotropic(const Quadrature<1>& qx, template QAnisotropic::QAnisotropic(const Quadrature<1>& qx, - const Quadrature<1>& qy, - const Quadrature<1>& qz) - : Quadrature(qx.size() - *qy.size() - *qz.size()) + const Quadrature<1>& qy, + const Quadrature<1>& qz) + : Quadrature(qx.size() + *qy.size() + *qz.size()) { Assert (dim==3, ExcImpossibleInDim(dim)); unsigned int k=0; for (unsigned int k3=0;k3quadrature_points[k](0) = qx.point(k1)(0); - this->quadrature_points[k](1) = qy.point(k2)(0); - this->quadrature_points[k](2) = qz.point(k3)(0); - this->weights[k++] = qx.weight(k1) * qy.weight(k2) * qz.weight(k3); - } + { + this->quadrature_points[k](0) = qx.point(k1)(0); + this->quadrature_points[k](1) = qy.point(k2)(0); + this->quadrature_points[k](2) = qz.point(k3)(0); + this->weights[k++] = qx.weight(k1) * qy.weight(k2) * qz.weight(k3); + } Assert (k==this->size(), ExcInternalError()); } @@ -384,35 +384,35 @@ QProjector::reflect (const Quadrature<2> &q) template Quadrature<2> QProjector::rotate (const Quadrature<2> &q, - const unsigned int n_times) + const unsigned int n_times) { std::vector > q_points (q.size()); std::vector weights (q.size()); for (unsigned int i=0; i::project_to_face (const Quadrature<1> &quadrature, const unsigned int dim=2; AssertIndexRange (face_no, GeometryInfo::faces_per_cell); Assert (q_points.size() == quadrature.size(), - ExcDimensionMismatch (q_points.size(), quadrature.size())); + ExcDimensionMismatch (q_points.size(), quadrature.size())); for (unsigned int p=0; p(0,quadrature.point(p)(0)); - break; - case 1: - q_points[p] = Point(1,quadrature.point(p)(0)); - break; - case 2: - q_points[p] = Point(quadrature.point(p)(0),0); - break; - case 3: - q_points[p] = Point(quadrature.point(p)(0),1); - break; - default: - Assert (false, ExcInternalError()); + case 0: + q_points[p] = Point(0,quadrature.point(p)(0)); + break; + case 1: + q_points[p] = Point(1,quadrature.point(p)(0)); + break; + case 2: + q_points[p] = Point(quadrature.point(p)(0),0); + break; + case 3: + q_points[p] = Point(quadrature.point(p)(0),1); + break; + default: + Assert (false, ExcInternalError()); }; } @@ -478,44 +478,44 @@ QProjector<3>::project_to_face (const Quadrature<2> &quadrature, const unsigned int dim=3; AssertIndexRange (face_no, GeometryInfo::faces_per_cell); Assert (q_points.size() == quadrature.size(), - ExcDimensionMismatch (q_points.size(), quadrature.size())); + ExcDimensionMismatch (q_points.size(), quadrature.size())); for (unsigned int p=0; p(0, - quadrature.point(p)(0), - quadrature.point(p)(1)); - break; - case 1: - q_points[p] = Point(1, - quadrature.point(p)(0), - quadrature.point(p)(1)); - break; - case 2: - q_points[p] = Point(quadrature.point(p)(1), - 0, - quadrature.point(p)(0)); - break; - case 3: - q_points[p] = Point(quadrature.point(p)(1), - 1, - quadrature.point(p)(0)); - break; - case 4: - q_points[p] = Point(quadrature.point(p)(0), - quadrature.point(p)(1), - 0); - break; - case 5: - q_points[p] = Point(quadrature.point(p)(0), - quadrature.point(p)(1), - 1); - break; - - default: - Assert (false, ExcInternalError()); + case 0: + q_points[p] = Point(0, + quadrature.point(p)(0), + quadrature.point(p)(1)); + break; + case 1: + q_points[p] = Point(1, + quadrature.point(p)(0), + quadrature.point(p)(1)); + break; + case 2: + q_points[p] = Point(quadrature.point(p)(1), + 0, + quadrature.point(p)(0)); + break; + case 3: + q_points[p] = Point(quadrature.point(p)(1), + 1, + quadrature.point(p)(0)); + break; + case 4: + q_points[p] = Point(quadrature.point(p)(0), + quadrature.point(p)(1), + 0); + break; + case 5: + q_points[p] = Point(quadrature.point(p)(0), + quadrature.point(p)(1), + 1); + break; + + default: + Assert (false, ExcInternalError()); }; } @@ -527,7 +527,7 @@ QProjector<1>::project_to_subface (const Quadrature<0> &, const unsigned int face_no, const unsigned int, std::vector >& q_points, - const RefinementCase<0> &) + const RefinementCase<0> &) { const unsigned int dim=1; AssertIndexRange (face_no, GeometryInfo::faces_per_cell); @@ -544,75 +544,75 @@ QProjector<2>::project_to_subface (const Quadrature<1> &quadrature, const unsigned int face_no, const unsigned int subface_no, std::vector > &q_points, - const RefinementCase<1> &) + const RefinementCase<1> &) { const unsigned int dim=2; AssertIndexRange (face_no, GeometryInfo::faces_per_cell); AssertIndexRange (subface_no, GeometryInfo::max_children_per_face); Assert (q_points.size() == quadrature.size(), - ExcDimensionMismatch (q_points.size(), quadrature.size())); + ExcDimensionMismatch (q_points.size(), quadrature.size())); for (unsigned int p=0; p(0,quadrature.point(p)(0)/2); - break; - case 1: - q_points[p] = Point(0,quadrature.point(p)(0)/2+0.5); - break; - default: - Assert (false, ExcInternalError()); - }; - break; - case 1: - switch (subface_no) - { - case 0: - q_points[p] = Point(1,quadrature.point(p)(0)/2); - break; - case 1: - q_points[p] = Point(1,quadrature.point(p)(0)/2+0.5); - break; - default: - Assert (false, ExcInternalError()); - }; - break; - case 2: - switch (subface_no) - { - case 0: - q_points[p] - = Point(quadrature.point(p)(0)/2,0); - break; - case 1: - q_points[p] - = Point(quadrature.point(p)(0)/2+0.5,0); - break; - default: - Assert (false, ExcInternalError()); - }; - break; - case 3: - switch (subface_no) - { - case 0: - q_points[p] = Point(quadrature.point(p)(0)/2,1); - break; - case 1: - q_points[p] = Point(quadrature.point(p)(0)/2+0.5,1); - break; - default: - Assert (false, ExcInternalError()); - }; - break; - - default: - Assert (false, ExcInternalError()); + case 0: + switch (subface_no) + { + case 0: + q_points[p] = Point(0,quadrature.point(p)(0)/2); + break; + case 1: + q_points[p] = Point(0,quadrature.point(p)(0)/2+0.5); + break; + default: + Assert (false, ExcInternalError()); + }; + break; + case 1: + switch (subface_no) + { + case 0: + q_points[p] = Point(1,quadrature.point(p)(0)/2); + break; + case 1: + q_points[p] = Point(1,quadrature.point(p)(0)/2+0.5); + break; + default: + Assert (false, ExcInternalError()); + }; + break; + case 2: + switch (subface_no) + { + case 0: + q_points[p] + = Point(quadrature.point(p)(0)/2,0); + break; + case 1: + q_points[p] + = Point(quadrature.point(p)(0)/2+0.5,0); + break; + default: + Assert (false, ExcInternalError()); + }; + break; + case 3: + switch (subface_no) + { + case 0: + q_points[p] = Point(quadrature.point(p)(0)/2,1); + break; + case 1: + q_points[p] = Point(quadrature.point(p)(0)/2+0.5,1); + break; + default: + Assert (false, ExcInternalError()); + }; + break; + + default: + Assert (false, ExcInternalError()); }; } @@ -624,77 +624,77 @@ QProjector<3>::project_to_subface (const Quadrature<2> &quadrature, const unsigned int face_no, const unsigned int subface_no, std::vector > &q_points, - const RefinementCase<2> &ref_case) + const RefinementCase<2> &ref_case) { const unsigned int dim=3; AssertIndexRange (face_no, GeometryInfo::faces_per_cell); AssertIndexRange (subface_no, GeometryInfo::max_children_per_face); Assert (q_points.size() == quadrature.size(), - ExcDimensionMismatch (q_points.size(), quadrature.size())); + ExcDimensionMismatch (q_points.size(), quadrature.size())); - // one coordinate is at a const value. for - // faces 0, 2 and 4 this value is 0.0, for - // faces 1, 3 and 5 it is 1.0 + // one coordinate is at a const value. for + // faces 0, 2 and 4 this value is 0.0, for + // faces 1, 3 and 5 it is 1.0 double const_value=face_no%2; - // local 2d coordinates are xi and eta, - // global 3d coordinates are x, y and - // z. those have to be mapped. the following - // indices tell, which global coordinate - // (0->x, 1->y, 2->z) corresponds to which - // local one + // local 2d coordinates are xi and eta, + // global 3d coordinates are x, y and + // z. those have to be mapped. the following + // indices tell, which global coordinate + // (0->x, 1->y, 2->z) corresponds to which + // local one unsigned int xi_index = deal_II_numbers::invalid_unsigned_int, - eta_index = deal_II_numbers::invalid_unsigned_int, - const_index = face_no/2; - // the xi and eta values have to be scaled - // (by factor 0.5 or factor 1.0) depending on - // the refinement case and translated (by 0.0 - // or 0.5) depending on the refinement case - // and subface_no. + eta_index = deal_II_numbers::invalid_unsigned_int, + const_index = face_no/2; + // the xi and eta values have to be scaled + // (by factor 0.5 or factor 1.0) depending on + // the refinement case and translated (by 0.0 + // or 0.5) depending on the refinement case + // and subface_no. double xi_scale=1.0, eta_scale=1.0, xi_translation=0.0, eta_translation=0.0; - // set the index mapping between local and - // global coordinates + // set the index mapping between local and + // global coordinates switch(face_no/2) { case 0: - xi_index=1; - eta_index=2; - break; + xi_index=1; + eta_index=2; + break; case 1: - xi_index=2; - eta_index=0; - break; + xi_index=2; + eta_index=0; + break; case 2: - xi_index=0; - eta_index=1; - break; + xi_index=0; + eta_index=1; + break; } - // set the scale and translation parameter - // for individual subfaces + // set the scale and translation parameter + // for individual subfaces switch((unsigned char)ref_case) { case RefinementCase::cut_x: - xi_scale=0.5; - xi_translation=subface_no%2 * 0.5; - break; + xi_scale=0.5; + xi_translation=subface_no%2 * 0.5; + break; case RefinementCase::cut_y: - eta_scale=0.5; - eta_translation=subface_no%2 * 0.5; - break; + eta_scale=0.5; + eta_translation=subface_no%2 * 0.5; + break; case RefinementCase::cut_xy: - xi_scale= 0.5; - eta_scale=0.5; - xi_translation =subface_no%2 * 0.5; - eta_translation=subface_no/2 * 0.5; - break; + xi_scale= 0.5; + eta_scale=0.5; + xi_translation =subface_no%2 * 0.5; + eta_translation=subface_no/2 * 0.5; + break; default: - Assert(false,ExcInternalError()); - break; + Assert(false,ExcInternalError()); + break; } - // finally, compute the scaled, translated, - // projected quadrature points + // finally, compute the scaled, translated, + // projected quadrature points for (unsigned int p=0; p::project_to_all_faces (const Quadrature<0>& quadrature) const unsigned int dim = 1; const unsigned int n_points = 1, - n_faces = GeometryInfo::faces_per_cell; + n_faces = GeometryInfo::faces_per_cell; - // first fix quadrature points + // first fix quadrature points std::vector > q_points; q_points.reserve(n_points * n_faces); std::vector > help(n_points); - // project to each face and append - // results + // project to each face and append + // results for (unsigned int face=0; face::project_to_all_faces (const Quadrature<0>& quadrature) std::back_inserter (q_points)); } - // next copy over weights + // next copy over weights std::vector weights; weights.reserve (n_points * n_faces); for (unsigned int face=0; face::project_to_all_faces (const SubQuadrature &quadrature) const unsigned int dim = 2; const unsigned int n_points = quadrature.size(), - n_faces = GeometryInfo::faces_per_cell; + n_faces = GeometryInfo::faces_per_cell; - // first fix quadrature points + // first fix quadrature points std::vector > q_points; q_points.reserve(n_points * n_faces); std::vector > help(n_points); - // project to each face and append - // results + // project to each face and append + // results for (unsigned int face=0; face::project_to_all_faces (const SubQuadrature &quadrature) std::back_inserter (q_points)); } - // next copy over weights + // next copy over weights std::vector weights; weights.reserve (n_points * n_faces); for (unsigned int face=0; face::project_to_all_faces (const SubQuadrature &quadrature) const unsigned int n_points = quadrature.size(), - n_faces = GeometryInfo::faces_per_cell; + n_faces = GeometryInfo::faces_per_cell; - // first fix quadrature points + // first fix quadrature points std::vector > q_points; q_points.reserve(n_points * n_faces * 8); std::vector > help(n_points); @@ -817,26 +817,26 @@ QProjector<3>::project_to_all_faces (const SubQuadrature &quadrature) std::vector weights; weights.reserve (n_points * n_faces * 8); - // do the following for all possible - // mutations of a face (mutation==0 - // corresponds to a face with standard - // orientation, no flip and no rotation) + // do the following for all possible + // mutations of a face (mutation==0 + // corresponds to a face with standard + // orientation, no flip and no rotation) for (unsigned int mutation=0; mutation<8; ++mutation) { - // project to each face and append - // results + // project to each face and append + // results for (unsigned int face=0; face::project_to_all_subfaces (const Quadrature<0>& quadrature) const unsigned int dim = 1; const unsigned int n_points = 1, - n_faces = GeometryInfo::faces_per_cell, - subfaces_per_face = GeometryInfo::max_children_per_face; + n_faces = GeometryInfo::faces_per_cell, + subfaces_per_face = GeometryInfo::max_children_per_face; - // first fix quadrature points + // first fix quadrature points std::vector > q_points; q_points.reserve (n_points * n_faces * subfaces_per_face); std::vector > help(n_points); - // project to each face and copy - // results + // project to each face and copy + // results for (unsigned int face=0; face weights; weights.reserve (n_points * n_faces * subfaces_per_face); for (unsigned int face=0; face::project_to_all_subfaces (const SubQuadrature &quadrature) const unsigned int dim = 2; const unsigned int n_points = quadrature.size(), - n_faces = GeometryInfo::faces_per_cell, - subfaces_per_face = GeometryInfo::max_children_per_face; + n_faces = GeometryInfo::faces_per_cell, + subfaces_per_face = GeometryInfo::max_children_per_face; - // first fix quadrature points + // first fix quadrature points std::vector > q_points; q_points.reserve (n_points * n_faces * subfaces_per_face); std::vector > help(n_points); - // project to each face and copy - // results + // project to each face and copy + // results for (unsigned int face=0; face weights; weights.reserve (n_points * n_faces * subfaces_per_face); for (unsigned int face=0; face::project_to_all_subfaces (const SubQuadrature &quadrature) rotate (q_reflected,1)}; const unsigned int n_points = quadrature.size(), - n_faces = GeometryInfo::faces_per_cell, - total_subfaces_per_face = 2 + 2 + 4; + n_faces = GeometryInfo::faces_per_cell, + total_subfaces_per_face = 2 + 2 + 4; - // first fix quadrature points + // first fix quadrature points std::vector > q_points; q_points.reserve (n_points * n_faces * total_subfaces_per_face * 8); std::vector > help(n_points); @@ -966,35 +966,35 @@ QProjector<3>::project_to_all_subfaces (const SubQuadrature &quadrature) std::vector weights; weights.reserve (n_points * n_faces * total_subfaces_per_face * 8); - // do the following for all possible - // mutations of a face (mutation==0 - // corresponds to a face with standard - // orientation, no flip and no rotation) + // do the following for all possible + // mutations of a face (mutation==0 + // corresponds to a face with standard + // orientation, no flip and no rotation) for (unsigned int mutation=0; mutation<8; ++mutation) { - // project to each face and copy - // results + // project to each face and copy + // results for (unsigned int face=0; face::cut_xy; - ref_case>=RefinementCase::cut_x; - --ref_case) - for (unsigned int subface=0; subface::n_children(RefinementCase(ref_case)); ++subface) - { - project_to_subface(q[mutation], face, subface, help, - RefinementCase(ref_case)); - std::copy (help.begin(), help.end(), - std::back_inserter (q_points)); - } - - // next copy over weights + for (unsigned int ref_case=RefinementCase::cut_xy; + ref_case>=RefinementCase::cut_x; + --ref_case) + for (unsigned int subface=0; subface::n_children(RefinementCase(ref_case)); ++subface) + { + project_to_subface(q[mutation], face, subface, help, + RefinementCase(ref_case)); + std::copy (help.begin(), help.end(), + std::back_inserter (q_points)); + } + + // next copy over weights for (unsigned int face=0; face::cut_xy; - ref_case>=RefinementCase::cut_x; - --ref_case) - for (unsigned int subface=0; subface::n_children(RefinementCase(ref_case)); ++subface) - std::copy (q[mutation].get_weights().begin(), - q[mutation].get_weights().end(), - std::back_inserter (weights)); + for (unsigned int ref_case=RefinementCase::cut_xy; + ref_case>=RefinementCase::cut_x; + --ref_case) + for (unsigned int subface=0; subface::n_children(RefinementCase(ref_case)); ++subface) + std::copy (q[mutation].get_weights().begin(), + q[mutation].get_weights().end(), + std::back_inserter (weights)); } Assert (q_points.size() == n_points * n_faces * total_subfaces_per_face * 8, @@ -1011,10 +1011,10 @@ QProjector<3>::project_to_all_subfaces (const SubQuadrature &quadrature) template Quadrature QProjector::project_to_child (const Quadrature &quadrature, - const unsigned int child_no) + const unsigned int child_no) { Assert (child_no < GeometryInfo::max_children_per_cell, - ExcIndexRange (child_no, 0, GeometryInfo::max_children_per_cell)); + ExcIndexRange (child_no, 0, GeometryInfo::max_children_per_cell)); const unsigned int n_q_points = quadrature.size(); @@ -1023,9 +1023,9 @@ QProjector::project_to_child (const Quadrature &quadrature, q_points[i]=GeometryInfo::child_to_cell_coordinates( quadrature.point(i), child_no); - // for the weights, things are - // equally simple: copy them and - // scale them + // for the weights, things are + // equally simple: copy them and + // scale them std::vector weights = quadrature.get_weights (); for (unsigned int i=0; i::max_children_per_cell); @@ -1039,21 +1039,21 @@ Quadrature QProjector::project_to_all_children (const Quadrature &quadrature) { const unsigned int n_points = quadrature.size(), - n_children = GeometryInfo::max_children_per_cell; + n_children = GeometryInfo::max_children_per_cell; std::vector > q_points(n_points * n_children); std::vector weights(n_points * n_children); - // project to each child and copy - // results + // project to each child and copy + // results for (unsigned int child=0; child help = project_to_child(quadrature, child); for (unsigned int i=0;i(q_points, weights); } @@ -1106,10 +1106,10 @@ face (const unsigned int face_no, case 3: { - // in 3d, we have to account for faces that - // have non-standard face orientation, flip - // and rotation. thus, we have to store - // _eight_ data sets per face or subface + // in 3d, we have to account for faces that + // have non-standard face orientation, flip + // and rotation. thus, we have to store + // _eight_ data sets per face or subface // set up a table with the according offsets // for non-standard orientation, first index: @@ -1128,15 +1128,15 @@ face (const unsigned int face_no, // stick to that (implicit) convention static const unsigned int offset[2][2][2]= {{{4*GeometryInfo::faces_per_cell, 5*GeometryInfo::faces_per_cell}, // face_orientation=false; face_flip=false; face_rotation=false and true - {6*GeometryInfo::faces_per_cell, 7*GeometryInfo::faces_per_cell}}, // face_orientation=false; face_flip=true; face_rotation=false and true - {{0*GeometryInfo::faces_per_cell, 1*GeometryInfo::faces_per_cell}, // face_orientation=true; face_flip=false; face_rotation=false and true - {2*GeometryInfo::faces_per_cell, 3*GeometryInfo::faces_per_cell}}}; // face_orientation=true; face_flip=true; face_rotation=false and true + {6*GeometryInfo::faces_per_cell, 7*GeometryInfo::faces_per_cell}}, // face_orientation=false; face_flip=true; face_rotation=false and true + {{0*GeometryInfo::faces_per_cell, 1*GeometryInfo::faces_per_cell}, // face_orientation=true; face_flip=false; face_rotation=false and true + {2*GeometryInfo::faces_per_cell, 3*GeometryInfo::faces_per_cell}}}; // face_orientation=true; face_flip=true; face_rotation=false and true return ((face_no + offset[face_orientation][face_flip][face_rotation]) - * n_quadrature_points); + * n_quadrature_points); } - + default: Assert (false, ExcInternalError()); } @@ -1154,7 +1154,7 @@ subface (const unsigned int face_no, const bool, const bool, const unsigned int n_quadrature_points, - const internal::SubfaceCase<1>) + const internal::SubfaceCase<1>) { Assert (face_no < GeometryInfo<1>::faces_per_cell, ExcInternalError()); @@ -1162,8 +1162,8 @@ subface (const unsigned int face_no, ExcInternalError()); return ((face_no * GeometryInfo<1>::max_children_per_face + - subface_no) - * n_quadrature_points); + subface_no) + * n_quadrature_points); } @@ -1177,7 +1177,7 @@ subface (const unsigned int face_no, const bool, const bool, const unsigned int n_quadrature_points, - const internal::SubfaceCase<2>) + const internal::SubfaceCase<2>) { Assert (face_no < GeometryInfo<2>::faces_per_cell, ExcInternalError()); @@ -1185,8 +1185,8 @@ subface (const unsigned int face_no, ExcInternalError()); return ((face_no * GeometryInfo<2>::max_children_per_face + - subface_no) - * n_quadrature_points); + subface_no) + * n_quadrature_points); } @@ -1199,7 +1199,7 @@ subface (const unsigned int face_no, const bool face_flip, const bool face_rotation, const unsigned int n_quadrature_points, - const internal::SubfaceCase<3> ref_case) + const internal::SubfaceCase<3> ref_case) { const unsigned int dim = 3; @@ -1208,248 +1208,248 @@ subface (const unsigned int face_no, Assert (subface_no < GeometryInfo::max_children_per_face, ExcInternalError()); - // As the quadrature points created by - // QProjector are on subfaces in their - // "standard location" we have to use a - // permutation of the equivalent subface - // number in order to respect face - // orientation, flip and rotation. The - // information we need here is exactly the - // same as the - // GeometryInfo<3>::child_cell_on_face info - // for the bottom face (face 4) of a hex, as - // on this the RefineCase of the cell matches - // that of the face and the subfaces are - // numbered in the same way as the child - // cells. - - // in 3d, we have to account for faces that - // have non-standard face orientation, flip - // and rotation. thus, we have to store - // _eight_ data sets per face or subface - // already for the isotropic - // case. Additionally, we have three - // different refinement cases, resulting in - // 4 + 2 + 2 = 8 differnt subfaces - // for each face. + // As the quadrature points created by + // QProjector are on subfaces in their + // "standard location" we have to use a + // permutation of the equivalent subface + // number in order to respect face + // orientation, flip and rotation. The + // information we need here is exactly the + // same as the + // GeometryInfo<3>::child_cell_on_face info + // for the bottom face (face 4) of a hex, as + // on this the RefineCase of the cell matches + // that of the face and the subfaces are + // numbered in the same way as the child + // cells. + + // in 3d, we have to account for faces that + // have non-standard face orientation, flip + // and rotation. thus, we have to store + // _eight_ data sets per face or subface + // already for the isotropic + // case. Additionally, we have three + // different refinement cases, resulting in + // 4 + 2 + 2 = 8 differnt subfaces + // for each face. const unsigned int total_subfaces_per_face=8; - // set up a table with the according offsets - // for non-standard orientation, first index: - // face_orientation (standard true=1), second - // index: face_flip (standard false=0), third - // index: face_rotation (standard false=0) - // - // note, that normally we should use the - // obvious offsets 0,1,2,3,4,5,6,7. However, - // prior to the changes enabling flipped and - // rotated faces, in many places of the - // library the convention was used, that the - // first dataset with offset 0 corresponds to - // a face in standard orientation. therefore - // we use the offsets 4,5,6,7,0,1,2,3 here to - // stick to that (implicit) convention + // set up a table with the according offsets + // for non-standard orientation, first index: + // face_orientation (standard true=1), second + // index: face_flip (standard false=0), third + // index: face_rotation (standard false=0) + // + // note, that normally we should use the + // obvious offsets 0,1,2,3,4,5,6,7. However, + // prior to the changes enabling flipped and + // rotated faces, in many places of the + // library the convention was used, that the + // first dataset with offset 0 corresponds to + // a face in standard orientation. therefore + // we use the offsets 4,5,6,7,0,1,2,3 here to + // stick to that (implicit) convention static const unsigned int orientation_offset[2][2][2]= {{ - // face_orientation=false; face_flip=false; face_rotation=false and true - {4*GeometryInfo::faces_per_cell*total_subfaces_per_face, - 5*GeometryInfo::faces_per_cell*total_subfaces_per_face}, - // face_orientation=false; face_flip=true; face_rotation=false and true - {6*GeometryInfo::faces_per_cell*total_subfaces_per_face, - 7*GeometryInfo::faces_per_cell*total_subfaces_per_face}}, + // face_orientation=false; face_flip=false; face_rotation=false and true + {4*GeometryInfo::faces_per_cell*total_subfaces_per_face, + 5*GeometryInfo::faces_per_cell*total_subfaces_per_face}, + // face_orientation=false; face_flip=true; face_rotation=false and true + {6*GeometryInfo::faces_per_cell*total_subfaces_per_face, + 7*GeometryInfo::faces_per_cell*total_subfaces_per_face}}, { - // face_orientation=true; face_flip=false; face_rotation=false and true - {0*GeometryInfo::faces_per_cell*total_subfaces_per_face, - 1*GeometryInfo::faces_per_cell*total_subfaces_per_face}, - // face_orientation=true; face_flip=true; face_rotation=false and true - {2*GeometryInfo::faces_per_cell*total_subfaces_per_face, - 3*GeometryInfo::faces_per_cell*total_subfaces_per_face}}}; - - // set up a table with the offsets for a - // given refinement case respecting the - // corresponding number of subfaces. the - // index corresponds to (RefineCase::Type - 1) - - // note, that normally we should use the - // obvious offsets 0,2,6. However, prior to - // the implementation of anisotropic - // refinement, in many places of the library - // the convention was used, that the first - // dataset with offset 0 corresponds to a - // standard (isotropic) face - // refinement. therefore we use the offsets - // 6,4,0 here to stick to that (implicit) - // convention + // face_orientation=true; face_flip=false; face_rotation=false and true + {0*GeometryInfo::faces_per_cell*total_subfaces_per_face, + 1*GeometryInfo::faces_per_cell*total_subfaces_per_face}, + // face_orientation=true; face_flip=true; face_rotation=false and true + {2*GeometryInfo::faces_per_cell*total_subfaces_per_face, + 3*GeometryInfo::faces_per_cell*total_subfaces_per_face}}}; + + // set up a table with the offsets for a + // given refinement case respecting the + // corresponding number of subfaces. the + // index corresponds to (RefineCase::Type - 1) + + // note, that normally we should use the + // obvious offsets 0,2,6. However, prior to + // the implementation of anisotropic + // refinement, in many places of the library + // the convention was used, that the first + // dataset with offset 0 corresponds to a + // standard (isotropic) face + // refinement. therefore we use the offsets + // 6,4,0 here to stick to that (implicit) + // convention static const unsigned int ref_case_offset[3]= { - 6, //cut_x - 4, //cut_y - 0 //cut_xy + 6, //cut_x + 4, //cut_y + 0 //cut_xy }; - // for each subface of a given FaceRefineCase - // there is a corresponding equivalent - // subface number of one of the "standard" - // RefineCases (cut_x, cut_y, cut_xy). Map - // the given values to those equivalent - // ones. + // for each subface of a given FaceRefineCase + // there is a corresponding equivalent + // subface number of one of the "standard" + // RefineCases (cut_x, cut_y, cut_xy). Map + // the given values to those equivalent + // ones. - // first, define an invalid number + // first, define an invalid number static const unsigned int e = deal_II_numbers::invalid_unsigned_int; static const RefinementCase equivalent_refine_case[internal::SubfaceCase::case_isotropic+1][GeometryInfo<3>::max_children_per_face] = { - // case_none. there should be only - // invalid values here. However, as - // this function is also called (in - // tests) for cells which have no - // refined faces, use isotropic - // refinement instead - {RefinementCase::cut_xy, - RefinementCase::cut_xy, - RefinementCase::cut_xy, - RefinementCase::cut_xy}, - // case_x - {RefinementCase::cut_x, - RefinementCase::cut_x, - RefinementCase::no_refinement, - RefinementCase::no_refinement}, - // case_x1y - {RefinementCase::cut_xy, - RefinementCase::cut_xy, - RefinementCase::cut_x, - RefinementCase::no_refinement}, - // case_x2y - {RefinementCase::cut_x, - RefinementCase::cut_xy, - RefinementCase::cut_xy, - RefinementCase::no_refinement}, - // case_x1y2y - {RefinementCase::cut_xy, - RefinementCase::cut_xy, - RefinementCase::cut_xy, - RefinementCase::cut_xy}, - // case_y - {RefinementCase::cut_y, - RefinementCase::cut_y, - RefinementCase::no_refinement, - RefinementCase::no_refinement}, - // case_y1x - {RefinementCase::cut_xy, - RefinementCase::cut_xy, - RefinementCase::cut_y, - RefinementCase::no_refinement}, - // case_y2x - {RefinementCase::cut_y, - RefinementCase::cut_xy, - RefinementCase::cut_xy, - RefinementCase::no_refinement}, - // case_y1x2x - {RefinementCase::cut_xy, - RefinementCase::cut_xy, - RefinementCase::cut_xy, - RefinementCase::cut_xy}, - // case_xy (case_isotropic) - {RefinementCase::cut_xy, - RefinementCase::cut_xy, - RefinementCase::cut_xy, - RefinementCase::cut_xy} + // case_none. there should be only + // invalid values here. However, as + // this function is also called (in + // tests) for cells which have no + // refined faces, use isotropic + // refinement instead + {RefinementCase::cut_xy, + RefinementCase::cut_xy, + RefinementCase::cut_xy, + RefinementCase::cut_xy}, + // case_x + {RefinementCase::cut_x, + RefinementCase::cut_x, + RefinementCase::no_refinement, + RefinementCase::no_refinement}, + // case_x1y + {RefinementCase::cut_xy, + RefinementCase::cut_xy, + RefinementCase::cut_x, + RefinementCase::no_refinement}, + // case_x2y + {RefinementCase::cut_x, + RefinementCase::cut_xy, + RefinementCase::cut_xy, + RefinementCase::no_refinement}, + // case_x1y2y + {RefinementCase::cut_xy, + RefinementCase::cut_xy, + RefinementCase::cut_xy, + RefinementCase::cut_xy}, + // case_y + {RefinementCase::cut_y, + RefinementCase::cut_y, + RefinementCase::no_refinement, + RefinementCase::no_refinement}, + // case_y1x + {RefinementCase::cut_xy, + RefinementCase::cut_xy, + RefinementCase::cut_y, + RefinementCase::no_refinement}, + // case_y2x + {RefinementCase::cut_y, + RefinementCase::cut_xy, + RefinementCase::cut_xy, + RefinementCase::no_refinement}, + // case_y1x2x + {RefinementCase::cut_xy, + RefinementCase::cut_xy, + RefinementCase::cut_xy, + RefinementCase::cut_xy}, + // case_xy (case_isotropic) + {RefinementCase::cut_xy, + RefinementCase::cut_xy, + RefinementCase::cut_xy, + RefinementCase::cut_xy} }; static const unsigned int equivalent_subface_number[internal::SubfaceCase::case_isotropic+1][GeometryInfo<3>::max_children_per_face] = { - // case_none, see above - {0,1,2,3}, - // case_x - {0,1,e,e}, - // case_x1y - {0,2,1,e}, - // case_x2y - {0,1,3,e}, - // case_x1y2y - {0,2,1,3}, - // case_y - {0,1,e,e}, - // case_y1x - {0,1,1,e}, - // case_y2x - {0,2,3,e}, - // case_y1x2x - {0,1,2,3}, - // case_xy (case_isotropic) - {0,1,2,3} + // case_none, see above + {0,1,2,3}, + // case_x + {0,1,e,e}, + // case_x1y + {0,2,1,e}, + // case_x2y + {0,1,3,e}, + // case_x1y2y + {0,2,1,3}, + // case_y + {0,1,e,e}, + // case_y1x + {0,1,1,e}, + // case_y2x + {0,2,3,e}, + // case_y1x2x + {0,1,2,3}, + // case_xy (case_isotropic) + {0,1,2,3} }; - // If face-orientation or face_rotation are - // non-standard, cut_x and cut_y have to be - // exchanged. + // If face-orientation or face_rotation are + // non-standard, cut_x and cut_y have to be + // exchanged. static const RefinementCase ref_case_permutation[4] ={RefinementCase::no_refinement, RefinementCase::cut_y, RefinementCase::cut_x, RefinementCase::cut_xy}; - // set a corresponding (equivalent) - // RefineCase and subface number + // set a corresponding (equivalent) + // RefineCase and subface number const RefinementCase equ_ref_case=equivalent_refine_case[ref_case][subface_no]; const unsigned int equ_subface_no=equivalent_subface_number[ref_case][subface_no]; - // make sure, that we got a valid subface and RefineCase + // make sure, that we got a valid subface and RefineCase Assert(equ_ref_case!=RefinementCase::no_refinement, ExcInternalError()); Assert(equ_subface_no!=e, ExcInternalError()); - // now, finally respect non-standard faces + // now, finally respect non-standard faces const RefinementCase final_ref_case = (face_orientation==face_rotation - ? - ref_case_permutation[equ_ref_case] - : - equ_ref_case); - - // what we have now is the number of - // the subface in the natural - // orientation of the *face*. what we - // need to know is the number of the - // subface concerning the standard face - // orientation as seen from the *cell*. - - // this mapping is not trivial, but we - // have done exactly this stuff in the - // child_cell_on_face function. in - // order to reduce the amount of code - // as well as to make maintaining the - // functionality easier we want to - // reuse that information. So we note - // that on the bottom face (face 4) of - // a hex cell the local x and y - // coordinates of the face and the cell - // coincide, thus also the refinement - // case of the face corresponds to the - // refinement case of the cell - // (ignoring cell refinement along the - // z direction). Using this knowledge - // we can (ab)use the - // child_cell_on_face function to do - // exactly the transformation we are in - // need of now + ? + ref_case_permutation[equ_ref_case] + : + equ_ref_case); + + // what we have now is the number of + // the subface in the natural + // orientation of the *face*. what we + // need to know is the number of the + // subface concerning the standard face + // orientation as seen from the *cell*. + + // this mapping is not trivial, but we + // have done exactly this stuff in the + // child_cell_on_face function. in + // order to reduce the amount of code + // as well as to make maintaining the + // functionality easier we want to + // reuse that information. So we note + // that on the bottom face (face 4) of + // a hex cell the local x and y + // coordinates of the face and the cell + // coincide, thus also the refinement + // case of the face corresponds to the + // refinement case of the cell + // (ignoring cell refinement along the + // z direction). Using this knowledge + // we can (ab)use the + // child_cell_on_face function to do + // exactly the transformation we are in + // need of now const unsigned int final_subface_no = GeometryInfo::child_cell_on_face(RefinementCase(final_ref_case), - 4, - equ_subface_no, - face_orientation, - face_flip, - face_rotation, - equ_ref_case); + 4, + equ_subface_no, + face_orientation, + face_flip, + face_rotation, + equ_ref_case); return (((face_no * total_subfaces_per_face - + ref_case_offset[final_ref_case-1] - + final_subface_no) - + orientation_offset[face_orientation][face_flip][face_rotation] - ) - * n_quadrature_points); + + ref_case_offset[final_ref_case-1] + + final_subface_no) + + orientation_offset[face_orientation][face_flip][face_rotation] + ) + * n_quadrature_points); } @@ -1457,7 +1457,7 @@ subface (const unsigned int face_no, template Quadrature QProjector::project_to_face(const SubQuadrature &quadrature, - const unsigned int face_no) + const unsigned int face_no) { std::vector > points(quadrature.size()); project_to_face(quadrature, face_no, points); @@ -1468,9 +1468,9 @@ QProjector::project_to_face(const SubQuadrature &quadrature, template Quadrature QProjector::project_to_subface(const SubQuadrature &quadrature, - const unsigned int face_no, - const unsigned int subface_no, - const RefinementCase &ref_case) + const unsigned int face_no, + const unsigned int subface_no, + const RefinementCase &ref_case) { std::vector > points(quadrature.size()); project_to_subface(quadrature, face_no, subface_no, points, ref_case); @@ -1490,9 +1490,9 @@ QIterated<1>::uses_both_endpoints (const Quadrature<1> &base_quadrature) for (unsigned int i=0; i(0.0)) - at_left = true; + at_left = true; if (base_quadrature.point(i) == Point<1>(1.0)) - at_right = true; + at_right = true; }; return (at_left && at_right); @@ -1502,8 +1502,8 @@ QIterated<1>::uses_both_endpoints (const Quadrature<1> &base_quadrature) // template<> // void // QIterated<1>::fill(Quadrature<1>& dst, -// const Quadrature<1> &base_quadrature, -// const unsigned int n_copies) +// const Quadrature<1> &base_quadrature, +// const unsigned int n_copies) // { // Assert (n_copies > 0, ExcZero()); // Assert (base_quadrature.size() > 0, ExcZero()); @@ -1517,79 +1517,79 @@ QIterated<1>::uses_both_endpoints (const Quadrature<1> &base_quadrature) // dst.weights.resize(np); // if (!uses_both_endpoints(base_quadrature)) -// // we don't have to skip some -// // points in order to get a -// // reasonable quadrature formula +// // we don't have to skip some +// // points in order to get a +// // reasonable quadrature formula // { // unsigned int next_point = 0; // for (unsigned int copy=0; copy 0) && -// (base_quadrature.point(q_point)(0) == 0.)) -// continue; - -// dst.quadrature_points[next_point](0) -// = (copy+base_quadrature.point(q_point)(0)) / n_copies; - -// // if this is the -// // rightmost point of one -// // of the non-last -// // copies: give it the -// // double weight -// if ((copy != n_copies-1) && -// (base_quadrature.point(q_point)(0) == 1.)) -// dst.weights[next_point] = double_point_weight; -// else -// dst.weights[next_point] = base_quadrature.weight(q_point) / -// n_copies; - -// ++next_point; -// }; +// for (unsigned int q_point=0; q_point 0) && +// (base_quadrature.point(q_point)(0) == 0.)) +// continue; + +// dst.quadrature_points[next_point](0) +// = (copy+base_quadrature.point(q_point)(0)) / n_copies; + +// // if this is the +// // rightmost point of one +// // of the non-last +// // copies: give it the +// // double weight +// if ((copy != n_copies-1) && +// (base_quadrature.point(q_point)(0) == 1.)) +// dst.weights[next_point] = double_point_weight; +// else +// dst.weights[next_point] = base_quadrature.weight(q_point) / +// n_copies; + +// ++next_point; +// }; // }; // #if DEBUG @@ -1597,7 +1597,7 @@ QIterated<1>::uses_both_endpoints (const Quadrature<1> &base_quadrature) // for (unsigned int i=0; i::uses_both_endpoints (const Quadrature<1> &base_quadrature) template <> QIterated<0>::QIterated (const Quadrature<1> &, - const unsigned int ) - : - Quadrature<0>() + const unsigned int ) + : + Quadrature<0>() { Assert (false, ExcNotImplemented()); } @@ -1616,95 +1616,95 @@ QIterated<0>::QIterated (const Quadrature<1> &, template <> QIterated<1>::QIterated (const Quadrature<1> &base_quadrature, - const unsigned int n_copies) + const unsigned int n_copies) : - Quadrature<1> (uses_both_endpoints(base_quadrature) ? - (base_quadrature.size()-1) * n_copies + 1 : - base_quadrature.size() * n_copies) + Quadrature<1> (uses_both_endpoints(base_quadrature) ? + (base_quadrature.size()-1) * n_copies + 1 : + base_quadrature.size() * n_copies) { // fill(*this, base_quadrature, n_copies); Assert (base_quadrature.size() > 0, ExcNotInitialized()); Assert (n_copies > 0, ExcZero()); if (!uses_both_endpoints(base_quadrature)) - // we don't have to skip some - // points in order to get a - // reasonable quadrature formula + // we don't have to skip some + // points in order to get a + // reasonable quadrature formula { unsigned int next_point = 0; for (unsigned int copy=0; copyquadrature_points[next_point] - = Point<1>(base_quadrature.point(q_point)(0) / n_copies - + - (1.0*copy)/n_copies); - this->weights[next_point] - = base_quadrature.weight(q_point) / n_copies; - - ++next_point; - }; + for (unsigned int q_point=0; q_pointquadrature_points[next_point] + = Point<1>(base_quadrature.point(q_point)(0) / n_copies + + + (1.0*copy)/n_copies); + this->weights[next_point] + = base_quadrature.weight(q_point) / n_copies; + + ++next_point; + }; } else - // skip doubly available points + // skip doubly available points { unsigned int next_point = 0; - // first find out the weights of - // the left and the right boundary - // points. note that these usually - // are but need not necessarily be - // the same + // first find out the weights of + // the left and the right boundary + // points. note that these usually + // are but need not necessarily be + // the same double double_point_weight = 0; unsigned int n_end_points = 0; for (unsigned int i=0; i(0.0)) || - (base_quadrature.point(i) == Point<1>(1.0))) - { - double_point_weight += base_quadrature.weight(i); - ++n_end_points; - }; - // scale the weight correctly + // add up the weight if this + // is an endpoint + if ((base_quadrature.point(i) == Point<1>(0.0)) || + (base_quadrature.point(i) == Point<1>(1.0))) + { + double_point_weight += base_quadrature.weight(i); + ++n_end_points; + }; + // scale the weight correctly double_point_weight /= n_copies; - // make sure the base quadrature formula - // has only one quadrature point - // per end point + // make sure the base quadrature formula + // has only one quadrature point + // per end point Assert (n_end_points == 2, ExcInvalidQuadratureFormula()); for (unsigned int copy=0; copy 0) && - (base_quadrature.point(q_point) == Point<1>(0.0))) - continue; - - this->quadrature_points[next_point] - = Point<1>(base_quadrature.point(q_point)(0) / n_copies - + - (1.0*copy)/n_copies); - - // if this is the - // rightmost point of one - // of the non-last - // copies: give it the - // double weight - if ((copy != n_copies-1) && - (base_quadrature.point(q_point) == Point<1>(1.0))) - this->weights[next_point] = double_point_weight; - else - this->weights[next_point] = base_quadrature.weight(q_point) / - n_copies; - - ++next_point; - }; + for (unsigned int q_point=0; q_point 0) && + (base_quadrature.point(q_point) == Point<1>(0.0))) + continue; + + this->quadrature_points[next_point] + = Point<1>(base_quadrature.point(q_point)(0) / n_copies + + + (1.0*copy)/n_copies); + + // if this is the + // rightmost point of one + // of the non-last + // copies: give it the + // double weight + if ((copy != n_copies-1) && + (base_quadrature.point(q_point) == Point<1>(1.0))) + this->weights[next_point] = double_point_weight; + else + this->weights[next_point] = base_quadrature.weight(q_point) / + n_copies; + + ++next_point; + }; }; #if DEBUG @@ -1712,7 +1712,7 @@ QIterated<1>::QIterated (const Quadrature<1> &base_quadrature, for (unsigned int i=0; isize(); ++i) sum_of_weights += this->weight(i); Assert (std::fabs(sum_of_weights-1) < 1e-13, - ExcInternalError()); + ExcInternalError()); #endif } @@ -1729,10 +1729,10 @@ QIterated<1>::QIterated (const Quadrature<1> &base_quadrature, // of lower dimensional iterated quadrature formulae template QIterated::QIterated (const Quadrature<1> &base_quadrature, - const unsigned int N) + const unsigned int N) : - Quadrature (QIterated(base_quadrature, N), - QIterated<1>(base_quadrature, N)) + Quadrature (QIterated(base_quadrature, N), + QIterated<1>(base_quadrature, N)) {} diff --git a/deal.II/source/base/quadrature_lib.cc b/deal.II/source/base/quadrature_lib.cc index 9cc5727aab..93384ec7cf 100644 --- a/deal.II/source/base/quadrature_lib.cc +++ b/deal.II/source/base/quadrature_lib.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -41,12 +41,12 @@ namespace template <> QGauss<0>::QGauss (const unsigned int) : - // there are n_q^dim == 1 - // points + // there are n_q^dim == 1 + // points Quadrature<0> (1) { - // the single quadrature point gets unit - // weight + // the single quadrature point gets unit + // weight this->weights[0] = 1; } @@ -55,12 +55,12 @@ QGauss<0>::QGauss (const unsigned int) template <> QGaussLobatto<0>::QGaussLobatto (const unsigned int) : - // there are n_q^dim == 1 - // points + // there are n_q^dim == 1 + // points Quadrature<0> (1) { - // the single quadrature point gets unit - // weight + // the single quadrature point gets unit + // weight this->weights[0] = 1; } @@ -86,22 +86,22 @@ QGauss<1>::QGauss (const unsigned int n) // of the accuracy of double there, // while on other machines we'd // like to go further down - // - // the situation is complicated by - // the fact that even if long - // double exists and is described - // by std::numeric_limits, we may - // not actually get the additional - // precision. One case where this - // happens is on x86, where one can - // set hardware flags that disable - // long double precision even for - // long double variables. these - // flags are not usually set, but - // for example matlab sets them and - // this then breaks deal.II code - // that is run as a subroutine to - // matlab... + // + // the situation is complicated by + // the fact that even if long + // double exists and is described + // by std::numeric_limits, we may + // not actually get the additional + // precision. One case where this + // happens is on x86, where one can + // set hardware flags that disable + // long double precision even for + // long double variables. these + // flags are not usually set, but + // for example matlab sets them and + // this then breaks deal.II code + // that is run as a subroutine to + // matlab... // // a similar situation exists, btw, // when running programs under @@ -120,16 +120,16 @@ QGauss<1>::QGauss (const unsigned int n) double_eps = 2.23-16; #endif - // now check whether long double is more - // accurate than double, and set - // tolerances accordingly. generate a one - // that really is generated at run-time - // and is not optimized away by the - // compiler. that makes sure that the - // tolerance is set at run-time with the - // current behavior, not at compile-time - // (not doing so leads to trouble with - // valgrind for example). + // now check whether long double is more + // accurate than double, and set + // tolerances accordingly. generate a one + // that really is generated at run-time + // and is not optimized away by the + // compiler. that makes sure that the + // tolerance is set at run-time with the + // current behavior, not at compile-time + // (not doing so leads to trouble with + // valgrind for example). volatile long double runtime_one = 1.0; const long double tolerance = (runtime_one + long_double_eps != runtime_one @@ -149,19 +149,19 @@ QGauss<1>::QGauss (const unsigned int n) // Newton iteration do - { - // compute L_n (z) - p1 = 1.; - p2 = 0.; - for (unsigned int j=0;j tolerance); double x = .5*z; @@ -177,16 +177,16 @@ QGauss<1>::QGauss (const unsigned int n) template <> QGaussLobatto<1>::QGaussLobatto (const unsigned int n) - : - Quadrature<1> (n) + : + Quadrature<1> (n) { Assert (n >= 2, ExcNotImplemented()); std::vector points = compute_quadrature_points(n, 1, 1); std::vector w = compute_quadrature_weights(points, 0, 0); - // scale points to the interval - // [0.0, 1.0]: + // scale points to the interval + // [0.0, 1.0]: for (unsigned int i=0; iquadrature_points[i] = Point<1>(0.5 + 0.5*static_cast(points[i])); @@ -199,17 +199,17 @@ QGaussLobatto<1>::QGaussLobatto (const unsigned int n) template <> std::vector QGaussLobatto<1>:: compute_quadrature_points(const unsigned int q, - const int alpha, - const int beta) const + const int alpha, + const int beta) const { const unsigned int m = q-2; // no. of inner points std::vector x(m); - // compute quadrature points with - // a Newton algorithm. + // compute quadrature points with + // a Newton algorithm. - // Set tolerance. See class QGauss - // for detailed explanation. + // Set tolerance. See class QGauss + // for detailed explanation. #ifdef HAVE_STD_NUMERIC_LIMITS const long double long_double_eps = static_cast(std::numeric_limits::epsilon()), @@ -220,9 +220,9 @@ compute_quadrature_points(const unsigned int q, double_eps = 2.23-16; #endif - // check whether long double is - // more accurate than double, and - // set tolerances accordingly + // check whether long double is + // more accurate than double, and + // set tolerances accordingly volatile long double runtime_one = 1.0; const long double tolerance = (runtime_one + long_double_eps != runtime_one @@ -232,17 +232,17 @@ compute_quadrature_points(const unsigned int q, double_eps * 5 ); - // The following implementation - // follows closely the one given in - // the appendix of the book by - // Karniadakis and Sherwin: - // Spectral/hp element methods for - // computational fluid dynamics - // (Oxford University Press, 2005) - - // we take the zeros of the Chebyshev - // polynomial (alpha=beta=-0.5) as - // initial values: + // The following implementation + // follows closely the one given in + // the appendix of the book by + // Karniadakis and Sherwin: + // Spectral/hp element methods for + // computational fluid dynamics + // (Oxford University Press, 2005) + + // we take the zeros of the Chebyshev + // polynomial (alpha=beta=-0.5) as + // initial values: for (unsigned int i=0; i0) - r = (r + x[k-1])/2; + r = (r + x[k-1])/2; do - { - s = 0.; - for (unsigned int i=0; i= tolerance); x[k] = r; } // for - // add boundary points: + // add boundary points: x.insert(x.begin(), -1.L); x.push_back(+1.L); @@ -282,17 +282,17 @@ compute_quadrature_points(const unsigned int q, template <> std::vector QGaussLobatto<1>:: compute_quadrature_weights(const std::vector &x, - const int alpha, - const int beta) const + const int alpha, + const int beta) const { const unsigned int q = x.size(); std::vector w(q); long double s = 0.L; const long double factor = std::pow(2., alpha+beta+1) * - gamma(alpha+q) * - gamma(beta+q) / - ((q-1)*gamma(q)*gamma(alpha+beta+q+1)); + gamma(alpha+q) * + gamma(beta+q) / + ((q-1)*gamma(q)*gamma(alpha+beta+q+1)); for (unsigned int i=0; i &x, template <> long double QGaussLobatto<1>::JacobiP(const long double x, - const int alpha, - const int beta, - const unsigned int n) const + const int alpha, + const int beta, + const unsigned int n) const { - // the Jacobi polynomial is evaluated - // using a recursion formula. + // the Jacobi polynomial is evaluated + // using a recursion formula. std::vector p(n+1); int v, a1, a2, a3, a4; - // initial values P_0(x), P_1(x): + // initial values P_0(x), P_1(x): p[0] = 1.0L; if (n==0) return p[0]; p[1] = ((alpha+beta+2)*x + (alpha-beta))/2; @@ -352,7 +352,7 @@ long double QGaussLobatto<1>::gamma(const unsigned int n) const template <> QMidpoint<1>::QMidpoint () : - Quadrature<1>(1) + Quadrature<1>(1) { this->quadrature_points[0] = Point<1>(0.5); this->weights[0] = 1.0; @@ -363,7 +363,7 @@ QMidpoint<1>::QMidpoint () template <> QTrapez<1>::QTrapez () : - Quadrature<1> (2) + Quadrature<1> (2) { static const double xpts[] = { 0.0, 1.0 }; static const double wts[] = { 0.5, 0.5 }; @@ -380,7 +380,7 @@ QTrapez<1>::QTrapez () template <> QSimpson<1>::QSimpson () : - Quadrature<1> (3) + Quadrature<1> (3) { static const double xpts[] = { 0.0, 0.5, 1.0 }; static const double wts[] = { 1./6., 2./3., 1./6. }; @@ -397,7 +397,7 @@ QSimpson<1>::QSimpson () template <> QMilne<1>::QMilne () : - Quadrature<1> (5) + Quadrature<1> (5) { static const double xpts[] = { 0.0, .25, .5, .75, 1.0 }; static const double wts[] = { 7./90., 32./90., 12./90., 32./90., 7./90. }; @@ -414,11 +414,11 @@ QMilne<1>::QMilne () template <> QWeddle<1>::QWeddle () : - Quadrature<1> (7) + Quadrature<1> (7) { static const double xpts[] = { 0.0, 1./6., 1./3., .5, 2./3., 5./6., 1.0 }; static const double wts[] = { 41./840., 216./840., 27./840., 272./840., - 27./840., 216./840., 41./840. + 27./840., 216./840., 41./840. }; for (unsigned int i=0; isize(); ++i) @@ -441,11 +441,11 @@ QGaussLog<1>::QGaussLog(const unsigned int n, for (unsigned int i=0; isize(); ++i) { - // Using the change of variables x=1-t, it's possible to show - // that int f(x)ln|1-x| = int f(1-t) ln|t|, which implies that - // we can use this quadrature formula also with weight ln|1-x|. - this->quadrature_points[i] = revert ? Point<1>(1-p[n-1-i]) : Point<1>(p[i]); - this->weights[i] = revert ? w[n-1-i] : w[i]; + // Using the change of variables x=1-t, it's possible to show + // that int f(x)ln|1-x| = int f(1-t) ln|t|, which implies that + // we can use this quadrature formula also with weight ln|1-x|. + this->quadrature_points[i] = revert ? Point<1>(1-p[n-1-i]) : Point<1>(p[i]); + this->weights[i] = revert ? w[n-1-i] : w[i]; } } @@ -720,11 +720,11 @@ QGaussLog<1>::set_quadrature_weights(const unsigned int n) const template<> QGaussLogR<1>::QGaussLogR(const unsigned int n, - const Point<1> origin, - const double alpha, - const bool factor_out_singularity) : + const Point<1> origin, + const double alpha, + const bool factor_out_singularity) : Quadrature<1>( ( (origin[0] == 0) || (origin[0] == 1) ) ? - (alpha == 1 ? n : 2*n ) : 4*n ), + (alpha == 1 ? n : 2*n ) : 4*n ), fraction( ( (origin[0] == 0) || (origin[0] == 1.) ) ? 1. : origin[0] ) { // The three quadrature formulas that make this one up. There are @@ -746,55 +746,55 @@ QGaussLogR<1>::QGaussLogR(const unsigned int n, // Check that the origin is inside 0,1 Assert( (fraction >= 0) && (fraction <= 1), - ExcMessage("Origin is outside [0,1].")); + ExcMessage("Origin is outside [0,1].")); // Non singular offset. This is the start of non singular quad // points. unsigned int ns_offset = (fraction == 1) ? n : 2*n; for(unsigned int i=0, j=ns_offset; iquadrature_points[i] = quad1.point(i)*fraction; - this->weights[i] = quad1.weight(i)*fraction; - - // We need to scale with -log|fraction*alpha| - if( (alpha != 1) || (fraction != 1) ) { - this->quadrature_points[j] = quad.point(i)*fraction; - this->weights[j] = -std::log(alpha/fraction)*quad.weight(i)*fraction; - } - // In case we need the second quadrature as well, do it now. - if(fraction != 1) { - this->quadrature_points[i+n] = quad2.point(i)*(1-fraction)+Point<1>(fraction); - this->weights[i+n] = quad2.weight(i)*(1-fraction); - - // We need to scale with -log|fraction*alpha| - this->quadrature_points[j+n] = quad.point(i)*(1-fraction)+Point<1>(fraction); - this->weights[j+n] = -std::log(alpha/(1-fraction))*quad.weight(i)*(1-fraction); - } + // The first i quadrature points are the same as quad1, and + // are by default singular. + this->quadrature_points[i] = quad1.point(i)*fraction; + this->weights[i] = quad1.weight(i)*fraction; + + // We need to scale with -log|fraction*alpha| + if( (alpha != 1) || (fraction != 1) ) { + this->quadrature_points[j] = quad.point(i)*fraction; + this->weights[j] = -std::log(alpha/fraction)*quad.weight(i)*fraction; + } + // In case we need the second quadrature as well, do it now. + if(fraction != 1) { + this->quadrature_points[i+n] = quad2.point(i)*(1-fraction)+Point<1>(fraction); + this->weights[i+n] = quad2.weight(i)*(1-fraction); + + // We need to scale with -log|fraction*alpha| + this->quadrature_points[j+n] = quad.point(i)*(1-fraction)+Point<1>(fraction); + this->weights[j+n] = -std::log(alpha/(1-fraction))*quad.weight(i)*(1-fraction); + } } if(factor_out_singularity == true) - for(unsigned int i=0; iquadrature_points[i] != origin, - ExcMessage("The singularity cannot be on a Gauss point of the same order!") ); - this->weights[i] /= std::log(std::abs( (this->quadrature_points[i]-origin)[0] )/alpha ); - } + for(unsigned int i=0; iquadrature_points[i] != origin, + ExcMessage("The singularity cannot be on a Gauss point of the same order!") ); + this->weights[i] /= std::log(std::abs( (this->quadrature_points[i]-origin)[0] )/alpha ); + } } template<> unsigned int QGaussOneOverR<2>::quad_size(const Point<2> singularity, - const unsigned int n) + const unsigned int n) { double eps=1e-8; bool on_edge=false; bool on_vertex=false; for(unsigned int i=0; i<2; ++i) if( ( std::abs(singularity[i] ) < eps ) || - ( std::abs(singularity[i]-1) < eps ) ) + ( std::abs(singularity[i]-1) < eps ) ) on_edge = true; if(on_edge && (std::abs( (singularity-Point<2>(.5, .5)).square()-.5) - < eps) ) + < eps) ) on_vertex = true; if(on_vertex) return (2*n*n); if(on_edge) return (4*n*n); @@ -803,20 +803,20 @@ unsigned int QGaussOneOverR<2>::quad_size(const Point<2> singularity, template<> QGaussOneOverR<2>::QGaussOneOverR(const unsigned int n, - const Point<2> singularity, - const bool factor_out_singularity) : - Quadrature<2>(quad_size(singularity, n)) + const Point<2> singularity, + const bool factor_out_singularity) : + Quadrature<2>(quad_size(singularity, n)) { - // We treat all the cases in the - // same way. Split the element in 4 - // pieces, measure the area, if - // it's relevant, add the - // quadrature connected to that - // singularity. + // We treat all the cases in the + // same way. Split the element in 4 + // pieces, measure the area, if + // it's relevant, add the + // quadrature connected to that + // singularity. std::vector > quads; std::vector > origins; - // Id of the corner with a - // singularity + // Id of the corner with a + // singularity quads.push_back(QGaussOneOverR(n, 3, factor_out_singularity)); quads.push_back(QGaussOneOverR(n, 2, factor_out_singularity)); quads.push_back(QGaussOneOverR(n, 1, factor_out_singularity)); @@ -827,7 +827,7 @@ QGaussOneOverR<2>::QGaussOneOverR(const unsigned int n, origins.push_back(Point<2>(0.,singularity[1])); origins.push_back(singularity); - // Lexycographical ordering. + // Lexycographical ordering. double eps = 1e-8; unsigned int q_id = 0; // Current quad point index. @@ -840,32 +840,32 @@ QGaussOneOverR<2>::QGaussOneOverR(const unsigned int n, dist = Point<2>(std::abs(dist[0]), std::abs(dist[1])); area = dist[0]*dist[1]; if(area > eps) - for(unsigned int q=0; q &qp = quads[box].point(q); - this->quadrature_points[q_id] = - origins[box]+ - Point<2>(dist[0]*qp[0], dist[1]*qp[1]); - this->weights[q_id] = quads[box].weight(q)*area; - } + for(unsigned int q=0; q &qp = quads[box].point(q); + this->quadrature_points[q_id] = + origins[box]+ + Point<2>(dist[0]*qp[0], dist[1]*qp[1]); + this->weights[q_id] = quads[box].weight(q)*area; + } } } template<> QGaussOneOverR<2>::QGaussOneOverR(const unsigned int n, - const unsigned int vertex_index, - const bool factor_out_singularity) : + const unsigned int vertex_index, + const bool factor_out_singularity) : Quadrature<2>(2*n*n) { - // This version of the constructor - // works only for the 4 - // vertices. If you need a more - // general one, you should use the - // one with the Point<2> in the - // constructor. + // This version of the constructor + // works only for the 4 + // vertices. If you need a more + // general one, you should use the + // one with the Point<2> in the + // constructor. Assert(vertex_index <4, ExcIndexRange(vertex_index, 0, 4)); - + // Start with the gauss quadrature formula on the (u,v) reference // element. QGauss<2> gauss(n); @@ -890,52 +890,52 @@ QGaussOneOverR<2>::QGaussOneOverR(const unsigned int n, // // And we get rid of R to take into account the singularity, // unless specified differently in the constructor. - std::vector > &ps = this->quadrature_points; - std::vector &ws = this->weights; + std::vector > &ps = this->quadrature_points; + std::vector &ws = this->weights; double pi4 = numbers::PI/4; for(unsigned int q=0; q &gp = gauss.point(q); - ps[q][0] = gp[0]; - ps[q][1] = gp[0] * std::tan(pi4*gp[1]); - ws[q] = gauss.weight(q)*pi4/std::cos(pi4 *gp[1]); - if(factor_out_singularity) - ws[q] *= (ps[q]-GeometryInfo<2>::unit_cell_vertex(0)).norm(); - // The other half of the quadrilateral is symmetric with - // respect to xy plane. - ws[gauss.size()+q] = ws[q]; - ps[gauss.size()+q][0] = ps[q][1]; - ps[gauss.size()+q][1] = ps[q][0]; + const Point<2> &gp = gauss.point(q); + ps[q][0] = gp[0]; + ps[q][1] = gp[0] * std::tan(pi4*gp[1]); + ws[q] = gauss.weight(q)*pi4/std::cos(pi4 *gp[1]); + if(factor_out_singularity) + ws[q] *= (ps[q]-GeometryInfo<2>::unit_cell_vertex(0)).norm(); + // The other half of the quadrilateral is symmetric with + // respect to xy plane. + ws[gauss.size()+q] = ws[q]; + ps[gauss.size()+q][0] = ps[q][1]; + ps[gauss.size()+q][1] = ps[q][0]; } // Now we distribute these vertices in the correct manner double theta = 0; switch(vertex_index) { case 0: - theta = 0; - break; + theta = 0; + break; case 1: - // - theta = numbers::PI/2; - break; + // + theta = numbers::PI/2; + break; case 2: - theta = -numbers::PI/2; - break; + theta = -numbers::PI/2; + break; case 3: - theta = numbers::PI; - break; + theta = numbers::PI; + break; } double R00 = std::cos(theta), R01 = -std::sin(theta); double R10 = std::sin(theta), R11 = std::cos(theta); if(vertex_index != 0) - for(unsigned int q=0; q::QGaussLobatto (const unsigned int n) template QMidpoint::QMidpoint () : - Quadrature (QMidpoint(), QMidpoint<1>()) + Quadrature (QMidpoint(), QMidpoint<1>()) {} @@ -967,7 +967,7 @@ QMidpoint::QMidpoint () template QTrapez::QTrapez () : - Quadrature (QTrapez(), QTrapez<1>()) + Quadrature (QTrapez(), QTrapez<1>()) {} @@ -975,7 +975,7 @@ QTrapez::QTrapez () template QSimpson::QSimpson () : - Quadrature (QSimpson(), QSimpson<1>()) + Quadrature (QSimpson(), QSimpson<1>()) {} @@ -983,14 +983,14 @@ QSimpson::QSimpson () template QMilne::QMilne () : - Quadrature (QMilne(), QMilne<1>()) + Quadrature (QMilne(), QMilne<1>()) {} template QWeddle::QWeddle () : - Quadrature (QWeddle(), QWeddle<1>()) + Quadrature (QWeddle(), QWeddle<1>()) {} diff --git a/deal.II/source/base/quadrature_selector.cc b/deal.II/source/base/quadrature_selector.cc index b26f0f0b95..3e63cccc06 100644 --- a/deal.II/source/base/quadrature_selector.cc +++ b/deal.II/source/base/quadrature_selector.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2005, 2006, 2010 by the deal.II authors +// Copyright (C) 2003, 2005, 2006, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -22,7 +22,7 @@ template Quadrature QuadratureSelector:: create_quadrature (const std::string &s, - const unsigned int order) + const unsigned int order) { if(s == "gauss") { @@ -40,11 +40,11 @@ create_quadrature (const std::string &s, else if (s == "weddle") return QWeddle(); } - // we didn't find this name + // we didn't find this name AssertThrow (false, ExcInvalidQuadrature(s)); - // return something to suppress - // stupid warnings by some - // compilers + // return something to suppress + // stupid warnings by some + // compilers return Quadrature(); } @@ -52,11 +52,11 @@ create_quadrature (const std::string &s, template QuadratureSelector::QuadratureSelector (const std::string &s, - const unsigned int order) - : - Quadrature (create_quadrature(s, order).get_points(), - create_quadrature(s, order).get_weights()) -{ + const unsigned int order) + : + Quadrature (create_quadrature(s, order).get_points(), + create_quadrature(s, order).get_weights()) +{ } diff --git a/deal.II/source/base/subscriptor.cc b/deal.II/source/base/subscriptor.cc index e6b3633be1..ec6f3534ab 100644 --- a/deal.II/source/base/subscriptor.cc +++ b/deal.II/source/base/subscriptor.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2010 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -23,7 +23,7 @@ DEAL_II_NAMESPACE_OPEN -namespace +namespace { // create a lock that might be used to control subscription to and // unsubscription from objects, as that might happen in parallel. @@ -43,87 +43,87 @@ static const char* unknown_subscriber = "unknown subscriber"; Subscriptor::Subscriptor () : - counter (0), - object_info (0) + counter (0), + object_info (0) {} Subscriptor::Subscriptor (const Subscriptor &) : - counter (0), - object_info (0) + counter (0), + object_info (0) {} Subscriptor::~Subscriptor () { - // check whether there are still - // subscriptions to this object. if - // so, output the actual name of - // the class to which this object - // belongs, i.e. the most derived - // class. note that the name may be - // mangled, so it need not be the - // clear-text class name. however, - // you can obtain the latter by - // running the c++filt program over - // the output. + // check whether there are still + // subscriptions to this object. if + // so, output the actual name of + // the class to which this object + // belongs, i.e. the most derived + // class. note that the name may be + // mangled, so it need not be the + // clear-text class name. however, + // you can obtain the latter by + // running the c++filt program over + // the output. #ifdef DEBUG std::string infostring; for (map_iterator it = counter_map.begin(); it != counter_map.end(); ++it) { if (it->second > 0) - infostring += std::string("\n from Subscriber ") - + std::string(it->first); + infostring += std::string("\n from Subscriber ") + + std::string(it->first); } - // if there are still active pointers, show - // a message and kill the program. However, - // under some circumstances, this is not so - // desirable. For example, in code like this - // - // Triangulation tria; - // DoFHandler *dh = new DoFHandler(tria); - // ...some function that throws an exception - // - // the exception will lead to the - // destruction of the triangulation, but - // since the dof_handler is on the heap it - // will not be destroyed. This will trigger - // an assertion in the triangulation. If we - // kill the program at this point, we will - // never be able to learn what caused the - // problem. In this situation, just display - // a message and continue the program. + // if there are still active pointers, show + // a message and kill the program. However, + // under some circumstances, this is not so + // desirable. For example, in code like this + // + // Triangulation tria; + // DoFHandler *dh = new DoFHandler(tria); + // ...some function that throws an exception + // + // the exception will lead to the + // destruction of the triangulation, but + // since the dof_handler is on the heap it + // will not be destroyed. This will trigger + // an assertion in the triangulation. If we + // kill the program at this point, we will + // never be able to learn what caused the + // problem. In this situation, just display + // a message and continue the program. if (counter != 0) { if (std::uncaught_exception() == false) - { - Assert (counter == 0, - ExcInUse (counter, object_info->name(), infostring)); - } + { + Assert (counter == 0, + ExcInUse (counter, object_info->name(), infostring)); + } else - { - std::cerr << "---------------------------------------------------------" - << std::endl - << "An object pointed to by a SmartPointer is being destroyed." - << std::endl - << "Under normal circumstances, this would abort the program." - << std::endl - << "However, another exception is being processed at the" - << std::endl - << "moment, so the program will continue to run to allow" - << std::endl - << "this exception to be processed." - << std::endl - << "---------------------------------------------------------" - << std::endl; - } + { + std::cerr << "---------------------------------------------------------" + << std::endl + << "An object pointed to by a SmartPointer is being destroyed." + << std::endl + << "Under normal circumstances, this would abort the program." + << std::endl + << "However, another exception is being processed at the" + << std::endl + << "moment, so the program will continue to run to allow" + << std::endl + << "this exception to be processed." + << std::endl + << "---------------------------------------------------------" + << std::endl; + } } - // In case we do not abort - // on error, this will tell - // do_unsubscribe below that the - // object is unused now. + // In case we do not abort + // on error, this will tell + // do_unsubscribe below that the + // object is unused now. counter = 0; #endif } @@ -146,14 +146,14 @@ void Subscriptor::do_subscribe (const char* id) const object_info = &typeid(*this); Threads::ThreadMutex::ScopedLock lock (subscription_lock); ++counter; - + #if DEAL_USE_MT == 0 const char* const name = (id != 0) ? id : unknown_subscriber; - + map_iterator it = counter_map.find(name); if (it == counter_map.end()) counter_map.insert(map_value_type(name, 1U)); - + else it->second++; #endif @@ -166,19 +166,19 @@ void Subscriptor::do_unsubscribe (const char* id) const #ifdef DEBUG const char* name = (id != 0) ? id : unknown_subscriber; Assert (counter>0, ExcNoSubscriber(object_info->name(), name)); - // This is for the case that we do - // not abort after the exception + // This is for the case that we do + // not abort after the exception if (counter == 0) return; - + Threads::ThreadMutex::ScopedLock lock (subscription_lock); --counter; - + #if DEAL_USE_MT == 0 map_iterator it = counter_map.find(name); Assert (it != counter_map.end(), ExcNoSubscriber(object_info->name(), name)); Assert (it->second > 0, ExcNoSubscriber(object_info->name(), name)); - + it->second--; #endif #endif @@ -197,8 +197,8 @@ void Subscriptor::list_subscribers () const for (map_iterator it = counter_map.begin(); it != counter_map.end(); ++it) deallog << it->second << '/' - << counter << " subscriptions from \"" - << it->first << '\"' << std::endl; + << counter << " subscriptions from \"" + << it->first << '\"' << std::endl; #else deallog << "No subscriber listing with multithreading" << std::endl; #endif diff --git a/deal.II/source/base/symmetric_tensor.cc b/deal.II/source/base/symmetric_tensor.cc index 30ef5f61bb..d7de1d997e 100644 --- a/deal.II/source/base/symmetric_tensor.cc +++ b/deal.II/source/base/symmetric_tensor.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2005, 2006 by the deal.II authors +// Copyright (C) 2005, 2006, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -34,13 +34,13 @@ invert<3,double> (const SymmetricTensor<4,3,double> &t) // references between libbase and liblac const unsigned int N = 6; - // first get an estimate of the - // size of the elements of this - // matrix, for later checks whether - // the pivot element is large - // enough, or whether we have to - // fear that the matrix is not - // regular + // first get an estimate of the + // size of the elements of this + // matrix, for later checks whether + // the pivot element is large + // enough, or whether we have to + // fear that the matrix is not + // regular double diagonal_sum = 0; for (unsigned int i=0; i (const SymmetricTensor<4,3,double> &t) for (unsigned int j=0; j (const SymmetricTensor<4,3,double> &t) max = std::fabs(tmp.data[i][j]); r = i; } - // check whether the pivot is - // too small + // check whether the pivot is + // too small Assert(max > 1.e-16*typical_diagonal_element, - ExcMessage("This tensor seems to be noninvertible")); + ExcMessage("This tensor seems to be noninvertible")); - // row interchange + // row interchange if (r>j) - { - for (unsigned int k=0; k void operator()( T & operand ) const { - operand = T(); + operand = T(); } }; } @@ -100,22 +100,22 @@ namespace internal TableHandler::Column::Column(const std::string &tex_caption) : - tex_caption(tex_caption), - tex_format("c"), - precision(4), - scientific(0), - flag(0) + tex_caption(tex_caption), + tex_format("c"), + precision(4), + scientific(0), + flag(0) {} TableHandler::Column::Column() : - tex_caption(), - tex_format("c"), - precision(4), - scientific(0), - flag(0) + tex_caption(), + tex_format("c"), + precision(4), + scientific(0), + flag(0) {} @@ -151,7 +151,7 @@ TableHandler::set_auto_fill_mode (const bool state) void TableHandler::add_column_to_supercolumn (const std::string &key, - const std::string &superkey) + const std::string &superkey) { Assert(columns.count(key), ExcColumnNotExistent(key)); @@ -160,33 +160,33 @@ void TableHandler::add_column_to_supercolumn (const std::string &key, std::pair > new_column(superkey, std::vector()); supercolumns.insert(new_column); - // replace key in column_order - // by superkey + // replace key in column_order + // by superkey for (unsigned int j=0; j::iterator order_iter=column_order.begin(); - order_iter!=column_order.end(); ++order_iter) - if (*order_iter==key) - { - column_order.erase(order_iter); - break; - } + order_iter!=column_order.end(); ++order_iter) + if (*order_iter==key) + { + column_order.erase(order_iter); + break; + } } if (supercolumns.count(superkey)) { supercolumns[superkey].push_back(key); - // By default set the - // tex_supercaption to superkey + // By default set the + // tex_supercaption to superkey std::pair new_tex_supercaption(superkey, superkey); tex_supercaptions.insert(new_tex_supercaption); } @@ -200,14 +200,14 @@ void TableHandler::set_column_order (const std::vector &new_order) { for (unsigned int j=0; j::const_iterator p = columns.begin(); - p != columns.end(); ++p) + p != columns.end(); ++p) max_rows = std::max(max_rows, p->second.entries.size()); for (std::map::iterator p = columns.begin(); - p != columns.end(); ++p) + p != columns.end(); ++p) p->second.pad_column_below (max_rows); } @@ -290,99 +290,99 @@ void TableHandler::write_text(std::ostream &out, const unsigned int nrows = n_rows(); const unsigned int n_cols = sel_columns.size(); - // first compute the widths of each - // entry of the table, in order to - // have a nicer alignement + // first compute the widths of each + // entry of the table, in order to + // have a nicer alignement Table<2,unsigned int> entry_widths (nrows, n_cols); for (unsigned int i=0; i::const_iterator - col_iter = columns.find(key); - Assert(col_iter!=columns.end(), ExcInternalError()); - - const Column & column = col_iter->second; - - // write it into a dummy - // stream, just to get its - // size upon output - std::ostringstream dummy_out; - - dummy_out << std::setprecision(column.precision); - - if (col_iter->second.scientific) - dummy_out.setf (std::ios::scientific, std::ios::floatfield); - else - dummy_out.setf (std::ios::fixed, std::ios::floatfield); - - dummy_out << column.entries[i].value; - - // get size. as a side note, if the - // text printed is in fact the empty - // string, then we get into a bit of - // trouble since readers would skip - // over the resulting whitespaces. as - // a consequence, we'll print "" - // instead in that case. - const unsigned int size = dummy_out.str().length(); - if (size > 0) - entry_widths[i][j] = size; - else - entry_widths[i][j] = 2; + // get key and entry here + std::string key = sel_columns[j]; + const std::map::const_iterator + col_iter = columns.find(key); + Assert(col_iter!=columns.end(), ExcInternalError()); + + const Column & column = col_iter->second; + + // write it into a dummy + // stream, just to get its + // size upon output + std::ostringstream dummy_out; + + dummy_out << std::setprecision(column.precision); + + if (col_iter->second.scientific) + dummy_out.setf (std::ios::scientific, std::ios::floatfield); + else + dummy_out.setf (std::ios::fixed, std::ios::floatfield); + + dummy_out << column.entries[i].value; + + // get size. as a side note, if the + // text printed is in fact the empty + // string, then we get into a bit of + // trouble since readers would skip + // over the resulting whitespaces. as + // a consequence, we'll print "" + // instead in that case. + const unsigned int size = dummy_out.str().length(); + if (size > 0) + entry_widths[i][j] = size; + else + entry_widths[i][j] = 2; } - // next compute the width each row - // has to have to suit all entries + // next compute the width each row + // has to have to suit all entries std::vector column_widths (n_cols, 0); for (unsigned int i=0; i column_widths[j]) - column_widths[j] = key.length(); - - // now write key. try to center - // it somehow - const unsigned int front_padding = (column_widths[j]-key.length())/2, - rear_padding = (column_widths[j]-key.length()) - - front_padding; + case table_with_headers: + { + // if the key of this column is + // wider than the widest entry, + // then adjust + if (key.length() > column_widths[j]) + column_widths[j] = key.length(); + + // now write key. try to center + // it somehow + const unsigned int front_padding = (column_widths[j]-key.length())/2, + rear_padding = (column_widths[j]-key.length()) - + front_padding; for (unsigned int i=0; i::const_iterator - col_iter=columns.find(key); - Assert(col_iter!=columns.end(), ExcInternalError()); - - const Column &column=col_iter->second; - - out << std::setprecision(column.precision); - - if (col_iter->second.scientific) - out.setf(std::ios::scientific, std::ios::floatfield); - else - out.setf(std::ios::fixed, std::ios::floatfield); - out << std::setw(column_widths[j]); - - // get the string to write into the - // table. we could simply << it - // into the stream but we have to - // be a bit careful about the case - // where the string may be empty, - // in which case we'll print it as - // "". note that ultimately we - // still just << it into the stream - // since we want to use the flags - // of that stream, and the first - // test is only used to determine - // whether the size of the string - // representation is zero - { - std::ostringstream text; - text << column.entries[i].value; - if (text.str().size() > 0) - out << column.entries[i].value; - else - out << "\"\""; - } - - // pad after this column - out << " "; - } + { + std::string key=sel_columns[j]; + const std::map::const_iterator + col_iter=columns.find(key); + Assert(col_iter!=columns.end(), ExcInternalError()); + + const Column &column=col_iter->second; + + out << std::setprecision(column.precision); + + if (col_iter->second.scientific) + out.setf(std::ios::scientific, std::ios::floatfield); + else + out.setf(std::ios::fixed, std::ios::floatfield); + out << std::setw(column_widths[j]); + + // get the string to write into the + // table. we could simply << it + // into the stream but we have to + // be a bit careful about the case + // where the string may be empty, + // in which case we'll print it as + // "". note that ultimately we + // still just << it into the stream + // since we want to use the flags + // of that stream, and the first + // test is only used to determine + // whether the size of the string + // representation is zero + { + std::ostringstream text; + text << column.entries[i].value; + if (text.str().size() > 0) + out << column.entries[i].value; + else + out << "\"\""; + } + + // pad after this column + out << " "; + } out << std::endl; } } @@ -442,8 +442,8 @@ void TableHandler::write_tex (std::ostream &out, const bool with_header) const AssertThrow (out, ExcIO()); if (with_header) out << "\\documentclass[10pt]{report}" << std::endl - << "\\usepackage{float}" << std::endl << std::endl << std::endl - << "\\begin{document}" << std::endl; + << "\\usepackage{float}" << std::endl << std::endl << std::endl + << "\\begin{document}" << std::endl; out << "\\begin{table}[H]" << std::endl << "\\begin{center}" << std::endl @@ -454,112 +454,112 @@ void TableHandler::write_tex (std::ostream &out, const bool with_header) const { unsigned int max_rows = 0; for (std::map::const_iterator p = columns.begin(); - p != columns.end(); ++p) + p != columns.end(); ++p) max_rows = std::max(max_rows, p->second.entries.size()); for (std::map::iterator p = columns.begin(); - p != columns.end(); ++p) + p != columns.end(); ++p) p->second.pad_column_below (max_rows); } std::vector sel_columns; get_selected_columns(sel_columns); - // write the column formats + // write the column formats for (unsigned int j=0; j >::const_iterator - super_iter=supercolumns.find(key); + super_iter=supercolumns.find(key); if (super_iter!=supercolumns.end()) - { - const unsigned int n_subcolumns=super_iter->second.size(); - for (unsigned int k=0; k::const_iterator - col_iter=columns.find(super_iter->second[k]); - Assert(col_iter!=columns.end(), ExcInternalError()); - - out << col_iter->second.tex_format << "|"; - } - } + { + const unsigned int n_subcolumns=super_iter->second.size(); + for (unsigned int k=0; k::const_iterator + col_iter=columns.find(super_iter->second[k]); + Assert(col_iter!=columns.end(), ExcInternalError()); + + out << col_iter->second.tex_format << "|"; + } + } else - { - // avoid `columns[key]'; - const std::map::const_iterator - col_iter=columns.find(key); - Assert(col_iter!=columns.end(), ExcInternalError()); - out << col_iter->second.tex_format << "|"; - } + { + // avoid `columns[key]'; + const std::map::const_iterator + col_iter=columns.find(key); + Assert(col_iter!=columns.end(), ExcInternalError()); + out << col_iter->second.tex_format << "|"; + } } out << "} \\hline" << std::endl; - // write the caption line of the table + // write the caption line of the table for (unsigned int j=0; j >::const_iterator - super_iter=supercolumns.find(key); + super_iter=supercolumns.find(key); if (super_iter!=supercolumns.end()) - { - const unsigned int n_subcolumns=super_iter->second.size(); - // avoid use of `tex_supercaptions[key]' - std::map::const_iterator - tex_super_cap_iter=tex_supercaptions.find(key); - out << std::endl << "\\multicolumn{" << n_subcolumns << "}{|c|}{" - << tex_super_cap_iter->second << "}"; - } + { + const unsigned int n_subcolumns=super_iter->second.size(); + // avoid use of `tex_supercaptions[key]' + std::map::const_iterator + tex_super_cap_iter=tex_supercaptions.find(key); + out << std::endl << "\\multicolumn{" << n_subcolumns << "}{|c|}{" + << tex_super_cap_iter->second << "}"; + } else - { - // col_iter->second=columns[col]; - const std::map::const_iterator - col_iter=columns.find(key); - Assert(col_iter!=columns.end(), ExcInternalError()); - out << col_iter->second.tex_caption; - } + { + // col_iter->second=columns[col]; + const std::map::const_iterator + col_iter=columns.find(key); + Assert(col_iter!=columns.end(), ExcInternalError()); + out << col_iter->second.tex_caption; + } if (j::const_iterator - col_iter=columns.find(key); - Assert(col_iter!=columns.end(), ExcInternalError()); + { + std::string key=sel_columns[j]; + // avoid `column[key]' + const std::map::const_iterator + col_iter=columns.find(key); + Assert(col_iter!=columns.end(), ExcInternalError()); - const Column &column=col_iter->second; + const Column &column=col_iter->second; - out << std::setprecision(column.precision); + out << std::setprecision(column.precision); - if (col_iter->second.scientific) - out.setf(std::ios::scientific, std::ios::floatfield); - else - out.setf(std::ios::fixed, std::ios::floatfield); + if (col_iter->second.scientific) + out.setf(std::ios::scientific, std::ios::floatfield); + else + out.setf(std::ios::fixed, std::ios::floatfield); - out << column.entries[i].value; + out << column.entries[i].value; - if (jsecond.entries.size()==n, - ExcWrongNumberOfDataEntries(col_iter->first, - col_iter->second.entries.size(), - first_name, n)); + ExcWrongNumberOfDataEntries(col_iter->first, + col_iter->second.entries.size(), + first_name, n)); return n; } @@ -597,25 +597,25 @@ void TableHandler::get_selected_columns(std::vector &sel_columns) c { std::string key=column_order[j]; const std::map >::const_iterator - super_iter=supercolumns.find(key); + super_iter=supercolumns.find(key); if (super_iter!=supercolumns.end()) - { - // i.e. key is a supercolumn key - const unsigned int n_subcolumns=super_iter->second.size(); - for (unsigned int j=0; jsecond[j]; - Assert(columns.count(subkey), ExcInternalError()); - sel_columns.push_back(subkey); - } - } + { + // i.e. key is a supercolumn key + const unsigned int n_subcolumns=super_iter->second.size(); + for (unsigned int j=0; jsecond[j]; + Assert(columns.count(subkey), ExcInternalError()); + sel_columns.push_back(subkey); + } + } else - { - Assert(columns.count(key), ExcInternalError()); - // i.e. key is a column key - sel_columns.push_back(key); - } + { + Assert(columns.count(key), ExcInternalError()); + // i.e. key is a column key + sel_columns.push_back(key); + } } } diff --git a/deal.II/source/base/tensor_function.cc b/deal.II/source/base/tensor_function.cc index 5267eef1bc..950a892f57 100644 --- a/deal.II/source/base/tensor_function.cc +++ b/deal.II/source/base/tensor_function.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -27,8 +27,8 @@ DEAL_II_NAMESPACE_OPEN template TensorFunction::TensorFunction (const double initial_time) - : - FunctionTime (initial_time) + : + FunctionTime (initial_time) {} @@ -50,10 +50,10 @@ TensorFunction::value (const Point &) const template void TensorFunction::value_list (const std::vector > &points, - std::vector &values) const + std::vector &values) const { Assert (values.size() == points.size(), - ExcDimensionMismatch(values.size(), points.size())); + ExcDimensionMismatch(values.size(), points.size())); for (unsigned int i=0; ivalue (points[i]); @@ -72,10 +72,10 @@ TensorFunction::gradient (const Point &) const template void TensorFunction::gradient_list (const std::vector > &points, - std::vector &gradients) const + std::vector &gradients) const { Assert (gradients.size() == points.size(), - ExcDimensionMismatch(gradients.size(), points.size())); + ExcDimensionMismatch(gradients.size(), points.size())); for (unsigned int i=0; i::output_indices(std::ostream &out) const compute_index(i,ix); out << i << "\t"; for (unsigned int d=0; d::set_numbering( const std::vector &renumber) { Assert(renumber.size()==index_map.size(), - ExcDimensionMismatch(renumber.size(), index_map.size())); + ExcDimensionMismatch(renumber.size(), index_map.size())); index_map=renumber; for (unsigned int i=0; i::compute_value (const unsigned int i, template <> double TensorProductPolynomials<0>::compute_value (const unsigned int , - const Point<0> &) const + const Point<0> &) const { Assert (false, ExcNotImplemented()); return 0.; @@ -146,9 +146,9 @@ TensorProductPolynomials::compute_grad (const unsigned int i, std::vector tmp (2); for (unsigned int d=0; d::compute_grad_grad (const unsigned int i, std::vector tmp (3); for (unsigned int d=0; d &p, std::vector tmp (n_values_and_derivatives); for (unsigned int d=0; d::n() const template AnisotropicPolynomials:: AnisotropicPolynomials(const std::vector > > &pols) - : - polynomials (pols), - n_tensor_pols(get_n_tensor_pols(pols)) + : + polynomials (pols), + n_tensor_pols(get_n_tensor_pols(pols)) { Assert (pols.size() == dim, ExcDimensionMismatch(pols.size(), dim)); for (unsigned int d=0; d > split_interval (const unsigned int begin, - const unsigned int end, - const unsigned int n_intervals) + const unsigned int end, + const unsigned int n_intervals) { Assert (end >= begin, ExcInternalError()); @@ -261,20 +261,20 @@ namespace Threads return_values[0].first = begin; for (unsigned int i=0; impi_data - = Utilities::MPI::min_max_avg (time, mpi_communicator); + { + this->mpi_data + = Utilities::MPI::min_max_avg (time, mpi_communicator); - cumulative_wall_time += this->mpi_data.max; - } + cumulative_wall_time += this->mpi_data.max; + } else #endif - cumulative_wall_time += time; + cumulative_wall_time += time; } return cumulative_time; } @@ -146,28 +146,28 @@ double Timer::operator() () const rusage usage_children; getrusage (RUSAGE_CHILDREN, &usage_children); const double dtime_children = - usage_children.ru_utime.tv_sec + 1.e-6 * usage_children.ru_utime.tv_usec; + usage_children.ru_utime.tv_sec + 1.e-6 * usage_children.ru_utime.tv_usec; const double running_time = dtime - start_time + dtime_children - - start_time_children + cumulative_time; + - start_time_children + cumulative_time; if (Utilities::System::job_supports_mpi()) - // in case of MPI, need to get the time - // passed by summing the time over all - // processes in the network. works also - // in case we just want to have the time - // of a single thread, since then the - // communicator is MPI_COMM_SELF - return Utilities::MPI::sum (running_time, mpi_communicator); + // in case of MPI, need to get the time + // passed by summing the time over all + // processes in the network. works also + // in case we just want to have the time + // of a single thread, since then the + // communicator is MPI_COMM_SELF + return Utilities::MPI::sum (running_time, mpi_communicator); else - return running_time; + return running_time; } else { if (Utilities::System::job_supports_mpi()) - return Utilities::MPI::sum (cumulative_time, mpi_communicator); + return Utilities::MPI::sum (cumulative_time, mpi_communicator); else - return cumulative_time; + return cumulative_time; } } @@ -180,7 +180,7 @@ double Timer::wall_time () const struct timeval wall_timer; gettimeofday(&wall_timer, NULL); return wall_timer.tv_sec + 1.e-6 * wall_timer.tv_usec - start_wall_time + - cumulative_wall_time; + cumulative_wall_time; } else return cumulative_wall_time; @@ -200,30 +200,30 @@ void Timer::reset () /* ---------------------------- TimerOutput -------------------------- */ TimerOutput::TimerOutput (std::ostream &stream, - const enum OutputFrequency output_frequency, - const enum OutputType output_type) + const enum OutputFrequency output_frequency, + const enum OutputType output_type) : output_frequency (output_frequency), - output_type (output_type), + output_type (output_type), out_stream (stream, true), - output_is_enabled (true) + output_is_enabled (true) #ifdef DEAL_II_COMPILER_SUPPORTS_MPI - , mpi_communicator (MPI_COMM_SELF) + , mpi_communicator (MPI_COMM_SELF) #endif {} TimerOutput::TimerOutput (ConditionalOStream &stream, - const enum OutputFrequency output_frequency, - const enum OutputType output_type) + const enum OutputFrequency output_frequency, + const enum OutputType output_type) : output_frequency (output_frequency), - output_type (output_type), + output_type (output_type), out_stream (stream), - output_is_enabled (true) + output_is_enabled (true) #ifdef DEAL_II_COMPILER_SUPPORTS_MPI - , mpi_communicator (MPI_COMM_SELF) + , mpi_communicator (MPI_COMM_SELF) #endif {} @@ -231,29 +231,29 @@ TimerOutput::TimerOutput (ConditionalOStream &stream, #ifdef DEAL_II_COMPILER_SUPPORTS_MPI TimerOutput::TimerOutput (MPI_Comm mpi_communicator, - std::ostream &stream, - const enum OutputFrequency output_frequency, - const enum OutputType output_type) + std::ostream &stream, + const enum OutputFrequency output_frequency, + const enum OutputType output_type) : output_frequency (output_frequency), - output_type (output_type), + output_type (output_type), out_stream (stream, true), - output_is_enabled (true), - mpi_communicator (mpi_communicator) + output_is_enabled (true), + mpi_communicator (mpi_communicator) {} TimerOutput::TimerOutput (MPI_Comm mpi_communicator, - ConditionalOStream &stream, - const enum OutputFrequency output_frequency, - const enum OutputType output_type) + ConditionalOStream &stream, + const enum OutputFrequency output_frequency, + const enum OutputType output_type) : output_frequency (output_frequency), - output_type (output_type), + output_type (output_type), out_stream (stream), - output_is_enabled (true), - mpi_communicator (mpi_communicator) + output_is_enabled (true), + mpi_communicator (mpi_communicator) {} #endif @@ -276,11 +276,11 @@ TimerOutput::enter_subsection (const std::string §ion_name) Threads::ThreadMutex::ScopedLock lock (mutex); Assert (section_name.empty() == false, - ExcMessage ("Section string is empty.")); + ExcMessage ("Section string is empty.")); Assert (std::find (active_sections.begin(), active_sections.end(), - section_name) == active_sections.end(), - ExcMessage ("Cannot enter the already active section.")); + section_name) == active_sections.end(), + ExcMessage ("Cannot enter the already active section.")); if (sections.find (section_name) == sections.end()) { @@ -302,40 +302,40 @@ void TimerOutput::leave_subsection (const std::string §ion_name) { Assert (!active_sections.empty(), - ExcMessage("Cannot exit any section because none has been entered!")); + ExcMessage("Cannot exit any section because none has been entered!")); Threads::ThreadMutex::ScopedLock lock (mutex); if (section_name != "") { Assert (sections.find (section_name) != sections.end(), - ExcMessage ("Cannot delete a section that was never created.")); + ExcMessage ("Cannot delete a section that was never created.")); Assert (std::find (active_sections.begin(), active_sections.end(), - section_name) != active_sections.end(), - ExcMessage ("Cannot delete a section that has not been entered.")); + section_name) != active_sections.end(), + ExcMessage ("Cannot delete a section that has not been entered.")); } - // if no string is given, exit the last - // active section. + // if no string is given, exit the last + // active section. const std::string actual_section_name = (section_name == "" ? - active_sections.back () : - section_name); + active_sections.back () : + section_name); sections[actual_section_name].timer.stop(); sections[actual_section_name].total_wall_time += sections[actual_section_name].timer.wall_time(); - // get cpu time. on MPI systems, add - // the local contributions. we could - // do that also in the Timer class - // itself, but we didn't initialize - // the Timers here according to that + // get cpu time. on MPI systems, add + // the local contributions. we could + // do that also in the Timer class + // itself, but we didn't initialize + // the Timers here according to that double cpu_time = sections[actual_section_name].timer(); sections[actual_section_name].total_cpu_time += Utilities::MPI::sum (cpu_time, mpi_communicator); - // in case we have to print out - // something, do that here... + // in case we have to print out + // something, do that here... if (output_frequency != summary && output_is_enabled == true) { std::string output_time; @@ -344,20 +344,20 @@ TimerOutput::leave_subsection (const std::string §ion_name) std::ostringstream wall; wall << sections[actual_section_name].timer.wall_time() << "s"; if (output_type == cpu_times) - output_time = ", CPU time: " + cpu.str(); + output_time = ", CPU time: " + cpu.str(); else if (output_type == wall_times) - output_time = ", wall time: " + wall.str() + "."; + output_time = ", wall time: " + wall.str() + "."; else - output_time = ", CPU/wall time: " + cpu.str() + " / " + wall.str() + "."; + output_time = ", CPU/wall time: " + cpu.str() + " / " + wall.str() + "."; out_stream << actual_section_name << output_time - << std::endl; + << std::endl; } - // delete the index from the list of - // active ones + // delete the index from the list of + // active ones active_sections.erase (std::find (active_sections.begin(), active_sections.end(), - actual_section_name)); + actual_section_name)); } @@ -365,150 +365,150 @@ TimerOutput::leave_subsection (const std::string §ion_name) void TimerOutput::print_summary () const { - // we are going to change the - // precision and width of output - // below. store the old values so we - // can restore it later on + // we are going to change the + // precision and width of output + // below. store the old values so we + // can restore it later on const std::istream::fmtflags old_flags = out_stream.get_stream().flags(); const std::streamsize old_precision = out_stream.get_stream().precision (); const std::streamsize old_width = out_stream.get_stream().width (); - // in case we want to write CPU times + // in case we want to write CPU times if (output_type != wall_times) { double total_cpu_time = Utilities::MPI::sum (timer_all(), - mpi_communicator); + mpi_communicator); - // check that the sum of all times is - // less or equal than the total - // time. otherwise, we might have - // generated a lot of overhead in this - // function. + // check that the sum of all times is + // less or equal than the total + // time. otherwise, we might have + // generated a lot of overhead in this + // function. double check_time = 0.; for (std::map::const_iterator - i = sections.begin(); i!=sections.end(); ++i) - check_time += i->second.total_cpu_time; + i = sections.begin(); i!=sections.end(); ++i) + check_time += i->second.total_cpu_time; if (check_time > total_cpu_time) - total_cpu_time = check_time; + total_cpu_time = check_time; - // generate a nice table + // generate a nice table out_stream << "\n\n" - << "+---------------------------------------------+------------" - << "+------------+\n" - << "| Total CPU time elapsed since start |"; + << "+---------------------------------------------+------------" + << "+------------+\n" + << "| Total CPU time elapsed since start |"; out_stream << std::setw(10) << std::setprecision(3) << std::right; out_stream << total_cpu_time << "s | |\n"; out_stream << "| | " - << "| |\n"; + << "| |\n"; out_stream << "| Section | no. calls |"; out_stream << std::setw(10); out_stream << std::setprecision(3); out_stream << " CPU time " << " | % of total |\n"; out_stream << "+---------------------------------+-----------+------------" - << "+------------+"; + << "+------------+"; for (std::map::const_iterator - i = sections.begin(); i!=sections.end(); ++i) - { - std::string name_out = i->first; - - // resize the array so that it is always - // of the same size - unsigned int pos_non_space = name_out.find_first_not_of (" "); - name_out.erase(0, pos_non_space); - name_out.resize (32, ' '); - out_stream << std::endl; - out_stream << "| " << name_out; - out_stream << "| "; - out_stream << std::setw(9); - out_stream << i->second.n_calls << " |"; - out_stream << std::setw(10); - out_stream << std::setprecision(3); - out_stream << i->second.total_cpu_time << "s |"; - out_stream << std::setw(10); - out_stream << std::setprecision(2); - out_stream << i->second.total_cpu_time/total_cpu_time * 100 << "% |"; - } + i = sections.begin(); i!=sections.end(); ++i) + { + std::string name_out = i->first; + + // resize the array so that it is always + // of the same size + unsigned int pos_non_space = name_out.find_first_not_of (" "); + name_out.erase(0, pos_non_space); + name_out.resize (32, ' '); + out_stream << std::endl; + out_stream << "| " << name_out; + out_stream << "| "; + out_stream << std::setw(9); + out_stream << i->second.n_calls << " |"; + out_stream << std::setw(10); + out_stream << std::setprecision(3); + out_stream << i->second.total_cpu_time << "s |"; + out_stream << std::setw(10); + out_stream << std::setprecision(2); + out_stream << i->second.total_cpu_time/total_cpu_time * 100 << "% |"; + } out_stream << std::endl - << "+---------------------------------+-----------+" - << "------------+------------+\n" - << std::endl; + << "+---------------------------------+-----------+" + << "------------+------------+\n" + << std::endl; if (check_time > total_cpu_time) - out_stream << std::endl - << "Note: The sum of counted times is larger than the total time.\n" - << "(Timer function may have introduced too much overhead, or different\n" - << "section timers may have run at the same time.)" << std::endl; + out_stream << std::endl + << "Note: The sum of counted times is larger than the total time.\n" + << "(Timer function may have introduced too much overhead, or different\n" + << "section timers may have run at the same time.)" << std::endl; } - // in case we want to write out wallclock times + // in case we want to write out wallclock times if (output_type != cpu_times) { double total_wall_time = timer_all.wall_time(); - // check that the sum of all times is - // less or equal than the total - // time. otherwise, we might have - // generated a lot of overhead in this - // function. + // check that the sum of all times is + // less or equal than the total + // time. otherwise, we might have + // generated a lot of overhead in this + // function. double check_time = 0.; for (std::map::const_iterator - i = sections.begin(); i!=sections.end(); ++i) - check_time += i->second.total_wall_time; + i = sections.begin(); i!=sections.end(); ++i) + check_time += i->second.total_wall_time; if (check_time > total_wall_time) - total_wall_time = check_time; + total_wall_time = check_time; - // now generate a nice table + // now generate a nice table out_stream << "\n\n" - << "+---------------------------------------------+------------" - << "+------------+\n" - << "| Total wallclock time elapsed since start |"; + << "+---------------------------------------------+------------" + << "+------------+\n" + << "| Total wallclock time elapsed since start |"; out_stream << std::setw(10) << std::setprecision(3) << std::right; out_stream << total_wall_time << "s | |\n"; out_stream << "| | " - << "| |\n"; + << "| |\n"; out_stream << "| Section | no. calls |"; out_stream << std::setw(10); out_stream << std::setprecision(3); out_stream << " wall time | % of total |\n"; out_stream << "+---------------------------------+-----------+------------" - << "+------------+"; + << "+------------+"; for (std::map::const_iterator - i = sections.begin(); i!=sections.end(); ++i) - { - std::string name_out = i->first; - - // resize the array so that it is always - // of the same size - unsigned int pos_non_space = name_out.find_first_not_of (" "); - name_out.erase(0, pos_non_space); - name_out.resize (32, ' '); - out_stream << std::endl; - out_stream << "| " << name_out; - out_stream << "| "; - out_stream << std::setw(9); - out_stream << i->second.n_calls << " |"; - out_stream << std::setw(10); - out_stream << std::setprecision(3); - out_stream << i->second.total_wall_time << "s |"; - out_stream << std::setw(10); - out_stream << std::setprecision(2); - out_stream << i->second.total_wall_time/total_wall_time * 100 << "% |"; - } + i = sections.begin(); i!=sections.end(); ++i) + { + std::string name_out = i->first; + + // resize the array so that it is always + // of the same size + unsigned int pos_non_space = name_out.find_first_not_of (" "); + name_out.erase(0, pos_non_space); + name_out.resize (32, ' '); + out_stream << std::endl; + out_stream << "| " << name_out; + out_stream << "| "; + out_stream << std::setw(9); + out_stream << i->second.n_calls << " |"; + out_stream << std::setw(10); + out_stream << std::setprecision(3); + out_stream << i->second.total_wall_time << "s |"; + out_stream << std::setw(10); + out_stream << std::setprecision(2); + out_stream << i->second.total_wall_time/total_wall_time * 100 << "% |"; + } out_stream << std::endl - << "+---------------------------------+-----------+" - << "------------+------------+\n" - << std::endl; + << "+---------------------------------+-----------+" + << "------------+------------+\n" + << std::endl; if (check_time > total_wall_time) - out_stream << std::endl - << "Note: The sum of counted times is larger than the total time.\n" - << "(Timer function may have introduced too much overhead, or different\n" - << "section timers may have run at the same time.)" << std::endl; + out_stream << std::endl + << "Note: The sum of counted times is larger than the total time.\n" + << "(Timer function may have introduced too much overhead, or different\n" + << "section timers may have run at the same time.)" << std::endl; } - // restore previous precision and width + // restore previous precision and width out_stream.get_stream().precision (old_precision); out_stream.get_stream().width (old_width); out_stream.get_stream().flags (old_flags); diff --git a/deal.II/source/base/utilities.cc b/deal.II/source/base/utilities.cc index 301246ca04..1804d87e8f 100644 --- a/deal.II/source/base/utilities.cc +++ b/deal.II/source/base/utilities.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2005, 2006, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 2005, 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -56,54 +56,54 @@ namespace Utilities DeclException2 (ExcInvalidNumber2StringConversersion, - unsigned int, unsigned int, - << "When trying to convert " << arg1 - << " to a string with " << arg2 << " digits"); + unsigned int, unsigned int, + << "When trying to convert " << arg1 + << " to a string with " << arg2 << " digits"); DeclException1 (ExcInvalidNumber, - unsigned int, - << "Invalid number " << arg1); + unsigned int, + << "Invalid number " << arg1); DeclException1 (ExcCantConvertString, - std::string, - << "Can't convert the string " << arg1 + std::string, + << "Can't convert the string " << arg1 << " to the desired type"); std::string int_to_string (const unsigned int i, - const unsigned int digits) + const unsigned int digits) { - // if second argument is invalid, then do - // not pad the resulting string at all + // if second argument is invalid, then do + // not pad the resulting string at all if (digits == numbers::invalid_unsigned_int) return int_to_string (i, needed_digits(i)); AssertThrow ( ! ((digits==1 && i>=10) || - (digits==2 && i>=100) || - (digits==3 && i>=1000) || - (digits==4 && i>=10000)|| - (digits==5 && i>=100000)|| - (i>=1000000)), - ExcInvalidNumber2StringConversersion(i, digits)); + (digits==2 && i>=100) || + (digits==3 && i>=1000) || + (digits==4 && i>=10000)|| + (digits==5 && i>=100000)|| + (i>=1000000)), + ExcInvalidNumber2StringConversersion(i, digits)); std::string s; switch (digits) { - case 6: - s += '0' + i/100000; - case 5: - s += '0' + (i%100000)/10000; - case 4: - s += '0' + (i%10000)/1000; - case 3: - s += '0' + (i%1000)/100; - case 2: - s += '0' + (i%100)/10; - case 1: - s += '0' + i%10; - break; - default: - s += "invalid digits information"; + case 6: + s += '0' + i/100000; + case 5: + s += '0' + (i%100000)/10000; + case 4: + s += '0' + (i%10000)/1000; + case 3: + s += '0' + (i%1000)/100; + case 2: + s += '0' + (i%100)/10; + case 1: + s += '0' + i%10; + break; + default: + s += "invalid digits information"; }; return s; } @@ -214,28 +214,28 @@ namespace Utilities std::vector split_list; split_list.reserve (std::count (tmp.begin(), tmp.end(), delimiter)+1); - // split the input list + // split the input list while (tmp.length() != 0) { std::string name; - name = tmp; + name = tmp; - if (name.find(delimiter) != std::string::npos) - { - name.erase (name.find(delimiter), std::string::npos); - tmp.erase (0, tmp.find(delimiter)+1); - } - else - tmp = ""; + if (name.find(delimiter) != std::string::npos) + { + name.erase (name.find(delimiter), std::string::npos); + tmp.erase (0, tmp.find(delimiter)+1); + } + else + tmp = ""; - while ((name.length() != 0) && - (name[0] == ' ')) - name.erase (0,1); + while ((name.length() != 0) && + (name[0] == ' ')) + name.erase (0,1); - while (name[name.length()-1] == ' ') - name.erase (name.length()-1, 1); + while (name[name.length()-1] == ' ') + name.erase (name.length()-1, 1); - split_list.push_back (name); + split_list.push_back (name); } return split_list; @@ -263,25 +263,25 @@ namespace Utilities while ((text.length() != 0) && (text[0] == delimiter)) text.erase(0, 1); - std::size_t pos_newline = text.find_first_of("\n", 0); - if (pos_newline != std::string::npos && pos_newline <= width) - { - std::string line (text, 0, pos_newline); - while ((line.length() != 0) && (line[line.length()-1] == delimiter)) - line.erase(line.length()-1,1); - lines.push_back (line); + std::size_t pos_newline = text.find_first_of("\n", 0); + if (pos_newline != std::string::npos && pos_newline <= width) + { + std::string line (text, 0, pos_newline); + while ((line.length() != 0) && (line[line.length()-1] == delimiter)) + line.erase(line.length()-1,1); + lines.push_back (line); text.erase (0, pos_newline+1); - continue; - } - + continue; + } + // if we can fit everything into one // line, then do so. otherwise, we have // to keep breaking if (text.length() < width) { - // remove trailing spaces - while ((text.length() != 0) && (text[text.length()-1] == delimiter)) - text.erase(text.length()-1,1); + // remove trailing spaces + while ((text.length() != 0) && (text[text.length()-1] == delimiter)) + text.erase(text.length()-1,1); lines.push_back (text); text = ""; } @@ -307,9 +307,9 @@ namespace Utilities // now take the text up to the found // location and put it into a single // line, and remove it from 'text' - std::string line (text, 0, location); - while ((line.length() != 0) && (line[line.length()-1] == delimiter)) - line.erase(line.length()-1,1); + std::string line (text, 0, location); + while ((line.length() != 0) && (line[line.length()-1] == delimiter)) + line.erase(line.length()-1,1); lines.push_back (line); text.erase (0, location); } @@ -322,14 +322,14 @@ namespace Utilities bool match_at_string_start (const std::string &name, - const std::string &pattern) + const std::string &pattern) { if (pattern.size() > name.size()) return false; for (unsigned int i=0; i get_integer_at_position (const std::string &name, - const unsigned int position) + const unsigned int position) { Assert (position < name.size(), ExcInternalError()); const std::string test_string (name.begin()+position, - name.end()); + name.end()); std::istringstream str(test_string); int i; if (str >> i) { - // compute the number of - // digits of i. assuming it - // is less than 8 is likely - // ok - if (i<10) - return std::make_pair (i, 1U); - else if (i<100) - return std::make_pair (i, 2U); - else if (i<1000) - return std::make_pair (i, 3U); - else if (i<10000) - return std::make_pair (i, 4U); - else if (i<100000) - return std::make_pair (i, 5U); - else if (i<1000000) - return std::make_pair (i, 6U); - else if (i<10000000) - return std::make_pair (i, 7U); - else - { - Assert (false, ExcNotImplemented()); - return std::make_pair (-1, numbers::invalid_unsigned_int); - } + // compute the number of + // digits of i. assuming it + // is less than 8 is likely + // ok + if (i<10) + return std::make_pair (i, 1U); + else if (i<100) + return std::make_pair (i, 2U); + else if (i<1000) + return std::make_pair (i, 3U); + else if (i<10000) + return std::make_pair (i, 4U); + else if (i<100000) + return std::make_pair (i, 5U); + else if (i<1000000) + return std::make_pair (i, 6U); + else if (i<10000000) + return std::make_pair (i, 7U); + else + { + Assert (false, ExcNotImplemented()); + return std::make_pair (-1, numbers::invalid_unsigned_int); + } } else return std::make_pair (-1, numbers::invalid_unsigned_int); @@ -382,9 +382,9 @@ namespace Utilities double generate_normal_random_number (const double a, - const double sigma) + const double sigma) { - // if no noise: return now + // if no noise: return now if (sigma == 0) return a; @@ -395,25 +395,25 @@ namespace Utilities const double y = 1.0*rand()/RAND_MAX; #endif - // find x such that y=erf(x). do so - // using a Newton method to find - // the zero of F(x)=erf(x)-y. start - // at x=0 + // find x such that y=erf(x). do so + // using a Newton method to find + // the zero of F(x)=erf(x)-y. start + // at x=0 double x = 0; unsigned int iteration = 0; while (true) { - const double residual = 0.5+erf(x/std::sqrt(2.)/sigma)/2-y; - if (std::fabs(residual) < 1e-7) - break; - const double F_prime = 1./std::sqrt(2*3.1415926536)/sigma * - std::exp(-x*x/sigma/sigma/2); - x += -residual / F_prime; - - // make sure that we don't - // recurse endlessly - ++iteration; - Assert (iteration < 20, ExcInternalError()); + const double residual = 0.5+erf(x/std::sqrt(2.)/sigma)/2-y; + if (std::fabs(residual) < 1e-7) + break; + const double F_prime = 1./std::sqrt(2*3.1415926536)/sigma * + std::exp(-x*x/sigma/sigma/2); + x += -residual / F_prime; + + // make sure that we don't + // recurse endlessly + ++iteration; + Assert (iteration < 20, ExcInternalError()); }; return x+a; } @@ -443,15 +443,15 @@ namespace Utilities for (unsigned int i=0; i> name; - if (name == "VmPeak:") - file >> stats.VmPeak; - else if (name == "VmSize:") - file >> stats.VmSize; - else if (name == "VmHWM:") - file >> stats.VmHWM; - else if (name == "VmRSS:") - { - file >> stats.VmRSS; - break; //this is always the last entry - } - - getline(file, line); - } + { + file >> name; + if (name == "VmPeak:") + file >> stats.VmPeak; + else if (name == "VmSize:") + file >> stats.VmSize; + else if (name == "VmHWM:") + file >> stats.VmHWM; + else if (name == "VmRSS:") + { + file >> stats.VmRSS; + break; //this is always the last entry + } + + getline(file, line); + } #endif } @@ -576,11 +576,11 @@ namespace Utilities void calculate_collective_mpi_min_max_avg(const MPI_Comm &mpi_communicator, - double my_value, - MinMaxAvg & result) + double my_value, + MinMaxAvg & result) { result = Utilities::MPI::min_max_avg (my_value, - mpi_communicator); + mpi_communicator); } @@ -596,10 +596,10 @@ namespace Utilities { #ifdef DEAL_II_COMPILER_SUPPORTS_MPI static Teuchos::RCP - communicator = Teuchos::rcp (new Epetra_MpiComm (MPI_COMM_WORLD), true); + communicator = Teuchos::rcp (new Epetra_MpiComm (MPI_COMM_WORLD), true); #else static Teuchos::RCP - communicator = Teuchos::rcp (new Epetra_SerialComm (), true); + communicator = Teuchos::rcp (new Epetra_SerialComm (), true); #endif return *communicator; @@ -612,10 +612,10 @@ namespace Utilities { #ifdef DEAL_II_COMPILER_SUPPORTS_MPI static Teuchos::RCP - communicator = Teuchos::rcp (new Epetra_MpiComm (MPI_COMM_SELF), true); + communicator = Teuchos::rcp (new Epetra_MpiComm (MPI_COMM_SELF), true); #else static Teuchos::RCP - communicator = Teuchos::rcp (new Epetra_SerialComm (), true); + communicator = Teuchos::rcp (new Epetra_SerialComm (), true); #endif return *communicator; @@ -628,23 +628,23 @@ namespace Utilities { #ifdef DEAL_II_COMPILER_SUPPORTS_MPI - // see if the communicator is in fact a - // parallel MPI communicator; if so, - // return a duplicate of it + // see if the communicator is in fact a + // parallel MPI communicator; if so, + // return a duplicate of it const Epetra_MpiComm - *mpi_comm = dynamic_cast(&communicator); + *mpi_comm = dynamic_cast(&communicator); if (mpi_comm != 0) - return new Epetra_MpiComm(Utilities::System:: - duplicate_communicator(mpi_comm->GetMpiComm())); + return new Epetra_MpiComm(Utilities::System:: + duplicate_communicator(mpi_comm->GetMpiComm())); #endif - // if we don't support MPI, or if the - // communicator in question was in fact - // not an MPI communicator, return a - // copy of the same object again + // if we don't support MPI, or if the + // communicator in question was in fact + // not an MPI communicator, return a + // copy of the same object again Assert (dynamic_cast(&communicator) - != 0, - ExcInternalError()); + != 0, + ExcInternalError()); return new Epetra_SerialComm(dynamic_cast(communicator)); } @@ -654,20 +654,20 @@ namespace Utilities { Assert (&communicator != 0, ExcInternalError()); - // save the communicator, reset - // the map, and delete the - // communicator if this whole - // thing was created as an MPI - // communicator + // save the communicator, reset + // the map, and delete the + // communicator if this whole + // thing was created as an MPI + // communicator #ifdef DEAL_II_COMPILER_SUPPORTS_MPI Epetra_MpiComm - *mpi_comm = dynamic_cast(&communicator); + *mpi_comm = dynamic_cast(&communicator); if (mpi_comm != 0) - { - MPI_Comm comm = mpi_comm->GetMpiComm(); - *mpi_comm = Epetra_MpiComm(MPI_COMM_SELF); - MPI_Comm_free (&comm); - } + { + MPI_Comm comm = mpi_comm->GetMpiComm(); + *mpi_comm = Epetra_MpiComm(MPI_COMM_SELF); + MPI_Comm_free (&comm); + } #endif } @@ -688,30 +688,30 @@ namespace Utilities Epetra_Map duplicate_map (const Epetra_BlockMap &map, - const Epetra_Comm &comm) + const Epetra_Comm &comm) { if (map.LinearMap() == true) - { - // each processor stores a - // contiguous range of - // elements in the - // following constructor - // call - return Epetra_Map (map.NumGlobalElements(), - map.NumMyElements(), - map.IndexBase(), - comm); - } + { + // each processor stores a + // contiguous range of + // elements in the + // following constructor + // call + return Epetra_Map (map.NumGlobalElements(), + map.NumMyElements(), + map.IndexBase(), + comm); + } else - { - // the range is not - // contiguous - return Epetra_Map (map.NumGlobalElements(), - map.NumMyElements(), - map.MyGlobalElements (), - 0, - comm); - } + { + // the range is not + // contiguous + return Epetra_Map (map.NumGlobalElements(), + map.NumMyElements(), + map.MyGlobalElements (), + 0, + comm); + } } } diff --git a/deal.II/source/distributed/grid_refinement.cc b/deal.II/source/distributed/grid_refinement.cc index 0210f0c34d..c56f8007dc 100644 --- a/deal.II/source/distributed/grid_refinement.cc +++ b/deal.II/source/distributed/grid_refinement.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -46,10 +46,10 @@ namespace max_element (const Vector &criteria) { return (criteria.size()>0) - ? - (*std::max_element(criteria.begin(), criteria.end())) - : - std::numeric_limits::min(); + ? + (*std::max_element(criteria.begin(), criteria.end())) + : + std::numeric_limits::min(); } @@ -60,80 +60,80 @@ namespace min_element (const Vector &criteria) { return (criteria.size()>0) - ? - (*std::min_element(criteria.begin(), criteria.end())) - : - std::numeric_limits::max(); + ? + (*std::min_element(criteria.begin(), criteria.end())) + : + std::numeric_limits::max(); } - /** - * Compute the global max and min - * of the criteria vector. These - * are returned only on the - * processor with rank zero, all - * others get a pair of zeros. - */ + /** + * Compute the global max and min + * of the criteria vector. These + * are returned only on the + * processor with rank zero, all + * others get a pair of zeros. + */ template std::pair compute_global_min_and_max_at_root (const Vector &criteria, - MPI_Comm mpi_communicator) + MPI_Comm mpi_communicator) { - // we'd like to compute the - // global max and min from the - // local ones in one MPI - // communication. we can do that - // by taking the elementwise - // minimum of the local min and - // the negative maximum over all - // processors + // we'd like to compute the + // global max and min from the + // local ones in one MPI + // communication. we can do that + // by taking the elementwise + // minimum of the local min and + // the negative maximum over all + // processors const double local_min = min_element (criteria), - local_max = max_element (criteria); + local_max = max_element (criteria); double comp[2] = { local_min, -local_max }; double result[2] = { 0, 0 }; - // compute the minimum on - // processor zero + // compute the minimum on + // processor zero MPI_Reduce (&comp, &result, 2, MPI_DOUBLE, - MPI_MIN, 0, mpi_communicator); + MPI_MIN, 0, mpi_communicator); - // make sure only processor zero - // got something + // make sure only processor zero + // got something if (Utilities::MPI::this_mpi_process (mpi_communicator) != 0) Assert ((result[0] == 0) && (result[1] == 0), - ExcInternalError()); + ExcInternalError()); return std::make_pair (result[0], -result[1]); } - /** - * Compute the global sum over the elements - * of the vectors passed to this function - * on all processors. This number is - * returned only on the processor with rank - * zero, all others get zero. - */ + /** + * Compute the global sum over the elements + * of the vectors passed to this function + * on all processors. This number is + * returned only on the processor with rank + * zero, all others get zero. + */ template double compute_global_sum (const Vector &criteria, - MPI_Comm mpi_communicator) + MPI_Comm mpi_communicator) { double my_sum = std::accumulate (criteria.begin(), - criteria.end(), - /* do accumulation in the correct data type: */ - number()); + criteria.end(), + /* do accumulation in the correct data type: */ + number()); double result = 0; - // compute the minimum on - // processor zero + // compute the minimum on + // processor zero MPI_Reduce (&my_sum, &result, 1, MPI_DOUBLE, - MPI_SUM, 0, mpi_communicator); + MPI_SUM, 0, mpi_communicator); - // make sure only processor zero - // got something + // make sure only processor zero + // got something if (Utilities::MPI::this_mpi_process (mpi_communicator) != 0) Assert (result == 0, ExcInternalError()); @@ -142,105 +142,105 @@ namespace - /** - * Given a vector of refinement criteria - * for all cells of a mesh (locally owned - * or not), extract those that pertain to - * locally owned cells. - */ + /** + * Given a vector of refinement criteria + * for all cells of a mesh (locally owned + * or not), extract those that pertain to + * locally owned cells. + */ template void get_locally_owned_indicators (const parallel::distributed::Triangulation &tria, - const Vector &criteria, - dealii::Vector &locally_owned_indicators) + const Vector &criteria, + dealii::Vector &locally_owned_indicators) { Assert (locally_owned_indicators.size() == tria.n_locally_owned_active_cells(), - ExcInternalError()); + ExcInternalError()); unsigned int active_index = 0; unsigned int owned_index = 0; for (typename Triangulation::active_cell_iterator - cell = tria.begin_active(); - cell != tria.end(); ++cell, ++active_index) + cell = tria.begin_active(); + cell != tria.end(); ++cell, ++active_index) if (cell->subdomain_id() == tria.locally_owned_subdomain()) - { - locally_owned_indicators(owned_index) - = criteria(active_index); - ++owned_index; - } + { + locally_owned_indicators(owned_index) + = criteria(active_index); + ++owned_index; + } Assert (owned_index == tria.n_locally_owned_active_cells(), - ExcInternalError()); + ExcInternalError()); Assert ((active_index == tria.dealii::Triangulation::n_active_cells()), - ExcInternalError()); + ExcInternalError()); } - // we compute refinement - // thresholds by bisection of the - // interval spanned by the - // smallest and largest error - // indicator. this leads to a - // small problem: if, for - // example, we want to coarsen - // zero per cent of the cells, - // then we need to pick a - // threshold equal to the - // smallest indicator, but of - // course the bisection algorithm - // can never find a threshold - // equal to one of the end points - // of the interval. So we - // slightly increase the interval - // before we even start + // we compute refinement + // thresholds by bisection of the + // interval spanned by the + // smallest and largest error + // indicator. this leads to a + // small problem: if, for + // example, we want to coarsen + // zero per cent of the cells, + // then we need to pick a + // threshold equal to the + // smallest indicator, but of + // course the bisection algorithm + // can never find a threshold + // equal to one of the end points + // of the interval. So we + // slightly increase the interval + // before we even start void adjust_interesting_range (double (&interesting_range)[2]) { Assert (interesting_range[0] <= interesting_range[1], - ExcInternalError()); + ExcInternalError()); if (interesting_range[0] > 0) interesting_range[0] *= 0.99; else interesting_range[0] - -= 0.01 * (interesting_range[1] - interesting_range[0]); + -= 0.01 * (interesting_range[1] - interesting_range[0]); if (interesting_range[1] > 0) interesting_range[1] *= 1.01; else interesting_range[1] - += 0.01 * (interesting_range[1] - interesting_range[0]); + += 0.01 * (interesting_range[1] - interesting_range[0]); } - /** - * Given a vector of criteria and bottom - * and top thresholds for coarsening and - * refinement, mark all those cells that we - * locally own as appropriate for - * coarsening or refinement. - */ + /** + * Given a vector of criteria and bottom + * and top thresholds for coarsening and + * refinement, mark all those cells that we + * locally own as appropriate for + * coarsening or refinement. + */ template void mark_cells (parallel::distributed::Triangulation &tria, - const Vector &criteria, - const double top_threshold, - const double bottom_threshold) + const Vector &criteria, + const double top_threshold, + const double bottom_threshold) { dealii::GridRefinement::refine (tria, criteria, top_threshold); dealii::GridRefinement::coarsen (tria, criteria, bottom_threshold); - // as a final good measure, - // delete all flags again - // from cells that we don't - // locally own + // as a final good measure, + // delete all flags again + // from cells that we don't + // locally own for (typename Triangulation::active_cell_iterator - cell = tria.begin_active(); - cell != tria.end(); ++cell) + cell = tria.begin_active(); + cell != tria.end(); ++cell) if (cell->subdomain_id() != tria.locally_owned_subdomain()) - { - cell->clear_refine_flag (); - cell->clear_coarsen_flag (); - } + { + cell->clear_refine_flag (); + cell->clear_coarsen_flag (); + } } @@ -248,96 +248,96 @@ namespace namespace RefineAndCoarsenFixedNumber { - /** - * Compute a threshold value so - * that exactly n_target_cells have - * a value that is larger. - */ + /** + * Compute a threshold value so + * that exactly n_target_cells have + * a value that is larger. + */ template number master_compute_threshold (const Vector &criteria, - const std::pair global_min_and_max, - const unsigned int n_target_cells, - MPI_Comm mpi_communicator) + const std::pair global_min_and_max, + const unsigned int n_target_cells, + MPI_Comm mpi_communicator) { double interesting_range[2] = { global_min_and_max.first, - global_min_and_max.second }; + global_min_and_max.second }; adjust_interesting_range (interesting_range); unsigned int iteration = 0; do - { - MPI_Bcast (&interesting_range[0], 2, MPI_DOUBLE, - 0, mpi_communicator); - - if (interesting_range[0] == interesting_range[1]) - return interesting_range[0]; - - const double test_threshold - = (interesting_range[0] > 0 - ? - std::sqrt(interesting_range[0] * - interesting_range[1]) - : - (interesting_range[0] + interesting_range[1]) / 2); - - // count how many of our own - // elements would be above - // this threshold and then - // add to it the number for - // all the others - unsigned int - my_count = std::count_if (criteria.begin(), - criteria.end(), - std::bind2nd (std::greater(), - test_threshold)); - - unsigned int total_count; - MPI_Reduce (&my_count, &total_count, 1, MPI_UNSIGNED, - MPI_SUM, 0, mpi_communicator); - - // now adjust the range. if - // we have to many cells, we - // take the upper half of the - // previous range, otherwise - // the lower half. if we have - // hit the right number, then - // set the range to the exact - // value - if (total_count > n_target_cells) - interesting_range[0] = test_threshold; - else if (total_count < n_target_cells) - interesting_range[1] = test_threshold; - else - interesting_range[0] = interesting_range[1] = test_threshold; - - // terminate the iteration - // after 10 go-arounds. this - // is necessary because - // oftentimes error - // indicators on cells have - // exactly the same value, - // and so there may not be a - // particular value that cuts - // the indicators in such a - // way that we can achieve - // the desired number of - // cells. using a max of 10 - // iterations means that we - // terminate the iteration - // after 10 steps if the - // indicators were perfectly - // badly distributed, and we - // make at most a mistake of - // 1/2^10 in the number of - // cells flagged if - // indicators are perfectly - // equidistributed - ++iteration; - if (iteration == 25) - interesting_range[0] = interesting_range[1] = test_threshold; - } + { + MPI_Bcast (&interesting_range[0], 2, MPI_DOUBLE, + 0, mpi_communicator); + + if (interesting_range[0] == interesting_range[1]) + return interesting_range[0]; + + const double test_threshold + = (interesting_range[0] > 0 + ? + std::sqrt(interesting_range[0] * + interesting_range[1]) + : + (interesting_range[0] + interesting_range[1]) / 2); + + // count how many of our own + // elements would be above + // this threshold and then + // add to it the number for + // all the others + unsigned int + my_count = std::count_if (criteria.begin(), + criteria.end(), + std::bind2nd (std::greater(), + test_threshold)); + + unsigned int total_count; + MPI_Reduce (&my_count, &total_count, 1, MPI_UNSIGNED, + MPI_SUM, 0, mpi_communicator); + + // now adjust the range. if + // we have to many cells, we + // take the upper half of the + // previous range, otherwise + // the lower half. if we have + // hit the right number, then + // set the range to the exact + // value + if (total_count > n_target_cells) + interesting_range[0] = test_threshold; + else if (total_count < n_target_cells) + interesting_range[1] = test_threshold; + else + interesting_range[0] = interesting_range[1] = test_threshold; + + // terminate the iteration + // after 10 go-arounds. this + // is necessary because + // oftentimes error + // indicators on cells have + // exactly the same value, + // and so there may not be a + // particular value that cuts + // the indicators in such a + // way that we can achieve + // the desired number of + // cells. using a max of 10 + // iterations means that we + // terminate the iteration + // after 10 steps if the + // indicators were perfectly + // badly distributed, and we + // make at most a mistake of + // 1/2^10 in the number of + // cells flagged if + // indicators are perfectly + // equidistributed + ++iteration; + if (iteration == 25) + interesting_range[0] = interesting_range[1] = test_threshold; + } while (true); Assert (false, ExcInternalError()); @@ -345,45 +345,45 @@ namespace } - /** - * The corresponding function to - * the one above, to be run on the - * slaves. - */ + /** + * The corresponding function to + * the one above, to be run on the + * slaves. + */ template number slave_compute_threshold (const Vector &criteria, - MPI_Comm mpi_communicator) + MPI_Comm mpi_communicator) { do - { - double interesting_range[2] = { -1, -1 }; - MPI_Bcast (&interesting_range[0], 2, MPI_DOUBLE, - 0, mpi_communicator); - - if (interesting_range[0] == interesting_range[1]) - return interesting_range[0]; - - // count how many elements - // there are that are bigger - // than the following trial - // threshold - const double test_threshold - = (interesting_range[0] > 0 - ? - std::exp((std::log(interesting_range[0]) + - std::log(interesting_range[1])) / 2) - : - (interesting_range[0] + interesting_range[1]) / 2); - unsigned int - my_count = std::count_if (criteria.begin(), - criteria.end(), - std::bind2nd (std::greater(), - test_threshold)); - - MPI_Reduce (&my_count, 0, 1, MPI_UNSIGNED, - MPI_SUM, 0, mpi_communicator); - } + { + double interesting_range[2] = { -1, -1 }; + MPI_Bcast (&interesting_range[0], 2, MPI_DOUBLE, + 0, mpi_communicator); + + if (interesting_range[0] == interesting_range[1]) + return interesting_range[0]; + + // count how many elements + // there are that are bigger + // than the following trial + // threshold + const double test_threshold + = (interesting_range[0] > 0 + ? + std::exp((std::log(interesting_range[0]) + + std::log(interesting_range[1])) / 2) + : + (interesting_range[0] + interesting_range[1]) / 2); + unsigned int + my_count = std::count_if (criteria.begin(), + criteria.end(), + std::bind2nd (std::greater(), + test_threshold)); + + MPI_Reduce (&my_count, 0, 1, MPI_UNSIGNED, + MPI_SUM, 0, mpi_communicator); + } while (true); Assert (false, ExcInternalError()); @@ -395,94 +395,94 @@ namespace namespace RefineAndCoarsenFixedFraction { - /** - * Compute a threshold value so - * that exactly n_target_cells have - * a value that is larger. - */ + /** + * Compute a threshold value so + * that exactly n_target_cells have + * a value that is larger. + */ template number master_compute_threshold (const Vector &criteria, - const std::pair global_min_and_max, - const double target_error, - MPI_Comm mpi_communicator) + const std::pair global_min_and_max, + const double target_error, + MPI_Comm mpi_communicator) { double interesting_range[2] = { global_min_and_max.first, - global_min_and_max.second }; + global_min_and_max.second }; adjust_interesting_range (interesting_range); unsigned int iteration = 0; do - { - MPI_Bcast (&interesting_range[0], 2, MPI_DOUBLE, - 0, mpi_communicator); - - if (interesting_range[0] == interesting_range[1]) - return interesting_range[0]; - - const double test_threshold - = (interesting_range[0] > 0 - ? - std::exp((std::log(interesting_range[0]) + - std::log(interesting_range[1])) / 2) - : - (interesting_range[0] + interesting_range[1]) / 2); - - // accumulate the error of those - // our own elements above this - // threshold and then add to it the - // number for all the others - double my_error = 0; - for (unsigned int i=0; i test_threshold) - my_error += criteria(i); - - double total_error; - MPI_Reduce (&my_error, &total_error, 1, MPI_DOUBLE, - MPI_SUM, 0, mpi_communicator); - - // now adjust the range. if - // we have to many cells, we - // take the upper half of the - // previous range, otherwise - // the lower half. if we have - // hit the right number, then - // set the range to the exact - // value - if (total_error > target_error) - interesting_range[0] = test_threshold; - else if (total_error < target_error) - interesting_range[1] = test_threshold; - else - interesting_range[0] = interesting_range[1] = test_threshold; - - // terminate the iteration - // after 10 go-arounds. this - // is necessary because - // oftentimes error - // indicators on cells have - // exactly the same value, - // and so there may not be a - // particular value that cuts - // the indicators in such a - // way that we can achieve - // the desired number of - // cells. using a max of 10 - // iterations means that we - // terminate the iteration - // after 10 steps if the - // indicators were perfectly - // badly distributed, and we - // make at most a mistake of - // 1/2^10 in the number of - // cells flagged if - // indicators are perfectly - // equidistributed - ++iteration; - if (iteration == 25) - interesting_range[0] = interesting_range[1] = test_threshold; - } + { + MPI_Bcast (&interesting_range[0], 2, MPI_DOUBLE, + 0, mpi_communicator); + + if (interesting_range[0] == interesting_range[1]) + return interesting_range[0]; + + const double test_threshold + = (interesting_range[0] > 0 + ? + std::exp((std::log(interesting_range[0]) + + std::log(interesting_range[1])) / 2) + : + (interesting_range[0] + interesting_range[1]) / 2); + + // accumulate the error of those + // our own elements above this + // threshold and then add to it the + // number for all the others + double my_error = 0; + for (unsigned int i=0; i test_threshold) + my_error += criteria(i); + + double total_error; + MPI_Reduce (&my_error, &total_error, 1, MPI_DOUBLE, + MPI_SUM, 0, mpi_communicator); + + // now adjust the range. if + // we have to many cells, we + // take the upper half of the + // previous range, otherwise + // the lower half. if we have + // hit the right number, then + // set the range to the exact + // value + if (total_error > target_error) + interesting_range[0] = test_threshold; + else if (total_error < target_error) + interesting_range[1] = test_threshold; + else + interesting_range[0] = interesting_range[1] = test_threshold; + + // terminate the iteration + // after 10 go-arounds. this + // is necessary because + // oftentimes error + // indicators on cells have + // exactly the same value, + // and so there may not be a + // particular value that cuts + // the indicators in such a + // way that we can achieve + // the desired number of + // cells. using a max of 10 + // iterations means that we + // terminate the iteration + // after 10 steps if the + // indicators were perfectly + // badly distributed, and we + // make at most a mistake of + // 1/2^10 in the number of + // cells flagged if + // indicators are perfectly + // equidistributed + ++iteration; + if (iteration == 25) + interesting_range[0] = interesting_range[1] = test_threshold; + } while (true); Assert (false, ExcInternalError()); @@ -490,45 +490,45 @@ namespace } - /** - * The corresponding function to - * the one above, to be run on the - * slaves. - */ + /** + * The corresponding function to + * the one above, to be run on the + * slaves. + */ template number slave_compute_threshold (const Vector &criteria, - MPI_Comm mpi_communicator) + MPI_Comm mpi_communicator) { do - { - double interesting_range[2] = { -1, -1 }; - MPI_Bcast (&interesting_range[0], 2, MPI_DOUBLE, - 0, mpi_communicator); - - if (interesting_range[0] == interesting_range[1]) - return interesting_range[0]; - - // count how many elements - // there are that are bigger - // than the following trial - // threshold - const double test_threshold - = (interesting_range[0] > 0 - ? - std::exp((std::log(interesting_range[0]) + - std::log(interesting_range[1])) / 2) - : - (interesting_range[0] + interesting_range[1]) / 2); - - double my_error = 0; - for (unsigned int i=0; i test_threshold) - my_error += criteria(i); - - MPI_Reduce (&my_error, 0, 1, MPI_DOUBLE, - MPI_SUM, 0, mpi_communicator); - } + { + double interesting_range[2] = { -1, -1 }; + MPI_Bcast (&interesting_range[0], 2, MPI_DOUBLE, + 0, mpi_communicator); + + if (interesting_range[0] == interesting_range[1]) + return interesting_range[0]; + + // count how many elements + // there are that are bigger + // than the following trial + // threshold + const double test_threshold + = (interesting_range[0] > 0 + ? + std::exp((std::log(interesting_range[0]) + + std::log(interesting_range[1])) / 2) + : + (interesting_range[0] + interesting_range[1]) / 2); + + double my_error = 0; + for (unsigned int i=0; i test_threshold) + my_error += criteria(i); + + MPI_Reduce (&my_error, 0, 1, MPI_DOUBLE, + MPI_SUM, 0, mpi_communicator); + } while (true); Assert (false, ExcInternalError()); @@ -548,226 +548,226 @@ namespace parallel template void refine_and_coarsen_fixed_number ( - parallel::distributed::Triangulation &tria, - const Vector &criteria, - const double top_fraction_of_cells, - const double bottom_fraction_of_cells) + parallel::distributed::Triangulation &tria, + const Vector &criteria, + const double top_fraction_of_cells, + const double bottom_fraction_of_cells) { - Assert ((top_fraction_of_cells>=0) && (top_fraction_of_cells<=1), - dealii::GridRefinement::ExcInvalidParameterValue()); - Assert ((bottom_fraction_of_cells>=0) && (bottom_fraction_of_cells<=1), - dealii::GridRefinement::ExcInvalidParameterValue()); - Assert (top_fraction_of_cells+bottom_fraction_of_cells <= 1, - dealii::GridRefinement::ExcInvalidParameterValue()); - Assert (criteria.is_non_negative (), - dealii::GridRefinement::ExcNegativeCriteria()); - - // first extract from the - // vector of indicators the - // ones that correspond to - // cells that we locally own - dealii::Vector - locally_owned_indicators (tria.n_locally_owned_active_cells()); - get_locally_owned_indicators (tria, - criteria, - locally_owned_indicators); - - MPI_Comm mpi_communicator = tria.get_communicator (); - - // figure out the global - // max and min of the - // indicators. we don't - // need it here, but it's a - // collective communication - // call - const std::pair global_min_and_max - = compute_global_min_and_max_at_root (locally_owned_indicators, - mpi_communicator); - - // from here on designate a - // master and slaves - double top_threshold, bottom_threshold; - if (Utilities::MPI::this_mpi_process (mpi_communicator) == 0) - { - // this is the master - // processor - top_threshold - = - RefineAndCoarsenFixedNumber:: - master_compute_threshold (locally_owned_indicators, - global_min_and_max, - static_cast - (top_fraction_of_cells * - tria.n_global_active_cells()), - mpi_communicator); - - // compute bottom - // threshold only if - // necessary. otherwise - // use a threshold lower - // than the smallest - // value we have locally - if (bottom_fraction_of_cells > 0) - bottom_threshold - = - RefineAndCoarsenFixedNumber:: - master_compute_threshold (locally_owned_indicators, - global_min_and_max, - static_cast - ((1-bottom_fraction_of_cells) * - tria.n_global_active_cells()), - mpi_communicator); - else - { - bottom_threshold = *std::min_element (criteria.begin(), - criteria.end()); - bottom_threshold -= std::fabs(bottom_threshold); - } - } - else - { - // this is a slave - // processor - top_threshold - = - RefineAndCoarsenFixedNumber:: - slave_compute_threshold (locally_owned_indicators, - mpi_communicator); - // compute bottom - // threshold only if - // necessary - if (bottom_fraction_of_cells > 0) - bottom_threshold - = - RefineAndCoarsenFixedNumber:: - slave_compute_threshold (locally_owned_indicators, - mpi_communicator); - else - { - bottom_threshold = *std::min_element (criteria.begin(), - criteria.end()); - bottom_threshold -= std::fabs(bottom_threshold); - } - } - - // now refine the mesh - mark_cells (tria, criteria, top_threshold, bottom_threshold); + Assert ((top_fraction_of_cells>=0) && (top_fraction_of_cells<=1), + dealii::GridRefinement::ExcInvalidParameterValue()); + Assert ((bottom_fraction_of_cells>=0) && (bottom_fraction_of_cells<=1), + dealii::GridRefinement::ExcInvalidParameterValue()); + Assert (top_fraction_of_cells+bottom_fraction_of_cells <= 1, + dealii::GridRefinement::ExcInvalidParameterValue()); + Assert (criteria.is_non_negative (), + dealii::GridRefinement::ExcNegativeCriteria()); + + // first extract from the + // vector of indicators the + // ones that correspond to + // cells that we locally own + dealii::Vector + locally_owned_indicators (tria.n_locally_owned_active_cells()); + get_locally_owned_indicators (tria, + criteria, + locally_owned_indicators); + + MPI_Comm mpi_communicator = tria.get_communicator (); + + // figure out the global + // max and min of the + // indicators. we don't + // need it here, but it's a + // collective communication + // call + const std::pair global_min_and_max + = compute_global_min_and_max_at_root (locally_owned_indicators, + mpi_communicator); + + // from here on designate a + // master and slaves + double top_threshold, bottom_threshold; + if (Utilities::MPI::this_mpi_process (mpi_communicator) == 0) + { + // this is the master + // processor + top_threshold + = + RefineAndCoarsenFixedNumber:: + master_compute_threshold (locally_owned_indicators, + global_min_and_max, + static_cast + (top_fraction_of_cells * + tria.n_global_active_cells()), + mpi_communicator); + + // compute bottom + // threshold only if + // necessary. otherwise + // use a threshold lower + // than the smallest + // value we have locally + if (bottom_fraction_of_cells > 0) + bottom_threshold + = + RefineAndCoarsenFixedNumber:: + master_compute_threshold (locally_owned_indicators, + global_min_and_max, + static_cast + ((1-bottom_fraction_of_cells) * + tria.n_global_active_cells()), + mpi_communicator); + else + { + bottom_threshold = *std::min_element (criteria.begin(), + criteria.end()); + bottom_threshold -= std::fabs(bottom_threshold); + } + } + else + { + // this is a slave + // processor + top_threshold + = + RefineAndCoarsenFixedNumber:: + slave_compute_threshold (locally_owned_indicators, + mpi_communicator); + // compute bottom + // threshold only if + // necessary + if (bottom_fraction_of_cells > 0) + bottom_threshold + = + RefineAndCoarsenFixedNumber:: + slave_compute_threshold (locally_owned_indicators, + mpi_communicator); + else + { + bottom_threshold = *std::min_element (criteria.begin(), + criteria.end()); + bottom_threshold -= std::fabs(bottom_threshold); + } + } + + // now refine the mesh + mark_cells (tria, criteria, top_threshold, bottom_threshold); } template void refine_and_coarsen_fixed_fraction ( - parallel::distributed::Triangulation &tria, - const Vector &criteria, - const double top_fraction_of_error, - const double bottom_fraction_of_error) + parallel::distributed::Triangulation &tria, + const Vector &criteria, + const double top_fraction_of_error, + const double bottom_fraction_of_error) { - Assert ((top_fraction_of_error>=0) && (top_fraction_of_error<=1), - dealii::GridRefinement::ExcInvalidParameterValue()); - Assert ((bottom_fraction_of_error>=0) && (bottom_fraction_of_error<=1), - dealii::GridRefinement::ExcInvalidParameterValue()); - Assert (top_fraction_of_error+bottom_fraction_of_error <= 1, - dealii::GridRefinement::ExcInvalidParameterValue()); - Assert (criteria.is_non_negative (), - dealii::GridRefinement::ExcNegativeCriteria()); - - // first extract from the - // vector of indicators the - // ones that correspond to - // cells that we locally own - dealii::Vector - locally_owned_indicators (tria.n_locally_owned_active_cells()); - get_locally_owned_indicators (tria, - criteria, - locally_owned_indicators); - - MPI_Comm mpi_communicator = tria.get_communicator (); - - // figure out the global - // max and min of the - // indicators. we don't - // need it here, but it's a - // collective communication - // call - const std::pair global_min_and_max - = compute_global_min_and_max_at_root (locally_owned_indicators, - mpi_communicator); - - const double total_error - = compute_global_sum (locally_owned_indicators, - mpi_communicator); - - // from here on designate a - // master and slaves - double top_threshold, bottom_threshold; - if (Utilities::MPI::this_mpi_process (mpi_communicator) == 0) - { - // this is the master - // processor - top_threshold - = - RefineAndCoarsenFixedFraction:: - master_compute_threshold (locally_owned_indicators, - global_min_and_max, - top_fraction_of_error * - total_error, - mpi_communicator); - - // compute bottom - // threshold only if - // necessary. otherwise - // use a threshold lower - // than the smallest - // value we have locally - if (bottom_fraction_of_error > 0) - bottom_threshold - = - RefineAndCoarsenFixedFraction:: - master_compute_threshold (locally_owned_indicators, - global_min_and_max, - (1-bottom_fraction_of_error) * - total_error, - mpi_communicator); - else - { - bottom_threshold = *std::min_element (criteria.begin(), - criteria.end()); - bottom_threshold -= std::fabs(bottom_threshold); - } - } - else - { - // this is a slave - // processor - top_threshold - = - RefineAndCoarsenFixedFraction:: - slave_compute_threshold (locally_owned_indicators, - mpi_communicator); - - // compute bottom - // threshold only if - // necessary. otherwise - // use a threshold lower - // than the smallest - // value we have locally - if (bottom_fraction_of_error > 0) - bottom_threshold - = - RefineAndCoarsenFixedFraction:: - slave_compute_threshold (locally_owned_indicators, - mpi_communicator); - else - { - bottom_threshold = *std::min_element (criteria.begin(), - criteria.end()); - bottom_threshold -= std::fabs(bottom_threshold); - } - } - - // now refine the mesh - mark_cells (tria, criteria, top_threshold, bottom_threshold); + Assert ((top_fraction_of_error>=0) && (top_fraction_of_error<=1), + dealii::GridRefinement::ExcInvalidParameterValue()); + Assert ((bottom_fraction_of_error>=0) && (bottom_fraction_of_error<=1), + dealii::GridRefinement::ExcInvalidParameterValue()); + Assert (top_fraction_of_error+bottom_fraction_of_error <= 1, + dealii::GridRefinement::ExcInvalidParameterValue()); + Assert (criteria.is_non_negative (), + dealii::GridRefinement::ExcNegativeCriteria()); + + // first extract from the + // vector of indicators the + // ones that correspond to + // cells that we locally own + dealii::Vector + locally_owned_indicators (tria.n_locally_owned_active_cells()); + get_locally_owned_indicators (tria, + criteria, + locally_owned_indicators); + + MPI_Comm mpi_communicator = tria.get_communicator (); + + // figure out the global + // max and min of the + // indicators. we don't + // need it here, but it's a + // collective communication + // call + const std::pair global_min_and_max + = compute_global_min_and_max_at_root (locally_owned_indicators, + mpi_communicator); + + const double total_error + = compute_global_sum (locally_owned_indicators, + mpi_communicator); + + // from here on designate a + // master and slaves + double top_threshold, bottom_threshold; + if (Utilities::MPI::this_mpi_process (mpi_communicator) == 0) + { + // this is the master + // processor + top_threshold + = + RefineAndCoarsenFixedFraction:: + master_compute_threshold (locally_owned_indicators, + global_min_and_max, + top_fraction_of_error * + total_error, + mpi_communicator); + + // compute bottom + // threshold only if + // necessary. otherwise + // use a threshold lower + // than the smallest + // value we have locally + if (bottom_fraction_of_error > 0) + bottom_threshold + = + RefineAndCoarsenFixedFraction:: + master_compute_threshold (locally_owned_indicators, + global_min_and_max, + (1-bottom_fraction_of_error) * + total_error, + mpi_communicator); + else + { + bottom_threshold = *std::min_element (criteria.begin(), + criteria.end()); + bottom_threshold -= std::fabs(bottom_threshold); + } + } + else + { + // this is a slave + // processor + top_threshold + = + RefineAndCoarsenFixedFraction:: + slave_compute_threshold (locally_owned_indicators, + mpi_communicator); + + // compute bottom + // threshold only if + // necessary. otherwise + // use a threshold lower + // than the smallest + // value we have locally + if (bottom_fraction_of_error > 0) + bottom_threshold + = + RefineAndCoarsenFixedFraction:: + slave_compute_threshold (locally_owned_indicators, + mpi_communicator); + else + { + bottom_threshold = *std::min_element (criteria.begin(), + criteria.end()); + bottom_threshold -= std::fabs(bottom_threshold); + } + } + + // now refine the mesh + mark_cells (tria, criteria, top_threshold, bottom_threshold); } } } diff --git a/deal.II/source/distributed/solution_transfer.cc b/deal.II/source/distributed/solution_transfer.cc index fef12dc303..8022f743c3 100644 --- a/deal.II/source/distributed/solution_transfer.cc +++ b/deal.II/source/distributed/solution_transfer.cc @@ -2,7 +2,7 @@ // $Id: solution_transfer.cc 23752 2011-05-30 00:16:00Z bangerth $ // Version: $Name$ // -// Copyright (C) 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -45,30 +45,30 @@ namespace parallel template void compress_vector_insert(VECTOR & vec) { - vec.compress(); + vec.compress(); } #ifdef DEAL_II_USE_TRILINOS void compress_vector_insert(TrilinosWrappers::Vector & vec) { - vec.compress(Insert); + vec.compress(Insert); } void compress_vector_insert(TrilinosWrappers::BlockVector & vec) { - for (unsigned int i=0;i SolutionTransfer::SolutionTransfer(const DH &dof) - : - dof_handler(&dof, typeid(*this).name()) + : + dof_handler(&dof, typeid(*this).name()) {} @@ -109,18 +109,18 @@ namespace parallel //TODO: casting away constness is bad parallel::distributed::Triangulation * tria - = (dynamic_cast*> - (const_cast*> - (&dof_handler->get_tria()))); + = (dynamic_cast*> + (const_cast*> + (&dof_handler->get_tria()))); Assert (tria != 0, ExcInternalError()); offset - = tria->register_data_attach(size, - std_cxx1x::bind(&SolutionTransfer::pack_callback, - this, - std_cxx1x::_1, - std_cxx1x::_2, - std_cxx1x::_3)); + = tria->register_data_attach(size, + std_cxx1x::bind(&SolutionTransfer::pack_callback, + this, + std_cxx1x::_1, + std_cxx1x::_2, + std_cxx1x::_3)); } @@ -140,47 +140,47 @@ namespace parallel template void SolutionTransfer:: - prepare_serialization(const VECTOR &in) - { + prepare_serialization(const VECTOR &in) + { std::vector all_in(1, &in); prepare_serialization(all_in); - } + } - template + template void SolutionTransfer:: - prepare_serialization(const std::vector &all_in) - { - prepare_for_coarsening_and_refinement (all_in); - } + prepare_serialization(const std::vector &all_in) + { + prepare_for_coarsening_and_refinement (all_in); + } template void SolutionTransfer:: - deserialize(VECTOR &in) - { + deserialize(VECTOR &in) + { std::vector all_in(1, &in); deserialize(all_in); - } + } - template + template void SolutionTransfer:: - deserialize(std::vector &all_in) - { - register_data_attach( get_data_size() * all_in.size() ); + deserialize(std::vector &all_in) + { + register_data_attach( get_data_size() * all_in.size() ); - // this makes interpolate() happy - input_vectors.resize(all_in.size()); + // this makes interpolate() happy + input_vectors.resize(all_in.size()); - interpolate(all_in); - } + interpolate(all_in); + } template @@ -189,27 +189,27 @@ namespace parallel interpolate (std::vector &all_out) { Assert(input_vectors.size()==all_out.size(), - ExcDimensionMismatch(input_vectors.size(), all_out.size()) ); + ExcDimensionMismatch(input_vectors.size(), all_out.size()) ); //TODO: casting away constness is bad parallel::distributed::Triangulation * tria - = (dynamic_cast*> - (const_cast*> - (&dof_handler->get_tria()))); + = (dynamic_cast*> + (const_cast*> + (&dof_handler->get_tria()))); Assert (tria != 0, ExcInternalError()); tria->notify_ready_to_unpack(offset, - std_cxx1x::bind(&SolutionTransfer::unpack_callback, - this, - std_cxx1x::_1, - std_cxx1x::_2, - std_cxx1x::_3, - std_cxx1x::ref(all_out))); + std_cxx1x::bind(&SolutionTransfer::unpack_callback, + this, + std_cxx1x::_1, + std_cxx1x::_2, + std_cxx1x::_3, + std_cxx1x::ref(all_out))); for (typename std::vector::iterator it=all_out.begin(); - it !=all_out.end(); - ++it) - compress_vector_insert(*(*it)); + it !=all_out.end(); + ++it) + compress_vector_insert(*(*it)); input_vectors.clear(); } @@ -240,8 +240,8 @@ namespace parallel void SolutionTransfer:: pack_callback(const typename Triangulation::cell_iterator & cell_, - const typename Triangulation::CellStatus /*status*/, - void* data) + const typename Triangulation::CellStatus /*status*/, + void* data) { double *data_store = reinterpret_cast(data); @@ -250,13 +250,13 @@ namespace parallel const unsigned int dofs_per_cell=cell->get_fe().dofs_per_cell; ::dealii::Vector dofvalues(dofs_per_cell); for (typename std::vector::iterator it=input_vectors.begin(); - it !=input_vectors.end(); - ++it) - { - cell->get_interpolated_dof_values(*(*it), dofvalues); - std::memcpy(data_store, &dofvalues(0), sizeof(double)*dofs_per_cell); - data_store += dofs_per_cell; - } + it !=input_vectors.end(); + ++it) + { + cell->get_interpolated_dof_values(*(*it), dofvalues); + std::memcpy(data_store, &dofvalues(0), sizeof(double)*dofs_per_cell); + data_store += dofs_per_cell; + } } @@ -264,25 +264,25 @@ namespace parallel void SolutionTransfer:: unpack_callback(const typename Triangulation::cell_iterator & cell_, - const typename Triangulation::CellStatus /*status*/, - const void* data, - std::vector &all_out) + const typename Triangulation::CellStatus /*status*/, + const void* data, + std::vector &all_out) { typename DH::cell_iterator - cell(&dof_handler->get_tria(), cell_->level(), cell_->index(), dof_handler); + cell(&dof_handler->get_tria(), cell_->level(), cell_->index(), dof_handler); const unsigned int dofs_per_cell=cell->get_fe().dofs_per_cell; ::dealii::Vector dofvalues(dofs_per_cell); const double *data_store = reinterpret_cast(data); for (typename std::vector::iterator it = all_out.begin(); - it != all_out.end(); - ++it) - { - std::memcpy(&dofvalues(0), data_store, sizeof(double)*dofs_per_cell); - cell->set_dof_values_by_interpolation(dofvalues, *(*it)); - data_store += dofs_per_cell; - } + it != all_out.end(); + ++it) + { + std::memcpy(&dofvalues(0), data_store, sizeof(double)*dofs_per_cell); + cell->set_dof_values_by_interpolation(dofvalues, *(*it)); + data_store += dofs_per_cell; + } } diff --git a/deal.II/source/distributed/tria.cc b/deal.II/source/distributed/tria.cc index 6afba8dc1e..a75cad3012 100644 --- a/deal.II/source/distributed/tria.cc +++ b/deal.II/source/distributed/tria.cc @@ -49,262 +49,262 @@ namespace internal { namespace p4est { - /** - * A structure whose explicit - * specializations contain - * pointers to the relevant - * p4est_* and p8est_* - * functions. Using this - * structure, for example by - * saying - * functions::quadrant_compare, - * we can write code in a - * dimension independent way, - * either calling - * p4est_quadrant_compare or - * p8est_quadrant_compare, - * depending on template - * argument. - */ + /** + * A structure whose explicit + * specializations contain + * pointers to the relevant + * p4est_* and p8est_* + * functions. Using this + * structure, for example by + * saying + * functions::quadrant_compare, + * we can write code in a + * dimension independent way, + * either calling + * p4est_quadrant_compare or + * p8est_quadrant_compare, + * depending on template + * argument. + */ template struct functions; template <> struct functions<2> { - static - int (&quadrant_compare) (const void *v1, const void *v2); - - static - void (&quadrant_childrenv) (const types<2>::quadrant * q, - types<2>::quadrant c[]); - - static - int (&quadrant_overlaps_tree) (types<2>::tree * tree, - const types<2>::quadrant * q); - - static - void (&quadrant_set_morton) (types<2>::quadrant * quadrant, - int level, - uint64_t id); - - static - int (&quadrant_is_equal) (const types<2>::quadrant * q1, - const types<2>::quadrant * q2); - - static - int (&quadrant_is_sibling) (const types<2>::quadrant * q1, - const types<2>::quadrant * q2); - - static - int (&quadrant_is_ancestor) (const types<2>::quadrant * q1, - const types<2>::quadrant * q2); - - static - types<2>::connectivity * (&connectivity_new) (types<2>::topidx num_vertices, - types<2>::topidx num_trees, - types<2>::topidx num_corners, - types<2>::topidx num_vtt); - - static - void (&connectivity_destroy) (p4est_connectivity_t *connectivity); - - static - types<2>::forest * (&new_forest) (MPI_Comm mpicomm, - types<2>::connectivity * connectivity, - types<2>::locidx min_quadrants, + static + int (&quadrant_compare) (const void *v1, const void *v2); + + static + void (&quadrant_childrenv) (const types<2>::quadrant * q, + types<2>::quadrant c[]); + + static + int (&quadrant_overlaps_tree) (types<2>::tree * tree, + const types<2>::quadrant * q); + + static + void (&quadrant_set_morton) (types<2>::quadrant * quadrant, + int level, + uint64_t id); + + static + int (&quadrant_is_equal) (const types<2>::quadrant * q1, + const types<2>::quadrant * q2); + + static + int (&quadrant_is_sibling) (const types<2>::quadrant * q1, + const types<2>::quadrant * q2); + + static + int (&quadrant_is_ancestor) (const types<2>::quadrant * q1, + const types<2>::quadrant * q2); + + static + types<2>::connectivity * (&connectivity_new) (types<2>::topidx num_vertices, + types<2>::topidx num_trees, + types<2>::topidx num_corners, + types<2>::topidx num_vtt); + + static + void (&connectivity_destroy) (p4est_connectivity_t *connectivity); + + static + types<2>::forest * (&new_forest) (MPI_Comm mpicomm, + types<2>::connectivity * connectivity, + types<2>::locidx min_quadrants, int min_level, int fill_uniform, - size_t data_size, - p4est_init_t init_fn, - void *user_pointer); - - static - void (&destroy) (types<2>::forest * p4est); - - static - void (&refine) (types<2>::forest * p4est, - int refine_recursive, - p4est_refine_t refine_fn, - p4est_init_t init_fn); - - static - void (&coarsen) (types<2>::forest * p4est, - int coarsen_recursive, - p4est_coarsen_t coarsen_fn, - p4est_init_t init_fn); - - static - void (&balance) (types<2>::forest * p4est, - types<2>::balance_type btype, - p4est_init_t init_fn); - - static - void (&partition) (types<2>::forest * p4est, + size_t data_size, + p4est_init_t init_fn, + void *user_pointer); + + static + void (&destroy) (types<2>::forest * p4est); + + static + void (&refine) (types<2>::forest * p4est, + int refine_recursive, + p4est_refine_t refine_fn, + p4est_init_t init_fn); + + static + void (&coarsen) (types<2>::forest * p4est, + int coarsen_recursive, + p4est_coarsen_t coarsen_fn, + p4est_init_t init_fn); + + static + void (&balance) (types<2>::forest * p4est, + types<2>::balance_type btype, + p4est_init_t init_fn); + + static + void (&partition) (types<2>::forest * p4est, int partition_for_coarsening, - p4est_weight_t weight_fn); - - static - void (&save) (const char *filename, - types<2>::forest * p4est, - int save_data); - - static - types<2>::forest * (&load) (const char *filename, - MPI_Comm mpicomm, - size_t data_size, - int load_data, - void *user_pointer, - types<2>::connectivity ** p4est); - - static - void (&connectivity_save) (const char *filename, - types<2>::connectivity * connectivity); - - static - types<2>::connectivity * (&connectivity_load) (const char *filename, - long *length); - - static - unsigned (&checksum) (types<2>::forest * p4est); - - static - void (&vtk_write_file) (types<2>::forest * p4est, - p4est_geometry_t*, - const char *baseName); - - static - types<2>::ghost* (&ghost_new) (types<2>::forest * p4est, - types<2>::balance_type btype); - - static - void (&ghost_destroy) (types<2>::ghost * ghost); - - static - void (&reset_data) (types<2>::forest * p4est, - size_t data_size, - p4est_init_t init_fn, + p4est_weight_t weight_fn); + + static + void (&save) (const char *filename, + types<2>::forest * p4est, + int save_data); + + static + types<2>::forest * (&load) (const char *filename, + MPI_Comm mpicomm, + size_t data_size, + int load_data, + void *user_pointer, + types<2>::connectivity ** p4est); + + static + void (&connectivity_save) (const char *filename, + types<2>::connectivity * connectivity); + + static + types<2>::connectivity * (&connectivity_load) (const char *filename, + long *length); + + static + unsigned (&checksum) (types<2>::forest * p4est); + + static + void (&vtk_write_file) (types<2>::forest * p4est, + p4est_geometry_t*, + const char *baseName); + + static + types<2>::ghost* (&ghost_new) (types<2>::forest * p4est, + types<2>::balance_type btype); + + static + void (&ghost_destroy) (types<2>::ghost * ghost); + + static + void (&reset_data) (types<2>::forest * p4est, + size_t data_size, + p4est_init_t init_fn, void *user_pointer); - static - size_t (&forest_memory_used) (types<2>::forest * p4est); + static + size_t (&forest_memory_used) (types<2>::forest * p4est); - static - size_t (&connectivity_memory_used) (types<2>::connectivity * p4est); + static + size_t (&connectivity_memory_used) (types<2>::connectivity * p4est); }; int (&functions<2>::quadrant_compare) (const void *v1, const void *v2) = p4est_quadrant_compare; void (&functions<2>::quadrant_childrenv) (const types<2>::quadrant * q, - types<2>::quadrant c[]) + types<2>::quadrant c[]) = p4est_quadrant_childrenv; int (&functions<2>::quadrant_overlaps_tree) (types<2>::tree * tree, - const types<2>::quadrant * q) + const types<2>::quadrant * q) = p4est_quadrant_overlaps_tree; void (&functions<2>::quadrant_set_morton) (types<2>::quadrant * quadrant, - int level, - uint64_t id) + int level, + uint64_t id) = p4est_quadrant_set_morton; int (&functions<2>::quadrant_is_equal) (const types<2>::quadrant * q1, - const types<2>::quadrant * q2) + const types<2>::quadrant * q2) = p4est_quadrant_is_equal; int (&functions<2>::quadrant_is_sibling) (const types<2>::quadrant * q1, - const types<2>::quadrant * q2) + const types<2>::quadrant * q2) = p4est_quadrant_is_sibling; int (&functions<2>::quadrant_is_ancestor) (const types<2>::quadrant * q1, - const types<2>::quadrant * q2) + const types<2>::quadrant * q2) = p4est_quadrant_is_ancestor; types<2>::connectivity * (&functions<2>::connectivity_new) (types<2>::topidx num_vertices, - types<2>::topidx num_trees, - types<2>::topidx num_corners, - types<2>::topidx num_vtt) + types<2>::topidx num_trees, + types<2>::topidx num_corners, + types<2>::topidx num_vtt) = p4est_connectivity_new; void (&functions<2>::connectivity_destroy) (p4est_connectivity_t *connectivity) = p4est_connectivity_destroy; types<2>::forest * (&functions<2>::new_forest) (MPI_Comm mpicomm, - types<2>::connectivity * connectivity, - types<2>::locidx min_quadrants, + types<2>::connectivity * connectivity, + types<2>::locidx min_quadrants, int min_level, int fill_uniform, - size_t data_size, - p4est_init_t init_fn, - void *user_pointer) + size_t data_size, + p4est_init_t init_fn, + void *user_pointer) = p4est_new_ext; void (&functions<2>::destroy) (types<2>::forest * p4est) = p4est_destroy; void (&functions<2>::refine) (types<2>::forest * p4est, - int refine_recursive, - p4est_refine_t refine_fn, - p4est_init_t init_fn) + int refine_recursive, + p4est_refine_t refine_fn, + p4est_init_t init_fn) = p4est_refine; void (&functions<2>::coarsen) (types<2>::forest * p4est, - int coarsen_recursive, - p4est_coarsen_t coarsen_fn, - p4est_init_t init_fn) + int coarsen_recursive, + p4est_coarsen_t coarsen_fn, + p4est_init_t init_fn) = p4est_coarsen; void (&functions<2>::balance) (types<2>::forest * p4est, - types<2>::balance_type btype, - p4est_init_t init_fn) + types<2>::balance_type btype, + p4est_init_t init_fn) = p4est_balance; void (&functions<2>::partition) (types<2>::forest * p4est, int partition_for_coarsening, - p4est_weight_t weight_fn) + p4est_weight_t weight_fn) = p4est_partition_ext; void (&functions<2>::save) (const char *filename, - types<2>::forest * p4est, - int save_data) + types<2>::forest * p4est, + int save_data) = p4est_save; types<2>::forest * (&functions<2>::load) (const char *filename, - MPI_Comm mpicomm, - std::size_t data_size, - int load_data, - void *user_pointer, - types<2>::connectivity ** p4est) + MPI_Comm mpicomm, + std::size_t data_size, + int load_data, + void *user_pointer, + types<2>::connectivity ** p4est) = p4est_load; void (&functions<2>::connectivity_save) (const char *filename, - types<2>::connectivity *connectivity) + types<2>::connectivity *connectivity) = p4est_connectivity_save; types<2>::connectivity * (&functions<2>::connectivity_load) (const char *filename, - long *length) + long *length) = p4est_connectivity_load; unsigned (&functions<2>::checksum) (types<2>::forest * p4est) = p4est_checksum; void (&functions<2>::vtk_write_file) (types<2>::forest * p4est, - p4est_geometry_t*, - const char *baseName) + p4est_geometry_t*, + const char *baseName) = p4est_vtk_write_file; types<2>::ghost* (&functions<2>::ghost_new) (types<2>::forest * p4est, - types<2>::balance_type btype) + types<2>::balance_type btype) = p4est_ghost_new; void (&functions<2>::ghost_destroy) (types<2>::ghost * ghost) = p4est_ghost_destroy; void (&functions<2>::reset_data) (types<2>::forest * p4est, - size_t data_size, - p4est_init_t init_fn, - void *user_pointer) + size_t data_size, + p4est_init_t init_fn, + void *user_pointer) = p4est_reset_data; size_t (&functions<2>::forest_memory_used) (types<2>::forest * p4est) @@ -316,127 +316,127 @@ namespace internal template <> struct functions<3> { - static - int (&quadrant_compare) (const void *v1, const void *v2); - - static - void (&quadrant_childrenv) (const types<3>::quadrant * q, - types<3>::quadrant c[]); - - static - int (&quadrant_overlaps_tree) (types<3>::tree * tree, - const types<3>::quadrant * q); - - static - void (&quadrant_set_morton) (types<3>::quadrant * quadrant, - int level, - uint64_t id); - - static - int (&quadrant_is_equal) (const types<3>::quadrant * q1, - const types<3>::quadrant * q2); - - static - int (&quadrant_is_sibling) (const types<3>::quadrant * q1, - const types<3>::quadrant * q2); - - static - int (&quadrant_is_ancestor) (const types<3>::quadrant * q1, - const types<3>::quadrant * q2); - - static - types<3>::connectivity * (&connectivity_new) (types<3>::topidx num_vertices, - types<3>::topidx num_trees, - types<3>::topidx num_edges, - types<3>::topidx num_ett, - types<3>::topidx num_corners, - types<3>::topidx num_ctt); - - static - void (&connectivity_destroy) (p8est_connectivity_t *connectivity); - - static - types<3>::forest * (&new_forest) (MPI_Comm mpicomm, - types<3>::connectivity * connectivity, - types<3>::locidx min_quadrants, + static + int (&quadrant_compare) (const void *v1, const void *v2); + + static + void (&quadrant_childrenv) (const types<3>::quadrant * q, + types<3>::quadrant c[]); + + static + int (&quadrant_overlaps_tree) (types<3>::tree * tree, + const types<3>::quadrant * q); + + static + void (&quadrant_set_morton) (types<3>::quadrant * quadrant, + int level, + uint64_t id); + + static + int (&quadrant_is_equal) (const types<3>::quadrant * q1, + const types<3>::quadrant * q2); + + static + int (&quadrant_is_sibling) (const types<3>::quadrant * q1, + const types<3>::quadrant * q2); + + static + int (&quadrant_is_ancestor) (const types<3>::quadrant * q1, + const types<3>::quadrant * q2); + + static + types<3>::connectivity * (&connectivity_new) (types<3>::topidx num_vertices, + types<3>::topidx num_trees, + types<3>::topidx num_edges, + types<3>::topidx num_ett, + types<3>::topidx num_corners, + types<3>::topidx num_ctt); + + static + void (&connectivity_destroy) (p8est_connectivity_t *connectivity); + + static + types<3>::forest * (&new_forest) (MPI_Comm mpicomm, + types<3>::connectivity * connectivity, + types<3>::locidx min_quadrants, int min_level, int fill_uniform, - size_t data_size, - p8est_init_t init_fn, - void *user_pointer); - - static - void (&destroy) (types<3>::forest * p8est); - - static - void (&refine) (types<3>::forest * p8est, - int refine_recursive, - p8est_refine_t refine_fn, - p8est_init_t init_fn); - - static - void (&coarsen) (types<3>::forest * p8est, - int coarsen_recursive, - p8est_coarsen_t coarsen_fn, - p8est_init_t init_fn); - - static - void (&balance) (types<3>::forest * p8est, - types<3>::balance_type btype, - p8est_init_t init_fn); - - static - void (&partition) (types<3>::forest * p8est, + size_t data_size, + p8est_init_t init_fn, + void *user_pointer); + + static + void (&destroy) (types<3>::forest * p8est); + + static + void (&refine) (types<3>::forest * p8est, + int refine_recursive, + p8est_refine_t refine_fn, + p8est_init_t init_fn); + + static + void (&coarsen) (types<3>::forest * p8est, + int coarsen_recursive, + p8est_coarsen_t coarsen_fn, + p8est_init_t init_fn); + + static + void (&balance) (types<3>::forest * p8est, + types<3>::balance_type btype, + p8est_init_t init_fn); + + static + void (&partition) (types<3>::forest * p8est, int partition_for_coarsening, - p8est_weight_t weight_fn); - - static - void (&save) (const char *filename, - types<3>::forest * p4est, - int save_data); - - static - types<3>::forest * (&load) (const char *filename, - MPI_Comm mpicomm, - std::size_t data_size, - int load_data, - void *user_pointer, - types<3>::connectivity ** p4est); - - static - void (&connectivity_save) (const char *filename, - types<3>::connectivity * connectivity); - - static - types<3>::connectivity * (&connectivity_load) (const char *filename, - long *length); - - static - unsigned (&checksum) (types<3>::forest * p8est); - - static - void (&vtk_write_file) (types<3>::forest * p8est, - p8est_geometry_t*, - const char *baseName); - - static - types<3>::ghost* (&ghost_new) (types<3>::forest * p4est, - types<3>::balance_type btype); - - static - void (&ghost_destroy) (types<3>::ghost * ghost); - - static - void (&reset_data) (types<3>::forest * p4est, - size_t data_size, - p8est_init_t init_fn, + p8est_weight_t weight_fn); + + static + void (&save) (const char *filename, + types<3>::forest * p4est, + int save_data); + + static + types<3>::forest * (&load) (const char *filename, + MPI_Comm mpicomm, + std::size_t data_size, + int load_data, + void *user_pointer, + types<3>::connectivity ** p4est); + + static + void (&connectivity_save) (const char *filename, + types<3>::connectivity * connectivity); + + static + types<3>::connectivity * (&connectivity_load) (const char *filename, + long *length); + + static + unsigned (&checksum) (types<3>::forest * p8est); + + static + void (&vtk_write_file) (types<3>::forest * p8est, + p8est_geometry_t*, + const char *baseName); + + static + types<3>::ghost* (&ghost_new) (types<3>::forest * p4est, + types<3>::balance_type btype); + + static + void (&ghost_destroy) (types<3>::ghost * ghost); + + static + void (&reset_data) (types<3>::forest * p4est, + size_t data_size, + p8est_init_t init_fn, void *user_pointer); - static - size_t (&forest_memory_used) (types<3>::forest * p4est); + static + size_t (&forest_memory_used) (types<3>::forest * p4est); - static - size_t (&connectivity_memory_used) (types<3>::connectivity * p4est); + static + size_t (&connectivity_memory_used) (types<3>::connectivity * p4est); }; @@ -444,118 +444,118 @@ namespace internal = p8est_quadrant_compare; void (&functions<3>::quadrant_childrenv) (const types<3>::quadrant * q, - types<3>::quadrant c[]) + types<3>::quadrant c[]) = p8est_quadrant_childrenv; int (&functions<3>::quadrant_overlaps_tree) (types<3>::tree * tree, - const types<3>::quadrant * q) + const types<3>::quadrant * q) = p8est_quadrant_overlaps_tree; void (&functions<3>::quadrant_set_morton) (types<3>::quadrant * quadrant, - int level, - uint64_t id) + int level, + uint64_t id) = p8est_quadrant_set_morton; int (&functions<3>::quadrant_is_equal) (const types<3>::quadrant * q1, - const types<3>::quadrant * q2) + const types<3>::quadrant * q2) = p8est_quadrant_is_equal; int (&functions<3>::quadrant_is_sibling) (const types<3>::quadrant * q1, - const types<3>::quadrant * q2) + const types<3>::quadrant * q2) = p8est_quadrant_is_sibling; int (&functions<3>::quadrant_is_ancestor) (const types<3>::quadrant * q1, - const types<3>::quadrant * q2) + const types<3>::quadrant * q2) = p8est_quadrant_is_ancestor; types<3>::connectivity * (&functions<3>::connectivity_new) (types<3>::topidx num_vertices, - types<3>::topidx num_trees, - types<3>::topidx num_edges, - types<3>::topidx num_ett, - types<3>::topidx num_corners, - types<3>::topidx num_ctt) + types<3>::topidx num_trees, + types<3>::topidx num_edges, + types<3>::topidx num_ett, + types<3>::topidx num_corners, + types<3>::topidx num_ctt) = p8est_connectivity_new; void (&functions<3>::connectivity_destroy) (p8est_connectivity_t *connectivity) = p8est_connectivity_destroy; types<3>::forest * (&functions<3>::new_forest) (MPI_Comm mpicomm, - types<3>::connectivity * connectivity, - types<3>::locidx min_quadrants, + types<3>::connectivity * connectivity, + types<3>::locidx min_quadrants, int min_level, int fill_uniform, - size_t data_size, - p8est_init_t init_fn, - void *user_pointer) + size_t data_size, + p8est_init_t init_fn, + void *user_pointer) = p8est_new_ext; void (&functions<3>::destroy) (types<3>::forest * p8est) = p8est_destroy; void (&functions<3>::refine) (types<3>::forest * p8est, - int refine_recursive, - p8est_refine_t refine_fn, - p8est_init_t init_fn) + int refine_recursive, + p8est_refine_t refine_fn, + p8est_init_t init_fn) = p8est_refine; void (&functions<3>::coarsen) (types<3>::forest * p8est, - int coarsen_recursive, - p8est_coarsen_t coarsen_fn, - p8est_init_t init_fn) + int coarsen_recursive, + p8est_coarsen_t coarsen_fn, + p8est_init_t init_fn) = p8est_coarsen; void (&functions<3>::balance) (types<3>::forest * p8est, - types<3>::balance_type btype, - p8est_init_t init_fn) + types<3>::balance_type btype, + p8est_init_t init_fn) = p8est_balance; void (&functions<3>::partition) (types<3>::forest * p8est, int partition_for_coarsening, - p8est_weight_t weight_fn) + p8est_weight_t weight_fn) = p8est_partition_ext; void (&functions<3>::save) (const char *filename, - types<3>::forest * p4est, - int save_data) + types<3>::forest * p4est, + int save_data) = p8est_save; types<3>::forest * (&functions<3>::load) (const char *filename, - MPI_Comm mpicomm, - std::size_t data_size, - int load_data, - void *user_pointer, - types<3>::connectivity ** p4est) + MPI_Comm mpicomm, + std::size_t data_size, + int load_data, + void *user_pointer, + types<3>::connectivity ** p4est) = p8est_load; void (&functions<3>::connectivity_save) (const char *filename, - types<3>::connectivity *connectivity) + types<3>::connectivity *connectivity) = p8est_connectivity_save; types<3>::connectivity * (&functions<3>::connectivity_load) (const char *filename, - long *length) + long *length) = p8est_connectivity_load; unsigned (&functions<3>::checksum) (types<3>::forest * p8est) = p8est_checksum; void (&functions<3>::vtk_write_file) (types<3>::forest * p8est, - p8est_geometry_t*, - const char *baseName) + p8est_geometry_t*, + const char *baseName) = p8est_vtk_write_file; types<3>::ghost* (&functions<3>::ghost_new) (types<3>::forest * p4est, - types<3>::balance_type btype) + types<3>::balance_type btype) = p8est_ghost_new; void (&functions<3>::ghost_destroy) (types<3>::ghost * ghost) = p8est_ghost_destroy; void (&functions<3>::reset_data) (types<3>::forest * p4est, - size_t data_size, - p8est_init_t init_fn, - void *user_pointer) + size_t data_size, + p8est_init_t init_fn, + void *user_pointer) = p8est_reset_data; size_t (&functions<3>::forest_memory_used) (types<3>::forest * p4est) @@ -574,22 +574,22 @@ namespace internal { for (unsigned int c=0; - c::max_children_per_cell; ++c) - switch (dim) - { - case 2: - P4EST_QUADRANT_INIT(&p4est_children[c]); - break; - case 3: - P8EST_QUADRANT_INIT(&p4est_children[c]); - break; - default: - Assert (false, ExcNotImplemented()); - } + c::max_children_per_cell; ++c) + switch (dim) + { + case 2: + P4EST_QUADRANT_INIT(&p4est_children[c]); + break; + case 3: + P8EST_QUADRANT_INIT(&p4est_children[c]); + break; + default: + Assert (false, ExcNotImplemented()); + } functions::quadrant_childrenv (&p4est_cell, - p4est_children); + p4est_children); } @@ -599,26 +599,26 @@ namespace internal init_coarse_quadrant(typename types::quadrant & quad) { switch (dim) - { - case 2: - P4EST_QUADRANT_INIT(&quad); - break; - case 3: - P8EST_QUADRANT_INIT(&quad); - break; - default: - Assert (false, ExcNotImplemented()); - } + { + case 2: + P4EST_QUADRANT_INIT(&quad); + break; + case 3: + P8EST_QUADRANT_INIT(&quad); + break; + default: + Assert (false, ExcNotImplemented()); + } functions::quadrant_set_morton (&quad, - /*level=*/0, - /*index=*/0); + /*level=*/0, + /*index=*/0); } template bool quadrant_is_equal (const typename types::quadrant & q1, - const typename types::quadrant & q2) + const typename types::quadrant & q2) { return functions::quadrant_is_equal(&q1, &q2); } @@ -628,7 +628,7 @@ namespace internal template bool quadrant_is_ancestor (const typename types::quadrant & q1, - const typename types::quadrant & q2) + const typename types::quadrant & q2) { return functions::quadrant_is_ancestor(&q1, &q2); } @@ -641,23 +641,23 @@ namespace template void get_vertex_to_cell_mappings (const Triangulation &triangulation, - std::vector &vertex_touch_count, - std::vector::active_cell_iterator,unsigned int> > > - & vertex_to_cell) + std::vector &vertex_touch_count, + std::vector::active_cell_iterator,unsigned int> > > + & vertex_to_cell) { vertex_touch_count.resize (triangulation.n_vertices()); vertex_to_cell.resize (triangulation.n_vertices()); for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell != triangulation.end(); ++cell) + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell) for (unsigned int v=0; v::vertices_per_cell; ++v) - { - ++vertex_touch_count[cell->vertex_index(v)]; - vertex_to_cell[cell->vertex_index(v)] - .push_back (std::make_pair (cell, v)); - } + { + ++vertex_touch_count[cell->vertex_index(v)]; + vertex_to_cell[cell->vertex_index(v)] + .push_back (std::make_pair (cell, v)); + } } @@ -665,10 +665,10 @@ namespace template void get_edge_to_cell_mappings (const Triangulation &triangulation, - std::vector &edge_touch_count, - std::vector::active_cell_iterator,unsigned int> > > - & edge_to_cell) + std::vector &edge_touch_count, + std::vector::active_cell_iterator,unsigned int> > > + & edge_to_cell) { Assert (triangulation.n_levels() == 1, ExcInternalError()); @@ -676,244 +676,244 @@ namespace edge_to_cell.resize (triangulation.n_active_lines()); for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell != triangulation.end(); ++cell) + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell) for (unsigned int l=0; l::lines_per_cell; ++l) - { - ++edge_touch_count[cell->line(l)->index()]; - edge_to_cell[cell->line(l)->index()] - .push_back (std::make_pair (cell, l)); - } + { + ++edge_touch_count[cell->line(l)->index()]; + edge_to_cell[cell->line(l)->index()] + .push_back (std::make_pair (cell, l)); + } } - /** - * Set all vertex and cell - * related information in the - * p4est connectivity structure. - */ + /** + * Set all vertex and cell + * related information in the + * p4est connectivity structure. + */ template void set_vertex_and_cell_info (const Triangulation &triangulation, - const std::vector &vertex_touch_count, - const std::vector::active_cell_iterator,unsigned int> > > - & vertex_to_cell, - const std::vector &coarse_cell_to_p4est_tree_permutation, - const bool set_vertex_info, - typename internal::p4est::types::connectivity *connectivity) + const std::vector &vertex_touch_count, + const std::vector::active_cell_iterator,unsigned int> > > + & vertex_to_cell, + const std::vector &coarse_cell_to_p4est_tree_permutation, + const bool set_vertex_info, + typename internal::p4est::types::connectivity *connectivity) { - // copy the vertices into the - // connectivity structure. the - // triangulation exports the array of - // vertices, but some of the entries are - // sometimes unused; this shouldn't be - // the case for a newly created - // triangulation, but make sure - // - // note that p4est stores coordinates as - // a triplet of values even in 2d + // copy the vertices into the + // connectivity structure. the + // triangulation exports the array of + // vertices, but some of the entries are + // sometimes unused; this shouldn't be + // the case for a newly created + // triangulation, but make sure + // + // note that p4est stores coordinates as + // a triplet of values even in 2d Assert (triangulation.get_used_vertices().size() == - triangulation.get_vertices().size(), - ExcInternalError()); + triangulation.get_vertices().size(), + ExcInternalError()); Assert (std::find (triangulation.get_used_vertices().begin(), - triangulation.get_used_vertices().end(), - false) - == triangulation.get_used_vertices().end(), - ExcInternalError()); + triangulation.get_used_vertices().end(), + false) + == triangulation.get_used_vertices().end(), + ExcInternalError()); if (set_vertex_info == true) for (unsigned int v=0; vvertices[3*v ] = triangulation.get_vertices()[v][0]; - connectivity->vertices[3*v+1] = triangulation.get_vertices()[v][1]; - connectivity->vertices[3*v+2] = (spacedim == 2 ? - 0 - : - triangulation.get_vertices()[v][2]); - } - - // next store the tree_to_vertex indices - // (each tree is here only a single cell - // in the coarse mesh). p4est requires - // vertex numbering in clockwise - // orientation - // - // while we're at it, also copy the - // neighborship information between cells + { + connectivity->vertices[3*v ] = triangulation.get_vertices()[v][0]; + connectivity->vertices[3*v+1] = triangulation.get_vertices()[v][1]; + connectivity->vertices[3*v+2] = (spacedim == 2 ? + 0 + : + triangulation.get_vertices()[v][2]); + } + + // next store the tree_to_vertex indices + // (each tree is here only a single cell + // in the coarse mesh). p4est requires + // vertex numbering in clockwise + // orientation + // + // while we're at it, also copy the + // neighborship information between cells typename Triangulation::active_cell_iterator cell = triangulation.begin_active(), endc = triangulation.end(); for (; cell != endc; ++cell) { - const unsigned int - index = coarse_cell_to_p4est_tree_permutation[cell->index()]; - - for (unsigned int v=0; v::vertices_per_cell; ++v) - { - if (set_vertex_info == true) - connectivity->tree_to_vertex[index*GeometryInfo::vertices_per_cell+v] = cell->vertex_index(v); - connectivity->tree_to_corner[index*GeometryInfo::vertices_per_cell+v] = cell->vertex_index(v); - } - - // neighborship information. if a - // cell is at a boundary, then enter - // the index of the cell itself here - for (unsigned int f=0; f::faces_per_cell; ++f) - if (cell->face(f)->at_boundary() == false) - connectivity->tree_to_tree[index*GeometryInfo::faces_per_cell + f] - = coarse_cell_to_p4est_tree_permutation[cell->neighbor(f)->index()]; - else - connectivity->tree_to_tree[index*GeometryInfo::faces_per_cell + f] - = coarse_cell_to_p4est_tree_permutation[cell->index()]; - - // fill tree_to_face, which is - // essentially neighbor_to_neighbor; - // however, we have to remap the - // resulting face number as well - for (unsigned int f=0; f::faces_per_cell; ++f) - if (cell->face(f)->at_boundary() == false) - { - switch (dim) - { - case 2: - { - connectivity->tree_to_face[index*GeometryInfo::faces_per_cell + f] - = cell->neighbor_of_neighbor (f); - break; - } - - case 3: - { - /* - * The values for - * tree_to_face are in - * 0..23 where ttf % 6 - * gives the face - * number and ttf / 6 - * the face orientation - * code. The - * orientation is - * determined as - * follows. Let - * my_face and - * other_face be the - * two face numbers of - * the connecting trees - * in 0..5. Then the - * first face vertex of - * the lower of my_face - * and other_face - * connects to a face - * vertex numbered 0..3 - * in the higher of - * my_face and - * other_face. The - * face orientation is - * defined as this - * number. If my_face - * == other_face, - * treating either of - * both faces as the - * lower one leads to - * the same result. - */ - - connectivity->tree_to_face[index*6 + f] - = cell->neighbor_of_neighbor (f); - - unsigned int face_idx_list[2] = - {f, cell->neighbor_of_neighbor (f)}; - typename Triangulation::active_cell_iterator - cell_list[2] = {cell, cell->neighbor(f)}; - unsigned int smaller_idx = 0; - - if (f>cell->neighbor_of_neighbor (f)) - smaller_idx = 1; - - unsigned larger_idx = (smaller_idx+1) % 2; - //smaller = *_list[smaller_idx] - //larger = *_list[larger_idx] - - unsigned int v = 0; - - // global vertex index of - // vertex 0 on face of - // cell with smaller - // local face index - unsigned int g_idx = - cell_list[smaller_idx]->vertex_index( - GeometryInfo::face_to_cell_vertices( - face_idx_list[smaller_idx], - 0, - cell_list[smaller_idx]->face_orientation(face_idx_list[smaller_idx]), - cell_list[smaller_idx]->face_flip(face_idx_list[smaller_idx]), - cell_list[smaller_idx]->face_rotation(face_idx_list[smaller_idx])) - ); - - // loop over vertices on - // face from other cell - // and compare global - // vertex numbers - for (unsigned int i=0; i::vertices_per_face; ++i) - { - unsigned int idx - = - cell_list[larger_idx]->vertex_index( - GeometryInfo::face_to_cell_vertices( - face_idx_list[larger_idx], - i) - ); - - if (idx==g_idx) - { - v = i; - break; - } - } - - connectivity->tree_to_face[index*6 + f] += 6*v; - break; - } - - default: - Assert (false, ExcNotImplemented()); - } - } - else - connectivity->tree_to_face[index*GeometryInfo::faces_per_cell + f] = f; + const unsigned int + index = coarse_cell_to_p4est_tree_permutation[cell->index()]; + + for (unsigned int v=0; v::vertices_per_cell; ++v) + { + if (set_vertex_info == true) + connectivity->tree_to_vertex[index*GeometryInfo::vertices_per_cell+v] = cell->vertex_index(v); + connectivity->tree_to_corner[index*GeometryInfo::vertices_per_cell+v] = cell->vertex_index(v); + } + + // neighborship information. if a + // cell is at a boundary, then enter + // the index of the cell itself here + for (unsigned int f=0; f::faces_per_cell; ++f) + if (cell->face(f)->at_boundary() == false) + connectivity->tree_to_tree[index*GeometryInfo::faces_per_cell + f] + = coarse_cell_to_p4est_tree_permutation[cell->neighbor(f)->index()]; + else + connectivity->tree_to_tree[index*GeometryInfo::faces_per_cell + f] + = coarse_cell_to_p4est_tree_permutation[cell->index()]; + + // fill tree_to_face, which is + // essentially neighbor_to_neighbor; + // however, we have to remap the + // resulting face number as well + for (unsigned int f=0; f::faces_per_cell; ++f) + if (cell->face(f)->at_boundary() == false) + { + switch (dim) + { + case 2: + { + connectivity->tree_to_face[index*GeometryInfo::faces_per_cell + f] + = cell->neighbor_of_neighbor (f); + break; + } + + case 3: + { + /* + * The values for + * tree_to_face are in + * 0..23 where ttf % 6 + * gives the face + * number and ttf / 6 + * the face orientation + * code. The + * orientation is + * determined as + * follows. Let + * my_face and + * other_face be the + * two face numbers of + * the connecting trees + * in 0..5. Then the + * first face vertex of + * the lower of my_face + * and other_face + * connects to a face + * vertex numbered 0..3 + * in the higher of + * my_face and + * other_face. The + * face orientation is + * defined as this + * number. If my_face + * == other_face, + * treating either of + * both faces as the + * lower one leads to + * the same result. + */ + + connectivity->tree_to_face[index*6 + f] + = cell->neighbor_of_neighbor (f); + + unsigned int face_idx_list[2] = + {f, cell->neighbor_of_neighbor (f)}; + typename Triangulation::active_cell_iterator + cell_list[2] = {cell, cell->neighbor(f)}; + unsigned int smaller_idx = 0; + + if (f>cell->neighbor_of_neighbor (f)) + smaller_idx = 1; + + unsigned larger_idx = (smaller_idx+1) % 2; + //smaller = *_list[smaller_idx] + //larger = *_list[larger_idx] + + unsigned int v = 0; + + // global vertex index of + // vertex 0 on face of + // cell with smaller + // local face index + unsigned int g_idx = + cell_list[smaller_idx]->vertex_index( + GeometryInfo::face_to_cell_vertices( + face_idx_list[smaller_idx], + 0, + cell_list[smaller_idx]->face_orientation(face_idx_list[smaller_idx]), + cell_list[smaller_idx]->face_flip(face_idx_list[smaller_idx]), + cell_list[smaller_idx]->face_rotation(face_idx_list[smaller_idx])) + ); + + // loop over vertices on + // face from other cell + // and compare global + // vertex numbers + for (unsigned int i=0; i::vertices_per_face; ++i) + { + unsigned int idx + = + cell_list[larger_idx]->vertex_index( + GeometryInfo::face_to_cell_vertices( + face_idx_list[larger_idx], + i) + ); + + if (idx==g_idx) + { + v = i; + break; + } + } + + connectivity->tree_to_face[index*6 + f] += 6*v; + break; + } + + default: + Assert (false, ExcNotImplemented()); + } + } + else + connectivity->tree_to_face[index*GeometryInfo::faces_per_cell + f] = f; } - // now fill the vertex information + // now fill the vertex information connectivity->ctt_offset[0] = 0; std::partial_sum (vertex_touch_count.begin(), - vertex_touch_count.end(), - &connectivity->ctt_offset[1]); + vertex_touch_count.end(), + &connectivity->ctt_offset[1]); const typename internal::p4est::types::locidx num_vtt = std::accumulate (vertex_touch_count.begin(), - vertex_touch_count.end(), - 0); + vertex_touch_count.end(), + 0); Assert (connectivity->ctt_offset[triangulation.n_vertices()] == - num_vtt, - ExcInternalError()); + num_vtt, + ExcInternalError()); for (unsigned int v=0; v::active_cell_iterator, - unsigned int> >::const_iterator - p = vertex_to_cell[v].begin(); - for (unsigned int c=0; ccorner_to_tree[connectivity->ctt_offset[v]+c] - = coarse_cell_to_p4est_tree_permutation[p->first->index()]; - connectivity->corner_to_corner[connectivity->ctt_offset[v]+c] - = p->second; - } + Assert (vertex_to_cell[v].size() == vertex_touch_count[v], + ExcInternalError()); + + typename std::list::active_cell_iterator, + unsigned int> >::const_iterator + p = vertex_to_cell[v].begin(); + for (unsigned int c=0; ccorner_to_tree[connectivity->ctt_offset[v]+c] + = coarse_cell_to_p4est_tree_permutation[p->first->index()]; + connectivity->corner_to_corner[connectivity->ctt_offset[v]+c] + = p->second; + } } } @@ -922,13 +922,13 @@ namespace template bool tree_exists_locally (const typename internal::p4est::types::forest *parallel_forest, - const typename internal::p4est::types::topidx coarse_grid_cell) + const typename internal::p4est::types::topidx coarse_grid_cell) { Assert (coarse_grid_cell < parallel_forest->connectivity->num_trees, - ExcInternalError()); + ExcInternalError()); return ((coarse_grid_cell >= parallel_forest->first_local_tree) - && - (coarse_grid_cell <= parallel_forest->last_local_tree)); + && + (coarse_grid_cell <= parallel_forest->last_local_tree)); } @@ -938,7 +938,7 @@ namespace { if (cell->has_children()) for (unsigned int c=0; cn_children(); ++c) - delete_all_children_and_self (cell->child(c)); + delete_all_children_and_self (cell->child(c)); else cell->set_coarsen_flag (); } @@ -951,7 +951,7 @@ namespace { if (cell->has_children()) for (unsigned int c=0; cn_children(); ++c) - delete_all_children_and_self (cell->child(c)); + delete_all_children_and_self (cell->child(c)); } @@ -959,99 +959,99 @@ namespace template void match_tree_recursively (const typename internal::p4est::types::tree &tree, - const typename Triangulation::cell_iterator &dealii_cell, - const typename internal::p4est::types::quadrant &p4est_cell, - const typename internal::p4est::types::forest &forest, - const types::subdomain_id_t my_subdomain) + const typename Triangulation::cell_iterator &dealii_cell, + const typename internal::p4est::types::quadrant &p4est_cell, + const typename internal::p4est::types::forest &forest, + const types::subdomain_id_t my_subdomain) { - // check if this cell exists in - // the local p4est cell + // check if this cell exists in + // the local p4est cell if (sc_array_bsearch(const_cast(&tree.quadrants), - &p4est_cell, - internal::p4est::functions::quadrant_compare) - != -1) + &p4est_cell, + internal::p4est::functions::quadrant_compare) + != -1) { - // yes, cell found in local part of p4est - delete_all_children (dealii_cell); - dealii_cell->set_subdomain_id(my_subdomain); + // yes, cell found in local part of p4est + delete_all_children (dealii_cell); + dealii_cell->set_subdomain_id(my_subdomain); } else { - // no, cell not found in - // local part of - // p4est. this means that - // the local part is more - // refined than the current - // cell. if this cell has - // no children of its own, - // we need to refine it, - // and if it does already - // have children then loop - // over all children and - // see if they are locally - // available as well - if (dealii_cell->has_children () == false) - dealii_cell->set_refine_flag (); - else - { - typename internal::p4est::types::quadrant - p4est_child[GeometryInfo::max_children_per_cell]; - for (unsigned int c=0; - c::max_children_per_cell; ++c) - switch (dim) - { - case 2: - P4EST_QUADRANT_INIT(&p4est_child[c]); - break; - case 3: - P8EST_QUADRANT_INIT(&p4est_child[c]); - break; - default: - Assert (false, ExcNotImplemented()); - } - - - internal::p4est::functions:: - quadrant_childrenv (&p4est_cell, - p4est_child); - - for (unsigned int c=0; - c::max_children_per_cell; ++c) - if (internal::p4est::functions:: - quadrant_overlaps_tree (const_cast::tree*>(&tree), - &p4est_child[c]) - == false) - { - // no, this child - // is locally not - // available in - // the p4est. - // delete all - // its children - // but, because this - // may not be successfull, - // make sure to mark all - // children recursively as - // not local. - delete_all_children (dealii_cell->child(c)); - dealii_cell->child(c) - ->recursively_set_subdomain_id(types::artificial_subdomain_id); - } - else - { - // at least some - // part of the - // tree rooted in - // this child is - // locally - // available - match_tree_recursively (tree, - dealii_cell->child(c), - p4est_child[c], - forest, - my_subdomain); - } - } + // no, cell not found in + // local part of + // p4est. this means that + // the local part is more + // refined than the current + // cell. if this cell has + // no children of its own, + // we need to refine it, + // and if it does already + // have children then loop + // over all children and + // see if they are locally + // available as well + if (dealii_cell->has_children () == false) + dealii_cell->set_refine_flag (); + else + { + typename internal::p4est::types::quadrant + p4est_child[GeometryInfo::max_children_per_cell]; + for (unsigned int c=0; + c::max_children_per_cell; ++c) + switch (dim) + { + case 2: + P4EST_QUADRANT_INIT(&p4est_child[c]); + break; + case 3: + P8EST_QUADRANT_INIT(&p4est_child[c]); + break; + default: + Assert (false, ExcNotImplemented()); + } + + + internal::p4est::functions:: + quadrant_childrenv (&p4est_cell, + p4est_child); + + for (unsigned int c=0; + c::max_children_per_cell; ++c) + if (internal::p4est::functions:: + quadrant_overlaps_tree (const_cast::tree*>(&tree), + &p4est_child[c]) + == false) + { + // no, this child + // is locally not + // available in + // the p4est. + // delete all + // its children + // but, because this + // may not be successfull, + // make sure to mark all + // children recursively as + // not local. + delete_all_children (dealii_cell->child(c)); + dealii_cell->child(c) + ->recursively_set_subdomain_id(types::artificial_subdomain_id); + } + else + { + // at least some + // part of the + // tree rooted in + // this child is + // locally + // available + match_tree_recursively (tree, + dealii_cell->child(c), + p4est_child[c], + forest, + my_subdomain); + } + } } } @@ -1059,60 +1059,60 @@ namespace template void match_quadrant_recursively (const typename internal::p4est::types::quadrant &this_quadrant, - const typename Triangulation::cell_iterator &dealii_cell, - const typename internal::p4est::types::quadrant &ghost_quadrant, - const typename internal::p4est::types::forest &forest, - unsigned int ghost_owner) + const typename Triangulation::cell_iterator &dealii_cell, + const typename internal::p4est::types::quadrant &ghost_quadrant, + const typename internal::p4est::types::forest &forest, + unsigned int ghost_owner) { if (internal::p4est::functions::quadrant_is_equal(&this_quadrant, &ghost_quadrant)) { - // this is the ghostcell - dealii_cell->set_subdomain_id(ghost_owner); - - if (dealii_cell->has_children()) - delete_all_children (dealii_cell); - else - dealii_cell->clear_coarsen_flag(); - return; + // this is the ghostcell + dealii_cell->set_subdomain_id(ghost_owner); + + if (dealii_cell->has_children()) + delete_all_children (dealii_cell); + else + dealii_cell->clear_coarsen_flag(); + return; } if (! internal::p4est::functions::quadrant_is_ancestor ( &this_quadrant, &ghost_quadrant)) { - return; + return; } if (dealii_cell->has_children () == false) { - dealii_cell->clear_coarsen_flag(); - dealii_cell->set_refine_flag (); - return; + dealii_cell->clear_coarsen_flag(); + dealii_cell->set_refine_flag (); + return; } typename internal::p4est::types::quadrant p4est_child[GeometryInfo::max_children_per_cell]; for (unsigned int c=0; - c::max_children_per_cell; ++c) + c::max_children_per_cell; ++c) switch (dim) - { - case 2: - P4EST_QUADRANT_INIT(&p4est_child[c]); - break; - case 3: - P8EST_QUADRANT_INIT(&p4est_child[c]); - break; - default: - Assert (false, ExcNotImplemented()); - } + { + case 2: + P4EST_QUADRANT_INIT(&p4est_child[c]); + break; + case 3: + P8EST_QUADRANT_INIT(&p4est_child[c]); + break; + default: + Assert (false, ExcNotImplemented()); + } internal::p4est::functions:: quadrant_childrenv (&this_quadrant, p4est_child); for (unsigned int c=0; - c::max_children_per_cell; ++c) + c::max_children_per_cell; ++c) { - match_quadrant_recursively (p4est_child[c], dealii_cell->child(c), ghost_quadrant, forest, ghost_owner); + match_quadrant_recursively (p4est_child[c], dealii_cell->child(c), ghost_quadrant, forest, ghost_owner); } @@ -1123,160 +1123,160 @@ namespace template void attach_mesh_data_recursively (const typename internal::p4est::types::tree &tree, - const typename Triangulation::cell_iterator &dealii_cell, - const typename internal::p4est::types::quadrant &p4est_cell, - const typename std::list::cell_iterator, - typename parallel::distributed::Triangulation::CellStatus, - void*) - > > > &attached_data_pack_callbacks) + const typename Triangulation::cell_iterator &dealii_cell, + const typename internal::p4est::types::quadrant &p4est_cell, + const typename std::list::cell_iterator, + typename parallel::distributed::Triangulation::CellStatus, + void*) + > > > &attached_data_pack_callbacks) { typedef std::list::cell_iterator, - typename parallel::distributed::Triangulation::CellStatus, - void*) + typename parallel::distributed::Triangulation::CellStatus, + void*) > > > callback_list_t; int idx = sc_array_bsearch(const_cast(&tree.quadrants), - &p4est_cell, - internal::p4est::functions::quadrant_compare); + &p4est_cell, + internal::p4est::functions::quadrant_compare); if (idx == -1 && (internal::p4est::functions:: - quadrant_overlaps_tree (const_cast::tree*>(&tree), - &p4est_cell) - == false)) + quadrant_overlaps_tree (const_cast::tree*>(&tree), + &p4est_cell) + == false)) return; //this quadrant and none of it's childs belongs to us. bool p4est_has_children = (idx == -1); if (p4est_has_children && dealii_cell->has_children()) { - //recurse further - typename internal::p4est::types::quadrant - p4est_child[GeometryInfo::max_children_per_cell]; - for (unsigned int c=0; c::max_children_per_cell; ++c) - switch (dim) - { - case 2: - P4EST_QUADRANT_INIT(&p4est_child[c]); - break; - case 3: - P8EST_QUADRANT_INIT(&p4est_child[c]); - break; - default: - Assert (false, ExcNotImplemented()); - } - - internal::p4est::functions:: - quadrant_childrenv (&p4est_cell, p4est_child); - - for (unsigned int c=0; - c::max_children_per_cell; ++c) - { - attach_mesh_data_recursively (tree, - dealii_cell->child(c), - p4est_child[c], - attached_data_pack_callbacks); - } + //recurse further + typename internal::p4est::types::quadrant + p4est_child[GeometryInfo::max_children_per_cell]; + for (unsigned int c=0; c::max_children_per_cell; ++c) + switch (dim) + { + case 2: + P4EST_QUADRANT_INIT(&p4est_child[c]); + break; + case 3: + P8EST_QUADRANT_INIT(&p4est_child[c]); + break; + default: + Assert (false, ExcNotImplemented()); + } + + internal::p4est::functions:: + quadrant_childrenv (&p4est_cell, p4est_child); + + for (unsigned int c=0; + c::max_children_per_cell; ++c) + { + attach_mesh_data_recursively (tree, + dealii_cell->child(c), + p4est_child[c], + attached_data_pack_callbacks); + } } else if (!p4est_has_children && !dealii_cell->has_children()) { - //this active cell didn't change - typename internal::p4est::types::quadrant *q; - q = static_cast::quadrant*> ( - sc_array_index (const_cast(&tree.quadrants), idx) - ); - *static_cast::CellStatus*>(q->p.user_data) = parallel::distributed::Triangulation::CELL_PERSIST; - - for(typename callback_list_t::const_iterator it = attached_data_pack_callbacks.begin(); - it != attached_data_pack_callbacks.end(); - ++it) - { - void * ptr = static_cast(q->p.user_data) + (*it).first; //add offset - ((*it).second)(dealii_cell, - parallel::distributed::Triangulation::CELL_PERSIST, - ptr); - } + //this active cell didn't change + typename internal::p4est::types::quadrant *q; + q = static_cast::quadrant*> ( + sc_array_index (const_cast(&tree.quadrants), idx) + ); + *static_cast::CellStatus*>(q->p.user_data) = parallel::distributed::Triangulation::CELL_PERSIST; + + for(typename callback_list_t::const_iterator it = attached_data_pack_callbacks.begin(); + it != attached_data_pack_callbacks.end(); + ++it) + { + void * ptr = static_cast(q->p.user_data) + (*it).first; //add offset + ((*it).second)(dealii_cell, + parallel::distributed::Triangulation::CELL_PERSIST, + ptr); + } } else if (p4est_has_children) { - //this cell got refined - - //attach to the first child, because - // we can only attach to active - // quadrants - typename internal::p4est::types::quadrant - p4est_child[GeometryInfo::max_children_per_cell]; - for (unsigned int c=0; c::max_children_per_cell; ++c) - switch (dim) - { - case 2: - P4EST_QUADRANT_INIT(&p4est_child[c]); - break; - case 3: - P8EST_QUADRANT_INIT(&p4est_child[c]); - break; - default: - Assert (false, ExcNotImplemented()); - } - - internal::p4est::functions:: - quadrant_childrenv (&p4est_cell, p4est_child); - int child0_idx = sc_array_bsearch(const_cast(&tree.quadrants), - &p4est_child[0], - internal::p4est::functions::quadrant_compare); - Assert(child0_idx != -1, ExcMessage("the first child should exist as an active quadrant!")); - - typename internal::p4est::types::quadrant *q; - q = static_cast::quadrant*> ( - sc_array_index (const_cast(&tree.quadrants), child0_idx) - ); - *static_cast::CellStatus*>(q->p.user_data) = parallel::distributed::Triangulation::CELL_REFINE; - - for(typename callback_list_t::const_iterator it = attached_data_pack_callbacks.begin(); - it != attached_data_pack_callbacks.end(); - ++it) - { - void * ptr = static_cast(q->p.user_data) + (*it).first; //add offset - - ((*it).second)(dealii_cell, - parallel::distributed::Triangulation::CELL_REFINE, - ptr); - } - - //mark other childs as invalid, so that unpack only happens once - for (unsigned int i=1;i::max_children_per_cell; ++i) - { - int child_idx = sc_array_bsearch(const_cast(&tree.quadrants), - &p4est_child[i], - internal::p4est::functions::quadrant_compare); - q = static_cast::quadrant*> ( - sc_array_index (const_cast(&tree.quadrants), child_idx) - ); - *static_cast::CellStatus*>(q->p.user_data) = parallel::distributed::Triangulation::CELL_INVALID; - } + //this cell got refined + + //attach to the first child, because + // we can only attach to active + // quadrants + typename internal::p4est::types::quadrant + p4est_child[GeometryInfo::max_children_per_cell]; + for (unsigned int c=0; c::max_children_per_cell; ++c) + switch (dim) + { + case 2: + P4EST_QUADRANT_INIT(&p4est_child[c]); + break; + case 3: + P8EST_QUADRANT_INIT(&p4est_child[c]); + break; + default: + Assert (false, ExcNotImplemented()); + } + + internal::p4est::functions:: + quadrant_childrenv (&p4est_cell, p4est_child); + int child0_idx = sc_array_bsearch(const_cast(&tree.quadrants), + &p4est_child[0], + internal::p4est::functions::quadrant_compare); + Assert(child0_idx != -1, ExcMessage("the first child should exist as an active quadrant!")); + + typename internal::p4est::types::quadrant *q; + q = static_cast::quadrant*> ( + sc_array_index (const_cast(&tree.quadrants), child0_idx) + ); + *static_cast::CellStatus*>(q->p.user_data) = parallel::distributed::Triangulation::CELL_REFINE; + + for(typename callback_list_t::const_iterator it = attached_data_pack_callbacks.begin(); + it != attached_data_pack_callbacks.end(); + ++it) + { + void * ptr = static_cast(q->p.user_data) + (*it).first; //add offset + + ((*it).second)(dealii_cell, + parallel::distributed::Triangulation::CELL_REFINE, + ptr); + } + + //mark other childs as invalid, so that unpack only happens once + for (unsigned int i=1;i::max_children_per_cell; ++i) + { + int child_idx = sc_array_bsearch(const_cast(&tree.quadrants), + &p4est_child[i], + internal::p4est::functions::quadrant_compare); + q = static_cast::quadrant*> ( + sc_array_index (const_cast(&tree.quadrants), child_idx) + ); + *static_cast::CellStatus*>(q->p.user_data) = parallel::distributed::Triangulation::CELL_INVALID; + } } else { - //it's children got coarsened into - //this cell - typename internal::p4est::types::quadrant *q; - q = static_cast::quadrant*> ( - sc_array_index (const_cast(&tree.quadrants), idx) - ); - *static_cast::CellStatus*>(q->p.user_data) = parallel::distributed::Triangulation::CELL_COARSEN; - - for(typename callback_list_t::const_iterator it = attached_data_pack_callbacks.begin(); - it != attached_data_pack_callbacks.end(); - ++it) - { - void * ptr = static_cast(q->p.user_data) + (*it).first; //add offset - ((*it).second)(dealii_cell, - parallel::distributed::Triangulation::CELL_COARSEN, - ptr); - } + //it's children got coarsened into + //this cell + typename internal::p4est::types::quadrant *q; + q = static_cast::quadrant*> ( + sc_array_index (const_cast(&tree.quadrants), idx) + ); + *static_cast::CellStatus*>(q->p.user_data) = parallel::distributed::Triangulation::CELL_COARSEN; + + for(typename callback_list_t::const_iterator it = attached_data_pack_callbacks.begin(); + it != attached_data_pack_callbacks.end(); + ++it) + { + void * ptr = static_cast(q->p.user_data) + (*it).first; //add offset + ((*it).second)(dealii_cell, + parallel::distributed::Triangulation::CELL_COARSEN, + ptr); + } } } @@ -1284,155 +1284,155 @@ namespace template void post_mesh_data_recursively (const typename internal::p4est::types::tree &tree, - const typename Triangulation::cell_iterator &dealii_cell, - const typename Triangulation::cell_iterator &parent_cell, - const typename internal::p4est::types::quadrant &p4est_cell, - const unsigned int offset, - const typename std_cxx1x::function< - void(typename parallel::distributed::Triangulation::cell_iterator, typename parallel::distributed::Triangulation::CellStatus, void*) - > &unpack_callback) + const typename Triangulation::cell_iterator &dealii_cell, + const typename Triangulation::cell_iterator &parent_cell, + const typename internal::p4est::types::quadrant &p4est_cell, + const unsigned int offset, + const typename std_cxx1x::function< + void(typename parallel::distributed::Triangulation::cell_iterator, typename parallel::distributed::Triangulation::CellStatus, void*) + > &unpack_callback) { int idx = sc_array_bsearch(const_cast(&tree.quadrants), - &p4est_cell, - internal::p4est::functions::quadrant_compare); + &p4est_cell, + internal::p4est::functions::quadrant_compare); if (idx == -1 && (internal::p4est::functions:: - quadrant_overlaps_tree (const_cast::tree*>(&tree), - &p4est_cell) - == false)) - // this quadrant and none of - // it's children belong to us. + quadrant_overlaps_tree (const_cast::tree*>(&tree), + &p4est_cell) + == false)) + // this quadrant and none of + // it's children belong to us. return; const bool p4est_has_children = (idx == -1); if (p4est_has_children) { - Assert(dealii_cell->has_children(), ExcInternalError()); - - //recurse further - typename internal::p4est::types::quadrant - p4est_child[GeometryInfo::max_children_per_cell]; - for (unsigned int c=0; c::max_children_per_cell; ++c) - switch (dim) - { - case 2: - P4EST_QUADRANT_INIT(&p4est_child[c]); - break; - case 3: - P8EST_QUADRANT_INIT(&p4est_child[c]); - break; - default: - Assert (false, ExcNotImplemented()); - } - - internal::p4est::functions:: - quadrant_childrenv (&p4est_cell, p4est_child); - - for (unsigned int c=0; - c::max_children_per_cell; ++c) - { - post_mesh_data_recursively (tree, - dealii_cell->child(c), - dealii_cell, - p4est_child[c], - offset, - unpack_callback); - } + Assert(dealii_cell->has_children(), ExcInternalError()); + + //recurse further + typename internal::p4est::types::quadrant + p4est_child[GeometryInfo::max_children_per_cell]; + for (unsigned int c=0; c::max_children_per_cell; ++c) + switch (dim) + { + case 2: + P4EST_QUADRANT_INIT(&p4est_child[c]); + break; + case 3: + P8EST_QUADRANT_INIT(&p4est_child[c]); + break; + default: + Assert (false, ExcNotImplemented()); + } + + internal::p4est::functions:: + quadrant_childrenv (&p4est_cell, p4est_child); + + for (unsigned int c=0; + c::max_children_per_cell; ++c) + { + post_mesh_data_recursively (tree, + dealii_cell->child(c), + dealii_cell, + p4est_child[c], + offset, + unpack_callback); + } } else { - Assert(! dealii_cell->has_children(), ExcInternalError()); - - typename internal::p4est::types::quadrant *q; - q = static_cast::quadrant*> ( - sc_array_index (const_cast(&tree.quadrants), idx) - ); - - void * ptr = static_cast(q->p.user_data) + offset; - typename parallel::distributed::Triangulation::CellStatus - status = * static_cast< - typename parallel::distributed::Triangulation::CellStatus* - >(q->p.user_data); - switch (status) - { - case parallel::distributed::Triangulation::CELL_PERSIST: - { - unpack_callback(dealii_cell, status, ptr); - break; - } - case parallel::distributed::Triangulation::CELL_REFINE: - { - unpack_callback(parent_cell, status, ptr); - break; - } - case parallel::distributed::Triangulation::CELL_COARSEN: - { - unpack_callback(dealii_cell, status, ptr); - break; - } - case parallel::distributed::Triangulation::CELL_INVALID: - { - break; - } - default: - AssertThrow (false, ExcInternalError()); - } + Assert(! dealii_cell->has_children(), ExcInternalError()); + + typename internal::p4est::types::quadrant *q; + q = static_cast::quadrant*> ( + sc_array_index (const_cast(&tree.quadrants), idx) + ); + + void * ptr = static_cast(q->p.user_data) + offset; + typename parallel::distributed::Triangulation::CellStatus + status = * static_cast< + typename parallel::distributed::Triangulation::CellStatus* + >(q->p.user_data); + switch (status) + { + case parallel::distributed::Triangulation::CELL_PERSIST: + { + unpack_callback(dealii_cell, status, ptr); + break; + } + case parallel::distributed::Triangulation::CELL_REFINE: + { + unpack_callback(parent_cell, status, ptr); + break; + } + case parallel::distributed::Triangulation::CELL_COARSEN: + { + unpack_callback(dealii_cell, status, ptr); + break; + } + case parallel::distributed::Triangulation::CELL_INVALID: + { + break; + } + default: + AssertThrow (false, ExcInternalError()); + } } } - /** - * A data structure that we use to store - * which cells (indicated by - * internal::p4est::types::quadrant objects) shall be - * refined and which shall be coarsened. - */ + /** + * A data structure that we use to store + * which cells (indicated by + * internal::p4est::types::quadrant objects) shall be + * refined and which shall be coarsened. + */ template class RefineAndCoarsenList { public: RefineAndCoarsenList (const Triangulation &triangulation, - const std::vector &p4est_tree_to_coarse_cell_permutation, - const types::subdomain_id_t my_subdomain, - typename internal::p4est::types::forest &forest); - - /** - * A callback function that we - * pass to the p4est data - * structures when a forest is - * to be refined. The p4est - * functions call it back with - * a tree (the index of the - * tree that grows out of a - * given coarse cell) and a - * refinement path from that - * coarse cell to a - * terminal/leaf cell. The - * function returns whether the - * corresponding cell in the - * deal.II triangulation has - * the refined flag set. - */ + const std::vector &p4est_tree_to_coarse_cell_permutation, + const types::subdomain_id_t my_subdomain, + typename internal::p4est::types::forest &forest); + + /** + * A callback function that we + * pass to the p4est data + * structures when a forest is + * to be refined. The p4est + * functions call it back with + * a tree (the index of the + * tree that grows out of a + * given coarse cell) and a + * refinement path from that + * coarse cell to a + * terminal/leaf cell. The + * function returns whether the + * corresponding cell in the + * deal.II triangulation has + * the refined flag set. + */ static int refine_callback (typename internal::p4est::types::forest *forest, - typename internal::p4est::types::topidx coarse_cell_index, - typename internal::p4est::types::quadrant *quadrant); - - /** - * Same as the refine_callback - * function, but return whether - * all four of the given - * children of a non-terminal - * cell are to be coarsened - * away. - */ + typename internal::p4est::types::topidx coarse_cell_index, + typename internal::p4est::types::quadrant *quadrant); + + /** + * Same as the refine_callback + * function, but return whether + * all four of the given + * children of a non-terminal + * cell are to be coarsened + * away. + */ static int coarsen_callback (typename internal::p4est::types::forest *forest, - typename internal::p4est::types::topidx coarse_cell_index, - typename internal::p4est::types::quadrant *children[]); + typename internal::p4est::types::topidx coarse_cell_index, + typename internal::p4est::types::quadrant *children[]); bool pointers_are_at_end () const; @@ -1446,8 +1446,8 @@ namespace typename internal::p4est::types::forest forest; void build_lists (const typename Triangulation::cell_iterator &cell, - const typename internal::p4est::types::quadrant &p4est_cell, - const unsigned int myid); + const typename internal::p4est::types::quadrant &p4est_cell, + const unsigned int myid); }; @@ -1458,8 +1458,8 @@ namespace pointers_are_at_end () const { return ((current_refine_pointer == refine_list.end()) - && - (current_coarsen_pointer == coarsen_list.end())); + && + (current_coarsen_pointer == coarsen_list.end())); } @@ -1467,81 +1467,81 @@ namespace template RefineAndCoarsenList:: RefineAndCoarsenList (const Triangulation &triangulation, - const std::vector &p4est_tree_to_coarse_cell_permutation, - const types::subdomain_id_t my_subdomain, - typename internal::p4est::types::forest &forest) - : - forest(forest) + const std::vector &p4est_tree_to_coarse_cell_permutation, + const types::subdomain_id_t my_subdomain, + typename internal::p4est::types::forest &forest) + : + forest(forest) { - // count how many flags are set and - // allocate that much memory + // count how many flags are set and + // allocate that much memory unsigned int n_refine_flags = 0, - n_coarsen_flags = 0; + n_coarsen_flags = 0; for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell != triangulation.end(); ++cell) + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell) { - //skip cells that are not local - if (cell->subdomain_id() != my_subdomain) - continue; - - if (cell->refine_flag_set()) - ++n_refine_flags; - else if (cell->coarsen_flag_set()) - ++n_coarsen_flags; + //skip cells that are not local + if (cell->subdomain_id() != my_subdomain) + continue; + + if (cell->refine_flag_set()) + ++n_refine_flags; + else if (cell->coarsen_flag_set()) + ++n_coarsen_flags; } refine_list.reserve (n_refine_flags); coarsen_list.reserve (n_coarsen_flags); - // now build the lists of cells that - // are flagged. note that p4est will - // traverse its cells in the order in - // which trees appear in the - // forest. this order is not the same - // as the order of coarse cells in the - // deal.II Triangulation because we - // have translated everything by the - // coarse_cell_to_p4est_tree_permutation - // permutation. in order to make sure - // that the output array is already in - // the correct order, traverse our - // coarse cells in the same order in - // which p4est will: + // now build the lists of cells that + // are flagged. note that p4est will + // traverse its cells in the order in + // which trees appear in the + // forest. this order is not the same + // as the order of coarse cells in the + // deal.II Triangulation because we + // have translated everything by the + // coarse_cell_to_p4est_tree_permutation + // permutation. in order to make sure + // that the output array is already in + // the correct order, traverse our + // coarse cells in the same order in + // which p4est will: for (unsigned int c=0; c::cell_iterator - cell (&triangulation, 0, coarse_cell_index); - - typename internal::p4est::types::quadrant p4est_cell; - internal::p4est::functions:: - quadrant_set_morton (&p4est_cell, - /*level=*/0, - /*index=*/0); - p4est_cell.p.which_tree = c; - build_lists (cell, p4est_cell, my_subdomain); + unsigned int coarse_cell_index = + p4est_tree_to_coarse_cell_permutation[c]; + + const typename Triangulation::cell_iterator + cell (&triangulation, 0, coarse_cell_index); + + typename internal::p4est::types::quadrant p4est_cell; + internal::p4est::functions:: + quadrant_set_morton (&p4est_cell, + /*level=*/0, + /*index=*/0); + p4est_cell.p.which_tree = c; + build_lists (cell, p4est_cell, my_subdomain); } Assert(refine_list.size() == n_refine_flags, - ExcInternalError()); + ExcInternalError()); Assert(coarsen_list.size() == n_coarsen_flags, - ExcInternalError()); + ExcInternalError()); - // make sure that our ordering in fact - // worked + // make sure that our ordering in fact + // worked for (unsigned int i=1; i= - refine_list[i-1].p.which_tree, - ExcInternalError()); + refine_list[i-1].p.which_tree, + ExcInternalError()); for (unsigned int i=1; i= - coarsen_list[i-1].p.which_tree, - ExcInternalError()); + coarsen_list[i-1].p.which_tree, + ExcInternalError()); current_refine_pointer = refine_list.begin(); current_coarsen_pointer = coarsen_list.begin(); @@ -1553,46 +1553,46 @@ namespace void RefineAndCoarsenList:: build_lists (const typename Triangulation::cell_iterator &cell, - const typename internal::p4est::types::quadrant &p4est_cell, - const types::subdomain_id_t my_subdomain) + const typename internal::p4est::types::quadrant &p4est_cell, + const types::subdomain_id_t my_subdomain) { if (!cell->has_children()) { - if (cell->subdomain_id() == my_subdomain) - { - if (cell->refine_flag_set()) - refine_list.push_back (p4est_cell); - else if (cell->coarsen_flag_set()) - coarsen_list.push_back (p4est_cell); - } + if (cell->subdomain_id() == my_subdomain) + { + if (cell->refine_flag_set()) + refine_list.push_back (p4est_cell); + else if (cell->coarsen_flag_set()) + coarsen_list.push_back (p4est_cell); + } } else { - typename internal::p4est::types::quadrant - p4est_child[GeometryInfo::max_children_per_cell]; - for (unsigned int c=0; c::max_children_per_cell; ++c) - switch (dim) - { - case 2: - P4EST_QUADRANT_INIT(&p4est_child[c]); - break; - case 3: - P8EST_QUADRANT_INIT(&p4est_child[c]); - break; - default: - Assert (false, ExcNotImplemented()); - } - internal::p4est::functions:: - quadrant_childrenv (&p4est_cell, - p4est_child); - for (unsigned int c=0; - c::max_children_per_cell; ++c) - { - p4est_child[c].p.which_tree = p4est_cell.p.which_tree; - build_lists (cell->child(c), - p4est_child[c], - my_subdomain); - } + typename internal::p4est::types::quadrant + p4est_child[GeometryInfo::max_children_per_cell]; + for (unsigned int c=0; c::max_children_per_cell; ++c) + switch (dim) + { + case 2: + P4EST_QUADRANT_INIT(&p4est_child[c]); + break; + case 3: + P8EST_QUADRANT_INIT(&p4est_child[c]); + break; + default: + Assert (false, ExcNotImplemented()); + } + internal::p4est::functions:: + quadrant_childrenv (&p4est_cell, + p4est_child); + for (unsigned int c=0; + c::max_children_per_cell; ++c) + { + p4est_child[c].p.which_tree = p4est_cell.p.which_tree; + build_lists (cell->child(c), + p4est_child[c], + my_subdomain); + } } } @@ -1601,53 +1601,53 @@ namespace int RefineAndCoarsenList:: refine_callback (typename internal::p4est::types::forest *forest, - typename internal::p4est::types::topidx coarse_cell_index, - typename internal::p4est::types::quadrant *quadrant) + typename internal::p4est::types::topidx coarse_cell_index, + typename internal::p4est::types::quadrant *quadrant) { RefineAndCoarsenList *this_object = reinterpret_cast*>(forest->user_pointer); - // if there are no more cells in our - // list the current cell can't be - // flagged for refinement + // if there are no more cells in our + // list the current cell can't be + // flagged for refinement if (this_object->current_refine_pointer == this_object->refine_list.end()) return false; Assert (coarse_cell_index <= - this_object->current_refine_pointer->p.which_tree, - ExcInternalError()); + this_object->current_refine_pointer->p.which_tree, + ExcInternalError()); - // if p4est hasn't yet reached the tree - // of the next flagged cell the current - // cell can't be flagged for refinement + // if p4est hasn't yet reached the tree + // of the next flagged cell the current + // cell can't be flagged for refinement if (coarse_cell_index < - this_object->current_refine_pointer->p.which_tree) + this_object->current_refine_pointer->p.which_tree) return false; - // now we're in the right tree in the - // forest + // now we're in the right tree in the + // forest Assert (coarse_cell_index <= - this_object->current_refine_pointer->p.which_tree, - ExcInternalError()); + this_object->current_refine_pointer->p.which_tree, + ExcInternalError()); - // make sure that the p4est loop over - // cells hasn't gotten ahead of our own - // pointer + // make sure that the p4est loop over + // cells hasn't gotten ahead of our own + // pointer Assert (internal::p4est::functions:: - quadrant_compare (quadrant, - &*this_object->current_refine_pointer) <= 0, - ExcInternalError()); + quadrant_compare (quadrant, + &*this_object->current_refine_pointer) <= 0, + ExcInternalError()); - // now, if the p4est cell is one in the - // list, it is supposed to be refined + // now, if the p4est cell is one in the + // list, it is supposed to be refined if (internal::p4est::functions:: - quadrant_is_equal (quadrant, &*this_object->current_refine_pointer)) + quadrant_is_equal (quadrant, &*this_object->current_refine_pointer)) { - ++this_object->current_refine_pointer; - return true; + ++this_object->current_refine_pointer; + return true; } - // p4est cell is not in list + // p4est cell is not in list return false; } @@ -1657,70 +1657,70 @@ namespace int RefineAndCoarsenList:: coarsen_callback (typename internal::p4est::types::forest *forest, - typename internal::p4est::types::topidx coarse_cell_index, - typename internal::p4est::types::quadrant *children[]) + typename internal::p4est::types::topidx coarse_cell_index, + typename internal::p4est::types::quadrant *children[]) { RefineAndCoarsenList *this_object = reinterpret_cast*>(forest->user_pointer); - // if there are no more cells in our - // list the current cell can't be - // flagged for coarsening + // if there are no more cells in our + // list the current cell can't be + // flagged for coarsening if (this_object->current_coarsen_pointer == - this_object->coarsen_list.end()) + this_object->coarsen_list.end()) return false; Assert (coarse_cell_index <= - this_object->current_coarsen_pointer->p.which_tree, - ExcInternalError()); + this_object->current_coarsen_pointer->p.which_tree, + ExcInternalError()); - // if p4est hasn't yet reached the tree - // of the next flagged cell the current - // cell can't be flagged for coarsening + // if p4est hasn't yet reached the tree + // of the next flagged cell the current + // cell can't be flagged for coarsening if (coarse_cell_index < - this_object->current_coarsen_pointer->p.which_tree) + this_object->current_coarsen_pointer->p.which_tree) return false; - // now we're in the right tree in the - // forest + // now we're in the right tree in the + // forest Assert (coarse_cell_index <= - this_object->current_coarsen_pointer->p.which_tree, - ExcInternalError()); + this_object->current_coarsen_pointer->p.which_tree, + ExcInternalError()); - // make sure that the p4est loop over - // cells hasn't gotten ahead of our own - // pointer + // make sure that the p4est loop over + // cells hasn't gotten ahead of our own + // pointer Assert (internal::p4est::functions:: - quadrant_compare (children[0], - &*this_object->current_coarsen_pointer) <= 0, - ExcInternalError()); + quadrant_compare (children[0], + &*this_object->current_coarsen_pointer) <= 0, + ExcInternalError()); - // now, if the p4est cell is one in the - // list, it is supposed to be coarsened + // now, if the p4est cell is one in the + // list, it is supposed to be coarsened if (internal::p4est::functions:: - quadrant_is_equal (children[0], - &*this_object->current_coarsen_pointer)) + quadrant_is_equal (children[0], + &*this_object->current_coarsen_pointer)) { - // move current pointer one up - ++this_object->current_coarsen_pointer; - - // note that the next 3 cells in - // our list need to correspond to - // the other siblings of the cell - // we have just found - for (unsigned int c=1; c::max_children_per_cell; ++c) - { - Assert (internal::p4est::functions:: - quadrant_is_equal (children[c], - &*this_object->current_coarsen_pointer), - ExcInternalError()); - ++this_object->current_coarsen_pointer; - } - - return true; + // move current pointer one up + ++this_object->current_coarsen_pointer; + + // note that the next 3 cells in + // our list need to correspond to + // the other siblings of the cell + // we have just found + for (unsigned int c=1; c::max_children_per_cell; ++c) + { + Assert (internal::p4est::functions:: + quadrant_is_equal (children[c], + &*this_object->current_coarsen_pointer), + ExcInternalError()); + ++this_object->current_coarsen_pointer; + } + + return true; } - // p4est cell is not in list + // p4est cell is not in list return false; } } @@ -1734,52 +1734,52 @@ namespace internal struct InitFinalize { private: - struct Singleton - { - Singleton () - { - // ensure that the - // initialization - // code is run only - // once, even if we - // link with 1d, 2d, - // and 3d libraries - static bool initialized = false; - - if (initialized == false) - { - sc_init (MPI_COMM_WORLD, - 0, 0, 0, SC_LP_SILENT); - p4est_init (0, SC_LP_SILENT); - - initialized = true; - } - } - - ~Singleton () - { - // same here - static bool deinitialized = false; - - if (deinitialized == false) - { - // p4est has no - // p4est_finalize - // function - sc_finalize (); - - deinitialized = true; - } - } - }; + struct Singleton + { + Singleton () + { + // ensure that the + // initialization + // code is run only + // once, even if we + // link with 1d, 2d, + // and 3d libraries + static bool initialized = false; + + if (initialized == false) + { + sc_init (MPI_COMM_WORLD, + 0, 0, 0, SC_LP_SILENT); + p4est_init (0, SC_LP_SILENT); + + initialized = true; + } + } + + ~Singleton () + { + // same here + static bool deinitialized = false; + + if (deinitialized == false) + { + // p4est has no + // p4est_finalize + // function + sc_finalize (); + + deinitialized = true; + } + } + }; public: - // do run the initialization code, at least the first time around we - // get to this function + // do run the initialization code, at least the first time around we + // get to this function static void do_initialize () - { - static Singleton singleton; - } + { + static Singleton singleton; + } }; } } @@ -1796,34 +1796,34 @@ namespace parallel template Triangulation:: Triangulation (MPI_Comm mpi_communicator, - const typename dealii::Triangulation::MeshSmoothing smooth_grid, - const Settings settings_) - : - // do not check - // for distorted - // cells - dealii::Triangulation - (smooth_grid, - false), - mpi_communicator (Utilities::MPI:: - duplicate_communicator(mpi_communicator)), - settings(settings_), - my_subdomain (Utilities::MPI::this_mpi_process (this->mpi_communicator)), - triangulation_has_content (false), - connectivity (0), - parallel_forest (0), - refinement_in_progress (false), - attached_data_size(0), - n_attached_datas(0), - n_attached_deserialize(0) + const typename dealii::Triangulation::MeshSmoothing smooth_grid, + const Settings settings_) + : + // do not check + // for distorted + // cells + dealii::Triangulation + (smooth_grid, + false), + mpi_communicator (Utilities::MPI:: + duplicate_communicator(mpi_communicator)), + settings(settings_), + my_subdomain (Utilities::MPI::this_mpi_process (this->mpi_communicator)), + triangulation_has_content (false), + connectivity (0), + parallel_forest (0), + refinement_in_progress (false), + attached_data_size(0), + n_attached_datas(0), + n_attached_deserialize(0) { - // initialize p4est. do this in a separate function since it has - // to happen only once, even if we have triangulation objects - // for several different space dimensions + // initialize p4est. do this in a separate function since it has + // to happen only once, even if we have triangulation objects + // for several different space dimensions dealii::internal::p4est::InitFinalize::do_initialize (); number_cache.n_locally_owned_active_cells - .resize (Utilities::MPI::n_mpi_processes (mpi_communicator)); + .resize (Utilities::MPI::n_mpi_processes (mpi_communicator)); } @@ -1834,13 +1834,13 @@ namespace parallel clear (); Assert (triangulation_has_content == false, - ExcInternalError()); + ExcInternalError()); Assert (connectivity == 0, ExcInternalError()); Assert (parallel_forest == 0, ExcInternalError()); Assert (refinement_in_progress == false, ExcInternalError()); - // get rid of the unique - // communicator used here again + // get rid of the unique + // communicator used here again MPI_Comm_free (&mpi_communicator); } @@ -1851,28 +1851,28 @@ namespace parallel void Triangulation:: create_triangulation (const std::vector > &vertices, - const std::vector > &cells, - const SubCellData &subcelldata) + const std::vector > &cells, + const SubCellData &subcelldata) { try - { - dealii::Triangulation:: - create_triangulation (vertices, cells, subcelldata); - } + { + dealii::Triangulation:: + create_triangulation (vertices, cells, subcelldata); + } catch (const typename dealii::Triangulation::DistortedCellList &) - { - // the underlying - // triangulation should not - // be checking for - // distorted cells - AssertThrow (false, ExcInternalError()); - } - - // note that now we have some content in - // the p4est objects and call the - // functions that do the actual work - // (which are dimension dependent, so - // separate) + { + // the underlying + // triangulation should not + // be checking for + // distorted cells + AssertThrow (false, ExcInternalError()); + } + + // note that now we have some content in + // the p4est objects and call the + // functions that do the actual work + // (which are dimension dependent, so + // separate) triangulation_has_content = true; setup_coarse_cell_to_p4est_tree_permutation (); @@ -1880,17 +1880,17 @@ namespace parallel copy_new_triangulation_to_p4est (dealii::internal::int2type()); try - { - copy_local_forest_to_triangulation (); - } + { + copy_local_forest_to_triangulation (); + } catch (const typename Triangulation::DistortedCellList &) - { - // the underlying - // triangulation should not - // be checking for - // distorted cells - AssertThrow (false, ExcInternalError()); - } + { + // the underlying + // triangulation should not + // be checking for + // distorted cells + AssertThrow (false, ExcInternalError()); + } update_number_cache (); } @@ -1904,16 +1904,16 @@ namespace parallel triangulation_has_content = false; if (parallel_forest != 0) - { - dealii::internal::p4est::functions::destroy (parallel_forest); - parallel_forest = 0; - } + { + dealii::internal::p4est::functions::destroy (parallel_forest); + parallel_forest = 0; + } if (connectivity != 0) - { - dealii::internal::p4est::functions::connectivity_destroy (connectivity); - connectivity = 0; - } + { + dealii::internal::p4est::functions::connectivity_destroy (connectivity); + connectivity = 0; + } coarse_cell_to_p4est_tree_permutation.resize (0); p4est_tree_to_coarse_cell_permutation.resize (0); @@ -1933,11 +1933,11 @@ namespace parallel GridTools::get_face_connectivity_of_cells (*this, cell_connectivity); coarse_cell_to_p4est_tree_permutation.resize (this->n_cells(0)); SparsityTools:: - reorder_Cuthill_McKee (cell_connectivity, - coarse_cell_to_p4est_tree_permutation); + reorder_Cuthill_McKee (cell_connectivity, + coarse_cell_to_p4est_tree_permutation); p4est_tree_to_coarse_cell_permutation - = Utilities::invert_permutation (coarse_cell_to_p4est_tree_permutation); + = Utilities::invert_permutation (coarse_cell_to_p4est_tree_permutation); } @@ -1947,9 +1947,9 @@ namespace parallel Triangulation::write_mesh_vtk (const char *file_basename) const { Assert (parallel_forest != 0, - ExcMessage ("Can't produce output when no forest is created yet.")); + ExcMessage ("Can't produce output when no forest is created yet.")); dealii::internal::p4est::functions:: - vtk_write_file (parallel_forest, 0, file_basename); + vtk_write_file (parallel_forest, 0, file_basename); } @@ -1959,36 +1959,36 @@ namespace parallel save(const char* filename) const { Assert(n_attached_deserialize==0, - ExcMessage ("not all SolutionTransfer's got deserialized after the last load()")); + ExcMessage ("not all SolutionTransfer's got deserialized after the last load()")); int real_data_size = 0; if (attached_data_size>0) - real_data_size = attached_data_size+sizeof(CellStatus); + real_data_size = attached_data_size+sizeof(CellStatus); if (my_subdomain==0) - { - std::string fname=std::string(filename)+".info"; - std::ofstream f(fname.c_str()); - f << Utilities::System::get_n_mpi_processes (mpi_communicator) << " " - << real_data_size << " " - << attached_data_pack_callbacks.size() << std::endl; - } + { + std::string fname=std::string(filename)+".info"; + std::ofstream f(fname.c_str()); + f << Utilities::System::get_n_mpi_processes (mpi_communicator) << " " + << real_data_size << " " + << attached_data_pack_callbacks.size() << std::endl; + } if (attached_data_size>0) - { - const_cast*>(this) - ->attach_mesh_data(); - } + { + const_cast*>(this) + ->attach_mesh_data(); + } dealii::internal::p4est::functions::save(filename, parallel_forest, attached_data_size>0); dealii::parallel::distributed::Triangulation* tria - = const_cast*>(this); + = const_cast*>(this); tria->n_attached_datas = 0; tria->attached_data_size = 0; tria->attached_data_pack_callbacks.clear(); - // and release the data + // and release the data void * userptr = parallel_forest->user_pointer; dealii::internal::p4est::functions::reset_data (parallel_forest, 0, NULL, NULL); parallel_forest->user_pointer = userptr; @@ -2007,11 +2007,11 @@ namespace parallel unsigned int numcpus, attached_size, attached_count; { - std::string fname=std::string(filename)+".info"; - std::ifstream f(fname.c_str()); - f >> numcpus >> attached_size >> attached_count; - if (numcpus != Utilities::System::get_n_mpi_processes (mpi_communicator)) - throw ExcInternalError(); + std::string fname=std::string(filename)+".info"; + std::ifstream f(fname.c_str()); + f >> numcpus >> attached_size >> attached_count; + if (numcpus != Utilities::System::get_n_mpi_processes (mpi_communicator)) + throw ExcInternalError(); } attached_data_size = 0; @@ -2019,23 +2019,23 @@ namespace parallel n_attached_deserialize = attached_count; parallel_forest = dealii::internal::p4est::functions::load ( - filename, mpi_communicator, - attached_size, attached_size>0, - this, - &connectivity); + filename, mpi_communicator, + attached_size, attached_size>0, + this, + &connectivity); try - { - copy_local_forest_to_triangulation (); - } + { + copy_local_forest_to_triangulation (); + } catch (const typename Triangulation::DistortedCellList &) - { - // the underlying - // triangulation should not - // be checking for - // distorted cells - AssertThrow (false, ExcInternalError()); - } + { + // the underlying + // triangulation should not + // be checking for + // distorted cells + AssertThrow (false, ExcInternalError()); + } update_number_cache (); } @@ -2047,7 +2047,7 @@ namespace parallel Triangulation::get_checksum () const { Assert (parallel_forest != 0, - ExcMessage ("Can't produce a check sum when no forest is created yet.")); + ExcMessage ("Can't produce a check sum when no forest is created yet.")); return dealii::internal::p4est::functions::checksum (parallel_forest); } @@ -2058,11 +2058,11 @@ namespace parallel init_tree(const int dealii_coarse_cell_index) const { const unsigned int tree_index - = coarse_cell_to_p4est_tree_permutation[dealii_coarse_cell_index]; + = coarse_cell_to_p4est_tree_permutation[dealii_coarse_cell_index]; typename dealii::internal::p4est::types::tree *tree - = static_cast::tree*> - (sc_array_index (parallel_forest->trees, - tree_index)); + = static_cast::tree*> + (sc_array_index (parallel_forest->trees, + tree_index)); return tree; } @@ -2077,76 +2077,76 @@ namespace parallel Assert (this->n_cells(0) > 0, ExcInternalError()); Assert (this->n_levels() == 1, ExcInternalError()); - // data structures that counts how many - // cells touch each vertex - // (vertex_touch_count), and which cells - // touch a given vertex (together with - // the local numbering of that vertex - // within the cells that touch it) + // data structures that counts how many + // cells touch each vertex + // (vertex_touch_count), and which cells + // touch a given vertex (together with + // the local numbering of that vertex + // within the cells that touch it) std::vector vertex_touch_count; std::vector< - std::list< - std::pair::active_cell_iterator, - unsigned int> > > - vertex_to_cell; + std::list< + std::pair::active_cell_iterator, + unsigned int> > > + vertex_to_cell; get_vertex_to_cell_mappings (*this, - vertex_touch_count, - vertex_to_cell); + vertex_touch_count, + vertex_to_cell); const dealii::internal::p4est::types<2>::locidx - num_vtt = std::accumulate (vertex_touch_count.begin(), - vertex_touch_count.end(), - 0); - - // now create a connectivity - // object with the right sizes - // for all arrays. set vertex - // information only in debug - // mode (saves a few bytes in - // optimized mode) + num_vtt = std::accumulate (vertex_touch_count.begin(), + vertex_touch_count.end(), + 0); + + // now create a connectivity + // object with the right sizes + // for all arrays. set vertex + // information only in debug + // mode (saves a few bytes in + // optimized mode) const bool set_vertex_info #ifdef DEBUG - = true + = true #else - = false + = false #endif - ; + ; connectivity - = dealii::internal::p4est::functions<2>:: - connectivity_new ((set_vertex_info == true ? this->n_vertices() : 0), - this->n_cells(0), - this->n_vertices(), - num_vtt); + = dealii::internal::p4est::functions<2>:: + connectivity_new ((set_vertex_info == true ? this->n_vertices() : 0), + this->n_cells(0), + this->n_vertices(), + num_vtt); set_vertex_and_cell_info (*this, - vertex_touch_count, - vertex_to_cell, - coarse_cell_to_p4est_tree_permutation, - set_vertex_info, - connectivity); + vertex_touch_count, + vertex_to_cell, + coarse_cell_to_p4est_tree_permutation, + set_vertex_info, + connectivity); Assert (p4est_connectivity_is_valid (connectivity) == 1, - ExcInternalError()); + ExcInternalError()); - // now create a forest out of the - // connectivity data structure + // now create a forest out of the + // connectivity data structure parallel_forest - = dealii::internal::p4est::functions<2>:: - new_forest (mpi_communicator, - connectivity, - /* minimum initial number of quadrants per tree */ 0, + = dealii::internal::p4est::functions<2>:: + new_forest (mpi_communicator, + connectivity, + /* minimum initial number of quadrants per tree */ 0, /* minimum level of upfront refinement */ 0, /* use uniform upfront refinement */ 1, - /* user_data_size = */ 0, - /* user_data_constructor = */ NULL, - /* user_pointer */ this); + /* user_data_size = */ 0, + /* user_data_constructor = */ NULL, + /* user_pointer */ this); } - // TODO: This is a verbatim copy of the 2,2 - // case. However, we can't just specialize the - // dim template argument, but let spacedim open + // TODO: This is a verbatim copy of the 2,2 + // case. However, we can't just specialize the + // dim template argument, but let spacedim open template <> void Triangulation<2,3>::copy_new_triangulation_to_p4est (dealii::internal::int2type<2>) @@ -2155,69 +2155,69 @@ namespace parallel Assert (this->n_cells(0) > 0, ExcInternalError()); Assert (this->n_levels() == 1, ExcInternalError()); - // data structures that counts how many - // cells touch each vertex - // (vertex_touch_count), and which cells - // touch a given vertex (together with - // the local numbering of that vertex - // within the cells that touch it) + // data structures that counts how many + // cells touch each vertex + // (vertex_touch_count), and which cells + // touch a given vertex (together with + // the local numbering of that vertex + // within the cells that touch it) std::vector vertex_touch_count; std::vector< - std::list< - std::pair::active_cell_iterator, - unsigned int> > > - vertex_to_cell; + std::list< + std::pair::active_cell_iterator, + unsigned int> > > + vertex_to_cell; get_vertex_to_cell_mappings (*this, - vertex_touch_count, - vertex_to_cell); + vertex_touch_count, + vertex_to_cell); const dealii::internal::p4est::types<2>::locidx - num_vtt = std::accumulate (vertex_touch_count.begin(), - vertex_touch_count.end(), - 0); - - // now create a connectivity - // object with the right sizes - // for all arrays. set vertex - // information only in debug - // mode (saves a few bytes in - // optimized mode) + num_vtt = std::accumulate (vertex_touch_count.begin(), + vertex_touch_count.end(), + 0); + + // now create a connectivity + // object with the right sizes + // for all arrays. set vertex + // information only in debug + // mode (saves a few bytes in + // optimized mode) const bool set_vertex_info #ifdef DEBUG - = true + = true #else - = false + = false #endif - ; + ; connectivity - = dealii::internal::p4est::functions<2>:: - connectivity_new ((set_vertex_info == true ? this->n_vertices() : 0), - this->n_cells(0), - this->n_vertices(), - num_vtt); + = dealii::internal::p4est::functions<2>:: + connectivity_new ((set_vertex_info == true ? this->n_vertices() : 0), + this->n_cells(0), + this->n_vertices(), + num_vtt); set_vertex_and_cell_info (*this, - vertex_touch_count, - vertex_to_cell, - coarse_cell_to_p4est_tree_permutation, - set_vertex_info, - connectivity); + vertex_touch_count, + vertex_to_cell, + coarse_cell_to_p4est_tree_permutation, + set_vertex_info, + connectivity); Assert (p4est_connectivity_is_valid (connectivity) == 1, - ExcInternalError()); + ExcInternalError()); - // now create a forest out of the - // connectivity data structure + // now create a forest out of the + // connectivity data structure parallel_forest - = dealii::internal::p4est::functions<2>:: - new_forest (mpi_communicator, - connectivity, - /* minimum initial number of quadrants per tree */ 0, + = dealii::internal::p4est::functions<2>:: + new_forest (mpi_communicator, + connectivity, + /* minimum initial number of quadrants per tree */ 0, /* minimum level of upfront refinement */ 0, /* use uniform upfront refinement */ 1, - /* user_data_size = */ 0, - /* user_data_constructor = */ NULL, - /* user_pointer */ this); + /* user_data_size = */ 0, + /* user_data_constructor = */ NULL, + /* user_pointer */ this); } @@ -2230,150 +2230,150 @@ namespace parallel Assert (this->n_cells(0) > 0, ExcInternalError()); Assert (this->n_levels() == 1, ExcInternalError()); - // data structures that counts how many - // cells touch each vertex - // (vertex_touch_count), and which cells - // touch a given vertex (together with - // the local numbering of that vertex - // within the cells that touch it) + // data structures that counts how many + // cells touch each vertex + // (vertex_touch_count), and which cells + // touch a given vertex (together with + // the local numbering of that vertex + // within the cells that touch it) std::vector vertex_touch_count; std::vector< - std::list< - std::pair::active_cell_iterator, - unsigned int> > > - vertex_to_cell; + std::list< + std::pair::active_cell_iterator, + unsigned int> > > + vertex_to_cell; get_vertex_to_cell_mappings (*this, - vertex_touch_count, - vertex_to_cell); + vertex_touch_count, + vertex_to_cell); const dealii::internal::p4est::types<2>::locidx - num_vtt = std::accumulate (vertex_touch_count.begin(), - vertex_touch_count.end(), - 0); + num_vtt = std::accumulate (vertex_touch_count.begin(), + vertex_touch_count.end(), + 0); std::vector edge_touch_count; std::vector< - std::list< - std::pair::active_cell_iterator, - unsigned int> > > - edge_to_cell; + std::list< + std::pair::active_cell_iterator, + unsigned int> > > + edge_to_cell; get_edge_to_cell_mappings (*this, - edge_touch_count, - edge_to_cell); + edge_touch_count, + edge_to_cell); const dealii::internal::p4est::types<2>::locidx - num_ett = std::accumulate (edge_touch_count.begin(), - edge_touch_count.end(), - 0); - // now create a connectivity object with - // the right sizes for all arrays + num_ett = std::accumulate (edge_touch_count.begin(), + edge_touch_count.end(), + 0); + // now create a connectivity object with + // the right sizes for all arrays const bool set_vertex_info #ifdef DEBUG - = true + = true #else - = false + = false #endif - ; + ; connectivity - = dealii::internal::p4est::functions<3>:: - connectivity_new ((set_vertex_info == true ? this->n_vertices() : 0), - this->n_cells(0), - this->n_active_lines(), - num_ett, - this->n_vertices(), - num_vtt); + = dealii::internal::p4est::functions<3>:: + connectivity_new ((set_vertex_info == true ? this->n_vertices() : 0), + this->n_cells(0), + this->n_active_lines(), + num_ett, + this->n_vertices(), + num_vtt); set_vertex_and_cell_info (*this, - vertex_touch_count, - vertex_to_cell, - coarse_cell_to_p4est_tree_permutation, - set_vertex_info, - connectivity); - - // next to tree-to-edge - // data. note that in p4est lines - // are ordered as follows - // *---3---* *---3---* - // /| | / /| - // 6 | 11 6 7 11 - // / 10 | / / | - // * | | *---2---* | - // | *---1---* | | * - // | / / | 9 / - // 8 4 5 8 | 5 - // |/ / | |/ - // *---0---* *---0---* - // whereas in deal.II they are like this: - // *---7---* *---7---* - // /| | / /| - // 4 | 11 4 5 11 - // / 10 | / / | - // * | | *---6---* | - // | *---3---* | | * - // | / / | 9 / - // 8 0 1 8 | 1 - // |/ / | |/ - // *---2---* *---2---* + vertex_touch_count, + vertex_to_cell, + coarse_cell_to_p4est_tree_permutation, + set_vertex_info, + connectivity); + + // next to tree-to-edge + // data. note that in p4est lines + // are ordered as follows + // *---3---* *---3---* + // /| | / /| + // 6 | 11 6 7 11 + // / 10 | / / | + // * | | *---2---* | + // | *---1---* | | * + // | / / | 9 / + // 8 4 5 8 | 5 + // |/ / | |/ + // *---0---* *---0---* + // whereas in deal.II they are like this: + // *---7---* *---7---* + // /| | / /| + // 4 | 11 4 5 11 + // / 10 | / / | + // * | | *---6---* | + // | *---3---* | | * + // | / / | 9 / + // 8 0 1 8 | 1 + // |/ / | |/ + // *---2---* *---2---* const unsigned int deal_to_p4est_line_index[12] - = { 4, 5, 0, 1, 6, 7, 2, 3, 8, 9, 10, 11 } ; + = { 4, 5, 0, 1, 6, 7, 2, 3, 8, 9, 10, 11 } ; for (Triangulation::active_cell_iterator - cell = this->begin_active(); - cell != this->end(); ++cell) - { - const unsigned int - index = coarse_cell_to_p4est_tree_permutation[cell->index()]; - for (unsigned int e=0; e::lines_per_cell; ++e) - connectivity->tree_to_edge[index*GeometryInfo<3>::lines_per_cell+ - deal_to_p4est_line_index[e]] - = cell->line(e)->index(); - } - - // now also set edge-to-tree - // information + cell = this->begin_active(); + cell != this->end(); ++cell) + { + const unsigned int + index = coarse_cell_to_p4est_tree_permutation[cell->index()]; + for (unsigned int e=0; e::lines_per_cell; ++e) + connectivity->tree_to_edge[index*GeometryInfo<3>::lines_per_cell+ + deal_to_p4est_line_index[e]] + = cell->line(e)->index(); + } + + // now also set edge-to-tree + // information connectivity->ett_offset[0] = 0; std::partial_sum (edge_touch_count.begin(), - edge_touch_count.end(), - &connectivity->ett_offset[1]); + edge_touch_count.end(), + &connectivity->ett_offset[1]); Assert (connectivity->ett_offset[this->n_active_lines()] == - num_ett, - ExcInternalError()); + num_ett, + ExcInternalError()); for (unsigned int v=0; vn_active_lines(); ++v) - { - Assert (edge_to_cell[v].size() == edge_touch_count[v], - ExcInternalError()); - - std::list::active_cell_iterator, - unsigned int> >::const_iterator - p = edge_to_cell[v].begin(); - for (unsigned int c=0; cedge_to_tree[connectivity->ett_offset[v]+c] - = coarse_cell_to_p4est_tree_permutation[p->first->index()]; - connectivity->edge_to_edge[connectivity->ett_offset[v]+c] - = deal_to_p4est_line_index[p->second]; - } - } + { + Assert (edge_to_cell[v].size() == edge_touch_count[v], + ExcInternalError()); + + std::list::active_cell_iterator, + unsigned int> >::const_iterator + p = edge_to_cell[v].begin(); + for (unsigned int c=0; cedge_to_tree[connectivity->ett_offset[v]+c] + = coarse_cell_to_p4est_tree_permutation[p->first->index()]; + connectivity->edge_to_edge[connectivity->ett_offset[v]+c] + = deal_to_p4est_line_index[p->second]; + } + } Assert (p8est_connectivity_is_valid (connectivity) == 1, - ExcInternalError()); + ExcInternalError()); - // now create a forest out of the - // connectivity data structure + // now create a forest out of the + // connectivity data structure parallel_forest - = dealii::internal::p4est::functions<3>:: - new_forest (mpi_communicator, - connectivity, - /* minimum initial number of quadrants per tree */ 0, + = dealii::internal::p4est::functions<3>:: + new_forest (mpi_communicator, + connectivity, + /* minimum initial number of quadrants per tree */ 0, /* minimum level of upfront refinement */ 0, /* use uniform upfront refinement */ 1, - /* user_data_size = */ 0, - /* user_data_constructor = */ NULL, - /* user_pointer */ this); + /* user_data_size = */ 0, + /* user_data_constructor = */ NULL, + /* user_pointer */ this); } @@ -2382,32 +2382,32 @@ namespace parallel void Triangulation::copy_local_forest_to_triangulation () { - // disable mesh smoothing for - // recreating the deal.II - // triangulation, otherwise we might - // not be able to reproduce the p4est - // mesh exactly. We restore the - // original smoothing at the end of - // this function. Note that the - // smoothing flag is used in the normal - // refinement process. + // disable mesh smoothing for + // recreating the deal.II + // triangulation, otherwise we might + // not be able to reproduce the p4est + // mesh exactly. We restore the + // original smoothing at the end of + // this function. Note that the + // smoothing flag is used in the normal + // refinement process. typename Triangulation::MeshSmoothing - save_smooth = this->smooth_grid; + save_smooth = this->smooth_grid; this->smooth_grid = dealii::Triangulation::none; bool mesh_changed = false; - // remove all deal.II refinements. Note that we could skip this and - // start from our current state, because the algorithm later coarsens as - // necessary. This has the advantage of being faster when large parts - // of the local partition changes (likely) and gives a deterministic - // ordering of the cells (useful for snapshot/resume). - // TODO: is there a more efficient way to do this? + // remove all deal.II refinements. Note that we could skip this and + // start from our current state, because the algorithm later coarsens as + // necessary. This has the advantage of being faster when large parts + // of the local partition changes (likely) and gives a deterministic + // ordering of the cells (useful for snapshot/resume). + // TODO: is there a more efficient way to do this? if (settings & mesh_reconstruction_after_repartitioning) while (this->begin_active()->level() > 0) { for (typename Triangulation::active_cell_iterator - cell = this->begin_active(); + cell = this->begin_active(); cell != this->end(); ++cell) { @@ -2424,10 +2424,10 @@ namespace parallel } catch (const typename Triangulation::DistortedCellList &) { - // the underlying - // triangulation should not - // be checking for - // distorted cells + // the underlying + // triangulation should not + // be checking for + // distorted cells AssertThrow (false, ExcInternalError()); } @@ -2435,200 +2435,200 @@ namespace parallel } - // query p4est for the ghost cells + // query p4est for the ghost cells typename dealii::internal::p4est::types::ghost * ghostlayer; ghostlayer = dealii::internal::p4est::functions::ghost_new (parallel_forest, - (dim == 2 - ? - typename dealii::internal::p4est::types:: - balance_type(P4EST_BALANCE_CORNER) - : - typename dealii::internal::p4est::types:: - balance_type(P8EST_BALANCE_CORNER))); + (dim == 2 + ? + typename dealii::internal::p4est::types:: + balance_type(P4EST_BALANCE_CORNER) + : + typename dealii::internal::p4est::types:: + balance_type(P8EST_BALANCE_CORNER))); Assert (ghostlayer, ExcInternalError()); - //set all cells to artificial + //set all cells to artificial for (typename Triangulation::cell_iterator - cell = this->begin(0); - cell != this->end(0); - ++cell) - cell->recursively_set_subdomain_id(types::artificial_subdomain_id); + cell = this->begin(0); + cell != this->end(0); + ++cell) + cell->recursively_set_subdomain_id(types::artificial_subdomain_id); do - { - for (typename Triangulation::cell_iterator - cell = this->begin(0); - cell != this->end(0); - ++cell) - { - // if this processor - // stores no part of the - // forest that comes out - // of this coarse grid - // cell, then we need to - // delete all children of - // this cell (the coarse - // grid cell remains) - if (tree_exists_locally(parallel_forest, - coarse_cell_to_p4est_tree_permutation[cell->index()]) - == false) - { - delete_all_children (cell); - cell->set_subdomain_id (types::artificial_subdomain_id); - } - - else - { - - // this processor - // stores at least a - // part of the tree - // that comes out of - // this cell. - - - typename dealii::internal::p4est::types::quadrant p4est_coarse_cell; - typename dealii::internal::p4est::types::tree *tree = - init_tree(cell->index()); - - dealii::internal::p4est::init_coarse_quadrant(p4est_coarse_cell); - - match_tree_recursively (*tree, cell, - p4est_coarse_cell, - *parallel_forest, - my_subdomain); - } - } - - // check mesh for ghostcells, - // refine as neccessary. - // iterate over every ghostquadrant, - // find corresponding deal coarsecell - // and recurse. - typename dealii::internal::p4est::types::quadrant * quadr; - unsigned int ghost_owner=0; - - for (unsigned int g_idx=0;g_idxghosts.elem_count;++g_idx) - { - while (g_idx >= (unsigned int)ghostlayer->proc_offsets[ghost_owner+1]) - ++ghost_owner; - - quadr = static_cast::quadrant *> - ( sc_array_index(&ghostlayer->ghosts, g_idx) ); - - unsigned int coarse_cell_index = - p4est_tree_to_coarse_cell_permutation[quadr->p.piggy3.which_tree]; - - const typename Triangulation::cell_iterator - cell (this, 0U, coarse_cell_index); - - typename dealii::internal::p4est::types::quadrant p4est_coarse_cell; - dealii::internal::p4est::init_coarse_quadrant (p4est_coarse_cell); - - match_quadrant_recursively (p4est_coarse_cell, cell, *quadr, - *parallel_forest, ghost_owner); - } - - // fix all the flags to make - // sure we have a consistent - // mesh - this->prepare_coarsening_and_refinement (); - - // see if any flags are still set - mesh_changed = false; - for (typename Triangulation::active_cell_iterator - cell = this->begin_active(); - cell != this->end(); - ++cell) - if (cell->refine_flag_set() || cell->coarsen_flag_set()) - { - mesh_changed = true; - break; - } - - // actually do the refinement - // but prevent the refinement - // hook below from taking - // over - const bool saved_refinement_in_progress = refinement_in_progress; - refinement_in_progress = true; - - try - { - this->execute_coarsening_and_refinement(); - } - catch (const typename Triangulation::DistortedCellList &) - { - // the underlying - // triangulation should not - // be checking for - // distorted cells - AssertThrow (false, ExcInternalError()); - } - - refinement_in_progress = saved_refinement_in_progress; - } + { + for (typename Triangulation::cell_iterator + cell = this->begin(0); + cell != this->end(0); + ++cell) + { + // if this processor + // stores no part of the + // forest that comes out + // of this coarse grid + // cell, then we need to + // delete all children of + // this cell (the coarse + // grid cell remains) + if (tree_exists_locally(parallel_forest, + coarse_cell_to_p4est_tree_permutation[cell->index()]) + == false) + { + delete_all_children (cell); + cell->set_subdomain_id (types::artificial_subdomain_id); + } + + else + { + + // this processor + // stores at least a + // part of the tree + // that comes out of + // this cell. + + + typename dealii::internal::p4est::types::quadrant p4est_coarse_cell; + typename dealii::internal::p4est::types::tree *tree = + init_tree(cell->index()); + + dealii::internal::p4est::init_coarse_quadrant(p4est_coarse_cell); + + match_tree_recursively (*tree, cell, + p4est_coarse_cell, + *parallel_forest, + my_subdomain); + } + } + + // check mesh for ghostcells, + // refine as neccessary. + // iterate over every ghostquadrant, + // find corresponding deal coarsecell + // and recurse. + typename dealii::internal::p4est::types::quadrant * quadr; + unsigned int ghost_owner=0; + + for (unsigned int g_idx=0;g_idxghosts.elem_count;++g_idx) + { + while (g_idx >= (unsigned int)ghostlayer->proc_offsets[ghost_owner+1]) + ++ghost_owner; + + quadr = static_cast::quadrant *> + ( sc_array_index(&ghostlayer->ghosts, g_idx) ); + + unsigned int coarse_cell_index = + p4est_tree_to_coarse_cell_permutation[quadr->p.piggy3.which_tree]; + + const typename Triangulation::cell_iterator + cell (this, 0U, coarse_cell_index); + + typename dealii::internal::p4est::types::quadrant p4est_coarse_cell; + dealii::internal::p4est::init_coarse_quadrant (p4est_coarse_cell); + + match_quadrant_recursively (p4est_coarse_cell, cell, *quadr, + *parallel_forest, ghost_owner); + } + + // fix all the flags to make + // sure we have a consistent + // mesh + this->prepare_coarsening_and_refinement (); + + // see if any flags are still set + mesh_changed = false; + for (typename Triangulation::active_cell_iterator + cell = this->begin_active(); + cell != this->end(); + ++cell) + if (cell->refine_flag_set() || cell->coarsen_flag_set()) + { + mesh_changed = true; + break; + } + + // actually do the refinement + // but prevent the refinement + // hook below from taking + // over + const bool saved_refinement_in_progress = refinement_in_progress; + refinement_in_progress = true; + + try + { + this->execute_coarsening_and_refinement(); + } + catch (const typename Triangulation::DistortedCellList &) + { + // the underlying + // triangulation should not + // be checking for + // distorted cells + AssertThrow (false, ExcInternalError()); + } + + refinement_in_progress = saved_refinement_in_progress; + } while (mesh_changed); #ifdef DEBUG - // check if correct number of ghosts is created + // check if correct number of ghosts is created unsigned int num_ghosts = 0; for (typename Triangulation::active_cell_iterator - cell = this->begin_active(); - cell != this->end(); - ++cell) - { - if (cell->subdomain_id() != my_subdomain - && - cell->subdomain_id() != types::artificial_subdomain_id) - ++num_ghosts; - } + cell = this->begin_active(); + cell != this->end(); + ++cell) + { + if (cell->subdomain_id() != my_subdomain + && + cell->subdomain_id() != types::artificial_subdomain_id) + ++num_ghosts; + } Assert( num_ghosts == ghostlayer->ghosts.elem_count, ExcInternalError()); #endif - // check that our local copy has - // exactly as many cells as the - // p4est original (at least if we - // are on only one processor); - // for parallel computations, we - // want to check that we have at - // least as many as p4est stores - // locally (in the future we - // should check that we have - // exactly as many non-artificial - // cells as - // parallel_forest->local_num_quadrants) + // check that our local copy has + // exactly as many cells as the + // p4est original (at least if we + // are on only one processor); + // for parallel computations, we + // want to check that we have at + // least as many as p4est stores + // locally (in the future we + // should check that we have + // exactly as many non-artificial + // cells as + // parallel_forest->local_num_quadrants) { - const unsigned int total_local_cells = this->n_active_cells(); - - if (Utilities::MPI::n_mpi_processes (mpi_communicator) == 1) - Assert (static_cast(parallel_forest->local_num_quadrants) == - total_local_cells, - ExcInternalError()) - else - Assert (static_cast(parallel_forest->local_num_quadrants) <= - total_local_cells, - ExcInternalError()); - - // count the number of owned, active - // cells and compare with p4est. - unsigned int n_owned = 0; - for (typename Triangulation::active_cell_iterator - cell = this->begin_active(); - cell != this->end(); ++cell) - { - if (cell->subdomain_id() == my_subdomain) - ++n_owned; - } - - Assert(static_cast(parallel_forest->local_num_quadrants) == - n_owned, ExcInternalError()); + const unsigned int total_local_cells = this->n_active_cells(); + + if (Utilities::MPI::n_mpi_processes (mpi_communicator) == 1) + Assert (static_cast(parallel_forest->local_num_quadrants) == + total_local_cells, + ExcInternalError()) + else + Assert (static_cast(parallel_forest->local_num_quadrants) <= + total_local_cells, + ExcInternalError()); + + // count the number of owned, active + // cells and compare with p4est. + unsigned int n_owned = 0; + for (typename Triangulation::active_cell_iterator + cell = this->begin_active(); + cell != this->end(); ++cell) + { + if (cell->subdomain_id() == my_subdomain) + ++n_owned; + } + + Assert(static_cast(parallel_forest->local_num_quadrants) == + n_owned, ExcInternalError()); } @@ -2643,136 +2643,136 @@ namespace parallel void Triangulation::execute_coarsening_and_refinement () { - // first make sure that recursive - // calls are handled correctly + // first make sure that recursive + // calls are handled correctly if (refinement_in_progress == true) - { - dealii::Triangulation::execute_coarsening_and_refinement (); - return; - } - - // now do the work we're - // supposed to do when we are - // in charge + { + dealii::Triangulation::execute_coarsening_and_refinement (); + return; + } + + // now do the work we're + // supposed to do when we are + // in charge refinement_in_progress = true; this->prepare_coarsening_and_refinement (); - // make sure all flags are - // cleared on cells we don't - // own, since nothing good can - // come of that if they are - // still around + // make sure all flags are + // cleared on cells we don't + // own, since nothing good can + // come of that if they are + // still around for (typename Triangulation::active_cell_iterator - cell = this->begin_active(); - cell != this->end(); ++cell) - if (cell->is_ghost() || cell->is_artificial()) - { - cell->clear_refine_flag (); - cell->clear_coarsen_flag (); - } - else - // if this is a cell we do - // own, make sure they are - // not refined - // anisotropically since we - // don't support this - if (cell->refine_flag_set()) - Assert (cell->refine_flag_set() == - RefinementPossibilities::isotropic_refinement, - ExcMessage ("This class does not support anisotropic refinement")); - - - - // count how many cells will be refined - // and coarsened, and allocate that much - // memory + cell = this->begin_active(); + cell != this->end(); ++cell) + if (cell->is_ghost() || cell->is_artificial()) + { + cell->clear_refine_flag (); + cell->clear_coarsen_flag (); + } + else + // if this is a cell we do + // own, make sure they are + // not refined + // anisotropically since we + // don't support this + if (cell->refine_flag_set()) + Assert (cell->refine_flag_set() == + RefinementPossibilities::isotropic_refinement, + ExcMessage ("This class does not support anisotropic refinement")); + + + + // count how many cells will be refined + // and coarsened, and allocate that much + // memory RefineAndCoarsenList - refine_and_coarsen_list (*this, - p4est_tree_to_coarse_cell_permutation, - my_subdomain, - *parallel_forest); - - // copy refine and coarsen flags into - // p4est and execute the refinement and - // coarsening. this uses the - // refine_and_coarsen_list just built, - // which is communicated to the callback - // functions through the - // user_pointer + refine_and_coarsen_list (*this, + p4est_tree_to_coarse_cell_permutation, + my_subdomain, + *parallel_forest); + + // copy refine and coarsen flags into + // p4est and execute the refinement and + // coarsening. this uses the + // refine_and_coarsen_list just built, + // which is communicated to the callback + // functions through the + // user_pointer Assert (parallel_forest->user_pointer == this, - ExcInternalError()); + ExcInternalError()); parallel_forest->user_pointer = &refine_and_coarsen_list; dealii::internal::p4est::functions:: - refine (parallel_forest, /* refine_recursive */ false, - &RefineAndCoarsenList::refine_callback, - /*init_callback=*/NULL); + refine (parallel_forest, /* refine_recursive */ false, + &RefineAndCoarsenList::refine_callback, + /*init_callback=*/NULL); dealii::internal::p4est::functions:: - coarsen (parallel_forest, /* coarsen_recursive */ false, - &RefineAndCoarsenList::coarsen_callback, - /*init_callback=*/NULL); + coarsen (parallel_forest, /* coarsen_recursive */ false, + &RefineAndCoarsenList::coarsen_callback, + /*init_callback=*/NULL); - // make sure all cells in the lists have - // been consumed + // make sure all cells in the lists have + // been consumed Assert (refine_and_coarsen_list.pointers_are_at_end(), - ExcInternalError()); + ExcInternalError()); - // reset the pointer + // reset the pointer parallel_forest->user_pointer = this; - // enforce 2:1 hanging node condition + // enforce 2:1 hanging node condition dealii::internal::p4est::functions:: - balance (parallel_forest, - /* face and corner balance */ - (dim == 2 - ? - typename dealii::internal::p4est::types:: - balance_type(P4EST_BALANCE_FULL) - : - typename dealii::internal::p4est::types:: - balance_type(P8EST_BALANCE_FULL)), - /*init_callback=*/NULL); - - - // before repartitioning the mesh let - // others attach mesh related info - // (such as SolutionTransfer data) to - // the p4est + balance (parallel_forest, + /* face and corner balance */ + (dim == 2 + ? + typename dealii::internal::p4est::types:: + balance_type(P4EST_BALANCE_FULL) + : + typename dealii::internal::p4est::types:: + balance_type(P8EST_BALANCE_FULL)), + /*init_callback=*/NULL); + + + // before repartitioning the mesh let + // others attach mesh related info + // (such as SolutionTransfer data) to + // the p4est attach_mesh_data(); - // partition the new mesh between - // all processors + // partition the new mesh between + // all processors dealii::internal::p4est::functions:: - partition (parallel_forest, + partition (parallel_forest, /* prepare coarsening */ 1, - /* weight_callback */ NULL); - - // finally copy back from local - // part of tree to deal.II - // triangulation. before doing - // so, make sure there are no - // refine or coarsen flags - // pending + /* weight_callback */ NULL); + + // finally copy back from local + // part of tree to deal.II + // triangulation. before doing + // so, make sure there are no + // refine or coarsen flags + // pending for (typename Triangulation::active_cell_iterator - cell = this->begin_active(); - cell != this->end(); ++cell) - { - cell->clear_refine_flag(); - cell->clear_coarsen_flag(); - } + cell = this->begin_active(); + cell != this->end(); ++cell) + { + cell->clear_refine_flag(); + cell->clear_coarsen_flag(); + } try - { - copy_local_forest_to_triangulation (); - } + { + copy_local_forest_to_triangulation (); + } catch (const typename Triangulation::DistortedCellList &) - { - // the underlying - // triangulation should not - // be checking for - // distorted cells - AssertThrow (false, ExcInternalError()); - } + { + // the underlying + // triangulation should not + // be checking for + // distorted cells + AssertThrow (false, ExcInternalError()); + } refinement_in_progress = false; @@ -2787,35 +2787,35 @@ namespace parallel Triangulation::update_number_cache () { Assert (number_cache.n_locally_owned_active_cells.size() - == - Utilities::MPI::n_mpi_processes (mpi_communicator), - ExcInternalError()); + == + Utilities::MPI::n_mpi_processes (mpi_communicator), + ExcInternalError()); std::fill (number_cache.n_locally_owned_active_cells.begin(), - number_cache.n_locally_owned_active_cells.end(), - 0); + number_cache.n_locally_owned_active_cells.end(), + 0); if (this->n_levels() > 0) - for (typename Triangulation::active_cell_iterator - cell = this->begin_active(); - cell != this->end(); ++cell) - if (cell->subdomain_id() == my_subdomain) - ++number_cache.n_locally_owned_active_cells[my_subdomain]; + for (typename Triangulation::active_cell_iterator + cell = this->begin_active(); + cell != this->end(); ++cell) + if (cell->subdomain_id() == my_subdomain) + ++number_cache.n_locally_owned_active_cells[my_subdomain]; unsigned int send_value - = number_cache.n_locally_owned_active_cells[my_subdomain]; + = number_cache.n_locally_owned_active_cells[my_subdomain]; MPI_Allgather (&send_value, - 1, - MPI_UNSIGNED, - &number_cache.n_locally_owned_active_cells[0], - 1, - MPI_UNSIGNED, - mpi_communicator); + 1, + MPI_UNSIGNED, + &number_cache.n_locally_owned_active_cells[0], + 1, + MPI_UNSIGNED, + mpi_communicator); number_cache.n_global_active_cells - = std::accumulate (number_cache.n_locally_owned_active_cells.begin(), - number_cache.n_locally_owned_active_cells.end(), - 0); + = std::accumulate (number_cache.n_locally_owned_active_cells.begin(), + number_cache.n_locally_owned_active_cells.end(), + 0); } @@ -2861,13 +2861,13 @@ namespace parallel unsigned int Triangulation:: register_data_attach (const std::size_t size, - const std_cxx1x::function & pack_callback) + const std_cxx1x::function & pack_callback) { Assert(size>0, ExcMessage("register_data_attach(), size==0")); Assert(attached_data_pack_callbacks.size()==n_attached_datas, - ExcMessage("register_data_attach(), not all data has been unpacked last time?")); + ExcMessage("register_data_attach(), not all data has been unpacked last time?")); unsigned int offset = attached_data_size+sizeof(CellStatus); ++n_attached_datas; @@ -2884,20 +2884,20 @@ namespace parallel void Triangulation:: notify_ready_to_unpack (const unsigned int offset, - const std_cxx1x::function & unpack_callback) + const std_cxx1x::function & unpack_callback) { Assert (offset < attached_data_size, ExcMessage ("invalid offset in notify_ready_to_unpack()")); Assert (n_attached_datas > 0, ExcMessage ("notify_ready_to_unpack() called too often")); - // Recurse over p4est and hand the caller the data back + // Recurse over p4est and hand the caller the data back for (typename Triangulation::cell_iterator - cell = this->begin (0); + cell = this->begin (0); cell != this->end (0); ++cell) { - //skip coarse cells, that are not ours + //skip coarse cells, that are not ours if (tree_exists_locally (parallel_forest, coarse_cell_to_p4est_tree_permutation[cell->index() ]) == false) @@ -2909,15 +2909,15 @@ namespace parallel dealii::internal::p4est::init_coarse_quadrant (p4est_coarse_cell); - // parent_cell is not correct here, - // but is only used in a refined - // cell + // parent_cell is not correct here, + // but is only used in a refined + // cell post_mesh_data_recursively (*tree, - cell, - cell, - p4est_coarse_cell, - offset, - unpack_callback); + cell, + cell, + p4est_coarse_cell, + offset, + unpack_callback); } --n_attached_datas; @@ -2927,19 +2927,19 @@ namespace parallel attached_data_pack_callbacks.pop_front(); } - // important: only remove data if we are not in the deserialization - // process. There, each SolutionTransfer registers and unpacks - // before the next one does this, so n_attached_datas is only 1 here. - // This would destroy the saved data before the second SolutionTransfer - // can get it. This created a bug that is documented in - // tests/mpi/p4est_save_03 with more than one SolutionTransfer. + // important: only remove data if we are not in the deserialization + // process. There, each SolutionTransfer registers and unpacks + // before the next one does this, so n_attached_datas is only 1 here. + // This would destroy the saved data before the second SolutionTransfer + // can get it. This created a bug that is documented in + // tests/mpi/p4est_save_03 with more than one SolutionTransfer. if (!n_attached_datas && n_attached_deserialize == 0) { - // everybody got his data, time for cleanup! + // everybody got his data, time for cleanup! attached_data_size = 0; attached_data_pack_callbacks.clear(); - // and release the data + // and release the data void * userptr = parallel_forest->user_pointer; dealii::internal::p4est::functions::reset_data (parallel_forest, 0, NULL, NULL); parallel_forest->user_pointer = userptr; @@ -2971,21 +2971,21 @@ namespace parallel Triangulation::memory_consumption () const { std::size_t mem= - this->dealii::Triangulation::memory_consumption() - + MemoryConsumption::memory_consumption(mpi_communicator) - + MemoryConsumption::memory_consumption(my_subdomain) - + MemoryConsumption::memory_consumption(triangulation_has_content) - + MemoryConsumption::memory_consumption(number_cache.n_locally_owned_active_cells) - + MemoryConsumption::memory_consumption(number_cache.n_global_active_cells) - + MemoryConsumption::memory_consumption(connectivity) - + MemoryConsumption::memory_consumption(parallel_forest) - + MemoryConsumption::memory_consumption(refinement_in_progress) - + MemoryConsumption::memory_consumption(attached_data_size) - + MemoryConsumption::memory_consumption(n_attached_datas) -// + MemoryConsumption::memory_consumption(attached_data_pack_callbacks) //TODO[TH]: how? - + MemoryConsumption::memory_consumption(coarse_cell_to_p4est_tree_permutation) - + MemoryConsumption::memory_consumption(p4est_tree_to_coarse_cell_permutation) - + memory_consumption_p4est(); + this->dealii::Triangulation::memory_consumption() + + MemoryConsumption::memory_consumption(mpi_communicator) + + MemoryConsumption::memory_consumption(my_subdomain) + + MemoryConsumption::memory_consumption(triangulation_has_content) + + MemoryConsumption::memory_consumption(number_cache.n_locally_owned_active_cells) + + MemoryConsumption::memory_consumption(number_cache.n_global_active_cells) + + MemoryConsumption::memory_consumption(connectivity) + + MemoryConsumption::memory_consumption(parallel_forest) + + MemoryConsumption::memory_consumption(refinement_in_progress) + + MemoryConsumption::memory_consumption(attached_data_size) + + MemoryConsumption::memory_consumption(n_attached_datas) +// + MemoryConsumption::memory_consumption(attached_data_pack_callbacks) //TODO[TH]: how? + + MemoryConsumption::memory_consumption(coarse_cell_to_p4est_tree_permutation) + + MemoryConsumption::memory_consumption(p4est_tree_to_coarse_cell_permutation) + + memory_consumption_p4est(); return mem; } @@ -2997,7 +2997,7 @@ namespace parallel Triangulation::memory_consumption_p4est () const { return dealii::internal::p4est::functions::forest_memory_used(parallel_forest) - + dealii::internal::p4est::functions::connectivity_memory_used(connectivity); + + dealii::internal::p4est::functions::connectivity_memory_used(connectivity); } @@ -3016,56 +3016,56 @@ namespace parallel Triangulation:: attach_mesh_data() { - // determine size of memory in bytes to - // attach to each cell. This needs to - // be constant because of p4est. + // determine size of memory in bytes to + // attach to each cell. This needs to + // be constant because of p4est. if (attached_data_size==0) - { - Assert(n_attached_datas==0, ExcInternalError()); + { + Assert(n_attached_datas==0, ExcInternalError()); - //nothing to do - return; - } + //nothing to do + return; + } - // realloc user_data in p4est + // realloc user_data in p4est void * userptr = parallel_forest->user_pointer; dealii::internal::p4est::functions::reset_data (parallel_forest, - attached_data_size+sizeof(CellStatus), - NULL, NULL); + attached_data_size+sizeof(CellStatus), + NULL, NULL); parallel_forest->user_pointer = userptr; - // Recurse over p4est and Triangulation - // to find refined/coarsened/kept - // cells. Then query and attach the data. + // Recurse over p4est and Triangulation + // to find refined/coarsened/kept + // cells. Then query and attach the data. for (typename Triangulation::cell_iterator - cell = this->begin(0); - cell != this->end(0); - ++cell) - { - //skip coarse cells, that are not ours - if (tree_exists_locally(parallel_forest, - coarse_cell_to_p4est_tree_permutation[cell->index()]) - == false) - continue; - - typename dealii::internal::p4est::types::quadrant p4est_coarse_cell; - typename dealii::internal::p4est::types::tree *tree = - init_tree(cell->index()); - - dealii::internal::p4est::init_coarse_quadrant(p4est_coarse_cell); - - attach_mesh_data_recursively(*tree, - cell, - p4est_coarse_cell, - attached_data_pack_callbacks); - } + cell = this->begin(0); + cell != this->end(0); + ++cell) + { + //skip coarse cells, that are not ours + if (tree_exists_locally(parallel_forest, + coarse_cell_to_p4est_tree_permutation[cell->index()]) + == false) + continue; + + typename dealii::internal::p4est::types::quadrant p4est_coarse_cell; + typename dealii::internal::p4est::types::tree *tree = + init_tree(cell->index()); + + dealii::internal::p4est::init_coarse_quadrant(p4est_coarse_cell); + + attach_mesh_data_recursively(*tree, + cell, + p4est_coarse_cell, + attached_data_pack_callbacks); + } } - // TODO: again problems with specialization in - // only one template argument + // TODO: again problems with specialization in + // only one template argument template <> Triangulation<1,1>::Triangulation (MPI_Comm) { diff --git a/deal.II/source/dofs/block_info.cc b/deal.II/source/dofs/block_info.cc index 59e0811bea..f74605a2be 100644 --- a/deal.II/source/dofs/block_info.cc +++ b/deal.II/source/dofs/block_info.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2009, 2010 by the deal.II authors +// Copyright (C) 2009, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -48,8 +48,8 @@ BlockInfo::initialize_local(const DoFHandler& dof) local_renumbering.resize(fe.n_dofs_per_cell()); FETools::compute_block_renumbering(fe, - local_renumbering, - sizes, false); + local_renumbering, + sizes, false); bi_local.reinit(sizes); } diff --git a/deal.II/source/dofs/dof_accessor.cc b/deal.II/source/dofs/dof_accessor.cc index 81dcf5e156..1082bedd5e 100644 --- a/deal.II/source/dofs/dof_accessor.cc +++ b/deal.II/source/dofs/dof_accessor.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -77,15 +77,15 @@ DoFCellAccessor::set_dof_indices (const std::vector &local_dof template typename internal::DoFHandler::Iterators::cell_iterator DoFCellAccessor::neighbor_child_on_subface (const unsigned int face, - const unsigned int subface) const + const unsigned int subface) const { const TriaIterator > q = CellAccessor::neighbor_child_on_subface (face, subface); return typename internal::DoFHandler::Iterators::cell_iterator (this->tria, - q->level (), - q->index (), - this->dof_handler); + q->level (), + q->index (), + this->dof_handler); } @@ -95,26 +95,26 @@ template void DoFCellAccessor:: get_interpolated_dof_values (const InputVector &values, - Vector &interpolated_values) const + Vector &interpolated_values) const { const FiniteElement &fe = this->get_fe(); const unsigned int dofs_per_cell = fe.dofs_per_cell; Assert (this->dof_handler != 0, - typename BaseClass::ExcInvalidObject()); + typename BaseClass::ExcInvalidObject()); Assert (&fe != 0, - typename BaseClass::ExcInvalidObject()); + typename BaseClass::ExcInvalidObject()); Assert (interpolated_values.size() == dofs_per_cell, - typename BaseClass::ExcVectorDoesNotMatch()); + typename BaseClass::ExcVectorDoesNotMatch()); Assert (values.size() == this->dof_handler->n_dofs(), - typename BaseClass::ExcVectorDoesNotMatch()); + typename BaseClass::ExcVectorDoesNotMatch()); if (!this->has_children()) - // if this cell has no children: simply - // return the exact values on this cell + // if this cell has no children: simply + // return the exact values on this cell this->get_dof_values (values, interpolated_values); else - // otherwise clobber them from the children + // otherwise clobber them from the children { Vector tmp1(dofs_per_cell); Vector tmp2(dofs_per_cell); @@ -183,25 +183,25 @@ get_interpolated_dof_values (const InputVector &values, restriction_is_additive[i] = fe.restriction_is_additive(i); for (unsigned int child=0; childn_children(); ++child) - { - // get the values from the present - // child, if necessary by - // interpolation itself - this->child(child)->get_interpolated_dof_values (values, - tmp1); - // interpolate these to the mother - // cell - fe.get_restriction_matrix(child, this->refinement_case()).vmult (tmp2, tmp1); + { + // get the values from the present + // child, if necessary by + // interpolation itself + this->child(child)->get_interpolated_dof_values (values, + tmp1); + // interpolate these to the mother + // cell + fe.get_restriction_matrix(child, this->refinement_case()).vmult (tmp2, tmp1); // and add up or set them // in the output vector - for (unsigned int i=0; i void DoFCellAccessor:: set_dof_values_by_interpolation (const Vector &local_values, - OutputVector &values) const + OutputVector &values) const { const unsigned int dofs_per_cell = this->get_fe().dofs_per_cell; Assert (this->dof_handler != 0, - typename BaseClass::ExcInvalidObject()); + typename BaseClass::ExcInvalidObject()); Assert (&this->get_fe() != 0, - typename BaseClass::ExcInvalidObject()); + typename BaseClass::ExcInvalidObject()); Assert (local_values.size() == dofs_per_cell, - typename BaseClass::ExcVectorDoesNotMatch()); + typename BaseClass::ExcVectorDoesNotMatch()); Assert (values.size() == this->dof_handler->n_dofs(), - typename BaseClass::ExcVectorDoesNotMatch()); + typename BaseClass::ExcVectorDoesNotMatch()); if (!this->has_children()) // if this cell has no children: simply - // set the values on this cell + // set the values on this cell this->set_dof_values (local_values, values); else - // otherwise distribute them to the children + // otherwise distribute them to the children { Vector tmp(dofs_per_cell); for (unsigned int child=0; childn_children(); ++child) - { - // prolong the given data - // to the present cell - this->get_fe().get_prolongation_matrix(child, this->refinement_case()) + { + // prolong the given data + // to the present cell + this->get_fe().get_prolongation_matrix(child, this->refinement_case()) .vmult (tmp, local_values); - this->child(child)->set_dof_values_by_interpolation (tmp, values); - } + this->child(child)->set_dof_values_by_interpolation (tmp, values); + } } } diff --git a/deal.II/source/dofs/dof_faces.cc b/deal.II/source/dofs/dof_faces.cc index 3577387c78..66f146b63d 100644 --- a/deal.II/source/dofs/dof_faces.cc +++ b/deal.II/source/dofs/dof_faces.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2006, 2010, 2011 by the deal.II authors +// Copyright (C) 2006, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -41,7 +41,7 @@ namespace internal DoFFaces<3>::memory_consumption () const { return (MemoryConsumption::memory_consumption (quads) + - MemoryConsumption::memory_consumption (lines) ); + MemoryConsumption::memory_consumption (lines) ); } } } diff --git a/deal.II/source/dofs/dof_handler.cc b/deal.II/source/dofs/dof_handler.cc index 9e42a724f8..1be336cebb 100644 --- a/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/source/dofs/dof_handler.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -65,9 +65,9 @@ namespace internal { namespace DoFHandler { - // access class - // dealii::DoFHandler instead of - // namespace internal::DoFHandler + // access class + // dealii::DoFHandler instead of + // namespace internal::DoFHandler using dealii::DoFHandler; @@ -77,279 +77,279 @@ namespace internal */ struct Implementation { - /** - * Implement the function of same name in - * the mother class. - */ - template - static - unsigned int - max_couplings_between_dofs (const DoFHandler<1,spacedim> &dof_handler) - { - return std::min(3*dof_handler.selected_fe->dofs_per_vertex + - 2*dof_handler.selected_fe->dofs_per_line, - dof_handler.n_dofs()); - } - - - - template - static - unsigned int - max_couplings_between_dofs (const DoFHandler<2,spacedim> &dof_handler) - { - - // get these numbers by drawing pictures - // and counting... - // example: - // | | | - // --x-----x--x--X-- - // | | | | - // | x--x--x - // | | | | - // --x--x--*--x--x-- - // | | | | - // x--x--x | - // | | | | - // --X--x--x-----x-- - // | | | - // x = vertices connected with center vertex *; - // = total of 19 - // (the X vertices are connected with * if - // the vertices adjacent to X are hanging - // nodes) - // count lines -> 28 (don't forget to count - // mother and children separately!) - unsigned int max_couplings; - switch (dof_handler.tria->max_adjacent_cells()) - { - case 4: - max_couplings=19*dof_handler.selected_fe->dofs_per_vertex + - 28*dof_handler.selected_fe->dofs_per_line + - 8*dof_handler.selected_fe->dofs_per_quad; - break; - case 5: - max_couplings=21*dof_handler.selected_fe->dofs_per_vertex + - 31*dof_handler.selected_fe->dofs_per_line + - 9*dof_handler.selected_fe->dofs_per_quad; - break; - case 6: - max_couplings=28*dof_handler.selected_fe->dofs_per_vertex + - 42*dof_handler.selected_fe->dofs_per_line + - 12*dof_handler.selected_fe->dofs_per_quad; - break; - case 7: - max_couplings=30*dof_handler.selected_fe->dofs_per_vertex + - 45*dof_handler.selected_fe->dofs_per_line + - 13*dof_handler.selected_fe->dofs_per_quad; - break; - case 8: - max_couplings=37*dof_handler.selected_fe->dofs_per_vertex + - 56*dof_handler.selected_fe->dofs_per_line + - 16*dof_handler.selected_fe->dofs_per_quad; - break; - - // the following - // numbers are not - // based on actual - // counting but by - // extrapolating the - // number sequences - // from the previous - // ones (for example, - // for dofs_per_vertex, - // the sequence above - // is 19, 21, 28, 30, - // 37, and is continued - // as follows): - case 9: - max_couplings=39*dof_handler.selected_fe->dofs_per_vertex + - 59*dof_handler.selected_fe->dofs_per_line + - 17*dof_handler.selected_fe->dofs_per_quad; - break; - case 10: - max_couplings=46*dof_handler.selected_fe->dofs_per_vertex + - 70*dof_handler.selected_fe->dofs_per_line + - 20*dof_handler.selected_fe->dofs_per_quad; - break; - case 11: - max_couplings=48*dof_handler.selected_fe->dofs_per_vertex + - 73*dof_handler.selected_fe->dofs_per_line + - 21*dof_handler.selected_fe->dofs_per_quad; - break; - case 12: - max_couplings=55*dof_handler.selected_fe->dofs_per_vertex + - 84*dof_handler.selected_fe->dofs_per_line + - 24*dof_handler.selected_fe->dofs_per_quad; - break; - case 13: - max_couplings=57*dof_handler.selected_fe->dofs_per_vertex + - 87*dof_handler.selected_fe->dofs_per_line + - 25*dof_handler.selected_fe->dofs_per_quad; - break; - case 14: - max_couplings=63*dof_handler.selected_fe->dofs_per_vertex + - 98*dof_handler.selected_fe->dofs_per_line + - 28*dof_handler.selected_fe->dofs_per_quad; - break; - case 15: - max_couplings=65*dof_handler.selected_fe->dofs_per_vertex + - 103*dof_handler.selected_fe->dofs_per_line + - 29*dof_handler.selected_fe->dofs_per_quad; - break; - case 16: - max_couplings=72*dof_handler.selected_fe->dofs_per_vertex + - 114*dof_handler.selected_fe->dofs_per_line + - 32*dof_handler.selected_fe->dofs_per_quad; - break; - - default: - Assert (false, ExcNotImplemented()); - max_couplings=0; - } - return std::min(max_couplings,dof_handler.n_dofs()); - } - - - template - static - unsigned int - max_couplings_between_dofs (const DoFHandler<3,spacedim> &dof_handler) - { + /** + * Implement the function of same name in + * the mother class. + */ + template + static + unsigned int + max_couplings_between_dofs (const DoFHandler<1,spacedim> &dof_handler) + { + return std::min(3*dof_handler.selected_fe->dofs_per_vertex + + 2*dof_handler.selected_fe->dofs_per_line, + dof_handler.n_dofs()); + } + + + + template + static + unsigned int + max_couplings_between_dofs (const DoFHandler<2,spacedim> &dof_handler) + { + + // get these numbers by drawing pictures + // and counting... + // example: + // | | | + // --x-----x--x--X-- + // | | | | + // | x--x--x + // | | | | + // --x--x--*--x--x-- + // | | | | + // x--x--x | + // | | | | + // --X--x--x-----x-- + // | | | + // x = vertices connected with center vertex *; + // = total of 19 + // (the X vertices are connected with * if + // the vertices adjacent to X are hanging + // nodes) + // count lines -> 28 (don't forget to count + // mother and children separately!) + unsigned int max_couplings; + switch (dof_handler.tria->max_adjacent_cells()) + { + case 4: + max_couplings=19*dof_handler.selected_fe->dofs_per_vertex + + 28*dof_handler.selected_fe->dofs_per_line + + 8*dof_handler.selected_fe->dofs_per_quad; + break; + case 5: + max_couplings=21*dof_handler.selected_fe->dofs_per_vertex + + 31*dof_handler.selected_fe->dofs_per_line + + 9*dof_handler.selected_fe->dofs_per_quad; + break; + case 6: + max_couplings=28*dof_handler.selected_fe->dofs_per_vertex + + 42*dof_handler.selected_fe->dofs_per_line + + 12*dof_handler.selected_fe->dofs_per_quad; + break; + case 7: + max_couplings=30*dof_handler.selected_fe->dofs_per_vertex + + 45*dof_handler.selected_fe->dofs_per_line + + 13*dof_handler.selected_fe->dofs_per_quad; + break; + case 8: + max_couplings=37*dof_handler.selected_fe->dofs_per_vertex + + 56*dof_handler.selected_fe->dofs_per_line + + 16*dof_handler.selected_fe->dofs_per_quad; + break; + + // the following + // numbers are not + // based on actual + // counting but by + // extrapolating the + // number sequences + // from the previous + // ones (for example, + // for dofs_per_vertex, + // the sequence above + // is 19, 21, 28, 30, + // 37, and is continued + // as follows): + case 9: + max_couplings=39*dof_handler.selected_fe->dofs_per_vertex + + 59*dof_handler.selected_fe->dofs_per_line + + 17*dof_handler.selected_fe->dofs_per_quad; + break; + case 10: + max_couplings=46*dof_handler.selected_fe->dofs_per_vertex + + 70*dof_handler.selected_fe->dofs_per_line + + 20*dof_handler.selected_fe->dofs_per_quad; + break; + case 11: + max_couplings=48*dof_handler.selected_fe->dofs_per_vertex + + 73*dof_handler.selected_fe->dofs_per_line + + 21*dof_handler.selected_fe->dofs_per_quad; + break; + case 12: + max_couplings=55*dof_handler.selected_fe->dofs_per_vertex + + 84*dof_handler.selected_fe->dofs_per_line + + 24*dof_handler.selected_fe->dofs_per_quad; + break; + case 13: + max_couplings=57*dof_handler.selected_fe->dofs_per_vertex + + 87*dof_handler.selected_fe->dofs_per_line + + 25*dof_handler.selected_fe->dofs_per_quad; + break; + case 14: + max_couplings=63*dof_handler.selected_fe->dofs_per_vertex + + 98*dof_handler.selected_fe->dofs_per_line + + 28*dof_handler.selected_fe->dofs_per_quad; + break; + case 15: + max_couplings=65*dof_handler.selected_fe->dofs_per_vertex + + 103*dof_handler.selected_fe->dofs_per_line + + 29*dof_handler.selected_fe->dofs_per_quad; + break; + case 16: + max_couplings=72*dof_handler.selected_fe->dofs_per_vertex + + 114*dof_handler.selected_fe->dofs_per_line + + 32*dof_handler.selected_fe->dofs_per_quad; + break; + + default: + Assert (false, ExcNotImplemented()); + max_couplings=0; + } + return std::min(max_couplings,dof_handler.n_dofs()); + } + + + template + static + unsigned int + max_couplings_between_dofs (const DoFHandler<3,spacedim> &dof_handler) + { //TODO:[?] Invent significantly better estimates than the ones in this function - // doing the same thing here is a - // rather complicated thing, compared - // to the 2d case, since it is hard - // to draw pictures with several - // refined hexahedra :-) so I - // presently only give a coarse - // estimate for the case that at most - // 8 hexes meet at each vertex - // - // can anyone give better estimate - // here? - const unsigned int max_adjacent_cells - = dof_handler.tria->max_adjacent_cells(); - - unsigned int max_couplings; - if (max_adjacent_cells <= 8) - max_couplings=7*7*7*dof_handler.selected_fe->dofs_per_vertex + - 7*6*7*3*dof_handler.selected_fe->dofs_per_line + - 9*4*7*3*dof_handler.selected_fe->dofs_per_quad + - 27*dof_handler.selected_fe->dofs_per_hex; - else - { - Assert (false, ExcNotImplemented()); - max_couplings=0; - } - - return std::min(max_couplings,dof_handler.n_dofs()); - } - - - /** - * Reserve enough space in the - * levels[] objects to store the - * numbers of the degrees of freedom - * needed for the given element. The - * given element is that one which - * was selected when calling - * @p distribute_dofs the last time. - */ - template - static - void reserve_space (DoFHandler<1,spacedim> &dof_handler) - { - dof_handler.vertex_dofs - .resize(dof_handler.tria->n_vertices() * - dof_handler.selected_fe->dofs_per_vertex, - DoFHandler<1,spacedim>::invalid_dof_index); - - for (unsigned int i=0; in_levels(); ++i) - { - dof_handler.levels - .push_back (new internal::DoFHandler::DoFLevel<1>); - - dof_handler.levels.back()->lines.dofs - .resize (dof_handler.tria->n_raw_lines(i) * - dof_handler.selected_fe->dofs_per_line, - DoFHandler<1,spacedim>::invalid_dof_index); - - dof_handler.levels.back()->cell_dof_indices_cache - .resize (dof_handler.tria->n_raw_lines(i) * - dof_handler.selected_fe->dofs_per_cell, - DoFHandler<1,spacedim>::invalid_dof_index); - } - } - - - template - static - void reserve_space (DoFHandler<2,spacedim> &dof_handler) - { - dof_handler.vertex_dofs - .resize(dof_handler.tria->n_vertices() * - dof_handler.selected_fe->dofs_per_vertex, - DoFHandler<2,spacedim>::invalid_dof_index); - - for (unsigned int i=0; in_levels(); ++i) - { - dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<2>); - - dof_handler.levels.back()->quads.dofs - .resize (dof_handler.tria->n_raw_quads(i) * - dof_handler.selected_fe->dofs_per_quad, - DoFHandler<2,spacedim>::invalid_dof_index); - - dof_handler.levels.back()->cell_dof_indices_cache - .resize (dof_handler.tria->n_raw_quads(i) * - dof_handler.selected_fe->dofs_per_cell, - DoFHandler<2,spacedim>::invalid_dof_index); - } - - dof_handler.faces = new internal::DoFHandler::DoFFaces<2>; - dof_handler.faces->lines.dofs - .resize (dof_handler.tria->n_raw_lines() * - dof_handler.selected_fe->dofs_per_line, - DoFHandler<2,spacedim>::invalid_dof_index); - } - - - template - static - void reserve_space (DoFHandler<3,spacedim> &dof_handler) - { - dof_handler.vertex_dofs - .resize(dof_handler.tria->n_vertices() * - dof_handler.selected_fe->dofs_per_vertex, - DoFHandler<3,spacedim>::invalid_dof_index); - - for (unsigned int i=0; in_levels(); ++i) - { - dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<3>); - - dof_handler.levels.back()->hexes.dofs - .resize (dof_handler.tria->n_raw_hexs(i) * - dof_handler.selected_fe->dofs_per_hex, - DoFHandler<3,spacedim>::invalid_dof_index); - - dof_handler.levels.back()->cell_dof_indices_cache - .resize (dof_handler.tria->n_raw_hexs(i) * - dof_handler.selected_fe->dofs_per_cell, - DoFHandler<3,spacedim>::invalid_dof_index); - } - dof_handler.faces = new internal::DoFHandler::DoFFaces<3>; - - dof_handler.faces->lines.dofs - .resize (dof_handler.tria->n_raw_lines() * - dof_handler.selected_fe->dofs_per_line, - DoFHandler<3,spacedim>::invalid_dof_index); - dof_handler.faces->quads.dofs - .resize (dof_handler.tria->n_raw_quads() * - dof_handler.selected_fe->dofs_per_quad, - DoFHandler<3,spacedim>::invalid_dof_index); - } + // doing the same thing here is a + // rather complicated thing, compared + // to the 2d case, since it is hard + // to draw pictures with several + // refined hexahedra :-) so I + // presently only give a coarse + // estimate for the case that at most + // 8 hexes meet at each vertex + // + // can anyone give better estimate + // here? + const unsigned int max_adjacent_cells + = dof_handler.tria->max_adjacent_cells(); + + unsigned int max_couplings; + if (max_adjacent_cells <= 8) + max_couplings=7*7*7*dof_handler.selected_fe->dofs_per_vertex + + 7*6*7*3*dof_handler.selected_fe->dofs_per_line + + 9*4*7*3*dof_handler.selected_fe->dofs_per_quad + + 27*dof_handler.selected_fe->dofs_per_hex; + else + { + Assert (false, ExcNotImplemented()); + max_couplings=0; + } + + return std::min(max_couplings,dof_handler.n_dofs()); + } + + + /** + * Reserve enough space in the + * levels[] objects to store the + * numbers of the degrees of freedom + * needed for the given element. The + * given element is that one which + * was selected when calling + * @p distribute_dofs the last time. + */ + template + static + void reserve_space (DoFHandler<1,spacedim> &dof_handler) + { + dof_handler.vertex_dofs + .resize(dof_handler.tria->n_vertices() * + dof_handler.selected_fe->dofs_per_vertex, + DoFHandler<1,spacedim>::invalid_dof_index); + + for (unsigned int i=0; in_levels(); ++i) + { + dof_handler.levels + .push_back (new internal::DoFHandler::DoFLevel<1>); + + dof_handler.levels.back()->lines.dofs + .resize (dof_handler.tria->n_raw_lines(i) * + dof_handler.selected_fe->dofs_per_line, + DoFHandler<1,spacedim>::invalid_dof_index); + + dof_handler.levels.back()->cell_dof_indices_cache + .resize (dof_handler.tria->n_raw_lines(i) * + dof_handler.selected_fe->dofs_per_cell, + DoFHandler<1,spacedim>::invalid_dof_index); + } + } + + + template + static + void reserve_space (DoFHandler<2,spacedim> &dof_handler) + { + dof_handler.vertex_dofs + .resize(dof_handler.tria->n_vertices() * + dof_handler.selected_fe->dofs_per_vertex, + DoFHandler<2,spacedim>::invalid_dof_index); + + for (unsigned int i=0; in_levels(); ++i) + { + dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<2>); + + dof_handler.levels.back()->quads.dofs + .resize (dof_handler.tria->n_raw_quads(i) * + dof_handler.selected_fe->dofs_per_quad, + DoFHandler<2,spacedim>::invalid_dof_index); + + dof_handler.levels.back()->cell_dof_indices_cache + .resize (dof_handler.tria->n_raw_quads(i) * + dof_handler.selected_fe->dofs_per_cell, + DoFHandler<2,spacedim>::invalid_dof_index); + } + + dof_handler.faces = new internal::DoFHandler::DoFFaces<2>; + dof_handler.faces->lines.dofs + .resize (dof_handler.tria->n_raw_lines() * + dof_handler.selected_fe->dofs_per_line, + DoFHandler<2,spacedim>::invalid_dof_index); + } + + + template + static + void reserve_space (DoFHandler<3,spacedim> &dof_handler) + { + dof_handler.vertex_dofs + .resize(dof_handler.tria->n_vertices() * + dof_handler.selected_fe->dofs_per_vertex, + DoFHandler<3,spacedim>::invalid_dof_index); + + for (unsigned int i=0; in_levels(); ++i) + { + dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<3>); + + dof_handler.levels.back()->hexes.dofs + .resize (dof_handler.tria->n_raw_hexs(i) * + dof_handler.selected_fe->dofs_per_hex, + DoFHandler<3,spacedim>::invalid_dof_index); + + dof_handler.levels.back()->cell_dof_indices_cache + .resize (dof_handler.tria->n_raw_hexs(i) * + dof_handler.selected_fe->dofs_per_cell, + DoFHandler<3,spacedim>::invalid_dof_index); + } + dof_handler.faces = new internal::DoFHandler::DoFFaces<3>; + + dof_handler.faces->lines.dofs + .resize (dof_handler.tria->n_raw_lines() * + dof_handler.selected_fe->dofs_per_line, + DoFHandler<3,spacedim>::invalid_dof_index); + dof_handler.faces->quads.dofs + .resize (dof_handler.tria->n_raw_quads() * + dof_handler.selected_fe->dofs_per_quad, + DoFHandler<3,spacedim>::invalid_dof_index); + } }; } } @@ -358,14 +358,14 @@ namespace internal template DoFHandler::DoFHandler (const Triangulation &tria) - : - tria(&tria, typeid(*this).name()), - selected_fe(0, typeid(*this).name()), - faces(NULL) -{ - // decide whether we need a - // sequential or a parallel - // distributed policy + : + tria(&tria, typeid(*this).name()), + selected_fe(0, typeid(*this).name()), + faces(NULL) +{ + // decide whether we need a + // sequential or a parallel + // distributed policy if (dynamic_cast*> (&tria) == 0) @@ -377,17 +377,17 @@ DoFHandler::DoFHandler (const Triangulation &tria) template DoFHandler::DoFHandler () - : - tria(0, typeid(*this).name()), - selected_fe(0, typeid(*this).name()), - faces(NULL) + : + tria(0, typeid(*this).name()), + selected_fe(0, typeid(*this).name()), + faces(NULL) {} template DoFHandler::~DoFHandler () { - // release allocated memory + // release allocated memory clear (); } @@ -402,9 +402,9 @@ DoFHandler::initialize( faces = 0; number_cache.n_global_dofs = 0; - // decide whether we need a - // sequential or a parallel - // distributed policy + // decide whether we need a + // sequential or a parallel + // distributed policy if (dynamic_cast*> (&t) == 0) @@ -426,14 +426,14 @@ DoFHandler::begin_raw (const unsigned int level) const switch (dim) { case 1: - return begin_raw_line (level); + return begin_raw_line (level); case 2: - return begin_raw_quad (level); + return begin_raw_quad (level); case 3: - return begin_raw_hex (level); + return begin_raw_hex (level); default: - Assert (false, ExcNotImplemented()); - return raw_cell_iterator(); + Assert (false, ExcNotImplemented()); + return raw_cell_iterator(); } } @@ -446,14 +446,14 @@ DoFHandler::begin (const unsigned int level) const switch (dim) { case 1: - return begin_line (level); + return begin_line (level); case 2: - return begin_quad (level); + return begin_quad (level); case 3: - return begin_hex (level); + return begin_hex (level); default: - Assert (false, ExcImpossibleInDim(dim)); - return cell_iterator(); + Assert (false, ExcImpossibleInDim(dim)); + return cell_iterator(); } } @@ -466,14 +466,14 @@ DoFHandler::begin_active (const unsigned int level) const switch (dim) { case 1: - return begin_active_line (level); + return begin_active_line (level); case 2: - return begin_active_quad (level); + return begin_active_quad (level); case 3: - return begin_active_hex (level); + return begin_active_hex (level); default: - Assert (false, ExcNotImplemented()); - return active_cell_iterator(); + Assert (false, ExcNotImplemented()); + return active_cell_iterator(); } } @@ -486,14 +486,14 @@ DoFHandler::last_raw () const switch (dim) { case 1: - return last_raw_line (); + return last_raw_line (); case 2: - return last_raw_quad (); + return last_raw_quad (); case 3: - return last_raw_hex (); + return last_raw_hex (); default: - Assert (false, ExcNotImplemented()); - return raw_cell_iterator(); + Assert (false, ExcNotImplemented()); + return raw_cell_iterator(); } } @@ -506,14 +506,14 @@ DoFHandler::last_raw (const unsigned int level) const switch (dim) { case 1: - return last_raw_line (level); + return last_raw_line (level); case 2: - return last_raw_quad (level); + return last_raw_quad (level); case 3: - return last_raw_hex (level); + return last_raw_hex (level); default: - Assert (false, ExcNotImplemented()); - return raw_cell_iterator(); + Assert (false, ExcNotImplemented()); + return raw_cell_iterator(); } } @@ -526,14 +526,14 @@ DoFHandler::last () const switch (dim) { case 1: - return last_line (); + return last_line (); case 2: - return last_quad (); + return last_quad (); case 3: - return last_hex (); + return last_hex (); default: - Assert (false, ExcNotImplemented()); - return cell_iterator(); + Assert (false, ExcNotImplemented()); + return cell_iterator(); } } @@ -546,14 +546,14 @@ DoFHandler::last (const unsigned int level) const switch (dim) { case 1: - return last_line (level); + return last_line (level); case 2: - return last_quad (level); + return last_quad (level); case 3: - return last_hex (level); + return last_hex (level); default: - Assert (false, ExcNotImplemented()); - return cell_iterator(); + Assert (false, ExcNotImplemented()); + return cell_iterator(); } } @@ -566,14 +566,14 @@ DoFHandler::last_active () const switch (dim) { case 1: - return last_active_line (); + return last_active_line (); case 2: - return last_active_quad (); + return last_active_quad (); case 3: - return last_active_hex (); + return last_active_hex (); default: - Assert (false, ExcNotImplemented()); - return active_cell_iterator(); + Assert (false, ExcNotImplemented()); + return active_cell_iterator(); } } @@ -586,14 +586,14 @@ DoFHandler::last_active (const unsigned int level) const switch (dim) { case 1: - return last_active_line (level); + return last_active_line (level); case 2: - return last_active_quad (level); + return last_active_quad (level); case 3: - return last_active_hex (level); + return last_active_hex (level); default: - Assert (false, ExcNotImplemented()); - return active_cell_iterator(); + Assert (false, ExcNotImplemented()); + return active_cell_iterator(); } } @@ -605,14 +605,14 @@ DoFHandler::end () const switch (dim) { case 1: - return end_line(); + return end_line(); case 2: - return end_quad(); + return end_quad(); case 3: - return end_hex(); + return end_hex(); default: - Assert (false, ExcImpossibleInDim(dim)); - return raw_cell_iterator(); + Assert (false, ExcImpossibleInDim(dim)); + return raw_cell_iterator(); } } @@ -624,8 +624,8 @@ DoFHandler::end_raw (const unsigned int level) const { Assert(tria != 0, ExcNotInitialized()); return (level == tria->n_levels()-1 ? - end() : - begin_raw (level+1)); + end() : + begin_raw (level+1)); } @@ -635,8 +635,8 @@ DoFHandler::end (const unsigned int level) const { Assert(tria != 0, ExcNotInitialized()); return (level == tria->n_levels()-1 ? - cell_iterator(end()) : - begin (level+1)); + cell_iterator(end()) : + begin (level+1)); } @@ -646,8 +646,8 @@ DoFHandler::end_active (const unsigned int level) const { Assert(tria != 0, ExcNotInitialized()); return (level == tria->n_levels()-1 ? - active_cell_iterator(end()) : - begin_active (level+1)); + active_cell_iterator(end()) : + begin_active (level+1)); } @@ -661,15 +661,15 @@ DoFHandler::begin_raw_face () const switch (dim) { case 1: - Assert (false, ExcImpossibleInDim(1)); - return raw_face_iterator(); + Assert (false, ExcImpossibleInDim(1)); + return raw_face_iterator(); case 2: - return begin_raw_line (); + return begin_raw_line (); case 3: - return begin_raw_quad (); + return begin_raw_quad (); default: - Assert (false, ExcNotImplemented()); - return raw_face_iterator (); + Assert (false, ExcNotImplemented()); + return raw_face_iterator (); } } @@ -682,15 +682,15 @@ DoFHandler::begin_face () const switch (dim) { case 1: - Assert (false, ExcImpossibleInDim(1)); - return raw_face_iterator(); + Assert (false, ExcImpossibleInDim(1)); + return raw_face_iterator(); case 2: - return begin_line (); + return begin_line (); case 3: - return begin_quad (); + return begin_quad (); default: - Assert (false, ExcNotImplemented()); - return face_iterator (); + Assert (false, ExcNotImplemented()); + return face_iterator (); } } @@ -703,15 +703,15 @@ DoFHandler::begin_active_face () const switch (dim) { case 1: - Assert (false, ExcImpossibleInDim(1)); - return raw_face_iterator(); + Assert (false, ExcImpossibleInDim(1)); + return raw_face_iterator(); case 2: - return begin_active_line (); + return begin_active_line (); case 3: - return begin_active_quad (); + return begin_active_quad (); default: - Assert (false, ExcNotImplemented()); - return active_face_iterator (); + Assert (false, ExcNotImplemented()); + return active_face_iterator (); } } @@ -733,15 +733,15 @@ DoFHandler::end_face () const switch (dim) { case 1: - Assert (false, ExcImpossibleInDim(1)); - return raw_face_iterator(); + Assert (false, ExcImpossibleInDim(1)); + return raw_face_iterator(); case 2: - return end_line (); + return end_line (); case 3: - return end_quad (); + return end_quad (); default: - Assert (false, ExcNotImplemented()); - return raw_face_iterator (); + Assert (false, ExcNotImplemented()); + return raw_face_iterator (); } } @@ -765,15 +765,15 @@ DoFHandler::last_raw_face () const switch (dim) { case 1: - Assert (false, ExcImpossibleInDim(1)); - return raw_face_iterator(); + Assert (false, ExcImpossibleInDim(1)); + return raw_face_iterator(); case 2: - return last_raw_line (); + return last_raw_line (); case 3: - return last_raw_quad (); + return last_raw_quad (); default: - Assert (false, ExcNotImplemented()); - return raw_face_iterator (); + Assert (false, ExcNotImplemented()); + return raw_face_iterator (); } } @@ -786,15 +786,15 @@ DoFHandler::last_face () const switch (dim) { case 1: - Assert (false, ExcImpossibleInDim(1)); - return raw_face_iterator(); + Assert (false, ExcImpossibleInDim(1)); + return raw_face_iterator(); case 2: - return last_line (); + return last_line (); case 3: - return last_quad (); + return last_quad (); default: - Assert (false, ExcNotImplemented()); - return raw_face_iterator (); + Assert (false, ExcNotImplemented()); + return raw_face_iterator (); } } @@ -807,15 +807,15 @@ DoFHandler::last_active_face () const switch (dim) { case 1: - Assert (false, ExcImpossibleInDim(1)); - return raw_face_iterator(); + Assert (false, ExcImpossibleInDim(1)); + return raw_face_iterator(); case 2: - return last_active_line (); + return last_active_line (); case 3: - return last_active_quad (); + return last_active_quad (); default: - Assert (false, ExcNotImplemented()); - return raw_face_iterator (); + Assert (false, ExcNotImplemented()); + return raw_face_iterator (); } } @@ -832,22 +832,22 @@ DoFHandler::begin_raw_line (const unsigned int level) const switch (dim) { case 1: - Assert (leveln_levels(), ExcInvalidLevel(level)); + Assert (leveln_levels(), ExcInvalidLevel(level)); - if (tria->n_raw_lines(level) == 0) - return end_line (); + if (tria->n_raw_lines(level) == 0) + return end_line (); - return raw_line_iterator (tria, - level, - 0, - this); + return raw_line_iterator (tria, + level, + 0, + this); default: - Assert (level == 0, ExcFacesHaveNoLevel()); - return raw_line_iterator (tria, - 0, - 0, - this); + Assert (level == 0, ExcFacesHaveNoLevel()); + return raw_line_iterator (tria, + 0, + 0, + this); } } @@ -856,7 +856,7 @@ template typename DoFHandler::line_iterator DoFHandler::begin_line (const unsigned int level) const { - // level is checked in begin_raw + // level is checked in begin_raw raw_line_iterator ri = begin_raw_line (level); if (ri.state() != IteratorState::valid) return ri; @@ -872,7 +872,7 @@ template typename DoFHandler::active_line_iterator DoFHandler::begin_active_line (const unsigned int level) const { - // level is checked in begin_raw + // level is checked in begin_raw line_iterator i = begin_line (level); if (i.state() != IteratorState::valid) return i; @@ -889,9 +889,9 @@ typename DoFHandler::raw_line_iterator DoFHandler::end_line () const { return raw_line_iterator (tria, - -1, - -1, - this); + -1, + -1, + this); } @@ -904,21 +904,21 @@ DoFHandler::last_raw_line (const unsigned int level) const switch (dim) { case 1: - Assert (leveln_levels(), ExcInvalidLevel(level)); - Assert (tria->n_raw_lines(level) != 0, - ExcEmptyLevel (level)); + Assert (leveln_levels(), ExcInvalidLevel(level)); + Assert (tria->n_raw_lines(level) != 0, + ExcEmptyLevel (level)); - return raw_line_iterator (tria, - level, - tria->n_raw_lines(level)-1, - this); + return raw_line_iterator (tria, + level, + tria->n_raw_lines(level)-1, + this); default: - Assert (level == 0, ExcFacesHaveNoLevel()); - return raw_line_iterator (tria, - 0, - tria->n_raw_lines()-1, - this); + Assert (level == 0, ExcFacesHaveNoLevel()); + return raw_line_iterator (tria, + 0, + tria->n_raw_lines()-1, + this); } } @@ -939,7 +939,7 @@ template typename DoFHandler::line_iterator DoFHandler::last_line (const unsigned int level) const { - // level is checked in last_raw + // level is checked in last_raw raw_line_iterator ri = last_raw_line(level); if (ri->used()==true) return ri; @@ -965,7 +965,7 @@ template typename DoFHandler::active_line_iterator DoFHandler::last_active_line (const unsigned int level) const { - // level is checked in last_raw + // level is checked in last_raw line_iterator i = last_line(level); if (i->has_children()==false) return i; @@ -994,8 +994,8 @@ DoFHandler::end_raw_line (const unsigned int level) const Assert (dim == 1 || level == 0, ExcFacesHaveNoLevel()); if (dim == 1) return (level == tria->n_levels()-1 ? - end_line() : - begin_raw_line (level+1)); + end_line() : + begin_raw_line (level+1)); else return end_line(); } @@ -1008,8 +1008,8 @@ DoFHandler::end_line (const unsigned int level) const Assert (dim == 1 || level == 0, ExcFacesHaveNoLevel()); if (dim == 1) return (level == tria->n_levels()-1 ? - line_iterator(end_line()) : - begin_line (level+1)); + line_iterator(end_line()) : + begin_line (level+1)); else return line_iterator(end_line()); } @@ -1022,8 +1022,8 @@ DoFHandler::end_active_line (const unsigned int level) const Assert (dim == 1 || level == 0, ExcFacesHaveNoLevel()); if (dim == 1) return (level == tria->n_levels()-1 ? - active_line_iterator(end_line()) : - begin_active_line (level+1)); + active_line_iterator(end_line()) : + begin_active_line (level+1)); else return active_line_iterator(end_line()); } @@ -1040,35 +1040,35 @@ DoFHandler::begin_raw_quad (const unsigned int level) const switch (dim) { case 1: - Assert (false, ExcImpossibleInDim(1)); - return raw_hex_iterator(); + Assert (false, ExcImpossibleInDim(1)); + return raw_hex_iterator(); case 2: { - Assert (leveln_levels(), ExcInvalidLevel(level)); + Assert (leveln_levels(), ExcInvalidLevel(level)); - if (tria->n_raw_quads(level) == 0) - return end_quad(); + if (tria->n_raw_quads(level) == 0) + return end_quad(); - return raw_quad_iterator (tria, - level, - 0, - this); + return raw_quad_iterator (tria, + level, + 0, + this); } case 3: { - Assert (level == 0, ExcFacesHaveNoLevel()); + Assert (level == 0, ExcFacesHaveNoLevel()); - return raw_quad_iterator (tria, - 0, - 0, - this); + return raw_quad_iterator (tria, + 0, + 0, + this); } default: - Assert (false, ExcNotImplemented()); - return raw_hex_iterator(); + Assert (false, ExcNotImplemented()); + return raw_hex_iterator(); } } @@ -1078,7 +1078,7 @@ template typename DoFHandler::quad_iterator DoFHandler::begin_quad (const unsigned int level) const { - // level is checked in begin_raw + // level is checked in begin_raw raw_quad_iterator ri = begin_raw_quad (level); if (ri.state() != IteratorState::valid) return ri; @@ -1094,7 +1094,7 @@ template typename DoFHandler::active_quad_iterator DoFHandler::begin_active_quad (const unsigned int level) const { - // level is checked in begin_raw + // level is checked in begin_raw quad_iterator i = begin_quad (level); if (i.state() != IteratorState::valid) return i; @@ -1113,8 +1113,8 @@ DoFHandler::end_raw_quad (const unsigned int level) const Assert (dim == 2 || level == 0, ExcFacesHaveNoLevel()); if (dim == 2) return (level == tria->n_levels()-1 ? - end_quad() : - begin_raw_quad (level+1)); + end_quad() : + begin_raw_quad (level+1)); else return end_quad(); } @@ -1128,8 +1128,8 @@ DoFHandler::end_quad (const unsigned int level) const Assert (dim == 2 || level == 0, ExcFacesHaveNoLevel()); if (dim == 2) return (level == tria->n_levels()-1 ? - quad_iterator(end_quad()) : - begin_quad (level+1)); + quad_iterator(end_quad()) : + begin_quad (level+1)); else return quad_iterator(end_quad()); } @@ -1142,8 +1142,8 @@ DoFHandler::end_active_quad (const unsigned int level) const Assert(dim == 2 || level == 0, ExcFacesHaveNoLevel()); if (dim == 2) return (level == tria->n_levels()-1 ? - active_quad_iterator(end_quad()) : - begin_active_quad (level+1)); + active_quad_iterator(end_quad()) : + begin_active_quad (level+1)); else return active_quad_iterator(end_quad()); } @@ -1155,9 +1155,9 @@ typename DoFHandler::raw_quad_iterator DoFHandler::end_quad () const { return raw_quad_iterator (tria, - -1, - -1, - this); + -1, + -1, + this); } @@ -1170,26 +1170,26 @@ DoFHandler::last_raw_quad (const unsigned int level) const switch (dim) { case 1: - Assert (false, ExcImpossibleInDim(1)); - return raw_quad_iterator(); + Assert (false, ExcImpossibleInDim(1)); + return raw_quad_iterator(); case 2: - Assert (leveln_levels(), - ExcInvalidLevel(level)); - Assert (tria->n_raw_quads(level) != 0, - ExcEmptyLevel (level)); - return raw_quad_iterator (tria, - level, - tria->n_raw_quads(level)-1, - this); + Assert (leveln_levels(), + ExcInvalidLevel(level)); + Assert (tria->n_raw_quads(level) != 0, + ExcEmptyLevel (level)); + return raw_quad_iterator (tria, + level, + tria->n_raw_quads(level)-1, + this); case 3: - Assert (level == 0, ExcFacesHaveNoLevel()); - return raw_quad_iterator (tria, - 0, - tria->n_raw_quads()-1, - this); + Assert (level == 0, ExcFacesHaveNoLevel()); + return raw_quad_iterator (tria, + 0, + tria->n_raw_quads()-1, + this); default: - Assert (false, ExcNotImplemented()); - return raw_quad_iterator(); + Assert (false, ExcNotImplemented()); + return raw_quad_iterator(); } } @@ -1211,7 +1211,7 @@ template typename DoFHandler::quad_iterator DoFHandler::last_quad (const unsigned int level) const { - // level is checked in last_raw + // level is checked in last_raw raw_quad_iterator ri = last_raw_quad(level); if (ri->used()==true) return ri; @@ -1239,7 +1239,7 @@ template typename DoFHandler::active_quad_iterator DoFHandler::last_active_quad (const unsigned int level) const { - // level is checked in last_raw + // level is checked in last_raw quad_iterator i = last_quad(level); if (i->has_children()==false) return i; @@ -1273,24 +1273,24 @@ DoFHandler::begin_raw_hex (const unsigned int level) const { case 1: case 2: - Assert (false, ExcImpossibleInDim(1)); - return raw_hex_iterator(); + Assert (false, ExcImpossibleInDim(1)); + return raw_hex_iterator(); case 3: { - Assert (leveln_levels(), ExcInvalidLevel(level)); + Assert (leveln_levels(), ExcInvalidLevel(level)); - if (tria->n_raw_hexs(level) == 0) - return end_hex(); + if (tria->n_raw_hexs(level) == 0) + return end_hex(); - return raw_hex_iterator (tria, - level, - 0, - this); + return raw_hex_iterator (tria, + level, + 0, + this); } default: - Assert (false, ExcNotImplemented()); - return raw_hex_iterator(); + Assert (false, ExcNotImplemented()); + return raw_hex_iterator(); } } @@ -1300,7 +1300,7 @@ template typename DoFHandler::hex_iterator DoFHandler::begin_hex (const unsigned int level) const { - // level is checked in begin_raw + // level is checked in begin_raw raw_hex_iterator ri = begin_raw_hex (level); if (ri.state() != IteratorState::valid) return ri; @@ -1316,7 +1316,7 @@ template typename DoFHandler::active_hex_iterator DoFHandler::begin_active_hex (const unsigned int level) const { - // level is checked in begin_raw + // level is checked in begin_raw hex_iterator i = begin_hex (level); if (i.state() != IteratorState::valid) return i; @@ -1333,8 +1333,8 @@ typename DoFHandler::raw_hex_iterator DoFHandler::end_raw_hex (const unsigned int level) const { return (level == tria->n_levels()-1 ? - end_hex() : - begin_raw_hex (level+1)); + end_hex() : + begin_raw_hex (level+1)); } @@ -1343,8 +1343,8 @@ typename DoFHandler::hex_iterator DoFHandler::end_hex (const unsigned int level) const { return (level == tria->n_levels()-1 ? - hex_iterator(end_hex()) : - begin_hex (level+1)); + hex_iterator(end_hex()) : + begin_hex (level+1)); } @@ -1353,8 +1353,8 @@ typename DoFHandler::active_hex_iterator DoFHandler::end_active_hex (const unsigned int level) const { return (level == tria->n_levels()-1 ? - active_hex_iterator(end_hex()) : - begin_active_hex (level+1)); + active_hex_iterator(end_hex()) : + begin_active_hex (level+1)); } @@ -1364,9 +1364,9 @@ typename DoFHandler::raw_hex_iterator DoFHandler::end_hex () const { return raw_hex_iterator (tria, - -1, - -1, - this); + -1, + -1, + this); } @@ -1379,22 +1379,22 @@ DoFHandler::last_raw_hex (const unsigned int level) const { case 1: case 2: - Assert (false, ExcImpossibleInDim(dim)); - return raw_hex_iterator(); + Assert (false, ExcImpossibleInDim(dim)); + return raw_hex_iterator(); case 3: - Assert (leveln_levels(), - ExcInvalidLevel(level)); - Assert (tria->n_raw_hexs(level) != 0, - ExcEmptyLevel (level)); - - return raw_hex_iterator (tria, - level, - tria->n_raw_hexs(level)-1, - this); + Assert (leveln_levels(), + ExcInvalidLevel(level)); + Assert (tria->n_raw_hexs(level) != 0, + ExcEmptyLevel (level)); + + return raw_hex_iterator (tria, + level, + tria->n_raw_hexs(level)-1, + this); default: - Assert (false, ExcNotImplemented()); - return raw_hex_iterator(); + Assert (false, ExcNotImplemented()); + return raw_hex_iterator(); } } @@ -1413,7 +1413,7 @@ template typename DoFHandler::hex_iterator DoFHandler::last_hex (const unsigned int level) const { - // level is checked in last_raw + // level is checked in last_raw raw_hex_iterator ri = last_raw_hex(level); if (ri->used()==true) return ri; @@ -1438,7 +1438,7 @@ template typename DoFHandler::active_hex_iterator DoFHandler::last_active_hex (const unsigned int level) const { - // level is checked in last_raw + // level is checked in last_raw hex_iterator i = last_hex(level); if (i->has_children()==false) return i; @@ -1475,13 +1475,13 @@ unsigned int DoFHandler<1>::n_boundary_dofs () const template <> unsigned int DoFHandler<1>::n_boundary_dofs (const FunctionMap &boundary_indicators) const { - // check that only boundary - // indicators 0 and 1 are allowed - // in 1d + // check that only boundary + // indicators 0 and 1 are allowed + // in 1d for (FunctionMap::const_iterator i=boundary_indicators.begin(); i!=boundary_indicators.end(); ++i) Assert ((i->first == 0) || (i->first == 1), - ExcInvalidBoundaryIndicator()); + ExcInvalidBoundaryIndicator()); return boundary_indicators.size()*get_fe().dofs_per_vertex; } @@ -1491,13 +1491,13 @@ unsigned int DoFHandler<1>::n_boundary_dofs (const FunctionMap &boundary_indicat template <> unsigned int DoFHandler<1>::n_boundary_dofs (const std::set &boundary_indicators) const { - // check that only boundary - // indicators 0 and 1 are allowed - // in 1d + // check that only boundary + // indicators 0 and 1 are allowed + // in 1d for (std::set::const_iterator i=boundary_indicators.begin(); i!=boundary_indicators.end(); ++i) Assert ((*i == 0) || (*i == 1), - ExcInvalidBoundaryIndicator()); + ExcInvalidBoundaryIndicator()); return boundary_indicators.size()*get_fe().dofs_per_vertex; } @@ -1514,13 +1514,13 @@ unsigned int DoFHandler<1,2>::n_boundary_dofs () const template <> unsigned int DoFHandler<1,2>::n_boundary_dofs (const FunctionMap &boundary_indicators) const { - // check that only boundary - // indicators 0 and 1 are allowed - // in 1d + // check that only boundary + // indicators 0 and 1 are allowed + // in 1d for (FunctionMap::const_iterator i=boundary_indicators.begin(); i!=boundary_indicators.end(); ++i) Assert ((i->first == 0) || (i->first == 1), - ExcInvalidBoundaryIndicator()); + ExcInvalidBoundaryIndicator()); return boundary_indicators.size()*get_fe().dofs_per_vertex; } @@ -1530,13 +1530,13 @@ unsigned int DoFHandler<1,2>::n_boundary_dofs (const FunctionMap &boundary_indic template <> unsigned int DoFHandler<1,2>::n_boundary_dofs (const std::set &boundary_indicators) const { - // check that only boundary - // indicators 0 and 1 are allowed - // in 1d + // check that only boundary + // indicators 0 and 1 are allowed + // in 1d for (std::set::const_iterator i=boundary_indicators.begin(); i!=boundary_indicators.end(); ++i) Assert ((*i == 0) || (*i == 1), - ExcInvalidBoundaryIndicator()); + ExcInvalidBoundaryIndicator()); return boundary_indicators.size()*get_fe().dofs_per_vertex; } @@ -1551,24 +1551,24 @@ unsigned int DoFHandler::n_boundary_dofs () const const unsigned int dofs_per_face = get_fe().dofs_per_face; std::vector dofs_on_face(dofs_per_face); - // loop over all faces to check - // whether they are at a - // boundary. note that we need not - // take special care of single - // lines (using - // @p{cell->has_boundary_lines}), - // since we do not support - // boundaries of dimension dim-2, - // and so every boundary line is - // also part of a boundary face. + // loop over all faces to check + // whether they are at a + // boundary. note that we need not + // take special care of single + // lines (using + // @p{cell->has_boundary_lines}), + // since we do not support + // boundaries of dimension dim-2, + // and so every boundary line is + // also part of a boundary face. active_face_iterator face = begin_active_face (), - endf = end_face(); + endf = end_face(); for (; face!=endf; ++face) if (face->at_boundary()) { - face->get_dof_indices (dofs_on_face); - for (unsigned int i=0; iget_dof_indices (dofs_on_face); + for (unsigned int i=0; i::n_boundary_dofs (const FunctionMap &boundary_indicators) const { Assert (boundary_indicators.find(types::internal_face_boundary_id) == boundary_indicators.end(), - ExcInvalidBoundaryIndicator()); + ExcInvalidBoundaryIndicator()); std::set boundary_dofs; const unsigned int dofs_per_face = get_fe().dofs_per_face; std::vector dofs_on_face(dofs_per_face); active_face_iterator face = begin_active_face (), - endf = end_face(); + endf = end_face(); for (; face!=endf; ++face) if (boundary_indicators.find(face->boundary_indicator()) != - boundary_indicators.end()) + boundary_indicators.end()) { - face->get_dof_indices (dofs_on_face); - for (unsigned int i=0; iget_dof_indices (dofs_on_face); + for (unsigned int i=0; i::n_boundary_dofs (const std::set &boundary_indicators) const { Assert (boundary_indicators.find (types::internal_face_boundary_id) == boundary_indicators.end(), - ExcInvalidBoundaryIndicator()); + ExcInvalidBoundaryIndicator()); std::set boundary_dofs; const unsigned int dofs_per_face = get_fe().dofs_per_face; std::vector dofs_on_face(dofs_per_face); active_face_iterator face = begin_active_face (), - endf = end_face(); + endf = end_face(); for (; face!=endf; ++face) if (std::find (boundary_indicators.begin(), - boundary_indicators.end(), - face->boundary_indicator()) != - boundary_indicators.end()) + boundary_indicators.end(), + face->boundary_indicator()) != + boundary_indicators.end()) { - face->get_dof_indices (dofs_on_face); - for (unsigned int i=0; iget_dof_indices (dofs_on_face); + for (unsigned int i=0; i::memory_consumption () const { std::size_t mem = (MemoryConsumption::memory_consumption (tria) + - MemoryConsumption::memory_consumption (selected_fe) + - MemoryConsumption::memory_consumption (block_info_object) + - MemoryConsumption::memory_consumption (levels) + - MemoryConsumption::memory_consumption (*faces) + - MemoryConsumption::memory_consumption (faces) + - sizeof (number_cache) + - MemoryConsumption::memory_consumption (vertex_dofs)); + MemoryConsumption::memory_consumption (selected_fe) + + MemoryConsumption::memory_consumption (block_info_object) + + MemoryConsumption::memory_consumption (levels) + + MemoryConsumption::memory_consumption (*faces) + + MemoryConsumption::memory_consumption (faces) + + sizeof (number_cache) + + MemoryConsumption::memory_consumption (vertex_dofs)); for (unsigned int i=0; i::memory_consumption () const template void DoFHandler:: distribute_dofs (const FiniteElement &ff, - const unsigned int offset) + const unsigned int offset) { selected_fe = &ff; @@ -1675,14 +1675,14 @@ distribute_dofs (const FiniteElement &ff, clear_space (); internal::DoFHandler::Implementation::reserve_space (*this); - // hand things off to the policy + // hand things off to the policy number_cache = policy->distribute_dofs (offset, - *this); + *this); - // initialize the block info object - // only if this is a sequential - // triangulation. it doesn't work - // correctly yet if it is parallel + // initialize the block info object + // only if this is a sequential + // triangulation. it doesn't work + // correctly yet if it is parallel if (dynamic_cast*>(&*tria) == 0) block_info_object.initialize(*this); } @@ -1700,10 +1700,10 @@ void DoFHandler::initialize_local_block_info () template void DoFHandler::clear () { - // release lock to old fe + // release lock to old fe selected_fe = 0; - // release memory + // release memory clear_space (); } @@ -1715,18 +1715,18 @@ DoFHandler:: renumber_dofs (const std::vector &new_numbers) { Assert (new_numbers.size() == n_locally_owned_dofs(), - ExcRenumberingIncomplete()); + ExcRenumberingIncomplete()); #ifdef DEBUG - // assert that the new indices are - // consecutively numbered if we are - // working on a single - // processor. this doesn't need to - // hold in the case of a parallel - // mesh since we map the interval - // [0...n_dofs()) into itself but - // only globally, not on each - // processor + // assert that the new indices are + // consecutively numbered if we are + // working on a single + // processor. this doesn't need to + // hold in the case of a parallel + // mesh since we map the interval + // [0...n_dofs()) into itself but + // only globally, not on each + // processor if (n_locally_owned_dofs() == n_dofs()) { std::vector tmp(new_numbers); @@ -1734,12 +1734,12 @@ renumber_dofs (const std::vector &new_numbers) std::vector::const_iterator p = tmp.begin(); unsigned int i = 0; for (; p!=tmp.end(); ++p, ++i) - Assert (*p == i, ExcNewNumbersNotConsecutive(i)); + Assert (*p == i, ExcNewNumbersNotConsecutive(i)); } else for (unsigned int i=0; irenumber_dofs (new_numbers, *this); @@ -1763,33 +1763,33 @@ DoFHandler::max_couplings_between_boundary_dofs () const switch (dim) { case 1: - return get_fe().dofs_per_vertex; + return get_fe().dofs_per_vertex; case 2: - return (3*get_fe().dofs_per_vertex + - 2*get_fe().dofs_per_line); + return (3*get_fe().dofs_per_vertex + + 2*get_fe().dofs_per_line); case 3: - // we need to take refinement of - // one boundary face into - // consideration here; in fact, - // this function returns what - // #max_coupling_between_dofs<2> - // returns - // - // we assume here, that only four - // faces meet at the boundary; - // this assumption is not - // justified and needs to be - // fixed some time. fortunately, - // ommitting it for now does no - // harm since the matrix will cry - // foul if its requirements are - // not satisfied - return (19*get_fe().dofs_per_vertex + - 28*get_fe().dofs_per_line + - 8*get_fe().dofs_per_quad); + // we need to take refinement of + // one boundary face into + // consideration here; in fact, + // this function returns what + // #max_coupling_between_dofs<2> + // returns + // + // we assume here, that only four + // faces meet at the boundary; + // this assumption is not + // justified and needs to be + // fixed some time. fortunately, + // ommitting it for now does no + // harm since the matrix will cry + // foul if its requirements are + // not satisfied + return (19*get_fe().dofs_per_vertex + + 28*get_fe().dofs_per_line + + 8*get_fe().dofs_per_quad); default: - Assert (false, ExcNotImplemented()); - return numbers::invalid_unsigned_int; + Assert (false, ExcNotImplemented()); + return numbers::invalid_unsigned_int; } } diff --git a/deal.II/source/dofs/dof_handler_policy.cc b/deal.II/source/dofs/dof_handler_policy.cc index 1d03e7f2a5..435690e3d5 100644 --- a/deal.II/source/dofs/dof_handler_policy.cc +++ b/deal.II/source/dofs/dof_handler_policy.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -35,9 +35,9 @@ namespace internal { namespace Policy { - // use class dealii::DoFHandler instead - // of namespace internal::DoFHandler in - // the following + // use class dealii::DoFHandler instead + // of namespace internal::DoFHandler in + // the following using dealii::DoFHandler; struct Implementation @@ -45,436 +45,436 @@ namespace internal /* -------------- distribute_dofs functionality ------------- */ - /** - * Distribute dofs on the given cell, - * with new dofs starting with index - * @p next_free_dof. Return the next - * unused index number. - * - * This function is excluded from the - * @p distribute_dofs function since - * it can not be implemented dimension - * independent. - */ - template - static - unsigned int - distribute_dofs_on_cell (const DoFHandler<1,spacedim> &dof_handler, - const typename DoFHandler<1,spacedim>::active_cell_iterator &cell, - unsigned int next_free_dof) - { - - // distribute dofs of vertices - if (dof_handler.get_fe().dofs_per_vertex > 0) - for (unsigned int v=0; v::vertices_per_cell; ++v) - { - if (cell->vertex_dof_index (v,0) == - DoFHandler<1,spacedim>::invalid_dof_index) - for (unsigned int d=0; - dvertex_dof_index (v,d) == - DoFHandler<1,spacedim>::invalid_dof_index), - ExcInternalError()); - cell->set_vertex_dof_index (v, d, next_free_dof++); - } - else - for (unsigned int d=0; - dvertex_dof_index (v,d) != - DoFHandler<1,spacedim>::invalid_dof_index), - ExcInternalError()); - } - - // dofs of line - for (unsigned int d=0; - dset_dof_index (d, next_free_dof++); - - // note that this cell has been - // processed - cell->set_user_flag (); - - return next_free_dof; - } - - - - template - static - unsigned int - distribute_dofs_on_cell (const DoFHandler<2,spacedim> &dof_handler, - const typename DoFHandler<2,spacedim>::active_cell_iterator &cell, - unsigned int next_free_dof) - { - if (dof_handler.get_fe().dofs_per_vertex > 0) - // number dofs on vertices - for (unsigned int vertex=0; vertex::vertices_per_cell; ++vertex) - // check whether dofs for this - // vertex have been distributed - // (only check the first dof) - if (cell->vertex_dof_index(vertex, 0) == DoFHandler<2,spacedim>::invalid_dof_index) - for (unsigned int d=0; dset_vertex_dof_index (vertex, d, next_free_dof++); - - // for the four sides - if (dof_handler.get_fe().dofs_per_line > 0) - for (unsigned int side=0; side::faces_per_cell; ++side) - { - const typename DoFHandler<2,spacedim>::line_iterator - line = cell->line(side); - - // distribute dofs if necessary: - // check whether line dof is already - // numbered (check only first dof) - if (line->dof_index(0) == DoFHandler<2,spacedim>::invalid_dof_index) - // if not: distribute dofs - for (unsigned int d=0; dset_dof_index (d, next_free_dof++); - } - - - // dofs of quad - if (dof_handler.get_fe().dofs_per_quad > 0) - for (unsigned int d=0; dset_dof_index (d, next_free_dof++); - - - // note that this cell has been processed - cell->set_user_flag (); - - return next_free_dof; - } - - - template - static - unsigned int - distribute_dofs_on_cell (const DoFHandler<3,spacedim> &dof_handler, - const typename DoFHandler<3,spacedim>::active_cell_iterator &cell, - unsigned int next_free_dof) - { - if (dof_handler.get_fe().dofs_per_vertex > 0) - // number dofs on vertices - for (unsigned int vertex=0; vertex::vertices_per_cell; ++vertex) - // check whether dofs for this - // vertex have been distributed - // (only check the first dof) - if (cell->vertex_dof_index(vertex, 0) == DoFHandler<3,spacedim>::invalid_dof_index) - for (unsigned int d=0; dset_vertex_dof_index (vertex, d, next_free_dof++); - - // for the lines - if (dof_handler.get_fe().dofs_per_line > 0) - for (unsigned int l=0; l::lines_per_cell; ++l) - { - const typename DoFHandler<3,spacedim>::line_iterator - line = cell->line(l); - - // distribute dofs if necessary: - // check whether line dof is already - // numbered (check only first dof) - if (line->dof_index(0) == DoFHandler<3,spacedim>::invalid_dof_index) - // if not: distribute dofs - for (unsigned int d=0; dset_dof_index (d, next_free_dof++); - } - - // for the quads - if (dof_handler.get_fe().dofs_per_quad > 0) - for (unsigned int q=0; q::quads_per_cell; ++q) - { - const typename DoFHandler<3,spacedim>::quad_iterator - quad = cell->quad(q); - - // distribute dofs if necessary: - // check whether quad dof is already - // numbered (check only first dof) - if (quad->dof_index(0) == DoFHandler<3,spacedim>::invalid_dof_index) - // if not: distribute dofs - for (unsigned int d=0; dset_dof_index (d, next_free_dof++); - } - - - // dofs of hex - if (dof_handler.get_fe().dofs_per_hex > 0) - for (unsigned int d=0; dset_dof_index (d, next_free_dof++); - - - // note that this cell has been - // processed - cell->set_user_flag (); - - return next_free_dof; - } - - - /** - * Distribute degrees of - * freedom on all cells, or - * on cells with the - * correct subdomain_id if - * the corresponding - * argument is not equal to - * types::invalid_subdomain_id. Return - * the total number of dofs - * returned. - */ - template - static - unsigned int - distribute_dofs (const unsigned int offset, - const types::subdomain_id_t subdomain_id, - DoFHandler &dof_handler) - { - const dealii::Triangulation & tria - = dof_handler.get_tria(); - Assert (tria.n_levels() > 0, ExcMessage("Empty triangulation")); - - // Clear user flags because we will - // need them. But first we save - // them and make sure that we - // restore them later such that at - // the end of this function the - // Triangulation will be in the - // same state as it was at the - // beginning of this function. - std::vector user_flags; - tria.save_user_flags(user_flags); - const_cast &>(tria).clear_user_flags (); - - unsigned int next_free_dof = offset; - typename DoFHandler::active_cell_iterator - cell = dof_handler.begin_active(), - endc = dof_handler.end(); - - for (; cell != endc; ++cell) - if ((subdomain_id == types::invalid_subdomain_id) - || - (cell->subdomain_id() == subdomain_id)) - next_free_dof - = Implementation::distribute_dofs_on_cell (dof_handler, cell, next_free_dof); - - // update the cache used - // for cell dof indices - for (typename DoFHandler::cell_iterator - cell = dof_handler.begin(); cell != dof_handler.end(); ++cell) - if (cell->subdomain_id() != types::artificial_subdomain_id) - cell->update_cell_dof_indices_cache (); - - // finally restore the user flags - const_cast &>(tria).load_user_flags(user_flags); - - return next_free_dof; - } + /** + * Distribute dofs on the given cell, + * with new dofs starting with index + * @p next_free_dof. Return the next + * unused index number. + * + * This function is excluded from the + * @p distribute_dofs function since + * it can not be implemented dimension + * independent. + */ + template + static + unsigned int + distribute_dofs_on_cell (const DoFHandler<1,spacedim> &dof_handler, + const typename DoFHandler<1,spacedim>::active_cell_iterator &cell, + unsigned int next_free_dof) + { + + // distribute dofs of vertices + if (dof_handler.get_fe().dofs_per_vertex > 0) + for (unsigned int v=0; v::vertices_per_cell; ++v) + { + if (cell->vertex_dof_index (v,0) == + DoFHandler<1,spacedim>::invalid_dof_index) + for (unsigned int d=0; + dvertex_dof_index (v,d) == + DoFHandler<1,spacedim>::invalid_dof_index), + ExcInternalError()); + cell->set_vertex_dof_index (v, d, next_free_dof++); + } + else + for (unsigned int d=0; + dvertex_dof_index (v,d) != + DoFHandler<1,spacedim>::invalid_dof_index), + ExcInternalError()); + } + + // dofs of line + for (unsigned int d=0; + dset_dof_index (d, next_free_dof++); + + // note that this cell has been + // processed + cell->set_user_flag (); + + return next_free_dof; + } + + + + template + static + unsigned int + distribute_dofs_on_cell (const DoFHandler<2,spacedim> &dof_handler, + const typename DoFHandler<2,spacedim>::active_cell_iterator &cell, + unsigned int next_free_dof) + { + if (dof_handler.get_fe().dofs_per_vertex > 0) + // number dofs on vertices + for (unsigned int vertex=0; vertex::vertices_per_cell; ++vertex) + // check whether dofs for this + // vertex have been distributed + // (only check the first dof) + if (cell->vertex_dof_index(vertex, 0) == DoFHandler<2,spacedim>::invalid_dof_index) + for (unsigned int d=0; dset_vertex_dof_index (vertex, d, next_free_dof++); + + // for the four sides + if (dof_handler.get_fe().dofs_per_line > 0) + for (unsigned int side=0; side::faces_per_cell; ++side) + { + const typename DoFHandler<2,spacedim>::line_iterator + line = cell->line(side); + + // distribute dofs if necessary: + // check whether line dof is already + // numbered (check only first dof) + if (line->dof_index(0) == DoFHandler<2,spacedim>::invalid_dof_index) + // if not: distribute dofs + for (unsigned int d=0; dset_dof_index (d, next_free_dof++); + } + + + // dofs of quad + if (dof_handler.get_fe().dofs_per_quad > 0) + for (unsigned int d=0; dset_dof_index (d, next_free_dof++); + + + // note that this cell has been processed + cell->set_user_flag (); + + return next_free_dof; + } + + + template + static + unsigned int + distribute_dofs_on_cell (const DoFHandler<3,spacedim> &dof_handler, + const typename DoFHandler<3,spacedim>::active_cell_iterator &cell, + unsigned int next_free_dof) + { + if (dof_handler.get_fe().dofs_per_vertex > 0) + // number dofs on vertices + for (unsigned int vertex=0; vertex::vertices_per_cell; ++vertex) + // check whether dofs for this + // vertex have been distributed + // (only check the first dof) + if (cell->vertex_dof_index(vertex, 0) == DoFHandler<3,spacedim>::invalid_dof_index) + for (unsigned int d=0; dset_vertex_dof_index (vertex, d, next_free_dof++); + + // for the lines + if (dof_handler.get_fe().dofs_per_line > 0) + for (unsigned int l=0; l::lines_per_cell; ++l) + { + const typename DoFHandler<3,spacedim>::line_iterator + line = cell->line(l); + + // distribute dofs if necessary: + // check whether line dof is already + // numbered (check only first dof) + if (line->dof_index(0) == DoFHandler<3,spacedim>::invalid_dof_index) + // if not: distribute dofs + for (unsigned int d=0; dset_dof_index (d, next_free_dof++); + } + + // for the quads + if (dof_handler.get_fe().dofs_per_quad > 0) + for (unsigned int q=0; q::quads_per_cell; ++q) + { + const typename DoFHandler<3,spacedim>::quad_iterator + quad = cell->quad(q); + + // distribute dofs if necessary: + // check whether quad dof is already + // numbered (check only first dof) + if (quad->dof_index(0) == DoFHandler<3,spacedim>::invalid_dof_index) + // if not: distribute dofs + for (unsigned int d=0; dset_dof_index (d, next_free_dof++); + } + + + // dofs of hex + if (dof_handler.get_fe().dofs_per_hex > 0) + for (unsigned int d=0; dset_dof_index (d, next_free_dof++); + + + // note that this cell has been + // processed + cell->set_user_flag (); + + return next_free_dof; + } + + + /** + * Distribute degrees of + * freedom on all cells, or + * on cells with the + * correct subdomain_id if + * the corresponding + * argument is not equal to + * types::invalid_subdomain_id. Return + * the total number of dofs + * returned. + */ + template + static + unsigned int + distribute_dofs (const unsigned int offset, + const types::subdomain_id_t subdomain_id, + DoFHandler &dof_handler) + { + const dealii::Triangulation & tria + = dof_handler.get_tria(); + Assert (tria.n_levels() > 0, ExcMessage("Empty triangulation")); + + // Clear user flags because we will + // need them. But first we save + // them and make sure that we + // restore them later such that at + // the end of this function the + // Triangulation will be in the + // same state as it was at the + // beginning of this function. + std::vector user_flags; + tria.save_user_flags(user_flags); + const_cast &>(tria).clear_user_flags (); + + unsigned int next_free_dof = offset; + typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(), + endc = dof_handler.end(); + + for (; cell != endc; ++cell) + if ((subdomain_id == types::invalid_subdomain_id) + || + (cell->subdomain_id() == subdomain_id)) + next_free_dof + = Implementation::distribute_dofs_on_cell (dof_handler, cell, next_free_dof); + + // update the cache used + // for cell dof indices + for (typename DoFHandler::cell_iterator + cell = dof_handler.begin(); cell != dof_handler.end(); ++cell) + if (cell->subdomain_id() != types::artificial_subdomain_id) + cell->update_cell_dof_indices_cache (); + + // finally restore the user flags + const_cast &>(tria).load_user_flags(user_flags); + + return next_free_dof; + } /* --------------------- renumber_dofs functionality ---------------- */ - /** - * Implementation of the - * general template of same - * name. - * - * If the second argument - * has any elements set, - * elements of the then the - * vector of new numbers do - * not relate to the old - * DoF number but instead - * to the index of the old - * DoF number within the - * set of locally owned - * DoFs. - */ - template - static - void - renumber_dofs (const std::vector &new_numbers, - const IndexSet &, - DoFHandler<1,spacedim> &dof_handler, - const bool check_validity) - { - // note that we can not use cell - // iterators in this function since - // then we would renumber the dofs on - // the interface of two cells more - // than once. Anyway, this way it's - // not only more correct but also - // faster; note, however, that dof - // numbers may be invalid_dof_index, - // namely when the appropriate - // vertex/line/etc is unused - for (std::vector::iterator - i=dof_handler.vertex_dofs.begin(); - i!=dof_handler.vertex_dofs.end(); ++i) - if (*i != DoFHandler<1,spacedim>::invalid_dof_index) - *i = new_numbers[*i]; - else if (check_validity) - // if index is - // invalid_dof_index: - // check if this one - // really is unused - Assert (dof_handler.get_tria() - .vertex_used((i-dof_handler.vertex_dofs.begin()) / - dof_handler.selected_fe->dofs_per_vertex) - == false, - ExcInternalError ()); - - for (unsigned int level=0; level::iterator - i=dof_handler.levels[level]->lines.dofs.begin(); - i!=dof_handler.levels[level]->lines.dofs.end(); ++i) - if (*i != DoFHandler<1,spacedim>::invalid_dof_index) - *i = new_numbers[*i]; - - // update the cache - // used for cell dof - // indices - for (typename DoFHandler<1,spacedim>::cell_iterator - cell = dof_handler.begin(); - cell != dof_handler.end(); ++cell) - cell->update_cell_dof_indices_cache (); - } - - - - template - static - void - renumber_dofs (const std::vector &new_numbers, - const IndexSet &indices, - DoFHandler<2,spacedim> &dof_handler, - const bool check_validity) - { - // note that we can not use cell - // iterators in this function since - // then we would renumber the dofs on - // the interface of two cells more - // than once. Anyway, this way it's - // not only more correct but also - // faster; note, however, that dof - // numbers may be invalid_dof_index, - // namely when the appropriate - // vertex/line/etc is unused - for (std::vector::iterator - i=dof_handler.vertex_dofs.begin(); - i!=dof_handler.vertex_dofs.end(); ++i) - if (*i != DoFHandler<2,spacedim>::invalid_dof_index) - *i = (indices.n_elements() == 0)? - (new_numbers[*i]) : - (new_numbers[indices.index_within_set(*i)]); - else if (check_validity) - // if index is invalid_dof_index: - // check if this one really is - // unused - Assert (dof_handler.get_tria() - .vertex_used((i-dof_handler.vertex_dofs.begin()) / - dof_handler.selected_fe->dofs_per_vertex) - == false, - ExcInternalError ()); - - for (std::vector::iterator - i=dof_handler.faces->lines.dofs.begin(); - i!=dof_handler.faces->lines.dofs.end(); ++i) - if (*i != DoFHandler<2,spacedim>::invalid_dof_index) - *i = ((indices.n_elements() == 0) ? - new_numbers[*i] : - new_numbers[indices.index_within_set(*i)]); - - for (unsigned int level=0; level::iterator - i=dof_handler.levels[level]->quads.dofs.begin(); - i!=dof_handler.levels[level]->quads.dofs.end(); ++i) - if (*i != DoFHandler<2,spacedim>::invalid_dof_index) - *i = ((indices.n_elements() == 0) ? - new_numbers[*i] : - new_numbers[indices.index_within_set(*i)]); - } - - // update the cache - // used for cell dof - // indices - for (typename DoFHandler<2,spacedim>::cell_iterator - cell = dof_handler.begin(); - cell != dof_handler.end(); ++cell) - cell->update_cell_dof_indices_cache (); - } - - - template - static - void - renumber_dofs (const std::vector &new_numbers, - const IndexSet &indices, - DoFHandler<3,spacedim> &dof_handler, - const bool check_validity) - { - // note that we can not use cell - // iterators in this function since - // then we would renumber the dofs on - // the interface of two cells more - // than once. Anyway, this way it's - // not only more correct but also - // faster; note, however, that dof - // numbers may be invalid_dof_index, - // namely when the appropriate - // vertex/line/etc is unused - for (std::vector::iterator - i=dof_handler.vertex_dofs.begin(); - i!=dof_handler.vertex_dofs.end(); ++i) - if (*i != DoFHandler<3,spacedim>::invalid_dof_index) - *i = ((indices.n_elements() == 0) ? - new_numbers[*i] : - new_numbers[indices.index_within_set(*i)]); - else if (check_validity) - // if index is invalid_dof_index: - // check if this one really is - // unused - Assert (dof_handler.get_tria() - .vertex_used((i-dof_handler.vertex_dofs.begin()) / - dof_handler.selected_fe->dofs_per_vertex) - == false, - ExcInternalError ()); - - for (std::vector::iterator - i=dof_handler.faces->lines.dofs.begin(); - i!=dof_handler.faces->lines.dofs.end(); ++i) - if (*i != DoFHandler<3,spacedim>::invalid_dof_index) - *i = ((indices.n_elements() == 0) ? - new_numbers[*i] : - new_numbers[indices.index_within_set(*i)]); - for (std::vector::iterator - i=dof_handler.faces->quads.dofs.begin(); - i!=dof_handler.faces->quads.dofs.end(); ++i) - if (*i != DoFHandler<3,spacedim>::invalid_dof_index) - *i = ((indices.n_elements() == 0) ? - new_numbers[*i] : - new_numbers[indices.index_within_set(*i)]); - - for (unsigned int level=0; level::iterator - i=dof_handler.levels[level]->hexes.dofs.begin(); - i!=dof_handler.levels[level]->hexes.dofs.end(); ++i) - if (*i != DoFHandler<3,spacedim>::invalid_dof_index) - *i = ((indices.n_elements() == 0) ? - new_numbers[*i] : - new_numbers[indices.index_within_set(*i)]); - } - - // update the cache - // used for cell dof - // indices - for (typename DoFHandler<3,spacedim>::cell_iterator - cell = dof_handler.begin(); - cell != dof_handler.end(); ++cell) - cell->update_cell_dof_indices_cache (); - } + /** + * Implementation of the + * general template of same + * name. + * + * If the second argument + * has any elements set, + * elements of the then the + * vector of new numbers do + * not relate to the old + * DoF number but instead + * to the index of the old + * DoF number within the + * set of locally owned + * DoFs. + */ + template + static + void + renumber_dofs (const std::vector &new_numbers, + const IndexSet &, + DoFHandler<1,spacedim> &dof_handler, + const bool check_validity) + { + // note that we can not use cell + // iterators in this function since + // then we would renumber the dofs on + // the interface of two cells more + // than once. Anyway, this way it's + // not only more correct but also + // faster; note, however, that dof + // numbers may be invalid_dof_index, + // namely when the appropriate + // vertex/line/etc is unused + for (std::vector::iterator + i=dof_handler.vertex_dofs.begin(); + i!=dof_handler.vertex_dofs.end(); ++i) + if (*i != DoFHandler<1,spacedim>::invalid_dof_index) + *i = new_numbers[*i]; + else if (check_validity) + // if index is + // invalid_dof_index: + // check if this one + // really is unused + Assert (dof_handler.get_tria() + .vertex_used((i-dof_handler.vertex_dofs.begin()) / + dof_handler.selected_fe->dofs_per_vertex) + == false, + ExcInternalError ()); + + for (unsigned int level=0; level::iterator + i=dof_handler.levels[level]->lines.dofs.begin(); + i!=dof_handler.levels[level]->lines.dofs.end(); ++i) + if (*i != DoFHandler<1,spacedim>::invalid_dof_index) + *i = new_numbers[*i]; + + // update the cache + // used for cell dof + // indices + for (typename DoFHandler<1,spacedim>::cell_iterator + cell = dof_handler.begin(); + cell != dof_handler.end(); ++cell) + cell->update_cell_dof_indices_cache (); + } + + + + template + static + void + renumber_dofs (const std::vector &new_numbers, + const IndexSet &indices, + DoFHandler<2,spacedim> &dof_handler, + const bool check_validity) + { + // note that we can not use cell + // iterators in this function since + // then we would renumber the dofs on + // the interface of two cells more + // than once. Anyway, this way it's + // not only more correct but also + // faster; note, however, that dof + // numbers may be invalid_dof_index, + // namely when the appropriate + // vertex/line/etc is unused + for (std::vector::iterator + i=dof_handler.vertex_dofs.begin(); + i!=dof_handler.vertex_dofs.end(); ++i) + if (*i != DoFHandler<2,spacedim>::invalid_dof_index) + *i = (indices.n_elements() == 0)? + (new_numbers[*i]) : + (new_numbers[indices.index_within_set(*i)]); + else if (check_validity) + // if index is invalid_dof_index: + // check if this one really is + // unused + Assert (dof_handler.get_tria() + .vertex_used((i-dof_handler.vertex_dofs.begin()) / + dof_handler.selected_fe->dofs_per_vertex) + == false, + ExcInternalError ()); + + for (std::vector::iterator + i=dof_handler.faces->lines.dofs.begin(); + i!=dof_handler.faces->lines.dofs.end(); ++i) + if (*i != DoFHandler<2,spacedim>::invalid_dof_index) + *i = ((indices.n_elements() == 0) ? + new_numbers[*i] : + new_numbers[indices.index_within_set(*i)]); + + for (unsigned int level=0; level::iterator + i=dof_handler.levels[level]->quads.dofs.begin(); + i!=dof_handler.levels[level]->quads.dofs.end(); ++i) + if (*i != DoFHandler<2,spacedim>::invalid_dof_index) + *i = ((indices.n_elements() == 0) ? + new_numbers[*i] : + new_numbers[indices.index_within_set(*i)]); + } + + // update the cache + // used for cell dof + // indices + for (typename DoFHandler<2,spacedim>::cell_iterator + cell = dof_handler.begin(); + cell != dof_handler.end(); ++cell) + cell->update_cell_dof_indices_cache (); + } + + + template + static + void + renumber_dofs (const std::vector &new_numbers, + const IndexSet &indices, + DoFHandler<3,spacedim> &dof_handler, + const bool check_validity) + { + // note that we can not use cell + // iterators in this function since + // then we would renumber the dofs on + // the interface of two cells more + // than once. Anyway, this way it's + // not only more correct but also + // faster; note, however, that dof + // numbers may be invalid_dof_index, + // namely when the appropriate + // vertex/line/etc is unused + for (std::vector::iterator + i=dof_handler.vertex_dofs.begin(); + i!=dof_handler.vertex_dofs.end(); ++i) + if (*i != DoFHandler<3,spacedim>::invalid_dof_index) + *i = ((indices.n_elements() == 0) ? + new_numbers[*i] : + new_numbers[indices.index_within_set(*i)]); + else if (check_validity) + // if index is invalid_dof_index: + // check if this one really is + // unused + Assert (dof_handler.get_tria() + .vertex_used((i-dof_handler.vertex_dofs.begin()) / + dof_handler.selected_fe->dofs_per_vertex) + == false, + ExcInternalError ()); + + for (std::vector::iterator + i=dof_handler.faces->lines.dofs.begin(); + i!=dof_handler.faces->lines.dofs.end(); ++i) + if (*i != DoFHandler<3,spacedim>::invalid_dof_index) + *i = ((indices.n_elements() == 0) ? + new_numbers[*i] : + new_numbers[indices.index_within_set(*i)]); + for (std::vector::iterator + i=dof_handler.faces->quads.dofs.begin(); + i!=dof_handler.faces->quads.dofs.end(); ++i) + if (*i != DoFHandler<3,spacedim>::invalid_dof_index) + *i = ((indices.n_elements() == 0) ? + new_numbers[*i] : + new_numbers[indices.index_within_set(*i)]); + + for (unsigned int level=0; level::iterator + i=dof_handler.levels[level]->hexes.dofs.begin(); + i!=dof_handler.levels[level]->hexes.dofs.end(); ++i) + if (*i != DoFHandler<3,spacedim>::invalid_dof_index) + *i = ((indices.n_elements() == 0) ? + new_numbers[*i] : + new_numbers[indices.index_within_set(*i)]); + } + + // update the cache + // used for cell dof + // indices + for (typename DoFHandler<3,spacedim>::cell_iterator + cell = dof_handler.begin(); + cell != dof_handler.end(); ++cell) + cell->update_cell_dof_indices_cache (); + } }; @@ -493,33 +493,33 @@ namespace internal NumberCache Sequential:: distribute_dofs (const unsigned int offset, - DoFHandler &dof_handler) const + DoFHandler &dof_handler) const { - const unsigned int n_dofs = - Implementation::distribute_dofs (offset, - types::invalid_subdomain_id, - dof_handler); - - // now set the elements of the - // number cache appropriately - NumberCache number_cache; - number_cache.n_global_dofs = n_dofs; - number_cache.n_locally_owned_dofs = number_cache.n_global_dofs; - - number_cache.locally_owned_dofs - = IndexSet (number_cache.n_global_dofs); - number_cache.locally_owned_dofs.add_range (0, - number_cache.n_global_dofs); - number_cache.locally_owned_dofs.compress(); - - number_cache.n_locally_owned_dofs_per_processor - = std::vector (1, - number_cache.n_global_dofs); - - number_cache.locally_owned_dofs_per_processor - = std::vector (1, - number_cache.locally_owned_dofs); - return number_cache; + const unsigned int n_dofs = + Implementation::distribute_dofs (offset, + types::invalid_subdomain_id, + dof_handler); + + // now set the elements of the + // number cache appropriately + NumberCache number_cache; + number_cache.n_global_dofs = n_dofs; + number_cache.n_locally_owned_dofs = number_cache.n_global_dofs; + + number_cache.locally_owned_dofs + = IndexSet (number_cache.n_global_dofs); + number_cache.locally_owned_dofs.add_range (0, + number_cache.n_global_dofs); + number_cache.locally_owned_dofs.compress(); + + number_cache.n_locally_owned_dofs_per_processor + = std::vector (1, + number_cache.n_global_dofs); + + number_cache.locally_owned_dofs_per_processor + = std::vector (1, + number_cache.locally_owned_dofs); + return number_cache; } @@ -528,35 +528,35 @@ namespace internal NumberCache Sequential:: renumber_dofs (const std::vector &new_numbers, - dealii::DoFHandler &dof_handler) const + dealii::DoFHandler &dof_handler) const { - Implementation::renumber_dofs (new_numbers, IndexSet(0), - dof_handler, true); - - // in the sequential case, - // the number cache should - // not have changed but we - // have to set the elements - // of the structure - // appropriately anyway - NumberCache number_cache; - number_cache.n_global_dofs = dof_handler.n_dofs(); - number_cache.n_locally_owned_dofs = number_cache.n_global_dofs; - - number_cache.locally_owned_dofs - = IndexSet (number_cache.n_global_dofs); - number_cache.locally_owned_dofs.add_range (0, - number_cache.n_global_dofs); - number_cache.locally_owned_dofs.compress(); - - number_cache.n_locally_owned_dofs_per_processor - = std::vector (1, - number_cache.n_global_dofs); - - number_cache.locally_owned_dofs_per_processor - = std::vector (1, - number_cache.locally_owned_dofs); - return number_cache; + Implementation::renumber_dofs (new_numbers, IndexSet(0), + dof_handler, true); + + // in the sequential case, + // the number cache should + // not have changed but we + // have to set the elements + // of the structure + // appropriately anyway + NumberCache number_cache; + number_cache.n_global_dofs = dof_handler.n_dofs(); + number_cache.n_locally_owned_dofs = number_cache.n_global_dofs; + + number_cache.locally_owned_dofs + = IndexSet (number_cache.n_global_dofs); + number_cache.locally_owned_dofs.add_range (0, + number_cache.n_global_dofs); + number_cache.locally_owned_dofs.compress(); + + number_cache.n_locally_owned_dofs_per_processor + = std::vector (1, + number_cache.n_global_dofs); + + number_cache.locally_owned_dofs_per_processor + = std::vector (1, + number_cache.locally_owned_dofs); + return number_cache; } @@ -567,479 +567,479 @@ namespace internal namespace { - template - struct types - { - - /** - * A list of tree+quadrant and - * their dof indices. dofs is of - * the form num_dofindices of - * quadrant 0, followed by - * num_dofindices indices, - * num_dofindices of quadrant 1, - * ... - */ - struct cellinfo - { - std::vector tree_index; - std::vector::quadrant> quadrants; - std::vector dofs; - - unsigned int bytes_for_buffer () const - { - return (sizeof(unsigned int) + - tree_index.size() * sizeof(unsigned int) + - quadrants.size() * sizeof(typename dealii::internal::p4est - ::types::quadrant) + - dofs.size() * sizeof(unsigned int)); - } - - void pack_data (std::vector &buffer) const - { - buffer.resize(bytes_for_buffer()); - - char * ptr = &buffer[0]; - - const unsigned int num_cells = tree_index.size(); - std::memcpy(ptr, &num_cells, sizeof(unsigned int)); - ptr += sizeof(unsigned int); - - std::memcpy(ptr, - &tree_index[0], - num_cells*sizeof(unsigned int)); - ptr += num_cells*sizeof(unsigned int); - - std::memcpy(ptr, - &quadrants[0], - num_cells * sizeof(typename dealii::internal::p4est:: - types::quadrant)); - ptr += num_cells*sizeof(typename dealii::internal::p4est::types:: - quadrant); - - std::memcpy(ptr, - &dofs[0], - dofs.size() * sizeof(unsigned int)); - ptr += dofs.size() * sizeof(unsigned int); - - Assert (ptr == &buffer[0]+buffer.size(), - ExcInternalError()); - - } - }; - }; - - - - template - void - fill_dofindices_recursively (const typename parallel::distributed::Triangulation & tria, - const unsigned int tree_index, - const typename DoFHandler::cell_iterator &dealii_cell, - const typename dealii::internal::p4est::types::quadrant &p4est_cell, - const std::map > &vertices_with_ghost_neighbors, - std::map::cellinfo> &needs_to_get_cell) - { - // see if we have to - // recurse... - if (dealii_cell->has_children()) - { - typename dealii::internal::p4est::types::quadrant - p4est_child[GeometryInfo::max_children_per_cell]; - internal::p4est::init_quadrant_children(p4est_cell, p4est_child); - - - for (unsigned int c=0;c::max_children_per_cell; ++c) - fill_dofindices_recursively(tria, - tree_index, - dealii_cell->child(c), - p4est_child[c], - vertices_with_ghost_neighbors, - needs_to_get_cell); - return; - } - - // we're at a leaf cell. see if - // the cell is flagged as - // interesting. note that we - // have only flagged our own - // cells before - if (dealii_cell->user_flag_set() && !dealii_cell->is_ghost()) - { - Assert (!dealii_cell->is_artificial(), ExcInternalError()); - - // check each vertex if - // it is interesting and - // push dofindices if yes - std::set send_to; - for (unsigned int v=0; v::vertices_per_cell; ++v) - { - const std::map >::const_iterator - neighbor_subdomains_of_vertex - = vertices_with_ghost_neighbors.find (dealii_cell->vertex_index(v)); - - if (neighbor_subdomains_of_vertex == - vertices_with_ghost_neighbors.end()) - continue; - - Assert(neighbor_subdomains_of_vertex->second.size()!=0, - ExcInternalError()); - - send_to.insert(neighbor_subdomains_of_vertex->second.begin(), - neighbor_subdomains_of_vertex->second.end()); - } - - if (send_to.size() > 0) - { - // this cell's dof_indices - // need to be sent to - // someone - std::vector - local_dof_indices (dealii_cell->get_fe().dofs_per_cell); - dealii_cell->get_dof_indices (local_dof_indices); - - for (std::set::iterator it=send_to.begin(); - it!=send_to.end();++it) - { - const dealii::types::subdomain_id_t subdomain = *it; - - // get an iterator - // to what needs to - // be sent to that - // subdomain (if - // already exists), - // or create such - // an object - typename std::map::cellinfo>::iterator - p - = needs_to_get_cell.insert (std::make_pair(subdomain, - typename types::cellinfo())) - .first; - - p->second.tree_index.push_back(tree_index); - p->second.quadrants.push_back(p4est_cell); - - p->second.dofs.push_back(dealii_cell->get_fe().dofs_per_cell); - p->second.dofs.insert(p->second.dofs.end(), - local_dof_indices.begin(), - local_dof_indices.end()); - - } - } - } - } - - - template - void - set_dofindices_recursively ( - const parallel::distributed::Triangulation &tria, - const typename dealii::internal::p4est::types::quadrant &p4est_cell, - const typename DoFHandler::cell_iterator &dealii_cell, - const typename dealii::internal::p4est::types::quadrant &quadrant, - unsigned int * dofs) - { - if (internal::p4est::quadrant_is_equal(p4est_cell, quadrant)) - { - Assert(!dealii_cell->has_children(), ExcInternalError()); - Assert(dealii_cell->is_ghost(), ExcInternalError()); - - // update dof indices of cell - std::vector - dof_indices (dealii_cell->get_fe().dofs_per_cell); - dealii_cell->update_cell_dof_indices_cache(); - dealii_cell->get_dof_indices(dof_indices); - - bool complete = true; - for (unsigned int i=0;i::invalid_dof_index) - { - Assert((dof_indices[i] == - (DoFHandler::invalid_dof_index)) - || - (dof_indices[i]==dofs[i]), - ExcInternalError()); - dof_indices[i]=dofs[i]; - } - else - complete=false; - - if (!complete) - const_cast - ::cell_iterator &> - (dealii_cell)->set_user_flag(); - else - const_cast - ::cell_iterator &> - (dealii_cell)->clear_user_flag(); - - const_cast - ::cell_iterator &> - (dealii_cell)->set_dof_indices(dof_indices); - - return; - } - - if (! dealii_cell->has_children()) - return; - - if (! internal::p4est::quadrant_is_ancestor (p4est_cell, quadrant)) - return; - - typename dealii::internal::p4est::types::quadrant - p4est_child[GeometryInfo::max_children_per_cell]; - internal::p4est::init_quadrant_children(p4est_cell, p4est_child); - - for (unsigned int c=0; c::max_children_per_cell; ++c) - set_dofindices_recursively (tria, p4est_child[c], - dealii_cell->child(c), - quadrant, dofs); - } - - /** - * Return a vector in which, - * for every vertex index, we - * mark whether a locally owned - * cell is adjacent. - */ - template - std::vector - mark_locally_active_vertices (const parallel::distributed::Triangulation &triangulation) - { - std::vector locally_active_vertices (triangulation.n_vertices(), - false); - - for (typename dealii::Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell != triangulation.end(); ++cell) - if (cell->subdomain_id() == triangulation.locally_owned_subdomain()) - for (unsigned int v=0; v::vertices_per_cell; ++v) - locally_active_vertices[cell->vertex_index(v)] = true; - - return locally_active_vertices; - } - - - - template - void - communicate_dof_indices_on_marked_cells - (const DoFHandler<1,spacedim> &, - const std::map > &, - const std::vector &, - const std::vector &) - { - Assert (false, ExcNotImplemented()); - } - - - - template - void - communicate_dof_indices_on_marked_cells - (const DoFHandler &dof_handler, - const std::map > &vertices_with_ghost_neighbors, - const std::vector &coarse_cell_to_p4est_tree_permutation, - const std::vector &p4est_tree_to_coarse_cell_permutation) - { + template + struct types + { + + /** + * A list of tree+quadrant and + * their dof indices. dofs is of + * the form num_dofindices of + * quadrant 0, followed by + * num_dofindices indices, + * num_dofindices of quadrant 1, + * ... + */ + struct cellinfo + { + std::vector tree_index; + std::vector::quadrant> quadrants; + std::vector dofs; + + unsigned int bytes_for_buffer () const + { + return (sizeof(unsigned int) + + tree_index.size() * sizeof(unsigned int) + + quadrants.size() * sizeof(typename dealii::internal::p4est + ::types::quadrant) + + dofs.size() * sizeof(unsigned int)); + } + + void pack_data (std::vector &buffer) const + { + buffer.resize(bytes_for_buffer()); + + char * ptr = &buffer[0]; + + const unsigned int num_cells = tree_index.size(); + std::memcpy(ptr, &num_cells, sizeof(unsigned int)); + ptr += sizeof(unsigned int); + + std::memcpy(ptr, + &tree_index[0], + num_cells*sizeof(unsigned int)); + ptr += num_cells*sizeof(unsigned int); + + std::memcpy(ptr, + &quadrants[0], + num_cells * sizeof(typename dealii::internal::p4est:: + types::quadrant)); + ptr += num_cells*sizeof(typename dealii::internal::p4est::types:: + quadrant); + + std::memcpy(ptr, + &dofs[0], + dofs.size() * sizeof(unsigned int)); + ptr += dofs.size() * sizeof(unsigned int); + + Assert (ptr == &buffer[0]+buffer.size(), + ExcInternalError()); + + } + }; + }; + + + + template + void + fill_dofindices_recursively (const typename parallel::distributed::Triangulation & tria, + const unsigned int tree_index, + const typename DoFHandler::cell_iterator &dealii_cell, + const typename dealii::internal::p4est::types::quadrant &p4est_cell, + const std::map > &vertices_with_ghost_neighbors, + std::map::cellinfo> &needs_to_get_cell) + { + // see if we have to + // recurse... + if (dealii_cell->has_children()) + { + typename dealii::internal::p4est::types::quadrant + p4est_child[GeometryInfo::max_children_per_cell]; + internal::p4est::init_quadrant_children(p4est_cell, p4est_child); + + + for (unsigned int c=0;c::max_children_per_cell; ++c) + fill_dofindices_recursively(tria, + tree_index, + dealii_cell->child(c), + p4est_child[c], + vertices_with_ghost_neighbors, + needs_to_get_cell); + return; + } + + // we're at a leaf cell. see if + // the cell is flagged as + // interesting. note that we + // have only flagged our own + // cells before + if (dealii_cell->user_flag_set() && !dealii_cell->is_ghost()) + { + Assert (!dealii_cell->is_artificial(), ExcInternalError()); + + // check each vertex if + // it is interesting and + // push dofindices if yes + std::set send_to; + for (unsigned int v=0; v::vertices_per_cell; ++v) + { + const std::map >::const_iterator + neighbor_subdomains_of_vertex + = vertices_with_ghost_neighbors.find (dealii_cell->vertex_index(v)); + + if (neighbor_subdomains_of_vertex == + vertices_with_ghost_neighbors.end()) + continue; + + Assert(neighbor_subdomains_of_vertex->second.size()!=0, + ExcInternalError()); + + send_to.insert(neighbor_subdomains_of_vertex->second.begin(), + neighbor_subdomains_of_vertex->second.end()); + } + + if (send_to.size() > 0) + { + // this cell's dof_indices + // need to be sent to + // someone + std::vector + local_dof_indices (dealii_cell->get_fe().dofs_per_cell); + dealii_cell->get_dof_indices (local_dof_indices); + + for (std::set::iterator it=send_to.begin(); + it!=send_to.end();++it) + { + const dealii::types::subdomain_id_t subdomain = *it; + + // get an iterator + // to what needs to + // be sent to that + // subdomain (if + // already exists), + // or create such + // an object + typename std::map::cellinfo>::iterator + p + = needs_to_get_cell.insert (std::make_pair(subdomain, + typename types::cellinfo())) + .first; + + p->second.tree_index.push_back(tree_index); + p->second.quadrants.push_back(p4est_cell); + + p->second.dofs.push_back(dealii_cell->get_fe().dofs_per_cell); + p->second.dofs.insert(p->second.dofs.end(), + local_dof_indices.begin(), + local_dof_indices.end()); + + } + } + } + } + + + template + void + set_dofindices_recursively ( + const parallel::distributed::Triangulation &tria, + const typename dealii::internal::p4est::types::quadrant &p4est_cell, + const typename DoFHandler::cell_iterator &dealii_cell, + const typename dealii::internal::p4est::types::quadrant &quadrant, + unsigned int * dofs) + { + if (internal::p4est::quadrant_is_equal(p4est_cell, quadrant)) + { + Assert(!dealii_cell->has_children(), ExcInternalError()); + Assert(dealii_cell->is_ghost(), ExcInternalError()); + + // update dof indices of cell + std::vector + dof_indices (dealii_cell->get_fe().dofs_per_cell); + dealii_cell->update_cell_dof_indices_cache(); + dealii_cell->get_dof_indices(dof_indices); + + bool complete = true; + for (unsigned int i=0;i::invalid_dof_index) + { + Assert((dof_indices[i] == + (DoFHandler::invalid_dof_index)) + || + (dof_indices[i]==dofs[i]), + ExcInternalError()); + dof_indices[i]=dofs[i]; + } + else + complete=false; + + if (!complete) + const_cast + ::cell_iterator &> + (dealii_cell)->set_user_flag(); + else + const_cast + ::cell_iterator &> + (dealii_cell)->clear_user_flag(); + + const_cast + ::cell_iterator &> + (dealii_cell)->set_dof_indices(dof_indices); + + return; + } + + if (! dealii_cell->has_children()) + return; + + if (! internal::p4est::quadrant_is_ancestor (p4est_cell, quadrant)) + return; + + typename dealii::internal::p4est::types::quadrant + p4est_child[GeometryInfo::max_children_per_cell]; + internal::p4est::init_quadrant_children(p4est_cell, p4est_child); + + for (unsigned int c=0; c::max_children_per_cell; ++c) + set_dofindices_recursively (tria, p4est_child[c], + dealii_cell->child(c), + quadrant, dofs); + } + + /** + * Return a vector in which, + * for every vertex index, we + * mark whether a locally owned + * cell is adjacent. + */ + template + std::vector + mark_locally_active_vertices (const parallel::distributed::Triangulation &triangulation) + { + std::vector locally_active_vertices (triangulation.n_vertices(), + false); + + for (typename dealii::Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell) + if (cell->subdomain_id() == triangulation.locally_owned_subdomain()) + for (unsigned int v=0; v::vertices_per_cell; ++v) + locally_active_vertices[cell->vertex_index(v)] = true; + + return locally_active_vertices; + } + + + + template + void + communicate_dof_indices_on_marked_cells + (const DoFHandler<1,spacedim> &, + const std::map > &, + const std::vector &, + const std::vector &) + { + Assert (false, ExcNotImplemented()); + } + + + + template + void + communicate_dof_indices_on_marked_cells + (const DoFHandler &dof_handler, + const std::map > &vertices_with_ghost_neighbors, + const std::vector &coarse_cell_to_p4est_tree_permutation, + const std::vector &p4est_tree_to_coarse_cell_permutation) + { #ifndef DEAL_II_USE_P4EST - (void)vertices_with_ghost_neighbors; - Assert (false, ExcNotImplemented()); + (void)vertices_with_ghost_neighbors; + Assert (false, ExcNotImplemented()); #else - const parallel::distributed::Triangulation< dim, spacedim > * tr - = (dynamic_cast*> - (&dof_handler.get_tria())); - Assert (tr != 0, ExcInternalError()); - - // now collect cells and their - // dof_indices for the - // interested neighbors - typedef - std::map::cellinfo> - cellmap_t; - cellmap_t needs_to_get_cells; - - for (typename DoFHandler::cell_iterator - cell = dof_handler.begin(0); - cell != dof_handler.end(0); - ++cell) - { - typename dealii::internal::p4est::types::quadrant p4est_coarse_cell; - internal::p4est::init_coarse_quadrant(p4est_coarse_cell); - - fill_dofindices_recursively - (*tr, - coarse_cell_to_p4est_tree_permutation[cell->index()], - cell, - p4est_coarse_cell, - vertices_with_ghost_neighbors, - needs_to_get_cells); - } - - - - //sending - std::vector > sendbuffers (needs_to_get_cells.size()); - std::vector >::iterator buffer = sendbuffers.begin(); - std::vector requests (needs_to_get_cells.size()); - - unsigned int idx=0; - - for (typename cellmap_t::iterator it=needs_to_get_cells.begin(); - it!=needs_to_get_cells.end(); - ++it, ++buffer, ++idx) - { - const unsigned int num_cells = it->second.tree_index.size(); - - Assert(num_cells==it->second.quadrants.size(), ExcInternalError()); - Assert(num_cells>0, ExcInternalError()); - - // pack all the data into - // the buffer for this - // recipient and send - // it. keep data around - // till we can make sure - // that the packet has been - // received - it->second.pack_data (*buffer); - MPI_Isend(&(*buffer)[0], buffer->size(), - MPI_BYTE, it->first, - 123, tr->get_communicator(), &requests[idx]); - } - - - // mark all own cells, that miss some - // dof_data and collect the neighbors - // that are going to send stuff to us - std::set senders; - { - std::vector local_dof_indices; - typename DoFHandler::active_cell_iterator - cell, endc = dof_handler.end(); - - for (cell = dof_handler.begin_active(); cell != endc; ++cell) - if (!cell->is_artificial()) - { - if (cell->is_ghost()) - { - if (cell->user_flag_set()) - senders.insert(cell->subdomain_id()); - } - else - { - local_dof_indices.resize (cell->get_fe().dofs_per_cell); - cell->get_dof_indices (local_dof_indices); - if (local_dof_indices.end() != - std::find (local_dof_indices.begin(), - local_dof_indices.end(), - DoFHandler::invalid_dof_index)) - cell->set_user_flag(); - else - cell->clear_user_flag(); - } - - } - } - - - //* 5. receive ghostcelldata - std::vector receive; - typename types::cellinfo cellinfo; - for (unsigned int i=0;iget_communicator(), &status); - MPI_Get_count(&status, MPI_BYTE, &len); - receive.resize(len); - - char * ptr = &receive[0]; - MPI_Recv(ptr, len, MPI_BYTE, status.MPI_SOURCE, status.MPI_TAG, - tr->get_communicator(), &status); - - unsigned int cells; - memcpy(&cells, ptr, sizeof(unsigned int)); - ptr+=sizeof(unsigned int); - - //reinterpret too evil? - unsigned int * treeindex=reinterpret_cast(ptr); - ptr+=cells*sizeof(unsigned int); - typename dealii::internal::p4est::types::quadrant * quadrant - =reinterpret_cast::quadrant *>(ptr); - ptr+=cells*sizeof(typename dealii::internal::p4est::types::quadrant); - unsigned int * dofs=reinterpret_cast(ptr); - - for (unsigned int c=0;c::cell_iterator - cell (&dof_handler.get_tria(), - 0, - p4est_tree_to_coarse_cell_permutation[treeindex[c]], - &dof_handler); - - typename dealii::internal::p4est::types::quadrant p4est_coarse_cell; - internal::p4est::init_coarse_quadrant(p4est_coarse_cell); - - Assert(cell->get_fe().dofs_per_cell==dofs[0], ExcInternalError()); - - set_dofindices_recursively (*tr, - p4est_coarse_cell, - cell, - quadrant[c], - (dofs+1)); - } - } - - // complete all sends, so that we can - // safely destroy the buffers. - if (requests.size() > 0) - MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE); + const parallel::distributed::Triangulation< dim, spacedim > * tr + = (dynamic_cast*> + (&dof_handler.get_tria())); + Assert (tr != 0, ExcInternalError()); + + // now collect cells and their + // dof_indices for the + // interested neighbors + typedef + std::map::cellinfo> + cellmap_t; + cellmap_t needs_to_get_cells; + + for (typename DoFHandler::cell_iterator + cell = dof_handler.begin(0); + cell != dof_handler.end(0); + ++cell) + { + typename dealii::internal::p4est::types::quadrant p4est_coarse_cell; + internal::p4est::init_coarse_quadrant(p4est_coarse_cell); + + fill_dofindices_recursively + (*tr, + coarse_cell_to_p4est_tree_permutation[cell->index()], + cell, + p4est_coarse_cell, + vertices_with_ghost_neighbors, + needs_to_get_cells); + } + + + + //sending + std::vector > sendbuffers (needs_to_get_cells.size()); + std::vector >::iterator buffer = sendbuffers.begin(); + std::vector requests (needs_to_get_cells.size()); + + unsigned int idx=0; + + for (typename cellmap_t::iterator it=needs_to_get_cells.begin(); + it!=needs_to_get_cells.end(); + ++it, ++buffer, ++idx) + { + const unsigned int num_cells = it->second.tree_index.size(); + + Assert(num_cells==it->second.quadrants.size(), ExcInternalError()); + Assert(num_cells>0, ExcInternalError()); + + // pack all the data into + // the buffer for this + // recipient and send + // it. keep data around + // till we can make sure + // that the packet has been + // received + it->second.pack_data (*buffer); + MPI_Isend(&(*buffer)[0], buffer->size(), + MPI_BYTE, it->first, + 123, tr->get_communicator(), &requests[idx]); + } + + + // mark all own cells, that miss some + // dof_data and collect the neighbors + // that are going to send stuff to us + std::set senders; + { + std::vector local_dof_indices; + typename DoFHandler::active_cell_iterator + cell, endc = dof_handler.end(); + + for (cell = dof_handler.begin_active(); cell != endc; ++cell) + if (!cell->is_artificial()) + { + if (cell->is_ghost()) + { + if (cell->user_flag_set()) + senders.insert(cell->subdomain_id()); + } + else + { + local_dof_indices.resize (cell->get_fe().dofs_per_cell); + cell->get_dof_indices (local_dof_indices); + if (local_dof_indices.end() != + std::find (local_dof_indices.begin(), + local_dof_indices.end(), + DoFHandler::invalid_dof_index)) + cell->set_user_flag(); + else + cell->clear_user_flag(); + } + + } + } + + + //* 5. receive ghostcelldata + std::vector receive; + typename types::cellinfo cellinfo; + for (unsigned int i=0;iget_communicator(), &status); + MPI_Get_count(&status, MPI_BYTE, &len); + receive.resize(len); + + char * ptr = &receive[0]; + MPI_Recv(ptr, len, MPI_BYTE, status.MPI_SOURCE, status.MPI_TAG, + tr->get_communicator(), &status); + + unsigned int cells; + memcpy(&cells, ptr, sizeof(unsigned int)); + ptr+=sizeof(unsigned int); + + //reinterpret too evil? + unsigned int * treeindex=reinterpret_cast(ptr); + ptr+=cells*sizeof(unsigned int); + typename dealii::internal::p4est::types::quadrant * quadrant + =reinterpret_cast::quadrant *>(ptr); + ptr+=cells*sizeof(typename dealii::internal::p4est::types::quadrant); + unsigned int * dofs=reinterpret_cast(ptr); + + for (unsigned int c=0;c::cell_iterator + cell (&dof_handler.get_tria(), + 0, + p4est_tree_to_coarse_cell_permutation[treeindex[c]], + &dof_handler); + + typename dealii::internal::p4est::types::quadrant p4est_coarse_cell; + internal::p4est::init_coarse_quadrant(p4est_coarse_cell); + + Assert(cell->get_fe().dofs_per_cell==dofs[0], ExcInternalError()); + + set_dofindices_recursively (*tr, + p4est_coarse_cell, + cell, + quadrant[c], + (dofs+1)); + } + } + + // complete all sends, so that we can + // safely destroy the buffers. + if (requests.size() > 0) + MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE); #ifdef DEBUG - { - //check all msgs got sent and received - unsigned int sum_send=0; - unsigned int sum_recv=0; - unsigned int sent=needs_to_get_cells.size(); - unsigned int recv=senders.size(); - - MPI_Reduce(&sent, &sum_send, 1, MPI_UNSIGNED, MPI_SUM, 0, tr->get_communicator()); - MPI_Reduce(&recv, &sum_recv, 1, MPI_UNSIGNED, MPI_SUM, 0, tr->get_communicator()); - Assert(sum_send==sum_recv, ExcInternalError()); - } + { + //check all msgs got sent and received + unsigned int sum_send=0; + unsigned int sum_recv=0; + unsigned int sent=needs_to_get_cells.size(); + unsigned int recv=senders.size(); + + MPI_Reduce(&sent, &sum_send, 1, MPI_UNSIGNED, MPI_SUM, 0, tr->get_communicator()); + MPI_Reduce(&recv, &sum_recv, 1, MPI_UNSIGNED, MPI_SUM, 0, tr->get_communicator()); + Assert(sum_send==sum_recv, ExcInternalError()); + } #endif - //update dofindices - { - typename DoFHandler::active_cell_iterator - cell, endc = dof_handler.end(); - - for (cell = dof_handler.begin_active(); cell != endc; ++cell) - if (!cell->is_artificial()) - cell->update_cell_dof_indices_cache(); - } - - // important, so that sends between two - // calls to this function are not mixed - // up. - // - // this is necessary because above we - // just see if there are messages and - // then receive them, without - // discriminating where they come from - // and whether they were sent in phase - // 1 or 2. the need for a global - // communication step like this barrier - // could be avoided by receiving - // messages specifically from those - // processors from which we expect - // messages, and by using different - // tags for phase 1 and 2 - MPI_Barrier(tr->get_communicator()); + //update dofindices + { + typename DoFHandler::active_cell_iterator + cell, endc = dof_handler.end(); + + for (cell = dof_handler.begin_active(); cell != endc; ++cell) + if (!cell->is_artificial()) + cell->update_cell_dof_indices_cache(); + } + + // important, so that sends between two + // calls to this function are not mixed + // up. + // + // this is necessary because above we + // just see if there are messages and + // then receive them, without + // discriminating where they come from + // and whether they were sent in phase + // 1 or 2. the need for a global + // communication step like this barrier + // could be avoided by receiving + // messages specifically from those + // processors from which we expect + // messages, and by using different + // tags for phase 1 and 2 + MPI_Barrier(tr->get_communicator()); #endif - } + } } #endif // DEAL_II_USE_P4EST @@ -1050,236 +1050,236 @@ namespace internal NumberCache ParallelDistributed:: distribute_dofs (const unsigned int offset, - DoFHandler &dof_handler) const + DoFHandler &dof_handler) const { - Assert(offset==0, ExcNotImplemented()); - NumberCache number_cache; + Assert(offset==0, ExcNotImplemented()); + NumberCache number_cache; #ifndef DEAL_II_USE_P4EST - (void)dof_handler; - Assert (false, ExcNotImplemented()); + (void)dof_handler; + Assert (false, ExcNotImplemented()); #else - parallel::distributed::Triangulation< dim, spacedim > * tr - = (dynamic_cast*> - (const_cast*> - (&dof_handler.get_tria()))); - Assert (tr != 0, ExcInternalError()); - - const unsigned int - n_cpus = Utilities::MPI::n_mpi_processes (tr->get_communicator()); - - //* 1. distribute on own - //* subdomain - const unsigned int n_initial_local_dofs = - Implementation::distribute_dofs (0, tr->locally_owned_subdomain(), - dof_handler); - - //* 2. iterate over ghostcells and - //kill dofs that are not owned - //by us - std::vector renumbering(n_initial_local_dofs); - for (unsigned int i=0; i local_dof_indices; - - typename DoFHandler::active_cell_iterator - cell = dof_handler.begin_active(), - endc = dof_handler.end(); - - for (; cell != endc; ++cell) - if (cell->is_ghost() && - (cell->subdomain_id() < tr->locally_owned_subdomain())) - { - // we found a - // neighboring ghost - // cell whose subdomain - // is "stronger" than - // our own subdomain - - // delete all dofs that - // live there and that - // we have previously - // assigned a number to - // (i.e. the ones on - // the interface) - local_dof_indices.resize (cell->get_fe().dofs_per_cell); - cell->get_dof_indices (local_dof_indices); - for (unsigned int i=0; iget_fe().dofs_per_cell; ++i) - if (local_dof_indices[i] != DoFHandler::invalid_dof_index) - renumbering[local_dof_indices[i]] - = DoFHandler::invalid_dof_index; - } - } - - - // make indices consecutive - number_cache.n_locally_owned_dofs = 0; - for (std::vector::iterator it=renumbering.begin(); - it!=renumbering.end(); ++it) - if (*it != DoFHandler::invalid_dof_index) - *it = number_cache.n_locally_owned_dofs++; - - //* 3. communicate local dofcount and - //shift ids to make them unique - number_cache.n_locally_owned_dofs_per_processor.resize(n_cpus); - - MPI_Allgather ( &number_cache.n_locally_owned_dofs, - 1, MPI_UNSIGNED, - &number_cache.n_locally_owned_dofs_per_processor[0], - 1, MPI_UNSIGNED, - tr->get_communicator()); - - const unsigned int - shift = std::accumulate (number_cache - .n_locally_owned_dofs_per_processor.begin(), - number_cache - .n_locally_owned_dofs_per_processor.begin() - + tr->locally_owned_subdomain(), - 0); - for (std::vector::iterator it=renumbering.begin(); - it!=renumbering.end(); ++it) - if (*it != DoFHandler::invalid_dof_index) - (*it) += shift; - - // now re-enumerate all dofs to - // this shifted and condensed - // numbering form. we renumber - // some dofs as invalid, so - // choose the nocheck-version. - Implementation::renumber_dofs (renumbering, IndexSet(0), - dof_handler, false); - - // now a little bit of - // housekeeping - number_cache.n_global_dofs - = std::accumulate (number_cache - .n_locally_owned_dofs_per_processor.begin(), - number_cache - .n_locally_owned_dofs_per_processor.end(), - 0); - - number_cache.locally_owned_dofs = IndexSet(number_cache.n_global_dofs); - number_cache.locally_owned_dofs - .add_range(shift, - shift+number_cache.n_locally_owned_dofs); - number_cache.locally_owned_dofs.compress(); - - // fill global_dof_indexsets - number_cache.locally_owned_dofs_per_processor.resize(n_cpus); - { - unsigned int lshift = 0; - for (unsigned int i=0;ilocally_owned_subdomain()].n_elements() - == - number_cache.n_locally_owned_dofs, - ExcInternalError()); - Assert(!number_cache.locally_owned_dofs_per_processor - [tr->locally_owned_subdomain()].n_elements() - || - number_cache.locally_owned_dofs_per_processor - [tr->locally_owned_subdomain()].nth_index_in_set(0) - == shift, - ExcInternalError()); - - //* 4. send dofids of cells that are - //ghostcells on other machines - - std::vector user_flags; - tr->save_user_flags(user_flags); - tr->clear_user_flags (); - - //mark all own cells for transfer - typename DoFHandler::active_cell_iterator - cell, endc = dof_handler.end(); - for (cell = dof_handler.begin_active(); cell != endc; ++cell) - if (!cell->is_artificial()) - cell->set_user_flag(); - - //mark the vertices we are interested - //in, i.e. belonging to own and marked cells - const std::vector locally_active_vertices - = mark_locally_active_vertices (*tr); - - // add each ghostcells' - // subdomain to the vertex and - // keep track of interesting - // neighbors - std::map > - vertices_with_ghost_neighbors; - for (typename DoFHandler::active_cell_iterator - cell = dof_handler.begin_active(); - cell != dof_handler.end(); ++cell) - if (cell->is_ghost ()) - for (unsigned int v=0; v::vertices_per_cell; ++v) - if (locally_active_vertices[cell->vertex_index(v)]) - vertices_with_ghost_neighbors[cell->vertex_index(v)] - .insert (cell->subdomain_id()); - - - /* Send and receive cells. After this, - only the local cells are marked, - that received new data. This has to - be communicated in a second - communication step. */ - communicate_dof_indices_on_marked_cells (dof_handler, - vertices_with_ghost_neighbors, - tr->coarse_cell_to_p4est_tree_permutation, - tr->p4est_tree_to_coarse_cell_permutation); - - communicate_dof_indices_on_marked_cells (dof_handler, - vertices_with_ghost_neighbors, - tr->coarse_cell_to_p4est_tree_permutation, - tr->p4est_tree_to_coarse_cell_permutation); - - tr->load_user_flags(user_flags); + parallel::distributed::Triangulation< dim, spacedim > * tr + = (dynamic_cast*> + (const_cast*> + (&dof_handler.get_tria()))); + Assert (tr != 0, ExcInternalError()); + + const unsigned int + n_cpus = Utilities::MPI::n_mpi_processes (tr->get_communicator()); + + //* 1. distribute on own + //* subdomain + const unsigned int n_initial_local_dofs = + Implementation::distribute_dofs (0, tr->locally_owned_subdomain(), + dof_handler); + + //* 2. iterate over ghostcells and + //kill dofs that are not owned + //by us + std::vector renumbering(n_initial_local_dofs); + for (unsigned int i=0; i local_dof_indices; + + typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(), + endc = dof_handler.end(); + + for (; cell != endc; ++cell) + if (cell->is_ghost() && + (cell->subdomain_id() < tr->locally_owned_subdomain())) + { + // we found a + // neighboring ghost + // cell whose subdomain + // is "stronger" than + // our own subdomain + + // delete all dofs that + // live there and that + // we have previously + // assigned a number to + // (i.e. the ones on + // the interface) + local_dof_indices.resize (cell->get_fe().dofs_per_cell); + cell->get_dof_indices (local_dof_indices); + for (unsigned int i=0; iget_fe().dofs_per_cell; ++i) + if (local_dof_indices[i] != DoFHandler::invalid_dof_index) + renumbering[local_dof_indices[i]] + = DoFHandler::invalid_dof_index; + } + } + + + // make indices consecutive + number_cache.n_locally_owned_dofs = 0; + for (std::vector::iterator it=renumbering.begin(); + it!=renumbering.end(); ++it) + if (*it != DoFHandler::invalid_dof_index) + *it = number_cache.n_locally_owned_dofs++; + + //* 3. communicate local dofcount and + //shift ids to make them unique + number_cache.n_locally_owned_dofs_per_processor.resize(n_cpus); + + MPI_Allgather ( &number_cache.n_locally_owned_dofs, + 1, MPI_UNSIGNED, + &number_cache.n_locally_owned_dofs_per_processor[0], + 1, MPI_UNSIGNED, + tr->get_communicator()); + + const unsigned int + shift = std::accumulate (number_cache + .n_locally_owned_dofs_per_processor.begin(), + number_cache + .n_locally_owned_dofs_per_processor.begin() + + tr->locally_owned_subdomain(), + 0); + for (std::vector::iterator it=renumbering.begin(); + it!=renumbering.end(); ++it) + if (*it != DoFHandler::invalid_dof_index) + (*it) += shift; + + // now re-enumerate all dofs to + // this shifted and condensed + // numbering form. we renumber + // some dofs as invalid, so + // choose the nocheck-version. + Implementation::renumber_dofs (renumbering, IndexSet(0), + dof_handler, false); + + // now a little bit of + // housekeeping + number_cache.n_global_dofs + = std::accumulate (number_cache + .n_locally_owned_dofs_per_processor.begin(), + number_cache + .n_locally_owned_dofs_per_processor.end(), + 0); + + number_cache.locally_owned_dofs = IndexSet(number_cache.n_global_dofs); + number_cache.locally_owned_dofs + .add_range(shift, + shift+number_cache.n_locally_owned_dofs); + number_cache.locally_owned_dofs.compress(); + + // fill global_dof_indexsets + number_cache.locally_owned_dofs_per_processor.resize(n_cpus); + { + unsigned int lshift = 0; + for (unsigned int i=0;ilocally_owned_subdomain()].n_elements() + == + number_cache.n_locally_owned_dofs, + ExcInternalError()); + Assert(!number_cache.locally_owned_dofs_per_processor + [tr->locally_owned_subdomain()].n_elements() + || + number_cache.locally_owned_dofs_per_processor + [tr->locally_owned_subdomain()].nth_index_in_set(0) + == shift, + ExcInternalError()); + + //* 4. send dofids of cells that are + //ghostcells on other machines + + std::vector user_flags; + tr->save_user_flags(user_flags); + tr->clear_user_flags (); + + //mark all own cells for transfer + typename DoFHandler::active_cell_iterator + cell, endc = dof_handler.end(); + for (cell = dof_handler.begin_active(); cell != endc; ++cell) + if (!cell->is_artificial()) + cell->set_user_flag(); + + //mark the vertices we are interested + //in, i.e. belonging to own and marked cells + const std::vector locally_active_vertices + = mark_locally_active_vertices (*tr); + + // add each ghostcells' + // subdomain to the vertex and + // keep track of interesting + // neighbors + std::map > + vertices_with_ghost_neighbors; + for (typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(); + cell != dof_handler.end(); ++cell) + if (cell->is_ghost ()) + for (unsigned int v=0; v::vertices_per_cell; ++v) + if (locally_active_vertices[cell->vertex_index(v)]) + vertices_with_ghost_neighbors[cell->vertex_index(v)] + .insert (cell->subdomain_id()); + + + /* Send and receive cells. After this, + only the local cells are marked, + that received new data. This has to + be communicated in a second + communication step. */ + communicate_dof_indices_on_marked_cells (dof_handler, + vertices_with_ghost_neighbors, + tr->coarse_cell_to_p4est_tree_permutation, + tr->p4est_tree_to_coarse_cell_permutation); + + communicate_dof_indices_on_marked_cells (dof_handler, + vertices_with_ghost_neighbors, + tr->coarse_cell_to_p4est_tree_permutation, + tr->p4est_tree_to_coarse_cell_permutation); + + tr->load_user_flags(user_flags); #ifdef DEBUG - //check that we are really done - { - std::vector local_dof_indices; - typename DoFHandler::active_cell_iterator - cell, endc = dof_handler.end(); - - for (cell = dof_handler.begin_active(); cell != endc; ++cell) - if (!cell->is_artificial()) - { - local_dof_indices.resize (cell->get_fe().dofs_per_cell); - cell->get_dof_indices (local_dof_indices); - if (local_dof_indices.end() != - std::find (local_dof_indices.begin(), - local_dof_indices.end(), - DoFHandler::invalid_dof_index)) - { - if (cell->is_ghost()) - { - Assert(false, ExcMessage ("Not a ghost cell")); - } - else - { - Assert(false, ExcMessage ("Not one of our own cells")); - } - } - } - } + //check that we are really done + { + std::vector local_dof_indices; + typename DoFHandler::active_cell_iterator + cell, endc = dof_handler.end(); + + for (cell = dof_handler.begin_active(); cell != endc; ++cell) + if (!cell->is_artificial()) + { + local_dof_indices.resize (cell->get_fe().dofs_per_cell); + cell->get_dof_indices (local_dof_indices); + if (local_dof_indices.end() != + std::find (local_dof_indices.begin(), + local_dof_indices.end(), + DoFHandler::invalid_dof_index)) + { + if (cell->is_ghost()) + { + Assert(false, ExcMessage ("Not a ghost cell")); + } + else + { + Assert(false, ExcMessage ("Not one of our own cells")); + } + } + } + } #endif // DEBUG #endif // DEAL_II_USE_P4EST - return number_cache; + return number_cache; } @@ -1288,268 +1288,268 @@ namespace internal NumberCache ParallelDistributed:: renumber_dofs (const std::vector &new_numbers, - dealii::DoFHandler &dof_handler) const + dealii::DoFHandler &dof_handler) const { - Assert (new_numbers.size() == dof_handler.locally_owned_dofs().n_elements(), - ExcInternalError()); + Assert (new_numbers.size() == dof_handler.locally_owned_dofs().n_elements(), + ExcInternalError()); - NumberCache number_cache; + NumberCache number_cache; #ifndef DEAL_II_USE_P4EST - Assert (false, ExcNotImplemented()); + Assert (false, ExcNotImplemented()); #else - //calculate new IndexSet. First try - //to find out if the new indices are - //contiguous blocks. This avoids - //inserting each index individually - //into the IndexSet, which is slow. - //If we own no DoFs, we still need to - //go through this function, but we - //can skip this calculation. - - number_cache.locally_owned_dofs = IndexSet (dof_handler.n_dofs()); - if (dof_handler.locally_owned_dofs().n_elements()>0) - { - std::vector::const_iterator it = new_numbers.begin(); - const unsigned int n_blocks = dof_handler.get_fe().n_blocks(); - std::vector > block_indices(n_blocks); - block_indices[0].first = *it++; - block_indices[0].second = 1; - unsigned int current_block = 0, n_filled_blocks = 1; - for ( ; it != new_numbers.end(); ++it) - { - bool done = false; - - // search from the current block onwards - // whether the next index is shifted by one - // from the previous one. - for (unsigned int i=0; i local_dof_indices; - - typename DoFHandler::active_cell_iterator - cell = dof_handler.begin_active(), - endc = dof_handler.end(); - - for (; cell != endc; ++cell) - if (!cell->is_artificial()) - { - local_dof_indices.resize (cell->get_fe().dofs_per_cell); - cell->get_dof_indices (local_dof_indices); - for (unsigned int i=0; iget_fe().dofs_per_cell; ++i) - { - if (local_dof_indices[i] == DoFHandler::invalid_dof_index) - continue; - - if (!dof_handler.locally_owned_dofs().is_element(local_dof_indices[i])) - { - //this DoF is not owned - //by us, so set it to - //invalid. - local_dof_indices[i] - = DoFHandler::invalid_dof_index; - } - } - - cell->set_dof_indices (local_dof_indices); - } - } - - - // renumber. Skip when there is - // nothing to do because we own no - // DoF. - if (dof_handler.locally_owned_dofs().n_elements() > 0) - Implementation::renumber_dofs (new_numbers, - dof_handler.locally_owned_dofs(), - dof_handler, - false); - - // communication - { - parallel::distributed::Triangulation< dim, spacedim > * tr - = (dynamic_cast*> - (const_cast*> - (&dof_handler.get_tria()))); - Assert (tr != 0, ExcInternalError()); - - std::vector user_flags; - tr->save_user_flags(user_flags); - tr->clear_user_flags (); - - //mark all own cells for transfer - typename DoFHandler::active_cell_iterator - cell, endc = dof_handler.end(); - for (cell = dof_handler.begin_active(); cell != endc; ++cell) - if (!cell->is_artificial()) - cell->set_user_flag(); - //mark the vertices we are interested - //in, i.e. belonging to own and marked cells - const std::vector locally_active_vertices - = mark_locally_active_vertices (*tr); - - // add each ghostcells' - // subdomain to the vertex and - // keep track of interesting - // neighbors - std::map > - vertices_with_ghost_neighbors; - for (typename DoFHandler::active_cell_iterator - cell = dof_handler.begin_active(); - cell != dof_handler.end(); ++cell) - if (cell->is_ghost ()) - for (unsigned int v=0; v::vertices_per_cell; ++v) - if (locally_active_vertices[cell->vertex_index(v)]) - vertices_with_ghost_neighbors[cell->vertex_index(v)] - .insert (cell->subdomain_id()); - - // Send and receive cells. After this, only - // the local cells are marked, that received - // new data. This has to be communicated in a - // second communication step. - communicate_dof_indices_on_marked_cells (dof_handler, - vertices_with_ghost_neighbors, - tr->coarse_cell_to_p4est_tree_permutation, - tr->p4est_tree_to_coarse_cell_permutation); - - communicate_dof_indices_on_marked_cells (dof_handler, - vertices_with_ghost_neighbors, - tr->coarse_cell_to_p4est_tree_permutation, - tr->p4est_tree_to_coarse_cell_permutation); - - - // * Create global_dof_indexsets by - // transfering our own owned_dofs to - // every other machine. - const unsigned int n_cpus = Utilities::System:: - get_n_mpi_processes (tr->get_communicator()); - - // Serialize our IndexSet and - // determine size. - std::ostringstream oss; - number_cache.locally_owned_dofs.block_write(oss); - std::string oss_str=oss.str(); - std::vector my_data(oss_str.begin(), oss_str.end()); - unsigned int my_size = oss_str.size(); - - // determine maximum size of IndexSet - const unsigned int max_size - = Utilities::MPI::max (my_size, tr->get_communicator()); - - // as we are reading past the end, we - // need to increase the size of the - // local buffer. This is filled with - // zeros. - my_data.resize(max_size); - - std::vector buffer(max_size*n_cpus); - MPI_Allgather(&my_data[0], max_size, MPI_BYTE, - &buffer[0], max_size, MPI_BYTE, - tr->get_communicator()); - - number_cache.locally_owned_dofs_per_processor.resize (n_cpus); - number_cache.n_locally_owned_dofs_per_processor.resize (n_cpus); - for (unsigned int i=0;iload_user_flags(user_flags); - } + //calculate new IndexSet. First try + //to find out if the new indices are + //contiguous blocks. This avoids + //inserting each index individually + //into the IndexSet, which is slow. + //If we own no DoFs, we still need to + //go through this function, but we + //can skip this calculation. + + number_cache.locally_owned_dofs = IndexSet (dof_handler.n_dofs()); + if (dof_handler.locally_owned_dofs().n_elements()>0) + { + std::vector::const_iterator it = new_numbers.begin(); + const unsigned int n_blocks = dof_handler.get_fe().n_blocks(); + std::vector > block_indices(n_blocks); + block_indices[0].first = *it++; + block_indices[0].second = 1; + unsigned int current_block = 0, n_filled_blocks = 1; + for ( ; it != new_numbers.end(); ++it) + { + bool done = false; + + // search from the current block onwards + // whether the next index is shifted by one + // from the previous one. + for (unsigned int i=0; i local_dof_indices; + + typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(), + endc = dof_handler.end(); + + for (; cell != endc; ++cell) + if (!cell->is_artificial()) + { + local_dof_indices.resize (cell->get_fe().dofs_per_cell); + cell->get_dof_indices (local_dof_indices); + for (unsigned int i=0; iget_fe().dofs_per_cell; ++i) + { + if (local_dof_indices[i] == DoFHandler::invalid_dof_index) + continue; + + if (!dof_handler.locally_owned_dofs().is_element(local_dof_indices[i])) + { + //this DoF is not owned + //by us, so set it to + //invalid. + local_dof_indices[i] + = DoFHandler::invalid_dof_index; + } + } + + cell->set_dof_indices (local_dof_indices); + } + } + + + // renumber. Skip when there is + // nothing to do because we own no + // DoF. + if (dof_handler.locally_owned_dofs().n_elements() > 0) + Implementation::renumber_dofs (new_numbers, + dof_handler.locally_owned_dofs(), + dof_handler, + false); + + // communication + { + parallel::distributed::Triangulation< dim, spacedim > * tr + = (dynamic_cast*> + (const_cast*> + (&dof_handler.get_tria()))); + Assert (tr != 0, ExcInternalError()); + + std::vector user_flags; + tr->save_user_flags(user_flags); + tr->clear_user_flags (); + + //mark all own cells for transfer + typename DoFHandler::active_cell_iterator + cell, endc = dof_handler.end(); + for (cell = dof_handler.begin_active(); cell != endc; ++cell) + if (!cell->is_artificial()) + cell->set_user_flag(); + //mark the vertices we are interested + //in, i.e. belonging to own and marked cells + const std::vector locally_active_vertices + = mark_locally_active_vertices (*tr); + + // add each ghostcells' + // subdomain to the vertex and + // keep track of interesting + // neighbors + std::map > + vertices_with_ghost_neighbors; + for (typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(); + cell != dof_handler.end(); ++cell) + if (cell->is_ghost ()) + for (unsigned int v=0; v::vertices_per_cell; ++v) + if (locally_active_vertices[cell->vertex_index(v)]) + vertices_with_ghost_neighbors[cell->vertex_index(v)] + .insert (cell->subdomain_id()); + + // Send and receive cells. After this, only + // the local cells are marked, that received + // new data. This has to be communicated in a + // second communication step. + communicate_dof_indices_on_marked_cells (dof_handler, + vertices_with_ghost_neighbors, + tr->coarse_cell_to_p4est_tree_permutation, + tr->p4est_tree_to_coarse_cell_permutation); + + communicate_dof_indices_on_marked_cells (dof_handler, + vertices_with_ghost_neighbors, + tr->coarse_cell_to_p4est_tree_permutation, + tr->p4est_tree_to_coarse_cell_permutation); + + + // * Create global_dof_indexsets by + // transfering our own owned_dofs to + // every other machine. + const unsigned int n_cpus = Utilities::System:: + get_n_mpi_processes (tr->get_communicator()); + + // Serialize our IndexSet and + // determine size. + std::ostringstream oss; + number_cache.locally_owned_dofs.block_write(oss); + std::string oss_str=oss.str(); + std::vector my_data(oss_str.begin(), oss_str.end()); + unsigned int my_size = oss_str.size(); + + // determine maximum size of IndexSet + const unsigned int max_size + = Utilities::MPI::max (my_size, tr->get_communicator()); + + // as we are reading past the end, we + // need to increase the size of the + // local buffer. This is filled with + // zeros. + my_data.resize(max_size); + + std::vector buffer(max_size*n_cpus); + MPI_Allgather(&my_data[0], max_size, MPI_BYTE, + &buffer[0], max_size, MPI_BYTE, + tr->get_communicator()); + + number_cache.locally_owned_dofs_per_processor.resize (n_cpus); + number_cache.n_locally_owned_dofs_per_processor.resize (n_cpus); + for (unsigned int i=0;iload_user_flags(user_flags); + } #endif - return number_cache; + return number_cache; } } } diff --git a/deal.II/source/dofs/dof_levels.cc b/deal.II/source/dofs/dof_levels.cc index e681ea2453..c595f65a3c 100644 --- a/deal.II/source/dofs/dof_levels.cc +++ b/deal.II/source/dofs/dof_levels.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006, 2011 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -21,7 +21,7 @@ namespace internal { namespace DoFHandler { - + std::size_t DoFLevel<0>::memory_consumption () const { @@ -29,7 +29,7 @@ namespace internal } - + std::size_t DoFLevel<1>::memory_consumption () const { @@ -37,8 +37,8 @@ namespace internal MemoryConsumption::memory_consumption (lines)); } - - + + std::size_t DoFLevel<2>::memory_consumption () const { @@ -46,7 +46,7 @@ namespace internal MemoryConsumption::memory_consumption (quads)); } - + std::size_t DoFLevel<3>::memory_consumption () const @@ -54,9 +54,9 @@ namespace internal return (DoFLevel<0>::memory_consumption () + MemoryConsumption::memory_consumption (hexes)); } - + } - + } DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/dofs/dof_objects.cc b/deal.II/source/dofs/dof_objects.cc index d4194dfe68..f5709f1313 100644 --- a/deal.II/source/dofs/dof_objects.cc +++ b/deal.II/source/dofs/dof_objects.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2006, 2010, 2011 by the deal.II authors +// Copyright (C) 2006, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -38,19 +38,19 @@ namespace internal void DoFObjects:: set_dof_index (const dealii::DoFHandler &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int global_index) + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index) { Assert ((fe_index == dealii::DoFHandler::default_fe_index), - ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); + ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); Assert (local_index(), - ExcIndexRange (local_index, 0, dof_handler.get_fe().template n_dofs_per_object())); + ExcIndexRange (local_index, 0, dof_handler.get_fe().template n_dofs_per_object())); Assert (obj_index * dof_handler.get_fe().template n_dofs_per_object()+local_index - < - dofs.size(), - ExcInternalError()); + < + dofs.size(), + ExcInternalError()); dofs[obj_index * dof_handler.get_fe() .template n_dofs_per_object() + local_index] = global_index; diff --git a/deal.II/source/dofs/dof_renumbering.cc b/deal.II/source/dofs/dof_renumbering.cc index 2fdac32cbc..9e3b71a732 100644 --- a/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/source/dofs/dof_renumbering.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -78,24 +78,24 @@ namespace DoFRenumbering class WrapDoFIterator : private T { public: - typedef typename T::AccessorType AccessorType; - - WrapDoFIterator (const T& t) : T(t) {} - - void get_dof_indices (std::vector& v) const - { - (*this)->get_dof_indices(v); - } - - template - bool operator != (const T2& i) const - { - return (! (T::operator==(i))); - } - // Allow access to these private operators of T - using T::operator->; - using T::operator++; - using T::operator==; + typedef typename T::AccessorType AccessorType; + + WrapDoFIterator (const T& t) : T(t) {} + + void get_dof_indices (std::vector& v) const + { + (*this)->get_dof_indices(v); + } + + template + bool operator != (const T2& i) const + { + return (! (T::operator==(i))); + } + // Allow access to these private operators of T + using T::operator->; + using T::operator++; + using T::operator==; }; @@ -104,24 +104,24 @@ namespace DoFRenumbering class WrapMGDoFIterator : private T { public: - typedef typename T::AccessorType AccessorType; - - WrapMGDoFIterator (const T& t) : T(t) {} - - void get_dof_indices (std::vector& v) const - { - (*this)->get_mg_dof_indices(v); - } - - bool operator != (const WrapMGDoFIterator& i) const - { - return (! (T::operator==(i))); - } - // Allow access to these - // private operators of T - using T::operator->; - using T::operator++; - using T::operator==; + typedef typename T::AccessorType AccessorType; + + WrapMGDoFIterator (const T& t) : T(t) {} + + void get_dof_indices (std::vector& v) const + { + (*this)->get_mg_dof_indices(v); + } + + bool operator != (const WrapMGDoFIterator& i) const + { + return (! (T::operator==(i))); + } + // Allow access to these + // private operators of T + using T::operator->; + using T::operator++; + using T::operator==; }; } @@ -134,8 +134,8 @@ namespace DoFRenumbering using namespace std; typedef adjacency_list > > Graph; + property > > Graph; typedef graph_traits::vertex_descriptor Vertex; typedef graph_traits::vertices_size_type size_type; @@ -147,33 +147,33 @@ namespace DoFRenumbering { template void create_graph (const DH &dof_handler, - const bool use_constraints, - types::Graph &graph, - types::property_map::type &graph_degree) + const bool use_constraints, + types::Graph &graph, + types::property_map::type &graph_degree) { - { - // create intermediate sparsity pattern - // (faster than directly submitting - // indices) - ConstraintMatrix constraints; - if (use_constraints) - DoFTools::make_hanging_node_constraints (dof_handler, constraints); - constraints.close (); - CompressedSimpleSparsityPattern csp (dof_handler.n_dofs(), - dof_handler.n_dofs()); - DoFTools::make_sparsity_pattern (dof_handler, csp, constraints); - - // submit the entries to the boost graph - for (unsigned int row=0;row::vertex_iterator ui, ui_end; - - graph_degree = get(::boost::vertex_degree, graph); - for (::boost::tie(ui, ui_end) = vertices(graph); ui != ui_end; ++ui) - graph_degree[*ui] = degree(*ui, graph); + { + // create intermediate sparsity pattern + // (faster than directly submitting + // indices) + ConstraintMatrix constraints; + if (use_constraints) + DoFTools::make_hanging_node_constraints (dof_handler, constraints); + constraints.close (); + CompressedSimpleSparsityPattern csp (dof_handler.n_dofs(), + dof_handler.n_dofs()); + DoFTools::make_sparsity_pattern (dof_handler, csp, constraints); + + // submit the entries to the boost graph + for (unsigned int row=0;row::vertex_iterator ui, ui_end; + + graph_degree = get(::boost::vertex_degree, graph); + for (::boost::tie(ui, ui_end) = vertices(graph); ui != ui_end; ++ui) + graph_degree[*ui] = degree(*ui, graph); } } #endif @@ -182,17 +182,17 @@ namespace DoFRenumbering template void Cuthill_McKee (DH& dof_handler, - const bool reversed_numbering, - const bool use_constraints) + const bool reversed_numbering, + const bool use_constraints) { std::vector renumbering(dof_handler.n_dofs(), - DH::invalid_dof_index); + DH::invalid_dof_index); compute_Cuthill_McKee(renumbering, dof_handler, reversed_numbering, - use_constraints); + use_constraints); - // actually perform renumbering; - // this is dimension specific and - // thus needs an own function + // actually perform renumbering; + // this is dimension specific and + // thus needs an own function dof_handler.renumber_dofs (renumbering); } @@ -200,9 +200,9 @@ namespace DoFRenumbering template void compute_Cuthill_McKee (std::vector& new_dof_indices, - const DH &dof_handler, - const bool reversed_numbering, - const bool use_constraints) + const DH &dof_handler, + const bool reversed_numbering, + const bool use_constraints) { #ifdef DEAL_II_BOOST_GRAPH_COMPILER_BUG (void)new_dof_indices; @@ -210,38 +210,38 @@ namespace DoFRenumbering (void)reversed_numbering; (void)use_constraints; Assert (false, - ExcMessage ("Due to a bug in your compiler, this function triggers an internal " - "compiler error and has been disabled. If you need to use the " - "function, you need to upgrade to a newer version of the compiler.")); + ExcMessage ("Due to a bug in your compiler, this function triggers an internal " + "compiler error and has been disabled. If you need to use the " + "function, you need to upgrade to a newer version of the compiler.")); #else types::Graph - graph(dof_handler.n_dofs()); + graph(dof_handler.n_dofs()); types::property_map::type - graph_degree; + graph_degree; internal::create_graph (dof_handler, use_constraints, graph, graph_degree); types::property_map::type - index_map = get(::boost::vertex_index, graph); + index_map = get(::boost::vertex_index, graph); std::vector inv_perm(num_vertices(graph)); if (reversed_numbering == false) - ::boost::cuthill_mckee_ordering(graph, inv_perm.rbegin(), - get(::boost::vertex_color, graph), - make_degree_map(graph)); + ::boost::cuthill_mckee_ordering(graph, inv_perm.rbegin(), + get(::boost::vertex_color, graph), + make_degree_map(graph)); else - ::boost::cuthill_mckee_ordering(graph, inv_perm.begin(), - get(::boost::vertex_color, graph), - make_degree_map(graph)); + ::boost::cuthill_mckee_ordering(graph, inv_perm.begin(), + get(::boost::vertex_color, graph), + make_degree_map(graph)); for (types::size_type c = 0; c != inv_perm.size(); ++c) - new_dof_indices[index_map[inv_perm[c]]] = c; + new_dof_indices[index_map[inv_perm[c]]] = c; Assert (std::find (new_dof_indices.begin(), new_dof_indices.end(), - DH::invalid_dof_index) == new_dof_indices.end(), - ExcInternalError()); + DH::invalid_dof_index) == new_dof_indices.end(), + ExcInternalError()); #endif } @@ -250,17 +250,17 @@ namespace DoFRenumbering template void king_ordering (DH& dof_handler, - const bool reversed_numbering, - const bool use_constraints) + const bool reversed_numbering, + const bool use_constraints) { std::vector renumbering(dof_handler.n_dofs(), - DH::invalid_dof_index); + DH::invalid_dof_index); compute_king_ordering(renumbering, dof_handler, reversed_numbering, - use_constraints); + use_constraints); - // actually perform renumbering; - // this is dimension specific and - // thus needs an own function + // actually perform renumbering; + // this is dimension specific and + // thus needs an own function dof_handler.renumber_dofs (renumbering); } @@ -268,9 +268,9 @@ namespace DoFRenumbering template void compute_king_ordering (std::vector& new_dof_indices, - const DH &dof_handler, - const bool reversed_numbering, - const bool use_constraints) + const DH &dof_handler, + const bool reversed_numbering, + const bool use_constraints) { #ifdef DEAL_II_BOOST_GRAPH_COMPILER_BUG (void)new_dof_indices; @@ -278,34 +278,34 @@ namespace DoFRenumbering (void)reversed_numbering; (void)use_constraints; Assert (false, - ExcMessage ("Due to a bug in your compiler, this function triggers an internal " - "compiler error and has been disabled. If you need to use the " - "function, you need to upgrade to a newer version of the compiler.")); + ExcMessage ("Due to a bug in your compiler, this function triggers an internal " + "compiler error and has been disabled. If you need to use the " + "function, you need to upgrade to a newer version of the compiler.")); #else types::Graph - graph(dof_handler.n_dofs()); + graph(dof_handler.n_dofs()); types::property_map::type - graph_degree; + graph_degree; internal::create_graph (dof_handler, use_constraints, graph, graph_degree); types::property_map::type - index_map = get(::boost::vertex_index, graph); + index_map = get(::boost::vertex_index, graph); std::vector inv_perm(num_vertices(graph)); if (reversed_numbering == false) - ::boost::king_ordering(graph, inv_perm.rbegin()); + ::boost::king_ordering(graph, inv_perm.rbegin()); else - ::boost::king_ordering(graph, inv_perm.begin()); + ::boost::king_ordering(graph, inv_perm.begin()); for (types::size_type c = 0; c != inv_perm.size(); ++c) - new_dof_indices[index_map[inv_perm[c]]] = c; + new_dof_indices[index_map[inv_perm[c]]] = c; Assert (std::find (new_dof_indices.begin(), new_dof_indices.end(), - DH::invalid_dof_index) == new_dof_indices.end(), - ExcInternalError()); + DH::invalid_dof_index) == new_dof_indices.end(), + ExcInternalError()); #endif } @@ -314,17 +314,17 @@ namespace DoFRenumbering template void minimum_degree (DH& dof_handler, - const bool reversed_numbering, - const bool use_constraints) + const bool reversed_numbering, + const bool use_constraints) { std::vector renumbering(dof_handler.n_dofs(), - DH::invalid_dof_index); + DH::invalid_dof_index); compute_minimum_degree(renumbering, dof_handler, reversed_numbering, - use_constraints); + use_constraints); - // actually perform renumbering; - // this is dimension specific and - // thus needs an own function + // actually perform renumbering; + // this is dimension specific and + // thus needs an own function dof_handler.renumber_dofs (renumbering); } @@ -332,25 +332,25 @@ namespace DoFRenumbering template void compute_minimum_degree (std::vector& new_dof_indices, - const DH &dof_handler, - const bool reversed_numbering, - const bool use_constraints) + const DH &dof_handler, + const bool reversed_numbering, + const bool use_constraints) { Assert (use_constraints == false, ExcNotImplemented()); - // the following code is pretty - // much a verbatim copy of the - // sample code for the - // minimum_degree_ordering manual - // page from the BOOST Graph - // Library + // the following code is pretty + // much a verbatim copy of the + // sample code for the + // minimum_degree_ordering manual + // page from the BOOST Graph + // Library using namespace ::boost; int delta = 0; typedef double Type; - // must be BGL directed graph now + // must be BGL directed graph now typedef adjacency_list Graph; typedef graph_traits::vertex_descriptor Vertex; @@ -361,24 +361,24 @@ namespace DoFRenumbering std::vector dofs_on_this_cell; typename DH::active_cell_iterator cell = dof_handler.begin_active(), - endc = dof_handler.end(); + endc = dof_handler.end(); for (; cell!=endc; ++cell) - { + { - const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; + const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; - dofs_on_this_cell.resize (dofs_per_cell); + dofs_on_this_cell.resize (dofs_per_cell); - cell->get_dof_indices (dofs_on_this_cell); - for (unsigned int i=0; i dofs_on_this_cell[j]) - { - add_edge (dofs_on_this_cell[i], dofs_on_this_cell[j], G); - add_edge (dofs_on_this_cell[j], dofs_on_this_cell[i], G); - } - } + cell->get_dof_indices (dofs_on_this_cell); + for (unsigned int i=0; i dofs_on_this_cell[j]) + { + add_edge (dofs_on_this_cell[i], dofs_on_this_cell[j], G); + add_edge (dofs_on_this_cell[j], dofs_on_this_cell[i], G); + } + } typedef std::vector Vector; @@ -390,41 +390,41 @@ namespace DoFRenumbering Vector supernode_sizes(n, 1); - // init has to be 1 + // init has to be 1 ::boost::property_map::type - id = get(vertex_index, G); + id = get(vertex_index, G); Vector degree(n, 0); minimum_degree_ordering - (G, - make_iterator_property_map(°ree[0], id, degree[0]), - &inverse_perm[0], - &perm[0], - make_iterator_property_map(&supernode_sizes[0], id, supernode_sizes[0]), - delta, id); + (G, + make_iterator_property_map(°ree[0], id, degree[0]), + &inverse_perm[0], + &perm[0], + make_iterator_property_map(&supernode_sizes[0], id, supernode_sizes[0]), + delta, id); for (int i=0; i void Cuthill_McKee (DH& dof_handler, - const bool reversed_numbering, - const bool use_constraints, - const std::vector &starting_indices) + const bool reversed_numbering, + const bool use_constraints, + const std::vector &starting_indices) { std::vector renumbering(dof_handler.n_dofs(), - DH::invalid_dof_index); + DH::invalid_dof_index); compute_Cuthill_McKee(renumbering, dof_handler, reversed_numbering, - use_constraints, starting_indices); + use_constraints, starting_indices); - // actually perform renumbering; - // this is dimension specific and - // thus needs an own function + // actually perform renumbering; + // this is dimension specific and + // thus needs an own function dof_handler.renumber_dofs (renumbering); } @@ -454,25 +454,25 @@ namespace DoFRenumbering template void compute_Cuthill_McKee (std::vector& new_indices, - const DH& dof_handler, - const bool reversed_numbering, - const bool use_constraints, - const std::vector& starting_indices) + const DH& dof_handler, + const bool reversed_numbering, + const bool use_constraints, + const std::vector& starting_indices) { - // make the connection graph. in - // more than 2d use an intermediate - // compressed sparsity pattern - // since the we don't have very - // good estimates for - // max_couplings_between_dofs() in - // 3d and this then leads to - // excessive memory consumption - // - // note that if constraints are not - // requested, then the - // 'constraints' object will be - // empty, and calling condense with - // it is a no-op + // make the connection graph. in + // more than 2d use an intermediate + // compressed sparsity pattern + // since the we don't have very + // good estimates for + // max_couplings_between_dofs() in + // 3d and this then leads to + // excessive memory consumption + // + // note that if constraints are not + // requested, then the + // 'constraints' object will be + // empty, and calling condense with + // it is a no-op ConstraintMatrix constraints; if (use_constraints) DoFTools::make_hanging_node_constraints (dof_handler, constraints); @@ -481,29 +481,29 @@ namespace DoFRenumbering SparsityPattern sparsity; if (DH::dimension < 2) { - sparsity.reinit (dof_handler.n_dofs(), - dof_handler.n_dofs(), - dof_handler.max_couplings_between_dofs()); - DoFTools::make_sparsity_pattern (dof_handler, sparsity, constraints); - sparsity.compress(); + sparsity.reinit (dof_handler.n_dofs(), + dof_handler.n_dofs(), + dof_handler.max_couplings_between_dofs()); + DoFTools::make_sparsity_pattern (dof_handler, sparsity, constraints); + sparsity.compress(); } else { - CompressedSimpleSparsityPattern csp (dof_handler.n_dofs(), - dof_handler.n_dofs()); - DoFTools::make_sparsity_pattern (dof_handler, csp, constraints); - sparsity.copy_from (csp); + CompressedSimpleSparsityPattern csp (dof_handler.n_dofs(), + dof_handler.n_dofs()); + DoFTools::make_sparsity_pattern (dof_handler, csp, constraints); + sparsity.copy_from (csp); } - // constraints are not needed anymore + // constraints are not needed anymore constraints.clear (); Assert(new_indices.size() == sparsity.n_rows(), - ExcDimensionMismatch(new_indices.size(), - sparsity.n_rows())); + ExcDimensionMismatch(new_indices.size(), + sparsity.n_rows())); SparsityTools::reorder_Cuthill_McKee (sparsity, new_indices, - starting_indices); + starting_indices); if (reversed_numbering) new_indices = Utilities::reverse_permutation (new_indices); @@ -513,27 +513,27 @@ namespace DoFRenumbering template void Cuthill_McKee (MGDoFHandler &dof_handler, - const unsigned int level, - const bool reversed_numbering, - const std::vector &starting_indices) + const unsigned int level, + const bool reversed_numbering, + const std::vector &starting_indices) { //TODO: we should be doing the same here as in the other compute_CMK function to preserve some memory - // make the connection graph + // make the connection graph SparsityPattern sparsity (dof_handler.n_dofs(level), - dof_handler.max_couplings_between_dofs()); + dof_handler.max_couplings_between_dofs()); MGTools::make_sparsity_pattern (dof_handler, sparsity, level); std::vector new_indices(sparsity.n_rows()); SparsityTools::reorder_Cuthill_McKee (sparsity, new_indices, - starting_indices); + starting_indices); if (reversed_numbering) new_indices = Utilities::reverse_permutation (new_indices); - // actually perform renumbering; - // this is dimension specific and - // thus needs an own function + // actually perform renumbering; + // this is dimension specific and + // thus needs an own function dof_handler.renumber_dofs (level, new_indices); } @@ -542,10 +542,10 @@ namespace DoFRenumbering template void component_wise (DoFHandler &dof_handler, - const std::vector &component_order_arg) + const std::vector &component_order_arg) { std::vector renumbering (dof_handler.n_locally_owned_dofs(), - DoFHandler::invalid_dof_index); + DoFHandler::invalid_dof_index); typedef internal::WrapDoFIterator @@ -565,19 +565,19 @@ namespace DoFRenumbering if (result == 0) return; - // verify that the last numbered - // degree of freedom is either - // equal to the number of degrees - // of freedom in total (the - // sequential case) or in the - // distributed case at least - // makes sense + // verify that the last numbered + // degree of freedom is either + // equal to the number of degrees + // of freedom in total (the + // sequential case) or in the + // distributed case at least + // makes sense Assert ((result == dof_handler.n_locally_owned_dofs()) - || - ((dof_handler.n_locally_owned_dofs() < dof_handler.n_dofs()) - && - (result <= dof_handler.n_dofs())), - ExcRenumberingIncomplete()); + || + ((dof_handler.n_locally_owned_dofs() < dof_handler.n_dofs()) + && + (result <= dof_handler.n_dofs())), + ExcRenumberingIncomplete()); dof_handler.renumber_dofs (renumbering); } @@ -587,10 +587,10 @@ namespace DoFRenumbering template void component_wise (hp::DoFHandler &dof_handler, - const std::vector &component_order_arg) + const std::vector &component_order_arg) { std::vector renumbering (dof_handler.n_dofs(), - hp::DoFHandler::invalid_dof_index); + hp::DoFHandler::invalid_dof_index); typedef internal::WrapDoFIterator::active_cell_iterator> ITERATOR; @@ -604,13 +604,13 @@ namespace DoFRenumbering const unsigned int result = compute_component_wise::cell_iterator>(renumbering, - start, end, - component_order_arg); + start, end, + component_order_arg); if (result == 0) return; Assert (result == dof_handler.n_dofs(), - ExcRenumberingIncomplete()); + ExcRenumberingIncomplete()); dof_handler.renumber_dofs (renumbering); } @@ -620,11 +620,11 @@ namespace DoFRenumbering template void component_wise (MGDoFHandler &dof_handler, - const unsigned int level, - const std::vector &component_order_arg) + const unsigned int level, + const std::vector &component_order_arg) { std::vector renumbering (dof_handler.n_dofs(level), - DoFHandler::invalid_dof_index); + DoFHandler::invalid_dof_index); typedef internal::WrapMGDoFIterator::cell_iterator> ITERATOR; @@ -638,12 +638,12 @@ namespace DoFRenumbering const unsigned int result = compute_component_wise( - renumbering, start, end, component_order_arg); + renumbering, start, end, component_order_arg); if (result == 0) return; Assert (result == dof_handler.n_dofs(level), - ExcRenumberingIncomplete()); + ExcRenumberingIncomplete()); if (renumbering.size()!=0) dof_handler.renumber_dofs (level, renumbering); @@ -654,16 +654,16 @@ namespace DoFRenumbering template void component_wise (MGDoFHandler &dof_handler, - const std::vector &component_order_arg) + const std::vector &component_order_arg) { - // renumber the non-MG part of - // the DoFHandler in parallel to - // the MG part. Because - // MGDoFHandler::renumber_dofs - // uses the user flags we can't - // run renumbering on individual - // levels in parallel to the - // other levels + // renumber the non-MG part of + // the DoFHandler in parallel to + // the MG part. Because + // MGDoFHandler::renumber_dofs + // uses the user flags we can't + // run renumbering on individual + // levels in parallel to the + // other levels void (*non_mg_part) (DoFHandler &, const std::vector &) = &component_wise; Threads::Task<> @@ -680,220 +680,220 @@ namespace DoFRenumbering template unsigned int compute_component_wise (std::vector& new_indices, - const ITERATOR & start, - const ENDITERATOR& end, - const std::vector &component_order_arg) + const ITERATOR & start, + const ENDITERATOR& end, + const std::vector &component_order_arg) { const hp::FECollection fe_collection (start->get_dof_handler().get_fe ()); - // do nothing if the FE has only - // one component + // do nothing if the FE has only + // one component if (fe_collection.n_components() == 1) { - new_indices.resize(0); - return 0; + new_indices.resize(0); + return 0; } - // Copy last argument into a - // writable vector. + // Copy last argument into a + // writable vector. std::vector component_order (component_order_arg); - // If the last argument was an - // empty vector, set up things to - // store components in the order - // found in the system. + // If the last argument was an + // empty vector, set up things to + // store components in the order + // found in the system. if (component_order.size() == 0) for (unsigned int i=0; i local_dof_indices; - // prebuilt list to which component - // a given dof on a cell - // should go. note that we get into - // trouble here if the shape - // function is not primitive, since - // then there is no single vector - // component to which it - // belongs. in this case, assign it - // to the first vector component to - // which it belongs + // prebuilt list to which component + // a given dof on a cell + // should go. note that we get into + // trouble here if the shape + // function is not primitive, since + // then there is no single vector + // component to which it + // belongs. in this case, assign it + // to the first vector component to + // which it belongs std::vector > component_list (fe_collection.size()); for (unsigned int f=0; f & fe = fe_collection[f]; - const unsigned int dofs_per_cell = fe.dofs_per_cell; - component_list[f].resize(dofs_per_cell); - for (unsigned int i=0; i & fe = fe_collection[f]; + const unsigned int dofs_per_cell = fe.dofs_per_cell; + component_list[f].resize(dofs_per_cell); + for (unsigned int i=0; i > component_to_dof_map (fe_collection.n_components()); for (ITERATOR cell=start; cell!=end; ++cell) if (cell->is_locally_owned()) - { - // on each cell: get dof indices - // and insert them into the global - // list using their component - const unsigned int fe_index = cell->active_fe_index(); - const unsigned int dofs_per_cell =fe_collection[fe_index].dofs_per_cell; - local_dof_indices.resize (dofs_per_cell); - cell.get_dof_indices (local_dof_indices); - for (unsigned int i=0; iget_dof_handler().locally_owned_dofs().is_element(local_dof_indices[i])) - component_to_dof_map[component_list[fe_index][i]]. - push_back (local_dof_indices[i]); - } - - // now we've got all indices sorted - // into buckets labelled with their - // target component number. we've - // only got to traverse this list - // and assign the new indices - // - // however, we first want to sort - // the indices entered into the - // buckets to preserve the order - // within each component and during - // this also remove duplicate - // entries - // - // note that we no longer have to - // care about non-primitive shape - // functions since the buckets - // corresponding to the second and - // following vector components of a - // non-primitive FE will simply be - // empty, everything being shoved - // into the first one. The same - // holds if several components were - // joined into a single target. + { + // on each cell: get dof indices + // and insert them into the global + // list using their component + const unsigned int fe_index = cell->active_fe_index(); + const unsigned int dofs_per_cell =fe_collection[fe_index].dofs_per_cell; + local_dof_indices.resize (dofs_per_cell); + cell.get_dof_indices (local_dof_indices); + for (unsigned int i=0; iget_dof_handler().locally_owned_dofs().is_element(local_dof_indices[i])) + component_to_dof_map[component_list[fe_index][i]]. + push_back (local_dof_indices[i]); + } + + // now we've got all indices sorted + // into buckets labelled with their + // target component number. we've + // only got to traverse this list + // and assign the new indices + // + // however, we first want to sort + // the indices entered into the + // buckets to preserve the order + // within each component and during + // this also remove duplicate + // entries + // + // note that we no longer have to + // care about non-primitive shape + // functions since the buckets + // corresponding to the second and + // following vector components of a + // non-primitive FE will simply be + // empty, everything being shoved + // into the first one. The same + // holds if several components were + // joined into a single target. for (unsigned int component=0; component shifts(n_buckets); if (const parallel::distributed::Triangulation * tria - = (dynamic_cast*> - (&start->get_dof_handler().get_tria()))) + = (dynamic_cast*> + (&start->get_dof_handler().get_tria()))) { #ifdef DEAL_II_USE_P4EST - std::vector local_dof_count(n_buckets); - - for (unsigned int c=0; c - all_dof_counts(fe_collection.n_components() * - Utilities::MPI::n_mpi_processes (tria->get_communicator())); - - MPI_Allgather ( &local_dof_count[0], n_buckets, MPI_UNSIGNED, &all_dof_counts[0], - n_buckets, MPI_UNSIGNED, tria->get_communicator()); - - for (unsigned int i=0; ilocally_owned_subdomain()+i] - == - local_dof_count[i], - ExcInternalError()); - - //calculate shifts - unsigned int cumulated = 0; - for (unsigned int c=0; clocally_owned_subdomain(); ++i) - shifts[c] += all_dof_counts[c+n_buckets*i]; - for (unsigned int i=0; iget_communicator()); ++i) - cumulated += all_dof_counts[c+n_buckets*i]; - } + std::vector local_dof_count(n_buckets); + + for (unsigned int c=0; c + all_dof_counts(fe_collection.n_components() * + Utilities::MPI::n_mpi_processes (tria->get_communicator())); + + MPI_Allgather ( &local_dof_count[0], n_buckets, MPI_UNSIGNED, &all_dof_counts[0], + n_buckets, MPI_UNSIGNED, tria->get_communicator()); + + for (unsigned int i=0; ilocally_owned_subdomain()+i] + == + local_dof_count[i], + ExcInternalError()); + + //calculate shifts + unsigned int cumulated = 0; + for (unsigned int c=0; clocally_owned_subdomain(); ++i) + shifts[c] += all_dof_counts[c+n_buckets*i]; + for (unsigned int i=0; iget_communicator()); ++i) + cumulated += all_dof_counts[c+n_buckets*i]; + } #else - (void)tria; - Assert (false, ExcInternalError()); + (void)tria; + Assert (false, ExcInternalError()); #endif } else { - shifts[0] = 0; - for (unsigned int c=1; c::const_iterator - begin_of_component = component_to_dof_map[component].begin(), - end_of_component = component_to_dof_map[component].end(); - - next_free_index = shifts[component]; - - for (typename std::vector::const_iterator - dof_index = begin_of_component; - dof_index != end_of_component; ++dof_index) - { - Assert (start->get_dof_handler().locally_owned_dofs() - .index_within_set(*dof_index) - < - new_indices.size(), - ExcInternalError()); - new_indices[start->get_dof_handler().locally_owned_dofs() - .index_within_set(*dof_index)] - = next_free_index++; - } + const typename std::vector::const_iterator + begin_of_component = component_to_dof_map[component].begin(), + end_of_component = component_to_dof_map[component].end(); + + next_free_index = shifts[component]; + + for (typename std::vector::const_iterator + dof_index = begin_of_component; + dof_index != end_of_component; ++dof_index) + { + Assert (start->get_dof_handler().locally_owned_dofs() + .index_within_set(*dof_index) + < + new_indices.size(), + ExcInternalError()); + new_indices[start->get_dof_handler().locally_owned_dofs() + .index_within_set(*dof_index)] + = next_free_index++; + } } return next_free_index; @@ -901,7 +901,7 @@ namespace DoFRenumbering namespace { - // helper function for hierarchical() + // helper function for hierarchical() template unsigned int compute_hierarchical_recursive ( @@ -912,7 +912,7 @@ namespace DoFRenumbering { if (cell->has_children()) { - //recursion + //recursion for (unsigned int c = 0;c < GeometryInfo::max_children_per_cell; ++c) next_free = compute_hierarchical_recursive ( next_free, @@ -954,18 +954,18 @@ namespace DoFRenumbering hierarchical (DoFHandler &dof_handler) { std::vector renumbering (dof_handler.n_locally_owned_dofs(), - DoFHandler::invalid_dof_index); + DoFHandler::invalid_dof_index); - typename DoFHandler::cell_iterator cell; + typename DoFHandler::cell_iterator cell; - unsigned int next_free = 0; - const IndexSet locally_owned = dof_handler.locally_owned_dofs(); + unsigned int next_free = 0; + const IndexSet locally_owned = dof_handler.locally_owned_dofs(); const parallel::distributed::Triangulation * tria - = dynamic_cast*> - (&dof_handler.get_tria()); + = dynamic_cast*> + (&dof_handler.get_tria()); - if (tria) + if (tria) { #ifdef DEAL_II_USE_P4EST //this is a distributed Triangulation. We need to traverse the coarse @@ -998,27 +998,27 @@ namespace DoFRenumbering locally_owned); } - // verify that the last numbered - // degree of freedom is either - // equal to the number of degrees - // of freedom in total (the - // sequential case) or in the - // distributed case at least - // makes sense + // verify that the last numbered + // degree of freedom is either + // equal to the number of degrees + // of freedom in total (the + // sequential case) or in the + // distributed case at least + // makes sense Assert ((next_free == dof_handler.n_locally_owned_dofs()) - || - ((dof_handler.n_locally_owned_dofs() < dof_handler.n_dofs()) - && - (next_free <= dof_handler.n_dofs())), - ExcRenumberingIncomplete()); - - // make sure that all local DoFs got new numbers assigned - Assert (std::find (renumbering.begin(), renumbering.end(), - numbers::invalid_unsigned_int) - == renumbering.end(), - ExcInternalError()); - - dof_handler.renumber_dofs(renumbering); + || + ((dof_handler.n_locally_owned_dofs() < dof_handler.n_dofs()) + && + (next_free <= dof_handler.n_dofs())), + ExcRenumberingIncomplete()); + + // make sure that all local DoFs got new numbers assigned + Assert (std::find (renumbering.begin(), renumbering.end(), + numbers::invalid_unsigned_int) + == renumbering.end(), + ExcInternalError()); + + dof_handler.renumber_dofs(renumbering); } @@ -1026,10 +1026,10 @@ namespace DoFRenumbering template void sort_selected_dofs_back (DH& dof_handler, - const std::vector& selected_dofs) + const std::vector& selected_dofs) { std::vector renumbering(dof_handler.n_dofs(), - DH::invalid_dof_index); + DH::invalid_dof_index); compute_sort_selected_dofs_back(renumbering, dof_handler, selected_dofs); dof_handler.renumber_dofs(renumbering); @@ -1040,35 +1040,35 @@ namespace DoFRenumbering template void compute_sort_selected_dofs_back (std::vector& new_indices, - const DH& dof_handler, - const std::vector& selected_dofs) + const DH& dof_handler, + const std::vector& selected_dofs) { const unsigned int n_dofs = dof_handler.n_dofs(); Assert (selected_dofs.size() == n_dofs, - ExcDimensionMismatch (selected_dofs.size(), n_dofs)); + ExcDimensionMismatch (selected_dofs.size(), n_dofs)); - // re-sort the dofs according to - // their selection state + // re-sort the dofs according to + // their selection state Assert (new_indices.size() == n_dofs, - ExcDimensionMismatch(new_indices.size(), n_dofs)); + ExcDimensionMismatch(new_indices.size(), n_dofs)); const unsigned int n_selected_dofs = std::count (selected_dofs.begin(), - selected_dofs.end(), - false); + selected_dofs.end(), + false); unsigned int next_unselected = 0; unsigned int next_selected = n_selected_dofs; for (unsigned int i=0; i void cell_wise_dg (DH& dof, - const std::vector& cells) + const std::vector& cells) { std::vector renumbering(dof.n_dofs()); std::vector reverse(dof.n_dofs()); @@ -1113,22 +1113,22 @@ namespace DoFRenumbering const typename std::vector& cells) { Assert(cells.size() == dof.get_tria().n_active_cells(), - ExcDimensionMismatch(cells.size(), - dof.get_tria().n_active_cells())); + ExcDimensionMismatch(cells.size(), + dof.get_tria().n_active_cells())); unsigned int n_global_dofs = dof.n_dofs(); - // Actually, we compute the - // inverse of the reordering - // vector, called reverse here. - // Later, its inverse is computed - // into new_indices, which is the - // return argument. + // Actually, we compute the + // inverse of the reordering + // vector, called reverse here. + // Later, its inverse is computed + // into new_indices, which is the + // return argument. Assert(new_indices.size() == n_global_dofs, - ExcDimensionMismatch(new_indices.size(), n_global_dofs)); + ExcDimensionMismatch(new_indices.size(), n_global_dofs)); Assert(reverse.size() == n_global_dofs, - ExcDimensionMismatch(reverse.size(), n_global_dofs)); + ExcDimensionMismatch(reverse.size(), n_global_dofs)); std::vector cell_dofs; @@ -1138,26 +1138,26 @@ namespace DoFRenumbering for(cell = cells.begin(); cell != cells.end(); ++cell) { - Assert((*cell)->get_fe().n_dofs_per_face()==0, ExcNotDGFEM()); - // Determine the number of dofs - // on this cell and reinit the - // vector storing these - // numbers. - unsigned int n_cell_dofs = (*cell)->get_fe().n_dofs_per_cell(); - cell_dofs.resize(n_cell_dofs); - - (*cell)->get_dof_indices(cell_dofs); - - // Sort here to make sure that - // degrees of freedom inside a - // single cell are in the same - // order after renumbering. - std::sort(cell_dofs.begin(), cell_dofs.end()); - - for (unsigned int i=0;iget_fe().n_dofs_per_face()==0, ExcNotDGFEM()); + // Determine the number of dofs + // on this cell and reinit the + // vector storing these + // numbers. + unsigned int n_cell_dofs = (*cell)->get_fe().n_dofs_per_cell(); + cell_dofs.resize(n_cell_dofs); + + (*cell)->get_dof_indices(cell_dofs); + + // Sort here to make sure that + // degrees of freedom inside a + // single cell are in the same + // order after renumbering. + std::sort(cell_dofs.begin(), cell_dofs.end()); + + for (unsigned int i=0;i& cells) { Assert(cells.size() == dof.get_tria().n_active_cells(), - ExcDimensionMismatch(cells.size(), - dof.get_tria().n_active_cells())); + ExcDimensionMismatch(cells.size(), + dof.get_tria().n_active_cells())); unsigned int n_global_dofs = dof.n_dofs(); - // Actually, we compute the - // inverse of the reordering - // vector, called reverse here. - // Later, irs inverse is computed - // into new_indices, which is the - // return argument. + // Actually, we compute the + // inverse of the reordering + // vector, called reverse here. + // Later, irs inverse is computed + // into new_indices, which is the + // return argument. Assert(new_indices.size() == n_global_dofs, - ExcDimensionMismatch(new_indices.size(), n_global_dofs)); + ExcDimensionMismatch(new_indices.size(), n_global_dofs)); Assert(reverse.size() == n_global_dofs, - ExcDimensionMismatch(reverse.size(), n_global_dofs)); + ExcDimensionMismatch(reverse.size(), n_global_dofs)); - // For continuous elements, we must - // make sure, that each dof is - // reordered only once. + // For continuous elements, we must + // make sure, that each dof is + // reordered only once. std::vector already_sorted(n_global_dofs, false); std::vector cell_dofs; @@ -1204,29 +1204,29 @@ namespace DoFRenumbering for(cell = cells.begin(); cell != cells.end(); ++cell) { - // Determine the number of dofs - // on this cell and reinit the - // vector storing these - // numbers. - unsigned int n_cell_dofs = (*cell)->get_fe().n_dofs_per_cell(); - cell_dofs.resize(n_cell_dofs); - - (*cell)->get_dof_indices(cell_dofs); - - // Sort here to make sure that - // degrees of freedom inside a - // single cell are in the same - // order after renumbering. - std::sort(cell_dofs.begin(), cell_dofs.end()); - - for (unsigned int i=0;iget_fe().n_dofs_per_cell(); + cell_dofs.resize(n_cell_dofs); + + (*cell)->get_dof_indices(cell_dofs); + + // Sort here to make sure that + // degrees of freedom inside a + // single cell are in the same + // order after renumbering. + std::sort(cell_dofs.begin(), cell_dofs.end()); + + for (unsigned int i=0;i::cell_iterator>& cells) { Assert(cells.size() == dof.get_tria().n_cells(level), - ExcDimensionMismatch(cells.size(), - dof.get_tria().n_cells(level))); + ExcDimensionMismatch(cells.size(), + dof.get_tria().n_cells(level))); switch (dim) { - case 3: - Assert(dof.get_fe().n_dofs_per_quad()==0, - ExcNotDGFEM()); - case 2: - Assert(dof.get_fe().n_dofs_per_line()==0, - ExcNotDGFEM()); - default: - Assert(dof.get_fe().n_dofs_per_vertex()==0, - ExcNotDGFEM()); + case 3: + Assert(dof.get_fe().n_dofs_per_quad()==0, + ExcNotDGFEM()); + case 2: + Assert(dof.get_fe().n_dofs_per_line()==0, + ExcNotDGFEM()); + default: + Assert(dof.get_fe().n_dofs_per_vertex()==0, + ExcNotDGFEM()); } Assert (new_order.size() == dof.n_dofs(level), - ExcDimensionMismatch(new_order.size(), dof.n_dofs(level))); + ExcDimensionMismatch(new_order.size(), dof.n_dofs(level))); Assert (reverse.size() == dof.n_dofs(level), - ExcDimensionMismatch(reverse.size(), dof.n_dofs(level))); + ExcDimensionMismatch(reverse.size(), dof.n_dofs(level))); unsigned int n_global_dofs = dof.n_dofs(level); unsigned int n_cell_dofs = dof.get_fe().n_dofs_per_cell(); @@ -1306,15 +1306,15 @@ namespace DoFRenumbering for(cell = cells.begin(); cell != cells.end(); ++cell) { - Assert ((*cell)->level() == (int) level, ExcInternalError()); + Assert ((*cell)->level() == (int) level, ExcInternalError()); - (*cell)->get_mg_dof_indices(cell_dofs); - std::sort(cell_dofs.begin(), cell_dofs.end()); + (*cell)->get_mg_dof_indices(cell_dofs); + std::sort(cell_dofs.begin(), cell_dofs.end()); - for (unsigned int i=0;i::cell_iterator>& cells) { Assert(cells.size() == dof.get_tria().n_cells(level), - ExcDimensionMismatch(cells.size(), - dof.get_tria().n_cells(level))); + ExcDimensionMismatch(cells.size(), + dof.get_tria().n_cells(level))); Assert (new_order.size() == dof.n_dofs(level), - ExcDimensionMismatch(new_order.size(), dof.n_dofs(level))); + ExcDimensionMismatch(new_order.size(), dof.n_dofs(level))); Assert (reverse.size() == dof.n_dofs(level), - ExcDimensionMismatch(reverse.size(), dof.n_dofs(level))); + ExcDimensionMismatch(reverse.size(), dof.n_dofs(level))); unsigned int n_global_dofs = dof.n_dofs(level); unsigned int n_cell_dofs = dof.get_fe().n_dofs_per_cell(); @@ -1352,19 +1352,19 @@ namespace DoFRenumbering for(cell = cells.begin(); cell != cells.end(); ++cell) { - Assert ((*cell)->level() == (int) level, ExcInternalError()); - - (*cell)->get_mg_dof_indices(cell_dofs); - std::sort(cell_dofs.begin(), cell_dofs.end()); - - for (unsigned int i=0;ilevel() == (int) level, ExcInternalError()); + + (*cell)->get_mg_dof_indices(cell_dofs); + std::sort(cell_dofs.begin(), cell_dofs.end()); + + for (unsigned int i=0;i void downstream (DH& dof, const Point& direction, - const bool dof_wise_renumbering) + const bool dof_wise_renumbering) { std::vector renumbering(dof.n_dofs()); std::vector reverse(dof.n_dofs()); compute_downstream(renumbering, reverse, dof, direction, - dof_wise_renumbering); + dof_wise_renumbering); dof.renumber_dofs(renumbering); } @@ -1457,76 +1457,76 @@ namespace DoFRenumbering { if (dof_wise_renumbering == false) { - std::vector - ordered_cells(dof.get_tria().n_active_cells()); - const CompareDownstream comparator(direction); + std::vector + ordered_cells(dof.get_tria().n_active_cells()); + const CompareDownstream comparator(direction); - typename DH::active_cell_iterator begin = dof.begin_active(); - typename DH::active_cell_iterator end = dof.end(); + typename DH::active_cell_iterator begin = dof.begin_active(); + typename DH::active_cell_iterator end = dof.end(); - copy (begin, end, ordered_cells.begin()); - std::sort (ordered_cells.begin(), ordered_cells.end(), comparator); + copy (begin, end, ordered_cells.begin()); + std::sort (ordered_cells.begin(), ordered_cells.end(), comparator); - compute_cell_wise(new_indices, reverse, dof, ordered_cells); + compute_cell_wise(new_indices, reverse, dof, ordered_cells); } else { - // similar code as for - // DoFTools::map_dofs_to_support_points, but - // need to do this for general DH classes and - // want to be able to sort the result - // (otherwise, could use something like - // DoFTools::map_support_points_to_dofs) - const unsigned int n_dofs = dof.n_dofs(); - std::vector,unsigned int> > support_point_list - (n_dofs); - - const hp::FECollection fe_collection (dof.get_fe ()); - Assert (fe_collection[0].has_support_points(), - typename FiniteElement::ExcFEHasNoSupportPoints()); - hp::QCollection quadrature_collection; - for (unsigned int comp=0; comp::ExcFEHasNoSupportPoints()); - quadrature_collection.push_back - (Quadrature (fe_collection[comp]. - get_unit_support_points())); - } - hp::FEValues - hp_fe_values (fe_collection, quadrature_collection, - update_quadrature_points); - - std::vector already_touched (n_dofs, false); - - std::vector local_dof_indices; - typename DH::active_cell_iterator begin = dof.begin_active(); - typename DH::active_cell_iterator end = dof.end(); - for ( ; begin != end; ++begin) - { - const unsigned int dofs_per_cell = begin->get_fe().dofs_per_cell; - local_dof_indices.resize (dofs_per_cell); - hp_fe_values.reinit (begin); - const FEValues &fe_values = - hp_fe_values.get_present_fe_values (); - begin->get_dof_indices(local_dof_indices); - const std::vector > & points - = fe_values.get_quadrature_points (); - for (unsigned int i=0; i comparator (direction); - std::sort (support_point_list.begin(), support_point_list.end(), - comparator); - for (unsigned int i=0; i,unsigned int> > support_point_list + (n_dofs); + + const hp::FECollection fe_collection (dof.get_fe ()); + Assert (fe_collection[0].has_support_points(), + typename FiniteElement::ExcFEHasNoSupportPoints()); + hp::QCollection quadrature_collection; + for (unsigned int comp=0; comp::ExcFEHasNoSupportPoints()); + quadrature_collection.push_back + (Quadrature (fe_collection[comp]. + get_unit_support_points())); + } + hp::FEValues + hp_fe_values (fe_collection, quadrature_collection, + update_quadrature_points); + + std::vector already_touched (n_dofs, false); + + std::vector local_dof_indices; + typename DH::active_cell_iterator begin = dof.begin_active(); + typename DH::active_cell_iterator end = dof.end(); + for ( ; begin != end; ++begin) + { + const unsigned int dofs_per_cell = begin->get_fe().dofs_per_cell; + local_dof_indices.resize (dofs_per_cell); + hp_fe_values.reinit (begin); + const FEValues &fe_values = + hp_fe_values.get_present_fe_values (); + begin->get_dof_indices(local_dof_indices); + const std::vector > & points + = fe_values.get_quadrature_points (); + for (unsigned int i=0; i comparator (direction); + std::sort (support_point_list.begin(), support_point_list.end(), + comparator); + for (unsigned int i=0; i void downstream_dg (MGDoFHandler& dof, - const unsigned int level, - const Point& direction) + const unsigned int level, + const Point& direction) { std::vector renumbering(dof.n_dofs(level)); std::vector reverse(dof.n_dofs(level)); @@ -1548,14 +1548,14 @@ namespace DoFRenumbering template void downstream (MGDoFHandler& dof, - const unsigned int level, - const Point& direction, - const bool dof_wise_renumbering) + const unsigned int level, + const Point& direction, + const bool dof_wise_renumbering) { std::vector renumbering(dof.n_dofs(level)); std::vector reverse(dof.n_dofs(level)); compute_downstream(renumbering, reverse, dof, level, direction, - dof_wise_renumbering); + dof_wise_renumbering); dof.renumber_dofs(level, renumbering); } @@ -1599,57 +1599,57 @@ namespace DoFRenumbering { if (dof_wise_renumbering == false) { - std::vector::cell_iterator> - ordered_cells(dof.get_tria().n_cells(level)); - const CompareDownstream::cell_iterator, dim> comparator(direction); + std::vector::cell_iterator> + ordered_cells(dof.get_tria().n_cells(level)); + const CompareDownstream::cell_iterator, dim> comparator(direction); - typename MGDoFHandler::cell_iterator begin = dof.begin(level); - typename MGDoFHandler::cell_iterator end = dof.end(level); + typename MGDoFHandler::cell_iterator begin = dof.begin(level); + typename MGDoFHandler::cell_iterator end = dof.end(level); - std::copy (begin, end, ordered_cells.begin()); - std::sort (ordered_cells.begin(), ordered_cells.end(), comparator); + std::copy (begin, end, ordered_cells.begin()); + std::sort (ordered_cells.begin(), ordered_cells.end(), comparator); - compute_cell_wise(new_indices, reverse, dof, level, ordered_cells); + compute_cell_wise(new_indices, reverse, dof, level, ordered_cells); } else { - Assert (dof.get_fe().has_support_points(), - typename FiniteElement::ExcFEHasNoSupportPoints()); - const unsigned int n_dofs = dof.n_dofs(level); - std::vector,unsigned int> > support_point_list - (n_dofs); - - Quadrature q_dummy(dof.get_fe().get_unit_support_points()); - FEValues fe_values (dof.get_fe(), q_dummy, - update_quadrature_points); - - std::vector already_touched (dof.n_dofs(), false); - - const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell; - std::vector local_dof_indices (dofs_per_cell); - typename MGDoFHandler::cell_iterator begin = dof.begin(level); - typename MGDoFHandler::cell_iterator end = dof.end(level); - for ( ; begin != end; ++begin) - { - begin->get_mg_dof_indices(local_dof_indices); - fe_values.reinit (begin); - const std::vector > & points - = fe_values.get_quadrature_points (); - for (unsigned int i=0; i comparator (direction); - std::sort (support_point_list.begin(), support_point_list.end(), - comparator); - for (unsigned int i=0; i::ExcFEHasNoSupportPoints()); + const unsigned int n_dofs = dof.n_dofs(level); + std::vector,unsigned int> > support_point_list + (n_dofs); + + Quadrature q_dummy(dof.get_fe().get_unit_support_points()); + FEValues fe_values (dof.get_fe(), q_dummy, + update_quadrature_points); + + std::vector already_touched (dof.n_dofs(), false); + + const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell; + std::vector local_dof_indices (dofs_per_cell); + typename MGDoFHandler::cell_iterator begin = dof.begin(level); + typename MGDoFHandler::cell_iterator end = dof.end(level); + for ( ; begin != end; ++begin) + { + begin->get_mg_dof_indices(local_dof_indices); + fe_values.reinit (begin); + const std::vector > & points + = fe_values.get_quadrature_points (); + for (unsigned int i=0; i comparator (direction); + std::sort (support_point_list.begin(), support_point_list.end(), + comparator); + for (unsigned int i=0; i struct ClockCells { - /** - * Center of rotation. - */ - const Point& center; - /** - * Revert sorting order. - */ - bool counter; - - /** - * Constructor. - */ - ClockCells (const Point& center, bool counter) : - center(center), - counter(counter) - {} - /** - * Comparison operator - */ - template - bool operator () (const DHCellIterator& c1, - const DHCellIterator& c2) const - { - - const Point v1 = c1->center() - center; - const Point v2 = c2->center() - center; - const double s1 = std::atan2(v1(0), v1(1)); - const double s2 = std::atan2(v2(0), v2(1)); - return ( counter ? (s1>s2) : (s2>s1)); - } + /** + * Center of rotation. + */ + const Point& center; + /** + * Revert sorting order. + */ + bool counter; + + /** + * Constructor. + */ + ClockCells (const Point& center, bool counter) : + center(center), + counter(counter) + {} + /** + * Comparison operator + */ + template + bool operator () (const DHCellIterator& c1, + const DHCellIterator& c2) const + { + + const Point v1 = c1->center() - center; + const Point v2 = c2->center() - center; + const double s1 = std::atan2(v1(0), v1(1)); + const double s2 = std::atan2(v2(0), v2(1)); + return ( counter ? (s1>s2) : (s2>s1)); + } }; } @@ -1739,9 +1739,9 @@ namespace DoFRenumbering template void clockwise_dg (MGDoFHandler& dof, - const unsigned int level, - const Point& center, - const bool counter) + const unsigned int level, + const Point& center, + const bool counter) { std::vector::cell_iterator> ordered_cells(dof.get_tria().n_cells(level)); @@ -1763,7 +1763,7 @@ namespace DoFRenumbering random (DH& dof_handler) { std::vector renumbering(dof_handler.n_dofs(), - DH::invalid_dof_index); + DH::invalid_dof_index); compute_random(renumbering, dof_handler); dof_handler.renumber_dofs(renumbering); @@ -1779,7 +1779,7 @@ namespace DoFRenumbering { const unsigned int n_dofs = dof_handler.n_dofs(); Assert(new_indices.size() == n_dofs, - ExcDimensionMismatch(new_indices.size(), n_dofs)); + ExcDimensionMismatch(new_indices.size(), n_dofs)); for (unsigned i=0; i renumbering(dof_handler.n_dofs(), - DH::invalid_dof_index); + DH::invalid_dof_index); compute_subdomain_wise(renumbering, dof_handler); dof_handler.renumber_dofs(renumbering); @@ -1805,48 +1805,48 @@ namespace DoFRenumbering template void compute_subdomain_wise (std::vector &new_dof_indices, - const DH &dof_handler) + const DH &dof_handler) { const unsigned int n_dofs = dof_handler.n_dofs(); Assert (new_dof_indices.size() == n_dofs, - ExcDimensionMismatch (new_dof_indices.size(), n_dofs)); + ExcDimensionMismatch (new_dof_indices.size(), n_dofs)); - // first get the association of each dof - // with a subdomain and determine the total - // number of subdomain ids used + // first get the association of each dof + // with a subdomain and determine the total + // number of subdomain ids used std::vector subdomain_association (n_dofs); DoFTools::get_subdomain_association (dof_handler, - subdomain_association); + subdomain_association); const unsigned int n_subdomains = *std::max_element (subdomain_association.begin(), - subdomain_association.end()) + 1; - - // then renumber the subdomains by first - // looking at those belonging to subdomain - // 0, then those of subdomain 1, etc. note - // that the algorithm is stable, i.e. if - // two dofs i,j have i void make_sparsity_pattern (const DH &dof, - SparsityPattern &sparsity, - const ConstraintMatrix &constraints, - const bool keep_constrained_dofs, - const types::subdomain_id_t subdomain_id) + SparsityPattern &sparsity, + const ConstraintMatrix &constraints, + const bool keep_constrained_dofs, + const types::subdomain_id_t subdomain_id) { const unsigned int n_dofs = dof.n_dofs(); Assert (sparsity.n_rows() == n_dofs, - ExcDimensionMismatch (sparsity.n_rows(), n_dofs)); + ExcDimensionMismatch (sparsity.n_rows(), n_dofs)); Assert (sparsity.n_cols() == n_dofs, - ExcDimensionMismatch (sparsity.n_cols(), n_dofs)); + ExcDimensionMismatch (sparsity.n_cols(), n_dofs)); - // If we have a distributed::Triangulation only - // allow locally_owned subdomain. Not setting a - // subdomain is also okay, because we skip ghost - // cells in the loop below. + // If we have a distributed::Triangulation only + // allow locally_owned subdomain. Not setting a + // subdomain is also okay, because we skip ghost + // cells in the loop below. Assert ( (dof.get_tria().locally_owned_subdomain() == types::invalid_subdomain_id) || @@ -80,38 +80,38 @@ namespace DoFTools || (subdomain_id == dof.get_tria().locally_owned_subdomain()), ExcMessage ("For parallel::distributed::Triangulation objects and " - "associated DoF handler objects, asking for any subdomain other " - "than the locally owned one does not make sense.")); + "associated DoF handler objects, asking for any subdomain other " + "than the locally owned one does not make sense.")); std::vector dofs_on_this_cell; dofs_on_this_cell.reserve (max_dofs_per_cell(dof)); typename DH::active_cell_iterator cell = dof.begin_active(), - endc = dof.end(); + endc = dof.end(); - // In case we work with a distributed - // sparsity pattern of Trilinos type, we - // only have to do the work if the - // current cell is owned by the calling - // processor. Otherwise, just continue. + // In case we work with a distributed + // sparsity pattern of Trilinos type, we + // only have to do the work if the + // current cell is owned by the calling + // processor. Otherwise, just continue. for (; cell!=endc; ++cell) if (((subdomain_id == types::invalid_subdomain_id) - || - (subdomain_id == cell->subdomain_id())) - && - cell->is_locally_owned()) - { - const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; - dofs_on_this_cell.resize (dofs_per_cell); - cell->get_dof_indices (dofs_on_this_cell); - - // make sparsity pattern for this - // cell. if no constraints pattern was - // given, then the following call acts - // as if simply no constraints existed - constraints.add_entries_local_to_global (dofs_on_this_cell, - sparsity, - keep_constrained_dofs); - } + || + (subdomain_id == cell->subdomain_id())) + && + cell->is_locally_owned()) + { + const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; + dofs_on_this_cell.resize (dofs_per_cell); + cell->get_dof_indices (dofs_on_this_cell); + + // make sparsity pattern for this + // cell. if no constraints pattern was + // given, then the following call acts + // as if simply no constraints existed + constraints.add_entries_local_to_global (dofs_on_this_cell, + sparsity, + keep_constrained_dofs); + } } @@ -119,27 +119,27 @@ namespace DoFTools template void make_sparsity_pattern (const DH &dof, - const Table<2,Coupling> &couplings, - SparsityPattern &sparsity, - const ConstraintMatrix &constraints, - const bool keep_constrained_dofs, - const types::subdomain_id_t subdomain_id) + const Table<2,Coupling> &couplings, + SparsityPattern &sparsity, + const ConstraintMatrix &constraints, + const bool keep_constrained_dofs, + const types::subdomain_id_t subdomain_id) { const unsigned int n_dofs = dof.n_dofs(); Assert (sparsity.n_rows() == n_dofs, - ExcDimensionMismatch (sparsity.n_rows(), n_dofs)); + ExcDimensionMismatch (sparsity.n_rows(), n_dofs)); Assert (sparsity.n_cols() == n_dofs, - ExcDimensionMismatch (sparsity.n_cols(), n_dofs)); + ExcDimensionMismatch (sparsity.n_cols(), n_dofs)); Assert (couplings.n_rows() == dof.get_fe().n_components(), - ExcDimensionMismatch(couplings.n_rows(), dof.get_fe().n_components())); + ExcDimensionMismatch(couplings.n_rows(), dof.get_fe().n_components())); Assert (couplings.n_cols() == dof.get_fe().n_components(), - ExcDimensionMismatch(couplings.n_cols(), dof.get_fe().n_components())); + ExcDimensionMismatch(couplings.n_cols(), dof.get_fe().n_components())); - // If we have a distributed::Triangulation only - // allow locally_owned subdomain. Not setting a - // subdomain is also okay, because we skip ghost - // cells in the loop below. + // If we have a distributed::Triangulation only + // allow locally_owned subdomain. Not setting a + // subdomain is also okay, because we skip ghost + // cells in the loop below. Assert ( (dof.get_tria().locally_owned_subdomain() == types::invalid_subdomain_id) || @@ -147,102 +147,102 @@ namespace DoFTools || (subdomain_id == dof.get_tria().locally_owned_subdomain()), ExcMessage ("For parallel::distributed::Triangulation objects and " - "associated DoF handler objects, asking for any subdomain other " - "than the locally owned one does not make sense.")); + "associated DoF handler objects, asking for any subdomain other " + "than the locally owned one does not make sense.")); const hp::FECollection fe_collection (dof.get_fe()); - // first, for each finite element, build a - // mask for each dof, not like the one - // given which represents components. make - // sure we do the right thing also with - // respect to non-primitive shape - // functions, which takes some additional - // thought + // first, for each finite element, build a + // mask for each dof, not like the one + // given which represents components. make + // sure we do the right thing also with + // respect to non-primitive shape + // functions, which takes some additional + // thought std::vector > dof_mask(fe_collection.size()); - // check whether the table of couplings - // contains only true arguments, i.e., we - // do not exclude any index. that is the - // easy case, since we don't have to set - // up the tables + // check whether the table of couplings + // contains only true arguments, i.e., we + // do not exclude any index. that is the + // easy case, since we don't have to set + // up the tables bool need_dof_mask = false; for (unsigned int i=0; i dofs_on_this_cell(fe_collection.max_dofs_per_cell()); typename DH::active_cell_iterator cell = dof.begin_active(), - endc = dof.end(); + endc = dof.end(); - // In case we work with a distributed - // sparsity pattern of Trilinos type, we - // only have to do the work if the - // current cell is owned by the calling - // processor. Otherwise, just continue. + // In case we work with a distributed + // sparsity pattern of Trilinos type, we + // only have to do the work if the + // current cell is owned by the calling + // processor. Otherwise, just continue. for (; cell!=endc; ++cell) if (((subdomain_id == types::invalid_subdomain_id) - || - (subdomain_id == cell->subdomain_id())) - && - cell->is_locally_owned()) - { - const unsigned int fe_index = cell->active_fe_index(); - const unsigned int dofs_per_cell =fe_collection[fe_index].dofs_per_cell; - - dofs_on_this_cell.resize (dofs_per_cell); - cell->get_dof_indices (dofs_on_this_cell); - - - // make sparsity pattern for this - // cell. if no constraints pattern was - // given, then the following call acts - // as if simply no constraints existed - constraints.add_entries_local_to_global (dofs_on_this_cell, - sparsity, - keep_constrained_dofs, - dof_mask[fe_index]); - } + || + (subdomain_id == cell->subdomain_id())) + && + cell->is_locally_owned()) + { + const unsigned int fe_index = cell->active_fe_index(); + const unsigned int dofs_per_cell =fe_collection[fe_index].dofs_per_cell; + + dofs_on_this_cell.resize (dofs_per_cell); + cell->get_dof_indices (dofs_on_this_cell); + + + // make sparsity pattern for this + // cell. if no constraints pattern was + // given, then the following call acts + // as if simply no constraints existed + constraints.add_entries_local_to_global (dofs_on_this_cell, + sparsity, + keep_constrained_dofs, + dof_mask[fe_index]); + } } @@ -258,9 +258,9 @@ namespace DoFTools const unsigned int n_dofs_col = dof_col.n_dofs(); Assert (sparsity.n_rows() == n_dofs_row, - ExcDimensionMismatch (sparsity.n_rows(), n_dofs_row)); + ExcDimensionMismatch (sparsity.n_rows(), n_dofs_row)); Assert (sparsity.n_cols() == n_dofs_col, - ExcDimensionMismatch (sparsity.n_cols(), n_dofs_col)); + ExcDimensionMismatch (sparsity.n_cols(), n_dofs_col)); const std::listfirst; - const typename DH::cell_iterator cell_col = cell_iter->second; - - if (!cell_row->has_children() && !cell_col->has_children()) - { - const unsigned int dofs_per_cell_row = - cell_row->get_fe().dofs_per_cell; - const unsigned int dofs_per_cell_col = - cell_col->get_fe().dofs_per_cell; - std::vector - local_dof_indices_row(dofs_per_cell_row); - std::vector - local_dof_indices_col(dofs_per_cell_col); - cell_row->get_dof_indices (local_dof_indices_row); - cell_col->get_dof_indices (local_dof_indices_col); - for (unsigned int i=0; ihas_children()) - { - const std::vector - child_cells = GridTools::get_active_child_cells (cell_row); - for (unsigned int i=0; iget_fe().dofs_per_cell; - const unsigned int dofs_per_cell_col = - cell_col->get_fe().dofs_per_cell; - std::vector - local_dof_indices_row(dofs_per_cell_row); - std::vector - local_dof_indices_col(dofs_per_cell_col); - cell_row_child->get_dof_indices (local_dof_indices_row); - cell_col->get_dof_indices (local_dof_indices_col); - for (unsigned int i=0; i - child_cells = GridTools::get_active_child_cells (cell_col); - for (unsigned int i=0; iget_fe().dofs_per_cell; - const unsigned int dofs_per_cell_col = - cell_col_child->get_fe().dofs_per_cell; - std::vector - local_dof_indices_row(dofs_per_cell_row); - std::vector - local_dof_indices_col(dofs_per_cell_col); - cell_row->get_dof_indices (local_dof_indices_row); - cell_col_child->get_dof_indices (local_dof_indices_col); - for (unsigned int i=0; ifirst; + const typename DH::cell_iterator cell_col = cell_iter->second; + + if (!cell_row->has_children() && !cell_col->has_children()) + { + const unsigned int dofs_per_cell_row = + cell_row->get_fe().dofs_per_cell; + const unsigned int dofs_per_cell_col = + cell_col->get_fe().dofs_per_cell; + std::vector + local_dof_indices_row(dofs_per_cell_row); + std::vector + local_dof_indices_col(dofs_per_cell_col); + cell_row->get_dof_indices (local_dof_indices_row); + cell_col->get_dof_indices (local_dof_indices_col); + for (unsigned int i=0; ihas_children()) + { + const std::vector + child_cells = GridTools::get_active_child_cells (cell_row); + for (unsigned int i=0; iget_fe().dofs_per_cell; + const unsigned int dofs_per_cell_col = + cell_col->get_fe().dofs_per_cell; + std::vector + local_dof_indices_row(dofs_per_cell_row); + std::vector + local_dof_indices_col(dofs_per_cell_col); + cell_row_child->get_dof_indices (local_dof_indices_row); + cell_col->get_dof_indices (local_dof_indices_col); + for (unsigned int i=0; i + child_cells = GridTools::get_active_child_cells (cell_col); + for (unsigned int i=0; iget_fe().dofs_per_cell; + const unsigned int dofs_per_cell_col = + cell_col_child->get_fe().dofs_per_cell; + std::vector + local_dof_indices_row(dofs_per_cell_row); + std::vector + local_dof_indices_col(dofs_per_cell_col); + cell_row->get_dof_indices (local_dof_indices_row); + cell_col_child->get_dof_indices (local_dof_indices_col); + for (unsigned int i=0; i (dof, - boundary_indicators, - dof_to_boundary_mapping, - sparsity); - return; + // there are only 2 boundary + // indicators in 1d, so it is no + // performance problem to call the + // other function + typename DH::FunctionMap boundary_indicators; + boundary_indicators[0] = 0; + boundary_indicators[1] = 0; + make_boundary_sparsity_pattern (dof, + boundary_indicators, + dof_to_boundary_mapping, + sparsity); + return; } const unsigned int n_dofs = dof.n_dofs(); @@ -380,46 +380,46 @@ namespace DoFTools #ifdef DEBUG if (sparsity.n_rows() != 0) { - unsigned int max_element = 0; - for (std::vector::const_iterator i=dof_to_boundary_mapping.begin(); - i!=dof_to_boundary_mapping.end(); ++i) - if ((*i != DH::invalid_dof_index) && - (*i > max_element)) - max_element = *i; - AssertDimension (max_element, sparsity.n_rows()-1); + unsigned int max_element = 0; + for (std::vector::const_iterator i=dof_to_boundary_mapping.begin(); + i!=dof_to_boundary_mapping.end(); ++i) + if ((*i != DH::invalid_dof_index) && + (*i > max_element)) + max_element = *i; + AssertDimension (max_element, sparsity.n_rows()-1); }; #endif std::vector dofs_on_this_face; dofs_on_this_face.reserve (max_dofs_per_face(dof)); - // loop over all faces to check - // whether they are at a - // boundary. note that we need not - // take special care of single - // lines (using - // @p{cell->has_boundary_lines}), - // since we do not support - // boundaries of dimension dim-2, - // and so every boundary line is - // also part of a boundary face. + // loop over all faces to check + // whether they are at a + // boundary. note that we need not + // take special care of single + // lines (using + // @p{cell->has_boundary_lines}), + // since we do not support + // boundaries of dimension dim-2, + // and so every boundary line is + // also part of a boundary face. typename DH::active_cell_iterator cell = dof.begin_active(), - endc = dof.end(); + endc = dof.end(); for (; cell!=endc; ++cell) for (unsigned int f=0; f::faces_per_cell; ++f) - if (cell->at_boundary(f)) - { - const unsigned int dofs_per_face = cell->get_fe().dofs_per_face; - dofs_on_this_face.resize (dofs_per_face); - cell->face(f)->get_dof_indices (dofs_on_this_face, - cell->active_fe_index()); - - // make sparsity pattern for this cell - for (unsigned int i=0; iat_boundary(f)) + { + const unsigned int dofs_per_face = cell->get_fe().dofs_per_face; + dofs_on_this_face.resize (dofs_per_face); + cell->face(f)->get_dof_indices (dofs_on_this_face, + cell->active_fe_index()); + + // make sparsity pattern for this cell + for (unsigned int i=0; iat_boundary(direction)) - cell = cell->neighbor(direction); - while (!cell->active()) - cell = cell->child(direction); - - const unsigned int dofs_per_vertex = cell->get_fe().dofs_per_vertex; - std::vector boundary_dof_boundary_indices (dofs_per_vertex); - - // next get boundary mapped dof - // indices of boundary dofs - for (unsigned int i=0; ivertex_dof_index(direction,i)]; - - for (unsigned int i=0; iat_boundary(direction)) + cell = cell->neighbor(direction); + while (!cell->active()) + cell = cell->child(direction); + + const unsigned int dofs_per_vertex = cell->get_fe().dofs_per_vertex; + std::vector boundary_dof_boundary_indices (dofs_per_vertex); + + // next get boundary mapped dof + // indices of boundary dofs + for (unsigned int i=0; ivertex_dof_index(direction,i)]; + + for (unsigned int i=0; i::const_iterator i=dof_to_boundary_mapping.begin(); - i!=dof_to_boundary_mapping.end(); ++i) - if ((*i != DH::invalid_dof_index) && - (*i > max_element)) - max_element = *i; - AssertDimension (max_element, sparsity.n_rows()-1); + unsigned int max_element = 0; + for (std::vector::const_iterator i=dof_to_boundary_mapping.begin(); + i!=dof_to_boundary_mapping.end(); ++i) + if ((*i != DH::invalid_dof_index) && + (*i > max_element)) + max_element = *i; + AssertDimension (max_element, sparsity.n_rows()-1); }; #endif std::vector dofs_on_this_face; dofs_on_this_face.reserve (max_dofs_per_face(dof)); typename DH::active_cell_iterator cell = dof.begin_active(), - endc = dof.end(); + endc = dof.end(); for (; cell!=endc; ++cell) for (unsigned int f=0; f::faces_per_cell; ++f) - if (boundary_indicators.find(cell->face(f)->boundary_indicator()) != - boundary_indicators.end()) - { - const unsigned int dofs_per_face = cell->get_fe().dofs_per_face; - dofs_on_this_face.resize (dofs_per_face); - cell->face(f)->get_dof_indices (dofs_on_this_face, - cell->active_fe_index()); - - // make sparsity pattern for this cell - for (unsigned int i=0; iface(f)->boundary_indicator()) != + boundary_indicators.end()) + { + const unsigned int dofs_per_face = cell->get_fe().dofs_per_face; + dofs_on_this_face.resize (dofs_per_face); + cell->face(f)->get_dof_indices (dofs_on_this_face, + cell->active_fe_index()); + + // make sparsity pattern for this cell + for (unsigned int i=0; i void make_flux_sparsity_pattern (const DH &dof, - SparsityPattern &sparsity, - const ConstraintMatrix &constraints, - const bool keep_constrained_dofs, + SparsityPattern &sparsity, + const ConstraintMatrix &constraints, + const bool keep_constrained_dofs, const types::subdomain_id_t subdomain_id) { const unsigned int n_dofs = dof.n_dofs(); @@ -539,114 +539,114 @@ namespace DoFTools || (subdomain_id == dof.get_tria().locally_owned_subdomain()), ExcMessage ("For parallel::distributed::Triangulation objects and " - "associated DoF handler objects, asking for any subdomain other " - "than the locally owned one does not make sense.")); + "associated DoF handler objects, asking for any subdomain other " + "than the locally owned one does not make sense.")); std::vector dofs_on_this_cell; std::vector dofs_on_other_cell; dofs_on_this_cell.reserve (max_dofs_per_cell(dof)); dofs_on_other_cell.reserve (max_dofs_per_cell(dof)); typename DH::active_cell_iterator cell = dof.begin_active(), - endc = dof.end(); - - // TODO: in an old implementation, we used - // user flags before to tag faces that were - // already touched. this way, we could reduce - // the work a little bit. now, we instead add - // only data from one side. this should be OK, - // but we need to actually verify it. - - // In case we work with a distributed - // sparsity pattern of Trilinos type, we - // only have to do the work if the - // current cell is owned by the calling - // processor. Otherwise, just continue. + endc = dof.end(); + + // TODO: in an old implementation, we used + // user flags before to tag faces that were + // already touched. this way, we could reduce + // the work a little bit. now, we instead add + // only data from one side. this should be OK, + // but we need to actually verify it. + + // In case we work with a distributed + // sparsity pattern of Trilinos type, we + // only have to do the work if the + // current cell is owned by the calling + // processor. Otherwise, just continue. for (; cell!=endc; ++cell) if (((subdomain_id == types::invalid_subdomain_id) - || - (subdomain_id == cell->subdomain_id())) + || + (subdomain_id == cell->subdomain_id())) && cell->is_locally_owned()) - { - const unsigned int n_dofs_on_this_cell = cell->get_fe().dofs_per_cell; - dofs_on_this_cell.resize (n_dofs_on_this_cell); - cell->get_dof_indices (dofs_on_this_cell); - - // make sparsity pattern for this - // cell. if no constraints pattern was - // given, then the following call acts - // as if simply no constraints existed - constraints.add_entries_local_to_global (dofs_on_this_cell, - sparsity, - keep_constrained_dofs); - - for (unsigned int face = 0; - face < GeometryInfo::faces_per_cell; - ++face) - { - typename DH::face_iterator cell_face = cell->face(face); - if (! cell->at_boundary(face) ) - { - typename DH::cell_iterator neighbor = cell->neighbor(face); - - if (cell_face->has_children()) - { - for (unsigned int sub_nr = 0; - sub_nr != cell_face->number_of_children(); - ++sub_nr) - { - const typename DH::cell_iterator - sub_neighbor - = cell->neighbor_child_on_subface (face, sub_nr); - - const unsigned int n_dofs_on_neighbor - = sub_neighbor->get_fe().dofs_per_cell; - dofs_on_other_cell.resize (n_dofs_on_neighbor); - sub_neighbor->get_dof_indices (dofs_on_other_cell); - - constraints.add_entries_local_to_global - (dofs_on_this_cell, dofs_on_other_cell, - sparsity, keep_constrained_dofs); - constraints.add_entries_local_to_global - (dofs_on_other_cell, dofs_on_this_cell, - sparsity, keep_constrained_dofs); - } - } - else - { - // Refinement edges are taken care of - // by coarser cells - - // TODO: in the distributed case, we miss out - // the constraints when the neighbor cell is - // coarser, but only the current cell is owned - // locally! - if (cell->neighbor_is_coarser(face)) - continue; - - const unsigned int n_dofs_on_neighbor - = neighbor->get_fe().dofs_per_cell; - dofs_on_other_cell.resize (n_dofs_on_neighbor); - - neighbor->get_dof_indices (dofs_on_other_cell); - - constraints.add_entries_local_to_global - (dofs_on_this_cell, dofs_on_other_cell, - sparsity, keep_constrained_dofs); - - // only need to add these in case the neighbor - // cell is not locally owned - otherwise, we - // touch each face twice and hence put the - // indices the other way around - if (cell->neighbor(face)->subdomain_id() != - cell->subdomain_id()) - constraints.add_entries_local_to_global - (dofs_on_other_cell, dofs_on_this_cell, - sparsity, keep_constrained_dofs); - } - } - } - } + { + const unsigned int n_dofs_on_this_cell = cell->get_fe().dofs_per_cell; + dofs_on_this_cell.resize (n_dofs_on_this_cell); + cell->get_dof_indices (dofs_on_this_cell); + + // make sparsity pattern for this + // cell. if no constraints pattern was + // given, then the following call acts + // as if simply no constraints existed + constraints.add_entries_local_to_global (dofs_on_this_cell, + sparsity, + keep_constrained_dofs); + + for (unsigned int face = 0; + face < GeometryInfo::faces_per_cell; + ++face) + { + typename DH::face_iterator cell_face = cell->face(face); + if (! cell->at_boundary(face) ) + { + typename DH::cell_iterator neighbor = cell->neighbor(face); + + if (cell_face->has_children()) + { + for (unsigned int sub_nr = 0; + sub_nr != cell_face->number_of_children(); + ++sub_nr) + { + const typename DH::cell_iterator + sub_neighbor + = cell->neighbor_child_on_subface (face, sub_nr); + + const unsigned int n_dofs_on_neighbor + = sub_neighbor->get_fe().dofs_per_cell; + dofs_on_other_cell.resize (n_dofs_on_neighbor); + sub_neighbor->get_dof_indices (dofs_on_other_cell); + + constraints.add_entries_local_to_global + (dofs_on_this_cell, dofs_on_other_cell, + sparsity, keep_constrained_dofs); + constraints.add_entries_local_to_global + (dofs_on_other_cell, dofs_on_this_cell, + sparsity, keep_constrained_dofs); + } + } + else + { + // Refinement edges are taken care of + // by coarser cells + + // TODO: in the distributed case, we miss out + // the constraints when the neighbor cell is + // coarser, but only the current cell is owned + // locally! + if (cell->neighbor_is_coarser(face)) + continue; + + const unsigned int n_dofs_on_neighbor + = neighbor->get_fe().dofs_per_cell; + dofs_on_other_cell.resize (n_dofs_on_neighbor); + + neighbor->get_dof_indices (dofs_on_other_cell); + + constraints.add_entries_local_to_global + (dofs_on_this_cell, dofs_on_other_cell, + sparsity, keep_constrained_dofs); + + // only need to add these in case the neighbor + // cell is not locally owned - otherwise, we + // touch each face twice and hence put the + // indices the other way around + if (cell->neighbor(face)->subdomain_id() != + cell->subdomain_id()) + constraints.add_entries_local_to_global + (dofs_on_other_cell, dofs_on_this_cell, + sparsity, keep_constrained_dofs); + } + } + } + } } @@ -669,11 +669,11 @@ namespace DoFTools const Table<2,Coupling> &component_couplings) { Assert(component_couplings.n_rows() == fe.n_components(), - ExcDimensionMismatch(component_couplings.n_rows(), - fe.n_components())); + ExcDimensionMismatch(component_couplings.n_rows(), + fe.n_components())); Assert(component_couplings.n_cols() == fe.n_components(), - ExcDimensionMismatch(component_couplings.n_cols(), - fe.n_components())); + ExcDimensionMismatch(component_couplings.n_cols(), + fe.n_components())); const unsigned int n_dofs = fe.dofs_per_cell; @@ -681,34 +681,34 @@ namespace DoFTools for (unsigned int i=0; i > return_value (fe.size()); for (unsigned int i=0; i void make_flux_sparsity_pattern (const DH &dof, - SparsityPattern &sparsity, - const Table<2,Coupling> &int_mask, - const Table<2,Coupling> &flux_mask) + SparsityPattern &sparsity, + const Table<2,Coupling> &int_mask, + const Table<2,Coupling> &flux_mask) { - const FiniteElement &fe = dof.get_fe(); + const FiniteElement &fe = dof.get_fe(); - std::vector dofs_on_this_cell(fe.dofs_per_cell); - std::vector dofs_on_other_cell(fe.dofs_per_cell); + std::vector dofs_on_this_cell(fe.dofs_per_cell); + std::vector dofs_on_other_cell(fe.dofs_per_cell); - const Table<2,Coupling> - int_dof_mask = dof_couplings_from_component_couplings(fe, int_mask), - flux_dof_mask = dof_couplings_from_component_couplings(fe, flux_mask); + const Table<2,Coupling> + int_dof_mask = dof_couplings_from_component_couplings(fe, int_mask), + flux_dof_mask = dof_couplings_from_component_couplings(fe, flux_mask); - Table<2,bool> support_on_face(fe.dofs_per_cell, - GeometryInfo::faces_per_cell); - for (unsigned int i=0; i::faces_per_cell;++f) - support_on_face(i,f) = fe.has_support_on_face(i,f); + Table<2,bool> support_on_face(fe.dofs_per_cell, + GeometryInfo::faces_per_cell); + for (unsigned int i=0; i::faces_per_cell;++f) + support_on_face(i,f) = fe.has_support_on_face(i,f); - typename DH::active_cell_iterator cell = dof.begin_active(), - endc = dof.end(); - for (; cell!=endc; ++cell) + typename DH::active_cell_iterator cell = dof.begin_active(), + endc = dof.end(); + for (; cell!=endc; ++cell) if (cell->is_locally_owned()) - { - cell->get_dof_indices (dofs_on_this_cell); - // make sparsity pattern for this cell - for (unsigned int i=0; i::faces_per_cell; - ++face) - { - const typename DH::face_iterator - cell_face = cell->face(face); - if (cell_face->user_flag_set ()) - continue; - - if (cell->at_boundary (face) ) - { - for (unsigned int i=0; ineighbor(face); - // Refinement edges are taken care of - // by coarser cells - if (cell->neighbor_is_coarser(face)) - continue; - - typename DH::face_iterator cell_face = cell->face(face); - const unsigned int - neighbor_face = cell->neighbor_of_neighbor(face); - - if (cell_face->has_children()) - { - for (unsigned int sub_nr = 0; - sub_nr != cell_face->n_children(); - ++sub_nr) - { - const typename DH::cell_iterator - sub_neighbor - = cell->neighbor_child_on_subface (face, sub_nr); - - sub_neighbor->get_dof_indices (dofs_on_other_cell); - for (unsigned int i=0; iface(neighbor_face)->set_user_flag (); - } - } - else - { - neighbor->get_dof_indices (dofs_on_other_cell); - for (unsigned int i=0; iface(neighbor_face)->set_user_flag (); - } - } - } + { + cell->get_dof_indices (dofs_on_this_cell); + // make sparsity pattern for this cell + for (unsigned int i=0; i::faces_per_cell; + ++face) + { + const typename DH::face_iterator + cell_face = cell->face(face); + if (cell_face->user_flag_set ()) + continue; + + if (cell->at_boundary (face) ) + { + for (unsigned int i=0; ineighbor(face); + // Refinement edges are taken care of + // by coarser cells + if (cell->neighbor_is_coarser(face)) + continue; + + typename DH::face_iterator cell_face = cell->face(face); + const unsigned int + neighbor_face = cell->neighbor_of_neighbor(face); + + if (cell_face->has_children()) + { + for (unsigned int sub_nr = 0; + sub_nr != cell_face->n_children(); + ++sub_nr) + { + const typename DH::cell_iterator + sub_neighbor + = cell->neighbor_child_on_subface (face, sub_nr); + + sub_neighbor->get_dof_indices (dofs_on_other_cell); + for (unsigned int i=0; iface(neighbor_face)->set_user_flag (); + } + } + else + { + neighbor->get_dof_indices (dofs_on_other_cell); + for (unsigned int i=0; iface(neighbor_face)->set_user_flag (); + } + } + } } } - // implementation of the same function in - // namespace DoFTools for non-hp - // DoFHandlers + // implementation of the same function in + // namespace DoFTools for non-hp + // DoFHandlers template void make_flux_sparsity_pattern (const dealii::hp::DoFHandler &dof, - SparsityPattern &sparsity, - const Table<2,Coupling> &int_mask, - const Table<2,Coupling> &flux_mask) + SparsityPattern &sparsity, + const Table<2,Coupling> &int_mask, + const Table<2,Coupling> &flux_mask) { - // while the implementation above is - // quite optimized and caches a lot of - // data (see e.g. the int/flux_dof_mask - // tables), this is no longer practical - // for the hp version since we would - // have to have it for all combinations - // of elements in the - // hp::FECollection. consequently, the - // implementation here is simpler and - // probably less efficient but at least - // readable... - - const dealii::hp::FECollection &fe = dof.get_fe(); - - std::vector dofs_on_this_cell(DoFTools::max_dofs_per_cell(dof)); - std::vector dofs_on_other_cell(DoFTools::max_dofs_per_cell(dof)); - - const std::vector > - int_dof_mask - = dof_couplings_from_component_couplings(fe, int_mask); - - typename dealii::hp::DoFHandler::active_cell_iterator - cell = dof.begin_active(), - endc = dof.end(); - for (; cell!=endc; ++cell) - { - dofs_on_this_cell.resize (cell->get_fe().dofs_per_cell); - cell->get_dof_indices (dofs_on_this_cell); - // make sparsity pattern for this cell - for (unsigned int i=0; iget_fe().dofs_per_cell; ++i) - for (unsigned int j=0; jget_fe().dofs_per_cell; ++j) - if (int_dof_mask[cell->active_fe_index()](i,j) != none) - sparsity.add (dofs_on_this_cell[i], - dofs_on_this_cell[j]); - - // Loop over all interior neighbors - for (unsigned int face = 0; - face < GeometryInfo::faces_per_cell; - ++face) - { - const typename dealii::hp::DoFHandler::face_iterator - cell_face = cell->face(face); - if (cell_face->user_flag_set ()) - continue; - - if (cell->at_boundary (face) ) - { - for (unsigned int i=0; iget_fe().dofs_per_cell; ++i) - for (unsigned int j=0; jget_fe().dofs_per_cell; ++j) - if ((flux_mask(cell->get_fe().system_to_component_index(i).first, - cell->get_fe().system_to_component_index(j).first) - == always) - || - (flux_mask(cell->get_fe().system_to_component_index(i).first, - cell->get_fe().system_to_component_index(j).first) - == nonzero)) - sparsity.add (dofs_on_this_cell[i], - dofs_on_this_cell[j]); - } - else - { - typename dealii::hp::DoFHandler::cell_iterator - neighbor = cell->neighbor(face); - // Refinement edges are taken care of - // by coarser cells - if (cell->neighbor_is_coarser(face)) - continue; - - typename dealii::hp::DoFHandler::face_iterator - cell_face = cell->face(face); - const unsigned int - neighbor_face = cell->neighbor_of_neighbor(face); - - if (cell_face->has_children()) - { - for (unsigned int sub_nr = 0; - sub_nr != cell_face->n_children(); - ++sub_nr) - { - const typename dealii::hp::DoFHandler::cell_iterator - sub_neighbor - = cell->neighbor_child_on_subface (face, sub_nr); - - dofs_on_other_cell.resize (sub_neighbor->get_fe().dofs_per_cell); - sub_neighbor->get_dof_indices (dofs_on_other_cell); - for (unsigned int i=0; iget_fe().dofs_per_cell; ++i) - { - for (unsigned int j=0; jget_fe().dofs_per_cell; - ++j) - { - if ((flux_mask(cell->get_fe().system_to_component_index(i).first, - sub_neighbor->get_fe().system_to_component_index(j).first) - == always) - || - (flux_mask(cell->get_fe().system_to_component_index(i).first, - sub_neighbor->get_fe().system_to_component_index(j).first) - == nonzero)) - { - sparsity.add (dofs_on_this_cell[i], - dofs_on_other_cell[j]); - sparsity.add (dofs_on_other_cell[i], - dofs_on_this_cell[j]); - sparsity.add (dofs_on_this_cell[i], - dofs_on_this_cell[j]); - sparsity.add (dofs_on_other_cell[i], - dofs_on_other_cell[j]); - } - - if ((flux_mask(sub_neighbor->get_fe().system_to_component_index(j).first, - cell->get_fe().system_to_component_index(i).first) - == always) - || - (flux_mask(sub_neighbor->get_fe().system_to_component_index(j).first, - cell->get_fe().system_to_component_index(i).first) - == nonzero)) - { - sparsity.add (dofs_on_this_cell[j], - dofs_on_other_cell[i]); - sparsity.add (dofs_on_other_cell[j], - dofs_on_this_cell[i]); - sparsity.add (dofs_on_this_cell[j], - dofs_on_this_cell[i]); - sparsity.add (dofs_on_other_cell[j], - dofs_on_other_cell[i]); - } - } - } - sub_neighbor->face(neighbor_face)->set_user_flag (); - } - } - else - { - dofs_on_other_cell.resize (neighbor->get_fe().dofs_per_cell); - neighbor->get_dof_indices (dofs_on_other_cell); - for (unsigned int i=0; iget_fe().dofs_per_cell; ++i) - { - for (unsigned int j=0; jget_fe().dofs_per_cell; ++j) - { - if ((flux_mask(cell->get_fe().system_to_component_index(i).first, - neighbor->get_fe().system_to_component_index(j).first) - == always) - || - (flux_mask(cell->get_fe().system_to_component_index(i).first, - neighbor->get_fe().system_to_component_index(j).first) - == nonzero)) - { - sparsity.add (dofs_on_this_cell[i], - dofs_on_other_cell[j]); - sparsity.add (dofs_on_other_cell[i], - dofs_on_this_cell[j]); - sparsity.add (dofs_on_this_cell[i], - dofs_on_this_cell[j]); - sparsity.add (dofs_on_other_cell[i], - dofs_on_other_cell[j]); - } - - if ((flux_mask(neighbor->get_fe().system_to_component_index(j).first, - cell->get_fe().system_to_component_index(i).first) - == always) - || - (flux_mask(neighbor->get_fe().system_to_component_index(j).first, - cell->get_fe().system_to_component_index(i).first) - == nonzero)) - { - sparsity.add (dofs_on_this_cell[j], - dofs_on_other_cell[i]); - sparsity.add (dofs_on_other_cell[j], - dofs_on_this_cell[i]); - sparsity.add (dofs_on_this_cell[j], - dofs_on_this_cell[i]); - sparsity.add (dofs_on_other_cell[j], - dofs_on_other_cell[i]); - } - } - } - neighbor->face(neighbor_face)->set_user_flag (); - } - } - } - } + // while the implementation above is + // quite optimized and caches a lot of + // data (see e.g. the int/flux_dof_mask + // tables), this is no longer practical + // for the hp version since we would + // have to have it for all combinations + // of elements in the + // hp::FECollection. consequently, the + // implementation here is simpler and + // probably less efficient but at least + // readable... + + const dealii::hp::FECollection &fe = dof.get_fe(); + + std::vector dofs_on_this_cell(DoFTools::max_dofs_per_cell(dof)); + std::vector dofs_on_other_cell(DoFTools::max_dofs_per_cell(dof)); + + const std::vector > + int_dof_mask + = dof_couplings_from_component_couplings(fe, int_mask); + + typename dealii::hp::DoFHandler::active_cell_iterator + cell = dof.begin_active(), + endc = dof.end(); + for (; cell!=endc; ++cell) + { + dofs_on_this_cell.resize (cell->get_fe().dofs_per_cell); + cell->get_dof_indices (dofs_on_this_cell); + // make sparsity pattern for this cell + for (unsigned int i=0; iget_fe().dofs_per_cell; ++i) + for (unsigned int j=0; jget_fe().dofs_per_cell; ++j) + if (int_dof_mask[cell->active_fe_index()](i,j) != none) + sparsity.add (dofs_on_this_cell[i], + dofs_on_this_cell[j]); + + // Loop over all interior neighbors + for (unsigned int face = 0; + face < GeometryInfo::faces_per_cell; + ++face) + { + const typename dealii::hp::DoFHandler::face_iterator + cell_face = cell->face(face); + if (cell_face->user_flag_set ()) + continue; + + if (cell->at_boundary (face) ) + { + for (unsigned int i=0; iget_fe().dofs_per_cell; ++i) + for (unsigned int j=0; jget_fe().dofs_per_cell; ++j) + if ((flux_mask(cell->get_fe().system_to_component_index(i).first, + cell->get_fe().system_to_component_index(j).first) + == always) + || + (flux_mask(cell->get_fe().system_to_component_index(i).first, + cell->get_fe().system_to_component_index(j).first) + == nonzero)) + sparsity.add (dofs_on_this_cell[i], + dofs_on_this_cell[j]); + } + else + { + typename dealii::hp::DoFHandler::cell_iterator + neighbor = cell->neighbor(face); + // Refinement edges are taken care of + // by coarser cells + if (cell->neighbor_is_coarser(face)) + continue; + + typename dealii::hp::DoFHandler::face_iterator + cell_face = cell->face(face); + const unsigned int + neighbor_face = cell->neighbor_of_neighbor(face); + + if (cell_face->has_children()) + { + for (unsigned int sub_nr = 0; + sub_nr != cell_face->n_children(); + ++sub_nr) + { + const typename dealii::hp::DoFHandler::cell_iterator + sub_neighbor + = cell->neighbor_child_on_subface (face, sub_nr); + + dofs_on_other_cell.resize (sub_neighbor->get_fe().dofs_per_cell); + sub_neighbor->get_dof_indices (dofs_on_other_cell); + for (unsigned int i=0; iget_fe().dofs_per_cell; ++i) + { + for (unsigned int j=0; jget_fe().dofs_per_cell; + ++j) + { + if ((flux_mask(cell->get_fe().system_to_component_index(i).first, + sub_neighbor->get_fe().system_to_component_index(j).first) + == always) + || + (flux_mask(cell->get_fe().system_to_component_index(i).first, + sub_neighbor->get_fe().system_to_component_index(j).first) + == nonzero)) + { + sparsity.add (dofs_on_this_cell[i], + dofs_on_other_cell[j]); + sparsity.add (dofs_on_other_cell[i], + dofs_on_this_cell[j]); + sparsity.add (dofs_on_this_cell[i], + dofs_on_this_cell[j]); + sparsity.add (dofs_on_other_cell[i], + dofs_on_other_cell[j]); + } + + if ((flux_mask(sub_neighbor->get_fe().system_to_component_index(j).first, + cell->get_fe().system_to_component_index(i).first) + == always) + || + (flux_mask(sub_neighbor->get_fe().system_to_component_index(j).first, + cell->get_fe().system_to_component_index(i).first) + == nonzero)) + { + sparsity.add (dofs_on_this_cell[j], + dofs_on_other_cell[i]); + sparsity.add (dofs_on_other_cell[j], + dofs_on_this_cell[i]); + sparsity.add (dofs_on_this_cell[j], + dofs_on_this_cell[i]); + sparsity.add (dofs_on_other_cell[j], + dofs_on_other_cell[i]); + } + } + } + sub_neighbor->face(neighbor_face)->set_user_flag (); + } + } + else + { + dofs_on_other_cell.resize (neighbor->get_fe().dofs_per_cell); + neighbor->get_dof_indices (dofs_on_other_cell); + for (unsigned int i=0; iget_fe().dofs_per_cell; ++i) + { + for (unsigned int j=0; jget_fe().dofs_per_cell; ++j) + { + if ((flux_mask(cell->get_fe().system_to_component_index(i).first, + neighbor->get_fe().system_to_component_index(j).first) + == always) + || + (flux_mask(cell->get_fe().system_to_component_index(i).first, + neighbor->get_fe().system_to_component_index(j).first) + == nonzero)) + { + sparsity.add (dofs_on_this_cell[i], + dofs_on_other_cell[j]); + sparsity.add (dofs_on_other_cell[i], + dofs_on_this_cell[j]); + sparsity.add (dofs_on_this_cell[i], + dofs_on_this_cell[j]); + sparsity.add (dofs_on_other_cell[i], + dofs_on_other_cell[j]); + } + + if ((flux_mask(neighbor->get_fe().system_to_component_index(j).first, + cell->get_fe().system_to_component_index(i).first) + == always) + || + (flux_mask(neighbor->get_fe().system_to_component_index(j).first, + cell->get_fe().system_to_component_index(i).first) + == nonzero)) + { + sparsity.add (dofs_on_this_cell[j], + dofs_on_other_cell[i]); + sparsity.add (dofs_on_other_cell[j], + dofs_on_this_cell[i]); + sparsity.add (dofs_on_this_cell[j], + dofs_on_this_cell[i]); + sparsity.add (dofs_on_other_cell[j], + dofs_on_other_cell[i]); + } + } + } + neighbor->face(neighbor_face)->set_user_flag (); + } + } + } + } } } @@ -1171,47 +1171,47 @@ namespace DoFTools template void make_flux_sparsity_pattern (const DH &dof, - SparsityPattern &sparsity, - const Table<2,Coupling> &int_mask, - const Table<2,Coupling> &flux_mask) + SparsityPattern &sparsity, + const Table<2,Coupling> &int_mask, + const Table<2,Coupling> &flux_mask) { - // do the error checking and frame code - // here, and then pass on to more - // specialized functions in the internal - // namespace + // do the error checking and frame code + // here, and then pass on to more + // specialized functions in the internal + // namespace const unsigned int n_dofs = dof.n_dofs(); const unsigned int n_comp = dof.get_fe().n_components(); Assert (sparsity.n_rows() == n_dofs, - ExcDimensionMismatch (sparsity.n_rows(), n_dofs)); + ExcDimensionMismatch (sparsity.n_rows(), n_dofs)); Assert (sparsity.n_cols() == n_dofs, - ExcDimensionMismatch (sparsity.n_cols(), n_dofs)); + ExcDimensionMismatch (sparsity.n_cols(), n_dofs)); Assert (int_mask.n_rows() == n_comp, - ExcDimensionMismatch (int_mask.n_rows(), n_comp)); + ExcDimensionMismatch (int_mask.n_rows(), n_comp)); Assert (int_mask.n_cols() == n_comp, - ExcDimensionMismatch (int_mask.n_cols(), n_comp)); + ExcDimensionMismatch (int_mask.n_cols(), n_comp)); Assert (flux_mask.n_rows() == n_comp, - ExcDimensionMismatch (flux_mask.n_rows(), n_comp)); + ExcDimensionMismatch (flux_mask.n_rows(), n_comp)); Assert (flux_mask.n_cols() == n_comp, - ExcDimensionMismatch (flux_mask.n_cols(), n_comp)); + ExcDimensionMismatch (flux_mask.n_cols(), n_comp)); - // Clear user flags because we will - // need them. But first we save - // them and make sure that we - // restore them later such that at - // the end of this function the - // Triangulation will be in the - // same state as it was at the - // beginning of this function. + // Clear user flags because we will + // need them. But first we save + // them and make sure that we + // restore them later such that at + // the end of this function the + // Triangulation will be in the + // same state as it was at the + // beginning of this function. std::vector user_flags; dof.get_tria().save_user_flags(user_flags); const_cast &>(dof.get_tria()).clear_user_flags (); internal::make_flux_sparsity_pattern (dof, sparsity, - int_mask, flux_mask); + int_mask, flux_mask); - // finally restore the user flags + // finally restore the user flags const_cast &>(dof.get_tria()).load_user_flags(user_flags); } @@ -1228,498 +1228,498 @@ namespace DoFTools inline bool check_master_dof_list (const FullMatrix &face_interpolation_matrix, - const std::vector &master_dof_list) + const std::vector &master_dof_list) { - const unsigned int N = master_dof_list.size(); - - FullMatrix tmp (N,N); - for (unsigned int i=0; i p(N); - for (unsigned int i=0; i max) - { - max = std::fabs(tmp(i,j)); - r = i; - } - } - // check whether the - // pivot is too small. if - // that is the case, then - // the matrix is singular - // and we shouldn't use - // this set of master - // dofs - if (max < 1.e-12*typical_diagonal_element) - return false; - - // row interchange - if (r>j) - { - for (unsigned int k=0; k tmp (N,N); + for (unsigned int i=0; i p(N); + for (unsigned int i=0; i max) + { + max = std::fabs(tmp(i,j)); + r = i; + } + } + // check whether the + // pivot is too small. if + // that is the case, then + // the matrix is singular + // and we shouldn't use + // this set of master + // dofs + if (max < 1.e-12*typical_diagonal_element) + return false; + + // row interchange + if (r>j) + { + for (unsigned int k=0; k void select_master_dofs_for_face_restriction (const FiniteElement &fe1, - const FiniteElement &fe2, - const FullMatrix &face_interpolation_matrix, - std::vector &master_dof_mask) + const FiniteElement &fe2, + const FullMatrix &face_interpolation_matrix, + std::vector &master_dof_mask) { - Assert (fe1.dofs_per_face >= fe2.dofs_per_face, - ExcInternalError()); - AssertDimension (master_dof_mask.size(), fe1.dofs_per_face); - - Assert (fe2.dofs_per_vertex <= fe1.dofs_per_vertex, - ExcInternalError()); - Assert (fe2.dofs_per_line <= fe1.dofs_per_line, - ExcInternalError()); - Assert ((dim < 3) - || - (fe2.dofs_per_quad <= fe1.dofs_per_quad), - ExcInternalError()); - - // the idea here is to designate as - // many DoFs in fe1 per object - // (vertex, line, quad) as master as - // there are such dofs in fe2 - // (indices are int, because we want - // to avoid the 'unsigned int < 0 is - // always false warning for the cases - // at the bottom in 1d and 2d) - // - // as mentioned in the paper, it is - // not always easy to find a set of - // master dofs that produces an - // invertible matrix. to this end, we - // check in each step whether the - // matrix is still invertible and - // simply discard this dof if the - // matrix is not invertible anymore. - // - // the cases where we did have - // trouble in the past were with - // adding more quad dofs when Q3 and - // Q4 elements meet at a refined face - // in 3d (see the hp/crash_12 test - // that tests that we can do exactly - // this, and failed before we had - // code to compensate for this - // case). the other case are system - // elements: if we have say a Q1Q2 vs - // a Q2Q3 element, then we can't just - // take all master dofs on a line - // from a single base element, since - // the shape functions of that base - // element are independent of that of - // the other one. this latter case - // shows up when running - // hp/hp_constraints_q_system_06 - std::vector master_dof_list; - unsigned int index = 0; - for (int v=0; - v(GeometryInfo::vertices_per_face); - ++v) - { - unsigned int dofs_added = 0; - unsigned int i = 0; - while (dofs_added < fe2.dofs_per_vertex) - { - // make sure that we - // were able to find - // a set of master - // dofs and that the - // code down below - // didn't just reject - // all our efforts - Assert (i < fe1.dofs_per_vertex, - ExcInternalError()); - // tentatively push - // this vertex dof - master_dof_list.push_back (index+i); - - // then see what - // happens. if it - // succeeds, fine - if (check_master_dof_list (face_interpolation_matrix, - master_dof_list) - == true) - ++dofs_added; - else - // well, it - // didn't. simply - // pop that dof - // from the list - // again and try - // with the next - // dof - master_dof_list.pop_back (); - - // forward counter by - // one - ++i; - } - index += fe1.dofs_per_vertex; - } - - for (int l=0; - l(GeometryInfo::lines_per_face); - ++l) - { - // same algorithm as above - unsigned int dofs_added = 0; - unsigned int i = 0; - while (dofs_added < fe2.dofs_per_line) - { - Assert (i < fe1.dofs_per_line, - ExcInternalError()); - - master_dof_list.push_back (index+i); - if (check_master_dof_list (face_interpolation_matrix, - master_dof_list) - == true) - ++dofs_added; - else - master_dof_list.pop_back (); - - ++i; - } - index += fe1.dofs_per_line; - } - - for (int q=0; - q(GeometryInfo::quads_per_face); - ++q) - { - // same algorithm as above - unsigned int dofs_added = 0; - unsigned int i = 0; - while (dofs_added < fe2.dofs_per_quad) - { - Assert (i < fe1.dofs_per_quad, - ExcInternalError()); - - master_dof_list.push_back (index+i); - if (check_master_dof_list (face_interpolation_matrix, - master_dof_list) - == true) - ++dofs_added; - else - master_dof_list.pop_back (); - - ++i; - } - index += fe1.dofs_per_quad; - } - - AssertDimension (index, fe1.dofs_per_face); - AssertDimension (master_dof_list.size(), fe2.dofs_per_face); - - // finally copy the list into the - // mask - std::fill (master_dof_mask.begin(), master_dof_mask.end(), false); - for (std::vector::const_iterator i=master_dof_list.begin(); - i!=master_dof_list.end(); ++i) - master_dof_mask[*i] = true; + Assert (fe1.dofs_per_face >= fe2.dofs_per_face, + ExcInternalError()); + AssertDimension (master_dof_mask.size(), fe1.dofs_per_face); + + Assert (fe2.dofs_per_vertex <= fe1.dofs_per_vertex, + ExcInternalError()); + Assert (fe2.dofs_per_line <= fe1.dofs_per_line, + ExcInternalError()); + Assert ((dim < 3) + || + (fe2.dofs_per_quad <= fe1.dofs_per_quad), + ExcInternalError()); + + // the idea here is to designate as + // many DoFs in fe1 per object + // (vertex, line, quad) as master as + // there are such dofs in fe2 + // (indices are int, because we want + // to avoid the 'unsigned int < 0 is + // always false warning for the cases + // at the bottom in 1d and 2d) + // + // as mentioned in the paper, it is + // not always easy to find a set of + // master dofs that produces an + // invertible matrix. to this end, we + // check in each step whether the + // matrix is still invertible and + // simply discard this dof if the + // matrix is not invertible anymore. + // + // the cases where we did have + // trouble in the past were with + // adding more quad dofs when Q3 and + // Q4 elements meet at a refined face + // in 3d (see the hp/crash_12 test + // that tests that we can do exactly + // this, and failed before we had + // code to compensate for this + // case). the other case are system + // elements: if we have say a Q1Q2 vs + // a Q2Q3 element, then we can't just + // take all master dofs on a line + // from a single base element, since + // the shape functions of that base + // element are independent of that of + // the other one. this latter case + // shows up when running + // hp/hp_constraints_q_system_06 + std::vector master_dof_list; + unsigned int index = 0; + for (int v=0; + v(GeometryInfo::vertices_per_face); + ++v) + { + unsigned int dofs_added = 0; + unsigned int i = 0; + while (dofs_added < fe2.dofs_per_vertex) + { + // make sure that we + // were able to find + // a set of master + // dofs and that the + // code down below + // didn't just reject + // all our efforts + Assert (i < fe1.dofs_per_vertex, + ExcInternalError()); + // tentatively push + // this vertex dof + master_dof_list.push_back (index+i); + + // then see what + // happens. if it + // succeeds, fine + if (check_master_dof_list (face_interpolation_matrix, + master_dof_list) + == true) + ++dofs_added; + else + // well, it + // didn't. simply + // pop that dof + // from the list + // again and try + // with the next + // dof + master_dof_list.pop_back (); + + // forward counter by + // one + ++i; + } + index += fe1.dofs_per_vertex; + } + + for (int l=0; + l(GeometryInfo::lines_per_face); + ++l) + { + // same algorithm as above + unsigned int dofs_added = 0; + unsigned int i = 0; + while (dofs_added < fe2.dofs_per_line) + { + Assert (i < fe1.dofs_per_line, + ExcInternalError()); + + master_dof_list.push_back (index+i); + if (check_master_dof_list (face_interpolation_matrix, + master_dof_list) + == true) + ++dofs_added; + else + master_dof_list.pop_back (); + + ++i; + } + index += fe1.dofs_per_line; + } + + for (int q=0; + q(GeometryInfo::quads_per_face); + ++q) + { + // same algorithm as above + unsigned int dofs_added = 0; + unsigned int i = 0; + while (dofs_added < fe2.dofs_per_quad) + { + Assert (i < fe1.dofs_per_quad, + ExcInternalError()); + + master_dof_list.push_back (index+i); + if (check_master_dof_list (face_interpolation_matrix, + master_dof_list) + == true) + ++dofs_added; + else + master_dof_list.pop_back (); + + ++i; + } + index += fe1.dofs_per_quad; + } + + AssertDimension (index, fe1.dofs_per_face); + AssertDimension (master_dof_list.size(), fe2.dofs_per_face); + + // finally copy the list into the + // mask + std::fill (master_dof_mask.begin(), master_dof_mask.end(), false); + for (std::vector::const_iterator i=master_dof_list.begin(); + i!=master_dof_list.end(); ++i) + master_dof_mask[*i] = true; } - /** - * Make sure that the mask exists that - * determines which dofs will be the - * masters on refined faces where an - * fe1 and a fe2 meet. - */ + /** + * Make sure that the mask exists that + * determines which dofs will be the + * masters on refined faces where an + * fe1 and a fe2 meet. + */ template void ensure_existence_of_master_dof_mask (const FiniteElement &fe1, - const FiniteElement &fe2, - const FullMatrix &face_interpolation_matrix, - std_cxx1x::shared_ptr > &master_dof_mask) + const FiniteElement &fe2, + const FullMatrix &face_interpolation_matrix, + std_cxx1x::shared_ptr > &master_dof_mask) { - if (master_dof_mask == std_cxx1x::shared_ptr >()) - { - master_dof_mask = std_cxx1x::shared_ptr > - (new std::vector (fe1.dofs_per_face)); - select_master_dofs_for_face_restriction (fe1, - fe2, - face_interpolation_matrix, - *master_dof_mask); - } + if (master_dof_mask == std_cxx1x::shared_ptr >()) + { + master_dof_mask = std_cxx1x::shared_ptr > + (new std::vector (fe1.dofs_per_face)); + select_master_dofs_for_face_restriction (fe1, + fe2, + face_interpolation_matrix, + *master_dof_mask); + } } - /** - * Make sure that the given @p - * face_interpolation_matrix - * pointer points to a valid - * matrix. If the pointer is zero - * beforehand, create an entry - * with the correct data. If it - * is nonzero, don't touch it. - */ + /** + * Make sure that the given @p + * face_interpolation_matrix + * pointer points to a valid + * matrix. If the pointer is zero + * beforehand, create an entry + * with the correct data. If it + * is nonzero, don't touch it. + */ template void ensure_existence_of_face_matrix (const FiniteElement &fe1, - const FiniteElement &fe2, - std_cxx1x::shared_ptr > &matrix) + const FiniteElement &fe2, + std_cxx1x::shared_ptr > &matrix) { - if (matrix == std_cxx1x::shared_ptr >()) - { - matrix = std_cxx1x::shared_ptr > - (new FullMatrix (fe2.dofs_per_face, - fe1.dofs_per_face)); - fe1.get_face_interpolation_matrix (fe2, - *matrix); - } + if (matrix == std_cxx1x::shared_ptr >()) + { + matrix = std_cxx1x::shared_ptr > + (new FullMatrix (fe2.dofs_per_face, + fe1.dofs_per_face)); + fe1.get_face_interpolation_matrix (fe2, + *matrix); + } } - /** - * Same, but for subface - * interpolation matrices. - */ + /** + * Same, but for subface + * interpolation matrices. + */ template void ensure_existence_of_subface_matrix (const FiniteElement &fe1, - const FiniteElement &fe2, - const unsigned int subface, - std_cxx1x::shared_ptr > &matrix) + const FiniteElement &fe2, + const unsigned int subface, + std_cxx1x::shared_ptr > &matrix) { - if (matrix == std_cxx1x::shared_ptr >()) - { - matrix = std_cxx1x::shared_ptr > - (new FullMatrix (fe2.dofs_per_face, - fe1.dofs_per_face)); - fe1.get_subface_interpolation_matrix (fe2, - subface, - *matrix); - } + if (matrix == std_cxx1x::shared_ptr >()) + { + matrix = std_cxx1x::shared_ptr > + (new FullMatrix (fe2.dofs_per_face, + fe1.dofs_per_face)); + fe1.get_subface_interpolation_matrix (fe2, + subface, + *matrix); + } } - /** - * Given the face interpolation - * matrix between two elements, - * split it into its master and - * slave parts and invert the - * master part as explained in - * the @ref hp_paper "hp paper". - */ + /** + * Given the face interpolation + * matrix between two elements, + * split it into its master and + * slave parts and invert the + * master part as explained in + * the @ref hp_paper "hp paper". + */ void ensure_existence_of_split_face_matrix (const FullMatrix &face_interpolation_matrix, - const std::vector &master_dof_mask, - std_cxx1x::shared_ptr,FullMatrix > > &split_matrix) + const std::vector &master_dof_mask, + std_cxx1x::shared_ptr,FullMatrix > > &split_matrix) { - AssertDimension (master_dof_mask.size(), face_interpolation_matrix.m()); - Assert (std::count (master_dof_mask.begin(), master_dof_mask.end(), true) == - static_cast(face_interpolation_matrix.n()), - ExcInternalError()); - - if (split_matrix == - std_cxx1x::shared_ptr,FullMatrix > >()) - { - split_matrix - = std_cxx1x::shared_ptr,FullMatrix > > - (new std::pair,FullMatrix >()); - - const unsigned int n_master_dofs = face_interpolation_matrix.n(); - const unsigned int n_dofs = face_interpolation_matrix.m(); - - Assert (n_master_dofs <= n_dofs, ExcInternalError()); - - // copy and invert the master - // component, copy the slave - // component - split_matrix->first.reinit (n_master_dofs, n_master_dofs); - split_matrix->second.reinit (n_dofs-n_master_dofs, n_master_dofs); - - unsigned int nth_master_dof = 0, - nth_slave_dof = 0; - - for (unsigned int i=0; ifirst(nth_master_dof,j) - = face_interpolation_matrix(i,j); - ++nth_master_dof; - } - else - { - for (unsigned int j=0; jsecond(nth_slave_dof,j) - = face_interpolation_matrix(i,j); - ++nth_slave_dof; - } - - AssertDimension (nth_master_dof, n_master_dofs); - AssertDimension (nth_slave_dof, n_dofs-n_master_dofs); + AssertDimension (master_dof_mask.size(), face_interpolation_matrix.m()); + Assert (std::count (master_dof_mask.begin(), master_dof_mask.end(), true) == + static_cast(face_interpolation_matrix.n()), + ExcInternalError()); + + if (split_matrix == + std_cxx1x::shared_ptr,FullMatrix > >()) + { + split_matrix + = std_cxx1x::shared_ptr,FullMatrix > > + (new std::pair,FullMatrix >()); + + const unsigned int n_master_dofs = face_interpolation_matrix.n(); + const unsigned int n_dofs = face_interpolation_matrix.m(); + + Assert (n_master_dofs <= n_dofs, ExcInternalError()); + + // copy and invert the master + // component, copy the slave + // component + split_matrix->first.reinit (n_master_dofs, n_master_dofs); + split_matrix->second.reinit (n_dofs-n_master_dofs, n_master_dofs); + + unsigned int nth_master_dof = 0, + nth_slave_dof = 0; + + for (unsigned int i=0; ifirst(nth_master_dof,j) + = face_interpolation_matrix(i,j); + ++nth_master_dof; + } + else + { + for (unsigned int j=0; jsecond(nth_slave_dof,j) + = face_interpolation_matrix(i,j); + ++nth_slave_dof; + } + + AssertDimension (nth_master_dof, n_master_dofs); + AssertDimension (nth_slave_dof, n_dofs-n_master_dofs); //TODO[WB]: We should make sure very small entries are removed after inversion - split_matrix->first.gauss_jordan (); - } + split_matrix->first.gauss_jordan (); + } } - // a template that can - // determine statically whether - // a given DoFHandler class - // supports different finite - // element elements + // a template that can + // determine statically whether + // a given DoFHandler class + // supports different finite + // element elements template struct DoFHandlerSupportsDifferentFEs { - static const bool value = true; + static const bool value = true; }; template struct DoFHandlerSupportsDifferentFEs< dealii::DoFHandler > { - static const bool value = false; + static const bool value = false; }; template struct DoFHandlerSupportsDifferentFEs< dealii::MGDoFHandler > { - static const bool value = false; + static const bool value = false; }; - /** - * A function that returns how - * many different finite - * elements a dof handler - * uses. This is one for non-hp - * DoFHandlers and - * dof_handler.get_fe().size() - * for the hp-versions. - */ + /** + * A function that returns how + * many different finite + * elements a dof handler + * uses. This is one for non-hp + * DoFHandlers and + * dof_handler.get_fe().size() + * for the hp-versions. + */ template unsigned int n_finite_elements (const dealii::hp::DoFHandler &dof_handler) { - return dof_handler.get_fe().size(); + return dof_handler.get_fe().size(); } @@ -1727,187 +1727,187 @@ namespace DoFTools unsigned int n_finite_elements (const DH &) { - return 1; + return 1; } - /** - * For a given face belonging - * to an active cell that - * borders to a more refined - * cell, return the fe_index of - * the most dominating finite - * element used on any of the - * face's subfaces. - */ + /** + * For a given face belonging + * to an active cell that + * borders to a more refined + * cell, return the fe_index of + * the most dominating finite + * element used on any of the + * face's subfaces. + */ template unsigned int get_most_dominating_subface_fe_index (const face_iterator &face) { - const unsigned int dim - = face_iterator::AccessorType::dimension; - const unsigned int spacedim - = face_iterator::AccessorType::space_dimension; - - unsigned int dominating_subface_no = 0; - for (; dominating_subface_non_children(); - ++dominating_subface_no) - { - // each of the subfaces - // can have only a single - // fe_index associated - // with them, since there - // is no cell on the - // other side - Assert (face->child(dominating_subface_no) - ->n_active_fe_indices() - == 1, - ExcInternalError()); - - const FiniteElement & - this_subface_fe = (face->child(dominating_subface_no) - ->get_fe (face->child(dominating_subface_no) - ->nth_active_fe_index(0))); - - FiniteElementDomination::Domination - domination = FiniteElementDomination::either_element_can_dominate; - for (unsigned int sf=0; sfn_children(); ++sf) - if (sf != dominating_subface_no) - { - const FiniteElement & - that_subface_fe = (face->child(sf) - ->get_fe (face->child(sf) - ->nth_active_fe_index(0))); - - domination = domination & - this_subface_fe.compare_for_face_domination(that_subface_fe); - } - - // see if the element - // on this subface is - // able to dominate - // the ones on all - // other subfaces, - // and if so take it - if ((domination == FiniteElementDomination::this_element_dominates) - || - (domination == FiniteElementDomination::either_element_can_dominate)) - break; - } - - // check that we have - // found one such subface - Assert (dominating_subface_no < face->n_children(), - ExcNotImplemented()); - - // return the finite element - // index used on it. note - // that only a single fe can - // be active on such subfaces - return face->child (dominating_subface_no)->nth_active_fe_index(0); + const unsigned int dim + = face_iterator::AccessorType::dimension; + const unsigned int spacedim + = face_iterator::AccessorType::space_dimension; + + unsigned int dominating_subface_no = 0; + for (; dominating_subface_non_children(); + ++dominating_subface_no) + { + // each of the subfaces + // can have only a single + // fe_index associated + // with them, since there + // is no cell on the + // other side + Assert (face->child(dominating_subface_no) + ->n_active_fe_indices() + == 1, + ExcInternalError()); + + const FiniteElement & + this_subface_fe = (face->child(dominating_subface_no) + ->get_fe (face->child(dominating_subface_no) + ->nth_active_fe_index(0))); + + FiniteElementDomination::Domination + domination = FiniteElementDomination::either_element_can_dominate; + for (unsigned int sf=0; sfn_children(); ++sf) + if (sf != dominating_subface_no) + { + const FiniteElement & + that_subface_fe = (face->child(sf) + ->get_fe (face->child(sf) + ->nth_active_fe_index(0))); + + domination = domination & + this_subface_fe.compare_for_face_domination(that_subface_fe); + } + + // see if the element + // on this subface is + // able to dominate + // the ones on all + // other subfaces, + // and if so take it + if ((domination == FiniteElementDomination::this_element_dominates) + || + (domination == FiniteElementDomination::either_element_can_dominate)) + break; + } + + // check that we have + // found one such subface + Assert (dominating_subface_no < face->n_children(), + ExcNotImplemented()); + + // return the finite element + // index used on it. note + // that only a single fe can + // be active on such subfaces + return face->child (dominating_subface_no)->nth_active_fe_index(0); } - /** - * Copy constraints into a constraint - * matrix object. - * - * This function removes zero - * constraints and those, which - * constrain a DoF which was - * already eliminated in one of - * the previous steps of the hp - * hanging node procedure. - * - * It also suppresses very small - * entries in the constraint matrix to - * avoid making the sparsity pattern - * fuller than necessary. - */ + /** + * Copy constraints into a constraint + * matrix object. + * + * This function removes zero + * constraints and those, which + * constrain a DoF which was + * already eliminated in one of + * the previous steps of the hp + * hanging node procedure. + * + * It also suppresses very small + * entries in the constraint matrix to + * avoid making the sparsity pattern + * fuller than necessary. + */ void filter_constraints (const std::vector &master_dofs, - const std::vector &slave_dofs, - const FullMatrix &face_constraints, - ConstraintMatrix &constraints) + const std::vector &slave_dofs, + const FullMatrix &face_constraints, + ConstraintMatrix &constraints) { - Assert (face_constraints.n () == master_dofs.size (), - ExcDimensionMismatch(master_dofs.size (), - face_constraints.n())); - Assert (face_constraints.m () == slave_dofs.size (), - ExcDimensionMismatch(slave_dofs.size (), - face_constraints.m())); - - const unsigned int n_master_dofs = master_dofs.size (); - const unsigned int n_slave_dofs = slave_dofs.size (); - - // check for a couple - // conditions that happened - // in parallel distributed - // mode - for (unsigned int row=0; row!=n_slave_dofs; ++row) - Assert (slave_dofs[row] != numbers::invalid_unsigned_int, - ExcInternalError()); - for (unsigned int col=0; col!=n_master_dofs; ++col) - Assert (master_dofs[col] != numbers::invalid_unsigned_int, - ExcInternalError()); - - - for (unsigned int row=0; row!=n_slave_dofs; ++row) - if (constraints.is_constrained (slave_dofs[row]) == false) - { - bool constraint_already_satisfied = false; - - // Check if we have an identity - // constraint, which is already - // satisfied by unification of - // the corresponding global dof - // indices - for (unsigned int i=0; i= 1e-14*abs_sum)) - constraints.add_entry (slave_dofs[row], - master_dofs[i], - face_constraints (row,i)); - constraints.set_inhomogeneity (slave_dofs[row], 0.); - } - } + Assert (face_constraints.n () == master_dofs.size (), + ExcDimensionMismatch(master_dofs.size (), + face_constraints.n())); + Assert (face_constraints.m () == slave_dofs.size (), + ExcDimensionMismatch(slave_dofs.size (), + face_constraints.m())); + + const unsigned int n_master_dofs = master_dofs.size (); + const unsigned int n_slave_dofs = slave_dofs.size (); + + // check for a couple + // conditions that happened + // in parallel distributed + // mode + for (unsigned int row=0; row!=n_slave_dofs; ++row) + Assert (slave_dofs[row] != numbers::invalid_unsigned_int, + ExcInternalError()); + for (unsigned int col=0; col!=n_master_dofs; ++col) + Assert (master_dofs[col] != numbers::invalid_unsigned_int, + ExcInternalError()); + + + for (unsigned int row=0; row!=n_slave_dofs; ++row) + if (constraints.is_constrained (slave_dofs[row]) == false) + { + bool constraint_already_satisfied = false; + + // Check if we have an identity + // constraint, which is already + // satisfied by unification of + // the corresponding global dof + // indices + for (unsigned int i=0; i= 1e-14*abs_sum)) + constraints.add_entry (slave_dofs[row], + master_dofs[i], + face_constraints (row,i)); + constraints.set_inhomogeneity (slave_dofs[row], 0.); + } + } } } @@ -1916,52 +1916,52 @@ namespace DoFTools void make_hp_hanging_node_constraints (const dealii::DoFHandler<1> &, - ConstraintMatrix &) + ConstraintMatrix &) { - // nothing to do for regular - // dof handlers in 1d + // nothing to do for regular + // dof handlers in 1d } void make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1> &, - ConstraintMatrix &, - dealii::internal::int2type<1>) + ConstraintMatrix &, + dealii::internal::int2type<1>) { - // nothing to do for regular - // dof handlers in 1d + // nothing to do for regular + // dof handlers in 1d } void make_hp_hanging_node_constraints (const dealii::MGDoFHandler<1> &, - ConstraintMatrix &) + ConstraintMatrix &) { - // nothing to do for regular - // dof handlers in 1d + // nothing to do for regular + // dof handlers in 1d } void make_oldstyle_hanging_node_constraints (const dealii::MGDoFHandler<1> &, - ConstraintMatrix &, - dealii::internal::int2type<1>) + ConstraintMatrix &, + dealii::internal::int2type<1>) { - // nothing to do for regular - // dof handlers in 1d + // nothing to do for regular + // dof handlers in 1d } void make_hp_hanging_node_constraints (const dealii::hp::DoFHandler<1> &/*dof_handler*/, - ConstraintMatrix &/*constraints*/) + ConstraintMatrix &/*constraints*/) { - // we may have to compute - // constraints for - // vertices. gotta think about - // that a bit more + // we may have to compute + // constraints for + // vertices. gotta think about + // that a bit more //TODO[WB]: think about what to do here... } @@ -1969,86 +1969,86 @@ namespace DoFTools void make_oldstyle_hanging_node_constraints (const dealii::hp::DoFHandler<1> &/*dof_handler*/, - ConstraintMatrix &/*constraints*/, - dealii::internal::int2type<1>) + ConstraintMatrix &/*constraints*/, + dealii::internal::int2type<1>) { - // we may have to compute - // constraints for - // vertices. gotta think about - // that a bit more + // we may have to compute + // constraints for + // vertices. gotta think about + // that a bit more //TODO[WB]: think about what to do here... } void make_hp_hanging_node_constraints (const dealii::DoFHandler<1,2> &, - ConstraintMatrix &) + ConstraintMatrix &) { - // nothing to do for regular - // dof handlers in 1d + // nothing to do for regular + // dof handlers in 1d } void make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1,2> &, - ConstraintMatrix &, - dealii::internal::int2type<1>) + ConstraintMatrix &, + dealii::internal::int2type<1>) { - // nothing to do for regular - // dof handlers in 1d + // nothing to do for regular + // dof handlers in 1d } void make_hp_hanging_node_constraints (const dealii::DoFHandler<1,3> &, - ConstraintMatrix &) + ConstraintMatrix &) { - // nothing to do for regular - // dof handlers in 1d + // nothing to do for regular + // dof handlers in 1d } - + void make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1,3> &, - ConstraintMatrix &, - dealii::internal::int2type<1>) + ConstraintMatrix &, + dealii::internal::int2type<1>) { - // nothing to do for regular - // dof handlers in 1d + // nothing to do for regular + // dof handlers in 1d } - + // currently not used but may be in the future: // void // make_hp_hanging_node_constraints (const dealii::MGDoFHandler<1,2> &, -// ConstraintMatrix &) +// ConstraintMatrix &) // { -// // nothing to do for regular -// // dof handlers in 1d +// // nothing to do for regular +// // dof handlers in 1d // } // void // make_oldstyle_hanging_node_constraints (const dealii::MGDoFHandler<1,2> &, -// ConstraintMatrix &, -// dealii::internal::int2type<1>) +// ConstraintMatrix &, +// dealii::internal::int2type<1>) // { -// // nothing to do for regular -// // dof handlers in 1d +// // nothing to do for regular +// // dof handlers in 1d // } // void // make_oldstyle_hanging_node_constraints (const dealii::hp::DoFHandler<1,2> &/*dof_handler*/, -// ConstraintMatrix &/*constraints*/, -// dealii::internal::int2type<1>) +// ConstraintMatrix &/*constraints*/, +// dealii::internal::int2type<1>) // { -// // we may have to compute -// // constraints for -// // vertices. gotta think about -// // that a bit more +// // we may have to compute +// // constraints for +// // vertices. gotta think about +// // that a bit more // //TODO[WB]: think about what to do here... // } //#endif @@ -2058,8 +2058,8 @@ namespace DoFTools template void make_oldstyle_hanging_node_constraints (const DH &dof_handler, - ConstraintMatrix &constraints, - dealii::internal::int2type<2>) + ConstraintMatrix &constraints, + dealii::internal::int2type<2>) { const unsigned int dim = 2; @@ -2068,145 +2068,145 @@ namespace DoFTools std::vector dofs_on_mother; std::vector dofs_on_children; - // loop over all lines; only on - // lines there can be constraints. - // We do so by looping over all - // active cells and checking - // whether any of the faces are - // refined which can only be from - // the neighboring cell because - // this one is active. In that - // case, the face is subject to - // constraints - // - // note that even though we may - // visit a face twice if the - // neighboring cells are equally - // refined, we can only visit each - // face with hanging nodes once + // loop over all lines; only on + // lines there can be constraints. + // We do so by looping over all + // active cells and checking + // whether any of the faces are + // refined which can only be from + // the neighboring cell because + // this one is active. In that + // case, the face is subject to + // constraints + // + // note that even though we may + // visit a face twice if the + // neighboring cells are equally + // refined, we can only visit each + // face with hanging nodes once typename DH::active_cell_iterator cell = dof_handler.begin_active(), - endc = dof_handler.end(); + endc = dof_handler.end(); for (; cell!=endc; ++cell) - // artificial cells can at - // best neighbor ghost cells, - // but we're not interested - // in these interfaces - if (!cell->is_artificial ()) - for (unsigned int face=0; face::faces_per_cell; ++face) - if (cell->face(face)->has_children()) - { - // in any case, faces - // can have at most two - // active fe indices, - // but here the face - // can have only one - // (namely the same as - // that from the cell - // we're sitting on), - // and each of the - // children can have - // only one as - // well. check this - Assert (cell->face(face)->n_active_fe_indices() == 1, - ExcInternalError()); - Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index()) - == true, - ExcInternalError()); - for (unsigned int c=0; cface(face)->n_children(); ++c) - if (!cell->neighbor_child_on_subface(face,c)->is_artificial()) - Assert (cell->face(face)->child(c)->n_active_fe_indices() == 1, - ExcInternalError()); - - // right now, all that - // is implemented is - // the case that both - // sides use the same - // fe - for (unsigned int c=0; cface(face)->n_children(); ++c) - if (!cell->neighbor_child_on_subface(face,c)->is_artificial()) - Assert (cell->face(face)->child(c) - ->fe_index_is_active(cell->active_fe_index()) == true, - ExcNotImplemented()); - - // ok, start up the work - const FiniteElement &fe = cell->get_fe(); - const unsigned int fe_index = cell->active_fe_index(); - - const unsigned int - n_dofs_on_mother = 2*fe.dofs_per_vertex + fe.dofs_per_line, - n_dofs_on_children = fe.dofs_per_vertex + 2*fe.dofs_per_line; - - dofs_on_mother.resize (n_dofs_on_mother); - dofs_on_children.resize (n_dofs_on_children); - - Assert(n_dofs_on_mother == fe.constraints().n(), - ExcDimensionMismatch(n_dofs_on_mother, - fe.constraints().n())); - Assert(n_dofs_on_children == fe.constraints().m(), - ExcDimensionMismatch(n_dofs_on_children, - fe.constraints().m())); - - const typename DH::line_iterator this_face = cell->face(face); - - // fill the dofs indices. Use same - // enumeration scheme as in - // @p{FiniteElement::constraints()} - unsigned int next_index = 0; - for (unsigned int vertex=0; vertex<2; ++vertex) - for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) - dofs_on_mother[next_index++] = this_face->vertex_dof_index(vertex,dof, - fe_index); - for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof) - dofs_on_mother[next_index++] = this_face->dof_index(dof, fe_index); - AssertDimension (next_index, dofs_on_mother.size()); - - next_index = 0; - for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) - dofs_on_children[next_index++] - = this_face->child(0)->vertex_dof_index(1,dof,fe_index); - for (unsigned int child=0; child<2; ++child) - for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof) - dofs_on_children[next_index++] - = this_face->child(child)->dof_index(dof, fe_index); - AssertDimension (next_index, dofs_on_children.size()); - - // for each row in the constraint - // matrix for this line: - for (unsigned int row=0; row!=dofs_on_children.size(); ++row) - { - constraints.add_line (dofs_on_children[row]); - for (unsigned int i=0; i!=dofs_on_mother.size(); ++i) - constraints.add_entry (dofs_on_children[row], - dofs_on_mother[i], - fe.constraints()(row,i)); - - constraints.set_inhomogeneity (dofs_on_children[row], 0.); - } - } - else - { - // this face has no - // children, but it - // could still be - // that it is shared - // by two cells that - // use a different fe - // index. check a - // couple of things, - // but ignore the - // case that the - // neighbor is an - // artificial cell - if (!cell->at_boundary(face) && - !cell->neighbor(face)->is_artificial()) - { - Assert (cell->face(face)->n_active_fe_indices() == 1, - ExcNotImplemented()); - Assert (cell->face(face) - ->fe_index_is_active(cell->active_fe_index()) == true, - ExcInternalError()); - } - } + // artificial cells can at + // best neighbor ghost cells, + // but we're not interested + // in these interfaces + if (!cell->is_artificial ()) + for (unsigned int face=0; face::faces_per_cell; ++face) + if (cell->face(face)->has_children()) + { + // in any case, faces + // can have at most two + // active fe indices, + // but here the face + // can have only one + // (namely the same as + // that from the cell + // we're sitting on), + // and each of the + // children can have + // only one as + // well. check this + Assert (cell->face(face)->n_active_fe_indices() == 1, + ExcInternalError()); + Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index()) + == true, + ExcInternalError()); + for (unsigned int c=0; cface(face)->n_children(); ++c) + if (!cell->neighbor_child_on_subface(face,c)->is_artificial()) + Assert (cell->face(face)->child(c)->n_active_fe_indices() == 1, + ExcInternalError()); + + // right now, all that + // is implemented is + // the case that both + // sides use the same + // fe + for (unsigned int c=0; cface(face)->n_children(); ++c) + if (!cell->neighbor_child_on_subface(face,c)->is_artificial()) + Assert (cell->face(face)->child(c) + ->fe_index_is_active(cell->active_fe_index()) == true, + ExcNotImplemented()); + + // ok, start up the work + const FiniteElement &fe = cell->get_fe(); + const unsigned int fe_index = cell->active_fe_index(); + + const unsigned int + n_dofs_on_mother = 2*fe.dofs_per_vertex + fe.dofs_per_line, + n_dofs_on_children = fe.dofs_per_vertex + 2*fe.dofs_per_line; + + dofs_on_mother.resize (n_dofs_on_mother); + dofs_on_children.resize (n_dofs_on_children); + + Assert(n_dofs_on_mother == fe.constraints().n(), + ExcDimensionMismatch(n_dofs_on_mother, + fe.constraints().n())); + Assert(n_dofs_on_children == fe.constraints().m(), + ExcDimensionMismatch(n_dofs_on_children, + fe.constraints().m())); + + const typename DH::line_iterator this_face = cell->face(face); + + // fill the dofs indices. Use same + // enumeration scheme as in + // @p{FiniteElement::constraints()} + unsigned int next_index = 0; + for (unsigned int vertex=0; vertex<2; ++vertex) + for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) + dofs_on_mother[next_index++] = this_face->vertex_dof_index(vertex,dof, + fe_index); + for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof) + dofs_on_mother[next_index++] = this_face->dof_index(dof, fe_index); + AssertDimension (next_index, dofs_on_mother.size()); + + next_index = 0; + for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) + dofs_on_children[next_index++] + = this_face->child(0)->vertex_dof_index(1,dof,fe_index); + for (unsigned int child=0; child<2; ++child) + for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof) + dofs_on_children[next_index++] + = this_face->child(child)->dof_index(dof, fe_index); + AssertDimension (next_index, dofs_on_children.size()); + + // for each row in the constraint + // matrix for this line: + for (unsigned int row=0; row!=dofs_on_children.size(); ++row) + { + constraints.add_line (dofs_on_children[row]); + for (unsigned int i=0; i!=dofs_on_mother.size(); ++i) + constraints.add_entry (dofs_on_children[row], + dofs_on_mother[i], + fe.constraints()(row,i)); + + constraints.set_inhomogeneity (dofs_on_children[row], 0.); + } + } + else + { + // this face has no + // children, but it + // could still be + // that it is shared + // by two cells that + // use a different fe + // index. check a + // couple of things, + // but ignore the + // case that the + // neighbor is an + // artificial cell + if (!cell->at_boundary(face) && + !cell->neighbor(face)->is_artificial()) + { + Assert (cell->face(face)->n_active_fe_indices() == 1, + ExcNotImplemented()); + Assert (cell->face(face) + ->fe_index_is_active(cell->active_fe_index()) == true, + ExcInternalError()); + } + } } @@ -2214,1059 +2214,1059 @@ namespace DoFTools template void make_oldstyle_hanging_node_constraints (const DH &dof_handler, - ConstraintMatrix &constraints, - dealii::internal::int2type<3>) + ConstraintMatrix &constraints, + dealii::internal::int2type<3>) { const unsigned int dim = 3; std::vector dofs_on_mother; std::vector dofs_on_children; - // loop over all quads; only on - // quads there can be constraints. - // We do so by looping over all - // active cells and checking - // whether any of the faces are - // refined which can only be from - // the neighboring cell because - // this one is active. In that - // case, the face is subject to - // constraints - // - // note that even though we may - // visit a face twice if the - // neighboring cells are equally - // refined, we can only visit each - // face with hanging nodes once + // loop over all quads; only on + // quads there can be constraints. + // We do so by looping over all + // active cells and checking + // whether any of the faces are + // refined which can only be from + // the neighboring cell because + // this one is active. In that + // case, the face is subject to + // constraints + // + // note that even though we may + // visit a face twice if the + // neighboring cells are equally + // refined, we can only visit each + // face with hanging nodes once typename DH::active_cell_iterator cell = dof_handler.begin_active(), - endc = dof_handler.end(); + endc = dof_handler.end(); for (; cell!=endc; ++cell) - // artificial cells can at - // best neighbor ghost cells, - // but we're not interested - // in these interfaces - if (!cell->is_artificial ()) - for (unsigned int face=0; face::faces_per_cell; ++face) - if (cell->face(face)->has_children()) - { - // first of all, make sure that - // we treat a case which is - // possible, i.e. either no dofs - // on the face at all or no - // anisotropic refinement - if (cell->get_fe().dofs_per_face == 0) - continue; - - Assert(cell->face(face)->refinement_case()==RefinementCase::isotropic_refinement, - ExcNotImplemented()); - - // in any case, faces - // can have at most two - // active fe indices, - // but here the face - // can have only one - // (namely the same as - // that from the cell - // we're sitting on), - // and each of the - // children can have - // only one as - // well. check this - AssertDimension (cell->face(face)->n_active_fe_indices(), 1); - Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index()) - == true, - ExcInternalError()); - for (unsigned int c=0; cface(face)->n_children(); ++c) - AssertDimension (cell->face(face)->child(c)->n_active_fe_indices(), 1); - - // right now, all that - // is implemented is - // the case that both - // sides use the same - // fe, and not only - // that but also that - // all lines bounding - // this face and the - // children have the - // same fe - for (unsigned int c=0; cface(face)->n_children(); ++c) - if (!cell->neighbor_child_on_subface(face,c)->is_artificial()) - { - Assert (cell->face(face)->child(c) - ->fe_index_is_active(cell->active_fe_index()) == true, - ExcNotImplemented()); - for (unsigned int e=0; e<4; ++e) - { - Assert (cell->face(face)->child(c)->line(e) - ->n_active_fe_indices() == 1, - ExcNotImplemented()); - Assert (cell->face(face)->child(c)->line(e) - ->fe_index_is_active(cell->active_fe_index()) == true, - ExcNotImplemented()); - } - } - for (unsigned int e=0; e<4; ++e) - { - Assert (cell->face(face)->line(e) - ->n_active_fe_indices() == 1, - ExcNotImplemented()); - Assert (cell->face(face)->line(e) - ->fe_index_is_active(cell->active_fe_index()) == true, - ExcNotImplemented()); - } - - // ok, start up the work - const FiniteElement &fe = cell->get_fe(); - const unsigned int fe_index = cell->active_fe_index(); - - const unsigned int n_dofs_on_mother = fe.dofs_per_face; - const unsigned int n_dofs_on_children = (5*fe.dofs_per_vertex+ - 12*fe.dofs_per_line+ - 4*fe.dofs_per_quad); + // artificial cells can at + // best neighbor ghost cells, + // but we're not interested + // in these interfaces + if (!cell->is_artificial ()) + for (unsigned int face=0; face::faces_per_cell; ++face) + if (cell->face(face)->has_children()) + { + // first of all, make sure that + // we treat a case which is + // possible, i.e. either no dofs + // on the face at all or no + // anisotropic refinement + if (cell->get_fe().dofs_per_face == 0) + continue; + + Assert(cell->face(face)->refinement_case()==RefinementCase::isotropic_refinement, + ExcNotImplemented()); + + // in any case, faces + // can have at most two + // active fe indices, + // but here the face + // can have only one + // (namely the same as + // that from the cell + // we're sitting on), + // and each of the + // children can have + // only one as + // well. check this + AssertDimension (cell->face(face)->n_active_fe_indices(), 1); + Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index()) + == true, + ExcInternalError()); + for (unsigned int c=0; cface(face)->n_children(); ++c) + AssertDimension (cell->face(face)->child(c)->n_active_fe_indices(), 1); + + // right now, all that + // is implemented is + // the case that both + // sides use the same + // fe, and not only + // that but also that + // all lines bounding + // this face and the + // children have the + // same fe + for (unsigned int c=0; cface(face)->n_children(); ++c) + if (!cell->neighbor_child_on_subface(face,c)->is_artificial()) + { + Assert (cell->face(face)->child(c) + ->fe_index_is_active(cell->active_fe_index()) == true, + ExcNotImplemented()); + for (unsigned int e=0; e<4; ++e) + { + Assert (cell->face(face)->child(c)->line(e) + ->n_active_fe_indices() == 1, + ExcNotImplemented()); + Assert (cell->face(face)->child(c)->line(e) + ->fe_index_is_active(cell->active_fe_index()) == true, + ExcNotImplemented()); + } + } + for (unsigned int e=0; e<4; ++e) + { + Assert (cell->face(face)->line(e) + ->n_active_fe_indices() == 1, + ExcNotImplemented()); + Assert (cell->face(face)->line(e) + ->fe_index_is_active(cell->active_fe_index()) == true, + ExcNotImplemented()); + } + + // ok, start up the work + const FiniteElement &fe = cell->get_fe(); + const unsigned int fe_index = cell->active_fe_index(); + + const unsigned int n_dofs_on_mother = fe.dofs_per_face; + const unsigned int n_dofs_on_children = (5*fe.dofs_per_vertex+ + 12*fe.dofs_per_line+ + 4*fe.dofs_per_quad); //TODO[TL]: think about this and the following in case of anisotropic refinement - dofs_on_mother.resize (n_dofs_on_mother); - dofs_on_children.resize (n_dofs_on_children); - - Assert(n_dofs_on_mother == fe.constraints().n(), - ExcDimensionMismatch(n_dofs_on_mother, - fe.constraints().n())); - Assert(n_dofs_on_children == fe.constraints().m(), - ExcDimensionMismatch(n_dofs_on_children, - fe.constraints().m())); - - const typename DH::face_iterator this_face = cell->face(face); - - // fill the dofs indices. Use same - // enumeration scheme as in - // @p{FiniteElement::constraints()} - unsigned int next_index = 0; - for (unsigned int vertex=0; vertex<4; ++vertex) - for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) - dofs_on_mother[next_index++] = this_face->vertex_dof_index(vertex,dof, - fe_index); - for (unsigned int line=0; line<4; ++line) - for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof) - dofs_on_mother[next_index++] - = this_face->line(line)->dof_index(dof, fe_index); - for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof) - dofs_on_mother[next_index++] = this_face->dof_index(dof, fe_index); - AssertDimension (next_index, dofs_on_mother.size()); - - next_index = 0; - - // assert some consistency - // assumptions - //TODO[TL]: think about this in case of anisotropic refinement - Assert (dof_handler.get_tria().get_anisotropic_refinement_flag() || - ((this_face->child(0)->vertex_index(3) == - this_face->child(1)->vertex_index(2)) && - (this_face->child(0)->vertex_index(3) == - this_face->child(2)->vertex_index(1)) && - (this_face->child(0)->vertex_index(3) == - this_face->child(3)->vertex_index(0))), - ExcInternalError()); - for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) - dofs_on_children[next_index++] - = this_face->child(0)->vertex_dof_index(3,dof); - - // dof numbers on the centers of - // the lines bounding this face - for (unsigned int line=0; line<4; ++line) - for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) - dofs_on_children[next_index++] - = this_face->line(line)->child(0)->vertex_dof_index(1,dof, fe_index); - - // next the dofs on the lines interior - // to the face; the order of these - // lines is laid down in the - // FiniteElement class documentation - for (unsigned int dof=0; dofchild(0)->line(1)->dof_index(dof, fe_index); - for (unsigned int dof=0; dofchild(2)->line(1)->dof_index(dof, fe_index); - for (unsigned int dof=0; dofchild(0)->line(3)->dof_index(dof, fe_index); - for (unsigned int dof=0; dofchild(1)->line(3)->dof_index(dof, fe_index); - - // dofs on the bordering lines - for (unsigned int line=0; line<4; ++line) - for (unsigned int child=0; child<2; ++child) - for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof) - dofs_on_children[next_index++] - = this_face->line(line)->child(child)->dof_index(dof, fe_index); - - // finally, for the dofs interior - // to the four child faces - for (unsigned int child=0; child<4; ++child) - for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof) - dofs_on_children[next_index++] - = this_face->child(child)->dof_index(dof, fe_index); - AssertDimension (next_index, dofs_on_children.size()); - - // for each row in the constraint - // matrix for this line: - for (unsigned int row=0; row!=dofs_on_children.size(); ++row) - { - constraints.add_line (dofs_on_children[row]); - for (unsigned int i=0; i!=dofs_on_mother.size(); ++i) - constraints.add_entry (dofs_on_children[row], - dofs_on_mother[i], - fe.constraints()(row,i)); - - constraints.set_inhomogeneity(dofs_on_children[row], 0.); - } - } - else - { - // this face has no - // children, but it - // could still be - // that it is shared - // by two cells that - // use a different fe - // index. check a - // couple of things, - // but ignore the - // case that the - // neighbor is an - // artificial cell - if (!cell->at_boundary(face) && - !cell->neighbor(face)->is_artificial()) - { - Assert (cell->face(face)->n_active_fe_indices() == 1, - ExcNotImplemented()); - Assert (cell->face(face) - ->fe_index_is_active(cell->active_fe_index()) == true, - ExcInternalError()); - } - } + dofs_on_mother.resize (n_dofs_on_mother); + dofs_on_children.resize (n_dofs_on_children); + + Assert(n_dofs_on_mother == fe.constraints().n(), + ExcDimensionMismatch(n_dofs_on_mother, + fe.constraints().n())); + Assert(n_dofs_on_children == fe.constraints().m(), + ExcDimensionMismatch(n_dofs_on_children, + fe.constraints().m())); + + const typename DH::face_iterator this_face = cell->face(face); + + // fill the dofs indices. Use same + // enumeration scheme as in + // @p{FiniteElement::constraints()} + unsigned int next_index = 0; + for (unsigned int vertex=0; vertex<4; ++vertex) + for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) + dofs_on_mother[next_index++] = this_face->vertex_dof_index(vertex,dof, + fe_index); + for (unsigned int line=0; line<4; ++line) + for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof) + dofs_on_mother[next_index++] + = this_face->line(line)->dof_index(dof, fe_index); + for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof) + dofs_on_mother[next_index++] = this_face->dof_index(dof, fe_index); + AssertDimension (next_index, dofs_on_mother.size()); + + next_index = 0; + + // assert some consistency + // assumptions + //TODO[TL]: think about this in case of anisotropic refinement + Assert (dof_handler.get_tria().get_anisotropic_refinement_flag() || + ((this_face->child(0)->vertex_index(3) == + this_face->child(1)->vertex_index(2)) && + (this_face->child(0)->vertex_index(3) == + this_face->child(2)->vertex_index(1)) && + (this_face->child(0)->vertex_index(3) == + this_face->child(3)->vertex_index(0))), + ExcInternalError()); + for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) + dofs_on_children[next_index++] + = this_face->child(0)->vertex_dof_index(3,dof); + + // dof numbers on the centers of + // the lines bounding this face + for (unsigned int line=0; line<4; ++line) + for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) + dofs_on_children[next_index++] + = this_face->line(line)->child(0)->vertex_dof_index(1,dof, fe_index); + + // next the dofs on the lines interior + // to the face; the order of these + // lines is laid down in the + // FiniteElement class documentation + for (unsigned int dof=0; dofchild(0)->line(1)->dof_index(dof, fe_index); + for (unsigned int dof=0; dofchild(2)->line(1)->dof_index(dof, fe_index); + for (unsigned int dof=0; dofchild(0)->line(3)->dof_index(dof, fe_index); + for (unsigned int dof=0; dofchild(1)->line(3)->dof_index(dof, fe_index); + + // dofs on the bordering lines + for (unsigned int line=0; line<4; ++line) + for (unsigned int child=0; child<2; ++child) + for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof) + dofs_on_children[next_index++] + = this_face->line(line)->child(child)->dof_index(dof, fe_index); + + // finally, for the dofs interior + // to the four child faces + for (unsigned int child=0; child<4; ++child) + for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof) + dofs_on_children[next_index++] + = this_face->child(child)->dof_index(dof, fe_index); + AssertDimension (next_index, dofs_on_children.size()); + + // for each row in the constraint + // matrix for this line: + for (unsigned int row=0; row!=dofs_on_children.size(); ++row) + { + constraints.add_line (dofs_on_children[row]); + for (unsigned int i=0; i!=dofs_on_mother.size(); ++i) + constraints.add_entry (dofs_on_children[row], + dofs_on_mother[i], + fe.constraints()(row,i)); + + constraints.set_inhomogeneity(dofs_on_children[row], 0.); + } + } + else + { + // this face has no + // children, but it + // could still be + // that it is shared + // by two cells that + // use a different fe + // index. check a + // couple of things, + // but ignore the + // case that the + // neighbor is an + // artificial cell + if (!cell->at_boundary(face) && + !cell->neighbor(face)->is_artificial()) + { + Assert (cell->face(face)->n_active_fe_indices() == 1, + ExcNotImplemented()); + Assert (cell->face(face) + ->fe_index_is_active(cell->active_fe_index()) == true, + ExcInternalError()); + } + } } template void make_hp_hanging_node_constraints (const DH &dof_handler, - ConstraintMatrix &constraints) + ConstraintMatrix &constraints) { - // note: this function is going - // to be hard to understand if - // you haven't read the hp - // paper. however, we try to - // follow the notation laid out - // there, so go read the paper - // before you try to understand - // what is going on here + // note: this function is going + // to be hard to understand if + // you haven't read the hp + // paper. however, we try to + // follow the notation laid out + // there, so go read the paper + // before you try to understand + // what is going on here const unsigned int dim = DH::dimension; const unsigned int spacedim = DH::space_dimension; - // a matrix to be used for - // constraints below. declared - // here and simply resized down - // below to avoid permanent - // re-allocation of memory + // a matrix to be used for + // constraints below. declared + // here and simply resized down + // below to avoid permanent + // re-allocation of memory FullMatrix constraint_matrix; - // similarly have arrays that - // will hold master and slave - // dof numbers, as well as a - // scratch array needed for the - // complicated case below + // similarly have arrays that + // will hold master and slave + // dof numbers, as well as a + // scratch array needed for the + // complicated case below std::vector master_dofs; std::vector slave_dofs; std::vector scratch_dofs; - // caches for the face and - // subface interpolation - // matrices between different - // (or the same) finite - // elements. we compute them - // only once, namely the first - // time they are needed, and - // then just reuse them + // caches for the face and + // subface interpolation + // matrices between different + // (or the same) finite + // elements. we compute them + // only once, namely the first + // time they are needed, and + // then just reuse them Table<2,std_cxx1x::shared_ptr > > - face_interpolation_matrices (n_finite_elements (dof_handler), - n_finite_elements (dof_handler)); + face_interpolation_matrices (n_finite_elements (dof_handler), + n_finite_elements (dof_handler)); Table<3,std_cxx1x::shared_ptr > > - subface_interpolation_matrices (n_finite_elements (dof_handler), - n_finite_elements (dof_handler), - GeometryInfo::max_children_per_face); - - // similarly have a cache for - // the matrices that are split - // into their master and slave - // parts, and for which the - // master part is - // inverted. these two matrices - // are derived from the face - // interpolation matrix as - // described in the @ref hp_paper "hp paper" + subface_interpolation_matrices (n_finite_elements (dof_handler), + n_finite_elements (dof_handler), + GeometryInfo::max_children_per_face); + + // similarly have a cache for + // the matrices that are split + // into their master and slave + // parts, and for which the + // master part is + // inverted. these two matrices + // are derived from the face + // interpolation matrix as + // described in the @ref hp_paper "hp paper" Table<2,std_cxx1x::shared_ptr,FullMatrix > > > - split_face_interpolation_matrices (n_finite_elements (dof_handler), - n_finite_elements (dof_handler)); - - // finally, for each pair of finite - // elements, have a mask that states - // which of the degrees of freedom on - // the coarse side of a refined face - // will act as master dofs. + split_face_interpolation_matrices (n_finite_elements (dof_handler), + n_finite_elements (dof_handler)); + + // finally, for each pair of finite + // elements, have a mask that states + // which of the degrees of freedom on + // the coarse side of a refined face + // will act as master dofs. Table<2,std_cxx1x::shared_ptr > > - master_dof_masks (n_finite_elements (dof_handler), - n_finite_elements (dof_handler)); - - // loop over all faces - // - // note that even though we may - // visit a face twice if the - // neighboring cells are equally - // refined, we can only visit each - // face with hanging nodes once + master_dof_masks (n_finite_elements (dof_handler), + n_finite_elements (dof_handler)); + + // loop over all faces + // + // note that even though we may + // visit a face twice if the + // neighboring cells are equally + // refined, we can only visit each + // face with hanging nodes once typename DH::active_cell_iterator cell = dof_handler.begin_active(), - endc = dof_handler.end(); + endc = dof_handler.end(); for (; cell!=endc; ++cell) - // artificial cells can at - // best neighbor ghost cells, - // but we're not interested - // in these interfaces - if (!cell->is_artificial ()) - for (unsigned int face=0; face::faces_per_cell; ++face) - if (cell->face(face)->has_children()) - { - // first of all, make sure that - // we treat a case which is - // possible, i.e. either no dofs - // on the face at all or no - // anisotropic refinement - if (cell->get_fe().dofs_per_face == 0) - continue; - - Assert(cell->face(face)->refinement_case()==RefinementCase::isotropic_refinement, - ExcNotImplemented()); - - // so now we've found a - // face of an active - // cell that has - // children. that means - // that there are - // hanging nodes here. - - // in any case, faces - // can have at most two - // sets of active fe - // indices, but here - // the face can have - // only one (namely the - // same as that from - // the cell we're - // sitting on), and - // each of the children - // can have only one as - // well. check this - Assert (cell->face(face)->n_active_fe_indices() == 1, - ExcInternalError()); - Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index()) - == true, - ExcInternalError()); - for (unsigned int c=0; cface(face)->n_children(); ++c) - Assert (cell->face(face)->child(c)->n_active_fe_indices() == 1, - ExcInternalError()); - - // first find out - // whether we can - // constrain each of - // the subfaces to the - // mother face. in the - // lingo of the hp - // paper, this would be - // the simple - // case. note that we - // can short-circuit - // this decision if the - // dof_handler doesn't - // support hp at all - // - // ignore all - // interfaces with - // artificial cells - FiniteElementDomination::Domination - mother_face_dominates = FiniteElementDomination::either_element_can_dominate; - - if (DoFHandlerSupportsDifferentFEs::value == true) - for (unsigned int c=0; cface(face)->number_of_children(); ++c) - if (!cell->neighbor_child_on_subface (face, c)->is_artificial()) - mother_face_dominates = mother_face_dominates & - (cell->get_fe().compare_for_face_domination - (cell->neighbor_child_on_subface (face, c)->get_fe())); - - switch (mother_face_dominates) - { - case FiniteElementDomination::this_element_dominates: - case FiniteElementDomination::either_element_can_dominate: - { - // Case 1 (the - // simple case - // and the only - // case that can - // happen for - // non-hp - // DoFHandlers): - // The coarse - // element - // dominates the - // elements on - // the subfaces - // (or they are - // all the same) - // - // so we are - // going to - // constrain - // the DoFs on - // the face - // children - // against the - // DoFs on the - // face itself - master_dofs.resize (cell->get_fe().dofs_per_face); - - cell->face(face)->get_dof_indices (master_dofs, - cell->active_fe_index ()); - - // Now create - // constraint matrix - // for the subfaces and - // assemble it. ignore - // all interfaces with - // artificial cells - // because we can only - // get to such - // interfaces if the - // current cell is a - // ghost cell. also - // ignore the interface - // if the neighboring - // cell is a ghost cell - // in 2d: what we would - // compute here are the - // constraints on the - // ghost cell's DoFs, - // but we are not - // interested in those: - // we only want - // constraints on - // *locally active* - // DoFs, not on - // *locally relevant* - // DoFs. However, in 3d - // we must still - // compute those - // constraints because - // it might happen that - // a constraint is - // related to an edge - // where the hanging - // node is only - // detected if we also - // look between ghosts - for (unsigned int c=0; cface(face)->n_children(); ++c) - { - if (cell->neighbor_child_on_subface (face, c)->is_artificial() - || - (dim == 2 && cell->neighbor_child_on_subface (face, c)->is_ghost())) - continue; - - const typename DH::active_face_iterator - subface = cell->face(face)->child(c); - - Assert (subface->n_active_fe_indices() == 1, - ExcInternalError()); - - const unsigned int - subface_fe_index = subface->nth_active_fe_index(0); - - // we sometime run - // into the - // situation where - // for example on - // one big cell we - // have a FE_Q(1) - // and on the - // subfaces we have - // a mixture of - // FE_Q(1) and - // FE_Nothing. In - // that case, the - // face domination - // is - // either_element_can_dominate - // for the whole - // collection of - // subfaces, but on - // the particular - // subface between - // FE_Q(1) and - // FE_Nothing, - // there are no - // constraints that - // we need to take - // care of. in that - // case, just - // continue - if (cell->get_fe().compare_for_face_domination - (subface->get_fe(subface_fe_index)) - == - FiniteElementDomination::no_requirements) - continue; - - // Same procedure as for the - // mother cell. Extract the face - // DoFs from the cell DoFs. - slave_dofs.resize (subface->get_fe(subface_fe_index) - .dofs_per_face); - subface->get_dof_indices (slave_dofs, subface_fe_index); - - for (unsigned int i=0; iget_fe(), - subface->get_fe(subface_fe_index), - c, - subface_interpolation_matrices - [cell->active_fe_index()][subface_fe_index][c]); - - // Add constraints to global constraint - // matrix. - filter_constraints (master_dofs, - slave_dofs, - *(subface_interpolation_matrices - [cell->active_fe_index()][subface_fe_index][c]), - constraints); - } - - break; - } - - case FiniteElementDomination::other_element_dominates: - case FiniteElementDomination::neither_element_dominates: - { - // Case 2 (the "complex" - // case): at least one - // (the neither_... case) - // of the finer elements - // or all of them (the - // other_... case) is - // dominating. See the hp - // paper for a way how to - // deal with this - // situation - // - // since this is - // something that - // can only - // happen for hp - // dof handlers, - // add a check - // here... - Assert (DoFHandlerSupportsDifferentFEs::value == true, - ExcInternalError()); - - // we first have - // to find the - // finite element - // that is able - // to generate a - // space that all - // the other ones - // can be - // constrained to - const unsigned int dominating_fe_index - = get_most_dominating_subface_fe_index (cell->face(face)); - - const FiniteElement &dominating_fe - = dof_handler.get_fe()[dominating_fe_index]; - - // check also - // that it is - // able to - // constrain the - // mother - // face. it - // should be, or - // we wouldn't - // have gotten - // into the - // branch for the - // 'complex' case - Assert ((dominating_fe.compare_for_face_domination - (cell->face(face)->get_fe(cell->face(face)->nth_active_fe_index(0))) - == FiniteElementDomination::this_element_dominates) - || - (dominating_fe.compare_for_face_domination - (cell->face(face)->get_fe(cell->face(face)->nth_active_fe_index(0))) - == FiniteElementDomination::either_element_can_dominate), - ExcInternalError()); - - - // first get the - // interpolation matrix - // from the mother to the - // virtual dofs - Assert (dominating_fe.dofs_per_face <= - cell->get_fe().dofs_per_face, - ExcInternalError()); - - ensure_existence_of_face_matrix - (dominating_fe, - cell->get_fe(), - face_interpolation_matrices - [dominating_fe_index][cell->active_fe_index()]); - - // split this matrix into - // master and slave - // components. invert the - // master component - ensure_existence_of_master_dof_mask - (cell->get_fe(), - dominating_fe, - (*face_interpolation_matrices - [dominating_fe_index] - [cell->active_fe_index()]), - master_dof_masks - [dominating_fe_index] - [cell->active_fe_index()]); - - ensure_existence_of_split_face_matrix - (*face_interpolation_matrices - [dominating_fe_index][cell->active_fe_index()], - (*master_dof_masks - [dominating_fe_index][cell->active_fe_index()]), - split_face_interpolation_matrices - [dominating_fe_index][cell->active_fe_index()]); - - const FullMatrix &restrict_mother_to_virtual_master_inv - = (split_face_interpolation_matrices - [dominating_fe_index][cell->active_fe_index()]->first); - - const FullMatrix &restrict_mother_to_virtual_slave - = (split_face_interpolation_matrices - [dominating_fe_index][cell->active_fe_index()]->second); - - // now compute - // the constraint - // matrix as the - // product - // between the - // inverse matrix - // and the slave - // part - constraint_matrix.reinit (cell->get_fe().dofs_per_face - - dominating_fe.dofs_per_face, - dominating_fe.dofs_per_face); - restrict_mother_to_virtual_slave - .mmult (constraint_matrix, - restrict_mother_to_virtual_master_inv); - - // then figure - // out the global - // numbers of - // master and - // slave dofs and - // apply - // constraints - scratch_dofs.resize (cell->get_fe().dofs_per_face); - cell->face(face)->get_dof_indices (scratch_dofs, - cell->active_fe_index ()); - - // split dofs into master - // and slave components - master_dofs.clear (); - slave_dofs.clear (); - for (unsigned int i=0; iget_fe().dofs_per_face; ++i) - if ((*master_dof_masks - [dominating_fe_index][cell->active_fe_index()])[i] == true) - master_dofs.push_back (scratch_dofs[i]); - else - slave_dofs.push_back (scratch_dofs[i]); - - AssertDimension (master_dofs.size(), dominating_fe.dofs_per_face); - AssertDimension (slave_dofs.size(), - cell->get_fe().dofs_per_face - dominating_fe.dofs_per_face); - - filter_constraints (master_dofs, - slave_dofs, - constraint_matrix, - constraints); - - - - // next we have - // to deal with - // the - // subfaces. do - // as discussed - // in the hp - // paper - for (unsigned int sf=0; - sfface(face)->n_children(); ++sf) - { - // ignore - // interfaces - // with - // artificial - // cells as - // well as - // interfaces - // between - // ghost - // cells in 2d - if (cell->neighbor_child_on_subface (face, sf)->is_artificial() - || - (dim==2 && cell->is_ghost() - && - cell->neighbor_child_on_subface (face, sf)->is_ghost())) - continue; - - Assert (cell->face(face)->child(sf) - ->n_active_fe_indices() == 1, - ExcInternalError()); - - const unsigned int subface_fe_index - = cell->face(face)->child(sf)->nth_active_fe_index(0); - const FiniteElement &subface_fe - = dof_handler.get_fe()[subface_fe_index]; - - // first get the - // interpolation - // matrix from the - // subface to the - // virtual dofs - Assert (dominating_fe.dofs_per_face <= - subface_fe.dofs_per_face, - ExcInternalError()); - ensure_existence_of_subface_matrix - (dominating_fe, - subface_fe, - sf, - subface_interpolation_matrices - [dominating_fe_index][subface_fe_index][sf]); - - const FullMatrix &restrict_subface_to_virtual - = *(subface_interpolation_matrices - [dominating_fe_index][subface_fe_index][sf]); - - constraint_matrix.reinit (subface_fe.dofs_per_face, - dominating_fe.dofs_per_face); - - restrict_subface_to_virtual - .mmult (constraint_matrix, - restrict_mother_to_virtual_master_inv); - - slave_dofs.resize (subface_fe.dofs_per_face); - cell->face(face)->child(sf)->get_dof_indices (slave_dofs, - subface_fe_index); - - filter_constraints (master_dofs, - slave_dofs, - constraint_matrix, - constraints); - } - - break; - } - - case FiniteElementDomination::no_requirements: - // there - // are no - // continuity - // requirements - // between - // the two - // elements. record - // no - // constraints - break; - - default: - // we shouldn't get here - Assert (false, ExcInternalError()); - } - } - else - { - // this face has no - // children, but it - // could still be that - // it is shared by two - // cells that use a - // different fe index - Assert (cell->face(face) - ->fe_index_is_active(cell->active_fe_index()) == true, - ExcInternalError()); - - // see if there is a - // neighbor that is - // an artificial - // cell. in that - // case, we're not - // interested in this - // interface. we test - // this case first - // since artificial - // cells may not have - // an active_fe_index - // set, etc - if (!cell->at_boundary(face) - && - cell->neighbor(face)->is_artificial()) - continue; - - // Only if there is - // a neighbor with - // a different - // active_fe_index - // and the same h-level, - // some action has - // to be taken. - if ((DoFHandlerSupportsDifferentFEs::value == true) - && - !cell->face(face)->at_boundary () - && - (cell->neighbor(face)->active_fe_index () != - cell->active_fe_index ()) - && - (!cell->face(face)->has_children() && - !cell->neighbor_is_coarser(face) )) - { - const typename DH::cell_iterator neighbor = cell->neighbor (face); - - // see which side of the - // face we have to - // constrain - switch (cell->get_fe().compare_for_face_domination (neighbor->get_fe ())) - { - case FiniteElementDomination::this_element_dominates: - { - // Get DoFs on - // dominating and - // dominated side of - // the face - master_dofs.resize (cell->get_fe().dofs_per_face); - cell->face(face)->get_dof_indices (master_dofs, - cell->active_fe_index ()); - - slave_dofs.resize (neighbor->get_fe().dofs_per_face); - cell->face(face)->get_dof_indices (slave_dofs, - neighbor->active_fe_index ()); - - // break if the n_master_dofs == 0, - // because we are attempting to - // constrain to an element that has - // has no face dofs - if(master_dofs.size() == 0) break; - - // make sure - // the element - // constraints - // for this - // face are - // available - ensure_existence_of_face_matrix - (cell->get_fe(), - neighbor->get_fe(), - face_interpolation_matrices - [cell->active_fe_index()][neighbor->active_fe_index()]); - - // Add constraints to global constraint - // matrix. - filter_constraints (master_dofs, - slave_dofs, - *(face_interpolation_matrices - [cell->active_fe_index()] - [neighbor->active_fe_index()]), - constraints); - - break; - } - - case FiniteElementDomination::other_element_dominates: - { - // we don't do anything - // here since we will - // come back to this - // face from the other - // cell, at which time - // we will fall into - // the first case - // clause above - break; - } - - case FiniteElementDomination::either_element_can_dominate: - { - // it appears as if - // neither element has - // any constraints on - // its neighbor. this - // may be because - // neither element has - // any DoFs on faces at - // all. or that the two - // elements are - // actually the same, - // although they happen - // to run under - // different fe_indices - // (this is what - // happens in - // hp/hp_hanging_nodes_01 - // for example). - // - // another possibility - // is what happens in - // crash_13. there, we - // have - // FESystem(FE_Q(1),FE_DGQ(0)) - // vs. FESystem(FE_Q(1),FE_DGQ(1)). - // neither of them - // dominates the - // other. the point is - // that it doesn't - // matter, since - // hopefully for this - // case, both sides' - // dofs should have - // been unified. - // - // make sure this is - // actually true. this - // actually only - // matters, of course, - // if either of the two - // finite elements - // actually do have - // dofs on the face - if ((cell->get_fe().dofs_per_face != 0) - || - (cell->neighbor(face)->get_fe().dofs_per_face != 0)) - { - Assert (cell->get_fe().dofs_per_face - == - cell->neighbor(face)->get_fe().dofs_per_face, - ExcNotImplemented()); - - // (ab)use the master - // and slave dofs - // arrays for a - // moment here - master_dofs.resize (cell->get_fe().dofs_per_face); - cell->face(face) - ->get_dof_indices (master_dofs, - cell->active_fe_index ()); - - slave_dofs.resize (cell->neighbor(face)->get_fe().dofs_per_face); - cell->face(face) - ->get_dof_indices (slave_dofs, - cell->neighbor(face)->active_fe_index ()); - - for (unsigned int i=0; iget_fe().dofs_per_face; ++i) - AssertDimension (master_dofs[i], slave_dofs[i]); - } - - break; - } - - case FiniteElementDomination::neither_element_dominates: - { - // we don't presently - // know what exactly to - // do here. it isn't quite - // clear what exactly we - // would have to do - // here. sit tight until - // someone trips over the - // following statement - // and see what exactly - // is going on - Assert (false, ExcNotImplemented()); - break; - } - - case FiniteElementDomination::no_requirements: - { - // nothing to do here - break; - } - - default: - // we shouldn't get - // here - Assert (false, ExcInternalError()); - } - } - } + // artificial cells can at + // best neighbor ghost cells, + // but we're not interested + // in these interfaces + if (!cell->is_artificial ()) + for (unsigned int face=0; face::faces_per_cell; ++face) + if (cell->face(face)->has_children()) + { + // first of all, make sure that + // we treat a case which is + // possible, i.e. either no dofs + // on the face at all or no + // anisotropic refinement + if (cell->get_fe().dofs_per_face == 0) + continue; + + Assert(cell->face(face)->refinement_case()==RefinementCase::isotropic_refinement, + ExcNotImplemented()); + + // so now we've found a + // face of an active + // cell that has + // children. that means + // that there are + // hanging nodes here. + + // in any case, faces + // can have at most two + // sets of active fe + // indices, but here + // the face can have + // only one (namely the + // same as that from + // the cell we're + // sitting on), and + // each of the children + // can have only one as + // well. check this + Assert (cell->face(face)->n_active_fe_indices() == 1, + ExcInternalError()); + Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index()) + == true, + ExcInternalError()); + for (unsigned int c=0; cface(face)->n_children(); ++c) + Assert (cell->face(face)->child(c)->n_active_fe_indices() == 1, + ExcInternalError()); + + // first find out + // whether we can + // constrain each of + // the subfaces to the + // mother face. in the + // lingo of the hp + // paper, this would be + // the simple + // case. note that we + // can short-circuit + // this decision if the + // dof_handler doesn't + // support hp at all + // + // ignore all + // interfaces with + // artificial cells + FiniteElementDomination::Domination + mother_face_dominates = FiniteElementDomination::either_element_can_dominate; + + if (DoFHandlerSupportsDifferentFEs::value == true) + for (unsigned int c=0; cface(face)->number_of_children(); ++c) + if (!cell->neighbor_child_on_subface (face, c)->is_artificial()) + mother_face_dominates = mother_face_dominates & + (cell->get_fe().compare_for_face_domination + (cell->neighbor_child_on_subface (face, c)->get_fe())); + + switch (mother_face_dominates) + { + case FiniteElementDomination::this_element_dominates: + case FiniteElementDomination::either_element_can_dominate: + { + // Case 1 (the + // simple case + // and the only + // case that can + // happen for + // non-hp + // DoFHandlers): + // The coarse + // element + // dominates the + // elements on + // the subfaces + // (or they are + // all the same) + // + // so we are + // going to + // constrain + // the DoFs on + // the face + // children + // against the + // DoFs on the + // face itself + master_dofs.resize (cell->get_fe().dofs_per_face); + + cell->face(face)->get_dof_indices (master_dofs, + cell->active_fe_index ()); + + // Now create + // constraint matrix + // for the subfaces and + // assemble it. ignore + // all interfaces with + // artificial cells + // because we can only + // get to such + // interfaces if the + // current cell is a + // ghost cell. also + // ignore the interface + // if the neighboring + // cell is a ghost cell + // in 2d: what we would + // compute here are the + // constraints on the + // ghost cell's DoFs, + // but we are not + // interested in those: + // we only want + // constraints on + // *locally active* + // DoFs, not on + // *locally relevant* + // DoFs. However, in 3d + // we must still + // compute those + // constraints because + // it might happen that + // a constraint is + // related to an edge + // where the hanging + // node is only + // detected if we also + // look between ghosts + for (unsigned int c=0; cface(face)->n_children(); ++c) + { + if (cell->neighbor_child_on_subface (face, c)->is_artificial() + || + (dim == 2 && cell->neighbor_child_on_subface (face, c)->is_ghost())) + continue; + + const typename DH::active_face_iterator + subface = cell->face(face)->child(c); + + Assert (subface->n_active_fe_indices() == 1, + ExcInternalError()); + + const unsigned int + subface_fe_index = subface->nth_active_fe_index(0); + + // we sometime run + // into the + // situation where + // for example on + // one big cell we + // have a FE_Q(1) + // and on the + // subfaces we have + // a mixture of + // FE_Q(1) and + // FE_Nothing. In + // that case, the + // face domination + // is + // either_element_can_dominate + // for the whole + // collection of + // subfaces, but on + // the particular + // subface between + // FE_Q(1) and + // FE_Nothing, + // there are no + // constraints that + // we need to take + // care of. in that + // case, just + // continue + if (cell->get_fe().compare_for_face_domination + (subface->get_fe(subface_fe_index)) + == + FiniteElementDomination::no_requirements) + continue; + + // Same procedure as for the + // mother cell. Extract the face + // DoFs from the cell DoFs. + slave_dofs.resize (subface->get_fe(subface_fe_index) + .dofs_per_face); + subface->get_dof_indices (slave_dofs, subface_fe_index); + + for (unsigned int i=0; iget_fe(), + subface->get_fe(subface_fe_index), + c, + subface_interpolation_matrices + [cell->active_fe_index()][subface_fe_index][c]); + + // Add constraints to global constraint + // matrix. + filter_constraints (master_dofs, + slave_dofs, + *(subface_interpolation_matrices + [cell->active_fe_index()][subface_fe_index][c]), + constraints); + } + + break; + } + + case FiniteElementDomination::other_element_dominates: + case FiniteElementDomination::neither_element_dominates: + { + // Case 2 (the "complex" + // case): at least one + // (the neither_... case) + // of the finer elements + // or all of them (the + // other_... case) is + // dominating. See the hp + // paper for a way how to + // deal with this + // situation + // + // since this is + // something that + // can only + // happen for hp + // dof handlers, + // add a check + // here... + Assert (DoFHandlerSupportsDifferentFEs::value == true, + ExcInternalError()); + + // we first have + // to find the + // finite element + // that is able + // to generate a + // space that all + // the other ones + // can be + // constrained to + const unsigned int dominating_fe_index + = get_most_dominating_subface_fe_index (cell->face(face)); + + const FiniteElement &dominating_fe + = dof_handler.get_fe()[dominating_fe_index]; + + // check also + // that it is + // able to + // constrain the + // mother + // face. it + // should be, or + // we wouldn't + // have gotten + // into the + // branch for the + // 'complex' case + Assert ((dominating_fe.compare_for_face_domination + (cell->face(face)->get_fe(cell->face(face)->nth_active_fe_index(0))) + == FiniteElementDomination::this_element_dominates) + || + (dominating_fe.compare_for_face_domination + (cell->face(face)->get_fe(cell->face(face)->nth_active_fe_index(0))) + == FiniteElementDomination::either_element_can_dominate), + ExcInternalError()); + + + // first get the + // interpolation matrix + // from the mother to the + // virtual dofs + Assert (dominating_fe.dofs_per_face <= + cell->get_fe().dofs_per_face, + ExcInternalError()); + + ensure_existence_of_face_matrix + (dominating_fe, + cell->get_fe(), + face_interpolation_matrices + [dominating_fe_index][cell->active_fe_index()]); + + // split this matrix into + // master and slave + // components. invert the + // master component + ensure_existence_of_master_dof_mask + (cell->get_fe(), + dominating_fe, + (*face_interpolation_matrices + [dominating_fe_index] + [cell->active_fe_index()]), + master_dof_masks + [dominating_fe_index] + [cell->active_fe_index()]); + + ensure_existence_of_split_face_matrix + (*face_interpolation_matrices + [dominating_fe_index][cell->active_fe_index()], + (*master_dof_masks + [dominating_fe_index][cell->active_fe_index()]), + split_face_interpolation_matrices + [dominating_fe_index][cell->active_fe_index()]); + + const FullMatrix &restrict_mother_to_virtual_master_inv + = (split_face_interpolation_matrices + [dominating_fe_index][cell->active_fe_index()]->first); + + const FullMatrix &restrict_mother_to_virtual_slave + = (split_face_interpolation_matrices + [dominating_fe_index][cell->active_fe_index()]->second); + + // now compute + // the constraint + // matrix as the + // product + // between the + // inverse matrix + // and the slave + // part + constraint_matrix.reinit (cell->get_fe().dofs_per_face - + dominating_fe.dofs_per_face, + dominating_fe.dofs_per_face); + restrict_mother_to_virtual_slave + .mmult (constraint_matrix, + restrict_mother_to_virtual_master_inv); + + // then figure + // out the global + // numbers of + // master and + // slave dofs and + // apply + // constraints + scratch_dofs.resize (cell->get_fe().dofs_per_face); + cell->face(face)->get_dof_indices (scratch_dofs, + cell->active_fe_index ()); + + // split dofs into master + // and slave components + master_dofs.clear (); + slave_dofs.clear (); + for (unsigned int i=0; iget_fe().dofs_per_face; ++i) + if ((*master_dof_masks + [dominating_fe_index][cell->active_fe_index()])[i] == true) + master_dofs.push_back (scratch_dofs[i]); + else + slave_dofs.push_back (scratch_dofs[i]); + + AssertDimension (master_dofs.size(), dominating_fe.dofs_per_face); + AssertDimension (slave_dofs.size(), + cell->get_fe().dofs_per_face - dominating_fe.dofs_per_face); + + filter_constraints (master_dofs, + slave_dofs, + constraint_matrix, + constraints); + + + + // next we have + // to deal with + // the + // subfaces. do + // as discussed + // in the hp + // paper + for (unsigned int sf=0; + sfface(face)->n_children(); ++sf) + { + // ignore + // interfaces + // with + // artificial + // cells as + // well as + // interfaces + // between + // ghost + // cells in 2d + if (cell->neighbor_child_on_subface (face, sf)->is_artificial() + || + (dim==2 && cell->is_ghost() + && + cell->neighbor_child_on_subface (face, sf)->is_ghost())) + continue; + + Assert (cell->face(face)->child(sf) + ->n_active_fe_indices() == 1, + ExcInternalError()); + + const unsigned int subface_fe_index + = cell->face(face)->child(sf)->nth_active_fe_index(0); + const FiniteElement &subface_fe + = dof_handler.get_fe()[subface_fe_index]; + + // first get the + // interpolation + // matrix from the + // subface to the + // virtual dofs + Assert (dominating_fe.dofs_per_face <= + subface_fe.dofs_per_face, + ExcInternalError()); + ensure_existence_of_subface_matrix + (dominating_fe, + subface_fe, + sf, + subface_interpolation_matrices + [dominating_fe_index][subface_fe_index][sf]); + + const FullMatrix &restrict_subface_to_virtual + = *(subface_interpolation_matrices + [dominating_fe_index][subface_fe_index][sf]); + + constraint_matrix.reinit (subface_fe.dofs_per_face, + dominating_fe.dofs_per_face); + + restrict_subface_to_virtual + .mmult (constraint_matrix, + restrict_mother_to_virtual_master_inv); + + slave_dofs.resize (subface_fe.dofs_per_face); + cell->face(face)->child(sf)->get_dof_indices (slave_dofs, + subface_fe_index); + + filter_constraints (master_dofs, + slave_dofs, + constraint_matrix, + constraints); + } + + break; + } + + case FiniteElementDomination::no_requirements: + // there + // are no + // continuity + // requirements + // between + // the two + // elements. record + // no + // constraints + break; + + default: + // we shouldn't get here + Assert (false, ExcInternalError()); + } + } + else + { + // this face has no + // children, but it + // could still be that + // it is shared by two + // cells that use a + // different fe index + Assert (cell->face(face) + ->fe_index_is_active(cell->active_fe_index()) == true, + ExcInternalError()); + + // see if there is a + // neighbor that is + // an artificial + // cell. in that + // case, we're not + // interested in this + // interface. we test + // this case first + // since artificial + // cells may not have + // an active_fe_index + // set, etc + if (!cell->at_boundary(face) + && + cell->neighbor(face)->is_artificial()) + continue; + + // Only if there is + // a neighbor with + // a different + // active_fe_index + // and the same h-level, + // some action has + // to be taken. + if ((DoFHandlerSupportsDifferentFEs::value == true) + && + !cell->face(face)->at_boundary () + && + (cell->neighbor(face)->active_fe_index () != + cell->active_fe_index ()) + && + (!cell->face(face)->has_children() && + !cell->neighbor_is_coarser(face) )) + { + const typename DH::cell_iterator neighbor = cell->neighbor (face); + + // see which side of the + // face we have to + // constrain + switch (cell->get_fe().compare_for_face_domination (neighbor->get_fe ())) + { + case FiniteElementDomination::this_element_dominates: + { + // Get DoFs on + // dominating and + // dominated side of + // the face + master_dofs.resize (cell->get_fe().dofs_per_face); + cell->face(face)->get_dof_indices (master_dofs, + cell->active_fe_index ()); + + slave_dofs.resize (neighbor->get_fe().dofs_per_face); + cell->face(face)->get_dof_indices (slave_dofs, + neighbor->active_fe_index ()); + + // break if the n_master_dofs == 0, + // because we are attempting to + // constrain to an element that has + // has no face dofs + if(master_dofs.size() == 0) break; + + // make sure + // the element + // constraints + // for this + // face are + // available + ensure_existence_of_face_matrix + (cell->get_fe(), + neighbor->get_fe(), + face_interpolation_matrices + [cell->active_fe_index()][neighbor->active_fe_index()]); + + // Add constraints to global constraint + // matrix. + filter_constraints (master_dofs, + slave_dofs, + *(face_interpolation_matrices + [cell->active_fe_index()] + [neighbor->active_fe_index()]), + constraints); + + break; + } + + case FiniteElementDomination::other_element_dominates: + { + // we don't do anything + // here since we will + // come back to this + // face from the other + // cell, at which time + // we will fall into + // the first case + // clause above + break; + } + + case FiniteElementDomination::either_element_can_dominate: + { + // it appears as if + // neither element has + // any constraints on + // its neighbor. this + // may be because + // neither element has + // any DoFs on faces at + // all. or that the two + // elements are + // actually the same, + // although they happen + // to run under + // different fe_indices + // (this is what + // happens in + // hp/hp_hanging_nodes_01 + // for example). + // + // another possibility + // is what happens in + // crash_13. there, we + // have + // FESystem(FE_Q(1),FE_DGQ(0)) + // vs. FESystem(FE_Q(1),FE_DGQ(1)). + // neither of them + // dominates the + // other. the point is + // that it doesn't + // matter, since + // hopefully for this + // case, both sides' + // dofs should have + // been unified. + // + // make sure this is + // actually true. this + // actually only + // matters, of course, + // if either of the two + // finite elements + // actually do have + // dofs on the face + if ((cell->get_fe().dofs_per_face != 0) + || + (cell->neighbor(face)->get_fe().dofs_per_face != 0)) + { + Assert (cell->get_fe().dofs_per_face + == + cell->neighbor(face)->get_fe().dofs_per_face, + ExcNotImplemented()); + + // (ab)use the master + // and slave dofs + // arrays for a + // moment here + master_dofs.resize (cell->get_fe().dofs_per_face); + cell->face(face) + ->get_dof_indices (master_dofs, + cell->active_fe_index ()); + + slave_dofs.resize (cell->neighbor(face)->get_fe().dofs_per_face); + cell->face(face) + ->get_dof_indices (slave_dofs, + cell->neighbor(face)->active_fe_index ()); + + for (unsigned int i=0; iget_fe().dofs_per_face; ++i) + AssertDimension (master_dofs[i], slave_dofs[i]); + } + + break; + } + + case FiniteElementDomination::neither_element_dominates: + { + // we don't presently + // know what exactly to + // do here. it isn't quite + // clear what exactly we + // would have to do + // here. sit tight until + // someone trips over the + // following statement + // and see what exactly + // is going on + Assert (false, ExcNotImplemented()); + break; + } + + case FiniteElementDomination::no_requirements: + { + // nothing to do here + break; + } + + default: + // we shouldn't get + // here + Assert (false, ExcInternalError()); + } + } + } } } @@ -3276,138 +3276,138 @@ namespace DoFTools template void make_hanging_node_constraints (const DH &dof_handler, - ConstraintMatrix &constraints) + ConstraintMatrix &constraints) { - // Decide whether to use the - // new or old make_hanging_node_constraints - // function. If all the FiniteElement - // or all elements in a FECollection support - // the new face constraint matrix, the - // new code will be used. - // Otherwise, the old implementation is used - // for the moment. + // Decide whether to use the + // new or old make_hanging_node_constraints + // function. If all the FiniteElement + // or all elements in a FECollection support + // the new face constraint matrix, the + // new code will be used. + // Otherwise, the old implementation is used + // for the moment. if (dof_handler.get_fe().hp_constraints_are_implemented ()) internal:: - make_hp_hanging_node_constraints (dof_handler, - constraints); + make_hp_hanging_node_constraints (dof_handler, + constraints); else internal:: - make_oldstyle_hanging_node_constraints (dof_handler, - constraints, - dealii::internal::int2type()); + make_oldstyle_hanging_node_constraints (dof_handler, + constraints, + dealii::internal::int2type()); } namespace internal { - // this internal function assigns to each dof - // the respective component of the vector - // system. if use_blocks is set, then the - // assignment is done by blocks, not by - // components, as specified by - // component_select. The additional argument - // component_select only is used for - // non-primitive FEs, where we need it since - // more components couple, and no unique - // component can be assigned. Then, we sort - // them to the first selected component of the - // vector system. + // this internal function assigns to each dof + // the respective component of the vector + // system. if use_blocks is set, then the + // assignment is done by blocks, not by + // components, as specified by + // component_select. The additional argument + // component_select only is used for + // non-primitive FEs, where we need it since + // more components couple, and no unique + // component can be assigned. Then, we sort + // them to the first selected component of the + // vector system. template inline void extract_dofs_by_component (const DH &dof, - const std::vector &component_select, - const bool sort_by_blocks, - std::vector &dofs_by_component) + const std::vector &component_select, + const bool sort_by_blocks, + std::vector &dofs_by_component) { const dealii::hp::FECollection - fe_collection (dof.get_fe()); + fe_collection (dof.get_fe()); Assert (fe_collection.n_components() < 256, ExcNotImplemented()); Assert (dofs_by_component.size() == dof.n_locally_owned_dofs(), - ExcDimensionMismatch(dofs_by_component.size(), - dof.n_locally_owned_dofs())); + ExcDimensionMismatch(dofs_by_component.size(), + dof.n_locally_owned_dofs())); - // next set up a table for the - // degrees of freedom on each of - // the cells whether it is - // something interesting or not + // next set up a table for the + // degrees of freedom on each of + // the cells whether it is + // something interesting or not std::vector > local_component_association - (fe_collection.size()); + (fe_collection.size()); for (unsigned int f=0; f &fe = - fe_collection[f]; - local_component_association[f].resize(fe.dofs_per_cell); - if (sort_by_blocks == true) - { - for (unsigned int i=0; i &fe = + fe_collection[f]; + local_component_association[f].resize(fe.dofs_per_cell); + if (sort_by_blocks == true) + { + for (unsigned int i=0; i indices; for (typename DH::active_cell_iterator c=dof.begin_active(); - c!=dof.end(); ++ c) - if (c->is_locally_owned()) - { - const unsigned int fe_index = c->active_fe_index(); - const unsigned int dofs_per_cell = c->get_fe().dofs_per_cell; - indices.resize(dofs_per_cell); - c->get_dof_indices(indices); - for (unsigned int i=0; iis_locally_owned()) + { + const unsigned int fe_index = c->active_fe_index(); + const unsigned int dofs_per_cell = c->get_fe().dofs_per_cell; + indices.resize(dofs_per_cell); + c->get_dof_indices(indices); + for (unsigned int i=0; i::ExcFENotPrimitive()); + typename FiniteElement::ExcFENotPrimitive()); - // store a flag whether we should care - // about different components. this is - // just a simplification, we could ask - // for this at every single place - // equally well + // store a flag whether we should care + // about different components. this is + // just a simplification, we could ask + // for this at every single place + // equally well const bool consider_components = (n_components(dof_handler) != 1); - // zero out the components that we - // will touch + // zero out the components that we + // will touch if (consider_components == false) dof_data = 0; else { - std::vector component_dofs (dof_handler.n_locally_owned_dofs()); - std::vector component_mask (dof_handler.get_fe().n_components(), - false); - component_mask[component] = true; - internal::extract_dofs_by_component (dof_handler, component_mask, - false, component_dofs); - - for (unsigned int i=0; i(component)) - dof_data(i) = 0; + std::vector component_dofs (dof_handler.n_locally_owned_dofs()); + std::vector component_mask (dof_handler.get_fe().n_components(), + false); + component_mask[component] = true; + internal::extract_dofs_by_component (dof_handler, component_mask, + false, component_dofs); + + for (unsigned int i=0; i(component)) + dof_data(i) = 0; } - // count how often we have added a value - // in the sum for each dof + // count how often we have added a value + // in the sum for each dof std::vector touch_count (dof_handler.n_dofs(), 0); typename DH::active_cell_iterator cell = dof_handler.begin_active(), - endc = dof_handler.end(); + endc = dof_handler.end(); std::vector dof_indices; dof_indices.reserve (max_dofs_per_cell(dof_handler)); for (unsigned int present_cell = 0; cell!=endc; ++cell, ++present_cell) { - const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; - dof_indices.resize (dofs_per_cell); - cell->get_dof_indices (dof_indices); - - for (unsigned int i=0; iget_fe().system_to_component_index(i).first == component)) - { - // sum up contribution of the - // present_cell to this dof - dof_data(dof_indices[i]) += cell_data(present_cell); - // note that we added another - // summand - ++touch_count[dof_indices[i]]; - } + const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; + dof_indices.resize (dofs_per_cell); + cell->get_dof_indices (dof_indices); + + for (unsigned int i=0; iget_fe().system_to_component_index(i).first == component)) + { + // sum up contribution of the + // present_cell to this dof + dof_data(dof_indices[i]) += cell_data(present_cell); + // note that we added another + // summand + ++touch_count[dof_indices[i]]; + } } - // compute the mean value on all the - // dofs by dividing with the number - // of summands. + // compute the mean value on all the + // dofs by dividing with the number + // of summands. for (unsigned int i=0; i(component_select.size())) + == static_cast(component_select.size())) { - std::fill_n (selected_dofs.begin(), dof.n_locally_owned_dofs(), true); - return; + std::fill_n (selected_dofs.begin(), dof.n_locally_owned_dofs(), true); + return; } - // preset all values by false + // preset all values by false std::fill_n (selected_dofs.begin(), dof.n_locally_owned_dofs(), false); - // if we count by blocks, we need to extract - // the association of blocks with local dofs, - // and then go through all the cells and set - // the properties according to this - // info. Otherwise, we let the function - // extract_dofs_by_component function do the - // job. + // if we count by blocks, we need to extract + // the association of blocks with local dofs, + // and then go through all the cells and set + // the properties according to this + // info. Otherwise, we let the function + // extract_dofs_by_component function do the + // job. std::vector dofs_by_component (dof.n_locally_owned_dofs()); internal::extract_dofs_by_component (dof, component_select, count_by_blocks, - dofs_by_component); + dofs_by_component); for (unsigned int i=0; i(component_select.size())) + == static_cast(component_select.size())) { - std::fill_n (selected_dofs.begin(), dof.n_dofs(), true); - return; + std::fill_n (selected_dofs.begin(), dof.n_dofs(), true); + return; }; - // preset all values by false + // preset all values by false std::fill_n (selected_dofs.begin(), dof.n_dofs(), false); - // if we count by blocks, we need to extract - // the association of blocks with local dofs, - // and then go through all the cells and set - // the properties according to this - // info. Otherwise, we let the function - // extract_dofs_by_component function do the - // job. + // if we count by blocks, we need to extract + // the association of blocks with local dofs, + // and then go through all the cells and set + // the properties according to this + // info. Otherwise, we let the function + // extract_dofs_by_component function do the + // job. std::vector dofs_by_component (dof.n_dofs()); internal::extract_dofs_by_component (dof, component_select, count_by_blocks, - dofs_by_component); + dofs_by_component); for (unsigned int i=0; i(component_select.size())) + == static_cast(component_select.size())) { - std::fill_n (selected_dofs.begin(), dof.n_dofs(level), true); - return; + std::fill_n (selected_dofs.begin(), dof.n_dofs(level), true); + return; }; - // preset all values by false + // preset all values by false std::fill_n (selected_dofs.begin(), dof.n_dofs(level), false); - // next set up a table for the - // degrees of freedom on each of - // the cells whether it is - // something interesting or not + // next set up a table for the + // degrees of freedom on each of + // the cells whether it is + // something interesting or not std::vector local_selected_dofs (fe.dofs_per_cell, false); for (unsigned int i=0; i indices(fe.dofs_per_cell); typename MGDoFHandler::cell_iterator c; for (c = dof.begin(level) ; c != dof.end(level) ; ++ c) { - c->get_mg_dof_indices(indices); - for (unsigned int i=0; iget_mg_dof_indices(indices); + for (unsigned int i=0; i void extract_boundary_dofs (const DH &dof_handler, - const std::vector &component_select, - std::vector &selected_dofs, - const std::set &boundary_indicators) + const std::vector &component_select, + std::vector &selected_dofs, + const std::set &boundary_indicators) { AssertDimension (component_select.size(),n_components(dof_handler)); Assert (boundary_indicators.find (types::internal_face_boundary_id) == boundary_indicators.end(), - ExcInvalidBoundaryIndicator()); + ExcInvalidBoundaryIndicator()); const unsigned int dim=DH::dimension; - // let's see whether we have to - // check for certain boundary - // indicators or whether we can - // accept all + // let's see whether we have to + // check for certain boundary + // indicators or whether we can + // accept all const bool check_boundary_indicator = (boundary_indicators.size() != 0); - // also see whether we have to - // check whether a certain vector - // component is selected, or all + // also see whether we have to + // check whether a certain vector + // component is selected, or all const bool check_vector_component = (component_select != std::vector(component_select.size(), - true)); + true)); - // clear and reset array by default - // values + // clear and reset array by default + // values selected_dofs.clear (); selected_dofs.resize (dof_handler.n_dofs(), false); std::vector face_dof_indices; face_dof_indices.reserve (max_dofs_per_face(dof_handler)); - // now loop over all cells and - // check whether their faces are at - // the boundary. note that we need - // not take special care of single - // lines being at the boundary - // (using - // @p{cell->has_boundary_lines}), - // since we do not support - // boundaries of dimension dim-2, - // and so every isolated boundary - // line is also part of a boundary - // face which we will be visiting - // sooner or later + // now loop over all cells and + // check whether their faces are at + // the boundary. note that we need + // not take special care of single + // lines being at the boundary + // (using + // @p{cell->has_boundary_lines}), + // since we do not support + // boundaries of dimension dim-2, + // and so every isolated boundary + // line is also part of a boundary + // face which we will be visiting + // sooner or later for (typename DH::active_cell_iterator cell=dof_handler.begin_active(); - cell!=dof_handler.end(); ++cell) + cell!=dof_handler.end(); ++cell) for (unsigned int face=0; - face::faces_per_cell; ++face) - if (cell->at_boundary(face)) - if (! check_boundary_indicator || - (boundary_indicators.find (cell->face(face)->boundary_indicator()) - != boundary_indicators.end())) - { - const FiniteElement &fe = cell->get_fe(); - - const unsigned int dofs_per_face = fe.dofs_per_face; - face_dof_indices.resize (dofs_per_face); - cell->face(face)->get_dof_indices (face_dof_indices, - cell->active_fe_index()); - - for (unsigned int i=0; i::faces_per_cell; ++face) + if (cell->at_boundary(face)) + if (! check_boundary_indicator || + (boundary_indicators.find (cell->face(face)->boundary_indicator()) + != boundary_indicators.end())) + { + const FiniteElement &fe = cell->get_fe(); + + const unsigned int dofs_per_face = fe.dofs_per_face; + face_dof_indices.resize (dofs_per_face); + cell->face(face)->get_dof_indices (face_dof_indices, + cell->active_fe_index()); + + for (unsigned int i=0; i void extract_dofs_with_support_on_boundary (const DH &dof_handler, - const std::vector &component_select, - std::vector &selected_dofs, - const std::set &boundary_indicators) + const std::vector &component_select, + std::vector &selected_dofs, + const std::set &boundary_indicators) { AssertDimension (component_select.size(), n_components(dof_handler)); Assert (boundary_indicators.find (types::internal_face_boundary_id) == boundary_indicators.end(), - ExcInvalidBoundaryIndicator()); + ExcInvalidBoundaryIndicator()); - // let's see whether we have to - // check for certain boundary - // indicators or whether we can - // accept all + // let's see whether we have to + // check for certain boundary + // indicators or whether we can + // accept all const bool check_boundary_indicator = (boundary_indicators.size() != 0); - // also see whether we have to - // check whether a certain vector - // component is selected, or all + // also see whether we have to + // check whether a certain vector + // component is selected, or all const bool check_vector_component = (component_select != std::vector(component_select.size(), - true)); + true)); - // clear and reset array by default - // values + // clear and reset array by default + // values selected_dofs.clear (); selected_dofs.resize (dof_handler.n_dofs(), false); std::vector cell_dof_indices; cell_dof_indices.reserve (max_dofs_per_cell(dof_handler)); - // now loop over all cells and - // check whether their faces are at - // the boundary. note that we need - // not take special care of single - // lines being at the boundary - // (using - // @p{cell->has_boundary_lines}), - // since we do not support - // boundaries of dimension dim-2, - // and so every isolated boundary - // line is also part of a boundary - // face which we will be visiting - // sooner or later + // now loop over all cells and + // check whether their faces are at + // the boundary. note that we need + // not take special care of single + // lines being at the boundary + // (using + // @p{cell->has_boundary_lines}), + // since we do not support + // boundaries of dimension dim-2, + // and so every isolated boundary + // line is also part of a boundary + // face which we will be visiting + // sooner or later for (typename DH::active_cell_iterator cell=dof_handler.begin_active(); - cell!=dof_handler.end(); ++cell) + cell!=dof_handler.end(); ++cell) for (unsigned int face=0; - face::faces_per_cell; ++face) - if (cell->at_boundary(face)) - if (! check_boundary_indicator || - (boundary_indicators.find (cell->face(face)->boundary_indicator()) - != boundary_indicators.end())) - { - const FiniteElement &fe = cell->get_fe(); - - const unsigned int dofs_per_cell = fe.dofs_per_cell; - cell_dof_indices.resize (dofs_per_cell); - cell->get_dof_indices (cell_dof_indices); - - for (unsigned int i=0; i::faces_per_cell; ++face) + if (cell->at_boundary(face)) + if (! check_boundary_indicator || + (boundary_indicators.find (cell->face(face)->boundary_indicator()) + != boundary_indicators.end())) + { + const FiniteElement &fe = cell->get_fe(); + + const unsigned int dofs_per_cell = fe.dofs_per_cell; + cell_dof_indices.resize (dofs_per_cell); + cell->get_dof_indices (cell_dof_indices); + + for (unsigned int i=0; i void extract_hanging_node_dofs (const dealii::DoFHandler<1,spacedim> &dof_handler, - std::vector &selected_dofs) + std::vector &selected_dofs) { - Assert(selected_dofs.size() == dof_handler.n_dofs(), - ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs())); - // preset all values by false - std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false); + Assert(selected_dofs.size() == dof_handler.n_dofs(), + ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs())); + // preset all values by false + std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false); - // there are no hanging nodes in 1d + // there are no hanging nodes in 1d } template void extract_hanging_node_dofs (const dealii::DoFHandler<2,spacedim> &dof_handler, - std::vector &selected_dofs) + std::vector &selected_dofs) { - const unsigned int dim = 2; - - Assert(selected_dofs.size() == dof_handler.n_dofs(), - ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs())); - // preset all values by false - std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false); - - const FiniteElement &fe = dof_handler.get_fe(); - - // this function is similar to the - // make_sparsity_pattern function, - // see there for more information - typename dealii::DoFHandler::active_cell_iterator - cell = dof_handler.begin_active(), - endc = dof_handler.end(); - for (; cell!=endc; ++cell) - for (unsigned int face=0; face::faces_per_cell; ++face) - if (cell->face(face)->has_children()) - { - const typename dealii::DoFHandler::line_iterator - line = cell->face(face); - - for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) - selected_dofs[line->child(0)->vertex_dof_index(1,dof)] = true; - - for (unsigned int child=0; child<2; ++child) - for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof) - selected_dofs[line->child(child)->dof_index(dof)] = true; - } + const unsigned int dim = 2; + + Assert(selected_dofs.size() == dof_handler.n_dofs(), + ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs())); + // preset all values by false + std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false); + + const FiniteElement &fe = dof_handler.get_fe(); + + // this function is similar to the + // make_sparsity_pattern function, + // see there for more information + typename dealii::DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(), + endc = dof_handler.end(); + for (; cell!=endc; ++cell) + for (unsigned int face=0; face::faces_per_cell; ++face) + if (cell->face(face)->has_children()) + { + const typename dealii::DoFHandler::line_iterator + line = cell->face(face); + + for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) + selected_dofs[line->child(0)->vertex_dof_index(1,dof)] = true; + + for (unsigned int child=0; child<2; ++child) + for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof) + selected_dofs[line->child(child)->dof_index(dof)] = true; + } } template void extract_hanging_node_dofs (const dealii::DoFHandler<3,spacedim> &dof_handler, - std::vector &selected_dofs) + std::vector &selected_dofs) { - const unsigned int dim = 3; - - Assert(selected_dofs.size() == dof_handler.n_dofs(), - ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs())); - // preset all values by false - std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false); - - const FiniteElement &fe = dof_handler.get_fe(); - - // this function is similar to the - // make_sparsity_pattern function, - // see there for more information - - typename dealii::DoFHandler::active_cell_iterator - cell = dof_handler.begin_active(), - endc = dof_handler.end(); - for (; cell!=endc; ++cell) - for (unsigned int f=0; f::faces_per_cell; ++f) - if (cell->face(f)->has_children()) - { - const typename dealii::DoFHandler::face_iterator - face = cell->face(f); - - for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) - selected_dofs[face->child(0)->vertex_dof_index(2,dof)] = true; - - // dof numbers on the centers of - // the lines bounding this face - for (unsigned int line=0; line<4; ++line) - for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) - selected_dofs[face->line(line)->child(0)->vertex_dof_index(1,dof)] = true; - - // next the dofs on the lines interior - // to the face; the order of these - // lines is laid down in the - // FiniteElement class documentation - for (unsigned int dof=0; dofchild(0)->line(1)->dof_index(dof)] = true; - for (unsigned int dof=0; dofchild(1)->line(2)->dof_index(dof)] = true; - for (unsigned int dof=0; dofchild(2)->line(3)->dof_index(dof)] = true; - for (unsigned int dof=0; dofchild(3)->line(0)->dof_index(dof)] = true; - - // dofs on the bordering lines - for (unsigned int line=0; line<4; ++line) - for (unsigned int child=0; child<2; ++child) - for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof) - selected_dofs[face->line(line)->child(child)->dof_index(dof)] = true; - - // finally, for the dofs interior - // to the four child faces - for (unsigned int child=0; child<4; ++child) - for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof) - selected_dofs[face->child(child)->dof_index(dof)] = true; - } + const unsigned int dim = 3; + + Assert(selected_dofs.size() == dof_handler.n_dofs(), + ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs())); + // preset all values by false + std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false); + + const FiniteElement &fe = dof_handler.get_fe(); + + // this function is similar to the + // make_sparsity_pattern function, + // see there for more information + + typename dealii::DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(), + endc = dof_handler.end(); + for (; cell!=endc; ++cell) + for (unsigned int f=0; f::faces_per_cell; ++f) + if (cell->face(f)->has_children()) + { + const typename dealii::DoFHandler::face_iterator + face = cell->face(f); + + for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) + selected_dofs[face->child(0)->vertex_dof_index(2,dof)] = true; + + // dof numbers on the centers of + // the lines bounding this face + for (unsigned int line=0; line<4; ++line) + for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof) + selected_dofs[face->line(line)->child(0)->vertex_dof_index(1,dof)] = true; + + // next the dofs on the lines interior + // to the face; the order of these + // lines is laid down in the + // FiniteElement class documentation + for (unsigned int dof=0; dofchild(0)->line(1)->dof_index(dof)] = true; + for (unsigned int dof=0; dofchild(1)->line(2)->dof_index(dof)] = true; + for (unsigned int dof=0; dofchild(2)->line(3)->dof_index(dof)] = true; + for (unsigned int dof=0; dofchild(3)->line(0)->dof_index(dof)] = true; + + // dofs on the bordering lines + for (unsigned int line=0; line<4; ++line) + for (unsigned int child=0; child<2; ++child) + for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof) + selected_dofs[face->line(line)->child(child)->dof_index(dof)] = true; + + // finally, for the dofs interior + // to the four child faces + for (unsigned int child=0; child<4; ++child) + for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof) + selected_dofs[face->child(child)->dof_index(dof)] = true; + } } } } @@ -4096,10 +4096,10 @@ namespace DoFTools void extract_hanging_node_dofs (const DoFHandler &dof_handler, - std::vector &selected_dofs) + std::vector &selected_dofs) { internal::extract_hanging_node_dofs (dof_handler, - selected_dofs); + selected_dofs); } @@ -4107,33 +4107,33 @@ namespace DoFTools template void extract_subdomain_dofs (const DH &dof_handler, - const types::subdomain_id_t subdomain_id, - std::vector &selected_dofs) + const types::subdomain_id_t subdomain_id, + std::vector &selected_dofs) { Assert(selected_dofs.size() == dof_handler.n_dofs(), - ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs())); + ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs())); - // preset all values by false + // preset all values by false std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false); std::vector local_dof_indices; local_dof_indices.reserve (max_dofs_per_cell(dof_handler)); - // this function is similar to the - // make_sparsity_pattern function, - // see there for more information + // this function is similar to the + // make_sparsity_pattern function, + // see there for more information typename DH::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); for (; cell!=endc; ++cell) if (cell->subdomain_id() == subdomain_id) - { - const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; - local_dof_indices.resize (dofs_per_cell); - cell->get_dof_indices (local_dof_indices); - for (unsigned int i=0; iget_fe().dofs_per_cell; + local_dof_indices.resize (dofs_per_cell); + cell->get_dof_indices (local_dof_indices); + for (unsigned int i=0; i void extract_locally_owned_dofs (const DH & dof_handler, - IndexSet & dof_set) + IndexSet & dof_set) { - // collect all the locally owned dofs + // collect all the locally owned dofs dof_set = dof_handler.locally_owned_dofs(); dof_set.compress (); } @@ -4153,34 +4153,34 @@ namespace DoFTools template void extract_locally_active_dofs (const DH & dof_handler, - IndexSet & dof_set) + IndexSet & dof_set) { - // collect all the locally owned dofs + // collect all the locally owned dofs dof_set = dof_handler.locally_owned_dofs(); - // add the DoF on the adjacent ghost cells - // to the IndexSet, cache them in a - // set. need to check each dof manually - // because we can't be sure that the dof - // range of locally_owned_dofs is really - // contiguous. + // add the DoF on the adjacent ghost cells + // to the IndexSet, cache them in a + // set. need to check each dof manually + // because we can't be sure that the dof + // range of locally_owned_dofs is really + // contiguous. std::vector dof_indices; std::set global_dof_indices; typename DH::active_cell_iterator cell = dof_handler.begin_active(), - endc = dof_handler.end(); + endc = dof_handler.end(); for (; cell!=endc; ++cell) if (cell->is_locally_owned()) - { - dof_indices.resize(cell->get_fe().dofs_per_cell); - cell->get_dof_indices(dof_indices); - - for (std::vector::iterator it=dof_indices.begin(); - it!=dof_indices.end(); - ++it) - if (!dof_set.is_element(*it)) - global_dof_indices.insert(*it); - } + { + dof_indices.resize(cell->get_fe().dofs_per_cell); + cell->get_dof_indices(dof_indices); + + for (std::vector::iterator it=dof_indices.begin(); + it!=dof_indices.end(); + ++it) + if (!dof_set.is_element(*it)) + global_dof_indices.insert(*it); + } dof_set.add_indices(global_dof_indices.begin(), global_dof_indices.end()); @@ -4192,34 +4192,34 @@ namespace DoFTools template void extract_locally_relevant_dofs (const DH & dof_handler, - IndexSet & dof_set) + IndexSet & dof_set) { - // collect all the locally owned dofs + // collect all the locally owned dofs dof_set = dof_handler.locally_owned_dofs(); - // add the DoF on the adjacent ghost cells - // to the IndexSet, cache them in a - // set. need to check each dof manually - // because we can't be sure that the dof - // range of locally_owned_dofs is really - // contiguous. + // add the DoF on the adjacent ghost cells + // to the IndexSet, cache them in a + // set. need to check each dof manually + // because we can't be sure that the dof + // range of locally_owned_dofs is really + // contiguous. std::vector dof_indices; std::set global_dof_indices; typename DH::active_cell_iterator cell = dof_handler.begin_active(), - endc = dof_handler.end(); + endc = dof_handler.end(); for (; cell!=endc; ++cell) if (cell->is_ghost()) - { - dof_indices.resize(cell->get_fe().dofs_per_cell); - cell->get_dof_indices(dof_indices); - - for (std::vector::iterator it=dof_indices.begin(); - it!=dof_indices.end(); - ++it) - if (!dof_set.is_element(*it)) - global_dof_indices.insert(*it); - } + { + dof_indices.resize(cell->get_fe().dofs_per_cell); + cell->get_dof_indices(dof_indices); + + for (std::vector::iterator it=dof_indices.begin(); + it!=dof_indices.end(); + ++it) + if (!dof_set.is_element(*it)) + global_dof_indices.insert(*it); + } dof_set.add_indices(global_dof_indices.begin(), global_dof_indices.end()); @@ -4231,33 +4231,33 @@ namespace DoFTools template void extract_constant_modes (const DH &dof_handler, - const std::vector &component_select, - std::vector > &constant_modes) + const std::vector &component_select, + std::vector > &constant_modes) { const unsigned int n_components = dof_handler.get_fe().n_components(); Assert (n_components == component_select.size(), - ExcDimensionMismatch(n_components, - component_select.size())); + ExcDimensionMismatch(n_components, + component_select.size())); std::vector localized_component (n_components, - numbers::invalid_unsigned_int); + numbers::invalid_unsigned_int); unsigned int n_components_selected = 0; for (unsigned int i=0; i dofs_by_component (dof_handler.n_locally_owned_dofs()); internal::extract_dofs_by_component (dof_handler, component_select, false, - dofs_by_component); + dofs_by_component); unsigned int n_selected_dofs = 0; for (unsigned int i=0; i(n_selected_dofs, - false)); + false)); std::vector component_list (n_components, 0); for (unsigned int d=0; d void get_active_fe_indices (const DH &dof_handler, - std::vector &active_fe_indices) + std::vector &active_fe_indices) { AssertDimension (active_fe_indices.size(), dof_handler.get_tria().n_active_cells()); @@ -4292,80 +4292,80 @@ namespace DoFTools template void get_subdomain_association (const DH &dof_handler, - std::vector &subdomain_association) + std::vector &subdomain_association) { - // if the Triangulation is distributed, the - // only thing we can usefully ask is for - // its locally owned subdomain + // if the Triangulation is distributed, the + // only thing we can usefully ask is for + // its locally owned subdomain Assert ((dynamic_cast*> - (&dof_handler.get_tria()) == 0), - ExcMessage ("For parallel::distributed::Triangulation objects and " - "associated DoF handler objects, asking for any subdomain other " - "than the locally owned one does not make sense.")); + Triangulation*> + (&dof_handler.get_tria()) == 0), + ExcMessage ("For parallel::distributed::Triangulation objects and " + "associated DoF handler objects, asking for any subdomain other " + "than the locally owned one does not make sense.")); Assert(subdomain_association.size() == dof_handler.n_dofs(), - ExcDimensionMismatch(subdomain_association.size(), - dof_handler.n_dofs())); + ExcDimensionMismatch(subdomain_association.size(), + dof_handler.n_dofs())); - // preset all values by an invalid value + // preset all values by an invalid value std::fill_n (subdomain_association.begin(), dof_handler.n_dofs(), - types::invalid_subdomain_id); + types::invalid_subdomain_id); std::vector local_dof_indices; local_dof_indices.reserve (max_dofs_per_cell(dof_handler)); - // pseudo-randomly assign variables - // which lie on the interface - // between subdomains to each of - // the two or more + // pseudo-randomly assign variables + // which lie on the interface + // between subdomains to each of + // the two or more bool coin_flip = true; - // loop over all cells and record - // which subdomain a DoF belongs - // to. toss a coin in case it is on - // an interface + // loop over all cells and record + // which subdomain a DoF belongs + // to. toss a coin in case it is on + // an interface typename DH::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); for (; cell!=endc; ++cell) { - Assert (cell->is_artificial() == false, - ExcMessage ("You can't call this function for meshes that " - "have artificial cells.")); - - const types::subdomain_id_t subdomain_id = cell->subdomain_id(); - const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; - local_dof_indices.resize (dofs_per_cell); - cell->get_dof_indices (local_dof_indices); - - // set subdomain ids. if dofs - // already have their values - // set then they must be on - // partition interfaces. in - // that case randomly assign - // them to either the previous - // association or the current - // one, where we take "random" - // to be "once this way once - // that way" - for (unsigned int i=0; iis_artificial() == false, + ExcMessage ("You can't call this function for meshes that " + "have artificial cells.")); + + const types::subdomain_id_t subdomain_id = cell->subdomain_id(); + const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; + local_dof_indices.resize (dofs_per_cell); + cell->get_dof_indices (local_dof_indices); + + // set subdomain ids. if dofs + // already have their values + // set then they must be on + // partition interfaces. in + // that case randomly assign + // them to either the previous + // association or the current + // one, where we take "random" + // to be "once this way once + // that way" + for (unsigned int i=0; i unsigned int count_dofs_with_subdomain_association (const DH &dof_handler, - const types::subdomain_id_t subdomain) + const types::subdomain_id_t subdomain) { std::vector subdomain_association (dof_handler.n_dofs()); get_subdomain_association (dof_handler, subdomain_association); return std::count (subdomain_association.begin(), - subdomain_association.end(), - subdomain); + subdomain_association.end(), + subdomain); } @@ -4388,32 +4388,32 @@ namespace DoFTools template IndexSet dof_indices_with_subdomain_association (const DH &dof_handler, - const types::subdomain_id_t subdomain) + const types::subdomain_id_t subdomain) { - // If we have a distributed::Triangulation only - // allow locally_owned subdomain. + // If we have a distributed::Triangulation only + // allow locally_owned subdomain. Assert ( (dof_handler.get_tria().locally_owned_subdomain() == types::invalid_subdomain_id) || (subdomain == dof_handler.get_tria().locally_owned_subdomain()), ExcMessage ("For parallel::distributed::Triangulation objects and " - "associated DoF handler objects, asking for any subdomain other " - "than the locally owned one does not make sense.")); + "associated DoF handler objects, asking for any subdomain other " + "than the locally owned one does not make sense.")); IndexSet index_set (dof_handler.n_dofs()); std::vector local_dof_indices; local_dof_indices.reserve (max_dofs_per_cell(dof_handler)); - // first generate an unsorted list of all - // indices which we fill from the back. could - // also insert them directly into the - // IndexSet, but that inserts indices in the - // middle, which is an O(n^2) algorithm and - // hence too expensive. Could also use - // std::set, but that is in general more - // expensive than a vector + // first generate an unsorted list of all + // indices which we fill from the back. could + // also insert them directly into the + // IndexSet, but that inserts indices in the + // middle, which is an O(n^2) algorithm and + // hence too expensive. Could also use + // std::set, but that is in general more + // expensive than a vector std::vector subdomain_indices; typename DH::active_cell_iterator @@ -4421,23 +4421,23 @@ namespace DoFTools endc = dof_handler.end(); for (; cell!=endc; ++cell) if ((cell->is_artificial() == false) - && - (cell->subdomain_id() == subdomain)) - { - const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; - local_dof_indices.resize (dofs_per_cell); - cell->get_dof_indices (local_dof_indices); - subdomain_indices.insert(subdomain_indices.end(), - local_dof_indices.begin(), - local_dof_indices.end()); - } - // sort indices and remove duplicates + && + (cell->subdomain_id() == subdomain)) + { + const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; + local_dof_indices.resize (dofs_per_cell); + cell->get_dof_indices (local_dof_indices); + subdomain_indices.insert(subdomain_indices.end(), + local_dof_indices.begin(), + local_dof_indices.end()); + } + // sort indices and remove duplicates std::sort (subdomain_indices.begin(), subdomain_indices.end()); subdomain_indices.erase (std::unique(subdomain_indices.begin(), - subdomain_indices.end()), - subdomain_indices.end()); + subdomain_indices.end()), + subdomain_indices.end()); - // insert into IndexSet + // insert into IndexSet index_set.add_indices (subdomain_indices.begin(), subdomain_indices.end()); index_set.compress (); @@ -4449,30 +4449,30 @@ namespace DoFTools template void count_dofs_with_subdomain_association (const DH &dof_handler, - const types::subdomain_id_t subdomain, - std::vector &n_dofs_on_subdomain) + const types::subdomain_id_t subdomain, + std::vector &n_dofs_on_subdomain) { Assert (n_dofs_on_subdomain.size() == dof_handler.get_fe().n_components(), - ExcDimensionMismatch (n_dofs_on_subdomain.size(), - dof_handler.get_fe().n_components())); + ExcDimensionMismatch (n_dofs_on_subdomain.size(), + dof_handler.get_fe().n_components())); std::fill (n_dofs_on_subdomain.begin(), n_dofs_on_subdomain.end(), 0); - // in debug mode, make sure that there are - // some cells at least with this subdomain - // id + // in debug mode, make sure that there are + // some cells at least with this subdomain + // id #ifdef DEBUG { bool found = false; for (typename Triangulation::active_cell_iterator - cell=dof_handler.get_tria().begin_active(); - cell!=dof_handler.get_tria().end(); ++cell) - if (cell->subdomain_id() == subdomain) - { - found = true; - break; - } + cell=dof_handler.get_tria().begin_active(); + cell!=dof_handler.get_tria().end(); ++cell) + if (cell->subdomain_id() == subdomain) + { + found = true; + break; + } Assert (found == true, - ExcMessage ("There are no cells for the given subdomain!")); + ExcMessage ("There are no cells for the given subdomain!")); } #endif @@ -4481,14 +4481,14 @@ namespace DoFTools std::vector component_association (dof_handler.n_dofs()); internal::extract_dofs_by_component (dof_handler, std::vector(), false, - component_association); + component_association); for (unsigned int c=0; c(c))) - ++n_dofs_on_subdomain[c]; + for (unsigned int i=0; i(c))) + ++n_dofs_on_subdomain[c]; } } @@ -4503,41 +4503,41 @@ namespace DoFTools template void resolve_components (const FiniteElement&fe, - const std::vector &dofs_by_component, - const std::vector &target_component, - const bool only_once, - std::vector &dofs_per_component, - unsigned int &component) + const std::vector &dofs_by_component, + const std::vector &target_component, + const bool only_once, + std::vector &dofs_per_component, + unsigned int &component) { for (unsigned int b=0;b& base = fe.base_element(b); - // Dimension of base element - unsigned int d = base.n_components(); - - for (unsigned int m=0;m 1) - resolve_components(base, dofs_by_component, target_component, - only_once, dofs_per_component, component); - else - { - for (unsigned int dd=0;dd& base = fe.base_element(b); + // Dimension of base element + unsigned int d = base.n_components(); + + for (unsigned int m=0;m 1) + resolve_components(base, dofs_by_component, target_component, + only_once, dofs_per_component, component); + else + { + for (unsigned int dd=0;dd @@ -4614,77 +4614,77 @@ namespace DoFTools std::fill (dofs_per_component.begin(), dofs_per_component.end(), 0U); - // If the empty vector was given as - // default argument, set up this - // vector as identity. + // If the empty vector was given as + // default argument, set up this + // vector as identity. if (target_component.size()==0) { - target_component.resize(n_components); - for (unsigned int i=0; i dofs_by_component (dof_handler.n_locally_owned_dofs()); internal::extract_dofs_by_component (dof_handler, std::vector(), false, - dofs_by_component); + dofs_by_component); - // next count what we got + // next count what we got unsigned int component = 0; internal::resolve_components(dof_handler.get_fe(), dofs_by_component, target_component, - only_once, dofs_per_component, component); + only_once, dofs_per_component, component); Assert (n_components == component, ExcInternalError()); - // finally sanity check. this is - // only valid if the finite element - // is actually primitive, so - // exclude other elements from this + // finally sanity check. this is + // only valid if the finite element + // is actually primitive, so + // exclude other elements from this Assert ((internal::all_elements_are_primitive(dof_handler.get_fe()) == false) - || - (std::accumulate (dofs_per_component.begin(), - dofs_per_component.end(), 0U) - == dof_handler.n_locally_owned_dofs()), - ExcInternalError()); + || + (std::accumulate (dofs_per_component.begin(), + dofs_per_component.end(), 0U) + == dof_handler.n_locally_owned_dofs()), + ExcInternalError()); - // reduce information from all CPUs + // reduce information from all CPUs #if defined(DEAL_II_USE_P4EST) && defined(DEAL_II_COMPILER_SUPPORTS_MPI) const unsigned int dim = DH::dimension; const unsigned int spacedim = DH::space_dimension; if (const parallel::distributed::Triangulation * tria - = (dynamic_cast*> - (&dof_handler.get_tria()))) + = (dynamic_cast*> + (&dof_handler.get_tria()))) { - std::vector local_dof_count = dofs_per_component; + std::vector local_dof_count = dofs_per_component; - MPI_Allreduce ( &local_dof_count[0], &dofs_per_component[0], n_target_components, - MPI_UNSIGNED, MPI_SUM, tria->get_communicator()); + MPI_Allreduce ( &local_dof_count[0], &dofs_per_component[0], n_target_components, + MPI_UNSIGNED, MPI_SUM, tria->get_communicator()); } #endif } @@ -4706,66 +4706,66 @@ namespace DoFTools const FiniteElement& fe = fe_collection[this_fe]; std::fill (dofs_per_block.begin(), dofs_per_block.end(), 0U); - // If the empty vector was given as - // default argument, set up this - // vector as identity. + // If the empty vector was given as + // default argument, set up this + // vector as identity. if (target_block.size()==0) - { + { target_block.resize(fe.n_blocks()); for (unsigned int i=0; i dofs_by_block (dof_handler.n_locally_owned_dofs()); internal::extract_dofs_by_component (dof_handler, std::vector(), - true, dofs_by_block); + true, dofs_by_block); - // next count what we got + // next count what we got for (unsigned int block=0; block * tria - = (dynamic_cast*> - (&dof_handler.get_tria()))) - { + = (dynamic_cast*> + (&dof_handler.get_tria()))) + { std::vector local_dof_count = dofs_per_block; MPI_Allreduce ( &local_dof_count[0], &dofs_per_block[0], n_target_blocks, - MPI_UNSIGNED, MPI_SUM, tria->get_communicator()); - } + MPI_UNSIGNED, MPI_SUM, tria->get_communicator()); + } #endif #endif } @@ -4776,11 +4776,11 @@ namespace DoFTools template void count_dofs_per_component (const DoFHandler &dof_handler, - std::vector &dofs_per_component, - std::vector target_component) + std::vector &dofs_per_component, + std::vector target_component) { count_dofs_per_component (dof_handler, dofs_per_component, - false, target_component); + false, target_component); } @@ -4790,325 +4790,325 @@ namespace DoFTools { namespace { - /** - * This is a function that is - * called by the _2 function and - * that operates on a range of - * cells only. It is used to - * split up the whole range of - * cells into chunks which are - * then worked on in parallel, if - * multithreading is available. - */ + /** + * This is a function that is + * called by the _2 function and + * that operates on a range of + * cells only. It is used to + * split up the whole range of + * cells into chunks which are + * then worked on in parallel, if + * multithreading is available. + */ template void compute_intergrid_weights_3 ( - const dealii::DoFHandler &coarse_grid, - const unsigned int coarse_component, - const InterGridMap > &coarse_to_fine_grid_map, - const std::vector > ¶meter_dofs, - const std::vector &weight_mapping, - std::vector > &weights, - const typename dealii::DoFHandler::active_cell_iterator &begin, - const typename dealii::DoFHandler::active_cell_iterator &end) + const dealii::DoFHandler &coarse_grid, + const unsigned int coarse_component, + const InterGridMap > &coarse_to_fine_grid_map, + const std::vector > ¶meter_dofs, + const std::vector &weight_mapping, + std::vector > &weights, + const typename dealii::DoFHandler::active_cell_iterator &begin, + const typename dealii::DoFHandler::active_cell_iterator &end) { - // aliases to the finite elements - // used by the dof handlers: - const FiniteElement &coarse_fe = coarse_grid.get_fe(); - - // for each cell on the parameter grid: - // find out which degrees of freedom on the - // fine grid correspond in which way to - // the degrees of freedom on the parameter - // grid - // - // since for continuous FEs some - // dofs exist on more than one - // cell, we have to track which - // ones were already visited. the - // problem is that if we visit a - // dof first on one cell and - // compute its weight with respect - // to some global dofs to be - // non-zero, and later visit the - // dof again on another cell and - // (since we are on another cell) - // recompute the weights with - // respect to the same dofs as - // above to be zero now, we have to - // preserve them. we therefore - // overwrite all weights if they - // are nonzero and do not enforce - // zero weights since that might be - // only due to the fact that we are - // on another cell. - // - // example: - // coarse grid - // | | | - // *-----*-----* - // | cell|cell | - // | 1 | 2 | - // | | | - // 0-----1-----* - // - // fine grid - // | | | | | - // *--*--*--*--* - // | | | | | - // *--*--*--*--* - // | | | | | - // *--x--y--*--* - // - // when on cell 1, we compute the - // weights of dof 'x' to be 1/2 - // from parameter dofs 0 and 1, - // respectively. however, when - // later we are on cell 2, we again - // compute the prolongation of - // shape function 1 restricted to - // cell 2 to the globla grid and - // find that the weight of global - // dof 'x' now is zero. however, we - // should not overwrite the old - // value. - // - // we therefore always only set - // nonzero values. why adding up is - // not useful: dof 'y' would get - // weight 1 from parameter dof 1 on - // both cells 1 and 2, but the - // correct weight is nevertheless - // only 1. - - // vector to hold the representation of - // a single degree of freedom on the - // coarse grid (for the selected fe) - // on the fine grid - const unsigned int n_fine_dofs = weight_mapping.size(); - dealii::Vector global_parameter_representation (n_fine_dofs); - - typename dealii::DoFHandler::active_cell_iterator cell; - std::vector parameter_dof_indices (coarse_fe.dofs_per_cell); - - for (cell=begin; cell!=end; ++cell) - { - // get the global indices of the - // parameter dofs on this parameter - // grid cell - cell->get_dof_indices (parameter_dof_indices); - - // loop over all dofs on this - // cell and check whether they - // are interesting for us - for (unsigned int local_dof=0; - local_dof - set_dof_values_by_interpolation (parameter_dofs[local_parameter_dof], - global_parameter_representation); - // now that we've got the global - // representation of each parameter - // dof, we've only got to clobber the - // non-zero entries in that vector and - // store the result - // - // what we have learned: if entry @p{i} - // of the global vector holds the value - // @p{v[i]}, then this is the weight with - // which the present dof contributes - // to @p{i}. there may be several such - // @p{i}s and their weights' sum should - // be one. Then, @p{v[i]} should be - // equal to @p{\sum_j w_{ij} p[j]} with - // @p{p[j]} be the values of the degrees - // of freedom on the coarse grid. we - // can thus compute constraints which - // link the degrees of freedom @p{v[i]} - // on the fine grid to those on the - // coarse grid, @p{p[j]}. Now to use - // these as real constraints, rather - // than as additional equations, we - // have to identify representants - // among the @p{i} for each @p{j}. this will - // be done by simply taking the first - // @p{i} for which @p{w_{ij}==1}. - // - // guard modification of - // the weights array by a - // Mutex. since it should - // happen rather rarely - // that there are several - // threads operating on - // different intergrid - // weights, have only one - // mutex for all of them - static Threads::ThreadMutex mutex; - Threads::ThreadMutex::ScopedLock lock (mutex); - for (unsigned int i=0; i &coarse_fe = coarse_grid.get_fe(); + + // for each cell on the parameter grid: + // find out which degrees of freedom on the + // fine grid correspond in which way to + // the degrees of freedom on the parameter + // grid + // + // since for continuous FEs some + // dofs exist on more than one + // cell, we have to track which + // ones were already visited. the + // problem is that if we visit a + // dof first on one cell and + // compute its weight with respect + // to some global dofs to be + // non-zero, and later visit the + // dof again on another cell and + // (since we are on another cell) + // recompute the weights with + // respect to the same dofs as + // above to be zero now, we have to + // preserve them. we therefore + // overwrite all weights if they + // are nonzero and do not enforce + // zero weights since that might be + // only due to the fact that we are + // on another cell. + // + // example: + // coarse grid + // | | | + // *-----*-----* + // | cell|cell | + // | 1 | 2 | + // | | | + // 0-----1-----* + // + // fine grid + // | | | | | + // *--*--*--*--* + // | | | | | + // *--*--*--*--* + // | | | | | + // *--x--y--*--* + // + // when on cell 1, we compute the + // weights of dof 'x' to be 1/2 + // from parameter dofs 0 and 1, + // respectively. however, when + // later we are on cell 2, we again + // compute the prolongation of + // shape function 1 restricted to + // cell 2 to the globla grid and + // find that the weight of global + // dof 'x' now is zero. however, we + // should not overwrite the old + // value. + // + // we therefore always only set + // nonzero values. why adding up is + // not useful: dof 'y' would get + // weight 1 from parameter dof 1 on + // both cells 1 and 2, but the + // correct weight is nevertheless + // only 1. + + // vector to hold the representation of + // a single degree of freedom on the + // coarse grid (for the selected fe) + // on the fine grid + const unsigned int n_fine_dofs = weight_mapping.size(); + dealii::Vector global_parameter_representation (n_fine_dofs); + + typename dealii::DoFHandler::active_cell_iterator cell; + std::vector parameter_dof_indices (coarse_fe.dofs_per_cell); + + for (cell=begin; cell!=end; ++cell) + { + // get the global indices of the + // parameter dofs on this parameter + // grid cell + cell->get_dof_indices (parameter_dof_indices); + + // loop over all dofs on this + // cell and check whether they + // are interesting for us + for (unsigned int local_dof=0; + local_dof + set_dof_values_by_interpolation (parameter_dofs[local_parameter_dof], + global_parameter_representation); + // now that we've got the global + // representation of each parameter + // dof, we've only got to clobber the + // non-zero entries in that vector and + // store the result + // + // what we have learned: if entry @p{i} + // of the global vector holds the value + // @p{v[i]}, then this is the weight with + // which the present dof contributes + // to @p{i}. there may be several such + // @p{i}s and their weights' sum should + // be one. Then, @p{v[i]} should be + // equal to @p{\sum_j w_{ij} p[j]} with + // @p{p[j]} be the values of the degrees + // of freedom on the coarse grid. we + // can thus compute constraints which + // link the degrees of freedom @p{v[i]} + // on the fine grid to those on the + // coarse grid, @p{p[j]}. Now to use + // these as real constraints, rather + // than as additional equations, we + // have to identify representants + // among the @p{i} for each @p{j}. this will + // be done by simply taking the first + // @p{i} for which @p{w_{ij}==1}. + // + // guard modification of + // the weights array by a + // Mutex. since it should + // happen rather rarely + // that there are several + // threads operating on + // different intergrid + // weights, have only one + // mutex for all of them + static Threads::ThreadMutex mutex; + Threads::ThreadMutex::ScopedLock lock (mutex); + for (unsigned int i=0; i void compute_intergrid_weights_2 ( - const dealii::DoFHandler &coarse_grid, - const unsigned int coarse_component, - const InterGridMap > &coarse_to_fine_grid_map, - const std::vector > ¶meter_dofs, - const std::vector &weight_mapping, - std::vector > &weights) + const dealii::DoFHandler &coarse_grid, + const unsigned int coarse_component, + const InterGridMap > &coarse_to_fine_grid_map, + const std::vector > ¶meter_dofs, + const std::vector &weight_mapping, + std::vector > &weights) { - // simply distribute the range of - // cells to different threads - typedef typename dealii::DoFHandler::active_cell_iterator active_cell_iterator; - std::vector > - cell_intervals = Threads::split_range (coarse_grid.begin_active(), - coarse_grid.end(), - multithread_info.n_default_threads); + // simply distribute the range of + // cells to different threads + typedef typename dealii::DoFHandler::active_cell_iterator active_cell_iterator; + std::vector > + cell_intervals = Threads::split_range (coarse_grid.begin_active(), + coarse_grid.end(), + multithread_info.n_default_threads); //TODO: use WorkStream here - Threads::TaskGroup<> tasks; - void (*fun_ptr) (const dealii::DoFHandler &, - const unsigned int , - const InterGridMap > &, - const std::vector > &, - const std::vector &, - std::vector > &, - const typename dealii::DoFHandler::active_cell_iterator &, - const typename dealii::DoFHandler::active_cell_iterator &) - = &compute_intergrid_weights_3; - for (unsigned int i=0; i tasks; + void (*fun_ptr) (const dealii::DoFHandler &, + const unsigned int , + const InterGridMap > &, + const std::vector > &, + const std::vector &, + std::vector > &, + const typename dealii::DoFHandler::active_cell_iterator &, + const typename dealii::DoFHandler::active_cell_iterator &) + = &compute_intergrid_weights_3; + for (unsigned int i=0; i unsigned int compute_intergrid_weights_1 ( - const dealii::DoFHandler &coarse_grid, - const unsigned int coarse_component, - const dealii::DoFHandler &fine_grid, - const unsigned int fine_component, - const InterGridMap > &coarse_to_fine_grid_map, - std::vector > &weights, - std::vector &weight_mapping) + const dealii::DoFHandler &coarse_grid, + const unsigned int coarse_component, + const dealii::DoFHandler &fine_grid, + const unsigned int fine_component, + const InterGridMap > &coarse_to_fine_grid_map, + std::vector > &weights, + std::vector &weight_mapping) { - // aliases to the finite elements - // used by the dof handlers: - const FiniteElement &coarse_fe = coarse_grid.get_fe(), - &fine_fe = fine_grid.get_fe(); - - // global numbers of dofs - const unsigned int n_coarse_dofs = coarse_grid.n_dofs(), - n_fine_dofs = fine_grid.n_dofs(); - - // local numbers of dofs - const unsigned int fine_dofs_per_cell = fine_fe.dofs_per_cell; - - // alias the number of dofs per - // cell belonging to the - // coarse_component which is to be - // the restriction of the fine - // grid: - const unsigned int coarse_dofs_per_cell_component - = coarse_fe.base_element(coarse_fe.component_to_base_index(coarse_component).first).dofs_per_cell; - - - // Try to find out whether the - // grids stem from the same coarse - // grid. This is a rather crude - // test, but better than nothing - Assert (coarse_grid.get_tria().n_cells(0) == fine_grid.get_tria().n_cells(0), - ExcGridsDontMatch()); - - // check whether the map correlates - // the right objects - Assert (&coarse_to_fine_grid_map.get_source_grid() == &coarse_grid, - ExcGridsDontMatch ()); - Assert (&coarse_to_fine_grid_map.get_destination_grid() == &fine_grid, - ExcGridsDontMatch ()); - - - // check whether component numbers - // are valid - AssertIndexRange (coarse_component,coarse_fe.n_components()); - AssertIndexRange (fine_component, fine_fe.n_components()); - // check whether respective finite - // elements are equal - Assert (coarse_fe.base_element (coarse_fe.component_to_base_index(coarse_component).first) - == - fine_fe.base_element (fine_fe.component_to_base_index(fine_component).first), - ExcFiniteElementsDontMatch()); + // aliases to the finite elements + // used by the dof handlers: + const FiniteElement &coarse_fe = coarse_grid.get_fe(), + &fine_fe = fine_grid.get_fe(); + + // global numbers of dofs + const unsigned int n_coarse_dofs = coarse_grid.n_dofs(), + n_fine_dofs = fine_grid.n_dofs(); + + // local numbers of dofs + const unsigned int fine_dofs_per_cell = fine_fe.dofs_per_cell; + + // alias the number of dofs per + // cell belonging to the + // coarse_component which is to be + // the restriction of the fine + // grid: + const unsigned int coarse_dofs_per_cell_component + = coarse_fe.base_element(coarse_fe.component_to_base_index(coarse_component).first).dofs_per_cell; + + + // Try to find out whether the + // grids stem from the same coarse + // grid. This is a rather crude + // test, but better than nothing + Assert (coarse_grid.get_tria().n_cells(0) == fine_grid.get_tria().n_cells(0), + ExcGridsDontMatch()); + + // check whether the map correlates + // the right objects + Assert (&coarse_to_fine_grid_map.get_source_grid() == &coarse_grid, + ExcGridsDontMatch ()); + Assert (&coarse_to_fine_grid_map.get_destination_grid() == &fine_grid, + ExcGridsDontMatch ()); + + + // check whether component numbers + // are valid + AssertIndexRange (coarse_component,coarse_fe.n_components()); + AssertIndexRange (fine_component, fine_fe.n_components()); + // check whether respective finite + // elements are equal + Assert (coarse_fe.base_element (coarse_fe.component_to_base_index(coarse_component).first) + == + fine_fe.base_element (fine_fe.component_to_base_index(fine_component).first), + ExcFiniteElementsDontMatch()); #ifdef DEBUG - // if in debug mode, check whether - // the coarse grid is indeed - // coarser everywhere than the fine - // grid - for (typename dealii::DoFHandler::active_cell_iterator - cell=coarse_grid.begin_active(); - cell != coarse_grid.end(); ++cell) - Assert (cell->level() <= coarse_to_fine_grid_map[cell]->level(), - ExcGridNotCoarser()); + // if in debug mode, check whether + // the coarse grid is indeed + // coarser everywhere than the fine + // grid + for (typename dealii::DoFHandler::active_cell_iterator + cell=coarse_grid.begin_active(); + cell != coarse_grid.end(); ++cell) + Assert (cell->level() <= coarse_to_fine_grid_map[cell]->level(), + ExcGridNotCoarser()); #endif @@ -5132,148 +5132,148 @@ namespace DoFTools - // set up vectors of cell-local - // data; each vector represents one - // degree of freedom of the - // coarse-grid variable in the - // fine-grid element - std::vector > - parameter_dofs (coarse_dofs_per_cell_component, - dealii::Vector(fine_dofs_per_cell)); - // for each coarse dof: find its - // position within the fine element - // and set this value to one in the - // respective vector (all other values - // are zero by construction) - for (unsigned int local_coarse_dof=0; - local_coarse_dof dof_is_interesting (fine_grid.n_dofs(), false); - std::vector local_dof_indices (fine_fe.dofs_per_cell); - - for (typename dealii::DoFHandler::active_cell_iterator - cell=fine_grid.begin_active(); - cell!=fine_grid.end(); ++cell) - { - cell->get_dof_indices (local_dof_indices); - for (unsigned int i=0; i local_dof_indices(fine_fe.dofs_per_cell); - unsigned int next_free_index=0; - for (typename dealii::DoFHandler::active_cell_iterator - cell=fine_grid.begin_active(); - cell != fine_grid.end(); ++cell) - { - cell->get_dof_indices (local_dof_indices); - for (unsigned int i=0; i > + parameter_dofs (coarse_dofs_per_cell_component, + dealii::Vector(fine_dofs_per_cell)); + // for each coarse dof: find its + // position within the fine element + // and set this value to one in the + // respective vector (all other values + // are zero by construction) + for (unsigned int local_coarse_dof=0; + local_coarse_dof dof_is_interesting (fine_grid.n_dofs(), false); + std::vector local_dof_indices (fine_fe.dofs_per_cell); + + for (typename dealii::DoFHandler::active_cell_iterator + cell=fine_grid.begin_active(); + cell!=fine_grid.end(); ++cell) + { + cell->get_dof_indices (local_dof_indices); + for (unsigned int i=0; i local_dof_indices(fine_fe.dofs_per_cell); + unsigned int next_free_index=0; + for (typename dealii::DoFHandler::active_cell_iterator + cell=fine_grid.begin_active(); + cell != fine_grid.end(); ++cell) + { + cell->get_dof_indices (local_dof_indices); + for (unsigned int i=0; i1) && (sum==0)), ExcInternalError()); - }; + for (unsigned int col=0; col1) && (sum==0)), ExcInternalError()); + }; #endif - return n_parameters_on_fine_grid; + return n_parameters_on_fine_grid; } @@ -5292,217 +5292,217 @@ namespace DoFTools const InterGridMap > &coarse_to_fine_grid_map, ConstraintMatrix &constraints) { - // store the weights with which a dof - // on the parameter grid contributes - // to a dof on the fine grid. see the - // long doc below for more info - // - // allocate as many rows as there are - // parameter dofs on the coarse grid - // and as many columns as there are - // parameter dofs on the fine grid. - // - // weight_mapping is used to map the - // global (fine grid) parameter dof - // indices to the columns - // - // in the original implementation, - // the weights array was actually - // of FullMatrix type. this - // wasted huge amounts of memory, - // but was fast. nonetheless, since - // the memory consumption was - // quadratic in the number of - // degrees of freedom, this was not - // very practical, so we now use a - // vector of rows of the matrix, - // and in each row a vector of - // pairs (colnum,value). this seems - // like the best tradeoff between - // memory and speed, as it is now - // linear in memory and still fast - // enough. - // - // to save some memory and since - // the weights are usually - // (negative) powers of 2, we - // choose the value type of the - // matrix to be @p{float} rather - // than @p{double}. + // store the weights with which a dof + // on the parameter grid contributes + // to a dof on the fine grid. see the + // long doc below for more info + // + // allocate as many rows as there are + // parameter dofs on the coarse grid + // and as many columns as there are + // parameter dofs on the fine grid. + // + // weight_mapping is used to map the + // global (fine grid) parameter dof + // indices to the columns + // + // in the original implementation, + // the weights array was actually + // of FullMatrix type. this + // wasted huge amounts of memory, + // but was fast. nonetheless, since + // the memory consumption was + // quadratic in the number of + // degrees of freedom, this was not + // very practical, so we now use a + // vector of rows of the matrix, + // and in each row a vector of + // pairs (colnum,value). this seems + // like the best tradeoff between + // memory and speed, as it is now + // linear in memory and still fast + // enough. + // + // to save some memory and since + // the weights are usually + // (negative) powers of 2, we + // choose the value type of the + // matrix to be @p{float} rather + // than @p{double}. std::vector > weights; - // this is this mapping. there is one - // entry for each dof on the fine grid; - // if it is a parameter dof, then its - // value is the column in weights for - // that parameter dof, if it is any - // other dof, then its value is -1, - // indicating an error + // this is this mapping. there is one + // entry for each dof on the fine grid; + // if it is a parameter dof, then its + // value is the column in weights for + // that parameter dof, if it is any + // other dof, then its value is -1, + // indicating an error std::vector weight_mapping; const unsigned int n_parameters_on_fine_grid = internal::compute_intergrid_weights_1 (coarse_grid, coarse_component, - fine_grid, fine_component, - coarse_to_fine_grid_map, - weights, weight_mapping); + fine_grid, fine_component, + coarse_to_fine_grid_map, + weights, weight_mapping); - // global numbers of dofs + // global numbers of dofs const unsigned int n_coarse_dofs = coarse_grid.n_dofs(), - n_fine_dofs = fine_grid.n_dofs(); + n_fine_dofs = fine_grid.n_dofs(); - // get an array in which we store - // which dof on the coarse grid is - // a parameter and which is not + // get an array in which we store + // which dof on the coarse grid is + // a parameter and which is not std::vector coarse_dof_is_parameter (coarse_grid.n_dofs()); if (true) { - std::vector mask (coarse_grid.get_fe().n_components(), - false); - mask[coarse_component] = true; - extract_dofs (coarse_grid, mask, coarse_dof_is_parameter); + std::vector mask (coarse_grid.get_fe().n_components(), + false); + mask[coarse_component] = true; + extract_dofs (coarse_grid, mask, coarse_dof_is_parameter); }; - // now we know that the weights in - // each row constitute a - // constraint. enter this into the - // constraints object - // - // first task: for each parameter - // dof on the parameter grid, find - // a representant on the fine, - // global grid. this is possible - // since we use conforming finite - // element. we take this - // representant to be the first - // element in this row with weight - // identical to one. the - // representant will become an - // unconstrained degree of freedom, - // while all others will be - // constrained to this dof (and - // possibly others) + // now we know that the weights in + // each row constitute a + // constraint. enter this into the + // constraints object + // + // first task: for each parameter + // dof on the parameter grid, find + // a representant on the fine, + // global grid. this is possible + // since we use conforming finite + // element. we take this + // representant to be the first + // element in this row with weight + // identical to one. the + // representant will become an + // unconstrained degree of freedom, + // while all others will be + // constrained to this dof (and + // possibly others) std::vector representants(n_coarse_dofs, -1); for (unsigned int parameter_dof=0; parameter_dof 0, ExcInternalError()); - - // find the column where the - // representant is mentioned - std::map::const_iterator i = weights[parameter_dof].begin(); - for (; i!=weights[parameter_dof].end(); ++i) - if (i->second == 1) - break; - Assert (i!=weights[parameter_dof].end(), ExcInternalError()); - const unsigned int column = i->first; - - // now we know in which column of - // weights the representant is, but - // we don't know its global index. get - // it using the inverse operation of - // the weight_mapping - unsigned int global_dof=0; - for (; global_dof(column)) - break; - Assert (global_dof < weight_mapping.size(), ExcInternalError()); - - // now enter the representants global - // index into our list - representants[parameter_dof] = global_dof; - } + { + // if this is the line of a + // parameter dof on the + // coarse grid, then it + // should have at least one + // dependent node on the fine + // grid + Assert (weights[parameter_dof].size() > 0, ExcInternalError()); + + // find the column where the + // representant is mentioned + std::map::const_iterator i = weights[parameter_dof].begin(); + for (; i!=weights[parameter_dof].end(); ++i) + if (i->second == 1) + break; + Assert (i!=weights[parameter_dof].end(), ExcInternalError()); + const unsigned int column = i->first; + + // now we know in which column of + // weights the representant is, but + // we don't know its global index. get + // it using the inverse operation of + // the weight_mapping + unsigned int global_dof=0; + for (; global_dof(column)) + break; + Assert (global_dof < weight_mapping.size(), ExcInternalError()); + + // now enter the representants global + // index into our list + representants[parameter_dof] = global_dof; + } else - { - // consistency check: if this - // is no parameter dof on the - // coarse grid, then the - // respective row must be - // empty! - Assert (weights[parameter_dof].size() == 0, ExcInternalError()); - }; - - - - // note for people that want to - // optimize this function: the - // largest part of the computing - // time is spent in the following, - // rather innocent block of - // code. basically, it must be the - // ConstraintMatrix::add_entry call - // which takes the bulk of the - // time, but it is not known to the - // author how to make it faster... + { + // consistency check: if this + // is no parameter dof on the + // coarse grid, then the + // respective row must be + // empty! + Assert (weights[parameter_dof].size() == 0, ExcInternalError()); + }; + + + + // note for people that want to + // optimize this function: the + // largest part of the computing + // time is spent in the following, + // rather innocent block of + // code. basically, it must be the + // ConstraintMatrix::add_entry call + // which takes the bulk of the + // time, but it is not known to the + // author how to make it faster... std::vector > constraint_line; for (unsigned int global_dof=0; global_dof 0, ExcInternalError()); - std::map::const_iterator - col_entry = weights[0].end(); - for (; first_used_rowsecond == 1) && - (representants[first_used_row] == static_cast(global_dof))) - // dof unconstrained or - // constrained to itself - // (in case this cell is - // mapped to itself, rather - // than to children of - // itself) - continue; - } - - - // otherwise enter all constraints - constraints.add_line (global_dof); - - constraint_line.clear (); - for (unsigned int row=first_used_row; row::const_iterator - j = weights[row].find(col); - if ((j != weights[row].end()) && (j->second != 0)) - constraint_line.push_back (std::make_pair(representants[row], - j->second)); - }; - - constraints.add_entries (global_dof, constraint_line); - }; + // this global dof is a parameter + // dof, so it may carry a constraint + // note that for each global dof, + // the sum of weights shall be one, + // so we can find out whether this + // dof is constrained in the following + // way: if the only weight in this row + // is a one, and the representant for + // the parameter dof of the line in + // which this one is is the present + // dof, then we consider this dof + // to be unconstrained. otherwise, + // all other dofs are constrained + { + const unsigned int col = weight_mapping[global_dof]; + Assert (col < n_parameters_on_fine_grid, ExcInternalError()); + + unsigned int first_used_row=0; + + { + Assert (weights.size() > 0, ExcInternalError()); + std::map::const_iterator + col_entry = weights[0].end(); + for (; first_used_rowsecond == 1) && + (representants[first_used_row] == static_cast(global_dof))) + // dof unconstrained or + // constrained to itself + // (in case this cell is + // mapped to itself, rather + // than to children of + // itself) + continue; + } + + + // otherwise enter all constraints + constraints.add_line (global_dof); + + constraint_line.clear (); + for (unsigned int row=first_used_row; row::const_iterator + j = weights[row].find(col); + if ((j != weights[row].end()) && (j->second != 0)) + constraint_line.push_back (std::make_pair(representants[row], + j->second)); + }; + + constraints.add_entries (global_dof, constraint_line); + }; } @@ -5517,87 +5517,87 @@ namespace DoFTools const InterGridMap > &coarse_to_fine_grid_map, std::vector > &transfer_representation) { - // store the weights with which a dof - // on the parameter grid contributes - // to a dof on the fine grid. see the - // long doc below for more info - // - // allocate as many rows as there are - // parameter dofs on the coarse grid - // and as many columns as there are - // parameter dofs on the fine grid. - // - // weight_mapping is used to map the - // global (fine grid) parameter dof - // indices to the columns - // - // in the original implementation, - // the weights array was actually - // of FullMatrix type. this - // wasted huge amounts of memory, - // but was fast. nonetheless, since - // the memory consumption was - // quadratic in the number of - // degrees of freedom, this was not - // very practical, so we now use a - // vector of rows of the matrix, - // and in each row a vector of - // pairs (colnum,value). this seems - // like the best tradeoff between - // memory and speed, as it is now - // linear in memory and still fast - // enough. - // - // to save some memory and since - // the weights are usually - // (negative) powers of 2, we - // choose the value type of the - // matrix to be @p{float} rather - // than @p{double}. + // store the weights with which a dof + // on the parameter grid contributes + // to a dof on the fine grid. see the + // long doc below for more info + // + // allocate as many rows as there are + // parameter dofs on the coarse grid + // and as many columns as there are + // parameter dofs on the fine grid. + // + // weight_mapping is used to map the + // global (fine grid) parameter dof + // indices to the columns + // + // in the original implementation, + // the weights array was actually + // of FullMatrix type. this + // wasted huge amounts of memory, + // but was fast. nonetheless, since + // the memory consumption was + // quadratic in the number of + // degrees of freedom, this was not + // very practical, so we now use a + // vector of rows of the matrix, + // and in each row a vector of + // pairs (colnum,value). this seems + // like the best tradeoff between + // memory and speed, as it is now + // linear in memory and still fast + // enough. + // + // to save some memory and since + // the weights are usually + // (negative) powers of 2, we + // choose the value type of the + // matrix to be @p{float} rather + // than @p{double}. std::vector > weights; - // this is this mapping. there is one - // entry for each dof on the fine grid; - // if it is a parameter dof, then its - // value is the column in weights for - // that parameter dof, if it is any - // other dof, then its value is -1, - // indicating an error + // this is this mapping. there is one + // entry for each dof on the fine grid; + // if it is a parameter dof, then its + // value is the column in weights for + // that parameter dof, if it is any + // other dof, then its value is -1, + // indicating an error std::vector weight_mapping; internal::compute_intergrid_weights_1 (coarse_grid, coarse_component, - fine_grid, fine_component, - coarse_to_fine_grid_map, - weights, weight_mapping); + fine_grid, fine_component, + coarse_to_fine_grid_map, + weights, weight_mapping); - // now compute the requested - // representation + // now compute the requested + // representation const unsigned int n_global_parm_dofs = std::count_if (weight_mapping.begin(), weight_mapping.end(), - std::bind2nd (std::not_equal_to (), -1)); + std::bind2nd (std::not_equal_to (), -1)); - // first construct the inverse - // mapping of weight_mapping + // first construct the inverse + // mapping of weight_mapping std::vector inverse_weight_mapping (n_global_parm_dofs, - DoFHandler::invalid_dof_index); + DoFHandler::invalid_dof_index); for (unsigned int i=0; i::invalid_dof_index), - ExcInternalError()); - - inverse_weight_mapping[parameter_dof] = i; - }; + const unsigned int parameter_dof = weight_mapping[i]; + // if this global dof is a + // parameter + if (parameter_dof != numbers::invalid_unsigned_int) + { + Assert (parameter_dof < n_global_parm_dofs, ExcInternalError()); + Assert ((inverse_weight_mapping[parameter_dof] == DoFHandler::invalid_dof_index), + ExcInternalError()); + + inverse_weight_mapping[parameter_dof] = i; + }; }; - // next copy over weights array - // and replace respective - // numbers + // next copy over weights array + // and replace respective + // numbers const unsigned int n_rows = weight_mapping.size(); transfer_representation.clear (); @@ -5606,14 +5606,14 @@ namespace DoFTools const unsigned int n_coarse_dofs = coarse_grid.n_dofs(); for (unsigned int i=0; i::const_iterator j = weights[i].begin(); - for (; j!=weights[i].end(); ++j) - { - const unsigned int p = inverse_weight_mapping[j->first]; - Assert (psecond; - }; + std::map::const_iterator j = weights[i].begin(); + for (; j!=weights[i].end(); ++j) + { + const unsigned int p = inverse_weight_mapping[j->first]; + Assert (psecond; + }; }; } @@ -5622,45 +5622,45 @@ namespace DoFTools template void map_dof_to_boundary_indices (const DH &dof_handler, - std::vector &mapping) + std::vector &mapping) { Assert (&dof_handler.get_fe() != 0, ExcNoFESelected()); mapping.clear (); mapping.insert (mapping.end(), dof_handler.n_dofs(), - DH::invalid_dof_index); + DH::invalid_dof_index); std::vector dofs_on_face; dofs_on_face.reserve (max_dofs_per_face(dof_handler)); unsigned int next_boundary_index = 0; - // now loop over all cells and - // check whether their faces are at - // the boundary. note that we need - // not take special care of single - // lines being at the boundary - // (using - // @p{cell->has_boundary_lines}), - // since we do not support - // boundaries of dimension dim-2, - // and so every isolated boundary - // line is also part of a boundary - // face which we will be visiting - // sooner or later + // now loop over all cells and + // check whether their faces are at + // the boundary. note that we need + // not take special care of single + // lines being at the boundary + // (using + // @p{cell->has_boundary_lines}), + // since we do not support + // boundaries of dimension dim-2, + // and so every isolated boundary + // line is also part of a boundary + // face which we will be visiting + // sooner or later typename DH::active_cell_iterator cell = dof_handler.begin_active(), - endc = dof_handler.end(); + endc = dof_handler.end(); for (; cell!=endc; ++cell) for (unsigned int f=0; f::faces_per_cell; ++f) - if (cell->at_boundary(f)) - { - const unsigned int dofs_per_face = cell->get_fe().dofs_per_face; - dofs_on_face.resize (dofs_per_face); - cell->face(f)->get_dof_indices (dofs_on_face, - cell->active_fe_index()); - for (unsigned int i=0; iat_boundary(f)) + { + const unsigned int dofs_per_face = cell->get_fe().dofs_per_face; + dofs_on_face.resize (dofs_per_face); + cell->face(f)->get_dof_indices (dofs_on_face, + cell->active_fe_index()); + for (unsigned int i=0; i::faces_per_cell; ++f) - if (boundary_indicators.find (cell->face(f)->boundary_indicator()) != - boundary_indicators.end()) - { - const unsigned int dofs_per_face = cell->get_fe().dofs_per_face; - dofs_on_face.resize (dofs_per_face); - cell->face(f)->get_dof_indices (dofs_on_face, cell->active_fe_index()); - for (unsigned int i=0; iface(f)->boundary_indicator()) != + boundary_indicators.end()) + { + const unsigned int dofs_per_face = cell->get_fe().dofs_per_face; + dofs_on_face.resize (dofs_per_face); + cell->face(f)->get_dof_indices (dofs_on_face, cell->active_fe_index()); + for (unsigned int i=0; i& fe = fe_collection[f]; - - const unsigned int nb = fe.n_blocks(); - tables_by_block[f].reinit(nb, nb); - tables_by_block[f].fill(none); - for (unsigned int i=0;i& fe = fe_collection[f]; + + const unsigned int nb = fe.n_blocks(); + tables_by_block[f].reinit(nb, nb); + tables_by_block[f].fill(none); + for (unsigned int i=0;i class DH> void make_zero_boundary_constraints (const DH &dof, - ConstraintMatrix &zero_boundary_constraints, - const std::vector &component_mask_) + ConstraintMatrix &zero_boundary_constraints, + const std::vector &component_mask_) { Assert ((component_mask_.size() == 0) || - (component_mask_.size() == dof.get_fe().n_components()), - ExcMessage ("The number of components in the mask has to be either " - "zero or equal to the number of components in the finite " - "element.")); + (component_mask_.size() == dof.get_fe().n_components()), + ExcMessage ("The number of components in the mask has to be either " + "zero or equal to the number of components in the finite " + "element.")); const unsigned int n_components = DoFTools::n_components (dof); - // set the component mask to either - // the original value or a vector - // of trues + // set the component mask to either + // the original value or a vector + // of trues const std::vector component_mask ((component_mask_.size() == 0) ? - std::vector (n_components, true) : - component_mask_); + std::vector (n_components, true) : + component_mask_); Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0, - VectorTools::ExcNoComponentSelected()); + VectorTools::ExcNoComponentSelected()); - // a field to store the indices + // a field to store the indices std::vector face_dofs; face_dofs.reserve (max_dofs_per_face(dof)); @@ -5897,53 +5897,53 @@ namespace DoFTools endc = dof.end(); for (; cell!=endc; ++cell) for (unsigned int face_no = 0; face_no < GeometryInfo::faces_per_cell; - ++face_no) - { - const FiniteElement &fe = cell->get_fe(); - - typename DH::face_iterator face = cell->face(face_no); - - // if face is on the boundary - if (face->at_boundary ()) - { - // get indices and physical - // location on this face - face_dofs.resize (fe.dofs_per_face); - face->get_dof_indices (face_dofs, cell->active_fe_index()); - - // enter those dofs into the list - // that match the component - // signature. - for (unsigned int i=0; i &nonzero_component_array - = cell->get_fe().get_nonzero_components (i); - bool nonzero = false; - for (unsigned int c=0; c &fe = cell->get_fe(); + + typename DH::face_iterator face = cell->face(face_no); + + // if face is on the boundary + if (face->at_boundary ()) + { + // get indices and physical + // location on this face + face_dofs.resize (fe.dofs_per_face); + face->get_dof_indices (face_dofs, cell->active_fe_index()); + + // enter those dofs into the list + // that match the component + // signature. + for (unsigned int i=0; i &nonzero_component_array + = cell->get_fe().get_nonzero_components (i); + bool nonzero = false; + for (unsigned int c=0; c void make_cell_patches( - Sparsity& block_list, - const DH& dof_handler, - const unsigned int level, - const std::vector& selected_dofs, + Sparsity& block_list, + const DH& dof_handler, + const unsigned int level, + const std::vector& selected_dofs, unsigned int offset) { typename DH::cell_iterator cell; @@ -5953,12 +5953,12 @@ namespace DoFTools unsigned int i=0; for (cell=dof_handler.begin(level); cell != endc; ++i, ++cell) { - indices.resize(cell->get_fe().dofs_per_cell); - cell->get_mg_dof_indices(indices); + indices.resize(cell->get_fe().dofs_per_cell); + cell->get_mg_dof_indices(indices); if(selected_dofs.size()!=0) AssertDimension(indices.size(), selected_dofs.size()); - + for (unsigned int j=0;jget_fe().dofs_per_cell); - cell->get_mg_dof_indices(indices); - - if (interior_only) - { - // Exclude degrees of - // freedom on faces - // opposite to the vertex - exclude.resize(fe.dofs_per_cell); - std::fill(exclude.begin(), exclude.end(), false); - const unsigned int dpf = fe.dofs_per_face; - - for (unsigned int face=0;face::faces_per_cell;++face) - if (cell->at_boundary(face) || cell->neighbor(face)->level() != cell->level()) - for (unsigned int i=0;iget_fe().dofs_per_cell); + cell->get_mg_dof_indices(indices); + + if (interior_only) + { + // Exclude degrees of + // freedom on faces + // opposite to the vertex + exclude.resize(fe.dofs_per_cell); + std::fill(exclude.begin(), exclude.end(), false); + const unsigned int dpf = fe.dofs_per_face; + + for (unsigned int face=0;face::faces_per_cell;++face) + if (cell->at_boundary(face) || cell->neighbor(face)->level() != cell->level()) + for (unsigned int i=0;i 0 && level < dof_handler.get_tria().n_levels(), - ExcIndexRange(level, 1, dof_handler.get_tria().n_levels())); + ExcIndexRange(level, 1, dof_handler.get_tria().n_levels())); typename DH::cell_iterator cell; typename DH::cell_iterator pcell = dof_handler.begin(level-1); @@ -6039,51 +6039,51 @@ namespace DoFTools for (unsigned int block = 0;pcell != endc;++pcell) { - if (!pcell->has_children()) continue; - for (unsigned int child=0;childn_children();++child) - { - cell = pcell->child(child); - // For hp, only this line - // here would have to be - // replaced. - const FiniteElement& fe = dof_handler.get_fe(); - const unsigned int n_dofs = fe.dofs_per_cell; - indices.resize(n_dofs); - exclude.resize(n_dofs); - std::fill(exclude.begin(), exclude.end(), false); - cell->get_mg_dof_indices(indices); - - if (interior_dofs_only) - { - // Eliminate dofs on - // faces of the child - // which are on faces - // of the parent - const unsigned int dpf = fe.dofs_per_face; - - for (unsigned int d=0;d::vertex_to_face[child][d]; - for (unsigned int i=0;i::faces_per_cell;++face) - if (cell->at_boundary(face)) - for (unsigned int i=0;ihas_children()) continue; + for (unsigned int child=0;childn_children();++child) + { + cell = pcell->child(child); + // For hp, only this line + // here would have to be + // replaced. + const FiniteElement& fe = dof_handler.get_fe(); + const unsigned int n_dofs = fe.dofs_per_cell; + indices.resize(n_dofs); + exclude.resize(n_dofs); + std::fill(exclude.begin(), exclude.end(), false); + cell->get_mg_dof_indices(indices); + + if (interior_dofs_only) + { + // Eliminate dofs on + // faces of the child + // which are on faces + // of the parent + const unsigned int dpf = fe.dofs_per_face; + + for (unsigned int d=0;d::vertex_to_face[child][d]; + for (unsigned int i=0;i::faces_per_cell;++face) + if (cell->at_boundary(face)) + for (unsigned int i=0;i vertex_cell_count(dof_handler.get_tria().n_vertices(), 0); - // Is a vertex at the boundary? + // Is a vertex at the boundary? std::vector vertex_boundary(dof_handler.get_tria().n_vertices(), false); std::vector vertex_mapping(dof_handler.get_tria().n_vertices(), - numbers::invalid_unsigned_int); - // Estimate for the number of - // dofs at this point + numbers::invalid_unsigned_int); + // Estimate for the number of + // dofs at this point std::vector vertex_dof_count(dof_handler.get_tria().n_vertices(), 0); - // Identify all vertices active - // on this level and remember - // some data about them + // Identify all vertices active + // on this level and remember + // some data about them for (cell=dof_handler.begin(level); cell != endc; ++cell) for (unsigned int v=0;v::vertices_per_cell;++v) - { - const unsigned int vg = cell->vertex_index(v); - vertex_dof_count[vg] += cell->get_fe().dofs_per_cell; - ++vertex_cell_count[vg]; - for (unsigned int d=0;d::vertex_to_face[v][d]; - if (cell->at_boundary(face)) - vertex_boundary[vg] = true; - else - if ((!level_boundary_patches) - && (cell->neighbor(face)->level() != (int) level)) - vertex_boundary[vg] = true; - } - } - // From now on, only vertices - // with positive dof count are - // "in". - - // Remove vertices at boundaries - // or in corners + { + const unsigned int vg = cell->vertex_index(v); + vertex_dof_count[vg] += cell->get_fe().dofs_per_cell; + ++vertex_cell_count[vg]; + for (unsigned int d=0;d::vertex_to_face[v][d]; + if (cell->at_boundary(face)) + vertex_boundary[vg] = true; + else + if ((!level_boundary_patches) + && (cell->neighbor(face)->level() != (int) level)) + vertex_boundary[vg] = true; + } + } + // From now on, only vertices + // with positive dof count are + // "in". + + // Remove vertices at boundaries + // or in corners for (unsigned int vg=0;vg indices; std::vector exclude; for (cell=dof_handler.begin(level); cell != endc; ++cell) { - const FiniteElement& fe = cell->get_fe(); - indices.resize(fe.dofs_per_cell); - cell->get_mg_dof_indices(indices); - - for (unsigned int v=0;v::vertices_per_cell;++v) - { - const unsigned int vg = cell->vertex_index(v); - const unsigned int block = vertex_mapping[vg]; - if (block == numbers::invalid_unsigned_int) - continue; - - if (interior_only) - { - // Exclude degrees of - // freedom on faces - // opposite to the vertex - exclude.resize(fe.dofs_per_cell); - std::fill(exclude.begin(), exclude.end(), false); - const unsigned int dpf = fe.dofs_per_face; - - for (unsigned int d=0;d::vertex_to_face[v][d]; - const unsigned int face = GeometryInfo::opposite_face[a_face]; - for (unsigned int i=0;i& fe = cell->get_fe(); + indices.resize(fe.dofs_per_cell); + cell->get_mg_dof_indices(indices); + + for (unsigned int v=0;v::vertices_per_cell;++v) + { + const unsigned int vg = cell->vertex_index(v); + const unsigned int block = vertex_mapping[vg]; + if (block == numbers::invalid_unsigned_int) + continue; + + if (interior_only) + { + // Exclude degrees of + // freedom on faces + // opposite to the vertex + exclude.resize(fe.dofs_per_cell); + std::fill(exclude.begin(), exclude.end(), false); + const unsigned int dpf = fe.dofs_per_face; + + for (unsigned int d=0;d::vertex_to_face[v][d]; + const unsigned int face = GeometryInfo::opposite_face[a_face]; + for (unsigned int i=0;i void FiniteElement:: InternalDataBase::initialize_2nd (const FiniteElement *element, - const Mapping &mapping, - const Quadrature &quadrature) + const Mapping &mapping, + const Quadrature &quadrature) { - // if we shall compute second - // derivatives, then we do so by - // finite differencing the - // gradients. that we do by - // evaluating the gradients of - // shape values at points shifted - // star-like a little in each - // coordinate direction around each - // quadrature point. - // - // therefore generate 2*dim (the - // number of evaluation points) - // FEValues objects with slightly - // shifted positions + // if we shall compute second + // derivatives, then we do so by + // finite differencing the + // gradients. that we do by + // evaluating the gradients of + // shape values at points shifted + // star-like a little in each + // coordinate direction around each + // quadrature point. + // + // therefore generate 2*dim (the + // number of evaluation points) + // FEValues objects with slightly + // shifted positions std::vector > diff_points (quadrature.size()); differences.resize(2*dim); @@ -66,23 +66,23 @@ InternalDataBase::initialize_2nd (const FiniteElement *element, Point shift; shift (d) = fd_step_length; - // generate points and FEValues - // objects shifted in - // plus-direction. note that - // they only need to compute - // gradients, not more + // generate points and FEValues + // objects shifted in + // plus-direction. note that + // they only need to compute + // gradients, not more for (unsigned int i=0; i plus_quad (diff_points, quadrature.get_weights()); differences[d] = new FEValues (mapping, *element, - plus_quad, update_gradients); + plus_quad, update_gradients); - // now same in minus-direction + // now same in minus-direction for (unsigned int i=0; i minus_quad (diff_points, quadrature.get_weights()); differences[d+dim] = new FEValues (mapping, *element, - minus_quad, update_gradients); + minus_quad, update_gradients); } } @@ -95,11 +95,11 @@ FiniteElement::InternalDataBase::~InternalDataBase () for (unsigned int i=0; i::FiniteElement ( const FiniteElementData &fe_data, const std::vector &r_i_a_f, const std::vector > &nonzero_c) - : - FiniteElementData (fe_data), - adjust_quad_dof_index_for_face_orientation_table (dim == 3 ? - this->dofs_per_quad : 0 , - dim==3 ? 8 : 0), - adjust_line_dof_index_for_line_orientation_table (dim == 3 ? - this->dofs_per_line : 0), + : + FiniteElementData (fe_data), + adjust_quad_dof_index_for_face_orientation_table (dim == 3 ? + this->dofs_per_quad : 0 , + dim==3 ? 8 : 0), + adjust_line_dof_index_for_line_orientation_table (dim == 3 ? + this->dofs_per_line : 0), system_to_base_table(this->dofs_per_cell), face_system_to_base_table(this->dofs_per_face), component_to_base_table (this->components, std::make_pair(std::make_pair(0U, 0U), 0U)), restriction_is_additive_flags(r_i_a_f), - nonzero_components (nonzero_c) + nonzero_components (nonzero_c) { - // Special handling of vectors of - // length one: in this case, we - // assume that all entries were - // supposed to be equal. - - // Normally, we should be careful - // with const_cast, but since this - // is the constructor and we do it - // here only, we are fine. + // Special handling of vectors of + // length one: in this case, we + // assume that all entries were + // supposed to be equal. + + // Normally, we should be careful + // with const_cast, but since this + // is the constructor and we do it + // here only, we are fine. unsigned int ndofs = this->dofs_per_cell; if (restriction_is_additive_flags.size() == 1 && ndofs > 1) { std::vector& aux - = const_cast&> (restriction_is_additive_flags); + = const_cast&> (restriction_is_additive_flags); aux.resize(ndofs, restriction_is_additive_flags[0]); } if (nonzero_components.size() == 1 && ndofs > 1) { std::vector >& aux - = const_cast >&> (nonzero_components); + = const_cast >&> (nonzero_components); aux.resize(ndofs, nonzero_components[0]); } - // These used to be initialized in - // the constructor, but here we - // have the possibly corrected - // nonzero_components vector. + // These used to be initialized in + // the constructor, but here we + // have the possibly corrected + // nonzero_components vector. const_cast&> (n_nonzero_components_table) = compute_n_nonzero_components(nonzero_components); this->set_primitivity(std::find_if (n_nonzero_components_table.begin(), - n_nonzero_components_table.end(), - std::bind2nd(std::not_equal_to(), - 1U)) - == n_nonzero_components_table.end()); + n_nonzero_components_table.end(), + std::bind2nd(std::not_equal_to(), + 1U)) + == n_nonzero_components_table.end()); Assert (restriction_is_additive_flags.size() == this->dofs_per_cell, - ExcDimensionMismatch(restriction_is_additive_flags.size(), - this->dofs_per_cell)); + ExcDimensionMismatch(restriction_is_additive_flags.size(), + this->dofs_per_cell)); AssertDimension (nonzero_components.size(), this->dofs_per_cell); for (unsigned int i=0; in_components(), - ExcInternalError()); + ExcInternalError()); Assert (std::count (nonzero_components[i].begin(), - nonzero_components[i].end(), - true) - >= 1, - ExcInternalError()); + nonzero_components[i].end(), + true) + >= 1, + ExcInternalError()); Assert (n_nonzero_components_table[i] >= 1, - ExcInternalError()); + ExcInternalError()); Assert (n_nonzero_components_table[i] <= this->n_components(), - ExcInternalError()); + ExcInternalError()); }; // initialize some tables in the - // default way, i.e. if there is - // only one (vector-)component; if - // the element is not primitive, - // leave these tables empty. + // default way, i.e. if there is + // only one (vector-)component; if + // the element is not primitive, + // leave these tables empty. if (this->is_primitive()) { system_to_component_table.resize(this->dofs_per_cell); face_system_to_component_table.resize(this->dofs_per_face); for (unsigned int j=0 ; jdofs_per_cell ; ++j) - { - system_to_component_table[j] = std::pair(0,j); - system_to_base_table[j] = std::make_pair(std::make_pair(0U,0U),j); - } + { + system_to_component_table[j] = std::pair(0,j); + system_to_base_table[j] = std::make_pair(std::make_pair(0U,0U),j); + } for (unsigned int j=0 ; jdofs_per_face ; ++j) - { - face_system_to_component_table[j] = std::pair(0,j); - face_system_to_base_table[j] = std::make_pair(std::make_pair(0U,0U),j); - } + { + face_system_to_component_table[j] = std::pair(0,j); + face_system_to_base_table[j] = std::make_pair(std::make_pair(0U,0U),j); + } } - // Fill with default value; may be - // changed by constructor of - // derived class. + // Fill with default value; may be + // changed by constructor of + // derived class. base_to_block_indices.reinit(1,1); - // initialize the restriction and - // prolongation matrices. the default - // contructur of FullMatrix initializes - // them with size zero + // initialize the restriction and + // prolongation matrices. the default + // contructur of FullMatrix initializes + // them with size zero prolongation.resize(RefinementCase::isotropic_refinement); restriction.resize(RefinementCase::isotropic_refinement); for (unsigned int ref=RefinementCase::cut_x; ref::isotropic_refinement+1; ++ref) { prolongation[ref-1].resize (GeometryInfo:: - n_children(RefinementCase(ref)), - FullMatrix()); + n_children(RefinementCase(ref)), + FullMatrix()); restriction[ref-1].resize (GeometryInfo:: - n_children(RefinementCase(ref)), - FullMatrix()); + n_children(RefinementCase(ref)), + FullMatrix()); } adjust_quad_dof_index_for_face_orientation_table.fill(0); @@ -238,7 +238,7 @@ FiniteElement::~FiniteElement () template double FiniteElement::shape_value (const unsigned int, - const Point &) const + const Point &) const { AssertThrow(false, ExcUnitShapeValuesDoNotExist()); return 0.; @@ -249,8 +249,8 @@ FiniteElement::shape_value (const unsigned int, template double FiniteElement::shape_value_component (const unsigned int, - const Point &, - const unsigned int) const + const Point &, + const unsigned int) const { AssertThrow(false, ExcUnitShapeValuesDoNotExist()); return 0.; @@ -261,7 +261,7 @@ FiniteElement::shape_value_component (const unsigned int, template Tensor<1,dim> FiniteElement::shape_grad (const unsigned int, - const Point &) const + const Point &) const { AssertThrow(false, ExcUnitShapeValuesDoNotExist()); return Tensor<1,dim> (); @@ -272,8 +272,8 @@ FiniteElement::shape_grad (const unsigned int, template Tensor<1,dim> FiniteElement::shape_grad_component (const unsigned int, - const Point &, - const unsigned int) const + const Point &, + const unsigned int) const { AssertThrow(false, ExcUnitShapeValuesDoNotExist()); return Tensor<1,dim> (); @@ -284,7 +284,7 @@ FiniteElement::shape_grad_component (const unsigned int, template Tensor<2,dim> FiniteElement::shape_grad_grad (const unsigned int, - const Point &) const + const Point &) const { AssertThrow(false, ExcUnitShapeValuesDoNotExist()); return Tensor<2,dim> (); @@ -295,8 +295,8 @@ FiniteElement::shape_grad_grad (const unsigned int, template Tensor<2,dim> FiniteElement::shape_grad_grad_component (const unsigned int, - const Point &, - const unsigned int) const + const Point &, + const unsigned int) const { AssertThrow(false, ExcUnitShapeValuesDoNotExist()); return Tensor<2,dim> (); @@ -315,14 +315,14 @@ FiniteElement::reinit_restriction_and_prolongation_matrices ( const unsigned int nc = GeometryInfo::n_children(RefinementCase(ref_case)); for (unsigned int i=0; i::isotropic_refinement) - this->restriction[ref_case-1][i].reinit (this->dofs_per_cell, - this->dofs_per_cell); - if (!isotropic_prolongation_only || ref_case==RefinementCase::isotropic_refinement) - this->prolongation[ref_case-1][i].reinit (this->dofs_per_cell, - this->dofs_per_cell); - } + { + if (!isotropic_restriction_only || ref_case==RefinementCase::isotropic_refinement) + this->restriction[ref_case-1][i].reinit (this->dofs_per_cell, + this->dofs_per_cell); + if (!isotropic_prolongation_only || ref_case==RefinementCase::isotropic_refinement) + this->prolongation[ref_case-1][i].reinit (this->dofs_per_cell, + this->dofs_per_cell); + } } } @@ -330,19 +330,19 @@ FiniteElement::reinit_restriction_and_prolongation_matrices ( template const FullMatrix & FiniteElement::get_restriction_matrix (const unsigned int child, - const RefinementCase &refinement_case) const + const RefinementCase &refinement_case) const { Assert (refinement_case::isotropic_refinement+1, - ExcIndexRange(refinement_case,0,RefinementCase::isotropic_refinement+1)); + ExcIndexRange(refinement_case,0,RefinementCase::isotropic_refinement+1)); Assert (refinement_case!=RefinementCase::no_refinement, - ExcMessage("Restriction matrices are only available for refined cells!")); + ExcMessage("Restriction matrices are only available for refined cells!")); Assert (child::n_children(RefinementCase(refinement_case)), - ExcIndexRange(child,0,GeometryInfo::n_children(RefinementCase(refinement_case)))); - // we use refinement_case-1 here. the -1 takes care - // of the origin of the vector, as for - // RefinementCase::no_refinement (=0) there is no - // data available and so the vector indices - // are shifted + ExcIndexRange(child,0,GeometryInfo::n_children(RefinementCase(refinement_case)))); + // we use refinement_case-1 here. the -1 takes care + // of the origin of the vector, as for + // RefinementCase::no_refinement (=0) there is no + // data available and so the vector indices + // are shifted Assert (restriction[refinement_case-1][child].n() == this->dofs_per_cell, ExcProjectionVoid()); return restriction[refinement_case-1][child]; } @@ -352,19 +352,19 @@ FiniteElement::get_restriction_matrix (const unsigned int child, template const FullMatrix & FiniteElement::get_prolongation_matrix (const unsigned int child, - const RefinementCase &refinement_case) const + const RefinementCase &refinement_case) const { Assert (refinement_case::isotropic_refinement+1, - ExcIndexRange(refinement_case,0,RefinementCase::isotropic_refinement+1)); + ExcIndexRange(refinement_case,0,RefinementCase::isotropic_refinement+1)); Assert (refinement_case!=RefinementCase::no_refinement, - ExcMessage("Prolongation matrices are only available for refined cells!")); + ExcMessage("Prolongation matrices are only available for refined cells!")); Assert (child::n_children(RefinementCase(refinement_case)), - ExcIndexRange(child,0,GeometryInfo::n_children(RefinementCase(refinement_case)))); - // we use refinement_case-1 here. the -1 takes care - // of the origin of the vector, as for - // RefinementCase::no_refinement (=0) there is no - // data available and so the vector indices - // are shifted + ExcIndexRange(child,0,GeometryInfo::n_children(RefinementCase(refinement_case)))); + // we use refinement_case-1 here. the -1 takes care + // of the origin of the vector, as for + // RefinementCase::no_refinement (=0) there is no + // data available and so the vector indices + // are shifted Assert (prolongation[refinement_case-1][child].n() == this->dofs_per_cell, ExcEmbeddingVoid()); return prolongation[refinement_case-1][child]; } @@ -376,7 +376,7 @@ unsigned int FiniteElement::component_to_block_index (const unsigned int index) const { Assert (index < this->n_components(), - ExcIndexRange(index, 0, this->n_components())); + ExcIndexRange(index, 0, this->n_components())); return first_block_of_base(component_to_base_table[index].first.first) + component_to_base_table[index].second; @@ -386,30 +386,30 @@ FiniteElement::component_to_block_index (const unsigned int index) template unsigned int FiniteElement::adjust_quad_dof_index_for_face_orientation (const unsigned int index, - const bool face_orientation, - const bool face_flip, - const bool face_rotation) const + const bool face_orientation, + const bool face_flip, + const bool face_rotation) const { - // general template for 1D and 2D: not - // implemented. in fact, the function - // shouldn't even be called unless we are - // in 3d, so throw an internal error + // general template for 1D and 2D: not + // implemented. in fact, the function + // shouldn't even be called unless we are + // in 3d, so throw an internal error Assert (dim==3, ExcInternalError()); if (dim < 3) return index; - // adjust dofs on 3d faces if the face is - // flipped. note that we query a table that - // derived elements need to have set up - // front. the exception are discontinuous - // elements for which there should be no - // face dofs anyway (i.e. dofs_per_quad==0 - // in 3d), so we don't need the table, but - // the function should also not have been - // called + // adjust dofs on 3d faces if the face is + // flipped. note that we query a table that + // derived elements need to have set up + // front. the exception are discontinuous + // elements for which there should be no + // face dofs anyway (i.e. dofs_per_quad==0 + // in 3d), so we don't need the table, but + // the function should also not have been + // called Assert (indexdofs_per_quad, ExcIndexRange(index,0,this->dofs_per_quad)); Assert (adjust_quad_dof_index_for_face_orientation_table.n_elements()==8*this->dofs_per_quad, - ExcInternalError()); + ExcInternalError()); return index+adjust_quad_dof_index_for_face_orientation_table(index,4*face_orientation+2*face_flip+face_rotation); } @@ -418,18 +418,18 @@ FiniteElement::adjust_quad_dof_index_for_face_orientation (const u template unsigned int FiniteElement::adjust_line_dof_index_for_line_orientation (const unsigned int index, - const bool line_orientation) const + const bool line_orientation) const { - // general template for 1D and 2D: do - // nothing. Do not throw an Assertion, - // however, in order to allow to call this - // function in 2D as well + // general template for 1D and 2D: do + // nothing. Do not throw an Assertion, + // however, in order to allow to call this + // function in 2D as well if (dim<3) return index; Assert (indexdofs_per_line, ExcIndexRange(index,0,this->dofs_per_line)); Assert (adjust_line_dof_index_for_line_orientation_table.size()==this->dofs_per_line, - ExcInternalError()); + ExcInternalError()); if (line_orientation) return index; else @@ -445,17 +445,17 @@ FiniteElement::prolongation_is_implemented () const for (unsigned int ref_case=RefinementCase::cut_x; ref_case::isotropic_refinement+1; ++ref_case) for (unsigned int c=0; - c::n_children(RefinementCase(ref_case)); ++c) + c::n_children(RefinementCase(ref_case)); ++c) { - Assert ((prolongation[ref_case-1][c].m() == this->dofs_per_cell) || - (prolongation[ref_case-1][c].m() == 0), - ExcInternalError()); - Assert ((prolongation[ref_case-1][c].n() == this->dofs_per_cell) || - (prolongation[ref_case-1][c].n() == 0), - ExcInternalError()); - if ((prolongation[ref_case-1][c].m() == 0) || - (prolongation[ref_case-1][c].n() == 0)) - return false; + Assert ((prolongation[ref_case-1][c].m() == this->dofs_per_cell) || + (prolongation[ref_case-1][c].m() == 0), + ExcInternalError()); + Assert ((prolongation[ref_case-1][c].n() == this->dofs_per_cell) || + (prolongation[ref_case-1][c].n() == 0), + ExcInternalError()); + if ((prolongation[ref_case-1][c].m() == 0) || + (prolongation[ref_case-1][c].n() == 0)) + return false; } return true; } @@ -469,17 +469,17 @@ FiniteElement::restriction_is_implemented () const for (unsigned int ref_case=RefinementCase::cut_x; ref_case::isotropic_refinement+1; ++ref_case) for (unsigned int c=0; - c::n_children(RefinementCase(ref_case)); ++c) + c::n_children(RefinementCase(ref_case)); ++c) { - Assert ((restriction[ref_case-1][c].m() == this->dofs_per_cell) || - (restriction[ref_case-1][c].m() == 0), - ExcInternalError()); - Assert ((restriction[ref_case-1][c].n() == this->dofs_per_cell) || - (restriction[ref_case-1][c].n() == 0), - ExcInternalError()); - if ((restriction[ref_case-1][c].m() == 0) || - (restriction[ref_case-1][c].n() == 0)) - return false; + Assert ((restriction[ref_case-1][c].m() == this->dofs_per_cell) || + (restriction[ref_case-1][c].m() == 0), + ExcInternalError()); + Assert ((restriction[ref_case-1][c].n() == this->dofs_per_cell) || + (restriction[ref_case-1][c].n() == 0), + ExcInternalError()); + if ((restriction[ref_case-1][c].m() == 0) || + (restriction[ref_case-1][c].n() == 0)) + return false; } return true; } @@ -496,14 +496,14 @@ FiniteElement::isotropic_prolongation_is_implemented () const c::n_children(RefinementCase(ref_case)); ++c) { Assert ((prolongation[ref_case-1][c].m() == this->dofs_per_cell) || - (prolongation[ref_case-1][c].m() == 0), - ExcInternalError()); + (prolongation[ref_case-1][c].m() == 0), + ExcInternalError()); Assert ((prolongation[ref_case-1][c].n() == this->dofs_per_cell) || - (prolongation[ref_case-1][c].n() == 0), - ExcInternalError()); + (prolongation[ref_case-1][c].n() == 0), + ExcInternalError()); if ((prolongation[ref_case-1][c].m() == 0) || - (prolongation[ref_case-1][c].n() == 0)) - return false; + (prolongation[ref_case-1][c].n() == 0)) + return false; } return true; } @@ -520,14 +520,14 @@ FiniteElement::isotropic_restriction_is_implemented () const c::n_children(RefinementCase(ref_case)); ++c) { Assert ((restriction[ref_case-1][c].m() == this->dofs_per_cell) || - (restriction[ref_case-1][c].m() == 0), - ExcInternalError()); + (restriction[ref_case-1][c].m() == 0), + ExcInternalError()); Assert ((restriction[ref_case-1][c].n() == this->dofs_per_cell) || - (restriction[ref_case-1][c].n() == 0), - ExcInternalError()); + (restriction[ref_case-1][c].n() == 0), + ExcInternalError()); if ((restriction[ref_case-1][c].m() == 0) || - (restriction[ref_case-1][c].n() == 0)) - return false; + (restriction[ref_case-1][c].n() == 0)) + return false; } return true; } @@ -565,8 +565,8 @@ FiniteElement::constraints (const internal::SubfaceCase &subf if (dim==1) Assert ((interface_constraints.m()==0) && (interface_constraints.n()==0), - ExcWrongInterfaceMatrixSize(interface_constraints.m(), - interface_constraints.n())); + ExcWrongInterfaceMatrixSize(interface_constraints.m(), + interface_constraints.n())); return interface_constraints; } @@ -603,15 +603,15 @@ template void FiniteElement:: get_interpolation_matrix (const FiniteElement &, - FullMatrix &) const + FullMatrix &) const { - // by default, no interpolation - // implemented. so throw exception, - // as documentation says + // by default, no interpolation + // implemented. so throw exception, + // as documentation says typedef FiniteElement FEE; AssertThrow (false, typename FEE:: - ExcInterpolationNotImplemented()); + ExcInterpolationNotImplemented()); } @@ -620,11 +620,11 @@ template void FiniteElement:: get_face_interpolation_matrix (const FiniteElement &, - FullMatrix &) const + FullMatrix &) const { - // by default, no interpolation - // implemented. so throw exception, - // as documentation says + // by default, no interpolation + // implemented. so throw exception, + // as documentation says typedef FiniteElement FEE; AssertThrow (false, typename FEE:: @@ -637,12 +637,12 @@ template void FiniteElement:: get_subface_interpolation_matrix (const FiniteElement &, - const unsigned int, - FullMatrix &) const + const unsigned int, + FullMatrix &) const { - // by default, no interpolation - // implemented. so throw exception, - // as documentation says + // by default, no interpolation + // implemented. so throw exception, + // as documentation says typedef FiniteElement FEE; AssertThrow (false, typename FEE::ExcInterpolationNotImplemented()); @@ -699,8 +699,8 @@ bool FiniteElement::operator == (const FiniteElement &f) const { return ((static_cast&>(*this) == - static_cast&>(f)) && - (interface_constraints == f.interface_constraints)); + static_cast&>(f)) && + (interface_constraints == f.interface_constraints)); } @@ -709,13 +709,13 @@ template const std::vector > & FiniteElement::get_unit_support_points () const { - // a finite element may define - // support points, but only if - // there are as many as there are - // degrees of freedom + // a finite element may define + // support points, but only if + // there are as many as there are + // degrees of freedom Assert ((unit_support_points.size() == 0) || - (unit_support_points.size() == this->dofs_per_cell), - ExcInternalError()); + (unit_support_points.size() == this->dofs_per_cell), + ExcInternalError()); return unit_support_points; } @@ -734,13 +734,13 @@ template const std::vector > & FiniteElement::get_generalized_support_points () const { - // a finite element may define - // support points, but only if - // there are as many as there are - // degrees of freedom + // a finite element may define + // support points, but only if + // there are as many as there are + // degrees of freedom return ((generalized_support_points.size() == 0) - ? unit_support_points - : generalized_support_points); + ? unit_support_points + : generalized_support_points); } @@ -771,13 +771,13 @@ template const std::vector > & FiniteElement::get_unit_face_support_points () const { - // a finite element may define - // support points, but only if - // there are as many as there are - // degrees of freedom on a face + // a finite element may define + // support points, but only if + // there are as many as there are + // degrees of freedom on a face Assert ((unit_face_support_points.size() == 0) || - (unit_face_support_points.size() == this->dofs_per_face), - ExcInternalError()); + (unit_face_support_points.size() == this->dofs_per_face), + ExcInternalError()); return unit_face_support_points; } @@ -796,13 +796,13 @@ template const std::vector > & FiniteElement::get_generalized_face_support_points () const { - // a finite element may define - // support points, but only if - // there are as many as there are - // degrees of freedom on a face + // a finite element may define + // support points, but only if + // there are as many as there are + // degrees of freedom on a face return ((generalized_face_support_points.size() == 0) - ? unit_face_support_points - : generalized_face_support_points); + ? unit_face_support_points + : generalized_face_support_points); } @@ -846,11 +846,11 @@ FiniteElement::interpolate( { Assert (has_support_points(), ExcFEHasNoSupportPoints()); Assert (values.size() == unit_support_points.size(), - ExcDimensionMismatch(values.size(), unit_support_points.size())); + ExcDimensionMismatch(values.size(), unit_support_points.size())); Assert (local_dofs.size() == this->dofs_per_cell, - ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); + ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); Assert (this->n_components() == 1, - ExcDimensionMismatch(this->n_components(), 1)); + ExcDimensionMismatch(this->n_components(), 1)); std::copy(values.begin(), values.end(), local_dofs.begin()); } @@ -867,16 +867,16 @@ FiniteElement::interpolate( { Assert (has_support_points(), ExcFEHasNoSupportPoints()); Assert (values.size() == unit_support_points.size(), - ExcDimensionMismatch(values.size(), unit_support_points.size())); + ExcDimensionMismatch(values.size(), unit_support_points.size())); Assert (local_dofs.size() == this->dofs_per_cell, - ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); + ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); Assert (values[0].size() >= offset+this->n_components(), - ExcDimensionMismatch(values[0].size(),offset+this->n_components())); + ExcDimensionMismatch(values[0].size(),offset+this->n_components())); for (unsigned int i=0;idofs_per_cell;++i) { const std::pair index - = this->system_to_component_index(i); + = this->system_to_component_index(i); local_dofs[i] = values[i](offset+index.first); } } @@ -892,16 +892,16 @@ FiniteElement::interpolate( { Assert (has_support_points(), ExcFEHasNoSupportPoints()); Assert (values[0].size() == unit_support_points.size(), - ExcDimensionMismatch(values.size(), unit_support_points.size())); + ExcDimensionMismatch(values.size(), unit_support_points.size())); Assert (local_dofs.size() == this->dofs_per_cell, - ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); + ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); Assert (values.size() == this->n_components(), - ExcDimensionMismatch(values.size(), this->n_components())); + ExcDimensionMismatch(values.size(), this->n_components())); for (unsigned int i=0;idofs_per_cell;++i) { const std::pair index - = this->system_to_component_index(i); + = this->system_to_component_index(i); local_dofs[i] = values[index.first][i]; } } @@ -913,17 +913,17 @@ std::size_t FiniteElement::memory_consumption () const { return (sizeof(FiniteElementData) + - MemoryConsumption::memory_consumption (restriction)+ - MemoryConsumption::memory_consumption (prolongation) + - MemoryConsumption::memory_consumption (interface_constraints) + - MemoryConsumption::memory_consumption (system_to_component_table) + - MemoryConsumption::memory_consumption (face_system_to_component_table) + - MemoryConsumption::memory_consumption (system_to_base_table) + - MemoryConsumption::memory_consumption (face_system_to_base_table) + - MemoryConsumption::memory_consumption (component_to_base_table) + - MemoryConsumption::memory_consumption (restriction_is_additive_flags) + - MemoryConsumption::memory_consumption (nonzero_components) + - MemoryConsumption::memory_consumption (n_nonzero_components_table)); + MemoryConsumption::memory_consumption (restriction)+ + MemoryConsumption::memory_consumption (prolongation) + + MemoryConsumption::memory_consumption (interface_constraints) + + MemoryConsumption::memory_consumption (system_to_component_table) + + MemoryConsumption::memory_consumption (face_system_to_component_table) + + MemoryConsumption::memory_consumption (system_to_base_table) + + MemoryConsumption::memory_consumption (face_system_to_base_table) + + MemoryConsumption::memory_consumption (component_to_base_table) + + MemoryConsumption::memory_consumption (restriction_is_additive_flags) + + MemoryConsumption::memory_consumption (nonzero_components) + + MemoryConsumption::memory_consumption (n_nonzero_components_table)); } @@ -939,7 +939,7 @@ FiniteElement<1,2>::compute_2nd ( FEValuesData<1,2> &) const { - Assert(false, ExcNotImplemented()); + Assert(false, ExcNotImplemented()); } @@ -954,7 +954,7 @@ FiniteElement<1,3>::compute_2nd ( FEValuesData<1,3> &) const { - Assert(false, ExcNotImplemented()); + Assert(false, ExcNotImplemented()); } @@ -970,7 +970,7 @@ FiniteElement<2,3>::compute_2nd ( FEValuesData<2,3> &) const { - Assert(false, ExcNotImplemented()); + Assert(false, ExcNotImplemented()); } @@ -986,42 +986,42 @@ FiniteElement::compute_2nd ( FEValuesData &data) const { Assert ((fe_internal.update_each | fe_internal.update_once) - & update_hessians, - ExcInternalError()); + & update_hessians, + ExcInternalError()); // make sure we have as many entries as there are nonzero components // Assert (data.shape_hessians.size() == -// std::accumulate (n_nonzero_components_table.begin(), +// std::accumulate (n_nonzero_components_table.begin(), // n_nonzero_components_table.end(), // 0U), -// ExcInternalError()); - // Number of quadrature points +// ExcInternalError()); + // Number of quadrature points const unsigned int n_q_points = data.shape_hessians[0].size(); - // first reinit the fe_values - // objects used for the finite - // differencing stuff + // first reinit the fe_values + // objects used for the finite + // differencing stuff for (unsigned int d=0; dreinit(cell); fe_internal.differences[d+dim]->reinit(cell); Assert(offset <= fe_internal.differences[d]->n_quadrature_points - n_q_points, - ExcIndexRange(offset, 0, fe_internal.differences[d]->n_quadrature_points - - n_q_points)); + ExcIndexRange(offset, 0, fe_internal.differences[d]->n_quadrature_points + - n_q_points)); } - // collection of difference - // quotients of gradients in each - // direction (first index) and at - // all q-points (second index) + // collection of difference + // quotients of gradients in each + // direction (first index) and at + // all q-points (second index) std::vector > > diff_quot (spacedim, std::vector > (n_q_points)); std::vector > diff_quot2 (n_q_points); - // for all nonzero components of - // all shape functions at all - // quadrature points and difference - // quotients in all directions: + // for all nonzero components of + // all shape functions at all + // quadrature points and difference + // quotients in all directions: unsigned int total_index = 0; for (unsigned int shape_index=0; shape_indexdofs_per_cell; ++shape_index) for (unsigned int n=0; n::compute_n_nonzero_components ( std::vector retval (nonzero_components.size()); for (unsigned int i=0; i::compute_n_nonzero_components ( template typename Mapping::InternalDataBase * FiniteElement::get_face_data (const UpdateFlags flags, - const Mapping &mapping, - const Quadrature &quadrature) const + const Mapping &mapping, + const Quadrature &quadrature) const { return get_data (flags, mapping, - QProjector::project_to_all_faces(quadrature)); + QProjector::project_to_all_faces(quadrature)); } @@ -1148,11 +1148,11 @@ FiniteElement::get_face_data (const UpdateFlags flags, template typename Mapping::InternalDataBase * FiniteElement::get_subface_data (const UpdateFlags flags, - const Mapping &mapping, - const Quadrature &quadrature) const + const Mapping &mapping, + const Quadrature &quadrature) const { return get_data (flags, mapping, - QProjector::project_to_all_subfaces(quadrature)); + QProjector::project_to_all_subfaces(quadrature)); } @@ -1162,8 +1162,8 @@ const FiniteElement& FiniteElement::base_element(const unsigned index) const { Assert (index==0, ExcIndexRange(index,0,1)); - // This function should not be - // called for a system element + // This function should not be + // called for a system element Assert (base_to_block_indices.size() == 1, ExcInternalError()); return *this; } diff --git a/deal.II/source/fe/fe_abf.cc b/deal.II/source/fe/fe_abf.cc index 4550c56d40..296a00749c 100644 --- a/deal.II/source/fe/fe_abf.cc +++ b/deal.II/source/fe/fe_abf.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011 by the deal.II authors +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -43,65 +43,65 @@ DEAL_II_NAMESPACE_OPEN template FE_ABF::FE_ABF (const unsigned int deg) - : - FE_PolyTensor, dim> ( - deg, - FiniteElementData(get_dpo_vector(deg), - dim, deg+1, FiniteElementData::Hdiv, 1), - std::vector(PolynomialsABF::compute_n_pols(deg), true), - std::vector >(PolynomialsABF::compute_n_pols(deg), - std::vector(dim,true))), - rt_order(deg) + : + FE_PolyTensor, dim> ( + deg, + FiniteElementData(get_dpo_vector(deg), + dim, deg+1, FiniteElementData::Hdiv, 1), + std::vector(PolynomialsABF::compute_n_pols(deg), true), + std::vector >(PolynomialsABF::compute_n_pols(deg), + std::vector(dim,true))), + rt_order(deg) { Assert (dim >= 2, ExcImpossibleInDim(dim)); const unsigned int n_dofs = this->dofs_per_cell; this->mapping_type = mapping_raviart_thomas; - // First, initialize the - // generalized support points and - // quadrature weights, since they - // are required for interpolation. + // First, initialize the + // generalized support points and + // quadrature weights, since they + // are required for interpolation. initialize_support_points(deg); - // Now compute the inverse node - //matrix, generating the correct - //basis functions from the raw - //ones. + // Now compute the inverse node + //matrix, generating the correct + //basis functions from the raw + //ones. FullMatrix M(n_dofs, n_dofs); FETools::compute_node_matrix(M, *this); this->inverse_node_matrix.reinit(n_dofs, n_dofs); this->inverse_node_matrix.invert(M); - // From now on, the shape functions - // will be the correct ones, not - // the raw shape functions anymore. - - // Reinit the vectors of - // restriction and prolongation - // matrices to the right sizes. - // Restriction only for isotropic - // refinement + // From now on, the shape functions + // will be the correct ones, not + // the raw shape functions anymore. + + // Reinit the vectors of + // restriction and prolongation + // matrices to the right sizes. + // Restriction only for isotropic + // refinement this->reinit_restriction_and_prolongation_matrices(true); - // Fill prolongation matrices with embedding operators + // Fill prolongation matrices with embedding operators FETools::compute_embedding_matrices (*this, this->prolongation); initialize_restriction (); - // TODO[TL]: for anisotropic refinement we will probably need a table of submatrices with an array for each refine case + // TODO[TL]: for anisotropic refinement we will probably need a table of submatrices with an array for each refine case std::vector > face_embeddings(1<<(dim-1), FullMatrix(this->dofs_per_face, - this->dofs_per_face)); + this->dofs_per_face)); // TODO: Something goes wrong there. The error of the least squares fit // is to large ... // FETools::compute_face_embedding_matrices(*this, &face_embeddings[0], 0, 0); this->interface_constraints.reinit((1<<(dim-1)) * this->dofs_per_face, - this->dofs_per_face); + this->dofs_per_face); unsigned int target_row=0; for (unsigned int d=0;dinterface_constraints(target_row,j) = face_embeddings[d](i,j); - ++target_row; + for (unsigned int j=0;jinterface_constraints(target_row,j) = face_embeddings[d](i,j); + ++target_row; } } @@ -111,12 +111,12 @@ template std::string FE_ABF::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch #ifdef HAVE_STD_STRINGSTREAM std::ostringstream namebuf; @@ -157,12 +157,12 @@ FE_ABF::initialize_support_points (const unsigned int deg) const unsigned int n_interior_points = cell_quadrature.size(); unsigned int n_face_points = (dim>1) ? 1 : 0; - // compute (deg+1)^(dim-1) + // compute (deg+1)^(dim-1) for (unsigned int d=1;dgeneralized_support_points.resize (GeometryInfo::faces_per_cell*n_face_points - + n_interior_points); + + n_interior_points); this->generalized_face_support_points.resize (n_face_points); @@ -175,48 +175,48 @@ FE_ABF::initialize_support_points (const unsigned int deg) { std::vector > > poly(dim); for (unsigned int d=0;d (deg+1)); + poly[d].push_back (Polynomials::Monomial (deg+1)); poly[dd] = Polynomials::Monomial::generate_complete_basis(deg); polynomials_abf[dd] = new AnisotropicPolynomials(poly); } - // Number of the point being entered + // Number of the point being entered unsigned int current = 0; if (dim>1) { QGauss face_points (deg+1); TensorProductPolynomials legendre = - Polynomials::Legendre::generate_complete_basis(deg); + Polynomials::Legendre::generate_complete_basis(deg); boundary_weights.reinit(n_face_points, legendre.n()); // Assert (face_points.size() == this->dofs_per_face, -// ExcInternalError()); +// ExcInternalError()); for (unsigned int k=0;kgeneralized_face_support_points[k] = face_points.point(k); - // Compute its quadrature - // contribution for each - // moment. - for (unsigned int i=0;igeneralized_face_support_points[k] = face_points.point(k); + // Compute its quadrature + // contribution for each + // moment. + for (unsigned int i=0;i faces = QProjector::project_to_all_faces(face_points); for (;current::faces_per_cell*n_face_points; - ++current) - { - // Enter the support point - // into the vector - this->generalized_support_points[current] = faces.point(current); - } + ++current) + { + // Enter the support point + // into the vector + this->generalized_support_points[current] = faces.point(current); + } // Now initialise edge interior weights for the ABF elements. @@ -226,13 +226,13 @@ FE_ABF::initialize_support_points (const unsigned int deg) // for vector valued elements. boundary_weights_abf.reinit(faces.size(), polynomials_abf[0]->n() * dim); for (unsigned int k=0;k < faces.size();++k) - { - for (unsigned int i=0;in() * dim;++i) - { - boundary_weights_abf(k,i) = polynomials_abf[i%dim]-> - compute_value(i / dim, faces.point(k)) * faces.weight(k); - } - } + { + for (unsigned int i=0;in() * dim;++i) + { + boundary_weights_abf(k,i) = polynomials_abf[i%dim]-> + compute_value(i / dim, faces.point(k)) * faces.weight(k); + } + } } // Create Legendre basis for the @@ -242,27 +242,27 @@ FE_ABF::initialize_support_points (const unsigned int deg) std::vector* > polynomials(dim); for (unsigned int dd=0;dd > > poly(dim); - for (unsigned int d=0;d > > poly(dim); + for (unsigned int d=0;d(poly); - } + polynomials[dd] = new AnisotropicPolynomials(poly); + } interior_weights.reinit(TableIndices<3>(n_interior_points, polynomials[0]->n(), dim)); for (unsigned int k=0;kn();++i) - for (unsigned int d=0;dcompute_value(i,cell_quadrature.point(k)); - } + { + for (unsigned int i=0;in();++i) + for (unsigned int d=0;dcompute_value(i,cell_quadrature.point(k)); + } for (unsigned int d=0;d::initialize_support_points (const unsigned int deg) // behind the ABF elements is implemented. It is unclear, // if this really leads to the ABF spaces in 3D! interior_weights_abf.reinit(TableIndices<3>(cell_quadrature.size(), - polynomials_abf[0]->n() * dim, dim)); + polynomials_abf[0]->n() * dim, dim)); Tensor<1, dim> poly_grad; for (unsigned int k=0;kn() * dim;++i) - { - poly_grad = polynomials_abf[i%dim]->compute_grad(i / dim,cell_quadrature.point(k)) - * cell_quadrature.weight(k); - // The minus sign comes from the use of the Gauss theorem to replace the divergence. - for (unsigned int d=0;dcompute_grad(i / dim,cell_quadrature.point(k)) + * cell_quadrature.weight(k); + // The minus sign comes from the use of the Gauss theorem to replace the divergence. + for (unsigned int d=0;dgeneralized_support_points.size(), - ExcInternalError()); + ExcInternalError()); } @@ -318,87 +318,87 @@ FE_ABF::initialize_restriction() { unsigned int iso=RefinementCase::isotropic_refinement-1; for (unsigned int i=0;i::max_children_per_cell;++i) - this->restriction[iso][i].reinit(0,0); + this->restriction[iso][i].reinit(0,0); return; } unsigned int iso=RefinementCase::isotropic_refinement-1; QGauss q_base (rt_order+1); const unsigned int n_face_points = q_base.size(); - // First, compute interpolation on - // subfaces + // First, compute interpolation on + // subfaces for (unsigned int face=0;face::faces_per_cell;++face) { - // The shape functions of the - // child cell are evaluated - // in the quadrature points - // of a full face. + // The shape functions of the + // child cell are evaluated + // in the quadrature points + // of a full face. Quadrature q_face - = QProjector::project_to_face(q_base, face); - // Store shape values, since the - // evaluation suffers if not - // ordered by point + = QProjector::project_to_face(q_base, face); + // Store shape values, since the + // evaluation suffers if not + // ordered by point Table<2,double> cached_values(this->dofs_per_cell, q_face.size()); for (unsigned int k=0;kdofs_per_cell; ++i) - cached_values(i,k) - = this->shape_value_component(i, q_face.point(k), - GeometryInfo::unit_normal_direction[face]); + for (unsigned int i = 0; i < this->dofs_per_cell; ++i) + cached_values(i,k) + = this->shape_value_component(i, q_face.point(k), + GeometryInfo::unit_normal_direction[face]); for (unsigned int sub=0;sub::max_children_per_face;++sub) - { - // The weight fuctions for - // the coarse face are - // evaluated on the subface - // only. - Quadrature q_sub - = QProjector::project_to_subface(q_base, face, sub); - const unsigned int child - = GeometryInfo::child_cell_on_face( - RefinementCase::isotropic_refinement, face, sub); - - // On a certain face, we must - // compute the moments of ALL - // fine level functions with - // the coarse level weight - // functions belonging to - // that face. Due to the - // orthogonalization process - // when building the shape - // functions, these weights - // are equal to the - // corresponding shpe - // functions. - for (unsigned int k=0;kdofs_per_cell; ++i_child) - for (unsigned int i_face = 0; i_face < this->dofs_per_face; ++i_face) - { - // The quadrature - // weights on the - // subcell are NOT - // transformed, so we - // have to do it here. - this->restriction[iso][child](face*this->dofs_per_face+i_face, - i_child) - += Utilities::fixed_power(.5) * q_sub.weight(k) - * cached_values(i_child, k) - * this->shape_value_component(face*this->dofs_per_face+i_face, - q_sub.point(k), - GeometryInfo::unit_normal_direction[face]); - } - } + { + // The weight fuctions for + // the coarse face are + // evaluated on the subface + // only. + Quadrature q_sub + = QProjector::project_to_subface(q_base, face, sub); + const unsigned int child + = GeometryInfo::child_cell_on_face( + RefinementCase::isotropic_refinement, face, sub); + + // On a certain face, we must + // compute the moments of ALL + // fine level functions with + // the coarse level weight + // functions belonging to + // that face. Due to the + // orthogonalization process + // when building the shape + // functions, these weights + // are equal to the + // corresponding shpe + // functions. + for (unsigned int k=0;kdofs_per_cell; ++i_child) + for (unsigned int i_face = 0; i_face < this->dofs_per_face; ++i_face) + { + // The quadrature + // weights on the + // subcell are NOT + // transformed, so we + // have to do it here. + this->restriction[iso][child](face*this->dofs_per_face+i_face, + i_child) + += Utilities::fixed_power(.5) * q_sub.weight(k) + * cached_values(i_child, k) + * this->shape_value_component(face*this->dofs_per_face+i_face, + q_sub.point(k), + GeometryInfo::unit_normal_direction[face]); + } + } } if (rt_order==0) return; - // Create Legendre basis for the - // space D_xi Q_k. Here, we cannot - // use the shape functions + // Create Legendre basis for the + // space D_xi Q_k. Here, we cannot + // use the shape functions std::vector* > polynomials(dim); for (unsigned int dd=0;dd > > poly(dim); for (unsigned int d=0;d(poly); @@ -408,30 +408,30 @@ FE_ABF::initialize_restriction() const unsigned int start_cell_dofs = GeometryInfo::faces_per_cell*this->dofs_per_face; - // Store shape values, since the - // evaluation suffers if not - // ordered by point + // Store shape values, since the + // evaluation suffers if not + // ordered by point Table<3,double> cached_values(this->dofs_per_cell, q_cell.size(), dim); for (unsigned int k=0;kdofs_per_cell; ++i) for (unsigned int d=0;dshape_value_component(i, q_cell.point(k), d); + cached_values(i,k,d) = this->shape_value_component(i, q_cell.point(k), d); for (unsigned int child=0;child::max_children_per_cell;++child) { Quadrature q_sub = QProjector::project_to_child(q_cell, child); for (unsigned int k=0;kdofs_per_cell; ++i_child) - for (unsigned int d=0;dn();++i_weight) - { - this->restriction[iso][child](start_cell_dofs+i_weight*dim+d, - i_child) - += q_sub.weight(k) - * cached_values(i_child, k, d) - * polynomials[d]->compute_value(i_weight, q_sub.point(k)); - } + for (unsigned int i_child = 0; i_child < this->dofs_per_cell; ++i_child) + for (unsigned int d=0;dn();++i_weight) + { + this->restriction[iso][child](start_cell_dofs+i_weight*dim+d, + i_child) + += q_sub.weight(k) + * cached_values(i_child, k, d) + * polynomials[d]->compute_value(i_weight, q_sub.point(k)); + } } for (unsigned int d=0;d UpdateFlags FE_ABF::update_once (const UpdateFlags) const { - // even the values have to be - // computed on the real cell, so - // nothing can be done in advance + // even the values have to be + // computed on the real cell, so + // nothing can be done in advance return update_default; } @@ -517,13 +517,13 @@ FE_ABF::has_support_on_face (const unsigned int shape_index, const unsigned int face_index) const { Assert (shape_index < this->dofs_per_cell, - ExcIndexRange (shape_index, 0, this->dofs_per_cell)); + ExcIndexRange (shape_index, 0, this->dofs_per_cell)); Assert (face_index < GeometryInfo::faces_per_cell, - ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); - // Return computed values if we - // know them easily. Otherwise, it - // is always safe to return true. + // Return computed values if we + // know them easily. Otherwise, it + // is always safe to return true. switch (rt_order) { case 0: @@ -541,12 +541,12 @@ FE_ABF::has_support_on_face (const unsigned int shape_index, } default: - return true; + return true; }; }; default: // other rt_order - return true; + return true; }; return true; @@ -573,11 +573,11 @@ FE_ABF::interpolate( unsigned int offset) const { Assert (values.size() == this->generalized_support_points.size(), - ExcDimensionMismatch(values.size(), this->generalized_support_points.size())); + ExcDimensionMismatch(values.size(), this->generalized_support_points.size())); Assert (local_dofs.size() == this->dofs_per_cell, - ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); + ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); Assert (values[0].size() >= offset+this->n_components(), - ExcDimensionMismatch(values[0].size(),offset+this->n_components())); + ExcDimensionMismatch(values[0].size(),offset+this->n_components())); std::fill(local_dofs.begin(), local_dofs.end(), 0.); @@ -586,8 +586,8 @@ FE_ABF::interpolate( for (unsigned int k=0;kdofs_per_face] += boundary_weights(k,i) - * values[face*n_face_points+k](GeometryInfo::unit_normal_direction[face]+offset); + local_dofs[i+face*this->dofs_per_face] += boundary_weights(k,i) + * values[face*n_face_points+k](GeometryInfo::unit_normal_direction[face]+offset); } const unsigned start_cell_dofs = GeometryInfo::faces_per_cell*this->dofs_per_face; @@ -596,7 +596,7 @@ FE_ABF::interpolate( for (unsigned int k=0;k::interpolate( for (unsigned int k=0;k::faces_per_cell; ++face) { double n_orient = (double) GeometryInfo::unit_normal_orientation[face]; for (unsigned int fp=0; fp < n_face_points; ++fp) - { - // TODO: Check what the face_orientation, face_flip and face_rotation have to be in 3D - unsigned int k = QProjector::DataSetDescriptor::face (face, false, false, false, n_face_points); - for (unsigned int i=0; i::unit_normal_direction[face]+offset); - } + { + // TODO: Check what the face_orientation, face_flip and face_rotation have to be in 3D + unsigned int k = QProjector::DataSetDescriptor::face (face, false, false, false, n_face_points); + for (unsigned int i=0; i::unit_normal_direction[face]+offset); + } } // TODO: Check if this "correction" can be removed. @@ -633,11 +633,11 @@ FE_ABF::interpolate( const VectorSlice > >& values) const { Assert (values.size() == this->n_components(), - ExcDimensionMismatch(values.size(), this->n_components())); + ExcDimensionMismatch(values.size(), this->n_components())); Assert (values[0].size() == this->generalized_support_points.size(), - ExcDimensionMismatch(values[0].size(), this->generalized_support_points.size())); + ExcDimensionMismatch(values[0].size(), this->generalized_support_points.size())); Assert (local_dofs.size() == this->dofs_per_cell, - ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); + ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); std::fill(local_dofs.begin(), local_dofs.end(), 0.); @@ -646,8 +646,8 @@ FE_ABF::interpolate( for (unsigned int k=0;kdofs_per_face] += boundary_weights(k,i) - * values[GeometryInfo::unit_normal_direction[face]][face*n_face_points+k]; + local_dofs[i+face*this->dofs_per_face] += boundary_weights(k,i) + * values[GeometryInfo::unit_normal_direction[face]][face*n_face_points+k]; } const unsigned start_cell_dofs = GeometryInfo::faces_per_cell*this->dofs_per_face; @@ -656,7 +656,7 @@ FE_ABF::interpolate( for (unsigned int k=0;k::interpolate( for (unsigned int k=0;k::faces_per_cell; ++face) { double n_orient = (double) GeometryInfo::unit_normal_orientation[face]; for (unsigned int fp=0; fp < n_face_points; ++fp) - { - // TODO: Check what the face_orientation, face_flip and face_rotation have to be in 3D - unsigned int k = QProjector::DataSetDescriptor::face (face, false, false, false, n_face_points); - for (unsigned int i=0; i::unit_normal_direction[face]][k + fp]; - } + { + // TODO: Check what the face_orientation, face_flip and face_rotation have to be in 3D + unsigned int k = QProjector::DataSetDescriptor::face (face, false, false, false, n_face_points); + for (unsigned int i=0; i::unit_normal_direction[face]][k + fp]; + } } // TODO: Check if this "correction" can be removed. diff --git a/deal.II/source/fe/fe_bdm.cc b/deal.II/source/fe/fe_bdm.cc index 6c5fb6bce2..8fc6db5639 100644 --- a/deal.II/source/fe/fe_bdm.cc +++ b/deal.II/source/fe/fe_bdm.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -32,67 +32,67 @@ DEAL_II_NAMESPACE_OPEN template FE_BDM::FE_BDM (const unsigned int deg) - : - FE_PolyTensor, dim> ( - deg, - FiniteElementData(get_dpo_vector(deg), - dim, deg+1, FiniteElementData::Hdiv, 1), - get_ria_vector (deg), - std::vector >(PolynomialsBDM::compute_n_pols(deg), - std::vector(dim,true))) + : + FE_PolyTensor, dim> ( + deg, + FiniteElementData(get_dpo_vector(deg), + dim, deg+1, FiniteElementData::Hdiv, 1), + get_ria_vector (deg), + std::vector >(PolynomialsBDM::compute_n_pols(deg), + std::vector(dim,true))) { Assert (dim >= 2, ExcImpossibleInDim(dim)); Assert (dim<3, ExcNotImplemented()); Assert (deg > 0, ExcMessage("Lowest order BDM element are degree 1, but you asked for degree 0")); - + const unsigned int n_dofs = this->dofs_per_cell; - + this->mapping_type = mapping_piola; - // These must be done first, since - // they change the evaluation of - // basis functions + // These must be done first, since + // they change the evaluation of + // basis functions - // Set up the generalized support - // points + // Set up the generalized support + // points initialize_support_points (deg); - //Now compute the inverse node - //matrix, generating the correct - //basis functions from the raw - //ones. - - // We use an auxiliary matrix in - // this function. Therefore, - // inverse_node_matrix is still - // empty and shape_value_component - // returns the 'raw' shape values. + //Now compute the inverse node + //matrix, generating the correct + //basis functions from the raw + //ones. + + // We use an auxiliary matrix in + // this function. Therefore, + // inverse_node_matrix is still + // empty and shape_value_component + // returns the 'raw' shape values. FullMatrix M(n_dofs, n_dofs); FETools::compute_node_matrix(M, *this); // std::cout << std::endl; // M.print_formatted(std::cout, 2, true); - + this->inverse_node_matrix.reinit(n_dofs, n_dofs); this->inverse_node_matrix.invert(M); - // From now on, the shape functions - // will be the correct ones, not - // the raw shape functions anymore. - + // From now on, the shape functions + // will be the correct ones, not + // the raw shape functions anymore. + this->reinit_restriction_and_prolongation_matrices(true, true); FETools::compute_embedding_matrices (*this, this->prolongation, true); - + FullMatrix face_embeddings[GeometryInfo::max_children_per_face]; for (unsigned int i=0; i::max_children_per_face; ++i) face_embeddings[i].reinit (this->dofs_per_face, this->dofs_per_face); FETools::compute_face_embedding_matrices(*this, face_embeddings, 0, 0); this->interface_constraints.reinit((1<<(dim-1)) * this->dofs_per_face, - this->dofs_per_face); + this->dofs_per_face); unsigned int target_row=0; for (unsigned int d=0;d::max_children_per_face;++d) for (unsigned int i=0;iinterface_constraints(target_row,j) = face_embeddings[d](i,j); - ++target_row; + for (unsigned int j=0;jinterface_constraints(target_row,j) = face_embeddings[d](i,j); + ++target_row; } } @@ -102,18 +102,18 @@ template std::string FE_BDM::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch - - // note that this->degree is the maximal - // polynomial degree and is thus one higher - // than the argument given to the - // constructor - std::ostringstream namebuf; + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch + + // note that this->degree is the maximal + // polynomial degree and is thus one higher + // than the argument given to the + // constructor + std::ostringstream namebuf; namebuf << "FE_BDM<" << dim << ">(" << this->degree-1 << ")"; return namebuf.str(); @@ -159,50 +159,50 @@ FE_BDM::interpolate( { AssertDimension (values.size(), dim); Assert (values[0].size() == this->generalized_support_points.size(), - ExcDimensionMismatch(values.size(), this->generalized_support_points.size())); + ExcDimensionMismatch(values.size(), this->generalized_support_points.size())); Assert (local_dofs.size() == this->dofs_per_cell, - ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); - // First do interpolation on - // faces. There, the component - // evaluated depends on the face - // direction and orientation. + ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); + // First do interpolation on + // faces. There, the component + // evaluated depends on the face + // direction and orientation. unsigned int fbase = 0; unsigned int f=0; for (;f::faces_per_cell; ++f, fbase+=this->dofs_per_face) { for (unsigned int i=0;idofs_per_face;++i) - { - local_dofs[fbase+i] = values[GeometryInfo::unit_normal_direction[f]][fbase+i]; - } + { + local_dofs[fbase+i] = values[GeometryInfo::unit_normal_direction[f]][fbase+i]; + } } - // Done for BDM1 + // Done for BDM1 if (fbase == this->dofs_per_cell) return; - - // What's missing are the interior - // degrees of freedom. In each - // point, we take all components of - // the solution. + + // What's missing are the interior + // degrees of freedom. In each + // point, we take all components of + // the solution. Assert ((this->dofs_per_cell - fbase) % dim == 0, ExcInternalError()); - // Here, the number of the point - // and of the shape function - // coincides. This will change - // below, since we have more - // support points than test - // functions in the interior. + // Here, the number of the point + // and of the shape function + // coincides. This will change + // below, since we have more + // support points than test + // functions in the interior. const unsigned int pbase = fbase; for (unsigned int d=0;ddofs_per_cell, ExcInternalError()); } @@ -227,11 +227,11 @@ FE_BDM::get_dpo_vector (const unsigned int deg) interior_dofs *= deg-2; interior_dofs /= 3; } - + std::vector dpo(dim+1); dpo[dim-1] = dofs_per_face; dpo[dim] = interior_dofs; - + return dpo; } @@ -250,11 +250,11 @@ FE_BDM::get_ria_vector (const unsigned int deg) Assert(dim==2, ExcNotImplemented()); const unsigned int dofs_per_cell = PolynomialsBDM::compute_n_pols(deg); const unsigned int dofs_per_face = deg+1; - // all dofs need to be - // non-additive, since they have - // continuity requirements. - // however, the interior dofs are - // made additive + // all dofs need to be + // non-additive, since they have + // continuity requirements. + // however, the interior dofs are + // made additive std::vector ret_val(dofs_per_cell,false); for (unsigned int i=GeometryInfo::faces_per_cell*dofs_per_face; i < dofs_per_cell; ++i) @@ -268,89 +268,89 @@ template void FE_BDM::initialize_support_points (const unsigned int deg) { - // interior point in 1d + // interior point in 1d unsigned int npoints = deg; - // interior point in 2d + // interior point in 2d if (dim >= 2) { npoints *= deg; // npoints /= 2; } - // interior point in 2d + // interior point in 2d if (dim >= 3) { npoints *= deg; // npoints /= 3; } npoints += GeometryInfo::faces_per_cell * this->dofs_per_face; - + this->generalized_support_points.resize (npoints); this->generalized_face_support_points.resize (this->dofs_per_face); - // Number of the point being entered + // Number of the point being entered unsigned int current = 0; - // On the faces, we choose as many - // Gauss points as necessary to - // determine the normal component - // uniquely. This is the deg of - // the BDM element plus - // one. + // On the faces, we choose as many + // Gauss points as necessary to + // determine the normal component + // uniquely. This is the deg of + // the BDM element plus + // one. if (dim>1) { QGauss face_points (deg+1); Assert (face_points.size() == this->dofs_per_face, - ExcInternalError()); + ExcInternalError()); for (unsigned int k=0;kdofs_per_face;++k) - this->generalized_face_support_points[k] = face_points.point(k); + this->generalized_face_support_points[k] = face_points.point(k); Quadrature faces = QProjector::project_to_all_faces(face_points); for (unsigned int k=0; - kdofs_per_face*GeometryInfo::faces_per_cell; - ++k) - this->generalized_support_points[k] = faces.point(k+QProjector - ::DataSetDescriptor::face(0, - true, - false, - false, - this->dofs_per_face)); + kdofs_per_face*GeometryInfo::faces_per_cell; + ++k) + this->generalized_support_points[k] = faces.point(k+QProjector + ::DataSetDescriptor::face(0, + true, + false, + false, + this->dofs_per_face)); current = this->dofs_per_face*GeometryInfo::faces_per_cell; } - + if (deg<=1) return; - // Although the polynomial space is - // only P_{k-2}, we use the tensor - // product points for Q_{k-2} + // Although the polynomial space is + // only P_{k-2}, we use the tensor + // product points for Q_{k-2} QGauss quadrature(deg); - - // Remember where interior points start + + // Remember where interior points start const unsigned int ibase=current; // for (unsigned int k=0;kgeneralized_support_points[current] = quadrature.point(current-ibase); - ++current; + this->generalized_support_points[current] = quadrature.point(current-ibase); + ++current; } Assert(current == npoints, ExcInternalError()); - // Finaly, compute the values of - // the test functios in the - // interior quadrature points + // Finaly, compute the values of + // the test functios in the + // interior quadrature points PolynomialsP poly(deg-2); - + test_values.resize(quadrature.size()); std::vector > dummy1; std::vector > dummy2; - + for (unsigned int k=0;k FiniteElementData::FiniteElementData () : - dofs_per_vertex(0), - dofs_per_line(0), - dofs_per_quad(0), - dofs_per_hex(0), - first_line_index(0), - first_quad_index(0), - first_hex_index(0), - first_face_line_index(0), - first_face_quad_index(0), - dofs_per_face(0), - dofs_per_cell (0), - components(0), - degree(0), - conforming_space(unknown), - cached_primitivity(false) + dofs_per_vertex(0), + dofs_per_line(0), + dofs_per_quad(0), + dofs_per_hex(0), + first_line_index(0), + first_quad_index(0), + first_hex_index(0), + first_face_line_index(0), + first_face_quad_index(0), + dofs_per_face(0), + dofs_per_cell (0), + components(0), + degree(0), + conforming_space(unknown), + cached_primitivity(false) {} @@ -44,41 +44,41 @@ FiniteElementData:: FiniteElementData (const std::vector &dofs_per_object, const unsigned int n_components, const unsigned int degree, - const Conformity conformity, - const unsigned int) + const Conformity conformity, + const unsigned int) : - dofs_per_vertex(dofs_per_object[0]), - dofs_per_line(dofs_per_object[1]), - dofs_per_quad(dim>1? dofs_per_object[2]:0), - dofs_per_hex(dim>2? dofs_per_object[3]:0), - first_line_index(GeometryInfo::vertices_per_cell - * dofs_per_vertex), - first_quad_index(first_line_index+ - GeometryInfo::lines_per_cell - * dofs_per_line), - first_hex_index(first_quad_index+ - GeometryInfo::quads_per_cell - * dofs_per_quad), - first_face_line_index(GeometryInfo::vertices_per_cell - * dofs_per_vertex), - first_face_quad_index((dim==3 ? - GeometryInfo::vertices_per_cell - * dofs_per_vertex : - GeometryInfo::vertices_per_cell - * dofs_per_vertex) + - GeometryInfo::lines_per_cell - * dofs_per_line), - dofs_per_face(GeometryInfo::vertices_per_face * dofs_per_vertex + - GeometryInfo::lines_per_face * dofs_per_line + - GeometryInfo::quads_per_face * dofs_per_quad), - dofs_per_cell (GeometryInfo::vertices_per_cell * dofs_per_vertex + - GeometryInfo::lines_per_cell * dofs_per_line + - GeometryInfo::quads_per_cell * dofs_per_quad + - GeometryInfo::hexes_per_cell * dofs_per_hex), - components(n_components), - degree(degree), - conforming_space(conformity), - block_indices_data(1, dofs_per_cell) + dofs_per_vertex(dofs_per_object[0]), + dofs_per_line(dofs_per_object[1]), + dofs_per_quad(dim>1? dofs_per_object[2]:0), + dofs_per_hex(dim>2? dofs_per_object[3]:0), + first_line_index(GeometryInfo::vertices_per_cell + * dofs_per_vertex), + first_quad_index(first_line_index+ + GeometryInfo::lines_per_cell + * dofs_per_line), + first_hex_index(first_quad_index+ + GeometryInfo::quads_per_cell + * dofs_per_quad), + first_face_line_index(GeometryInfo::vertices_per_cell + * dofs_per_vertex), + first_face_quad_index((dim==3 ? + GeometryInfo::vertices_per_cell + * dofs_per_vertex : + GeometryInfo::vertices_per_cell + * dofs_per_vertex) + + GeometryInfo::lines_per_cell + * dofs_per_line), + dofs_per_face(GeometryInfo::vertices_per_face * dofs_per_vertex + + GeometryInfo::lines_per_face * dofs_per_line + + GeometryInfo::quads_per_face * dofs_per_quad), + dofs_per_cell (GeometryInfo::vertices_per_cell * dofs_per_vertex + + GeometryInfo::lines_per_cell * dofs_per_line + + GeometryInfo::quads_per_cell * dofs_per_quad + + GeometryInfo::hexes_per_cell * dofs_per_hex), + components(n_components), + degree(degree), + conforming_space(conformity), + block_indices_data(1, dofs_per_cell) { Assert(dofs_per_object.size()==dim+1, ExcDimensionMismatch(dofs_per_object.size()-1,dim)); } @@ -89,57 +89,57 @@ template bool FiniteElementData::operator== (const FiniteElementData &f) const { return ((dofs_per_vertex == f.dofs_per_vertex) && - (dofs_per_line == f.dofs_per_line) && - (dofs_per_quad == f.dofs_per_quad) && - (dofs_per_hex == f.dofs_per_hex) && - (components == f.components) && - (degree == f.degree) && - (conforming_space == f.conforming_space)); + (dofs_per_line == f.dofs_per_line) && + (dofs_per_quad == f.dofs_per_quad) && + (dofs_per_hex == f.dofs_per_hex) && + (components == f.components) && + (degree == f.degree) && + (conforming_space == f.conforming_space)); } template unsigned int FiniteElementData:: face_to_cell_index (const unsigned int face_index, - const unsigned int face, - const bool face_orientation, - const bool face_flip, - const bool face_rotation) const + const unsigned int face, + const bool face_orientation, + const bool face_flip, + const bool face_rotation) const { Assert (face_index < this->dofs_per_face, - ExcIndexRange(face_index, 0, this->dofs_per_face)); + ExcIndexRange(face_index, 0, this->dofs_per_face)); Assert (face < GeometryInfo::faces_per_cell, - ExcIndexRange(face, 0, GeometryInfo::faces_per_cell)); - - // DoF on a vertex + ExcIndexRange(face, 0, GeometryInfo::faces_per_cell)); + + // DoF on a vertex if (face_index < this->first_face_line_index) { - // Vertex number on the face + // Vertex number on the face const unsigned int face_vertex = face_index / this->dofs_per_vertex; return face_index % this->dofs_per_vertex - + GeometryInfo::face_to_cell_vertices(face, face_vertex, - face_orientation, - face_flip, - face_rotation) - * this->dofs_per_vertex; + + GeometryInfo::face_to_cell_vertices(face, face_vertex, + face_orientation, + face_flip, + face_rotation) + * this->dofs_per_vertex; } - // Else, DoF on a line? + // Else, DoF on a line? if (face_index < this->first_face_quad_index) { - // Ignore vertex dofs + // Ignore vertex dofs const unsigned int index = face_index - this->first_face_line_index; - // Line number on the face + // Line number on the face const unsigned int face_line = index / this->dofs_per_line; return this->first_line_index + index % this->dofs_per_line - + GeometryInfo::face_to_cell_lines(face, face_line, - face_orientation, - face_flip, - face_rotation) - * this->dofs_per_line; + + GeometryInfo::face_to_cell_lines(face, face_line, + face_orientation, + face_flip, + face_rotation) + * this->dofs_per_line; } - // Else, DoF is on a quad + // Else, DoF is on a quad - // Ignore vertex and line dofs + // Ignore vertex and line dofs const unsigned int index = face_index - this->first_face_quad_index; return this->first_quad_index + index + face * this->dofs_per_quad; diff --git a/deal.II/source/fe/fe_dg_vector.cc b/deal.II/source/fe/fe_dg_vector.cc index 87bf348619..da639fbceb 100644 --- a/deal.II/source/fe/fe_dg_vector.cc +++ b/deal.II/source/fe/fe_dg_vector.cc @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 2010 by the deal.II authors +// Copyright (C) 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -28,12 +28,12 @@ template std::string FE_DGNedelec::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch std::ostringstream namebuf; namebuf << "FE_DGNedelec<" << dim << ',' << spacedim << ">(" << this->degree-1 << ")"; @@ -52,12 +52,12 @@ template std::string FE_DGRaviartThomas::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch std::ostringstream namebuf; namebuf << "FE_DGRaviartThomas<" << dim << ',' << spacedim << ">(" << this->degree-1 << ")"; @@ -76,12 +76,12 @@ template std::string FE_DGBDM::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch std::ostringstream namebuf; namebuf << "FE_DGBDM<" << dim << ',' << spacedim << ">(" << this->degree-1 << ")"; diff --git a/deal.II/source/fe/fe_dgp.cc b/deal.II/source/fe/fe_dgp.cc index a1a1fdfe21..f2f1201d7c 100644 --- a/deal.II/source/fe/fe_dgp.cc +++ b/deal.II/source/fe/fe_dgp.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011 by the deal.II authors +// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -20,23 +20,23 @@ DEAL_II_NAMESPACE_OPEN template FE_DGP::FE_DGP (const unsigned int degree) - : + : FE_Poly, dim, spacedim> ( - PolynomialSpace(Polynomials::Legendre::generate_complete_basis(degree)), - FiniteElementData(get_dpo_vector(degree), 1, degree, FiniteElementData::L2), - std::vector(FiniteElementData(get_dpo_vector(degree), 1, degree).dofs_per_cell,true), - std::vector >(FiniteElementData( - get_dpo_vector(degree), 1, degree).dofs_per_cell, std::vector(1,true))) + PolynomialSpace(Polynomials::Legendre::generate_complete_basis(degree)), + FiniteElementData(get_dpo_vector(degree), 1, degree, FiniteElementData::L2), + std::vector(FiniteElementData(get_dpo_vector(degree), 1, degree).dofs_per_cell,true), + std::vector >(FiniteElementData( + get_dpo_vector(degree), 1, degree).dofs_per_cell, std::vector(1,true))) { - // Reinit the vectors of - // restriction and prolongation - // matrices to the right sizes + // Reinit the vectors of + // restriction and prolongation + // matrices to the right sizes this->reinit_restriction_and_prolongation_matrices(); - // Fill prolongation matrices with embedding operators + // Fill prolongation matrices with embedding operators if (dim == spacedim) { FETools::compute_embedding_matrices (*this, this->prolongation); - // Fill restriction matrices with L2-projection + // Fill restriction matrices with L2-projection FETools::compute_projection_matrices (*this, this->restriction); } } @@ -46,12 +46,12 @@ template std::string FE_DGP::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch std::ostringstream namebuf; namebuf << "FE_DGP<" << dim << ">(" << this->degree << ")"; @@ -95,14 +95,14 @@ template void FE_DGP:: get_face_interpolation_matrix (const FiniteElement &x_source_fe, - FullMatrix &interpolation_matrix) const + FullMatrix &interpolation_matrix) const { - // this is only implemented, if the source - // FE is also a DGP element. in that case, - // both elements have no dofs on their - // faces and the face interpolation matrix - // is necessarily empty -- i.e. there isn't - // much we need to do here. + // this is only implemented, if the source + // FE is also a DGP element. in that case, + // both elements have no dofs on their + // faces and the face interpolation matrix + // is necessarily empty -- i.e. there isn't + // much we need to do here. typedef FiniteElement FE; typedef FE_DGP FEDGP; AssertThrow ((x_source_fe.get_name().find ("FE_DGP<") == 0) @@ -112,11 +112,11 @@ get_face_interpolation_matrix (const FiniteElement &x_source_fe, ExcInterpolationNotImplemented()); Assert (interpolation_matrix.m() == 0, - ExcDimensionMismatch (interpolation_matrix.m(), - 0)); + ExcDimensionMismatch (interpolation_matrix.m(), + 0)); Assert (interpolation_matrix.n() == 0, - ExcDimensionMismatch (interpolation_matrix.n(), - 0)); + ExcDimensionMismatch (interpolation_matrix.n(), + 0)); } @@ -125,15 +125,15 @@ template void FE_DGP:: get_subface_interpolation_matrix (const FiniteElement &x_source_fe, - const unsigned int , - FullMatrix &interpolation_matrix) const + const unsigned int , + FullMatrix &interpolation_matrix) const { - // this is only implemented, if the source - // FE is also a DGP element. in that case, - // both elements have no dofs on their - // faces and the face interpolation matrix - // is necessarily empty -- i.e. there isn't - // much we need to do here. + // this is only implemented, if the source + // FE is also a DGP element. in that case, + // both elements have no dofs on their + // faces and the face interpolation matrix + // is necessarily empty -- i.e. there isn't + // much we need to do here. typedef FiniteElement FE; typedef FE_DGP FEDGP; AssertThrow ((x_source_fe.get_name().find ("FE_DGP<") == 0) @@ -143,11 +143,11 @@ get_subface_interpolation_matrix (const FiniteElement &x_source_fe ExcInterpolationNotImplemented()); Assert (interpolation_matrix.m() == 0, - ExcDimensionMismatch (interpolation_matrix.m(), - 0)); + ExcDimensionMismatch (interpolation_matrix.m(), + 0)); Assert (interpolation_matrix.n() == 0, - ExcDimensionMismatch (interpolation_matrix.n(), - 0)); + ExcDimensionMismatch (interpolation_matrix.n(), + 0)); } @@ -166,8 +166,8 @@ std::vector > FE_DGP:: hp_vertex_dof_identities (const FiniteElement &fe_other) const { - // there are no such constraints for DGP - // elements at all + // there are no such constraints for DGP + // elements at all if (dynamic_cast*>(&fe_other) != 0) return std::vector > (); @@ -185,8 +185,8 @@ std::vector > FE_DGP:: hp_line_dof_identities (const FiniteElement &fe_other) const { - // there are no such constraints for DGP - // elements at all + // there are no such constraints for DGP + // elements at all if (dynamic_cast*>(&fe_other) != 0) return std::vector > (); @@ -204,8 +204,8 @@ std::vector > FE_DGP:: hp_quad_dof_identities (const FiniteElement &fe_other) const { - // there are no such constraints for DGP - // elements at all + // there are no such constraints for DGP + // elements at all if (dynamic_cast*>(&fe_other) != 0) return std::vector > (); @@ -222,9 +222,9 @@ template FiniteElementDomination::Domination FE_DGP::compare_for_face_domination (const FiniteElement &fe_other) const { - // check whether both are discontinuous - // elements, see the description of - // FiniteElementDomination::Domination + // check whether both are discontinuous + // elements, see the description of + // FiniteElementDomination::Domination if (dynamic_cast*>(&fe_other) != 0) return FiniteElementDomination::no_requirements; @@ -237,7 +237,7 @@ FE_DGP::compare_for_face_domination (const FiniteElement bool FE_DGP::has_support_on_face (const unsigned int, - const unsigned int) const + const unsigned int) const { // all shape functions have support on all // faces diff --git a/deal.II/source/fe/fe_dgp_monomial.cc b/deal.II/source/fe/fe_dgp_monomial.cc index 6833bd383d..1adc333ca0 100644 --- a/deal.II/source/fe/fe_dgp_monomial.cc +++ b/deal.II/source/fe/fe_dgp_monomial.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -21,21 +21,21 @@ DEAL_II_NAMESPACE_OPEN // namespace for some functions that are used in this file. namespace { - // storage of hand-chosen support - // points - // - // For dim=2, dofs_per_cell of - // FE_DGPMonomial(k) is given by - // 0.5(k+1)(k+2), i.e. - // - // k 0 1 2 3 4 5 6 7 - // dofs 1 3 6 10 15 21 28 36 - // - // indirect access of unit points: - // the points for degree k are - // located at - // - // points[start_index[k]..start_index[k+1]-1] + // storage of hand-chosen support + // points + // + // For dim=2, dofs_per_cell of + // FE_DGPMonomial(k) is given by + // 0.5(k+1)(k+2), i.e. + // + // k 0 1 2 3 4 5 6 7 + // dofs 1 3 6 10 15 21 28 36 + // + // indirect access of unit points: + // the points for degree k are + // located at + // + // points[start_index[k]..start_index[k+1]-1] const unsigned int start_index2d[6]={0,1,4,10,20,35}; const double points2d[35][2]= {{0,0}, @@ -45,12 +45,12 @@ namespace {0,0},{1,0},{0,1},{1,1},{0.25,0},{0.5,0},{0.75,0},{0,0.25},{0,0.5},{0,0.75},{1./3.,1},{2./3.,1},{1,1./3.},{1,2./3.},{0.5,0.5} }; - // For dim=3, dofs_per_cell of - // FE_DGPMonomial(k) is given by - // 1./6.(k+1)(k+2)(k+3), i.e. - // - // k 0 1 2 3 4 5 6 7 - // dofs 1 4 10 20 35 56 84 120 + // For dim=3, dofs_per_cell of + // FE_DGPMonomial(k) is given by + // 1./6.(k+1)(k+2)(k+3), i.e. + // + // k 0 1 2 3 4 5 6 7 + // dofs 1 4 10 20 35 56 84 120 const unsigned int start_index3d[6]={0,1,5,15/*,35*/}; const double points3d[35][3]= {{0,0,0}, @@ -61,11 +61,11 @@ namespace template void generate_unit_points (const unsigned int, - std::vector > &); + std::vector > &); template <> void generate_unit_points (const unsigned int k, - std::vector > &p) + std::vector > &p) { Assert(p.size()==k+1, ExcDimensionMismatch(p.size(), k+1)); const double h = 1./k; @@ -75,28 +75,28 @@ namespace template <> void generate_unit_points (const unsigned int k, - std::vector > &p) + std::vector > &p) { Assert(k<=4, ExcNotImplemented()); Assert(p.size()==start_index2d[k+1]-start_index2d[k], ExcInternalError()); for (unsigned int i=0; i void generate_unit_points (const unsigned int k, - std::vector > &p) + std::vector > &p) { Assert(k<=2, ExcNotImplemented()); Assert(p.size()==start_index3d[k+1]-start_index3d[k], ExcInternalError()); for (unsigned int i=0; i FE_DGPMonomial::FE_DGPMonomial (const unsigned int degree) - : - FE_Poly, dim> ( - PolynomialsP(degree), - FiniteElementData(get_dpo_vector(degree), 1, degree, FiniteElementData::L2), - std::vector(FiniteElementData(get_dpo_vector(degree), 1, degree).dofs_per_cell,true), - std::vector >(FiniteElementData( - get_dpo_vector(degree), 1, degree).dofs_per_cell, std::vector(1,true))) + : + FE_Poly, dim> ( + PolynomialsP(degree), + FiniteElementData(get_dpo_vector(degree), 1, degree, FiniteElementData::L2), + std::vector(FiniteElementData(get_dpo_vector(degree), 1, degree).dofs_per_cell,true), + std::vector >(FiniteElementData( + get_dpo_vector(degree), 1, degree).dofs_per_cell, std::vector(1,true))) { Assert(this->poly_space.n()==this->dofs_per_cell, ExcInternalError()); Assert(this->poly_space.degree()==this->degree, ExcInternalError()); - // DG doesn't have constraints, so - // leave them empty + // DG doesn't have constraints, so + // leave them empty - // Reinit the vectors of - // restriction and prolongation - // matrices to the right sizes + // Reinit the vectors of + // restriction and prolongation + // matrices to the right sizes this->reinit_restriction_and_prolongation_matrices(); - // Fill prolongation matrices with embedding operators + // Fill prolongation matrices with embedding operators FETools::compute_embedding_matrices (*this, this->prolongation); - // Fill restriction matrices with L2-projection + // Fill restriction matrices with L2-projection FETools::compute_projection_matrices (*this, this->restriction); } @@ -135,12 +135,12 @@ template std::string FE_DGPMonomial::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch std::ostringstream namebuf; namebuf << "FE_DGPMonomial<" << dim << ">(" << this->degree << ")"; @@ -164,28 +164,28 @@ template void FE_DGPMonomial:: get_interpolation_matrix (const FiniteElement &source_fe, - FullMatrix &interpolation_matrix) const + FullMatrix &interpolation_matrix) const { const FE_DGPMonomial *source_dgp_monomial = dynamic_cast *>(&source_fe); if (source_dgp_monomial) { - // ok, source_fe is a DGP_Monomial - // element. Then, the interpolation - // matrix is simple + // ok, source_fe is a DGP_Monomial + // element. Then, the interpolation + // matrix is simple const unsigned int m=interpolation_matrix.m(); const unsigned int n=interpolation_matrix.n(); Assert (m == this->dofs_per_cell, ExcDimensionMismatch (m, this->dofs_per_cell)); Assert (n == source_dgp_monomial->dofs_per_cell, - ExcDimensionMismatch (n, source_dgp_monomial->dofs_per_cell)); + ExcDimensionMismatch (n, source_dgp_monomial->dofs_per_cell)); const unsigned int min_mn= - interpolation_matrix.m() &source_fe, FullMatrix source_fe_matrix(unit_points.size(), source_fe.dofs_per_cell); for (unsigned int j=0; j this_matrix(this->dofs_per_cell, this->dofs_per_cell); for (unsigned int j=0; jdofs_per_cell; ++j) - for (unsigned int k=0; kpoly_space.compute_value (j, unit_points[k]); + for (unsigned int k=0; kpoly_space.compute_value (j, unit_points[k]); this_matrix.gauss_jordan(); @@ -242,14 +242,14 @@ template void FE_DGPMonomial:: get_face_interpolation_matrix (const FiniteElement &x_source_fe, - FullMatrix &interpolation_matrix) const + FullMatrix &interpolation_matrix) const { - // this is only implemented, if the source - // FE is also a DGPMonomial element. in that case, - // both elements have no dofs on their - // faces and the face interpolation matrix - // is necessarily empty -- i.e. there isn't - // much we need to do here. + // this is only implemented, if the source + // FE is also a DGPMonomial element. in that case, + // both elements have no dofs on their + // faces and the face interpolation matrix + // is necessarily empty -- i.e. there isn't + // much we need to do here. AssertThrow ((x_source_fe.get_name().find ("FE_DGPMonomial<") == 0) || (dynamic_cast*>(&x_source_fe) != 0), @@ -257,11 +257,11 @@ get_face_interpolation_matrix (const FiniteElement &x_source_fe, ExcInterpolationNotImplemented()); Assert (interpolation_matrix.m() == 0, - ExcDimensionMismatch (interpolation_matrix.m(), - 0)); + ExcDimensionMismatch (interpolation_matrix.m(), + 0)); Assert (interpolation_matrix.n() == 0, - ExcDimensionMismatch (interpolation_matrix.n(), - 0)); + ExcDimensionMismatch (interpolation_matrix.n(), + 0)); } @@ -270,15 +270,15 @@ template void FE_DGPMonomial:: get_subface_interpolation_matrix (const FiniteElement &x_source_fe, - const unsigned int , - FullMatrix &interpolation_matrix) const + const unsigned int , + FullMatrix &interpolation_matrix) const { - // this is only implemented, if the source - // FE is also a DGPMonomial element. in that case, - // both elements have no dofs on their - // faces and the face interpolation matrix - // is necessarily empty -- i.e. there isn't - // much we need to do here. + // this is only implemented, if the source + // FE is also a DGPMonomial element. in that case, + // both elements have no dofs on their + // faces and the face interpolation matrix + // is necessarily empty -- i.e. there isn't + // much we need to do here. AssertThrow ((x_source_fe.get_name().find ("FE_DGPMonomial<") == 0) || (dynamic_cast*>(&x_source_fe) != 0), @@ -286,11 +286,11 @@ get_subface_interpolation_matrix (const FiniteElement &x_source_fe, ExcInterpolationNotImplemented()); Assert (interpolation_matrix.m() == 0, - ExcDimensionMismatch (interpolation_matrix.m(), - 0)); + ExcDimensionMismatch (interpolation_matrix.m(), + 0)); Assert (interpolation_matrix.n() == 0, - ExcDimensionMismatch (interpolation_matrix.n(), - 0)); + ExcDimensionMismatch (interpolation_matrix.n(), + 0)); } @@ -309,8 +309,8 @@ std::vector > FE_DGPMonomial:: hp_vertex_dof_identities (const FiniteElement &fe_other) const { - // there are no such constraints for DGPMonomial - // elements at all + // there are no such constraints for DGPMonomial + // elements at all if (dynamic_cast*>(&fe_other) != 0) return std::vector > (); @@ -328,8 +328,8 @@ std::vector > FE_DGPMonomial:: hp_line_dof_identities (const FiniteElement &fe_other) const { - // there are no such constraints for DGPMonomial - // elements at all + // there are no such constraints for DGPMonomial + // elements at all if (dynamic_cast*>(&fe_other) != 0) return std::vector > (); @@ -347,8 +347,8 @@ std::vector > FE_DGPMonomial:: hp_quad_dof_identities (const FiniteElement &fe_other) const { - // there are no such constraints for DGPMonomial - // elements at all + // there are no such constraints for DGPMonomial + // elements at all if (dynamic_cast*>(&fe_other) != 0) return std::vector > (); @@ -366,10 +366,10 @@ FiniteElementDomination::Domination FE_DGPMonomial:: compare_for_face_domination (const FiniteElement &fe_other) const { - // check whether both are discontinuous - // elements, see - // the description of - // FiniteElementDomination::Domination + // check whether both are discontinuous + // elements, see + // the description of + // FiniteElementDomination::Domination if (dynamic_cast*>(&fe_other) != 0) return FiniteElementDomination::no_requirements; @@ -382,7 +382,7 @@ compare_for_face_domination (const FiniteElement &fe_other) const template <> bool FE_DGPMonomial<1>::has_support_on_face (const unsigned int, - const unsigned int face_index) const + const unsigned int face_index) const { return face_index==1 || (face_index==0 && this->degree==0); } @@ -392,7 +392,7 @@ FE_DGPMonomial<1>::has_support_on_face (const unsigned int, template <> bool FE_DGPMonomial<2>::has_support_on_face (const unsigned int shape_index, - const unsigned int face_index) const + const unsigned int face_index) const { bool support_on_face=false; if (face_index==1 || face_index==2) @@ -402,8 +402,8 @@ FE_DGPMonomial<2>::has_support_on_face (const unsigned int shape_index, unsigned int degrees[2]; this->poly_space.directional_degrees(shape_index, degrees); if ((face_index==0 && degrees[1]==0) || - (face_index==3 && degrees[0]==0)) - support_on_face=true; + (face_index==3 && degrees[0]==0)) + support_on_face=true; } return support_on_face; } @@ -413,7 +413,7 @@ FE_DGPMonomial<2>::has_support_on_face (const unsigned int shape_index, template <> bool FE_DGPMonomial<3>::has_support_on_face (const unsigned int shape_index, - const unsigned int face_index) const + const unsigned int face_index) const { bool support_on_face=false; if (face_index==1 || face_index==3 || face_index==4) @@ -423,9 +423,9 @@ FE_DGPMonomial<3>::has_support_on_face (const unsigned int shape_index, unsigned int degrees[3]; this->poly_space.directional_degrees(shape_index, degrees); if ((face_index==0 && degrees[1]==0) || - (face_index==2 && degrees[2]==0) || - (face_index==5 && degrees[0]==0)) - support_on_face=true; + (face_index==2 && degrees[2]==0) || + (face_index==5 && degrees[0]==0)) + support_on_face=true; } return support_on_face; } diff --git a/deal.II/source/fe/fe_dgp_nonparametric.cc b/deal.II/source/fe/fe_dgp_nonparametric.cc index 1df24ade4d..850c57e586 100644 --- a/deal.II/source/fe/fe_dgp_nonparametric.cc +++ b/deal.II/source/fe/fe_dgp_nonparametric.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011 by the deal.II authors +// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -26,15 +26,15 @@ DEAL_II_NAMESPACE_OPEN template FE_DGPNonparametric::FE_DGPNonparametric (const unsigned int degree) - : - FiniteElement ( - FiniteElementData(get_dpo_vector(degree), 1, degree, - FiniteElementData::L2), - std::vector( - FiniteElementData(get_dpo_vector(degree), 1, degree).dofs_per_cell,true), - std::vector >( - FiniteElementData(get_dpo_vector(degree),1, degree).dofs_per_cell, - std::vector(1,true))), + : + FiniteElement ( + FiniteElementData(get_dpo_vector(degree), 1, degree, + FiniteElementData::L2), + std::vector( + FiniteElementData(get_dpo_vector(degree), 1, degree).dofs_per_cell,true), + std::vector >( + FiniteElementData(get_dpo_vector(degree),1, degree).dofs_per_cell, + std::vector(1,true))), degree(degree), polynomial_space (Polynomials::Legendre::generate_complete_basis(degree)) { @@ -43,20 +43,20 @@ FE_DGPNonparametric::FE_DGPNonparametric (const unsigned int degre ref_case::isotropic_refinement+1; ++ref_case) { if (dim!=2 && ref_case!=RefinementCase::isotropic_refinement) - // do nothing, as anisotropic - // refinement is not - // implemented so far - continue; + // do nothing, as anisotropic + // refinement is not + // implemented so far + continue; const unsigned int nc = GeometryInfo::n_children(RefinementCase(ref_case)); for (unsigned int i=0;iprolongation[ref_case-1][i].reinit (n_dofs, n_dofs); - // Fill prolongation matrices with - // embedding operators - for (unsigned int j=0;jprolongation[ref_case-1][i](j,j) = 1.; - } + { + this->prolongation[ref_case-1][i].reinit (n_dofs, n_dofs); + // Fill prolongation matrices with + // embedding operators + for (unsigned int j=0;jprolongation[ref_case-1][i](j,j) = 1.; + } } // restriction can be defined @@ -73,7 +73,7 @@ FE_DGPNonparametric::FE_DGPNonparametric (const unsigned int degre // restriction[0].fill (Matrices::projection_matrices[degree]); // } // else -// // matrix undefined, set size to zero +// // matrix undefined, set size to zero // for (unsigned int i=0;i::max_children_per_cell;++i) // restriction[i].reinit(0, 0); // since not implemented, set to @@ -94,12 +94,12 @@ template std::string FE_DGPNonparametric::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch std::ostringstream namebuf; namebuf << "FE_DGPNonparametric<" << dim << ">(" << degree << ")"; @@ -121,7 +121,7 @@ FE_DGPNonparametric::clone() const template double FE_DGPNonparametric::shape_value (const unsigned int i, - const Point &p) const + const Point &p) const { Assert (idofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell)); return polynomial_space.compute_value(i, p); @@ -132,8 +132,8 @@ FE_DGPNonparametric::shape_value (const unsigned int i, template double FE_DGPNonparametric::shape_value_component (const unsigned int i, - const Point &p, - const unsigned int component) const + const Point &p, + const unsigned int component) const { Assert (idofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell)); Assert (component == 0, ExcIndexRange (component, 0, 1)); @@ -145,7 +145,7 @@ FE_DGPNonparametric::shape_value_component (const unsigned int i, template Tensor<1,dim> FE_DGPNonparametric::shape_grad (const unsigned int i, - const Point &p) const + const Point &p) const { Assert (idofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell)); return polynomial_space.compute_grad(i, p); @@ -155,8 +155,8 @@ FE_DGPNonparametric::shape_grad (const unsigned int i, template Tensor<1,dim> FE_DGPNonparametric::shape_grad_component (const unsigned int i, - const Point &p, - const unsigned int component) const + const Point &p, + const unsigned int component) const { Assert (idofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell)); Assert (component == 0, ExcIndexRange (component, 0, 1)); @@ -168,7 +168,7 @@ FE_DGPNonparametric::shape_grad_component (const unsigned int i, template Tensor<2,dim> FE_DGPNonparametric::shape_grad_grad (const unsigned int i, - const Point &p) const + const Point &p) const { Assert (idofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell)); return polynomial_space.compute_grad_grad(i, p); @@ -179,8 +179,8 @@ FE_DGPNonparametric::shape_grad_grad (const unsigned int i, template Tensor<2,dim> FE_DGPNonparametric::shape_grad_grad_component (const unsigned int i, - const Point &p, - const unsigned int component) const + const Point &p, + const unsigned int component) const { Assert (idofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell)); Assert (component == 0, ExcIndexRange (component, 0, 1)); @@ -212,11 +212,11 @@ template UpdateFlags FE_DGPNonparametric::update_once (const UpdateFlags) const { - // for this kind of elements, only - // the values can be precomputed - // once and for all. set this flag - // if the values are requested at - // all + // for this kind of elements, only + // the values can be precomputed + // once and for all. set this flag + // if the values are requested at + // all return update_default; } @@ -245,21 +245,21 @@ FE_DGPNonparametric::get_data ( const Mapping&, const Quadrature&) const { - // generate a new data object + // generate a new data object InternalData* data = new InternalData; - // check what needs to be - // initialized only once and what - // on every cell/face/subface we - // visit + // check what needs to be + // initialized only once and what + // on every cell/face/subface we + // visit data->update_once = update_once(update_flags); data->update_each = update_each(update_flags); data->update_flags = data->update_once | data->update_each; const UpdateFlags flags(data->update_flags); - // initialize fields only if really - // necessary. otherwise, don't - // allocate memory + // initialize fields only if really + // necessary. otherwise, don't + // allocate memory if (flags & update_values) { data->values.resize (this->dofs_per_cell); @@ -294,12 +294,12 @@ FE_DGPNonparametric::fill_fe_values ( FEValuesData&data, CellSimilarity::Similarity &/*cell_similarity*/) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&fedata) != 0, - ExcInternalError()); + ExcInternalError()); InternalData &fe_data = static_cast (fedata); const UpdateFlags flags(fe_data.current_update_flags()); @@ -310,17 +310,17 @@ FE_DGPNonparametric::fill_fe_values ( if (flags & (update_values | update_gradients)) for (unsigned int i=0; idofs_per_cell; ++k) - { - if (flags & update_values) - data.shape_values[k][i] = fe_data.values[k]; - if (flags & update_gradients) - data.shape_gradients[k][i] = fe_data.grads[k]; - if (flags & update_hessians) - data.shape_hessians[k][i] = fe_data.grad_grads[k]; - } + polynomial_space.compute(data.quadrature_points[i], + fe_data.values, fe_data.grads, fe_data.grad_grads); + for (unsigned int k=0; kdofs_per_cell; ++k) + { + if (flags & update_values) + data.shape_values[k][i] = fe_data.values[k]; + if (flags & update_gradients) + data.shape_gradients[k][i] = fe_data.grads[k]; + if (flags & update_hessians) + data.shape_hessians[k][i] = fe_data.grad_grads[k]; + } } } @@ -337,12 +337,12 @@ FE_DGPNonparametric::fill_fe_face_values ( typename Mapping::InternalDataBase& fedata, FEValuesData& data) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&fedata) != 0, - ExcInternalError()); + ExcInternalError()); InternalData &fe_data = static_cast (fedata); const UpdateFlags flags(fe_data.update_once | fe_data.update_each); @@ -353,17 +353,17 @@ FE_DGPNonparametric::fill_fe_face_values ( if (flags & (update_values | update_gradients)) for (unsigned int i=0; idofs_per_cell; ++k) - { - if (flags & update_values) - data.shape_values[k][i] = fe_data.values[k]; - if (flags & update_gradients) - data.shape_gradients[k][i] = fe_data.grads[k]; - if (flags & update_hessians) - data.shape_hessians[k][i] = fe_data.grad_grads[k]; - } + polynomial_space.compute(data.quadrature_points[i], + fe_data.values, fe_data.grads, fe_data.grad_grads); + for (unsigned int k=0; kdofs_per_cell; ++k) + { + if (flags & update_values) + data.shape_values[k][i] = fe_data.values[k]; + if (flags & update_gradients) + data.shape_gradients[k][i] = fe_data.grads[k]; + if (flags & update_hessians) + data.shape_hessians[k][i] = fe_data.grad_grads[k]; + } } } @@ -381,12 +381,12 @@ FE_DGPNonparametric::fill_fe_subface_values ( typename Mapping::InternalDataBase& fedata, FEValuesData& data) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&fedata) != 0, - ExcInternalError()); + ExcInternalError()); InternalData &fe_data = static_cast (fedata); const UpdateFlags flags(fe_data.update_once | fe_data.update_each); @@ -397,17 +397,17 @@ FE_DGPNonparametric::fill_fe_subface_values ( if (flags & (update_values | update_gradients)) for (unsigned int i=0; idofs_per_cell; ++k) - { - if (flags & update_values) - data.shape_values[k][i] = fe_data.values[k]; - if (flags & update_gradients) - data.shape_gradients[k][i] = fe_data.grads[k]; - if (flags & update_hessians) - data.shape_hessians[k][i] = fe_data.grad_grads[k]; - } + polynomial_space.compute(data.quadrature_points[i], + fe_data.values, fe_data.grads, fe_data.grad_grads); + for (unsigned int k=0; kdofs_per_cell; ++k) + { + if (flags & update_values) + data.shape_values[k][i] = fe_data.values[k]; + if (flags & update_gradients) + data.shape_gradients[k][i] = fe_data.grads[k]; + if (flags & update_hessians) + data.shape_hessians[k][i] = fe_data.grad_grads[k]; + } } } @@ -417,15 +417,15 @@ template void FE_DGPNonparametric:: get_face_interpolation_matrix (const FiniteElement &x_source_fe, - FullMatrix &interpolation_matrix) const + FullMatrix &interpolation_matrix) const { - // this is only implemented, if the source - // FE is also a DGPNonparametric element. in that case, - // both elements have no dofs on their - // faces and the face interpolation matrix - // is necessarily empty -- i.e. there isn't - // much we need to do here. - typedef FiniteElement FEE; + // this is only implemented, if the source + // FE is also a DGPNonparametric element. in that case, + // both elements have no dofs on their + // faces and the face interpolation matrix + // is necessarily empty -- i.e. there isn't + // much we need to do here. + typedef FiniteElement FEE; AssertThrow ((x_source_fe.get_name().find ("FE_DGPNonparametric<") == 0) || (dynamic_cast*>(&x_source_fe) != 0), @@ -433,11 +433,11 @@ get_face_interpolation_matrix (const FiniteElement &x_source_fe, ExcInterpolationNotImplemented()); Assert (interpolation_matrix.m() == 0, - ExcDimensionMismatch (interpolation_matrix.m(), - 0)); + ExcDimensionMismatch (interpolation_matrix.m(), + 0)); Assert (interpolation_matrix.n() == 0, - ExcDimensionMismatch (interpolation_matrix.n(), - 0)); + ExcDimensionMismatch (interpolation_matrix.n(), + 0)); } @@ -446,28 +446,28 @@ template void FE_DGPNonparametric:: get_subface_interpolation_matrix (const FiniteElement &x_source_fe, - const unsigned int , - FullMatrix &interpolation_matrix) const + const unsigned int , + FullMatrix &interpolation_matrix) const { - // this is only implemented, if the source - // FE is also a DGPNonparametric element. in that case, - // both elements have no dofs on their - // faces and the face interpolation matrix - // is necessarily empty -- i.e. there isn't - // much we need to do here. - typedef FiniteElement FEE; + // this is only implemented, if the source + // FE is also a DGPNonparametric element. in that case, + // both elements have no dofs on their + // faces and the face interpolation matrix + // is necessarily empty -- i.e. there isn't + // much we need to do here. + typedef FiniteElement FEE; AssertThrow ((x_source_fe.get_name().find ("FE_DGPNonparametric<") == 0) || (dynamic_cast*>(&x_source_fe) != 0), typename FEE:: - ExcInterpolationNotImplemented()); + ExcInterpolationNotImplemented()); Assert (interpolation_matrix.m() == 0, - ExcDimensionMismatch (interpolation_matrix.m(), - 0)); + ExcDimensionMismatch (interpolation_matrix.m(), + 0)); Assert (interpolation_matrix.n() == 0, - ExcDimensionMismatch (interpolation_matrix.n(), - 0)); + ExcDimensionMismatch (interpolation_matrix.n(), + 0)); } @@ -486,8 +486,8 @@ std::vector > FE_DGPNonparametric:: hp_vertex_dof_identities (const FiniteElement &fe_other) const { - // there are no such constraints for DGPNonparametric - // elements at all + // there are no such constraints for DGPNonparametric + // elements at all if (dynamic_cast*>(&fe_other) != 0) return std::vector > (); @@ -505,8 +505,8 @@ std::vector > FE_DGPNonparametric:: hp_line_dof_identities (const FiniteElement &fe_other) const { - // there are no such constraints for DGPNonparametric - // elements at all + // there are no such constraints for DGPNonparametric + // elements at all if (dynamic_cast*>(&fe_other) != 0) return std::vector > (); @@ -524,8 +524,8 @@ std::vector > FE_DGPNonparametric:: hp_quad_dof_identities (const FiniteElement &fe_other) const { - // there are no such constraints for DGPNonparametric - // elements at all + // there are no such constraints for DGPNonparametric + // elements at all if (dynamic_cast*>(&fe_other) != 0) return std::vector > (); @@ -543,9 +543,9 @@ FiniteElementDomination::Domination FE_DGPNonparametric:: compare_for_face_domination (const FiniteElement &fe_other) const { - // check whether both are discontinuous - // elements, see the description of - // FiniteElementDomination::Domination + // check whether both are discontinuous + // elements, see the description of + // FiniteElementDomination::Domination if (dynamic_cast*>(&fe_other) != 0) return FiniteElementDomination::no_requirements; @@ -558,7 +558,7 @@ compare_for_face_domination (const FiniteElement &fe_other) const template bool FE_DGPNonparametric::has_support_on_face (const unsigned int, - const unsigned int) const + const unsigned int) const { return true; } diff --git a/deal.II/source/fe/fe_dgq.cc b/deal.II/source/fe/fe_dgq.cc index f3f3eafb9c..6bf205aa83 100644 --- a/deal.II/source/fe/fe_dgq.cc +++ b/deal.II/source/fe/fe_dgq.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -29,39 +29,39 @@ DEAL_II_NAMESPACE_OPEN // are thus not very interesting to the outside world namespace { - // given an integer N, compute its - // integer square root (if it - // exists, otherwise give up) + // given an integer N, compute its + // integer square root (if it + // exists, otherwise give up) inline unsigned int int_sqrt (const unsigned int N) { for (unsigned int i=0; i<=N; ++i) if (i*i == N) - return i; + return i; Assert (false, ExcInternalError()); return numbers::invalid_unsigned_int; } - // given an integer N, compute its - // integer cube root (if it - // exists, otherwise give up) + // given an integer N, compute its + // integer cube root (if it + // exists, otherwise give up) inline unsigned int int_cuberoot (const unsigned int N) { for (unsigned int i=0; i<=N; ++i) if (i*i*i == N) - return i; + return i; Assert (false, ExcInternalError()); return numbers::invalid_unsigned_int; } - // given N, generate i=0...N-1 - // equidistant points in the - // interior of the interval [0,1] + // given N, generate i=0...N-1 + // equidistant points in the + // interior of the interval [0,1] inline Point<1> generate_unit_point (const unsigned int i, - const unsigned int N, - const dealii::internal::int2type<1> ) + const unsigned int N, + const dealii::internal::int2type<1> ) { Assert (i generate_unit_point (const unsigned int i, - const unsigned int N, - const dealii::internal::int2type<2> ) + const unsigned int N, + const dealii::internal::int2type<2> ) { Assert (i generate_unit_point (const unsigned int i, - const unsigned int N, - const dealii::internal::int2type<3> ) + const unsigned int N, + const dealii::internal::int2type<3> ) { Assert (i FE_DGQ::FE_DGQ (const unsigned int degree) - : - FE_Poly, dim, spacedim> ( - TensorProductPolynomials(Polynomials::LagrangeEquidistant::generate_complete_basis(degree)), - FiniteElementData(get_dpo_vector(degree), 1, degree, FiniteElementData::L2), - std::vector(FiniteElementData(get_dpo_vector(degree),1, degree).dofs_per_cell, true), - std::vector >(FiniteElementData( - get_dpo_vector(degree),1, degree).dofs_per_cell, std::vector(1,true))) + : + FE_Poly, dim, spacedim> ( + TensorProductPolynomials(Polynomials::LagrangeEquidistant::generate_complete_basis(degree)), + FiniteElementData(get_dpo_vector(degree), 1, degree, FiniteElementData::L2), + std::vector(FiniteElementData(get_dpo_vector(degree),1, degree).dofs_per_cell, true), + std::vector >(FiniteElementData( + get_dpo_vector(degree),1, degree).dofs_per_cell, std::vector(1,true))) { - // Reinit the vectors of - // restriction and prolongation - // matrices to the right sizes + // Reinit the vectors of + // restriction and prolongation + // matrices to the right sizes this->reinit_restriction_and_prolongation_matrices(); - // Fill prolongation matrices with - // embedding operators and - // restriction with L2 projection - // - // we can call the respective - // functions in the case - // dim==spacedim, but they are not - // currently implemented for the - // codim-1 case. there's no harm - // here, though, since these - // matrices are independent of the - // space dimension and so we can - // copy them from the respective - // elements (not cheap, but works) + // Fill prolongation matrices with + // embedding operators and + // restriction with L2 projection + // + // we can call the respective + // functions in the case + // dim==spacedim, but they are not + // currently implemented for the + // codim-1 case. there's no harm + // here, though, since these + // matrices are independent of the + // space dimension and so we can + // copy them from the respective + // elements (not cheap, but works) if (dim == spacedim) { FETools::compute_embedding_matrices (*this, this->prolongation); @@ -170,21 +170,21 @@ FE_DGQ::FE_DGQ (const unsigned int degree) } - // finally fill in support points + // finally fill in support points if (degree == 0) { - // constant elements, take - // midpoint + // constant elements, take + // midpoint this->unit_support_points.resize(1); for (unsigned int i=0; iunit_support_points[0](i) = 0.5; + this->unit_support_points[0](i) = 0.5; } else { - // number of points: (degree+1)^dim + // number of points: (degree+1)^dim unsigned int n = degree+1; for (unsigned int i=1; iunit_support_points.resize(n); @@ -193,48 +193,48 @@ FE_DGQ::FE_DGQ (const unsigned int degree) unsigned int k=0; for (unsigned int iz=0; iz <= ((dim>2) ? degree : 0) ; ++iz) - for (unsigned int iy=0; iy <= ((dim>1) ? degree : 0) ; ++iy) - for (unsigned int ix=0; ix<=degree; ++ix) - { - p(0) = ix * step; - if (dim>1) - p(1) = iy * step; - if (dim>2) - p(2) = iz * step; - - this->unit_support_points[k++] = p; - }; + for (unsigned int iy=0; iy <= ((dim>1) ? degree : 0) ; ++iy) + for (unsigned int ix=0; ix<=degree; ++ix) + { + p(0) = ix * step; + if (dim>1) + p(1) = iy * step; + if (dim>2) + p(2) = iz * step; + + this->unit_support_points[k++] = p; + }; }; - // note: no face support points for - // DG elements + // note: no face support points for + // DG elements } template FE_DGQ::FE_DGQ (const Quadrature<1>& points) - : - FE_Poly, dim, spacedim> ( - TensorProductPolynomials(Polynomials::generate_complete_Lagrange_basis(points.get_points())), - FiniteElementData(get_dpo_vector(points.size()-1), 1, points.size()-1, FiniteElementData::L2), - std::vector(FiniteElementData(get_dpo_vector(points.size()-1),1, points.size()-1).dofs_per_cell, true), - std::vector >(FiniteElementData( - get_dpo_vector(points.size()-1),1, points.size()-1).dofs_per_cell, std::vector(1,true))) + : + FE_Poly, dim, spacedim> ( + TensorProductPolynomials(Polynomials::generate_complete_Lagrange_basis(points.get_points())), + FiniteElementData(get_dpo_vector(points.size()-1), 1, points.size()-1, FiniteElementData::L2), + std::vector(FiniteElementData(get_dpo_vector(points.size()-1),1, points.size()-1).dofs_per_cell, true), + std::vector >(FiniteElementData( + get_dpo_vector(points.size()-1),1, points.size()-1).dofs_per_cell, std::vector(1,true))) { - // Reinit the vectors of - // restriction and prolongation - // matrices to the right sizes + // Reinit the vectors of + // restriction and prolongation + // matrices to the right sizes this->reinit_restriction_and_prolongation_matrices(); - // Fill prolongation matrices with embedding operators + // Fill prolongation matrices with embedding operators FETools::compute_embedding_matrices (*this, this->prolongation); - // Fill restriction matrices with L2-projection + // Fill restriction matrices with L2-projection FETools::compute_projection_matrices (*this, this->restriction); - // Compute support points, which - // are the tensor product of the - // Lagrange interpolation points in - // the constructor. + // Compute support points, which + // are the tensor product of the + // Lagrange interpolation points in + // the constructor. Quadrature support_quadrature(points); this->unit_support_points = support_quadrature.get_points(); } @@ -245,12 +245,12 @@ template std::string FE_DGQ::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch std::ostringstream namebuf; namebuf << "FE_DGQ<" << dim << ">(" << this->degree << ")"; @@ -288,7 +288,7 @@ FE_DGQ::get_dpo_vector (const unsigned int deg) template void FE_DGQ::rotate_indices (std::vector &numbers, - const char direction) const + const char direction) const { const unsigned int n = this->degree+1; unsigned int s = n; @@ -300,63 +300,63 @@ FE_DGQ::rotate_indices (std::vector &numbers, if (dim==1) { - // Mirror around midpoint + // Mirror around midpoint for (unsigned int i=n;i>0;) - numbers[l++]=--i; + numbers[l++]=--i; } else { switch (direction) - { - // Rotate xy-plane - // counter-clockwise - case 'z': - for (unsigned int iz=0;iz<((dim>2) ? n:1);++iz) - for (unsigned int j=0;j2) ? n:1);++iz) - for (unsigned int iy=0;iy2, ExcDimensionMismatch (dim,3)); - for (unsigned int iz=0;iz2, ExcDimensionMismatch (dim,3)); - for (unsigned int iz=0;iz2) ? n:1);++iz) + for (unsigned int j=0;j2) ? n:1);++iz) + for (unsigned int iy=0;iy2, ExcDimensionMismatch (dim,3)); + for (unsigned int iz=0;iz2, ExcDimensionMismatch (dim,3)); + for (unsigned int iz=0;iz void FE_DGQ:: get_interpolation_matrix (const FiniteElement &x_source_fe, - FullMatrix &interpolation_matrix) const + FullMatrix &interpolation_matrix) const { - // this is only implemented, if the - // source FE is also a - // DGQ element + // this is only implemented, if the + // source FE is also a + // DGQ element typedef FiniteElement FE; AssertThrow ((x_source_fe.get_name().find ("FE_DGQ<") == 0) || (dynamic_cast*>(&x_source_fe) != 0), typename FE::ExcInterpolationNotImplemented() ); - // ok, source is a Q element, so - // we will be able to do the work + // ok, source is a Q element, so + // we will be able to do the work const FE_DGQ &source_fe = dynamic_cast&>(x_source_fe); Assert (interpolation_matrix.m() == this->dofs_per_cell, - ExcDimensionMismatch (interpolation_matrix.m(), - this->dofs_per_cell)); + ExcDimensionMismatch (interpolation_matrix.m(), + this->dofs_per_cell)); Assert (interpolation_matrix.n() == source_fe.dofs_per_cell, - ExcDimensionMismatch (interpolation_matrix.n(), - source_fe.dofs_per_cell)); + ExcDimensionMismatch (interpolation_matrix.n(), + source_fe.dofs_per_cell)); - // compute the interpolation - // matrices in much the same way as - // we do for the embedding matrices - // from mother to child. + // compute the interpolation + // matrices in much the same way as + // we do for the embedding matrices + // from mother to child. FullMatrix cell_interpolation (this->dofs_per_cell, - this->dofs_per_cell); + this->dofs_per_cell); FullMatrix source_interpolation (this->dofs_per_cell, - source_fe.dofs_per_cell); + source_fe.dofs_per_cell); FullMatrix tmp (this->dofs_per_cell, - source_fe.dofs_per_cell); + source_fe.dofs_per_cell); for (unsigned int j=0; jdofs_per_cell; ++j) { // generate a point on this @@ -430,11 +430,11 @@ get_interpolation_matrix (const FiniteElement &x_source_fe, if (std::fabs(interpolation_matrix(i,j)) < 1e-15) interpolation_matrix(i,j) = 0.; - // make sure that the row sum of - // each of the matrices is 1 at - // this point. this must be so - // since the shape functions sum up - // to 1 + // make sure that the row sum of + // each of the matrices is 1 at + // this point. this must be so + // since the shape functions sum up + // to 1 for (unsigned int i=0; idofs_per_cell; ++i) { double sum = 0.; @@ -452,14 +452,14 @@ template void FE_DGQ:: get_face_interpolation_matrix (const FiniteElement &x_source_fe, - FullMatrix &interpolation_matrix) const + FullMatrix &interpolation_matrix) const { - // this is only implemented, if the source - // FE is also a DGQ element. in that case, - // both elements have no dofs on their - // faces and the face interpolation matrix - // is necessarily empty -- i.e. there isn't - // much we need to do here. + // this is only implemented, if the source + // FE is also a DGQ element. in that case, + // both elements have no dofs on their + // faces and the face interpolation matrix + // is necessarily empty -- i.e. there isn't + // much we need to do here. typedef FiniteElement FE; AssertThrow ((x_source_fe.get_name().find ("FE_DGQ<") == 0) || @@ -467,11 +467,11 @@ get_face_interpolation_matrix (const FiniteElement &x_source_fe, typename FE::ExcInterpolationNotImplemented()); Assert (interpolation_matrix.m() == 0, - ExcDimensionMismatch (interpolation_matrix.m(), - 0)); + ExcDimensionMismatch (interpolation_matrix.m(), + 0)); Assert (interpolation_matrix.n() == 0, - ExcDimensionMismatch (interpolation_matrix.m(), - 0)); + ExcDimensionMismatch (interpolation_matrix.m(), + 0)); } @@ -480,15 +480,15 @@ template void FE_DGQ:: get_subface_interpolation_matrix (const FiniteElement &x_source_fe, - const unsigned int , - FullMatrix &interpolation_matrix) const + const unsigned int , + FullMatrix &interpolation_matrix) const { - // this is only implemented, if the source - // FE is also a DGQ element. in that case, - // both elements have no dofs on their - // faces and the face interpolation matrix - // is necessarily empty -- i.e. there isn't - // much we need to do here. + // this is only implemented, if the source + // FE is also a DGQ element. in that case, + // both elements have no dofs on their + // faces and the face interpolation matrix + // is necessarily empty -- i.e. there isn't + // much we need to do here. typedef FiniteElement FE; AssertThrow ((x_source_fe.get_name().find ("FE_DGQ<") == 0) || @@ -496,11 +496,11 @@ get_subface_interpolation_matrix (const FiniteElement &x_source_f typename FE::ExcInterpolationNotImplemented()); Assert (interpolation_matrix.m() == 0, - ExcDimensionMismatch (interpolation_matrix.m(), - 0)); + ExcDimensionMismatch (interpolation_matrix.m(), + 0)); Assert (interpolation_matrix.n() == 0, - ExcDimensionMismatch (interpolation_matrix.m(), - 0)); + ExcDimensionMismatch (interpolation_matrix.m(), + 0)); } @@ -519,8 +519,8 @@ std::vector > FE_DGQ:: hp_vertex_dof_identities (const FiniteElement &fe_other) const { - // there are no such constraints for DGQ - // elements at all + // there are no such constraints for DGQ + // elements at all if (dynamic_cast*>(&fe_other) != 0) return std::vector > (); @@ -538,8 +538,8 @@ std::vector > FE_DGQ:: hp_line_dof_identities (const FiniteElement &fe_other) const { - // there are no such constraints for DGQ - // elements at all + // there are no such constraints for DGQ + // elements at all if (dynamic_cast*>(&fe_other) != 0) return std::vector > (); @@ -557,8 +557,8 @@ std::vector > FE_DGQ:: hp_quad_dof_identities (const FiniteElement &fe_other) const { - // there are no such constraints for DGQ - // elements at all + // there are no such constraints for DGQ + // elements at all if (dynamic_cast*>(&fe_other) != 0) return std::vector > (); @@ -575,9 +575,9 @@ template FiniteElementDomination::Domination FE_DGQ::compare_for_face_domination (const FiniteElement &fe_other) const { - // check whether both are discontinuous - // elements, see the description of - // FiniteElementDomination::Domination + // check whether both are discontinuous + // elements, see the description of + // FiniteElementDomination::Domination if (dynamic_cast*>(&fe_other) != 0) return FiniteElementDomination::no_requirements; @@ -590,18 +590,18 @@ FE_DGQ::compare_for_face_domination (const FiniteElement bool FE_DGQ::has_support_on_face (const unsigned int shape_index, - const unsigned int face_index) const + const unsigned int face_index) const { Assert (shape_index < this->dofs_per_cell, - ExcIndexRange (shape_index, 0, this->dofs_per_cell)); + ExcIndexRange (shape_index, 0, this->dofs_per_cell)); Assert (face_index < GeometryInfo::faces_per_cell, - ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); unsigned int n = this->degree+1; - // for DGQ(0) elements, the single - // shape functions is constant and - // therefore lives on the boundary + // for DGQ(0) elements, the single + // shape functions is constant and + // therefore lives on the boundary if (this->degree == 0) return true; @@ -611,56 +611,56 @@ FE_DGQ::has_support_on_face (const unsigned int shape_index, { case 1: { - // in 1d, things are simple. since - // there is only one degree of - // freedom per vertex in this - // class, the first is on vertex 0 - // (==face 0 in some sense), the - // second on face 1: - return (((shape_index == 0) && (face_index == 0)) || - ((shape_index == 1) && (face_index == 1))); + // in 1d, things are simple. since + // there is only one degree of + // freedom per vertex in this + // class, the first is on vertex 0 + // (==face 0 in some sense), the + // second on face 1: + return (((shape_index == 0) && (face_index == 0)) || + ((shape_index == 1) && (face_index == 1))); }; case 2: { - if (face_index==0 && (shape_index % n) == 0) - return true; - if (face_index==1 && (shape_index % n) == this->degree) - return true; - if (face_index==2 && shape_index < n) - return true; - if (face_index==3 && shape_index >= this->dofs_per_cell-n) - return true; - return false; + if (face_index==0 && (shape_index % n) == 0) + return true; + if (face_index==1 && (shape_index % n) == this->degree) + return true; + if (face_index==2 && shape_index < n) + return true; + if (face_index==3 && shape_index >= this->dofs_per_cell-n) + return true; + return false; }; case 3: { - const unsigned int in2 = shape_index % n2; - - // x=0 - if (face_index==0 && (shape_index % n) == 0) - return true; - // x=1 - if (face_index==1 && (shape_index % n) == n-1) - return true; - // y=0 - if (face_index==2 && in2 < n ) - return true; - // y=1 - if (face_index==3 && in2 >= n2-n) - return true; - // z=0 - if (face_index==4 && shape_index < n2) - return true; - // z=1 - if (face_index==5 && shape_index >= this->dofs_per_cell - n2) - return true; - return false; + const unsigned int in2 = shape_index % n2; + + // x=0 + if (face_index==0 && (shape_index % n) == 0) + return true; + // x=1 + if (face_index==1 && (shape_index % n) == n-1) + return true; + // y=0 + if (face_index==2 && in2 < n ) + return true; + // y=1 + if (face_index==3 && in2 >= n2-n) + return true; + // z=0 + if (face_index==4 && shape_index < n2) + return true; + // z=1 + if (face_index==5 && shape_index >= this->dofs_per_cell - n2) + return true; + return false; }; default: - Assert (false, ExcNotImplemented()); + Assert (false, ExcNotImplemented()); } return true; } @@ -679,7 +679,7 @@ FE_DGQ::memory_consumption () const template FE_DGQArbitraryNodes::FE_DGQArbitraryNodes (const Quadrature<1>& points) - : FE_DGQ(points) + : FE_DGQ(points) {} @@ -688,12 +688,12 @@ template std::string FE_DGQArbitraryNodes::get_name () const { - // note that the - // FETools::get_fe_from_name - // function does not work for - // FE_DGQArbitraryNodes since - // there is no initialization by - // a degree value. + // note that the + // FETools::get_fe_from_name + // function does not work for + // FE_DGQArbitraryNodes since + // there is no initialization by + // a degree value. std::ostringstream namebuf; bool type = true; @@ -703,26 +703,26 @@ FE_DGQArbitraryNodes::get_name () const const std::vector > &unit_support_points = this->unit_support_points; unsigned int index = 0; - // Decode the support points - // in one coordinate direction. + // Decode the support points + // in one coordinate direction. for (unsigned int j=0;j1) ? (unit_support_points[j](1)==0 && - ((dim>2) ? unit_support_points[j](2)==0: true)) : true) - { - points[index++] = unit_support_points[j](0); - } + ((dim>2) ? unit_support_points[j](2)==0: true)) : true) + { + points[index++] = unit_support_points[j](0); + } } Assert (index == n_points, - ExcMessage ("Could not decode support points in one coordinate direction.")); + ExcMessage ("Could not decode support points in one coordinate direction.")); - // Check whether the support - // points are equidistant. + // Check whether the support + // points are equidistant. for(unsigned int j=0;jdegree) > 1e-15) { - type = false; - break; + type = false; + break; } if (type == true) @@ -730,20 +730,20 @@ FE_DGQArbitraryNodes::get_name () const else { - // Check whether the support - // points come from QGaussLobatto. + // Check whether the support + // points come from QGaussLobatto. const QGaussLobatto<1> points_gl(n_points); type = true; for(unsigned int j=0;j(QGaussLobatto(" << this->degree+1 << "))"; + namebuf << "FE_DGQArbitraryNodes<" << dim << ">(QGaussLobatto(" << this->degree+1 << "))"; else - namebuf << "FE_DGQArbitraryNodes<" << dim << ">(QUnknownNodes(" << this->degree << "))"; + namebuf << "FE_DGQArbitraryNodes<" << dim << ">(QUnknownNodes(" << this->degree << "))"; } return namebuf.str(); @@ -755,12 +755,12 @@ template FiniteElement * FE_DGQArbitraryNodes::clone() const { - // TODO[Prill] : There must be a better way - // to extract 1D quadrature points from the - // tensor product FE. + // TODO[Prill] : There must be a better way + // to extract 1D quadrature points from the + // tensor product FE. - // Construct a dummy quadrature formula - // containing the FE's nodes: + // Construct a dummy quadrature formula + // containing the FE's nodes: std::vector > qpoints(this->degree+1); for (unsigned int i=0; i<=this->degree; ++i) qpoints[i] = Point<1>(this->unit_support_points[i][0]); diff --git a/deal.II/source/fe/fe_face.cc b/deal.II/source/fe/fe_face.cc index 248163be00..f22a9b74d2 100644 --- a/deal.II/source/fe/fe_face.cc +++ b/deal.II/source/fe/fe_face.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2009, 2011 by the deal.II authors +// Copyright (C) 2009, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -19,11 +19,11 @@ DEAL_II_NAMESPACE_OPEN template FE_FaceQ::FE_FaceQ (const unsigned int degree) - : + : FE_PolyFace, dim, spacedim> ( - TensorProductPolynomials(Polynomials::LagrangeEquidistant::generate_complete_basis(degree)), - FiniteElementData(get_dpo_vector(degree), 1, degree, FiniteElementData::L2), - std::vector(1,true)) + TensorProductPolynomials(Polynomials::LagrangeEquidistant::generate_complete_basis(degree)), + FiniteElementData(get_dpo_vector(degree), 1, degree, FiniteElementData::L2), + std::vector(1,true)) {} @@ -39,12 +39,12 @@ template std::string FE_FaceQ::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch std::ostringstream namebuf; namebuf << "FE_FaceQ<" << dim << ">(" << this->degree << ")"; diff --git a/deal.II/source/fe/fe_nedelec.cc b/deal.II/source/fe/fe_nedelec.cc index 80a7f3d498..e1c05bb37b 100644 --- a/deal.II/source/fe/fe_nedelec.cc +++ b/deal.II/source/fe/fe_nedelec.cc @@ -40,40 +40,40 @@ FE_PolyTensor, dim> #ifdef DEBUG_NEDELEC deallog << get_name() << std::endl; #endif - + Assert (dim >= 2, ExcImpossibleInDim(dim)); const unsigned int n_dofs = this->dofs_per_cell; this->mapping_type = mapping_nedelec; - // First, initialize the - // generalized support points and - // quadrature weights, since they - // are required for interpolation. + // First, initialize the + // generalized support points and + // quadrature weights, since they + // are required for interpolation. initialize_support_points (p); this->inverse_node_matrix.reinit (n_dofs, n_dofs); this->inverse_node_matrix.fill (FullMatrix (IdentityMatrix (n_dofs))); - // From now on, the shape functions - // will be the correct ones, not - // the raw shape functions anymore. - - // Reinit the vectors of - // restriction and prolongation - // matrices to the right sizes. - // Restriction only for isotropic - // refinement + // From now on, the shape functions + // will be the correct ones, not + // the raw shape functions anymore. + + // Reinit the vectors of + // restriction and prolongation + // matrices to the right sizes. + // Restriction only for isotropic + // refinement #ifdef DEBUG_NEDELEC deallog << "Embedding" << std::endl; #endif this->reinit_restriction_and_prolongation_matrices (); - // Fill prolongation matrices with embedding operators + // Fill prolongation matrices with embedding operators FETools::compute_embedding_matrices (*this, this->prolongation, true); #ifdef DEBUG_NEDELEC deallog << "Restriction" << std::endl; #endif initialize_restriction (); - + #ifdef DEBUG_NEDELEC deallog << "Face Embedding" << std::endl; #endif @@ -84,44 +84,44 @@ FE_PolyTensor, dim> FETools::compute_face_embedding_matrices (*this, face_embeddings, 0, 0); - + switch (dim) { case 1: - { + { this->interface_constraints.reinit (0, 0); break; } - + case 2: - { + { this->interface_constraints.reinit (2 * this->dofs_per_face, this->dofs_per_face); - + for (unsigned int i = 0; i < GeometryInfo<2>::max_children_per_face; ++i) for (unsigned int j = 0; j < this->dofs_per_face; ++j) for (unsigned int k = 0; k < this->dofs_per_face; ++k) this->interface_constraints (i * this->dofs_per_face + j, k) = face_embeddings[i] (j, k); - + break; } - + case 3: { this->interface_constraints.reinit (4 * (this->dofs_per_face - this->degree), this->dofs_per_face); - + unsigned int target_row = 0; - + for (unsigned int i = 0; i < 2; ++i) for (unsigned int j = this->degree; j < 2 * this->degree; ++j, ++target_row) for (unsigned int k = 0; k < this->dofs_per_face; ++k) this->interface_constraints (target_row, k) = face_embeddings[2 * i] (j, k); - + for (unsigned int i = 0; i < 2; ++i) for (unsigned int j = 3 * this->degree; j < GeometryInfo<3>::lines_per_face * this->degree; @@ -129,7 +129,7 @@ FE_PolyTensor, dim> for (unsigned int k = 0; k < this->dofs_per_face; ++k) this->interface_constraints (target_row, k) = face_embeddings[i] (j, k); - + for (unsigned int i = 0; i < 2; ++i) for (unsigned int j = 0; j < 2; ++j) for (unsigned int k = i * this->degree; @@ -137,7 +137,7 @@ FE_PolyTensor, dim> for (unsigned int l = 0; l < this->dofs_per_face; ++l) this->interface_constraints (target_row, l) = face_embeddings[i + 2 * j] (k, l); - + for (unsigned int i = 0; i < 2; ++i) for (unsigned int j = 0; j < 2; ++j) for (unsigned int k = (i + 2) * this->degree; @@ -145,7 +145,7 @@ FE_PolyTensor, dim> for (unsigned int l = 0; l < this->dofs_per_face; ++l) this->interface_constraints (target_row, l) = face_embeddings[2 * i + j] (k, l); - + for (unsigned int i = 0; i < GeometryInfo<3>::max_children_per_face; ++i) for (unsigned int @@ -154,10 +154,10 @@ FE_PolyTensor, dim> for (unsigned int k = 0; k < this->dofs_per_face; ++k) this->interface_constraints (target_row, k) = face_embeddings[i] (j, k); - + break; } - + default: Assert (false, ExcNotImplemented ()); } @@ -170,12 +170,12 @@ template std::string FE_Nedelec::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch std::ostringstream namebuf; namebuf << "FE_Nedelec<" << dim << ">(" << this->degree-1 << ")"; @@ -218,7 +218,7 @@ FE_Nedelec<2>::initialize_support_points (const unsigned int degree) { const int dim = 2; - // Create polynomial basis. + // Create polynomial basis. const std::vector >& lobatto_polynomials = Polynomials::Lobatto::generate_complete_basis (degree + 1); std::vector > @@ -227,8 +227,8 @@ FE_Nedelec<2>::initialize_support_points (const unsigned int degree) for (unsigned int i = 0; i < lobatto_polynomials_grad.size (); ++i) lobatto_polynomials_grad[i] = lobatto_polynomials[i + 1].derivative (); - // Initialize quadratures to obtain - // quadrature points later on. + // Initialize quadratures to obtain + // quadrature points later on. const QGauss reference_edge_quadrature (degree + 1); const unsigned int& n_edge_points = reference_edge_quadrature.size (); @@ -239,66 +239,66 @@ FE_Nedelec<2>::initialize_support_points (const unsigned int degree) this->generalized_face_support_points.resize (n_edge_points); - // Create face support points. + // Create face support points. for (unsigned int q_point = 0; q_point < n_edge_points; ++q_point) this->generalized_face_support_points[q_point] = reference_edge_quadrature.point (q_point); if (degree > 0) { - // If the polynomial degree is positive - // we have support points on the faces - // and in the interior of a cell. + // If the polynomial degree is positive + // we have support points on the faces + // and in the interior of a cell. const QGauss quadrature (degree + 1); const unsigned int& n_interior_points = quadrature.size (); this->generalized_support_points.resize - (n_boundary_points + n_interior_points); + (n_boundary_points + n_interior_points); boundary_weights.reinit (n_edge_points, degree); for (unsigned int q_point = 0; q_point < n_edge_points; - ++q_point) - { - for (unsigned int line = 0; - line < GeometryInfo::lines_per_cell; ++line) - this->generalized_support_points[line * n_edge_points - + q_point] - = edge_quadrature.point - (QProjector::DataSetDescriptor::face - (line, true, false, false, n_edge_points) + q_point); - - for (unsigned int i = 0; i < degree; ++i) - boundary_weights (q_point, i) - = reference_edge_quadrature.weight (q_point) - * lobatto_polynomials_grad[i + 1].value - (this->generalized_face_support_points[q_point] (0)); - } + ++q_point) + { + for (unsigned int line = 0; + line < GeometryInfo::lines_per_cell; ++line) + this->generalized_support_points[line * n_edge_points + + q_point] + = edge_quadrature.point + (QProjector::DataSetDescriptor::face + (line, true, false, false, n_edge_points) + q_point); + + for (unsigned int i = 0; i < degree; ++i) + boundary_weights (q_point, i) + = reference_edge_quadrature.weight (q_point) + * lobatto_polynomials_grad[i + 1].value + (this->generalized_face_support_points[q_point] (0)); + } for (unsigned int q_point = 0; q_point < n_interior_points; - ++q_point) - this->generalized_support_points[q_point + n_boundary_points] - = quadrature.point (q_point); + ++q_point) + this->generalized_support_points[q_point + n_boundary_points] + = quadrature.point (q_point); } else { - // In this case we only need support points - // on the faces of a cell. + // In this case we only need support points + // on the faces of a cell. const Quadrature& edge_quadrature - = QProjector::project_to_all_faces - (reference_edge_quadrature); + = QProjector::project_to_all_faces + (reference_edge_quadrature); this->generalized_support_points.resize (n_boundary_points); for (unsigned int line = 0; - line < GeometryInfo::lines_per_cell; ++line) - for (unsigned int q_point = 0; q_point < n_edge_points; - ++q_point) - this->generalized_support_points[line * n_edge_points - + q_point] - = edge_quadrature.point - (QProjector::DataSetDescriptor::face - (line, true, false, false, n_edge_points) + q_point); + line < GeometryInfo::lines_per_cell; ++line) + for (unsigned int q_point = 0; q_point < n_edge_points; + ++q_point) + this->generalized_support_points[line * n_edge_points + + q_point] + = edge_quadrature.point + (QProjector::DataSetDescriptor::face + (line, true, false, false, n_edge_points) + q_point); } } @@ -310,7 +310,7 @@ FE_Nedelec<3>::initialize_support_points (const unsigned int degree) { const int dim = 3; - // Create polynomial basis. + // Create polynomial basis. const std::vector >& lobatto_polynomials = Polynomials::Lobatto::generate_complete_basis (degree + 1); std::vector > @@ -319,8 +319,8 @@ FE_Nedelec<3>::initialize_support_points (const unsigned int degree) for (unsigned int i = 0; i < lobatto_polynomials_grad.size (); ++i) lobatto_polynomials_grad[i] = lobatto_polynomials[i + 1].derivative (); - // Initialize quadratures to obtain - // quadrature points later on. + // Initialize quadratures to obtain + // quadrature points later on. const QGauss<1> reference_edge_quadrature (degree + 1); const unsigned int& n_edge_points = reference_edge_quadrature.size (); const Quadrature& edge_quadrature @@ -329,156 +329,156 @@ FE_Nedelec<3>::initialize_support_points (const unsigned int degree) if (degree > 0) { - // If the polynomial degree is positive - // we have support points on the edges, - // faces and in the interior of a cell. + // If the polynomial degree is positive + // we have support points on the edges, + // faces and in the interior of a cell. const QGauss reference_face_quadrature (degree + 1); const unsigned int& n_face_points - = reference_face_quadrature.size (); + = reference_face_quadrature.size (); const unsigned int n_boundary_points - = GeometryInfo::lines_per_cell * n_edge_points - + GeometryInfo::faces_per_cell * n_face_points; + = GeometryInfo::lines_per_cell * n_edge_points + + GeometryInfo::faces_per_cell * n_face_points; const QGauss quadrature (degree + 1); const unsigned int& n_interior_points = quadrature.size (); boundary_weights.reinit (n_edge_points + n_face_points, - 2 * (degree + 1) * degree); + 2 * (degree + 1) * degree); this->generalized_face_support_points.resize - (4 * n_edge_points + n_face_points); + (4 * n_edge_points + n_face_points); this->generalized_support_points.resize - (n_boundary_points + n_interior_points); + (n_boundary_points + n_interior_points); - // Create support points on edges. + // Create support points on edges. for (unsigned int q_point = 0; q_point < n_edge_points; ++q_point) - { - for (unsigned int line = 0; - line < GeometryInfo::lines_per_cell; ++line) - this->generalized_face_support_points[line * n_edge_points - + q_point] - = edge_quadrature.point - (QProjector::DataSetDescriptor::face - (line, true, false, false, n_edge_points) + q_point); - - for (unsigned int i = 0; i < 2; ++i) - for (unsigned int j = 0; j < 2; ++j) - { - this->generalized_support_points - [q_point + (i + 4 * j) * n_edge_points] - = Point - (i, reference_edge_quadrature.point (q_point) (0), - j); - this->generalized_support_points - [q_point + (i + 4 * j + 2) * n_edge_points] - = Point - (reference_edge_quadrature.point (q_point) (0), - i, j); - this->generalized_support_points - [q_point + (i + 2 * (j + 4)) * n_edge_points] - = Point - (i, j, - reference_edge_quadrature.point (q_point) (0)); - } - - for (unsigned int i = 0; i < degree; ++i) - boundary_weights (q_point, i) - = reference_edge_quadrature.weight (q_point) - * lobatto_polynomials_grad[i + 1].value - (this->generalized_face_support_points[q_point] (1)); - } - - // Create support points on faces. + { + for (unsigned int line = 0; + line < GeometryInfo::lines_per_cell; ++line) + this->generalized_face_support_points[line * n_edge_points + + q_point] + = edge_quadrature.point + (QProjector::DataSetDescriptor::face + (line, true, false, false, n_edge_points) + q_point); + + for (unsigned int i = 0; i < 2; ++i) + for (unsigned int j = 0; j < 2; ++j) + { + this->generalized_support_points + [q_point + (i + 4 * j) * n_edge_points] + = Point + (i, reference_edge_quadrature.point (q_point) (0), + j); + this->generalized_support_points + [q_point + (i + 4 * j + 2) * n_edge_points] + = Point + (reference_edge_quadrature.point (q_point) (0), + i, j); + this->generalized_support_points + [q_point + (i + 2 * (j + 4)) * n_edge_points] + = Point + (i, j, + reference_edge_quadrature.point (q_point) (0)); + } + + for (unsigned int i = 0; i < degree; ++i) + boundary_weights (q_point, i) + = reference_edge_quadrature.weight (q_point) + * lobatto_polynomials_grad[i + 1].value + (this->generalized_face_support_points[q_point] (1)); + } + + // Create support points on faces. for (unsigned int q_point = 0; q_point < n_face_points; - ++q_point) - { - this->generalized_face_support_points[q_point - + 4 * n_edge_points] - = reference_face_quadrature.point (q_point); - - for (unsigned int i = 0; i <= degree; ++i) - for (unsigned int j = 0; j < degree; ++j) - { - boundary_weights (q_point + n_edge_points, - 2 * (i * degree + j)) - = reference_face_quadrature.weight (q_point) - * lobatto_polynomials_grad[i].value - (this->generalized_face_support_points - [q_point + 4 * n_edge_points] (0)) - * lobatto_polynomials[j + 2].value - (this->generalized_face_support_points - [q_point + 4 * n_edge_points] (1)); - boundary_weights (q_point + n_edge_points, - 2 * (i * degree + j) + 1) - = reference_face_quadrature.weight (q_point) - * lobatto_polynomials_grad[i].value - (this->generalized_face_support_points - [q_point + 4 * n_edge_points] (1)) - * lobatto_polynomials[j + 2].value - (this->generalized_face_support_points - [q_point + 4 * n_edge_points] (0)); - } - } + ++q_point) + { + this->generalized_face_support_points[q_point + + 4 * n_edge_points] + = reference_face_quadrature.point (q_point); + + for (unsigned int i = 0; i <= degree; ++i) + for (unsigned int j = 0; j < degree; ++j) + { + boundary_weights (q_point + n_edge_points, + 2 * (i * degree + j)) + = reference_face_quadrature.weight (q_point) + * lobatto_polynomials_grad[i].value + (this->generalized_face_support_points + [q_point + 4 * n_edge_points] (0)) + * lobatto_polynomials[j + 2].value + (this->generalized_face_support_points + [q_point + 4 * n_edge_points] (1)); + boundary_weights (q_point + n_edge_points, + 2 * (i * degree + j) + 1) + = reference_face_quadrature.weight (q_point) + * lobatto_polynomials_grad[i].value + (this->generalized_face_support_points + [q_point + 4 * n_edge_points] (1)) + * lobatto_polynomials[j + 2].value + (this->generalized_face_support_points + [q_point + 4 * n_edge_points] (0)); + } + } const Quadrature& face_quadrature - = QProjector::project_to_all_faces - (reference_face_quadrature); + = QProjector::project_to_all_faces + (reference_face_quadrature); for (unsigned int face = 0; - face < GeometryInfo::faces_per_cell; ++face) - for (unsigned int q_point = 0; q_point < n_face_points; - ++q_point) - { - this->generalized_support_points - [face * n_face_points + q_point - + GeometryInfo::lines_per_cell * n_edge_points] - = face_quadrature.point - (QProjector::DataSetDescriptor::face - (face, true, false, false, n_face_points) + q_point); - } - - // Create support points in the interior. + face < GeometryInfo::faces_per_cell; ++face) + for (unsigned int q_point = 0; q_point < n_face_points; + ++q_point) + { + this->generalized_support_points + [face * n_face_points + q_point + + GeometryInfo::lines_per_cell * n_edge_points] + = face_quadrature.point + (QProjector::DataSetDescriptor::face + (face, true, false, false, n_face_points) + q_point); + } + + // Create support points in the interior. for (unsigned int q_point = 0; q_point < n_interior_points; - ++q_point) - this->generalized_support_points[q_point + n_boundary_points] - = quadrature.point (q_point); + ++q_point) + this->generalized_support_points[q_point + n_boundary_points] + = quadrature.point (q_point); } else { this->generalized_face_support_points.resize (4 * n_edge_points); this->generalized_support_points.resize - (GeometryInfo::lines_per_cell * n_edge_points); + (GeometryInfo::lines_per_cell * n_edge_points); for (unsigned int q_point = 0; q_point < n_edge_points; - ++q_point) - { - for (unsigned int line = 0; - line < GeometryInfo::lines_per_cell; ++line) - this->generalized_face_support_points[line * n_edge_points - + q_point] - = edge_quadrature.point - (QProjector::DataSetDescriptor::face - (line, true, false, false, n_edge_points) + q_point); - - for (unsigned int i = 0; i < 2; ++i) - for (unsigned int j = 0; j < 2; ++j) - { - this->generalized_support_points - [q_point + (i + 4 * j) * n_edge_points] - = Point - (i, reference_edge_quadrature.point (q_point) (0), - j); - this->generalized_support_points - [q_point + (i + 4 * j + 2) * n_edge_points] - = Point - (reference_edge_quadrature.point (q_point) (0), - i, j); - this->generalized_support_points - [q_point + (i + 2 * (j + 4)) * n_edge_points] - = Point - (i, j, - reference_edge_quadrature.point (q_point) (0)); - } - } + ++q_point) + { + for (unsigned int line = 0; + line < GeometryInfo::lines_per_cell; ++line) + this->generalized_face_support_points[line * n_edge_points + + q_point] + = edge_quadrature.point + (QProjector::DataSetDescriptor::face + (line, true, false, false, n_edge_points) + q_point); + + for (unsigned int i = 0; i < 2; ++i) + for (unsigned int j = 0; j < 2; ++j) + { + this->generalized_support_points + [q_point + (i + 4 * j) * n_edge_points] + = Point + (i, reference_edge_quadrature.point (q_point) (0), + j); + this->generalized_support_points + [q_point + (i + 4 * j + 2) * n_edge_points] + = Point + (reference_edge_quadrature.point (q_point) (0), + i, j); + this->generalized_support_points + [q_point + (i + 2 * (j + 4)) * n_edge_points] + = Point + (i, j, + reference_edge_quadrature.point (q_point) (0)); + } + } } } @@ -489,8 +489,8 @@ template <> void FE_Nedelec<1>::initialize_restriction () { - // there is only one refinement case in 1d, - // which is the isotropic one + // there is only one refinement case in 1d, + // which is the isotropic one for (unsigned int i = 0; i < GeometryInfo<1>::max_children_per_cell; ++i) this->restriction[0][i].reinit(0, 0); } @@ -502,12 +502,12 @@ template void FE_Nedelec::initialize_restriction () { - // This function does the same as the - // function interpolate further below. - // But since the functions, which we - // interpolate here, are discontinuous - // we have to use more quadrature - // points as in interpolate. + // This function does the same as the + // function interpolate further below. + // But since the functions, which we + // interpolate here, are discontinuous + // we have to use more quadrature + // points as in interpolate. const QGauss<1> edge_quadrature (2 * this->degree); const std::vector >& edge_quadrature_points = edge_quadrature.get_points (); @@ -520,10 +520,10 @@ FE_Nedelec::initialize_restriction () { case 2: { - // First interpolate the shape - // functions of the child cells - // to the lowest order shape - // functions of the parent cell. + // First interpolate the shape + // functions of the child cells + // to the lowest order shape + // functions of the parent cell. for (unsigned int dof = 0; dof < this->dofs_per_cell; ++dof) for (unsigned int q_point = 0; q_point < n_edge_quadrature_points; ++q_point) @@ -561,8 +561,8 @@ FE_Nedelec::initialize_restriction () else { Point quadrature_point (0.0, - 2.0 * edge_quadrature_points[q_point] (0) - - 1.0); + 2.0 * edge_quadrature_points[q_point] (0) + - 1.0); this->restriction[index][2] (0, dof) += weight * this->shape_value_component @@ -594,7 +594,7 @@ FE_Nedelec::initialize_restriction () // parent cell. if (this->degree > 1) { - const unsigned int deg = this->degree-1; + const unsigned int deg = this->degree-1; const std::vector >& legendre_polynomials = Polynomials::Legendre::generate_complete_basis (deg); @@ -613,7 +613,7 @@ FE_Nedelec::initialize_restriction () for (unsigned int i = 0; i < deg; ++i) assembling_matrix (i, q_point) = weight * legendre_polynomials[i + 1].value - (edge_quadrature_points[q_point] (0)); + (edge_quadrature_points[q_point] (0)); } FullMatrix system_matrix (deg, deg); @@ -637,87 +637,87 @@ FE_Nedelec::initialize_restriction () const double weight = edge_quadrature.weight (q_point); const Point quadrature_point_0 (i, - edge_quadrature_points[q_point] (0)); + edge_quadrature_points[q_point] (0)); const Point quadrature_point_1 - (edge_quadrature_points[q_point] (0), - i); + (edge_quadrature_points[q_point] (0), + i); if (edge_quadrature_points[q_point] (0) < 0.5) { Point quadrature_point_2 (i, - 2.0 * edge_quadrature_points[q_point] (0)); + 2.0 * edge_quadrature_points[q_point] (0)); tmp (0) = weight * (2.0 * this->shape_value_component - (dof, quadrature_point_2, 1) - - this->restriction[index][i] - (i * this->degree, dof) - * this->shape_value_component - (i * this->degree, - quadrature_point_0, 1)); + (dof, quadrature_point_2, 1) + - this->restriction[index][i] + (i * this->degree, dof) + * this->shape_value_component + (i * this->degree, + quadrature_point_0, 1)); tmp (1) = -1.0 * weight - * this->restriction[index][i + 2] - (i * this->degree, dof) - * this->shape_value_component - (i * this->degree, - quadrature_point_0, 1); + * this->restriction[index][i + 2] + (i * this->degree, dof) + * this->shape_value_component + (i * this->degree, + quadrature_point_0, 1); quadrature_point_2 = Point (2.0 * edge_quadrature_points[q_point] (0), - i); + i); tmp (2) = weight * (2.0 * this->shape_value_component - (dof, quadrature_point_2, 0) - - this->restriction[index][2 * i] - ((i + 2) * this->degree, dof) - * this->shape_value_component - ((i + 2) * this->degree, - quadrature_point_1, 0)); + (dof, quadrature_point_2, 0) + - this->restriction[index][2 * i] + ((i + 2) * this->degree, dof) + * this->shape_value_component + ((i + 2) * this->degree, + quadrature_point_1, 0)); tmp (3) = -1.0 * weight - * this->restriction[index][2 * i + 1] - ((i + 2) * this->degree, dof) - * this->shape_value_component - ((i + 2) * this->degree, - quadrature_point_1, 0); + * this->restriction[index][2 * i + 1] + ((i + 2) * this->degree, dof) + * this->shape_value_component + ((i + 2) * this->degree, + quadrature_point_1, 0); } else { tmp (0) = -1.0 * weight * this->restriction[index][i] - (i * this->degree, dof) - * this->shape_value_component - (i * this->degree, - quadrature_point_0, 1); + (i * this->degree, dof) + * this->shape_value_component + (i * this->degree, + quadrature_point_0, 1); Point quadrature_point_2 (i, - 2.0 * edge_quadrature_points[q_point] (0) - - 1.0); + 2.0 * edge_quadrature_points[q_point] (0) + - 1.0); tmp (1) = weight - * (2.0 * this->shape_value_component - (dof, quadrature_point_2, 1) - - this->restriction[index][i + 2] - (i * this->degree, dof) - * this->shape_value_component - (i * this->degree, - quadrature_point_0, 1)); + * (2.0 * this->shape_value_component + (dof, quadrature_point_2, 1) + - this->restriction[index][i + 2] + (i * this->degree, dof) + * this->shape_value_component + (i * this->degree, + quadrature_point_0, 1)); tmp (2) = -1.0 * weight - * this->restriction[index][2 * i] - ((i + 2) * this->degree, dof) - * this->shape_value_component - ((i + 2) * this->degree, - quadrature_point_1, 0); + * this->restriction[index][2 * i] + ((i + 2) * this->degree, dof) + * this->shape_value_component + ((i + 2) * this->degree, + quadrature_point_1, 0); quadrature_point_2 = Point (2.0 * edge_quadrature_points[q_point] (0) - - 1.0, i); + - 1.0, i); tmp (3) = weight - * (2.0 * this->shape_value_component - (dof, quadrature_point_2, 0) - - this->restriction[index][2 * i + 1] - ((i + 2) * this->degree, dof) - * this->shape_value_component - ((i + 2) * this->degree, - quadrature_point_1, 0)); + * (2.0 * this->shape_value_component + (dof, quadrature_point_2, 0) + - this->restriction[index][2 * i + 1] + ((i + 2) * this->degree, dof) + * this->shape_value_component + ((i + 2) * this->degree, + quadrature_point_1, 0)); } for (unsigned int j = 0; j < this->degree-1; ++j) @@ -925,7 +925,7 @@ FE_Nedelec::initialize_restriction () if (std::abs (solution (i * (this->degree-1) + j, 2 * k)) > 1e-14) this->restriction[index][k] - (i * (this->degree-1) + j + n_boundary_dofs, dof) + (i * (this->degree-1) + j + n_boundary_dofs, dof) = solution (i * (this->degree-1) + j, 2 * k); if (std::abs (solution (i * (this->degree-1) + j, 2 * k + 1)) @@ -933,7 +933,7 @@ FE_Nedelec::initialize_restriction () this->restriction[index][k] (i + (this->degree-1 + j) * this->degree + n_boundary_dofs, dof) - = solution (i * (this->degree-1) + j, 2 * k + 1); + = solution (i * (this->degree-1) + j, 2 * k + 1); } } } @@ -943,10 +943,10 @@ FE_Nedelec::initialize_restriction () case 3: { - // First interpolate the shape - // functions of the child cells - // to the lowest order shape - // functions of the parent cell. + // First interpolate the shape + // functions of the child cells + // to the lowest order shape + // functions of the parent cell. for (unsigned int dof = 0; dof < this->dofs_per_cell; ++dof) for (unsigned int q_point = 0; q_point < n_edge_quadrature_points; ++q_point) @@ -1021,7 +1021,7 @@ FE_Nedelec::initialize_restriction () // parent cell. if (this->degree > 1) { - const unsigned int deg = this->degree-1; + const unsigned int deg = this->degree-1; const std::vector >& legendre_polynomials = Polynomials::Legendre::generate_complete_basis (deg); @@ -1039,8 +1039,8 @@ FE_Nedelec::initialize_restriction () for (unsigned int i = 0; i < deg; ++i) assembling_matrix (i, q_point) = weight - * legendre_polynomials[i + 1].value - (edge_quadrature_points[q_point] (0)); + * legendre_polynomials[i + 1].value + (edge_quadrature_points[q_point] (0)); } FullMatrix system_matrix (deg, deg); @@ -1296,8 +1296,8 @@ FE_Nedelec::initialize_restriction () if (face_quadrature_points[q_point] (1) < 0.5) { Point quadrature_point_0 (i, - 2.0 * face_quadrature_points[q_point] (0), - 2.0 * face_quadrature_points[q_point] (1)); + 2.0 * face_quadrature_points[q_point] (0), + 2.0 * face_quadrature_points[q_point] (1)); tmp (0) += 2.0 * this->shape_value_component (dof, quadrature_point_0, 1); @@ -1324,9 +1324,9 @@ FE_Nedelec::initialize_restriction () else { Point quadrature_point_0 (i, - 2.0 * face_quadrature_points[q_point] (0), - 2.0 * face_quadrature_points[q_point] (1) - - 1.0); + 2.0 * face_quadrature_points[q_point] (0), + 2.0 * face_quadrature_points[q_point] (1) + - 1.0); tmp (2) += 2.0 * this->shape_value_component (dof, quadrature_point_0, 1); @@ -1929,32 +1929,32 @@ FE_Nedelec::initialize_restriction () { if (std::abs (solution ((l * deg + m) * deg + n, - 3 * (i + 2 * (j + 2 * k)))) + 3 * (i + 2 * (j + 2 * k)))) > 1e-14) this->restriction[index][2 * (2 * i + j) + k] ((l * deg + m) * deg + n + n_boundary_dofs, dof) = solution ((l * deg + m) * deg + n, - 3 * (i + 2 * (j + 2 * k))); + 3 * (i + 2 * (j + 2 * k))); if (std::abs (solution ((l * deg + m) * deg + n, - 3 * (i + 2 * (j + 2 * k)) + 1)) + 3 * (i + 2 * (j + 2 * k)) + 1)) > 1e-14) this->restriction[index][2 * (2 * i + j) + k] ((l + (m + deg) * this->degree) * deg + n + n_boundary_dofs, dof) = solution ((l * deg + m) * deg + n, - 3 * (i + 2 * (j + 2 * k)) + 1); + 3 * (i + 2 * (j + 2 * k)) + 1); if (std::abs (solution ((l * deg + m) * deg + n, - 3 * (i + 2 * (j + 2 * k)) + 2)) + 3 * (i + 2 * (j + 2 * k)) + 2)) > 1e-14) this->restriction[index][2 * (2 * i + j) + k] (l + ((m + 2 * deg) * deg + n) * this->degree + n_boundary_dofs, dof) = solution ((l * deg + m) * deg + n, - 3 * (i + 2 * (j + 2 * k)) + 2); + 3 * (i + 2 * (j + 2 * k)) + 2); } } } @@ -1974,7 +1974,7 @@ std::vector FE_Nedelec::get_dpo_vector (const unsigned int degree, bool dg) { std::vector dpo (dim + 1); - + if (dg) { dpo[dim] = PolynomialsNedelec::compute_n_pols(degree); @@ -1984,11 +1984,11 @@ FE_Nedelec::get_dpo_vector (const unsigned int degree, bool dg) dpo[0] = 0; dpo[1] = degree + 1; dpo[2] = 2 * degree * (degree + 1); - + if (dim == 3) - dpo[3] = 3 * degree * degree * (degree + 1); + dpo[3] = 3 * degree * degree * (degree + 1); } - + return dpo; } @@ -2297,24 +2297,24 @@ FE_Nedelec::compare_for_face_domination (const FiniteElement &fe_other = dynamic_cast*>(&fe_other)) { if (this->degree < fe_nedelec_other->degree) - return FiniteElementDomination::this_element_dominates; + return FiniteElementDomination::this_element_dominates; else if (this->degree == fe_nedelec_other->degree) - return FiniteElementDomination::either_element_can_dominate; + return FiniteElementDomination::either_element_can_dominate; else - return FiniteElementDomination::other_element_dominates; + return FiniteElementDomination::other_element_dominates; } else if (dynamic_cast*>(&fe_other) != 0) { - // the FE_Nothing has no - // degrees of - // freedom. nevertheless, we - // say that the FE_Q element - // dominates so that we don't - // have to force the FE_Q side - // to become a zero function - // and rather allow the - // function to be discontinuous - // along the interface + // the FE_Nothing has no + // degrees of + // freedom. nevertheless, we + // say that the FE_Q element + // dominates so that we don't + // have to force the FE_Q side + // to become a zero function + // and rather allow the + // function to be discontinuous + // along the interface return FiniteElementDomination::other_element_dominates; } @@ -2344,17 +2344,17 @@ std::vector > FE_Nedelec::hp_line_dof_identities (const FiniteElement& fe_other) const { - // we can presently only compute these - // identities if both FEs are - // FE_Nedelec or if the other one is an - // FE_Nothing + // we can presently only compute these + // identities if both FEs are + // FE_Nedelec or if the other one is an + // FE_Nothing if (const FE_Nedelec *fe_nedelec_other = dynamic_cast*> (&fe_other)) { - // dofs are located on lines, so - // two dofs are identical, if their - // edge shape functions have the - // same polynomial degree. + // dofs are located on lines, so + // two dofs are identical, if their + // edge shape functions have the + // same polynomial degree. std::vector > identities; for (unsigned int i = 0; @@ -2367,10 +2367,10 @@ const else if (dynamic_cast*> (&fe_other) != 0) { - // the FE_Nothing has no - // degrees of freedom, so there - // are no equivalencies to be - // recorded + // the FE_Nothing has no + // degrees of freedom, so there + // are no equivalencies to be + // recorded return std::vector > (); } @@ -2386,17 +2386,17 @@ std::vector > FE_Nedelec::hp_quad_dof_identities (const FiniteElement& fe_other) const { - // we can presently only compute - // these identities if both FEs are - // FE_Nedelec or if the other one is an - // FE_Nothing + // we can presently only compute + // these identities if both FEs are + // FE_Nedelec or if the other one is an + // FE_Nothing if (const FE_Nedelec *fe_nedelec_other = dynamic_cast*> (&fe_other)) { - // dofs are located on the interior - // of faces, so two dofs are identical, - // if their face shape functions have - // the same polynomial degree. + // dofs are located on the interior + // of faces, so two dofs are identical, + // if their face shape functions have + // the same polynomial degree. const unsigned int p = fe_nedelec_other->degree; const unsigned int q = this->degree; const unsigned int p_min = std::min (p, q); @@ -2417,10 +2417,10 @@ const else if (dynamic_cast*> (&fe_other) != 0) { - // the FE_Nothing has no - // degrees of freedom, so there - // are no equivalencies to be - // recorded + // the FE_Nothing has no + // degrees of freedom, so there + // are no equivalencies to be + // recorded return std::vector > (); } @@ -2444,9 +2444,9 @@ FE_Nedelec::get_face_interpolation_matrix (const FiniteElement& source, FullMatrix& interpolation_matrix) const { - // this is only implemented, if the - // source FE is also a - // Nedelec element + // this is only implemented, if the + // source FE is also a + // Nedelec element typedef FE_Nedelec FEN; typedef FiniteElement FEL; @@ -2460,12 +2460,12 @@ const ExcDimensionMismatch (interpolation_matrix.n (), this->dofs_per_face)); - // ok, source is a Nedelec element, so - // we will be able to do the work + // ok, source is a Nedelec element, so + // we will be able to do the work const FE_Nedelec &source_fe = dynamic_cast&> (source); - // Make sure, that the element, + // Make sure, that the element, // for which the DoFs should be // constrained is the one with // the higher polynomial degree. @@ -2473,9 +2473,9 @@ const // also if this assertion is not // satisfied. But the matrices // produced in that case might - // lead to problems in the + // lead to problems in the // hp procedures, which use this - // method. + // method. Assert (this->dofs_per_face <= source_fe.dofs_per_face, typename FEL::ExcInterpolationNotImplemented ()); interpolation_matrix = 0; @@ -2551,9 +2551,9 @@ FE_Nedelec::get_subface_interpolation_matrix( const unsigned int subface, FullMatrix& interpolation_matrix) const { - // this is only implemented, if the - // source FE is also a - // Nedelec element + // this is only implemented, if the + // source FE is also a + // Nedelec element typedef FE_Nedelec FEN; typedef FiniteElement FEL; @@ -2567,12 +2567,12 @@ FE_Nedelec::get_subface_interpolation_matrix( ExcDimensionMismatch (interpolation_matrix.n (), this->dofs_per_face)); - // ok, source is a Nedelec element, so - // we will be able to do the work + // ok, source is a Nedelec element, so + // we will be able to do the work const FE_Nedelec &source_fe = dynamic_cast&> (source); - // Make sure, that the element, + // Make sure, that the element, // for which the DoFs should be // constrained is the one with // the higher polynomial degree. @@ -2580,14 +2580,14 @@ FE_Nedelec::get_subface_interpolation_matrix( // also if this assertion is not // satisfied. But the matrices // produced in that case might - // lead to problems in the + // lead to problems in the // hp procedures, which use this - // method. + // method. Assert (this->dofs_per_face <= source_fe.dofs_per_face, typename FEL::ExcInterpolationNotImplemented ()); interpolation_matrix = 0.0; - // Perform projection-based interpolation - // as usual. + // Perform projection-based interpolation + // as usual. const QGauss<1> edge_quadrature (source_fe.degree); const std::vector >& edge_quadrature_points = edge_quadrature.get_points (); @@ -2601,9 +2601,9 @@ FE_Nedelec::get_subface_interpolation_matrix( for (unsigned int q_point = 0; q_point < n_edge_quadrature_points; ++q_point) { - const Point quadrature_point (0.0, - 0.5 * (edge_quadrature_points[q_point] (0) - + subface)); + const Point quadrature_point (0.0, + 0.5 * (edge_quadrature_points[q_point] (0) + + subface)); interpolation_matrix (0, dof) += 0.5 * edge_quadrature.weight (q_point) @@ -2697,8 +2697,8 @@ FE_Nedelec::get_subface_interpolation_matrix( Point quadrature_point (0.5 * (i + shifts[subface][0]), 0.5 * (edge_quadrature_points[q_point] (0) - + shifts[subface][1]), - 0.0); + + shifts[subface][1]), + 0.0); interpolation_matrix (i * source_fe.degree, dof) += weight * this->shape_value_component @@ -2984,7 +2984,7 @@ FE_Nedelec::interpolate (std::vector& local_dofs, unsigned int offset) const { const unsigned int deg = this->degree-1; - + Assert (values.size () == this->generalized_support_points.size (), ExcDimensionMismatch (values.size (), this->generalized_support_points.size ())); @@ -3047,9 +3047,9 @@ FE_Nedelec::interpolate (std::vector& local_dofs, // equations. if (this->degree > 1) { - // We start with projection - // on the higher order edge - // shape function. + // We start with projection + // on the higher order edge + // shape function. const std::vector >& lobatto_polynomials = Polynomials::Lobatto::generate_complete_basis @@ -3138,12 +3138,12 @@ FE_Nedelec::interpolate (std::vector& local_dofs, const QGauss reference_quadrature (this->degree); const std::vector >& legendre_polynomials - = Polynomials::Legendre::generate_complete_basis (this->degree-1); + = Polynomials::Legendre::generate_complete_basis (this->degree-1); const unsigned int& n_interior_points = reference_quadrature.size (); system_matrix.reinit ((this->degree-1) * this->degree, - (this->degree-1) * this->degree); + (this->degree-1) * this->degree); system_matrix = 0; for (unsigned int i = 0; i < this->degree; ++i) @@ -3369,9 +3369,9 @@ FE_Nedelec::interpolate (std::vector& local_dofs, // equations. if (this->degree > 1) { - // We start with projection - // on the higher order edge - // shape function. + // We start with projection + // on the higher order edge + // shape function. const std::vector >& lobatto_polynomials = Polynomials::Lobatto::generate_complete_basis @@ -3466,7 +3466,7 @@ FE_Nedelec::interpolate (std::vector& local_dofs, n_face_points = n_edge_points * n_edge_points; system_matrix.reinit ((this->degree-1) * this->degree, - (this->degree-1) * this->degree); + (this->degree-1) * this->degree); system_matrix = 0; for (unsigned int i = 0; i < this->degree; ++i) @@ -3507,7 +3507,7 @@ FE_Nedelec::interpolate (std::vector& local_dofs, // Set up the right hand side // for the horizontal shape // functions. - system_rhs = 0; + system_rhs = 0; for (unsigned int q_point = 0; q_point < n_face_points; ++q_point) @@ -3611,7 +3611,7 @@ FE_Nedelec::interpolate (std::vector& local_dofs, // Set up the right hand side // for the horizontal shape // functions. - system_rhs = 0; + system_rhs = 0; for (unsigned int q_point = 0; q_point < n_face_points; ++q_point) @@ -3718,7 +3718,7 @@ FE_Nedelec::interpolate (std::vector& local_dofs, // Set up the right hand side // for the horizontal shape // functions. - system_rhs = 0; + system_rhs = 0; for (unsigned int q_point = 0; q_point < n_face_points; ++q_point) @@ -4593,9 +4593,9 @@ const // equations. if (this->degree-1 > 1) { - // We start with projection - // on the higher order edge - // shape function. + // We start with projection + // on the higher order edge + // shape function. const std::vector >& lobatto_polynomials = Polynomials::Lobatto::generate_complete_basis @@ -4621,7 +4621,7 @@ const * lobatto_polynomials_grad[i + 1].value (this->generalized_face_support_points[q_point] (1)); - + FullMatrix system_matrix_inv (this->degree-1, this->degree-1); system_matrix_inv.invert (system_matrix); @@ -4681,10 +4681,10 @@ const n_interior_points = reference_quadrature.size (); const std::vector >& legendre_polynomials - = Polynomials::Legendre::generate_complete_basis (this->degree-1); + = Polynomials::Legendre::generate_complete_basis (this->degree-1); system_matrix.reinit ((this->degree-1) * this->degree, - (this->degree-1) * this->degree); + (this->degree-1) * this->degree); system_matrix = 0; for (unsigned int i = 0; i < this->degree; ++i) @@ -4877,9 +4877,9 @@ const // equations. if (this->degree > 1) { - // We start with projection - // on the higher order edge - // shape function. + // We start with projection + // on the higher order edge + // shape function. const std::vector >& lobatto_polynomials = Polynomials::Lobatto::generate_complete_basis @@ -4919,7 +4919,7 @@ const for (unsigned int line = 0; line < GeometryInfo::lines_per_cell; ++line) { - // Set up the right hand side. + // Set up the right hand side. system_rhs = 0; for (unsigned int q_point = 0; q_point < this->degree; ++q_point) @@ -4965,7 +4965,7 @@ const const unsigned int n_face_points = n_edge_points * n_edge_points; system_matrix.reinit ((this->degree-1) * this->degree, - (this->degree-1) * this->degree); + (this->degree-1) * this->degree); system_matrix = 0; for (unsigned int i = 0; i < this->degree; ++i) diff --git a/deal.II/source/fe/fe_nothing.cc b/deal.II/source/fe/fe_nothing.cc index 39eb591b35..b64b834384 100644 --- a/deal.II/source/fe/fe_nothing.cc +++ b/deal.II/source/fe/fe_nothing.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2009, 2011 by the deal.II authors +// Copyright (C) 2009, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -28,11 +28,11 @@ template FE_Nothing::FE_Nothing (const unsigned n_components) : FiniteElement - (FiniteElementData(std::vector(dim+1,0), - n_components, 0, - FiniteElementData::unknown), - std::vector(), - std::vector >() ) + (FiniteElementData(std::vector(dim+1,0), + n_components, 0, + FiniteElementData::unknown), + std::vector(), + std::vector >() ) { // in most other elements we have to set up all sorts of stuff // here. there isn't much that we have to do here; in particular, @@ -86,7 +86,7 @@ FE_Nothing::update_each (const UpdateFlags /*flags*/) const template double FE_Nothing::shape_value (const unsigned int /*i*/, - const Point & /*p*/) const + const Point & /*p*/) const { Assert(false,ExcMessage(zero_dof_message)); return 0; @@ -97,8 +97,8 @@ FE_Nothing::shape_value (const unsigned int /*i*/, template typename Mapping::InternalDataBase * FE_Nothing::get_data (const UpdateFlags /*flags*/, - const Mapping & /*mapping*/, - const Quadrature & /*quadrature*/) const + const Mapping & /*mapping*/, + const Quadrature & /*quadrature*/) const { // Create a default data object. Normally we would then // need to resize things to hold the appropriate numbers @@ -114,12 +114,12 @@ template void FE_Nothing:: fill_fe_values (const Mapping & /*mapping*/, - const typename Triangulation::cell_iterator & /*cell*/, - const Quadrature & /*quadrature*/, - typename Mapping::InternalDataBase & /*mapping_data*/, - typename Mapping::InternalDataBase & /*fedata*/, - FEValuesData & /*data*/, - CellSimilarity::Similarity & /*cell_similarity*/) const + const typename Triangulation::cell_iterator & /*cell*/, + const Quadrature & /*quadrature*/, + typename Mapping::InternalDataBase & /*mapping_data*/, + typename Mapping::InternalDataBase & /*fedata*/, + FEValuesData & /*data*/, + CellSimilarity::Similarity & /*cell_similarity*/) const { // leave data fields empty } @@ -130,12 +130,12 @@ template void FE_Nothing:: fill_fe_face_values (const Mapping & /*mapping*/, - const typename Triangulation::cell_iterator & /*cell*/, - const unsigned int /*face*/, - const Quadrature & /*quadrature*/, - typename Mapping::InternalDataBase & /*mapping_data*/, - typename Mapping::InternalDataBase & /*fedata*/, - FEValuesData & /*data*/) const + const typename Triangulation::cell_iterator & /*cell*/, + const unsigned int /*face*/, + const Quadrature & /*quadrature*/, + typename Mapping::InternalDataBase & /*mapping_data*/, + typename Mapping::InternalDataBase & /*fedata*/, + FEValuesData & /*data*/) const { // leave data fields empty } @@ -144,13 +144,13 @@ template void FE_Nothing:: fill_fe_subface_values (const Mapping & /*mapping*/, - const typename Triangulation::cell_iterator & /*cell*/, - const unsigned int /*face*/, - const unsigned int /*subface*/, - const Quadrature & /*quadrature*/, - typename Mapping::InternalDataBase & /*mapping_data*/, - typename Mapping::InternalDataBase & /*fedata*/, - FEValuesData & /*data*/) const + const typename Triangulation::cell_iterator & /*cell*/, + const unsigned int /*face*/, + const unsigned int /*subface*/, + const Quadrature & /*quadrature*/, + typename Mapping::InternalDataBase & /*mapping_data*/, + typename Mapping::InternalDataBase & /*fedata*/, + FEValuesData & /*data*/) const { // leave data fields empty } @@ -171,9 +171,9 @@ FE_Nothing :: hp_vertex_dof_identities (const FiniteElement &/*fe_other*/) const { // the FE_Nothing has no - // degrees of freedom, so there - // are no equivalencies to be - // recorded + // degrees of freedom, so there + // are no equivalencies to be + // recorded return std::vector > (); } @@ -184,9 +184,9 @@ FE_Nothing :: hp_line_dof_identities (const FiniteElement &/*fe_other*/) const { // the FE_Nothing has no - // degrees of freedom, so there - // are no equivalencies to be - // recorded + // degrees of freedom, so there + // are no equivalencies to be + // recorded return std::vector > (); } @@ -197,9 +197,9 @@ FE_Nothing :: hp_quad_dof_identities (const FiniteElement &/*fe_other*/) const { // the FE_Nothing has no - // degrees of freedom, so there - // are no equivalencies to be - // recorded + // degrees of freedom, so there + // are no equivalencies to be + // recorded return std::vector > (); } diff --git a/deal.II/source/fe/fe_poly.cc b/deal.II/source/fe/fe_poly.cc index d1e3cbae0d..0601ef0c55 100644 --- a/deal.II/source/fe/fe_poly.cc +++ b/deal.II/source/fe/fe_poly.cc @@ -33,10 +33,10 @@ FE_Poly,1,2>::fill_fe_values FEValuesData<1,2> &data, CellSimilarity::Similarity &cell_similarity) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&fedata) != 0, ExcInternalError()); InternalData &fe_data = static_cast (fedata); @@ -45,17 +45,17 @@ FE_Poly,1,2>::fill_fe_values for (unsigned int k=0; kdofs_per_cell; ++k) { if (flags & update_values) - for (unsigned int i=0; icompute_2nd (mapping, cell, QProjector<1>::DataSetDescriptor::cell(), - mapping_data, fe_data, data); + mapping_data, fe_data, data); } @@ -72,8 +72,8 @@ FE_Poly,2,3>::fill_fe_values CellSimilarity::Similarity &cell_similarity) const { - // assert that the following dynamics - // cast is really well-defined. + // assert that the following dynamics + // cast is really well-defined. Assert (dynamic_cast (&fedata) != 0, ExcInternalError()); InternalData &fe_data = static_cast (fedata); @@ -82,17 +82,17 @@ FE_Poly,2,3>::fill_fe_values for (unsigned int k=0; kdofs_per_cell; ++k) { if (flags & update_values) - for (unsigned int i=0; icompute_2nd (mapping, cell, QProjector<2>::DataSetDescriptor::cell(), - mapping_data, fe_data, data); + mapping_data, fe_data, data); } @@ -107,10 +107,10 @@ FE_Poly,1,2>::fill_fe_values ( FEValuesData<1,2> &data, CellSimilarity::Similarity &cell_similarity) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&fedata) != 0, ExcInternalError()); InternalData &fe_data = static_cast (fedata); @@ -120,17 +120,17 @@ FE_Poly,1,2>::fill_fe_values ( for (unsigned int k=0; kdofs_per_cell; ++k) { if (flags & update_values) - for (unsigned int i=0; icompute_2nd (mapping, cell, QProjector<1>::DataSetDescriptor::cell(), - mapping_data, fe_data, data); + mapping_data, fe_data, data); } @@ -153,18 +153,18 @@ FE_Poly,2,3>::fill_fe_values for (unsigned int k=0; kdofs_per_cell; ++k) { if (flags & update_values) - for (unsigned int i=0; icompute_2nd (mapping, cell, QProjector<2>::DataSetDescriptor::cell(), - mapping_data, fe_data, data); + mapping_data, fe_data, data); } diff --git a/deal.II/source/fe/fe_poly_tensor.cc b/deal.II/source/fe/fe_poly_tensor.cc index 9157a7be46..ab42ebeefc 100644 --- a/deal.II/source/fe/fe_poly_tensor.cc +++ b/deal.II/source/fe/fe_poly_tensor.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -38,10 +38,10 @@ namespace */ void get_face_sign_change (const Triangulation<1>::cell_iterator &, - const unsigned int , - std::vector &face_sign) + const unsigned int , + std::vector &face_sign) { - // nothing to do in 1d + // nothing to do in 1d std::fill (face_sign.begin (), face_sign.end (), 1.0); } @@ -49,34 +49,34 @@ namespace void get_face_sign_change (const Triangulation<2>::cell_iterator &cell, - const unsigned int dofs_per_face, - std::vector &face_sign) + const unsigned int dofs_per_face, + std::vector &face_sign) { const unsigned int dim = 2; const unsigned int spacedim = 2; - // Default is no sign - // change. I.e. multiply by one. + // Default is no sign + // change. I.e. multiply by one. std::fill (face_sign.begin (), face_sign.end (), 1.0); for (unsigned int f = GeometryInfo::faces_per_cell / 2; - f < GeometryInfo::faces_per_cell; ++f) + f < GeometryInfo::faces_per_cell; ++f) { - Triangulation::face_iterator face = cell->face (f); - if (!face->at_boundary ()) - { - const unsigned int nn = cell->neighbor_face_no(f); + Triangulation::face_iterator face = cell->face (f); + if (!face->at_boundary ()) + { + const unsigned int nn = cell->neighbor_face_no(f); - if (nn < GeometryInfo::faces_per_cell / 2) - for (unsigned int j = 0; j < dofs_per_face; ++j) - { - Assert (f * dofs_per_face + j < face_sign.size(), - ExcInternalError()); + if (nn < GeometryInfo::faces_per_cell / 2) + for (unsigned int j = 0; j < dofs_per_face; ++j) + { + Assert (f * dofs_per_face + j < face_sign.size(), + ExcInternalError()); //TODO: This is probably only going to work for those elements for which all dofs are face dofs - face_sign[f * dofs_per_face + j] = -1.0; - } - } + face_sign[f * dofs_per_face + j] = -1.0; + } + } } } @@ -84,8 +84,8 @@ namespace void get_face_sign_change (const Triangulation<3>::cell_iterator &/*cell*/, - const unsigned int /*dofs_per_face*/, - std::vector &face_sign) + const unsigned int /*dofs_per_face*/, + std::vector &face_sign) { std::fill (face_sign.begin (), face_sign.end (), 1.0); //TODO: think about what it would take here @@ -96,23 +96,23 @@ namespace template FE_PolyTensor::FE_PolyTensor (const unsigned int degree, - const FiniteElementData &fe_data, - const std::vector &restriction_is_additive_flags, - const std::vector > &nonzero_components) - : - FiniteElement (fe_data, - restriction_is_additive_flags, - nonzero_components), + const FiniteElementData &fe_data, + const std::vector &restriction_is_additive_flags, + const std::vector > &nonzero_components) + : + FiniteElement (fe_data, + restriction_is_additive_flags, + nonzero_components), poly_space(POLY(degree)) { cached_point(0) = -1; - // Set up the table converting - // components to base - // components. Since we have only - // one base element, everything - // remains zero except the - // component in the base, which is - // the component itself + // Set up the table converting + // components to base + // components. Since we have only + // one base element, everything + // remains zero except the + // component in the base, which is + // the component itself for (unsigned int comp=0;compn_components() ;++comp) this->component_to_base_table[comp].first.second = comp; } @@ -134,8 +134,8 @@ FE_PolyTensor::shape_value (const unsigned int, const Point double FE_PolyTensor::shape_value_component (const unsigned int i, - const Point &p, - const unsigned int component) const + const Point &p, + const unsigned int component) const { Assert (idofs_per_cell, ExcIndexRange(i,0,this->dofs_per_cell)); Assert (component < dim, ExcIndexRange (component, 0, dim)); @@ -161,7 +161,7 @@ FE_PolyTensor::shape_value_component (const unsigned int i, template Tensor<1,dim> FE_PolyTensor::shape_grad (const unsigned int, - const Point &) const + const Point &) const { typedef FiniteElement FEE; Assert(false, typename FEE::ExcFENotPrimitive()); @@ -173,8 +173,8 @@ FE_PolyTensor::shape_grad (const unsigned int, template Tensor<1,dim> FE_PolyTensor::shape_grad_component (const unsigned int i, - const Point &p, - const unsigned int component) const + const Point &p, + const unsigned int component) const { Assert (idofs_per_cell, ExcIndexRange(i,0,this->dofs_per_cell)); Assert (component < dim, ExcIndexRange (component, 0, dim)); @@ -212,8 +212,8 @@ FE_PolyTensor::shape_grad_grad (const unsigned int, const Poi template Tensor<2,dim> FE_PolyTensor::shape_grad_grad_component (const unsigned int i, - const Point &p, - const unsigned int component) const + const Point &p, + const unsigned int component) const { Assert (idofs_per_cell, ExcIndexRange(i,0,this->dofs_per_cell)); Assert (component < dim, ExcIndexRange (component, 0, dim)); @@ -248,14 +248,14 @@ FE_PolyTensor::get_data ( const Mapping &mapping, const Quadrature &quadrature) const { - // generate a new data object and - // initialize some fields + // generate a new data object and + // initialize some fields InternalData* data = new InternalData; - // check what needs to be - // initialized only once and what - // on every cell/face/subface we - // visit + // check what needs to be + // initialized only once and what + // on every cell/face/subface we + // visit data->update_once = update_once(update_flags); data->update_each = update_each(update_flags); data->update_flags = data->update_once | data->update_each; @@ -263,20 +263,20 @@ FE_PolyTensor::get_data ( const UpdateFlags flags(data->update_flags); const unsigned int n_q_points = quadrature.size(); - // some scratch arrays + // some scratch arrays std::vector > values(0); std::vector > grads(0); std::vector > grad_grads(0); - // initialize fields only if really - // necessary. otherwise, don't - // allocate memory + // initialize fields only if really + // necessary. otherwise, don't + // allocate memory if (flags & update_values) { values.resize (this->dofs_per_cell); data->shape_values.resize (this->dofs_per_cell); for (unsigned int i=0;idofs_per_cell;++i) - data->shape_values[i].resize (n_q_points); + data->shape_values[i].resize (n_q_points); } if (flags & update_gradients) @@ -284,60 +284,60 @@ FE_PolyTensor::get_data ( grads.resize (this->dofs_per_cell); data->shape_grads.resize (this->dofs_per_cell); for (unsigned int i=0;idofs_per_cell;++i) - data->shape_grads[i].resize (n_q_points); + data->shape_grads[i].resize (n_q_points); } - // if second derivatives through - // finite differencing is required, - // then initialize some objects for - // that + // if second derivatives through + // finite differencing is required, + // then initialize some objects for + // that if (flags & update_hessians) { // grad_grads.resize (this->dofs_per_cell); data->initialize_2nd (this, mapping, quadrature); } - // Compute shape function values - // and derivatives on the reference - // cell. Make sure, that for the - // node values N_i holds - // N_i(v_j)=\delta_ij for all basis - // functions v_j + // Compute shape function values + // and derivatives on the reference + // cell. Make sure, that for the + // node values N_i holds + // N_i(v_j)=\delta_ij for all basis + // functions v_j if (flags & (update_values | update_gradients)) for (unsigned int k=0; kdofs_per_cell; ++i) - data->shape_values[i][k] = values[i]; - else - for (unsigned int i=0; idofs_per_cell; ++i) - { - Tensor<1,dim> add_values; - for (unsigned int j=0; jdofs_per_cell; ++j) - add_values += inverse_node_matrix(j,i) * values[j]; - data->shape_values[i][k] = add_values; - } - } - - if (flags & update_gradients) - { - if (inverse_node_matrix.n_cols() == 0) - for (unsigned int i=0; idofs_per_cell; ++i) - data->shape_grads[i][k] = grads[i]; - else - for (unsigned int i=0; idofs_per_cell; ++i) - { - Tensor<2,dim> add_grads; - for (unsigned int j=0; jdofs_per_cell; ++j) - add_grads += inverse_node_matrix(j,i) * grads[j]; - data->shape_grads[i][k] = add_grads; - } - } + poly_space.compute(quadrature.point(k), + values, grads, grad_grads); + + if (flags & update_values) + { + if (inverse_node_matrix.n_cols() == 0) + for (unsigned int i=0; idofs_per_cell; ++i) + data->shape_values[i][k] = values[i]; + else + for (unsigned int i=0; idofs_per_cell; ++i) + { + Tensor<1,dim> add_values; + for (unsigned int j=0; jdofs_per_cell; ++j) + add_values += inverse_node_matrix(j,i) * values[j]; + data->shape_values[i][k] = add_values; + } + } + + if (flags & update_gradients) + { + if (inverse_node_matrix.n_cols() == 0) + for (unsigned int i=0; idofs_per_cell; ++i) + data->shape_grads[i][k] = grads[i]; + else + for (unsigned int i=0; idofs_per_cell; ++i) + { + Tensor<2,dim> add_grads; + for (unsigned int j=0; jdofs_per_cell; ++j) + add_grads += inverse_node_matrix(j,i) * grads[j]; + data->shape_grads[i][k] = add_grads; + } + } } return data; @@ -361,21 +361,21 @@ FE_PolyTensor::fill_fe_values ( FEValuesData &data, CellSimilarity::Similarity &cell_similarity) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&fedata) != 0, - ExcInternalError()); + ExcInternalError()); InternalData &fe_data = static_cast (fedata); const unsigned int n_q_points = quadrature.size(); const UpdateFlags flags(fe_data.current_update_flags()); Assert(!(flags & update_values) || fe_data.shape_values.size() == this->dofs_per_cell, - ExcDimensionMismatch(fe_data.shape_values.size(), this->dofs_per_cell)); + ExcDimensionMismatch(fe_data.shape_values.size(), this->dofs_per_cell)); Assert(!(flags & update_values) || fe_data.shape_values[0].size() == n_q_points, - ExcDimensionMismatch(fe_data.shape_values[0].size(), n_q_points)); + ExcDimensionMismatch(fe_data.shape_values[0].size(), n_q_points)); // Create table with sign changes, due to the special structure of the RT elements. // TODO: Preliminary hack to demonstrate the overall prinicple! @@ -385,10 +385,10 @@ FE_PolyTensor::fill_fe_values ( std::vector sign_change (this->dofs_per_cell, 1.0); get_face_sign_change (cell, this->dofs_per_face, sign_change); - // for Piola mapping, the similarity - // concept cannot be used because of - // possible sign changes from one cell to - // the next. + // for Piola mapping, the similarity + // concept cannot be used because of + // possible sign changes from one cell to + // the next. if ( (mapping_type == mapping_piola) || (mapping_type == mapping_raviart_thomas) ) if (cell_similarity == CellSimilarity::translation) cell_similarity = CellSimilarity::none; @@ -398,118 +398,118 @@ FE_PolyTensor::fill_fe_values ( const unsigned int first = data.shape_function_to_row_table[i]; if (flags & update_values && cell_similarity != CellSimilarity::translation) - switch (mapping_type) - { - case mapping_none: - { - for (unsigned int k=0; k > shape_values (n_q_points); - mapping.transform(fe_data.shape_values[i], - shape_values, mapping_data, mapping_type); - - for (unsigned int k=0; k > shape_values (n_q_points); - mapping.transform(fe_data.shape_values[i], shape_values, - mapping_data, mapping_piola); - for (unsigned int k=0; k > shape_values (n_q_points); - mapping.transform (fe_data.shape_values[i], shape_values, - mapping_data, mapping_covariant); - - for (unsigned int k = 0; k < n_q_points; ++k) - for (unsigned int d = 0; d < dim; ++d) - data.shape_values(first+d,k) = shape_values[k][d]; - - break; - } - - default: - Assert(false, ExcNotImplemented()); - } + switch (mapping_type) + { + case mapping_none: + { + for (unsigned int k=0; k > shape_values (n_q_points); + mapping.transform(fe_data.shape_values[i], + shape_values, mapping_data, mapping_type); + + for (unsigned int k=0; k > shape_values (n_q_points); + mapping.transform(fe_data.shape_values[i], shape_values, + mapping_data, mapping_piola); + for (unsigned int k=0; k > shape_values (n_q_points); + mapping.transform (fe_data.shape_values[i], shape_values, + mapping_data, mapping_covariant); + + for (unsigned int k = 0; k < n_q_points; ++k) + for (unsigned int d = 0; d < dim; ++d) + data.shape_values(first+d,k) = shape_values[k][d]; + + break; + } + + default: + Assert(false, ExcNotImplemented()); + } if (flags & update_gradients && cell_similarity != CellSimilarity::translation) - { - std::vector > shape_grads1 (n_q_points); - //std::vector > shape_grads2 (n_q_points); - - switch (mapping_type) - { - case mapping_none: - { - mapping.transform(fe_data.shape_grads[i], shape_grads1, - mapping_data, mapping_covariant); - for (unsigned int k=0; k > input(fe_data.shape_grads[i].size()); - for (unsigned int k=0; k > shape_grads1 (n_q_points); + //std::vector > shape_grads2 (n_q_points); + + switch (mapping_type) + { + case mapping_none: + { + mapping.transform(fe_data.shape_grads[i], shape_grads1, + mapping_data, mapping_covariant); + for (unsigned int k=0; k > input(fe_data.shape_grads[i].size()); + for (unsigned int k=0; k::fill_fe_values ( // (J^-T)Dv(J^-1) is the // value we want to have on // the real cell. - std::vector > input(fe_data.shape_grads[i].size()); - for (unsigned int k=0; k > input(fe_data.shape_grads[i].size()); + for (unsigned int k=0; kcompute_2nd (mapping, cell, - typename QProjector::DataSetDescriptor().cell(), - mapping_data, fe_data, data); + typename QProjector::DataSetDescriptor().cell(), + mapping_data, fe_data, data); } @@ -559,25 +559,25 @@ FE_PolyTensor::fill_fe_face_values ( typename Mapping::InternalDataBase &fedata, FEValuesData &data) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&fedata) != 0, - ExcInternalError()); + ExcInternalError()); InternalData &fe_data = static_cast (fedata); const unsigned int n_q_points = quadrature.size(); - // offset determines which data set - // to take (all data sets for all - // faces are stored contiguously) + // offset determines which data set + // to take (all data sets for all + // faces are stored contiguously) const typename QProjector::DataSetDescriptor offset = QProjector::DataSetDescriptor::face (face, - cell->face_orientation(face), - cell->face_flip(face), - cell->face_rotation(face), - n_q_points); + cell->face_orientation(face), + cell->face_flip(face), + cell->face_rotation(face), + n_q_points); const UpdateFlags flags(fe_data.update_once | fe_data.update_each); @@ -586,8 +586,8 @@ FE_PolyTensor::fill_fe_face_values ( // Create table with sign changes, due to the special structure of the RT elements. // TODO: Preliminary hack to demonstrate the overall prinicple! - // Compute eventual sign changes depending - // on the neighborhood between two faces. + // Compute eventual sign changes depending + // on the neighborhood between two faces. std::vector sign_change (this->dofs_per_cell, 1.0); get_face_sign_change (cell, this->dofs_per_face, sign_change); @@ -596,147 +596,147 @@ FE_PolyTensor::fill_fe_face_values ( const unsigned int first = data.shape_function_to_row_table[i]; if (flags & update_values) - { - switch (mapping_type) - { - case mapping_none: - { - for (unsigned int k=0; k > shape_values (n_q_points); - mapping.transform(make_slice(fe_data.shape_values[i], offset, n_q_points), - shape_values, mapping_data, mapping_type); - - for (unsigned int k=0; k > shape_values (n_q_points); - mapping.transform(make_slice(fe_data.shape_values[i], offset, n_q_points), - shape_values, mapping_data, mapping_piola); - for (unsigned int k=0; k > shape_values (n_q_points); - mapping.transform (make_slice (fe_data.shape_values[i], offset, n_q_points), - shape_values, mapping_data, mapping_covariant); - - for (unsigned int k = 0; k < n_q_points; ++k) - for (unsigned int d = 0; d < dim; ++d) - data.shape_values(first+d,k) = shape_values[k][d]; - - break; - } - - default: - Assert(false, ExcNotImplemented()); - } - } + { + switch (mapping_type) + { + case mapping_none: + { + for (unsigned int k=0; k > shape_values (n_q_points); + mapping.transform(make_slice(fe_data.shape_values[i], offset, n_q_points), + shape_values, mapping_data, mapping_type); + + for (unsigned int k=0; k > shape_values (n_q_points); + mapping.transform(make_slice(fe_data.shape_values[i], offset, n_q_points), + shape_values, mapping_data, mapping_piola); + for (unsigned int k=0; k > shape_values (n_q_points); + mapping.transform (make_slice (fe_data.shape_values[i], offset, n_q_points), + shape_values, mapping_data, mapping_covariant); + + for (unsigned int k = 0; k < n_q_points; ++k) + for (unsigned int d = 0; d < dim; ++d) + data.shape_values(first+d,k) = shape_values[k][d]; + + break; + } + + default: + Assert(false, ExcNotImplemented()); + } + } if (flags & update_gradients) - { - std::vector > shape_grads1 (n_q_points); - // std::vector > shape_grads2 (n_q_points); - - - switch (mapping_type) - { - case mapping_none: - { - mapping.transform(make_slice(fe_data.shape_grads[i], offset, n_q_points), - shape_grads1, mapping_data, mapping_covariant); - for (unsigned int k=0; k > input(fe_data.shape_grads[i].size()); - for (unsigned int k=0; k > input(fe_data.shape_grads[i].size()); - for (unsigned int k=0; k > shape_grads1 (n_q_points); + // std::vector > shape_grads2 (n_q_points); + + + switch (mapping_type) + { + case mapping_none: + { + mapping.transform(make_slice(fe_data.shape_grads[i], offset, n_q_points), + shape_grads1, mapping_data, mapping_covariant); + for (unsigned int k=0; k > input(fe_data.shape_grads[i].size()); + for (unsigned int k=0; k > input(fe_data.shape_grads[i].size()); + for (unsigned int k=0; k::fill_fe_subface_values ( typename Mapping::InternalDataBase &fedata, FEValuesData &data) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&fedata) != 0, - ExcInternalError()); + ExcInternalError()); InternalData &fe_data = static_cast (fedata); const unsigned int n_q_points = quadrature.size(); - // offset determines which data set - // to take (all data sets for all - // sub-faces are stored contiguously) + // offset determines which data set + // to take (all data sets for all + // sub-faces are stored contiguously) const typename QProjector::DataSetDescriptor offset = QProjector::DataSetDescriptor::subface (face, subface, - cell->face_orientation(face), - cell->face_flip(face), - cell->face_rotation(face), - n_q_points, - cell->subface_case(face)); + cell->face_orientation(face), + cell->face_flip(face), + cell->face_rotation(face), + n_q_points, + cell->subface_case(face)); const UpdateFlags flags(fe_data.update_once | fe_data.update_each); // Assert(mapping_type == independent -// || ( mapping_type == independent_on_cartesian -// && dynamic_cast*>(&mapping) != 0), -// ExcNotImplemented()); +// || ( mapping_type == independent_on_cartesian +// && dynamic_cast*>(&mapping) != 0), +// ExcNotImplemented()); //TODO: Size assertions //TODO: Sign change for the face DoFs! - // Compute eventual sign changes depending - // on the neighborhood between two faces. + // Compute eventual sign changes depending + // on the neighborhood between two faces. std::vector sign_change (this->dofs_per_cell, 1.0); get_face_sign_change (cell, this->dofs_per_face, sign_change); @@ -798,148 +798,148 @@ FE_PolyTensor::fill_fe_subface_values ( const unsigned int first = data.shape_function_to_row_table[i]; if (flags & update_values) - { - switch (mapping_type) - { - case mapping_none: - { - for (unsigned int k=0; k > shape_values (n_q_points); - mapping.transform(make_slice(fe_data.shape_values[i], offset, n_q_points), - shape_values, mapping_data, mapping_type); - - for (unsigned int k=0; k > shape_values (n_q_points); - mapping.transform(make_slice(fe_data.shape_values[i], offset, n_q_points), - shape_values, mapping_data, mapping_piola); - for (unsigned int k=0; k > shape_values (n_q_points); - mapping.transform (make_slice (fe_data.shape_values[i], offset, n_q_points), - shape_values, mapping_data, mapping_covariant); - - for (unsigned int k = 0; k < n_q_points; ++k) - for (unsigned int d = 0; d < dim; ++d) - data.shape_values(first+d,k) = shape_values[k][d]; - - break; - } - default: - Assert(false, ExcNotImplemented()); - } - } + { + switch (mapping_type) + { + case mapping_none: + { + for (unsigned int k=0; k > shape_values (n_q_points); + mapping.transform(make_slice(fe_data.shape_values[i], offset, n_q_points), + shape_values, mapping_data, mapping_type); + + for (unsigned int k=0; k > shape_values (n_q_points); + mapping.transform(make_slice(fe_data.shape_values[i], offset, n_q_points), + shape_values, mapping_data, mapping_piola); + for (unsigned int k=0; k > shape_values (n_q_points); + mapping.transform (make_slice (fe_data.shape_values[i], offset, n_q_points), + shape_values, mapping_data, mapping_covariant); + + for (unsigned int k = 0; k < n_q_points; ++k) + for (unsigned int d = 0; d < dim; ++d) + data.shape_values(first+d,k) = shape_values[k][d]; + + break; + } + default: + Assert(false, ExcNotImplemented()); + } + } if (flags & update_gradients) - { - std::vector > shape_grads1 (n_q_points); - std::vector > shape_grads2 (n_q_points); - - switch (mapping_type) - { - case mapping_none: - { - mapping.transform(make_slice(fe_data.shape_grads[i], offset, n_q_points), - shape_grads1, mapping_data, mapping_covariant); - for (unsigned int k=0; k > input(fe_data.shape_grads[i].size()); - for (unsigned int k=0; k > input(fe_data.shape_grads[i].size()); - for (unsigned int k=0; k > shape_grads1 (n_q_points); + std::vector > shape_grads2 (n_q_points); + + switch (mapping_type) + { + case mapping_none: + { + mapping.transform(make_slice(fe_data.shape_grads[i], offset, n_q_points), + shape_grads1, mapping_data, mapping_covariant); + for (unsigned int k=0; k > input(fe_data.shape_grads[i].size()); + for (unsigned int k=0; k > input(fe_data.shape_grads[i].size()); + for (unsigned int k=0; k::update_each (const UpdateFlags flags) const case mapping_raviart_thomas: case mapping_piola: { - if (flags & update_values) - out |= update_values | update_piola; + if (flags & update_values) + out |= update_values | update_piola; - if (flags & update_gradients) - out |= update_gradients | update_piola | update_covariant_transformation; + if (flags & update_gradients) + out |= update_gradients | update_piola | update_covariant_transformation; - if (flags & update_hessians) - out |= update_hessians | update_piola | update_covariant_transformation; + if (flags & update_hessians) + out |= update_hessians | update_piola | update_covariant_transformation; - break; + break; } case mapping_piola_gradient: { - if (flags & update_values) - out |= update_values | update_piola; + if (flags & update_values) + out |= update_values | update_piola; - if (flags & update_gradients) - out |= update_gradients | update_piola | update_covariant_transformation; + if (flags & update_gradients) + out |= update_gradients | update_piola | update_covariant_transformation; - if (flags & update_hessians) - out |= update_hessians | update_piola | update_covariant_transformation; + if (flags & update_hessians) + out |= update_hessians | update_piola | update_covariant_transformation; - break; + break; } case mapping_nedelec: { - if (flags & update_values) - out |= update_values | update_covariant_transformation; + if (flags & update_values) + out |= update_values | update_covariant_transformation; - if (flags & update_gradients) - out |= update_gradients | update_covariant_transformation; + if (flags & update_gradients) + out |= update_gradients | update_covariant_transformation; - if (flags & update_hessians) - out |= update_hessians | update_covariant_transformation; + if (flags & update_hessians) + out |= update_hessians | update_covariant_transformation; break; } default: { - Assert (false, ExcNotImplemented()); + Assert (false, ExcNotImplemented()); } } diff --git a/deal.II/source/fe/fe_q.cc b/deal.II/source/fe/fe_q.cc index c5d2c77b8d..eb66c94564 100644 --- a/deal.II/source/fe/fe_q.cc +++ b/deal.II/source/fe/fe_q.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -53,9 +53,9 @@ namespace FE_Q_Helper { namespace { - // given a permutation array, - // compute and return the inverse - // permutation + // given a permutation array, + // compute and return the inverse + // permutation #ifdef DEAL_II_ANON_NAMESPACE_BUG static #endif @@ -65,17 +65,17 @@ namespace FE_Q_Helper { std::vector out (in.size()); for (unsigned int i=0; i #ifdef DEAL_II_ANON_NAMESPACE_BUG static @@ -85,16 +85,16 @@ namespace FE_Q_Helper zero_indices (unsigned int indices[dim]) { for (unsigned int d=0; d #ifdef DEAL_II_ANON_NAMESPACE_BUG static @@ -102,26 +102,26 @@ namespace FE_Q_Helper inline void increment_indices (unsigned int indices[dim], - const unsigned int dofs1d) + const unsigned int dofs1d) { ++indices[0]; for (int d=0; d #ifdef DEAL_II_ANON_NAMESPACE_BUG static @@ -129,20 +129,20 @@ namespace FE_Q_Helper inline std::vector > generate_poly_space1d (const std::vector > &unit_support_points, - const std::vector &index_map_inverse, - const unsigned int dofs1d) + const std::vector &index_map_inverse, + const unsigned int dofs1d) { AssertDimension (Utilities::fixed_power (dofs1d), - unit_support_points.size()); + unit_support_points.size()); std::vector > points1d (dofs1d); for (unsigned int i=0; i(unit_support_points[j](0)); - for (unsigned int d=1; d(unit_support_points[j](0)); + for (unsigned int d=1; d struct FE_Q::Implementation { - /** - * Initialize the hanging node - * constraints matrices. Called from the - * constructor in case the finite element - * is based on quadrature points. - */ + /** + * Initialize the hanging node + * constraints matrices. Called from the + * constructor in case the finite element + * is based on quadrature points. + */ template static void initialize_constraints (const Quadrature<1> &, - FE_Q<1,spacedim> &) + FE_Q<1,spacedim> &) { - // no constraints in 1d + // no constraints in 1d } template static void initialize_constraints (const Quadrature<1> &points, - FE_Q<2,spacedim> &fe) + FE_Q<2,spacedim> &fe) { - const unsigned int dim = 2; - - // restricted to each face, the - // traces of the shape functions is - // an element of P_{k} (in 2d), or - // Q_{k} (in 3d), where k is the - // degree of the element. from - // this, we interpolate between - // mother and cell face. - - // the interpolation process works - // as follows: on each subface, - // we want that finite element - // solutions from both sides - // coincide. i.e. if a and b are - // expansion coefficients for the - // shape functions from both sides, - // we seek a relation between a and - // b such that - // sum_j a_j phi^c_j(x) - // == sum_j b_j phi_j(x) - // for all points x on the - // interface. here, phi^c_j are the - // shape functions on the small - // cell on one side of the face, - // and phi_j those on the big cell - // on the other side. To get this - // relation, it suffices to look at - // a sufficient number of points - // for which this has to hold. if - // there are n functions, then we - // need n evaluation points, and we - // choose them equidistantly. - // - // we obtain the matrix system - // A a == B b - // where - // A_ij = phi^c_j(x_i) - // B_ij = phi_j(x_i) - // and the relation we are looking - // for is - // a = A^-1 B b - // - // for the special case of Lagrange - // interpolation polynomials, A_ij - // reduces to delta_ij, and - // a_i = B_ij b_j - // Hence, - // interface_constraints(i,j)=B_ij. - // - // for the general case, where we - // don't have Lagrange - // interpolation polynomials, this - // is a little more - // complicated. Then we would - // evaluate at a number of points - // and invert the interpolation - // matrix A. - // - // Note, that we build up these - // matrices for all subfaces at - // once, rather than considering - // them separately. the reason is - // that we finally will want to - // have them in this order anyway, - // as this is the format we need - // inside deal.II - - // In the following the points x_i - // are constructed in following - // order (n=degree-1) - // *----------*---------* - // 1..n 0 n+1..2n - // i.e. first the midpoint of the - // line, then the support points on - // subface 0 and on subface 1 - std::vector > constraint_points; - // Add midpoint - constraint_points.push_back (Point (0.5)); - - if (fe.degree>1) - { - const unsigned int n=fe.degree-1; - const double step=1./fe.degree; - // subface 0 - for (unsigned int i=1; i<=n; ++i) - constraint_points.push_back ( - GeometryInfo::child_to_cell_coordinates(Point(i*step),0)); - // subface 1 - for (unsigned int i=1; i<=n; ++i) - constraint_points.push_back ( - GeometryInfo::child_to_cell_coordinates(Point(i*step),1)); - } - - // Now construct relation between - // destination (child) and source (mother) - // dofs. - const std::vector > polynomials= - Polynomials::generate_complete_Lagrange_basis(points.get_points()); - - fe.interface_constraints - .TableBase<2,double>::reinit (fe.interface_constraints_size()); - - for (unsigned int i=0; i > constraint_points; + // Add midpoint + constraint_points.push_back (Point (0.5)); + + if (fe.degree>1) + { + const unsigned int n=fe.degree-1; + const double step=1./fe.degree; + // subface 0 + for (unsigned int i=1; i<=n; ++i) + constraint_points.push_back ( + GeometryInfo::child_to_cell_coordinates(Point(i*step),0)); + // subface 1 + for (unsigned int i=1; i<=n; ++i) + constraint_points.push_back ( + GeometryInfo::child_to_cell_coordinates(Point(i*step),1)); + } + + // Now construct relation between + // destination (child) and source (mother) + // dofs. + const std::vector > polynomials= + Polynomials::generate_complete_Lagrange_basis(points.get_points()); + + fe.interface_constraints + .TableBase<2,double>::reinit (fe.interface_constraints_size()); + + for (unsigned int i=0; i static void initialize_constraints (const Quadrature<1> &points, - FE_Q<3,spacedim> &fe) + FE_Q<3,spacedim> &fe) { - const unsigned int dim = 3; - - // For a detailed documentation of - // the interpolation see the - // FE_Q<2>::initialize_constraints - // function. - - // In the following the points x_i - // are constructed in the order as - // described in the documentation - // of the FiniteElement class - // (fe_base.h), i.e. - // *--15--4--16--* - // | | | - // 10 19 6 20 12 - // | | | - // 1--7---0--8---2 - // | | | - // 9 17 5 18 11 - // | | | - // *--13--3--14--* - std::vector > constraint_points; - - // Add midpoint - constraint_points.push_back (Point (0.5, 0.5)); - - // Add midpoints of lines of - // "mother-face" - constraint_points.push_back (Point (0, 0.5)); - constraint_points.push_back (Point (1, 0.5)); - constraint_points.push_back (Point (0.5, 0)); - constraint_points.push_back (Point (0.5, 1)); - - if (fe.degree>1) - { - const unsigned int n=fe.degree-1; - const double step=1./fe.degree; - std::vector > line_support_points(n); - for (unsigned int i=0; i qline(line_support_points); - - // auxiliary points in 2d - std::vector > p_line(n); - - // Add nodes of lines interior - // in the "mother-face" - - // line 5: use line 9 - QProjector::project_to_subface(qline, 0, 0, p_line); - for (unsigned int i=0; i (0.5, 0)); - // line 6: use line 10 - QProjector::project_to_subface(qline, 0, 1, p_line); - for (unsigned int i=0; i (0.5, 0)); - // line 7: use line 13 - QProjector::project_to_subface(qline, 2, 0, p_line); - for (unsigned int i=0; i (0, 0.5)); - // line 8: use line 14 - QProjector::project_to_subface(qline, 2, 1, p_line); - for (unsigned int i=0; i (0, 0.5)); - - // DoFs on bordering lines - // lines 9-16 - for (unsigned int face=0; face::faces_per_cell; ++face) - for (unsigned int subface=0; - subface::max_children_per_face; ++subface) - { - QProjector::project_to_subface(qline, face, subface, p_line); - constraint_points.insert(constraint_points.end(), - p_line.begin(), p_line.end()); - } - - // Create constraints for - // interior nodes - std::vector > inner_points(n*n); - for (unsigned int i=0, iy=1; iy<=n; ++iy) - for (unsigned int ix=1; ix<=n; ++ix) - inner_points[i++] = Point (ix*step, iy*step); - - // at the moment do this for - // isotropic face refinement only - for (unsigned int child=0; - child::max_children_per_cell; ++child) - for (unsigned int i=0; i::child_to_cell_coordinates(inner_points[i], child)); - } - - // Now construct relation between - // destination (child) and source (mother) - // dofs. - const unsigned int pnts=(fe.degree+1)*(fe.degree+1); - const std::vector > polynomial_basis= - Polynomials::generate_complete_Lagrange_basis(points.get_points()); - - const TensorProductPolynomials face_polynomials(polynomial_basis); - - fe.interface_constraints - .TableBase<2,double>::reinit (fe.interface_constraints_size()); - - for (unsigned int i=0; i constraint_point; - - // Eliminate FP errors in constraint - // points. Due to their origin, they - // must all be fractions of the unit - // interval. If we have polynomial - // degree 4, the refined element has 8 - // intervals. Hence the coordinates - // must be 0, 0.125, 0.25, 0.375 etc. - // Now the coordinates of the - // constraint points will be multiplied - // by the inverse of the interval size - // (in the example by 8). After that - // the coordinates must be integral - // numbers. Hence a normal truncation - // is performed and the coordinates - // will be scaled back. The equal - // treatment of all coordinates should - // eliminate any FP errors. - for (unsigned int k=0; k (constraint_points[i](k) * interval + 0.25); - constraint_point(k) = 1.*coord_int / interval; - - // The following lines of code - // should eliminate the problems - // with the Constraint-Matrix, - // which appeared for P>=4. The - // Constraint-Matrix class - // complained about different - // constraints for the same entry - // of the Constraint-Matrix. - // Actually this difference could - // be attributed to FP errors, as - // it was in the range of - // 1.0e-16. These errors originate - // in the loss of symmetry in the - // FP approximation of the - // shape-functions. Considering a - // 3rd order shape function in 1D, - // we have N0(x)=N3(1-x) and - // N1(x)=N2(1-x). For higher order - // polynomials the FP - // approximations of the shape - // functions do not satisfy these - // equations any more! Thus in the - // following code everything is - // computed in the interval x \in - // [0..0.5], which is sufficient to - // express all values that could - // come out from a computation of - // any shape function in the full - // interval [0..1]. If x > 0.5 the - // computation is done for 1-x with - // the shape function N_{p-n} - // instead of N_n. Hence symmetry - // is preserved and everything - // works fine... - // - // For a different explanation of - // the problem, see the discussion - // in the FiniteElement class - // for constraint matrices in 3d. - mirror[k] = (constraint_point(k) > 0.5); - if (mirror[k]) - constraint_point(k) = 1.0 - constraint_point(k); - } - - for (unsigned j=0; j::initialize_constraints + // function. + + // In the following the points x_i + // are constructed in the order as + // described in the documentation + // of the FiniteElement class + // (fe_base.h), i.e. + // *--15--4--16--* + // | | | + // 10 19 6 20 12 + // | | | + // 1--7---0--8---2 + // | | | + // 9 17 5 18 11 + // | | | + // *--13--3--14--* + std::vector > constraint_points; + + // Add midpoint + constraint_points.push_back (Point (0.5, 0.5)); + + // Add midpoints of lines of + // "mother-face" + constraint_points.push_back (Point (0, 0.5)); + constraint_points.push_back (Point (1, 0.5)); + constraint_points.push_back (Point (0.5, 0)); + constraint_points.push_back (Point (0.5, 1)); + + if (fe.degree>1) + { + const unsigned int n=fe.degree-1; + const double step=1./fe.degree; + std::vector > line_support_points(n); + for (unsigned int i=0; i qline(line_support_points); + + // auxiliary points in 2d + std::vector > p_line(n); + + // Add nodes of lines interior + // in the "mother-face" + + // line 5: use line 9 + QProjector::project_to_subface(qline, 0, 0, p_line); + for (unsigned int i=0; i (0.5, 0)); + // line 6: use line 10 + QProjector::project_to_subface(qline, 0, 1, p_line); + for (unsigned int i=0; i (0.5, 0)); + // line 7: use line 13 + QProjector::project_to_subface(qline, 2, 0, p_line); + for (unsigned int i=0; i (0, 0.5)); + // line 8: use line 14 + QProjector::project_to_subface(qline, 2, 1, p_line); + for (unsigned int i=0; i (0, 0.5)); + + // DoFs on bordering lines + // lines 9-16 + for (unsigned int face=0; face::faces_per_cell; ++face) + for (unsigned int subface=0; + subface::max_children_per_face; ++subface) + { + QProjector::project_to_subface(qline, face, subface, p_line); + constraint_points.insert(constraint_points.end(), + p_line.begin(), p_line.end()); + } + + // Create constraints for + // interior nodes + std::vector > inner_points(n*n); + for (unsigned int i=0, iy=1; iy<=n; ++iy) + for (unsigned int ix=1; ix<=n; ++ix) + inner_points[i++] = Point (ix*step, iy*step); + + // at the moment do this for + // isotropic face refinement only + for (unsigned int child=0; + child::max_children_per_cell; ++child) + for (unsigned int i=0; i::child_to_cell_coordinates(inner_points[i], child)); + } + + // Now construct relation between + // destination (child) and source (mother) + // dofs. + const unsigned int pnts=(fe.degree+1)*(fe.degree+1); + const std::vector > polynomial_basis= + Polynomials::generate_complete_Lagrange_basis(points.get_points()); + + const TensorProductPolynomials face_polynomials(polynomial_basis); + + fe.interface_constraints + .TableBase<2,double>::reinit (fe.interface_constraints_size()); + + for (unsigned int i=0; i constraint_point; + + // Eliminate FP errors in constraint + // points. Due to their origin, they + // must all be fractions of the unit + // interval. If we have polynomial + // degree 4, the refined element has 8 + // intervals. Hence the coordinates + // must be 0, 0.125, 0.25, 0.375 etc. + // Now the coordinates of the + // constraint points will be multiplied + // by the inverse of the interval size + // (in the example by 8). After that + // the coordinates must be integral + // numbers. Hence a normal truncation + // is performed and the coordinates + // will be scaled back. The equal + // treatment of all coordinates should + // eliminate any FP errors. + for (unsigned int k=0; k (constraint_points[i](k) * interval + 0.25); + constraint_point(k) = 1.*coord_int / interval; + + // The following lines of code + // should eliminate the problems + // with the Constraint-Matrix, + // which appeared for P>=4. The + // Constraint-Matrix class + // complained about different + // constraints for the same entry + // of the Constraint-Matrix. + // Actually this difference could + // be attributed to FP errors, as + // it was in the range of + // 1.0e-16. These errors originate + // in the loss of symmetry in the + // FP approximation of the + // shape-functions. Considering a + // 3rd order shape function in 1D, + // we have N0(x)=N3(1-x) and + // N1(x)=N2(1-x). For higher order + // polynomials the FP + // approximations of the shape + // functions do not satisfy these + // equations any more! Thus in the + // following code everything is + // computed in the interval x \in + // [0..0.5], which is sufficient to + // express all values that could + // come out from a computation of + // any shape function in the full + // interval [0..1]. If x > 0.5 the + // computation is done for 1-x with + // the shape function N_{p-n} + // instead of N_n. Hence symmetry + // is preserved and everything + // works fine... + // + // For a different explanation of + // the problem, see the discussion + // in the FiniteElement class + // for constraint matrices in 3d. + mirror[k] = (constraint_point(k) > 0.5); + if (mirror[k]) + constraint_point(k) = 1.0 - constraint_point(k); + } + + for (unsigned j=0; j::Implementation template FE_Q::FE_Q (const unsigned int degree) - : - FE_Poly, dim, spacedim> ( - TensorProductPolynomials(Polynomials::LagrangeEquidistant::generate_complete_basis(degree)), - FiniteElementData(get_dpo_vector(degree), - 1, degree, - FiniteElementData::H1), - std::vector (1, false), - std::vector >(1, std::vector(1,true))), - face_index_map(FE_Q_Helper::invert_numbering(face_lexicographic_to_hierarchic_numbering (degree))) + : + FE_Poly, dim, spacedim> ( + TensorProductPolynomials(Polynomials::LagrangeEquidistant::generate_complete_basis(degree)), + FiniteElementData(get_dpo_vector(degree), + 1, degree, + FiniteElementData::H1), + std::vector (1, false), + std::vector >(1, std::vector(1,true))), + face_index_map(FE_Q_Helper::invert_numbering(face_lexicographic_to_hierarchic_numbering (degree))) { Assert (degree > 0, ExcMessage ("This element can only be used for polynomial degrees " @@ -541,17 +541,17 @@ FE_Q::FE_Q (const unsigned int degree) FETools::hierarchic_to_lexicographic_numbering (*this, renumber); this->poly_space.set_numbering(renumber); - // finally fill in support points - // on cell and face + // finally fill in support points + // on cell and face initialize_unit_support_points (); initialize_unit_face_support_points (); - // reinit constraints + // reinit constraints initialize_constraints (); - // Reinit the vectors of restriction and - // prolongation matrices to the right sizes - // and compute the matrices + // Reinit the vectors of restriction and + // prolongation matrices to the right sizes + // and compute the matrices this->reinit_restriction_and_prolongation_matrices(); initialize_embedding(); initialize_restriction(); @@ -563,15 +563,15 @@ FE_Q::FE_Q (const unsigned int degree) template FE_Q::FE_Q (const Quadrature<1> &points) - : - FE_Poly, dim, spacedim> ( - TensorProductPolynomials(Polynomials::generate_complete_Lagrange_basis(points.get_points())), - FiniteElementData(get_dpo_vector(points.size()-1), - 1, points.size()-1, - FiniteElementData::H1), - std::vector (1, false), - std::vector >(1, std::vector(1,true))), - face_index_map(FE_Q_Helper::invert_numbering(face_lexicographic_to_hierarchic_numbering (points.size()-1))) + : + FE_Poly, dim, spacedim> ( + TensorProductPolynomials(Polynomials::generate_complete_Lagrange_basis(points.get_points())), + FiniteElementData(get_dpo_vector(points.size()-1), + 1, points.size()-1, + FiniteElementData::H1), + std::vector (1, false), + std::vector >(1, std::vector(1,true))), + face_index_map(FE_Q_Helper::invert_numbering(face_lexicographic_to_hierarchic_numbering (points.size()-1))) { const int degree = points.size()-1; @@ -579,25 +579,25 @@ FE_Q::FE_Q (const Quadrature<1> &points) ExcMessage ("This element can only be used for polynomial degrees " "at least zero")); Assert (points.point(0)(0) == 0, - ExcMessage ("The first support point has to be zero.")); + ExcMessage ("The first support point has to be zero.")); Assert (points.point(degree)(0) == 1, - ExcMessage ("The last support point has to be one.")); + ExcMessage ("The last support point has to be one.")); std::vector renumber (this->dofs_per_cell); FETools::hierarchic_to_lexicographic_numbering (*this, renumber); this->poly_space.set_numbering(renumber); - // finally fill in support points - // on cell and face + // finally fill in support points + // on cell and face initialize_unit_support_points (points); initialize_unit_face_support_points (points); - // reinit constraints + // reinit constraints Implementation::initialize_constraints (points, *this); - // Reinit the vectors of restriction and - // prolongation matrices to the right sizes - // and compute the matrices + // Reinit the vectors of restriction and + // prolongation matrices to the right sizes + // and compute the matrices this->reinit_restriction_and_prolongation_matrices(); initialize_embedding(); initialize_restriction(); @@ -611,12 +611,12 @@ template std::string FE_Q::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch std::ostringstream namebuf; bool type = true; @@ -626,33 +626,33 @@ FE_Q::get_name () const const std::vector > &unit_support_points = this->unit_support_points; unsigned int index = 0; - // Decode the support points - // in one coordinate direction. + // Decode the support points + // in one coordinate direction. for (unsigned int j=0;j1) ? (unit_support_points[j](1)==0 && - ((dim>2) ? unit_support_points[j](2)==0: true)) : true) - { - if (index == 0) - points[index] = unit_support_points[j](0); + ((dim>2) ? unit_support_points[j](2)==0: true)) : true) + { + if (index == 0) + points[index] = unit_support_points[j](0); else if (index == 1) - points[n_points-1] = unit_support_points[j](0); + points[n_points-1] = unit_support_points[j](0); else - points[index-1] = unit_support_points[j](0); + points[index-1] = unit_support_points[j](0); - index++; - } + index++; + } } Assert (index == n_points, - ExcMessage ("Could not decode support points in one coordinate direction.")); + ExcMessage ("Could not decode support points in one coordinate direction.")); - // Check whether the support - // points are equidistant. + // Check whether the support + // points are equidistant. for(unsigned int j=0;jdegree) > 1e-15) { - type = false; - break; + type = false; + break; } if (type == true) @@ -660,20 +660,20 @@ FE_Q::get_name () const else { - // Check whether the support - // points come from QGaussLobatto. + // Check whether the support + // points come from QGaussLobatto. const QGaussLobatto<1> points_gl(n_points); type = true; for(unsigned int j=0;j(QGaussLobatto(" << this->degree+1 << "))"; + namebuf << "FE_Q<" << dim << ">(QGaussLobatto(" << this->degree+1 << "))"; else - namebuf << "FE_Q<" << dim << ">(QUnknownNodes(" << this->degree << "))"; + namebuf << "FE_Q<" << dim << ">(QUnknownNodes(" << this->degree << "))"; } return namebuf.str(); } @@ -693,11 +693,11 @@ template void FE_Q:: get_interpolation_matrix (const FiniteElement &x_source_fe, - FullMatrix &interpolation_matrix) const + FullMatrix &interpolation_matrix) const { - // this is only implemented, if the - // source FE is also a - // Q element + // this is only implemented, if the + // source FE is also a + // Q element typedef FE_Q FEQ; typedef FiniteElement FEL; @@ -708,27 +708,27 @@ get_interpolation_matrix (const FiniteElement &x_source_fe, ExcInterpolationNotImplemented()); Assert (interpolation_matrix.m() == this->dofs_per_cell, - ExcDimensionMismatch (interpolation_matrix.m(), - this->dofs_per_cell)); + ExcDimensionMismatch (interpolation_matrix.m(), + this->dofs_per_cell)); Assert (interpolation_matrix.n() == x_source_fe.dofs_per_cell, - ExcDimensionMismatch (interpolation_matrix.m(), - x_source_fe.dofs_per_cell)); + ExcDimensionMismatch (interpolation_matrix.m(), + x_source_fe.dofs_per_cell)); - // ok, source is a Q element, so - // we will be able to do the work + // ok, source is a Q element, so + // we will be able to do the work const FE_Q &source_fe = dynamic_cast&>(x_source_fe); - // compute the interpolation - // matrices in much the same way as - // we do for the embedding matrices - // from mother to child. + // compute the interpolation + // matrices in much the same way as + // we do for the embedding matrices + // from mother to child. FullMatrix cell_interpolation (this->dofs_per_cell, - this->dofs_per_cell); + this->dofs_per_cell); FullMatrix source_interpolation (this->dofs_per_cell, - source_fe.dofs_per_cell); + source_fe.dofs_per_cell); FullMatrix tmp (this->dofs_per_cell, - source_fe.dofs_per_cell); + source_fe.dofs_per_cell); for (unsigned int j=0; jdofs_per_cell; ++j) { // read in a point on this @@ -758,11 +758,11 @@ get_interpolation_matrix (const FiniteElement &x_source_fe, if (std::fabs(interpolation_matrix(i,j)) < eps) interpolation_matrix(i,j) = 0.; - // make sure that the row sum of - // each of the matrices is 1 at - // this point. this must be so - // since the shape functions sum up - // to 1 + // make sure that the row sum of + // each of the matrices is 1 at + // this point. this must be so + // since the shape functions sum up + // to 1 for (unsigned int i=0; idofs_per_cell; ++i) { double sum = 0.; @@ -779,7 +779,7 @@ template <> void FE_Q<1>:: get_face_interpolation_matrix (const FiniteElement<1,1> &/*x_source_fe*/, - FullMatrix &/*interpolation_matrix*/) const + FullMatrix &/*interpolation_matrix*/) const { Assert (false, ExcImpossibleInDim(1)); } @@ -790,8 +790,8 @@ template <> void FE_Q<1>:: get_subface_interpolation_matrix (const FiniteElement<1,1> &/*x_source_fe*/, - const unsigned int /*subface*/, - FullMatrix &/*interpolation_matrix*/) const + const unsigned int /*subface*/, + FullMatrix &/*interpolation_matrix*/) const { Assert (false, ExcImpossibleInDim(1)); } @@ -801,12 +801,12 @@ template <> void FE_Q<1,2>:: get_face_interpolation_matrix (const FiniteElement<1,2> &/*x_source_fe*/, - FullMatrix &/*interpolation_matrix*/) const + FullMatrix &/*interpolation_matrix*/) const { typedef FiniteElement<1,2> FEL; Assert (false, - FEL:: - ExcInterpolationNotImplemented ()); + FEL:: + ExcInterpolationNotImplemented ()); } @@ -814,13 +814,13 @@ template <> void FE_Q<1,2>:: get_subface_interpolation_matrix (const FiniteElement<1,2> &/*x_source_fe*/, - const unsigned int /*subface*/, - FullMatrix &/*interpolation_matrix*/) const + const unsigned int /*subface*/, + FullMatrix &/*interpolation_matrix*/) const { typedef FiniteElement<1,2> FEL; Assert (false, - FEL:: - ExcInterpolationNotImplemented ()); + FEL:: + ExcInterpolationNotImplemented ()); } @@ -828,12 +828,12 @@ template <> void FE_Q<1,3>:: get_face_interpolation_matrix (const FiniteElement<1,3> &/*x_source_fe*/, - FullMatrix &/*interpolation_matrix*/) const + FullMatrix &/*interpolation_matrix*/) const { typedef FiniteElement<1,3> FEL; Assert (false, - FEL:: - ExcInterpolationNotImplemented ()); + FEL:: + ExcInterpolationNotImplemented ()); } @@ -841,13 +841,13 @@ template <> void FE_Q<1,3>:: get_subface_interpolation_matrix (const FiniteElement<1,3> &/*x_source_fe*/, - const unsigned int /*subface*/, - FullMatrix &/*interpolation_matrix*/) const + const unsigned int /*subface*/, + FullMatrix &/*interpolation_matrix*/) const { typedef FiniteElement<1,3> FEL; Assert (false, - FEL:: - ExcInterpolationNotImplemented ()); + FEL:: + ExcInterpolationNotImplemented ()); } @@ -856,11 +856,11 @@ template void FE_Q:: get_face_interpolation_matrix (const FiniteElement &x_source_fe, - FullMatrix &interpolation_matrix) const + FullMatrix &interpolation_matrix) const { - // this is only implemented, if the - // source FE is also a - // Q element + // this is only implemented, if the + // source FE is also a + // Q element typedef FE_Q FEQ; typedef FiniteElement FEL; AssertThrow ((x_source_fe.get_name().find ("FE_Q<") == 0) @@ -870,18 +870,18 @@ get_face_interpolation_matrix (const FiniteElement &x_source_fe, ExcInterpolationNotImplemented()); Assert (interpolation_matrix.n() == this->dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.n(), - this->dofs_per_face)); + ExcDimensionMismatch (interpolation_matrix.n(), + this->dofs_per_face)); Assert (interpolation_matrix.m() == x_source_fe.dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.m(), - x_source_fe.dofs_per_face)); + ExcDimensionMismatch (interpolation_matrix.m(), + x_source_fe.dofs_per_face)); - // ok, source is a Q element, so - // we will be able to do the work + // ok, source is a Q element, so + // we will be able to do the work const FE_Q &source_fe = dynamic_cast&>(x_source_fe); - // Make sure, that the element, + // Make sure, that the element, // for which the DoFs should be // constrained is the one with // the higher polynomial degree. @@ -889,30 +889,30 @@ get_face_interpolation_matrix (const FiniteElement &x_source_fe, // also if this assertion is not // satisfied. But the matrices // produced in that case might - // lead to problems in the + // lead to problems in the // hp procedures, which use this - // method. + // method. Assert (this->dofs_per_face <= source_fe.dofs_per_face, - typename FEL:: - ExcInterpolationNotImplemented ()); + typename FEL:: + ExcInterpolationNotImplemented ()); // generate a quadrature // with the unit support points. // This is later based as a - // basis for the QProjector, - // which returns the support + // basis for the QProjector, + // which returns the support // points on the face. Quadrature quad_face_support (source_fe.get_unit_face_support_points ()); - // Rule of thumb for FP accuracy, - // that can be expected for a - // given polynomial degree. - // This value is used to cut - // off values close to zero. + // Rule of thumb for FP accuracy, + // that can be expected for a + // given polynomial degree. + // This value is used to cut + // off values close to zero. const double eps = 2e-13*this->degree*(dim-1); - // compute the interpolation - // matrix by simply taking the + // compute the interpolation + // matrix by simply taking the // value at the support points. //TODO: Verify that all faces are the same with respect to // these support points. Furthermore, check if something has to @@ -924,29 +924,29 @@ get_face_interpolation_matrix (const FiniteElement &x_source_fe, const Point &p = face_quadrature.point (i); for (unsigned int j=0; jdofs_per_face; ++j) - { - double matrix_entry = this->shape_value (this->face_to_cell_index(j, 0), p); - - // Correct the interpolated - // value. I.e. if it is close - // to 1 or 0, make it exactly - // 1 or 0. Unfortunately, this - // is required to avoid problems - // with higher order elements. - if (std::fabs (matrix_entry - 1.0) < eps) - matrix_entry = 1.0; - if (std::fabs (matrix_entry) < eps) - matrix_entry = 0.0; - - interpolation_matrix(i,j) = matrix_entry; - } + { + double matrix_entry = this->shape_value (this->face_to_cell_index(j, 0), p); + + // Correct the interpolated + // value. I.e. if it is close + // to 1 or 0, make it exactly + // 1 or 0. Unfortunately, this + // is required to avoid problems + // with higher order elements. + if (std::fabs (matrix_entry - 1.0) < eps) + matrix_entry = 1.0; + if (std::fabs (matrix_entry) < eps) + matrix_entry = 0.0; + + interpolation_matrix(i,j) = matrix_entry; + } } - // make sure that the row sum of - // each of the matrices is 1 at - // this point. this must be so - // since the shape functions sum up - // to 1 + // make sure that the row sum of + // each of the matrices is 1 at + // this point. this must be so + // since the shape functions sum up + // to 1 for (unsigned int j=0; j void FE_Q:: get_subface_interpolation_matrix (const FiniteElement &x_source_fe, - const unsigned int subface, - FullMatrix &interpolation_matrix) const + const unsigned int subface, + FullMatrix &interpolation_matrix) const { Assert (interpolation_matrix.m() == x_source_fe.dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.m(), - x_source_fe.dofs_per_face)); + ExcDimensionMismatch (interpolation_matrix.m(), + x_source_fe.dofs_per_face)); - // see if source is a Q element + // see if source is a Q element if (const FE_Q *source_fe = dynamic_cast *>(&x_source_fe)) { - // have this test in here since - // a table of size 2x0 reports - // its size as 0x0 + // have this test in here since + // a table of size 2x0 reports + // its size as 0x0 Assert (interpolation_matrix.n() == this->dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.n(), - this->dofs_per_face)); - - // Make sure, that the element, - // for which the DoFs should be - // constrained is the one with - // the higher polynomial degree. - // Actually the procedure will work - // also if this assertion is not - // satisfied. But the matrices - // produced in that case might - // lead to problems in the - // hp procedures, which use this - // method. + ExcDimensionMismatch (interpolation_matrix.n(), + this->dofs_per_face)); + + // Make sure, that the element, + // for which the DoFs should be + // constrained is the one with + // the higher polynomial degree. + // Actually the procedure will work + // also if this assertion is not + // satisfied. But the matrices + // produced in that case might + // lead to problems in the + // hp procedures, which use this + // method. Assert (this->dofs_per_face <= source_fe->dofs_per_face, - (typename FiniteElement:: - ExcInterpolationNotImplemented ())); + (typename FiniteElement:: + ExcInterpolationNotImplemented ())); - // generate a point on this - // cell and evaluate the - // shape functions there + // generate a point on this + // cell and evaluate the + // shape functions there const Quadrature - quad_face_support (source_fe->get_unit_face_support_points ()); + quad_face_support (source_fe->get_unit_face_support_points ()); - // Rule of thumb for FP accuracy, - // that can be expected for a - // given polynomial degree. - // This value is used to cut - // off values close to zero. + // Rule of thumb for FP accuracy, + // that can be expected for a + // given polynomial degree. + // This value is used to cut + // off values close to zero. double eps = 2e-13*this->degree*(dim-1); - // compute the interpolation - // matrix by simply taking the - // value at the support points. + // compute the interpolation + // matrix by simply taking the + // value at the support points. //TODO: Verify that all faces are the same with respect to // these support points. Furthermore, check if something has to // be done for the face orientation flag in 3D. const Quadrature subface_quadrature - = QProjector::project_to_subface (quad_face_support, 0, subface); + = QProjector::project_to_subface (quad_face_support, 0, subface); for (unsigned int i=0; idofs_per_face; ++i) - { - const Point &p = subface_quadrature.point (i); - - for (unsigned int j=0; jdofs_per_face; ++j) - { - double matrix_entry = this->shape_value (this->face_to_cell_index(j, 0), p); - - // Correct the interpolated - // value. I.e. if it is close - // to 1 or 0, make it exactly - // 1 or 0. Unfortunately, this - // is required to avoid problems - // with higher order elements. - if (std::fabs (matrix_entry - 1.0) < eps) - matrix_entry = 1.0; - if (std::fabs (matrix_entry) < eps) - matrix_entry = 0.0; - - interpolation_matrix(i,j) = matrix_entry; - } - } - - // make sure that the row sum of - // each of the matrices is 1 at - // this point. this must be so - // since the shape functions sum up - // to 1 + { + const Point &p = subface_quadrature.point (i); + + for (unsigned int j=0; jdofs_per_face; ++j) + { + double matrix_entry = this->shape_value (this->face_to_cell_index(j, 0), p); + + // Correct the interpolated + // value. I.e. if it is close + // to 1 or 0, make it exactly + // 1 or 0. Unfortunately, this + // is required to avoid problems + // with higher order elements. + if (std::fabs (matrix_entry - 1.0) < eps) + matrix_entry = 1.0; + if (std::fabs (matrix_entry) < eps) + matrix_entry = 0.0; + + interpolation_matrix(i,j) = matrix_entry; + } + } + + // make sure that the row sum of + // each of the matrices is 1 at + // this point. this must be so + // since the shape functions sum up + // to 1 for (unsigned int j=0; jdofs_per_face; ++j) - { - double sum = 0.; + { + double sum = 0.; - for (unsigned int i=0; idofs_per_face; ++i) - sum += interpolation_matrix(j,i); + for (unsigned int i=0; idofs_per_face; ++i) + sum += interpolation_matrix(j,i); - Assert (std::fabs(sum-1) < 2e-13*this->degree*dim, - ExcInternalError()); - } + Assert (std::fabs(sum-1) < 2e-13*this->degree*dim, + ExcInternalError()); + } } else if (dynamic_cast *>(&x_source_fe) != 0) { - // nothing to do here, the - // FE_Nothing has no degrees of - // freedom anyway + // nothing to do here, the + // FE_Nothing has no degrees of + // freedom anyway } else AssertThrow (false, - (typename FiniteElement:: - ExcInterpolationNotImplemented())); + (typename FiniteElement:: + ExcInterpolationNotImplemented())); } @@ -1087,26 +1087,26 @@ std::vector > FE_Q:: hp_vertex_dof_identities (const FiniteElement &fe_other) const { - // we can presently only compute - // these identities if both FEs are - // FE_Qs or if the other one is an - // FE_Nothing. in the first case, - // there should be exactly one - // single DoF of each FE at a - // vertex, and they should have - // identical value + // we can presently only compute + // these identities if both FEs are + // FE_Qs or if the other one is an + // FE_Nothing. in the first case, + // there should be exactly one + // single DoF of each FE at a + // vertex, and they should have + // identical value if (dynamic_cast*>(&fe_other) != 0) { return - std::vector > - (1, std::make_pair (0U, 0U)); + std::vector > + (1, std::make_pair (0U, 0U)); } else if (dynamic_cast*>(&fe_other) != 0) { - // the FE_Nothing has no - // degrees of freedom, so there - // are no equivalencies to be - // recorded + // the FE_Nothing has no + // degrees of freedom, so there + // are no equivalencies to be + // recorded return std::vector > (); } else @@ -1123,53 +1123,53 @@ std::vector > FE_Q:: hp_line_dof_identities (const FiniteElement &fe_other) const { - // we can presently only compute - // these identities if both FEs are - // FE_Qs or if the other one is an - // FE_Nothing + // we can presently only compute + // these identities if both FEs are + // FE_Qs or if the other one is an + // FE_Nothing if (const FE_Q *fe_q_other = dynamic_cast*>(&fe_other)) { - // dofs are located along lines, so two - // dofs are identical if they are - // located at identical positions. if - // we had only equidistant points, we - // could simple check for similarity - // like (i+1)*q == (j+1)*p, but we - // might have other support points - // (e.g. Gauss-Lobatto - // points). Therefore, read the points - // in unit_support_points for the first - // coordinate direction. We take the - // lexicographic ordering of the points - // in the first direction (i.e., - // x-direction), which we access - // between index 1 and p-1 (index 0 and - // p are vertex dofs). + // dofs are located along lines, so two + // dofs are identical if they are + // located at identical positions. if + // we had only equidistant points, we + // could simple check for similarity + // like (i+1)*q == (j+1)*p, but we + // might have other support points + // (e.g. Gauss-Lobatto + // points). Therefore, read the points + // in unit_support_points for the first + // coordinate direction. We take the + // lexicographic ordering of the points + // in the first direction (i.e., + // x-direction), which we access + // between index 1 and p-1 (index 0 and + // p are vertex dofs). const unsigned int p = this->degree; const unsigned int q = fe_q_other->degree; std::vector > identities; const std::vector &index_map_inverse= - this->poly_space.get_numbering_inverse(); + this->poly_space.get_numbering_inverse(); const std::vector &index_map_inverse_other= - fe_q_other->poly_space.get_numbering_inverse(); + fe_q_other->poly_space.get_numbering_inverse(); for (unsigned int i=0; iunit_support_points[index_map_inverse[i+1]][0]- - fe_q_other->unit_support_points[index_map_inverse_other[j+1]][0]) - < 1e-14) - identities.push_back (std::make_pair(i,j)); + for (unsigned int j=0; junit_support_points[index_map_inverse[i+1]][0]- + fe_q_other->unit_support_points[index_map_inverse_other[j+1]][0]) + < 1e-14) + identities.push_back (std::make_pair(i,j)); return identities; } else if (dynamic_cast*>(&fe_other) != 0) { - // the FE_Nothing has no - // degrees of freedom, so there - // are no equivalencies to be - // recorded + // the FE_Nothing has no + // degrees of freedom, so there + // are no equivalencies to be + // recorded return std::vector > (); } else @@ -1186,53 +1186,53 @@ std::vector > FE_Q:: hp_quad_dof_identities (const FiniteElement &fe_other) const { - // we can presently only compute - // these identities if both FEs are - // FE_Qs or if the other one is an - // FE_Nothing + // we can presently only compute + // these identities if both FEs are + // FE_Qs or if the other one is an + // FE_Nothing if (const FE_Q *fe_q_other = dynamic_cast*>(&fe_other)) { - // this works exactly like the line - // case above, except that now we have - // to have two indices i1, i2 and j1, - // j2 to characterize the dofs on the - // face of each of the finite - // elements. since they are ordered - // lexicographically along the first - // line and we have a tensor product, - // the rest is rather straightforward + // this works exactly like the line + // case above, except that now we have + // to have two indices i1, i2 and j1, + // j2 to characterize the dofs on the + // face of each of the finite + // elements. since they are ordered + // lexicographically along the first + // line and we have a tensor product, + // the rest is rather straightforward const unsigned int p = this->degree; const unsigned int q = fe_q_other->degree; std::vector > identities; const std::vector &index_map_inverse= - this->poly_space.get_numbering_inverse(); + this->poly_space.get_numbering_inverse(); const std::vector &index_map_inverse_other= - fe_q_other->poly_space.get_numbering_inverse(); + fe_q_other->poly_space.get_numbering_inverse(); for (unsigned int i1=0; i1unit_support_points[index_map_inverse[i1+1]][0]- - fe_q_other->unit_support_points[index_map_inverse_other[j1+1]][0]) - < 1e-14) - && - (std::fabs(this->unit_support_points[index_map_inverse[i2+1]][0]- - fe_q_other->unit_support_points[index_map_inverse_other[j2+1]][0]) - < 1e-14)) - identities.push_back (std::make_pair(i1*(p-1)+i2, - j1*(q-1)+j2)); + for (unsigned int i2=0; i2unit_support_points[index_map_inverse[i1+1]][0]- + fe_q_other->unit_support_points[index_map_inverse_other[j1+1]][0]) + < 1e-14) + && + (std::fabs(this->unit_support_points[index_map_inverse[i2+1]][0]- + fe_q_other->unit_support_points[index_map_inverse_other[j2+1]][0]) + < 1e-14)) + identities.push_back (std::make_pair(i1*(p-1)+i2, + j1*(q-1)+j2)); return identities; } else if (dynamic_cast*>(&fe_other) != 0) { - // the FE_Nothing has no - // degrees of freedom, so there - // are no equivalencies to be - // recorded + // the FE_Nothing has no + // degrees of freedom, so there + // are no equivalencies to be + // recorded return std::vector > (); } else @@ -1253,20 +1253,20 @@ compare_for_face_domination (const FiniteElement &fe_other) const = dynamic_cast*>(&fe_other)) { if (this->degree < fe_q_other->degree) - return FiniteElementDomination::this_element_dominates; + return FiniteElementDomination::this_element_dominates; else if (this->degree == fe_q_other->degree) - return FiniteElementDomination::either_element_can_dominate; + return FiniteElementDomination::either_element_can_dominate; else - return FiniteElementDomination::other_element_dominates; + return FiniteElementDomination::other_element_dominates; } else if (dynamic_cast*>(&fe_other) != 0) { - // the FE_Nothing has no - // degrees of freedom and it is - // typically used in a context - // where we don't require any - // continuity along the - // interface + // the FE_Nothing has no + // degrees of freedom and it is + // typically used in a context + // where we don't require any + // continuity along the + // interface return FiniteElementDomination::no_requirements; } @@ -1284,7 +1284,7 @@ compare_for_face_domination (const FiniteElement &fe_other) const template void FE_Q::initialize_unit_support_points () { - // number of points: (degree+1)^dim + // number of points: (degree+1)^dim unsigned int n = this->degree+1; for (unsigned int i=1; idegree+1; @@ -1301,15 +1301,15 @@ void FE_Q::initialize_unit_support_points () for (unsigned int iz=0; iz <= ((dim>2) ? this->degree : 0) ; ++iz) for (unsigned int iy=0; iy <= ((dim>1) ? this->degree : 0) ; ++iy) for (unsigned int ix=0; ix<=this->degree; ++ix) - { - p(0) = ix * step; - if (dim>1) - p(1) = iy * step; - if (dim>2) - p(2) = iz * step; - - this->unit_support_points[index_map_inverse[k++]] = p; - } + { + p(0) = ix * step; + if (dim>1) + p(1) = iy * step; + if (dim>2) + p(2) = iz * step; + + this->unit_support_points[index_map_inverse[k++]] = p; + } } @@ -1317,7 +1317,7 @@ void FE_Q::initialize_unit_support_points () template void FE_Q::initialize_unit_support_points (const Quadrature<1> &points) { - // number of points: (degree+1)^dim + // number of points: (degree+1)^dim unsigned int n = this->degree+1; for (unsigned int i=1; idegree+1; @@ -1342,37 +1342,37 @@ void FE_Q::initialize_unit_support_points (const Quadrature<1> &po template <> void FE_Q<1>::initialize_unit_face_support_points () { - // no faces in 1d, so nothing to do + // no faces in 1d, so nothing to do } template <> void FE_Q<1>::initialize_unit_face_support_points (const Quadrature<1> &/*points*/) { - // no faces in 1d, so nothing to do + // no faces in 1d, so nothing to do } template <> void FE_Q<1,2>::initialize_unit_face_support_points () { - // no faces in 1d, so nothing to do + // no faces in 1d, so nothing to do } template <> void FE_Q<1,2>::initialize_unit_face_support_points (const Quadrature<1> &/*points*/) { - // no faces in 1d, so nothing to do + // no faces in 1d, so nothing to do } template <> void FE_Q<1,3>::initialize_unit_face_support_points () { - // no faces in 1d, so nothing to do + // no faces in 1d, so nothing to do } template <> void FE_Q<1,3>::initialize_unit_face_support_points (const Quadrature<1> &/*points*/) { - // no faces in 1d, so nothing to do + // no faces in 1d, so nothing to do } template @@ -1380,7 +1380,7 @@ void FE_Q::initialize_unit_face_support_points () { const unsigned int codim = dim-1; - // number of points: (degree+1)^codim + // number of points: (degree+1)^codim unsigned int n = this->degree+1; for (unsigned int i=1; idegree+1; @@ -1397,15 +1397,15 @@ void FE_Q::initialize_unit_face_support_points () for (unsigned int iz=0; iz <= ((codim>2) ? this->degree : 0) ; ++iz) for (unsigned int iy=0; iy <= ((codim>1) ? this->degree : 0) ; ++iy) for (unsigned int ix=0; ix<=this->degree; ++ix) - { - p(0) = ix * step; - if (codim>1) - p(1) = iy * step; - if (codim>2) - p(2) = iz * step; - - this->unit_face_support_points[face_index_map_inverse[k++]] = p; - } + { + p(0) = ix * step; + if (codim>1) + p(1) = iy * step; + if (codim>2) + p(2) = iz * step; + + this->unit_face_support_points[face_index_map_inverse[k++]] = p; + } } @@ -1415,7 +1415,7 @@ void FE_Q::initialize_unit_face_support_points (const Quadrature<1 { const unsigned int codim = dim-1; - // number of points: (degree+1)^codim + // number of points: (degree+1)^codim unsigned int n = this->degree+1; for (unsigned int i=1; idegree+1; @@ -1433,15 +1433,15 @@ void FE_Q::initialize_unit_face_support_points (const Quadrature<1 for (unsigned int iz=0; iz <= ((codim>2) ? this->degree : 0) ; ++iz) for (unsigned int iy=0; iy <= ((codim>1) ? this->degree : 0) ; ++iy) for (unsigned int ix=0; ix<=this->degree; ++ix) - { - p(0) = edge[ix](0); - if (codim>1) - p(1) = edge[iy](0); - if (codim>2) - p(2) = edge[iz](0); - - this->unit_face_support_points[face_index_map_inverse[k++]] = p; - } + { + p(0) = edge[ix](0); + if (codim>1) + p(1) = edge[iy](0); + if (codim>2) + p(2) = edge[iz](0); + + this->unit_face_support_points[face_index_map_inverse[k++]] = p; + } } @@ -1450,7 +1450,7 @@ template void FE_Q::initialize_quad_dof_index_permutation () { - // general template for 1D and 2D, do nothing + // general template for 1D and 2D, do nothing } @@ -1460,63 +1460,63 @@ void FE_Q<3>::initialize_quad_dof_index_permutation () { Assert (adjust_quad_dof_index_for_face_orientation_table.n_elements()==8*this->dofs_per_quad, - ExcInternalError()); + ExcInternalError()); const unsigned int n=this->degree-1; Assert(n*n==this->dofs_per_quad, ExcInternalError()); - // alias for the table to fill + // alias for the table to fill Table<2,int> &data=this->adjust_quad_dof_index_for_face_orientation_table; - // the dofs on a face are connected to a n x - // n matrix. for example, for degree==4 we - // have the following dofs on a quad - - // ___________ - // | | - // | 6 7 8 | - // | | - // | 3 4 5 | - // | | - // | 0 1 2 | - // |___________| - // - // we have dof_no=i+n*j with index i in - // x-direction and index j in y-direction - // running from 0 to n-1. to extract i and j - // we can use i=dof_no%n and j=dof_no/n. i - // and j can then be used to construct the - // rotated and mirrored numbers. + // the dofs on a face are connected to a n x + // n matrix. for example, for degree==4 we + // have the following dofs on a quad + + // ___________ + // | | + // | 6 7 8 | + // | | + // | 3 4 5 | + // | | + // | 0 1 2 | + // |___________| + // + // we have dof_no=i+n*j with index i in + // x-direction and index j in y-direction + // running from 0 to n-1. to extract i and j + // we can use i=dof_no%n and j=dof_no/n. i + // and j can then be used to construct the + // rotated and mirrored numbers. for (unsigned int local=0; localdofs_per_quad; ++local) - // face support points are in lexicographic - // ordering with x running fastest. invert - // that (y running fastest) + // face support points are in lexicographic + // ordering with x running fastest. invert + // that (y running fastest) { unsigned int i=local%n, - j=local/n; + j=local/n; - // face_orientation=false, face_flip=false, face_rotation=false + // face_orientation=false, face_flip=false, face_rotation=false data(local,0)=j + i *n - local; - // face_orientation=false, face_flip=false, face_rotation=true + // face_orientation=false, face_flip=false, face_rotation=true data(local,1)=i + (n-1-j)*n - local; - // face_orientation=false, face_flip=true, face_rotation=false + // face_orientation=false, face_flip=true, face_rotation=false data(local,2)=(n-1-j) + (n-1-i)*n - local; - // face_orientation=false, face_flip=true, face_rotation=true + // face_orientation=false, face_flip=true, face_rotation=true data(local,3)=(n-1-i) + j *n - local; - // face_orientation=true, face_flip=false, face_rotation=false + // face_orientation=true, face_flip=false, face_rotation=false data(local,4)=0; - // face_orientation=true, face_flip=false, face_rotation=true + // face_orientation=true, face_flip=false, face_rotation=true data(local,5)=j + (n-1-i)*n - local; - // face_orientation=true, face_flip=true, face_rotation=false + // face_orientation=true, face_flip=true, face_rotation=false data(local,6)=(n-1-i) + (n-1-j)*n - local; - // face_orientation=true, face_flip=true, face_rotation=true + // face_orientation=true, face_flip=true, face_rotation=true data(local,7)=(n-1-j) + i *n - local; } - // aditionally initialize reordering of line - // dofs + // aditionally initialize reordering of line + // dofs for (unsigned int i=0; idofs_per_line; ++i) this->adjust_line_dof_index_for_line_orientation_table[i]=this->dofs_per_line-1-i - i; } @@ -1585,169 +1585,169 @@ template void FE_Q::initialize_embedding () { - // compute the interpolation matrices in - // much the same way as we do for the - // constraints. it's actually simpler - // here, since we don't have this weird - // renumbering stuff going on. The trick - // is again that we the interpolation - // matrix is formed by a permutation of - // the indices of the cell matrix. The - // value eps is used a threshold to - // decide when certain evaluations of the - // Lagrange polynomials are zero or one. + // compute the interpolation matrices in + // much the same way as we do for the + // constraints. it's actually simpler + // here, since we don't have this weird + // renumbering stuff going on. The trick + // is again that we the interpolation + // matrix is formed by a permutation of + // the indices of the cell matrix. The + // value eps is used a threshold to + // decide when certain evaluations of the + // Lagrange polynomials are zero or one. const double eps = 1e-15*this->degree*dim; #ifdef DEBUG - // in DEBUG mode, check that the evaluation of - // support points in the current numbering - // gives the identity operation + // in DEBUG mode, check that the evaluation of + // support points in the current numbering + // gives the identity operation for (unsigned int i=0; idofs_per_cell; ++i) { Assert (std::fabs (1.-this->poly_space.compute_value - (i, this->unit_support_points[i])) < eps, - ExcInternalError()); + (i, this->unit_support_points[i])) < eps, + ExcInternalError()); for (unsigned int j=0; jdofs_per_cell; ++j) - if (j!=i) - Assert (std::fabs (this->poly_space.compute_value - (i, this->unit_support_points[j])) < eps, - ExcInternalError()); + if (j!=i) + Assert (std::fabs (this->poly_space.compute_value + (i, this->unit_support_points[j])) < eps, + ExcInternalError()); } #endif - // to efficiently evaluate the polynomial at - // the subcell, make use of the tensor product - // structure of this element and only evaluate - // 1D information from the polynomial. This - // makes the cost of this function almost - // negligible also for high order elements + // to efficiently evaluate the polynomial at + // the subcell, make use of the tensor product + // structure of this element and only evaluate + // 1D information from the polynomial. This + // makes the cost of this function almost + // negligible also for high order elements const unsigned int dofs1d = this->degree+1; std::vector > subcell_evaluations (dim, Table<2,double>(dofs1d, dofs1d)); const std::vector &index_map_inverse = this->poly_space.get_numbering_inverse(); - // recreate 1D polynomials + // recreate 1D polynomials std::vector > poly_space1d = FE_Q_Helper::generate_poly_space1d (this->unit_support_points, index_map_inverse, dofs1d); - // helper value: step size how to walk through - // diagonal and how many points we have left - // apart from the first dimension + // helper value: step size how to walk through + // diagonal and how many points we have left + // apart from the first dimension unsigned int step_size_diag = 0; { unsigned int factor = 1; for (unsigned int d=0; d::isotropic_refinement; ++ref) for (unsigned int child=0; child::n_children(RefinementCase(ref+1)); ++child) { - // go through the points in diagonal to - // capture variation in all directions - // simultaneously - for (unsigned int j=0; j p_subcell = this->unit_support_points[diag_comp]; - const Point p_cell = - GeometryInfo::child_to_cell_coordinates (p_subcell, child, - RefinementCase(ref+1)); - for (unsigned int i=0; i (j_indices); - for (unsigned int j=0; jdofs_per_cell; j+=dofs1d) - { - unsigned int i_indices[dim]; - FE_Q_Helper::zero_indices (i_indices); - for (unsigned int i=0; idofs_per_cell; i+=dofs1d) - { - double val_extra_dim = 1.; - for (unsigned int d=1; dprolongation[ref][child](j,i) = - // this->poly_space.compute_value (i, p_cell); - for (unsigned int jj=0; jjprolongation[ref][child](j_ind,index_map_inverse[i+ii]) - = val_extra_dim * subcell_evaluations[0](jj,ii); - } - - // update indices that denote the tensor - // product position. a bit fuzzy and therefore - // not done for innermost x_0 direction - FE_Q_Helper::increment_indices (i_indices, dofs1d); - } - Assert (i_indices[dim-1] == 1, ExcInternalError()); - FE_Q_Helper::increment_indices (j_indices, dofs1d); - } - - // and make sure that the row sum is - // 1. this must be so since for this - // element, the shape functions add up to - // one + // go through the points in diagonal to + // capture variation in all directions + // simultaneously + for (unsigned int j=0; j p_subcell = this->unit_support_points[diag_comp]; + const Point p_cell = + GeometryInfo::child_to_cell_coordinates (p_subcell, child, + RefinementCase(ref+1)); + for (unsigned int i=0; i (j_indices); + for (unsigned int j=0; jdofs_per_cell; j+=dofs1d) + { + unsigned int i_indices[dim]; + FE_Q_Helper::zero_indices (i_indices); + for (unsigned int i=0; idofs_per_cell; i+=dofs1d) + { + double val_extra_dim = 1.; + for (unsigned int d=1; dprolongation[ref][child](j,i) = + // this->poly_space.compute_value (i, p_cell); + for (unsigned int jj=0; jjprolongation[ref][child](j_ind,index_map_inverse[i+ii]) + = val_extra_dim * subcell_evaluations[0](jj,ii); + } + + // update indices that denote the tensor + // product position. a bit fuzzy and therefore + // not done for innermost x_0 direction + FE_Q_Helper::increment_indices (i_indices, dofs1d); + } + Assert (i_indices[dim-1] == 1, ExcInternalError()); + FE_Q_Helper::increment_indices (j_indices, dofs1d); + } + + // and make sure that the row sum is + // 1. this must be so since for this + // element, the shape functions add up to + // one #ifdef DEBUG - for (unsigned int row=0; rowdofs_per_cell; ++row) - { - double sum = 0; - for (unsigned int col=0; coldofs_per_cell; ++col) - sum += this->prolongation[ref][child](row,col); - Assert (std::fabs(sum-1.) < eps, ExcInternalError()); - } + for (unsigned int row=0; rowdofs_per_cell; ++row) + { + double sum = 0; + for (unsigned int col=0; coldofs_per_cell; ++col) + sum += this->prolongation[ref][child](row,col); + Assert (std::fabs(sum-1.) < eps, ExcInternalError()); + } #endif } } @@ -1805,8 +1805,8 @@ FE_Q::initialize_restriction () const std::vector &index_map_inverse = this->poly_space.get_numbering_inverse(); - // recreate 1D polynomials for faster - // evaluation of polynomial + // recreate 1D polynomials for faster + // evaluation of polynomial const unsigned int dofs1d = this->degree+1; std::vector > poly_space1d = FE_Q_Helper::generate_poly_space1d (this->unit_support_points, @@ -1822,63 +1822,63 @@ FE_Q::initialize_restriction () // which the interpolation // point is located for (unsigned int ref=RefinementCase::cut_x; ref<=RefinementCase::isotropic_refinement; ++ref) - for (unsigned int child=0; child::n_children(RefinementCase(ref)); ++child) - { - // check whether this - // interpolation point is - // inside this child cell - const Point p_subcell - = GeometryInfo::cell_to_child_coordinates (p_cell, child, RefinementCase(ref)); - if (GeometryInfo::is_inside_unit_cell (p_subcell)) - { - // same logic as in initialize_embedding to - // evaluate the polynomial faster than from - // the tensor product: since we evaluate all - // polynomials, it is much faster to just - // compute the 1D values for all polynomials - // before and then get the dim-data. - for (unsigned int j=0; j (j_indices); - double sum_check = 0; - for (unsigned int j = 0; jdofs_per_cell; j += dofs1d) - { - double val_extra_dim = 1.; - for (unsigned int d=1; drestriction[ref-1][child](mother_dof,child_dof)=1.; - else if(std::fabs(val) > eps) - this->restriction[ref-1][child](mother_dof,child_dof)=val; - sum_check += val; - } - FE_Q_Helper::increment_indices (j_indices, dofs1d); - } - Assert (std::fabs(sum_check-1) < eps, - ExcInternalError()); - } - } + for (unsigned int child=0; child::n_children(RefinementCase(ref)); ++child) + { + // check whether this + // interpolation point is + // inside this child cell + const Point p_subcell + = GeometryInfo::cell_to_child_coordinates (p_cell, child, RefinementCase(ref)); + if (GeometryInfo::is_inside_unit_cell (p_subcell)) + { + // same logic as in initialize_embedding to + // evaluate the polynomial faster than from + // the tensor product: since we evaluate all + // polynomials, it is much faster to just + // compute the 1D values for all polynomials + // before and then get the dim-data. + for (unsigned int j=0; j (j_indices); + double sum_check = 0; + for (unsigned int j = 0; jdofs_per_cell; j += dofs1d) + { + double val_extra_dim = 1.; + for (unsigned int d=1; drestriction[ref-1][child](mother_dof,child_dof)=1.; + else if(std::fabs(val) > eps) + this->restriction[ref-1][child](mother_dof,child_dof)=val; + sum_check += val; + } + FE_Q_Helper::increment_indices (j_indices, dofs1d); + } + Assert (std::fabs(sum_check-1) < eps, + ExcInternalError()); + } + } } } @@ -1895,17 +1895,17 @@ FE_Q<1>::has_support_on_face (const unsigned int shape_index, const unsigned int face_index) const { Assert (shape_index < this->dofs_per_cell, - ExcIndexRange (shape_index, 0, this->dofs_per_cell)); + ExcIndexRange (shape_index, 0, this->dofs_per_cell)); Assert (face_index < GeometryInfo<1>::faces_per_cell, - ExcIndexRange (face_index, 0, GeometryInfo<1>::faces_per_cell)); + ExcIndexRange (face_index, 0, GeometryInfo<1>::faces_per_cell)); - // in 1d, things are simple. since - // there is only one degree of - // freedom per vertex in this - // class, the first is on vertex 0 - // (==face 0 in some sense), the - // second on face 1: + // in 1d, things are simple. since + // there is only one degree of + // freedom per vertex in this + // class, the first is on vertex 0 + // (==face 0 in some sense), the + // second on face 1: return (((shape_index == 0) && (face_index == 0)) || ((shape_index == 1) && (face_index == 1))); } @@ -1917,17 +1917,17 @@ FE_Q<1,2>::has_support_on_face (const unsigned int shape_index, const unsigned int face_index) const { Assert (shape_index < this->dofs_per_cell, - ExcIndexRange (shape_index, 0, this->dofs_per_cell)); + ExcIndexRange (shape_index, 0, this->dofs_per_cell)); Assert (face_index < GeometryInfo<1>::faces_per_cell, - ExcIndexRange (face_index, 0, GeometryInfo<1>::faces_per_cell)); + ExcIndexRange (face_index, 0, GeometryInfo<1>::faces_per_cell)); - // in 1d, things are simple. since - // there is only one degree of - // freedom per vertex in this - // class, the first is on vertex 0 - // (==face 0 in some sense), the - // second on face 1: + // in 1d, things are simple. since + // there is only one degree of + // freedom per vertex in this + // class, the first is on vertex 0 + // (==face 0 in some sense), the + // second on face 1: return (((shape_index == 0) && (face_index == 0)) || ((shape_index == 1) && (face_index == 1))); } @@ -1938,17 +1938,17 @@ FE_Q<1,3>::has_support_on_face (const unsigned int shape_index, const unsigned int face_index) const { Assert (shape_index < this->dofs_per_cell, - ExcIndexRange (shape_index, 0, this->dofs_per_cell)); + ExcIndexRange (shape_index, 0, this->dofs_per_cell)); Assert (face_index < GeometryInfo<1>::faces_per_cell, - ExcIndexRange (face_index, 0, GeometryInfo<1>::faces_per_cell)); + ExcIndexRange (face_index, 0, GeometryInfo<1>::faces_per_cell)); - // in 1d, things are simple. since - // there is only one degree of - // freedom per vertex in this - // class, the first is on vertex 0 - // (==face 0 in some sense), the - // second on face 1: + // in 1d, things are simple. since + // there is only one degree of + // freedom per vertex in this + // class, the first is on vertex 0 + // (==face 0 in some sense), the + // second on face 1: return (((shape_index == 0) && (face_index == 0)) || ((shape_index == 1) && (face_index == 1))); } @@ -1957,12 +1957,12 @@ FE_Q<1,3>::has_support_on_face (const unsigned int shape_index, template bool FE_Q::has_support_on_face (const unsigned int shape_index, - const unsigned int face_index) const + const unsigned int face_index) const { Assert (shape_index < this->dofs_per_cell, - ExcIndexRange (shape_index, 0, this->dofs_per_cell)); + ExcIndexRange (shape_index, 0, this->dofs_per_cell)); Assert (face_index < GeometryInfo::faces_per_cell, - ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); // first, special-case interior diff --git a/deal.II/source/fe/fe_q_hierarchical.cc b/deal.II/source/fe/fe_q_hierarchical.cc index 71b999d681..9aea5fc9b2 100644 --- a/deal.II/source/fe/fe_q_hierarchical.cc +++ b/deal.II/source/fe/fe_q_hierarchical.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2011 by the deal.II authors +// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -41,54 +41,54 @@ namespace template FE_Q_Hierarchical::FE_Q_Hierarchical (const unsigned int degree) - : - FE_Poly, dim> ( - Polynomials::Hierarchical::generate_complete_basis(degree), - FiniteElementData(get_dpo_vector(degree),1, degree, - FiniteElementData::H1), - std::vector (FiniteElementData( - get_dpo_vector(degree),1, degree).dofs_per_cell, false), - std::vector >(FiniteElementData( - get_dpo_vector(degree),1, degree).dofs_per_cell, std::vector(1,true))), - face_renumber(face_fe_q_hierarchical_to_hierarchic_numbering (degree)) + : + FE_Poly, dim> ( + Polynomials::Hierarchical::generate_complete_basis(degree), + FiniteElementData(get_dpo_vector(degree),1, degree, + FiniteElementData::H1), + std::vector (FiniteElementData( + get_dpo_vector(degree),1, degree).dofs_per_cell, false), + std::vector >(FiniteElementData( + get_dpo_vector(degree),1, degree).dofs_per_cell, std::vector(1,true))), + face_renumber(face_fe_q_hierarchical_to_hierarchic_numbering (degree)) { this->poly_space.set_numbering( hierarchic_to_fe_q_hierarchical_numbering(*this)); - // The matrix @p{dofs_cell} contains the - // values of the linear functionals of - // the master 1d cell applied to the - // shape functions of the two 1d subcells. - // The matrix @p{dofs_subcell} constains - // the values of the linear functionals - // on each 1d subcell applied to the - // shape functions on the master 1d - // subcell. - // We use @p{dofs_cell} and - // @p{dofs_subcell} to compute the - // @p{prolongation}, @p{restriction} and - // @p{interface_constraints} matrices - // for all dimensions. + // The matrix @p{dofs_cell} contains the + // values of the linear functionals of + // the master 1d cell applied to the + // shape functions of the two 1d subcells. + // The matrix @p{dofs_subcell} constains + // the values of the linear functionals + // on each 1d subcell applied to the + // shape functions on the master 1d + // subcell. + // We use @p{dofs_cell} and + // @p{dofs_subcell} to compute the + // @p{prolongation}, @p{restriction} and + // @p{interface_constraints} matrices + // for all dimensions. std::vector > dofs_cell (GeometryInfo<1>::max_children_per_cell, - FullMatrix (2*this->dofs_per_vertex + this->dofs_per_line, - 2*this->dofs_per_vertex + this->dofs_per_line)); + FullMatrix (2*this->dofs_per_vertex + this->dofs_per_line, + 2*this->dofs_per_vertex + this->dofs_per_line)); std::vector > dofs_subcell (GeometryInfo<1>::max_children_per_cell, - FullMatrix (2*this->dofs_per_vertex + this->dofs_per_line, - 2*this->dofs_per_vertex + this->dofs_per_line)); - // build these fields, as they are - // needed as auxiliary fields later - // on + FullMatrix (2*this->dofs_per_vertex + this->dofs_per_line, + 2*this->dofs_per_vertex + this->dofs_per_line)); + // build these fields, as they are + // needed as auxiliary fields later + // on build_dofs_cell (dofs_cell, dofs_subcell); - // then use them to initialize - // other fields + // then use them to initialize + // other fields initialize_constraints (dofs_subcell); initialize_embedding_and_restriction (dofs_cell, dofs_subcell); - // finally fill in support points - // on cell and face + // finally fill in support points + // on cell and face initialize_unit_support_points (); initialize_unit_face_support_points (); } @@ -99,12 +99,12 @@ template std::string FE_Q_Hierarchical::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch std::ostringstream namebuf; namebuf << "FE_Q_Hierarchical<" << dim << ">(" << this->degree << ")"; @@ -136,26 +136,26 @@ std::vector > FE_Q_Hierarchical:: hp_vertex_dof_identities (const FiniteElement &fe_other) const { - // we can presently only compute - // these identities if both FEs are - // FE_Q_Hierarchicals or if the other - // one is an FE_Nothing. in the first - // case, there should be exactly one - // single DoF of each FE at a - // vertex, and they should have - // identical value + // we can presently only compute + // these identities if both FEs are + // FE_Q_Hierarchicals or if the other + // one is an FE_Nothing. in the first + // case, there should be exactly one + // single DoF of each FE at a + // vertex, and they should have + // identical value if (dynamic_cast*>(&fe_other) != 0) { return - std::vector > - (1, std::make_pair (0U, 0U)); + std::vector > + (1, std::make_pair (0U, 0U)); } else if (dynamic_cast*>(&fe_other) != 0) { - // the FE_Nothing has no - // degrees of freedom, so there - // are no equivalencies to be - // recorded + // the FE_Nothing has no + // degrees of freedom, so there + // are no equivalencies to be + // recorded return std::vector > (); } else @@ -175,20 +175,20 @@ compare_for_face_domination (const FiniteElement &fe_other) const = dynamic_cast*>(&fe_other)) { if (this->degree < fe_q_other->degree) - return FiniteElementDomination::this_element_dominates; + return FiniteElementDomination::this_element_dominates; else if (this->degree == fe_q_other->degree) - return FiniteElementDomination::either_element_can_dominate; + return FiniteElementDomination::either_element_can_dominate; else - return FiniteElementDomination::other_element_dominates; + return FiniteElementDomination::other_element_dominates; } else if (dynamic_cast*>(&fe_other) != 0) { - // the FE_Nothing has no - // degrees of freedom and it is - // typically used in a context - // where we don't require any - // continuity along the - // interface + // the FE_Nothing has no + // degrees of freedom and it is + // typically used in a context + // where we don't require any + // continuity along the + // interface return FiniteElementDomination::no_requirements; } @@ -205,59 +205,59 @@ compare_for_face_domination (const FiniteElement &fe_other) const template void FE_Q_Hierarchical::build_dofs_cell (std::vector > &dofs_cell, - std::vector > &dofs_subcell) const + std::vector > &dofs_subcell) const { const unsigned int dofs_1d = 2*this->dofs_per_vertex + this->dofs_per_line; for (unsigned int c=0; c::max_children_per_cell; ++c) for (unsigned int j=0; j=2)) - { - if (((c==0) && (j==1) && ((k % 2)==0)) || - ((c==1) && (j==0) && ((k % 2)==0))) - dofs_subcell[c](j,k) = -1.; - } - // lower diagonal block - else if ((j>=2) && (k>=2) && (j<=k)) - { - double factor = 1.; - for (unsigned int i=1; i<=j;++i) - factor *= ((double) (k-i+1))/((double) i); - if (c==0) - { - dofs_subcell[c](j,k) = ((k+j) % 2 == 0) ? - std::pow(.5,static_cast(k))*factor : - -std::pow(.5,static_cast(k))*factor; - dofs_cell[c](j,k) = std::pow(2.,static_cast(j))*factor; - } - else - { - dofs_subcell[c](j,k) = std::pow(.5,static_cast(k))*factor; - dofs_cell[c](j,k) = ((k+j) % 2 == 0) ? - std::pow(2.,static_cast(j))*factor : - -std::pow(2.,static_cast(j))*factor; - } - } - } + { + // upper diagonal block + if ((j<=1) && (k<=1)) + { + if (((c==0) && (j==0) && (k==0)) || + ((c==1) && (j==1) && (k==1))) + dofs_cell[c](j,k) = 1.; + else + dofs_cell[c](j,k) = 0.; + + if (((c==0) && (j==1)) || ((c==1) && (j==0))) + dofs_subcell[c](j,k) = .5; + else if (((c==0) && (k==0)) || ((c==1) && (k==1))) + dofs_subcell[c](j,k) = 1.; + else + dofs_subcell[c](j,k) = 0.; + } + // upper right block + else if ((j<=1) && (k>=2)) + { + if (((c==0) && (j==1) && ((k % 2)==0)) || + ((c==1) && (j==0) && ((k % 2)==0))) + dofs_subcell[c](j,k) = -1.; + } + // lower diagonal block + else if ((j>=2) && (k>=2) && (j<=k)) + { + double factor = 1.; + for (unsigned int i=1; i<=j;++i) + factor *= ((double) (k-i+1))/((double) i); + if (c==0) + { + dofs_subcell[c](j,k) = ((k+j) % 2 == 0) ? + std::pow(.5,static_cast(k))*factor : + -std::pow(.5,static_cast(k))*factor; + dofs_cell[c](j,k) = std::pow(2.,static_cast(j))*factor; + } + else + { + dofs_subcell[c](j,k) = std::pow(.5,static_cast(k))*factor; + dofs_cell[c](j,k) = ((k+j) % 2 == 0) ? + std::pow(2.,static_cast(j))*factor : + -std::pow(2.,static_cast(j))*factor; + } + } + } } @@ -277,124 +277,124 @@ initialize_constraints (const std::vector > &dofs_subcell) { case 1: { - // no constraints in 1d - break; + // no constraints in 1d + break; } case 2: { - // vertex node - for (unsigned int i=0; iinterface_constraints(0,i) = dofs_subcell[0](1,i); - // edge nodes - for (unsigned int c=0; c::max_children_per_cell; ++c) - for (unsigned int i=0; iinterface_constraints(1 + c*(degree-1) + j - 2,i) = - dofs_subcell[c](j,i); - break; + // vertex node + for (unsigned int i=0; iinterface_constraints(0,i) = dofs_subcell[0](1,i); + // edge nodes + for (unsigned int c=0; c::max_children_per_cell; ++c) + for (unsigned int i=0; iinterface_constraints(1 + c*(degree-1) + j - 2,i) = + dofs_subcell[c](j,i); + break; } case 3: { - for (unsigned int i=0; iinterface_constraints(0,face_renumber[i]) = - dofs_subcell[0](1,i % dofs_1d) * - dofs_subcell[0](1,(i - (i % dofs_1d)) / dofs_1d); - - // boundary vertex nodes - this->interface_constraints(1,face_renumber[i]) = - dofs_subcell[0](0, i % dofs_1d) * - dofs_subcell[0](1, (i - (i % dofs_1d)) / dofs_1d); - this->interface_constraints(2,face_renumber[i]) = - dofs_subcell[1](1, i % dofs_1d) * - dofs_subcell[0](1, (i - (i % dofs_1d)) / dofs_1d); - this->interface_constraints(3,face_renumber[i]) = - dofs_subcell[0](1, i % dofs_1d) * - dofs_subcell[0](0, (i - (i % dofs_1d)) / dofs_1d); - this->interface_constraints(4,face_renumber[i]) = - dofs_subcell[1](0, i % dofs_1d) * - dofs_subcell[1](1, (i - (i % dofs_1d)) / dofs_1d); - - // interior edges - for (unsigned int j=0; j<(degree-1); j++) - { - this->interface_constraints(5 + j,face_renumber[i]) = - dofs_subcell[0](1, i % dofs_1d) * - dofs_subcell[0](2 + j, (i - (i % dofs_1d)) / dofs_1d); - this->interface_constraints(5 + (degree-1) + j,face_renumber[i]) = - dofs_subcell[0](1,i % dofs_1d) * - dofs_subcell[1](2 + j, (i - (i % dofs_1d)) / dofs_1d); - this->interface_constraints(5 + 2*(degree-1) + j,face_renumber[i]) = - dofs_subcell[0](2 + j,i % dofs_1d) * - dofs_subcell[1](0, (i - (i % dofs_1d)) / dofs_1d); - this->interface_constraints(5 + 3*(degree-1) + j,face_renumber[i]) = - dofs_subcell[1](2 + j, i % dofs_1d) * - dofs_subcell[0](1, (i - (i % dofs_1d)) / dofs_1d); - } - - // boundary edges - for (unsigned int j=0; j<(degree-1); j++) - { - // left edge - this->interface_constraints(5 + 4*(degree-1) + j,face_renumber[i]) = - dofs_subcell[0](0, i % dofs_1d) * - dofs_subcell[0](2 + j, (i - (i % dofs_1d)) / dofs_1d); - this->interface_constraints(5 + 4*(degree-1) + (degree-1) + j,face_renumber[i]) = - dofs_subcell[0](0, i % dofs_1d) * - dofs_subcell[1](2 + j, (i - (i % dofs_1d)) / dofs_1d); - // right edge - this->interface_constraints(5 + 4*(degree-1) + 2*(degree-1) + j,face_renumber[i]) = - dofs_subcell[1](1, i % dofs_1d) * - dofs_subcell[0](2 + j, (i - (i % dofs_1d)) / dofs_1d); - this->interface_constraints(5 + 4*(degree-1) + 3*(degree-1) + j,face_renumber[i]) = - dofs_subcell[1](1, i % dofs_1d) * - dofs_subcell[1](2 + j, (i - (i % dofs_1d)) / dofs_1d); - // bottom edge - this->interface_constraints(5 + 4*(degree-1) + 4*(degree-1) + j,face_renumber[i]) = - dofs_subcell[0](2 + j, i % dofs_1d) * - dofs_subcell[0](0, (i - (i % dofs_1d)) / dofs_1d); - this->interface_constraints(5 + 4*(degree-1) + 5*(degree-1) + j,face_renumber[i]) = - dofs_subcell[1](2 + j, i % dofs_1d) * - dofs_subcell[0](0, (i - (i % dofs_1d)) / dofs_1d); - // top edge - this->interface_constraints(5 + 4*(degree-1) + 6*(degree-1) + j,face_renumber[i]) = - dofs_subcell[0](2 + j, i % dofs_1d) * - dofs_subcell[1](1, (i - (i % dofs_1d)) / dofs_1d); - this->interface_constraints(5 + 4*(degree-1) + 7*(degree-1) + j,face_renumber[i]) = - dofs_subcell[1](2 + j, i % dofs_1d) * - dofs_subcell[1](1, (i - (i % dofs_1d)) / dofs_1d); - } - - // interior faces - for (unsigned int j=0; j<(degree-1); j++) - for (unsigned int k=0; k<(degree-1); k++) - { - // subcell 0 - this->interface_constraints(5 + 12*(degree-1) + j + k*(degree-1),face_renumber[i]) = - dofs_subcell[0](2 + j, i % dofs_1d) * - dofs_subcell[0](2 + k, (i - (i % dofs_1d)) / dofs_1d); - // subcell 1 - this->interface_constraints(5 + 12*(degree-1) + j + k*(degree-1) + (degree-1)*(degree-1),face_renumber[i]) = - dofs_subcell[1](2 + j, i % dofs_1d) * - dofs_subcell[0](2 + k, (i - (i % dofs_1d)) / dofs_1d); - // subcell 2 - this->interface_constraints(5 + 12*(degree-1) + j + k*(degree-1) + 2*(degree-1)*(degree-1),face_renumber[i]) = - dofs_subcell[0](2 + j, i % dofs_1d) * - dofs_subcell[1](2 + k, (i - (i % dofs_1d)) / dofs_1d); - // subcell 3 - this->interface_constraints(5 + 12*(degree-1) + j + k*(degree-1) + 3*(degree-1)*(degree-1),face_renumber[i]) = - dofs_subcell[1](2 + j, i % dofs_1d) * - dofs_subcell[1](2 + k, (i - (i % dofs_1d)) / dofs_1d); - } - } - break; + for (unsigned int i=0; iinterface_constraints(0,face_renumber[i]) = + dofs_subcell[0](1,i % dofs_1d) * + dofs_subcell[0](1,(i - (i % dofs_1d)) / dofs_1d); + + // boundary vertex nodes + this->interface_constraints(1,face_renumber[i]) = + dofs_subcell[0](0, i % dofs_1d) * + dofs_subcell[0](1, (i - (i % dofs_1d)) / dofs_1d); + this->interface_constraints(2,face_renumber[i]) = + dofs_subcell[1](1, i % dofs_1d) * + dofs_subcell[0](1, (i - (i % dofs_1d)) / dofs_1d); + this->interface_constraints(3,face_renumber[i]) = + dofs_subcell[0](1, i % dofs_1d) * + dofs_subcell[0](0, (i - (i % dofs_1d)) / dofs_1d); + this->interface_constraints(4,face_renumber[i]) = + dofs_subcell[1](0, i % dofs_1d) * + dofs_subcell[1](1, (i - (i % dofs_1d)) / dofs_1d); + + // interior edges + for (unsigned int j=0; j<(degree-1); j++) + { + this->interface_constraints(5 + j,face_renumber[i]) = + dofs_subcell[0](1, i % dofs_1d) * + dofs_subcell[0](2 + j, (i - (i % dofs_1d)) / dofs_1d); + this->interface_constraints(5 + (degree-1) + j,face_renumber[i]) = + dofs_subcell[0](1,i % dofs_1d) * + dofs_subcell[1](2 + j, (i - (i % dofs_1d)) / dofs_1d); + this->interface_constraints(5 + 2*(degree-1) + j,face_renumber[i]) = + dofs_subcell[0](2 + j,i % dofs_1d) * + dofs_subcell[1](0, (i - (i % dofs_1d)) / dofs_1d); + this->interface_constraints(5 + 3*(degree-1) + j,face_renumber[i]) = + dofs_subcell[1](2 + j, i % dofs_1d) * + dofs_subcell[0](1, (i - (i % dofs_1d)) / dofs_1d); + } + + // boundary edges + for (unsigned int j=0; j<(degree-1); j++) + { + // left edge + this->interface_constraints(5 + 4*(degree-1) + j,face_renumber[i]) = + dofs_subcell[0](0, i % dofs_1d) * + dofs_subcell[0](2 + j, (i - (i % dofs_1d)) / dofs_1d); + this->interface_constraints(5 + 4*(degree-1) + (degree-1) + j,face_renumber[i]) = + dofs_subcell[0](0, i % dofs_1d) * + dofs_subcell[1](2 + j, (i - (i % dofs_1d)) / dofs_1d); + // right edge + this->interface_constraints(5 + 4*(degree-1) + 2*(degree-1) + j,face_renumber[i]) = + dofs_subcell[1](1, i % dofs_1d) * + dofs_subcell[0](2 + j, (i - (i % dofs_1d)) / dofs_1d); + this->interface_constraints(5 + 4*(degree-1) + 3*(degree-1) + j,face_renumber[i]) = + dofs_subcell[1](1, i % dofs_1d) * + dofs_subcell[1](2 + j, (i - (i % dofs_1d)) / dofs_1d); + // bottom edge + this->interface_constraints(5 + 4*(degree-1) + 4*(degree-1) + j,face_renumber[i]) = + dofs_subcell[0](2 + j, i % dofs_1d) * + dofs_subcell[0](0, (i - (i % dofs_1d)) / dofs_1d); + this->interface_constraints(5 + 4*(degree-1) + 5*(degree-1) + j,face_renumber[i]) = + dofs_subcell[1](2 + j, i % dofs_1d) * + dofs_subcell[0](0, (i - (i % dofs_1d)) / dofs_1d); + // top edge + this->interface_constraints(5 + 4*(degree-1) + 6*(degree-1) + j,face_renumber[i]) = + dofs_subcell[0](2 + j, i % dofs_1d) * + dofs_subcell[1](1, (i - (i % dofs_1d)) / dofs_1d); + this->interface_constraints(5 + 4*(degree-1) + 7*(degree-1) + j,face_renumber[i]) = + dofs_subcell[1](2 + j, i % dofs_1d) * + dofs_subcell[1](1, (i - (i % dofs_1d)) / dofs_1d); + } + + // interior faces + for (unsigned int j=0; j<(degree-1); j++) + for (unsigned int k=0; k<(degree-1); k++) + { + // subcell 0 + this->interface_constraints(5 + 12*(degree-1) + j + k*(degree-1),face_renumber[i]) = + dofs_subcell[0](2 + j, i % dofs_1d) * + dofs_subcell[0](2 + k, (i - (i % dofs_1d)) / dofs_1d); + // subcell 1 + this->interface_constraints(5 + 12*(degree-1) + j + k*(degree-1) + (degree-1)*(degree-1),face_renumber[i]) = + dofs_subcell[1](2 + j, i % dofs_1d) * + dofs_subcell[0](2 + k, (i - (i % dofs_1d)) / dofs_1d); + // subcell 2 + this->interface_constraints(5 + 12*(degree-1) + j + k*(degree-1) + 2*(degree-1)*(degree-1),face_renumber[i]) = + dofs_subcell[0](2 + j, i % dofs_1d) * + dofs_subcell[1](2 + k, (i - (i % dofs_1d)) / dofs_1d); + // subcell 3 + this->interface_constraints(5 + 12*(degree-1) + j + k*(degree-1) + 3*(degree-1)*(degree-1),face_renumber[i]) = + dofs_subcell[1](2 + j, i % dofs_1d) * + dofs_subcell[1](2 + k, (i - (i % dofs_1d)) / dofs_1d); + } + } + break; } default: - Assert (false, ExcNotImplemented()); + Assert (false, ExcNotImplemented()); } } @@ -404,7 +404,7 @@ template void FE_Q_Hierarchical:: initialize_embedding_and_restriction (const std::vector > &dofs_cell, - const std::vector > &dofs_subcell) + const std::vector > &dofs_subcell) { unsigned int iso=RefinementCase::isotropic_refinement-1; @@ -418,89 +418,89 @@ initialize_embedding_and_restriction (const std::vector > &do this->restriction[iso][c].reinit (this->dofs_per_cell, this->dofs_per_cell); } - // the 1d case is particularly - // simple, so special case it: + // the 1d case is particularly + // simple, so special case it: if (dim==1) { for (unsigned int c=0; c::max_children_per_cell; ++c) - { - this->prolongation[iso][c].fill (dofs_subcell[c]); - this->restriction[iso][c].fill (dofs_cell[c]); - } + { + this->prolongation[iso][c].fill (dofs_subcell[c]); + this->restriction[iso][c].fill (dofs_cell[c]); + } return; } - // for higher dimensions, things - // are a little more tricky: + // for higher dimensions, things + // are a little more tricky: - // j loops over dofs in the - // subcell. These are the rows in - // the embedding matrix. - // - // i loops over the dofs in the - // master cell. These are the - // columns in the embedding matrix. + // j loops over dofs in the + // subcell. These are the rows in + // the embedding matrix. + // + // i loops over the dofs in the + // master cell. These are the + // columns in the embedding matrix. for (unsigned int j=0; jdofs_per_cell; ++j) for (unsigned int i=0; idofs_per_cell; ++i) switch (dim) - { - case 2: - { - for (unsigned int c=0; c::max_children_per_cell; ++c) - { - // left/right line: 0/1 - const unsigned int c0 = c%2; - // bottom/top line: 0/1 - const unsigned int c1 = c/2; - - this->prolongation[iso][c](j,i) = - dofs_subcell[c0](renumber[j] % dofs_1d, - renumber[i] % dofs_1d) * - dofs_subcell[c1]((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d, - (renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d); - - this->restriction[iso][c](j,i) = - dofs_cell[c0](renumber[j] % dofs_1d, - renumber[i] % dofs_1d) * - dofs_cell[c1]((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d, - (renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d); - } - break; - } - - case 3: - { - for (unsigned int c=0; c::max_children_per_cell; ++c) - { - // left/right face: 0/1 - const unsigned int c0 = c%2; - // front/back face: 0/1 - const unsigned int c1 = (c%4)/2; - // bottom/top face: 0/1 - const unsigned int c2 = c/4; - - this->prolongation[iso][c](j,i) = - dofs_subcell[c0](renumber[j] % dofs_1d, - renumber[i] % dofs_1d) * - dofs_subcell[c1](((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d) % dofs_1d, - ((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d) % dofs_1d) * - dofs_subcell[c2](((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d - (((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d ) % dofs_1d)) / dofs_1d, - ((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d - (((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d ) % dofs_1d)) / dofs_1d); - - this->restriction[iso][c](j,i) = - dofs_cell[c0](renumber[j] % dofs_1d, - renumber[i] % dofs_1d) * - dofs_cell[c1](((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d) % dofs_1d, - ((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d) % dofs_1d) * - dofs_cell[c2](((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d - (((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d ) % dofs_1d)) / dofs_1d, - ((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d - (((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d ) % dofs_1d)) / dofs_1d); - } - break; - } - - default: - Assert (false, ExcNotImplemented()); - } + { + case 2: + { + for (unsigned int c=0; c::max_children_per_cell; ++c) + { + // left/right line: 0/1 + const unsigned int c0 = c%2; + // bottom/top line: 0/1 + const unsigned int c1 = c/2; + + this->prolongation[iso][c](j,i) = + dofs_subcell[c0](renumber[j] % dofs_1d, + renumber[i] % dofs_1d) * + dofs_subcell[c1]((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d, + (renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d); + + this->restriction[iso][c](j,i) = + dofs_cell[c0](renumber[j] % dofs_1d, + renumber[i] % dofs_1d) * + dofs_cell[c1]((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d, + (renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d); + } + break; + } + + case 3: + { + for (unsigned int c=0; c::max_children_per_cell; ++c) + { + // left/right face: 0/1 + const unsigned int c0 = c%2; + // front/back face: 0/1 + const unsigned int c1 = (c%4)/2; + // bottom/top face: 0/1 + const unsigned int c2 = c/4; + + this->prolongation[iso][c](j,i) = + dofs_subcell[c0](renumber[j] % dofs_1d, + renumber[i] % dofs_1d) * + dofs_subcell[c1](((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d) % dofs_1d, + ((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d) % dofs_1d) * + dofs_subcell[c2](((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d - (((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d ) % dofs_1d)) / dofs_1d, + ((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d - (((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d ) % dofs_1d)) / dofs_1d); + + this->restriction[iso][c](j,i) = + dofs_cell[c0](renumber[j] % dofs_1d, + renumber[i] % dofs_1d) * + dofs_cell[c1](((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d) % dofs_1d, + ((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d) % dofs_1d) * + dofs_cell[c2](((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d - (((renumber[j] - (renumber[j] % dofs_1d)) / dofs_1d ) % dofs_1d)) / dofs_1d, + ((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d - (((renumber[i] - (renumber[i] % dofs_1d)) / dofs_1d ) % dofs_1d)) / dofs_1d); + } + break; + } + + default: + Assert (false, ExcNotImplemented()); + } } @@ -508,7 +508,7 @@ initialize_embedding_and_restriction (const std::vector > &do template void FE_Q_Hierarchical::initialize_unit_support_points () { - // number of points: (degree+1)^dim + // number of points: (degree+1)^dim unsigned int n = this->degree+1; for (unsigned int i=1; idegree+1; @@ -547,33 +547,33 @@ void FE_Q_Hierarchical::initialize_unit_support_points () for (unsigned int iz=0; iz <= ((dim>2) ? this->degree : 0) ; ++iz) for (unsigned int iy=0; iy <= ((dim>1) ? this->degree : 0) ; ++iy) for (unsigned int ix=0; ix<=this->degree; ++ix) - { - if (ix==0) - p(0) = 0.; - else if (ix==1) - p(0) = 1.; - else - p(0) = .5; - if (dim>1) - { - if (iy==0) - p(1) = 0.; - else if (iy==1) - p(1) = 1.; - else - p(1) = .5; - } - if (dim>2) - { - if (iz==0) - p(2) = 0.; - else if (iz==1) - p(2) = 1.; - else - p(2) = .5; - } - this->unit_support_points[index_map_inverse[k++]] = p; - }; + { + if (ix==0) + p(0) = 0.; + else if (ix==1) + p(0) = 1.; + else + p(0) = .5; + if (dim>1) + { + if (iy==0) + p(1) = 0.; + else if (iy==1) + p(1) = 1.; + else + p(1) = .5; + } + if (dim>2) + { + if (iz==0) + p(2) = 0.; + else if (iz==1) + p(2) = 1.; + else + p(2) = .5; + } + this->unit_support_points[index_map_inverse[k++]] = p; + }; } @@ -581,14 +581,14 @@ void FE_Q_Hierarchical::initialize_unit_support_points () template <> void FE_Q_Hierarchical<1>::initialize_unit_face_support_points () { - // no faces in 1d, so nothing to do + // no faces in 1d, so nothing to do } template <> void FE_Q_Hierarchical<1>:: get_face_interpolation_matrix (const FiniteElement<1,1> &/*x_source_fe*/, - FullMatrix &/*interpolation_matrix*/) const + FullMatrix &/*interpolation_matrix*/) const { Assert (false, ExcImpossibleInDim(1)); } @@ -598,8 +598,8 @@ template <> void FE_Q_Hierarchical<1>:: get_subface_interpolation_matrix (const FiniteElement<1,1> &/*x_source_fe*/, - const unsigned int /*subface*/, - FullMatrix &/*interpolation_matrix*/) const + const unsigned int /*subface*/, + FullMatrix &/*interpolation_matrix*/) const { Assert (false, ExcImpossibleInDim(1)); } @@ -610,11 +610,11 @@ template void FE_Q_Hierarchical:: get_face_interpolation_matrix (const FiniteElement &x_source_fe, - FullMatrix &interpolation_matrix) const + FullMatrix &interpolation_matrix) const { - // this is only implemented, if the - // source FE is also a - // Q_Hierarchical element + // this is only implemented, if the + // source FE is also a + // Q_Hierarchical element typedef FE_Q_Hierarchical FEQHierarchical; typedef FiniteElement FEL; AssertThrow ((x_source_fe.get_name().find ("FE_Q_Hierarchical<") == 0) @@ -624,18 +624,18 @@ get_face_interpolation_matrix (const FiniteElement &x_source_fe, ExcInterpolationNotImplemented()); Assert (interpolation_matrix.n() == this->dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.n(), - this->dofs_per_face)); + ExcDimensionMismatch (interpolation_matrix.n(), + this->dofs_per_face)); Assert (interpolation_matrix.m() == x_source_fe.dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.m(), - x_source_fe.dofs_per_face)); + ExcDimensionMismatch (interpolation_matrix.m(), + x_source_fe.dofs_per_face)); - // ok, source is a Q_Hierarchical element, so - // we will be able to do the work + // ok, source is a Q_Hierarchical element, so + // we will be able to do the work const FE_Q_Hierarchical &source_fe = dynamic_cast&>(x_source_fe); - // Make sure, that the element, + // Make sure, that the element, // for which the DoFs should be // constrained is the one with // the higher polynomial degree. @@ -643,38 +643,38 @@ get_face_interpolation_matrix (const FiniteElement &x_source_fe, // also if this assertion is not // satisfied. But the matrices // produced in that case might - // lead to problems in the + // lead to problems in the // hp procedures, which use this - // method. + // method. Assert (this->dofs_per_face <= source_fe.dofs_per_face, - typename FEL:: - ExcInterpolationNotImplemented ()); + typename FEL:: + ExcInterpolationNotImplemented ()); interpolation_matrix = 0; switch (dim) { case 2: { for (unsigned int i = 0; i < this->dofs_per_face; ++i) - interpolation_matrix (i, i) = 1; + interpolation_matrix (i, i) = 1; break; } case 3: { for (unsigned int i = 0; i < GeometryInfo<3>::vertices_per_face; ++i) - interpolation_matrix (i, i) = 1; + interpolation_matrix (i, i) = 1; for (unsigned int i = 0; i < this->degree - 1; ++i) { - for (unsigned int j = 0; j < GeometryInfo<3>::lines_per_face; ++j) - interpolation_matrix ( - i + j * (x_source_fe.degree - 1) + GeometryInfo<3>::vertices_per_face, - i + j * (this->degree - 1) + GeometryInfo<3>::vertices_per_face) = 1; - - for (unsigned int j = 0; j < this->degree - 1; ++j) - interpolation_matrix ( - (i + GeometryInfo<3>::lines_per_face) * (x_source_fe.degree - 1) + j - + GeometryInfo<3>::vertices_per_face, - (i + GeometryInfo<3>::lines_per_face) * (this->degree - 1) + j - + GeometryInfo<3>::vertices_per_face) = 1; + for (unsigned int j = 0; j < GeometryInfo<3>::lines_per_face; ++j) + interpolation_matrix ( + i + j * (x_source_fe.degree - 1) + GeometryInfo<3>::vertices_per_face, + i + j * (this->degree - 1) + GeometryInfo<3>::vertices_per_face) = 1; + + for (unsigned int j = 0; j < this->degree - 1; ++j) + interpolation_matrix ( + (i + GeometryInfo<3>::lines_per_face) * (x_source_fe.degree - 1) + j + + GeometryInfo<3>::vertices_per_face, + (i + GeometryInfo<3>::lines_per_face) * (this->degree - 1) + j + + GeometryInfo<3>::vertices_per_face) = 1; } } } @@ -686,12 +686,12 @@ template void FE_Q_Hierarchical:: get_subface_interpolation_matrix (const FiniteElement &x_source_fe, - const unsigned int subface, - FullMatrix &interpolation_matrix) const + const unsigned int subface, + FullMatrix &interpolation_matrix) const { - // this is only implemented, if the - // source FE is also a - // Q_Hierarchical element + // this is only implemented, if the + // source FE is also a + // Q_Hierarchical element typedef FE_Q_Hierarchical FEQHierarchical; typedef FiniteElement FEL; AssertThrow ((x_source_fe.get_name().find ("FE_Q_Hierarchical<") == 0) @@ -701,18 +701,18 @@ get_subface_interpolation_matrix (const FiniteElement &x_source_fe, ExcInterpolationNotImplemented()); Assert (interpolation_matrix.n() == this->dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.n(), - this->dofs_per_face)); + ExcDimensionMismatch (interpolation_matrix.n(), + this->dofs_per_face)); Assert (interpolation_matrix.m() == x_source_fe.dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.m(), - x_source_fe.dofs_per_face)); + ExcDimensionMismatch (interpolation_matrix.m(), + x_source_fe.dofs_per_face)); - // ok, source is a Q_Hierarchical element, so - // we will be able to do the work + // ok, source is a Q_Hierarchical element, so + // we will be able to do the work const FE_Q_Hierarchical &source_fe = dynamic_cast&>(x_source_fe); - // Make sure, that the element, + // Make sure, that the element, // for which the DoFs should be // constrained is the one with // the higher polynomial degree. @@ -720,96 +720,96 @@ get_subface_interpolation_matrix (const FiniteElement &x_source_fe, // also if this assertion is not // satisfied. But the matrices // produced in that case might - // lead to problems in the + // lead to problems in the // hp procedures, which use this - // method. + // method. Assert (this->dofs_per_face <= source_fe.dofs_per_face, - typename FEL:: - ExcInterpolationNotImplemented ()); + typename FEL:: + ExcInterpolationNotImplemented ()); switch (dim) { case 2: { - switch (subface) - { - case 0: - { - interpolation_matrix (0, 0) = 1.0; - interpolation_matrix (1, 0) = 0.5; - interpolation_matrix (1, 1) = 0.5; - - for (unsigned int dof = 2; dof < this->dofs_per_face;) - { - interpolation_matrix (1, dof) = -1.0; - dof = dof + 2; - } - - int factorial_i = 1; - int factorial_ij; - int factorial_j; - - for (int i = 2; i < (int) this->dofs_per_face; ++i) - { - interpolation_matrix (i, i) = std::pow (0.5, i); - factorial_i *= i; - factorial_j = factorial_i; - factorial_ij = 1; - - for (int j = i + 1; j < (int) this->dofs_per_face; ++j) - { - factorial_ij *= j - i; - factorial_j *= j; - - if ((i + j) & 1) - interpolation_matrix (i, j) - = -1.0 * std::pow (0.5, j) * - factorial_j / (factorial_i * factorial_ij); - - else - interpolation_matrix (i, j) - = std::pow (0.5, j) * - factorial_j / (factorial_i * factorial_ij); - } - } - - break; - } - - case 1: - { - interpolation_matrix (0, 0) = 0.5; - interpolation_matrix (0, 1) = 0.5; - - for (unsigned int dof = 2; dof < this->dofs_per_face;) - { - interpolation_matrix (0, dof) = -1.0; - dof = dof + 2; - } - - interpolation_matrix (1, 1) = 1.0; - - int factorial_i = 1; - int factorial_ij; - int factorial_j; - - for (int i = 2; i < (int) this->dofs_per_face; ++i) - { - interpolation_matrix (i, i) = std::pow (0.5, i); - factorial_i *= i; - factorial_j = factorial_i; - factorial_ij = 1; - - for (int j = i + 1; j < (int) this->dofs_per_face; ++j) - { - factorial_ij *= j - i; - factorial_j *= j; - interpolation_matrix (i, j) - = std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij); - } - } - } - } + switch (subface) + { + case 0: + { + interpolation_matrix (0, 0) = 1.0; + interpolation_matrix (1, 0) = 0.5; + interpolation_matrix (1, 1) = 0.5; + + for (unsigned int dof = 2; dof < this->dofs_per_face;) + { + interpolation_matrix (1, dof) = -1.0; + dof = dof + 2; + } + + int factorial_i = 1; + int factorial_ij; + int factorial_j; + + for (int i = 2; i < (int) this->dofs_per_face; ++i) + { + interpolation_matrix (i, i) = std::pow (0.5, i); + factorial_i *= i; + factorial_j = factorial_i; + factorial_ij = 1; + + for (int j = i + 1; j < (int) this->dofs_per_face; ++j) + { + factorial_ij *= j - i; + factorial_j *= j; + + if ((i + j) & 1) + interpolation_matrix (i, j) + = -1.0 * std::pow (0.5, j) * + factorial_j / (factorial_i * factorial_ij); + + else + interpolation_matrix (i, j) + = std::pow (0.5, j) * + factorial_j / (factorial_i * factorial_ij); + } + } + + break; + } + + case 1: + { + interpolation_matrix (0, 0) = 0.5; + interpolation_matrix (0, 1) = 0.5; + + for (unsigned int dof = 2; dof < this->dofs_per_face;) + { + interpolation_matrix (0, dof) = -1.0; + dof = dof + 2; + } + + interpolation_matrix (1, 1) = 1.0; + + int factorial_i = 1; + int factorial_ij; + int factorial_j; + + for (int i = 2; i < (int) this->dofs_per_face; ++i) + { + interpolation_matrix (i, i) = std::pow (0.5, i); + factorial_i *= i; + factorial_j = factorial_i; + factorial_ij = 1; + + for (int j = i + 1; j < (int) this->dofs_per_face; ++j) + { + factorial_ij *= j - i; + factorial_j *= j; + interpolation_matrix (i, j) + = std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij); + } + } + } + } break; } @@ -817,318 +817,318 @@ get_subface_interpolation_matrix (const FiniteElement &x_source_fe, case 3: { switch (subface) - { - case 0: - { + { + case 0: + { interpolation_matrix (0, 0) = 1.0; interpolation_matrix (1, 0) = 0.5; interpolation_matrix (1, 1) = 0.5; interpolation_matrix (2, 0) = 0.5; interpolation_matrix (2, 2) = 0.5; - for (unsigned int i = 0; i < this->degree - 1;) - { - for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_face; ++line) - interpolation_matrix (3, i + line * (this->degree - 1) + 4) = -0.5; - - for (unsigned int j = 0; j < this->degree - 1;) - { - interpolation_matrix (3, i + (j + 4) * this->degree - j) = 1.0; - j = j + 2; - } - - interpolation_matrix (1, i + 2 * (this->degree + 1)) = -1.0; - interpolation_matrix (2, i + 4) = -1.0; - i = i + 2; - } - - for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_face; ++vertex) - interpolation_matrix (3, vertex) = 0.25; - - int factorial_i = 1; - int factorial_ij; - int factorial_j; - int factorial_k; - int factorial_kl; - int factorial_l; - - for (int i = 2; i <= (int) this->degree; ++i) - { - double tmp = std::pow (0.5, i); - interpolation_matrix (i + 2, i + 2) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, i + 2 * this->degree) = tmp; - tmp *= 0.5; - interpolation_matrix (i + source_fe.degree + 1, i + 2) = tmp; - interpolation_matrix (i + source_fe.degree + 1, i + this->degree + 1) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, i + 2 * this->degree) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, i + 3 * this->degree - 1) = tmp; - tmp *= -2.0; - - for (unsigned int j = 0; j < this->degree - 1;) - { - interpolation_matrix (i + source_fe.degree + 1, (i + 2) * this->degree + j + 2 - i) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, i + (j + 4) * this->degree - j - 2) = tmp; - j = j + 2; - } - - factorial_k = 1; - - for (int j = 2; j <= (int) this->degree; ++j) - { - interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j); - factorial_k *= j; - factorial_kl = 1; - factorial_l = factorial_k; - - for (int k = j + 1; k < (int) this->degree; ++k) - { - factorial_kl *= k - j; - factorial_l *= k; - - if ((j + k) & 1) - interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (k + 2) * this->degree - k) = -1.0 * std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl); - - else - interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (k + 2) * this->degree - k) = std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl); - } - } - - factorial_i *= i; - factorial_j = factorial_i; - factorial_ij = 1; - - for (int j = i + 1; j <= (int) this->degree; ++j) - { - factorial_ij *= j - i; - factorial_j *= j; - - if ((i + j) & 1) - { - tmp = -1.0 * std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij); - interpolation_matrix (i + 2, j + 2) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, j + 2 * this->degree) = tmp; - factorial_k = 1; - - for (int k = 2; k <= (int) this->degree; ++k) - { - interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k); - factorial_k *= k; - factorial_l = factorial_k; - factorial_kl = 1; - - for (int l = k + 1; l <= (int) this->degree; ++l) { - factorial_kl *= l - k; - factorial_l *= l; - - if ((k + l) & 1) - interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = -1.0 * tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); - - else - interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); - } - } - - tmp *= 0.5; - interpolation_matrix (i + source_fe.degree + 1, j + 2) = tmp; - interpolation_matrix (i + source_fe.degree + 1, j + this->degree + 1) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, j + 2 * this->degree) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, j + 3 * this->degree - 1) = tmp; - tmp *= -2.0; - - for (unsigned int k = 0; k < this->degree - 1;) - { - interpolation_matrix (i + source_fe.degree + 1, (j + 2) * this->degree + k + 2 - j) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, j + (k + 4) * this->degree - k - 2) = tmp; - k = k + 2; - } - } - else - { - tmp = std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij); - interpolation_matrix (i + 2, j + 2) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, j + 2 * this->degree) = tmp; - factorial_k = 1; - - for (int k = 2; k <= (int) this->degree; ++k) - { - interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k); - factorial_k *= k; - factorial_l = factorial_k; - factorial_kl = 1; - - for (int l = k + 1; l <= (int) this->degree; ++l) - { - factorial_kl *= l - k; - factorial_l *= l; - - if ((k + l) & 1) - interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = -1.0 * tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); - - else - interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); - } - } - - tmp *= 0.5; - interpolation_matrix (i + source_fe.degree + 1, j + 2) = tmp; - interpolation_matrix (i + source_fe.degree + 1, j + this->degree + 1) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, j + 2 * this->degree) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, j + 3 * this->degree - 1) = tmp; - tmp *= -2.0; - - for (unsigned int k = 0; k < this->degree - 1;) - { - interpolation_matrix (i + source_fe.degree + 1, (j + 2) * this->degree + k + 2 - j) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, j + (k + 4) * this->degree - k - 2) = tmp; - k = k + 2; - } - } - } - } + for (unsigned int i = 0; i < this->degree - 1;) + { + for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_face; ++line) + interpolation_matrix (3, i + line * (this->degree - 1) + 4) = -0.5; + + for (unsigned int j = 0; j < this->degree - 1;) + { + interpolation_matrix (3, i + (j + 4) * this->degree - j) = 1.0; + j = j + 2; + } + + interpolation_matrix (1, i + 2 * (this->degree + 1)) = -1.0; + interpolation_matrix (2, i + 4) = -1.0; + i = i + 2; + } + + for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_face; ++vertex) + interpolation_matrix (3, vertex) = 0.25; + + int factorial_i = 1; + int factorial_ij; + int factorial_j; + int factorial_k; + int factorial_kl; + int factorial_l; + + for (int i = 2; i <= (int) this->degree; ++i) + { + double tmp = std::pow (0.5, i); + interpolation_matrix (i + 2, i + 2) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, i + 2 * this->degree) = tmp; + tmp *= 0.5; + interpolation_matrix (i + source_fe.degree + 1, i + 2) = tmp; + interpolation_matrix (i + source_fe.degree + 1, i + this->degree + 1) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, i + 2 * this->degree) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, i + 3 * this->degree - 1) = tmp; + tmp *= -2.0; + + for (unsigned int j = 0; j < this->degree - 1;) + { + interpolation_matrix (i + source_fe.degree + 1, (i + 2) * this->degree + j + 2 - i) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, i + (j + 4) * this->degree - j - 2) = tmp; + j = j + 2; + } + + factorial_k = 1; + + for (int j = 2; j <= (int) this->degree; ++j) + { + interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j); + factorial_k *= j; + factorial_kl = 1; + factorial_l = factorial_k; + + for (int k = j + 1; k < (int) this->degree; ++k) + { + factorial_kl *= k - j; + factorial_l *= k; + + if ((j + k) & 1) + interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (k + 2) * this->degree - k) = -1.0 * std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl); + + else + interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (k + 2) * this->degree - k) = std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl); + } + } + + factorial_i *= i; + factorial_j = factorial_i; + factorial_ij = 1; + + for (int j = i + 1; j <= (int) this->degree; ++j) + { + factorial_ij *= j - i; + factorial_j *= j; + + if ((i + j) & 1) + { + tmp = -1.0 * std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij); + interpolation_matrix (i + 2, j + 2) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, j + 2 * this->degree) = tmp; + factorial_k = 1; + + for (int k = 2; k <= (int) this->degree; ++k) + { + interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k); + factorial_k *= k; + factorial_l = factorial_k; + factorial_kl = 1; + + for (int l = k + 1; l <= (int) this->degree; ++l) { + factorial_kl *= l - k; + factorial_l *= l; + + if ((k + l) & 1) + interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = -1.0 * tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); + + else + interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); + } + } + + tmp *= 0.5; + interpolation_matrix (i + source_fe.degree + 1, j + 2) = tmp; + interpolation_matrix (i + source_fe.degree + 1, j + this->degree + 1) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, j + 2 * this->degree) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, j + 3 * this->degree - 1) = tmp; + tmp *= -2.0; + + for (unsigned int k = 0; k < this->degree - 1;) + { + interpolation_matrix (i + source_fe.degree + 1, (j + 2) * this->degree + k + 2 - j) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, j + (k + 4) * this->degree - k - 2) = tmp; + k = k + 2; + } + } + else + { + tmp = std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij); + interpolation_matrix (i + 2, j + 2) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, j + 2 * this->degree) = tmp; + factorial_k = 1; + + for (int k = 2; k <= (int) this->degree; ++k) + { + interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k); + factorial_k *= k; + factorial_l = factorial_k; + factorial_kl = 1; + + for (int l = k + 1; l <= (int) this->degree; ++l) + { + factorial_kl *= l - k; + factorial_l *= l; + + if ((k + l) & 1) + interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = -1.0 * tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); + + else + interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); + } + } + + tmp *= 0.5; + interpolation_matrix (i + source_fe.degree + 1, j + 2) = tmp; + interpolation_matrix (i + source_fe.degree + 1, j + this->degree + 1) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, j + 2 * this->degree) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, j + 3 * this->degree - 1) = tmp; + tmp *= -2.0; + + for (unsigned int k = 0; k < this->degree - 1;) + { + interpolation_matrix (i + source_fe.degree + 1, (j + 2) * this->degree + k + 2 - j) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, j + (k + 4) * this->degree - k - 2) = tmp; + k = k + 2; + } + } + } + } break; - } - - case 1: - { - interpolation_matrix (0, 0) = 0.5; - interpolation_matrix (0, 1) = 0.5; - interpolation_matrix (1, 1) = 1.0; - interpolation_matrix (3, 1) = 0.5; - interpolation_matrix (3, 3) = 0.5; - - for (unsigned int i = 0; i < this->degree - 1;) - { - for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_face; ++line) - interpolation_matrix (2, i + line * (this->degree - 1) + 4) = -0.5; - - for (unsigned int j = 0; j < this->degree - 1;) - { - interpolation_matrix (2, i + (j + 4) * this->degree - j) = 1.0; - j = j + 2; - } - - interpolation_matrix (0, i + 2 * (this->degree + 1)) = -1.0; - interpolation_matrix (3, i + this->degree + 3) = -1.0; - i = i + 2; - } - - for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_face; ++vertex) - interpolation_matrix (2, vertex) = 0.25; - - int factorial_i = 1; - int factorial_ij; - int factorial_j; - int factorial_k; - int factorial_kl; - int factorial_l; - - for (int i = 2; i <= (int) this->degree; ++i) - { - double tmp = std::pow (0.5, i + 1); - interpolation_matrix (i + 2, i + 2) = tmp; - interpolation_matrix (i + 2, i + this->degree + 1) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, i + 2 * this->degree) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, i + 3 * this->degree - 1) = tmp; - tmp *= -2.0; - - for (unsigned int j = 0; j < this->degree - 1;) - { - interpolation_matrix (i + 2, j + (i + 2) * this->degree + 2 - i) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, i + (j + 4) * this->degree - j - 2) = tmp; - j = j + 2; - } - - tmp *= - 1.0; - interpolation_matrix (i + source_fe.degree + 1, i + this->degree + 1) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, i + 2 * this->degree) = tmp; - factorial_i *= i; - factorial_j = factorial_i; - factorial_ij = 1; - - for (int j = i + 1; j <= (int) this->degree; ++j) - { - factorial_ij *= j - i; - factorial_j *= j; - tmp = std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij); - interpolation_matrix (i + 2 * source_fe.degree, j + 2 * this->degree) = tmp; - factorial_k = 1; - - for (int k = 2; k <= (int) this->degree; ++k) - { - interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k); - factorial_k *= k; - factorial_l = factorial_k; - factorial_kl = 1; - - for (int l = k + 1; l <= (int) this->degree; ++l) - { - factorial_kl *= l - k; - factorial_l *= l; - - if ((k + l) & 1) - interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = -1.0 * tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); - - else - interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); - } - } - - tmp *= -1.0; - - for (unsigned int k = 0; k < this->degree - 1;) - { - interpolation_matrix (i + 3 * source_fe.degree - 1, j + (k + 4) * this->degree - k - 2) = tmp; - k = k + 2; - } - - tmp *= -0.5; - interpolation_matrix (i + 3 * source_fe.degree - 1, j + 2 * this->degree) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, j + 3 * this->degree - 1) = tmp; - - if ((i + j) & 1) - tmp *= -1.0; - - interpolation_matrix (i + 2, j + 2) = tmp; - interpolation_matrix (i + 2, j + this->degree + 1) = tmp; - interpolation_matrix (i + source_fe.degree + 1, j + this->degree + 1) = 2.0 * tmp; - tmp *= -2.0; - - for (unsigned int k = 0; k < this->degree - 1;) - { - interpolation_matrix (i + 2, k + (j + 2) * this->degree + 2 - j) = tmp; - k = k + 2; - } - } - - factorial_k = 1; - - for (int j = 2; j <= (int) this->degree; ++j) - { - interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j); - factorial_k *= j; - factorial_l = factorial_k; - factorial_kl = 1; - - for (int k = j + 1; k <= (int) this->degree; ++k) - { - factorial_kl *= k - j; - factorial_l *= k; - - if ((j + k) & 1) - interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (k + 2) * this->degree - k) = -1.0 * std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl); - - else - interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (k + 2) * this->degree - k) = std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl); - } - } - } + } + + case 1: + { + interpolation_matrix (0, 0) = 0.5; + interpolation_matrix (0, 1) = 0.5; + interpolation_matrix (1, 1) = 1.0; + interpolation_matrix (3, 1) = 0.5; + interpolation_matrix (3, 3) = 0.5; + + for (unsigned int i = 0; i < this->degree - 1;) + { + for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_face; ++line) + interpolation_matrix (2, i + line * (this->degree - 1) + 4) = -0.5; + + for (unsigned int j = 0; j < this->degree - 1;) + { + interpolation_matrix (2, i + (j + 4) * this->degree - j) = 1.0; + j = j + 2; + } + + interpolation_matrix (0, i + 2 * (this->degree + 1)) = -1.0; + interpolation_matrix (3, i + this->degree + 3) = -1.0; + i = i + 2; + } + + for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_face; ++vertex) + interpolation_matrix (2, vertex) = 0.25; + + int factorial_i = 1; + int factorial_ij; + int factorial_j; + int factorial_k; + int factorial_kl; + int factorial_l; + + for (int i = 2; i <= (int) this->degree; ++i) + { + double tmp = std::pow (0.5, i + 1); + interpolation_matrix (i + 2, i + 2) = tmp; + interpolation_matrix (i + 2, i + this->degree + 1) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, i + 2 * this->degree) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, i + 3 * this->degree - 1) = tmp; + tmp *= -2.0; + + for (unsigned int j = 0; j < this->degree - 1;) + { + interpolation_matrix (i + 2, j + (i + 2) * this->degree + 2 - i) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, i + (j + 4) * this->degree - j - 2) = tmp; + j = j + 2; + } + + tmp *= - 1.0; + interpolation_matrix (i + source_fe.degree + 1, i + this->degree + 1) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, i + 2 * this->degree) = tmp; + factorial_i *= i; + factorial_j = factorial_i; + factorial_ij = 1; + + for (int j = i + 1; j <= (int) this->degree; ++j) + { + factorial_ij *= j - i; + factorial_j *= j; + tmp = std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij); + interpolation_matrix (i + 2 * source_fe.degree, j + 2 * this->degree) = tmp; + factorial_k = 1; + + for (int k = 2; k <= (int) this->degree; ++k) + { + interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k); + factorial_k *= k; + factorial_l = factorial_k; + factorial_kl = 1; + + for (int l = k + 1; l <= (int) this->degree; ++l) + { + factorial_kl *= l - k; + factorial_l *= l; + + if ((k + l) & 1) + interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = -1.0 * tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); + + else + interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); + } + } + + tmp *= -1.0; + + for (unsigned int k = 0; k < this->degree - 1;) + { + interpolation_matrix (i + 3 * source_fe.degree - 1, j + (k + 4) * this->degree - k - 2) = tmp; + k = k + 2; + } + + tmp *= -0.5; + interpolation_matrix (i + 3 * source_fe.degree - 1, j + 2 * this->degree) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, j + 3 * this->degree - 1) = tmp; + + if ((i + j) & 1) + tmp *= -1.0; + + interpolation_matrix (i + 2, j + 2) = tmp; + interpolation_matrix (i + 2, j + this->degree + 1) = tmp; + interpolation_matrix (i + source_fe.degree + 1, j + this->degree + 1) = 2.0 * tmp; + tmp *= -2.0; + + for (unsigned int k = 0; k < this->degree - 1;) + { + interpolation_matrix (i + 2, k + (j + 2) * this->degree + 2 - j) = tmp; + k = k + 2; + } + } + + factorial_k = 1; + + for (int j = 2; j <= (int) this->degree; ++j) + { + interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j); + factorial_k *= j; + factorial_l = factorial_k; + factorial_kl = 1; + + for (int k = j + 1; k <= (int) this->degree; ++k) + { + factorial_kl *= k - j; + factorial_l *= k; + + if ((j + k) & 1) + interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (k + 2) * this->degree - k) = -1.0 * std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl); + + else + interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (k + 2) * this->degree - k) = std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl); + } + } + } break; - } + } - case 2: - { + case 2: + { interpolation_matrix (0, 0) = 0.5; interpolation_matrix (0, 2) = 0.5; interpolation_matrix (2, 2) = 1.0; @@ -1136,23 +1136,23 @@ get_subface_interpolation_matrix (const FiniteElement &x_source_fe, interpolation_matrix (3, 3) = 0.5; for (unsigned int i = 0; i < this->degree - 1;) - { - for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_face; ++line) + { + for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_face; ++line) interpolation_matrix (1, i + line * (this->degree - 1) + 4) = -0.5; - for (unsigned int j = 0; j < this->degree - 1;) - { - interpolation_matrix (1, i + (j + 4) * this->degree - j) = 1.0; - j = j + 2; - } + for (unsigned int j = 0; j < this->degree - 1;) + { + interpolation_matrix (1, i + (j + 4) * this->degree - j) = 1.0; + j = j + 2; + } - interpolation_matrix (0, i + 4) = -1.0; - interpolation_matrix (3, i + 3 * this->degree + 1) = -1.0; - i = i + 2; - } + interpolation_matrix (0, i + 4) = -1.0; + interpolation_matrix (3, i + 3 * this->degree + 1) = -1.0; + i = i + 2; + } for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_face; ++vertex) - interpolation_matrix (1, vertex) = 0.25; + interpolation_matrix (1, vertex) = 0.25; int factorial_i = 1; int factorial_ij; @@ -1162,120 +1162,120 @@ get_subface_interpolation_matrix (const FiniteElement &x_source_fe, int factorial_l; for (int i = 2; i <= (int) this->degree; ++i) - { - double tmp = std::pow (0.5, i); - interpolation_matrix (i + 2, i + 2) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, i + 3 * this->degree - 1) = tmp; - tmp *= 0.5; - interpolation_matrix (i + source_fe.degree + 1, i + 2) = tmp; - interpolation_matrix (i + source_fe.degree + 1, i + this->degree + 1) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, i + 2 * this->degree) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, i + 3 * this->degree - 1) = tmp; - tmp *= -2.0; - - for (unsigned int j = 0; j < this->degree - 1;) - { - interpolation_matrix (i + source_fe.degree + 1, j + (i + 2) * this->degree + 2 - i) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, i + (j + 4) * this->degree - j - 2) = tmp; - j = j + 2; - } - - factorial_k = 1; - - for (int j = 2; j <= (int) this->degree; ++j) - { - interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j); - factorial_k *= j; - factorial_l = factorial_k; - factorial_kl = 1; - - for (int k = j + 1; k <= (int) this->degree; ++k) - { - factorial_kl *= k - j; - factorial_l *= k; - interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (k + 2) * this->degree - k) = std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl); - } - } - - factorial_i *= i; - factorial_j = factorial_i; - factorial_ij = 1; - - for (int j = i + 1; j <= (int) this->degree; ++j) - { - factorial_ij *= j - i; - factorial_j *= j; - tmp = std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij); - interpolation_matrix (i + 2, j + 2) = tmp; - tmp *= -1.0; - - for (unsigned int k = 0; k < this->degree - 1;) - { - interpolation_matrix (i + source_fe.degree + 1, k + (j + 2) * this->degree + 2 - j) = tmp; - k = k + 2; - } - - tmp *= -0.5; - interpolation_matrix (i + source_fe.degree + 1, j + 2) = tmp; - interpolation_matrix (i + source_fe.degree + 1, j + this->degree + 1) = tmp; - - if ((i + j) & 1) - tmp *= -1.0; - - interpolation_matrix (i + 2 * source_fe.degree, j + 2 * this->degree) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, j + 3 * this->degree - 1) = tmp; - tmp *= 2.0; - interpolation_matrix (i + 3 * source_fe.degree - 1, j + 3 * this->degree - 1) = tmp; - factorial_k = 1; - - for (int k = 2; k <= (int) this->degree; ++k) - { - interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k); - factorial_k *= k; - factorial_l = factorial_k; - factorial_kl = 1; - - for (int l = k + 1; l <= (int) this->degree; ++l) - { - factorial_kl *= l - k; - factorial_l *= l; - interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); - } - } - - tmp *= -1.0; - - for (unsigned int k = 0; k < this->degree - 1;) - { - interpolation_matrix (i + 2 * source_fe.degree, j + (k + 4) * this->degree - k - 2) = tmp; - k = k + 2; - } - } - } + { + double tmp = std::pow (0.5, i); + interpolation_matrix (i + 2, i + 2) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, i + 3 * this->degree - 1) = tmp; + tmp *= 0.5; + interpolation_matrix (i + source_fe.degree + 1, i + 2) = tmp; + interpolation_matrix (i + source_fe.degree + 1, i + this->degree + 1) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, i + 2 * this->degree) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, i + 3 * this->degree - 1) = tmp; + tmp *= -2.0; + + for (unsigned int j = 0; j < this->degree - 1;) + { + interpolation_matrix (i + source_fe.degree + 1, j + (i + 2) * this->degree + 2 - i) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, i + (j + 4) * this->degree - j - 2) = tmp; + j = j + 2; + } + + factorial_k = 1; + + for (int j = 2; j <= (int) this->degree; ++j) + { + interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j); + factorial_k *= j; + factorial_l = factorial_k; + factorial_kl = 1; + + for (int k = j + 1; k <= (int) this->degree; ++k) + { + factorial_kl *= k - j; + factorial_l *= k; + interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (k + 2) * this->degree - k) = std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl); + } + } + + factorial_i *= i; + factorial_j = factorial_i; + factorial_ij = 1; + + for (int j = i + 1; j <= (int) this->degree; ++j) + { + factorial_ij *= j - i; + factorial_j *= j; + tmp = std::pow (0.5, j) * factorial_j / (factorial_i * factorial_ij); + interpolation_matrix (i + 2, j + 2) = tmp; + tmp *= -1.0; + + for (unsigned int k = 0; k < this->degree - 1;) + { + interpolation_matrix (i + source_fe.degree + 1, k + (j + 2) * this->degree + 2 - j) = tmp; + k = k + 2; + } + + tmp *= -0.5; + interpolation_matrix (i + source_fe.degree + 1, j + 2) = tmp; + interpolation_matrix (i + source_fe.degree + 1, j + this->degree + 1) = tmp; + + if ((i + j) & 1) + tmp *= -1.0; + + interpolation_matrix (i + 2 * source_fe.degree, j + 2 * this->degree) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, j + 3 * this->degree - 1) = tmp; + tmp *= 2.0; + interpolation_matrix (i + 3 * source_fe.degree - 1, j + 3 * this->degree - 1) = tmp; + factorial_k = 1; + + for (int k = 2; k <= (int) this->degree; ++k) + { + interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k); + factorial_k *= k; + factorial_l = factorial_k; + factorial_kl = 1; + + for (int l = k + 1; l <= (int) this->degree; ++l) + { + factorial_kl *= l - k; + factorial_l *= l; + interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); + } + } + + tmp *= -1.0; + + for (unsigned int k = 0; k < this->degree - 1;) + { + interpolation_matrix (i + 2 * source_fe.degree, j + (k + 4) * this->degree - k - 2) = tmp; + k = k + 2; + } + } + } break; - } + } - case 3: - { + case 3: + { for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_face; ++vertex) - interpolation_matrix (0, vertex) = 0.25; + interpolation_matrix (0, vertex) = 0.25; for (unsigned int i = 0; i < this->degree - 1;) - { - for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_face; ++line) + { + for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_face; ++line) interpolation_matrix (0, i + line * (this->degree - 1) + 4) = -0.5; - for (unsigned int j = 0; j < this->degree - 1;) - { - interpolation_matrix (0, i + (j + 4) * this->degree - j) = 1.0; - j = j + 2; - } + for (unsigned int j = 0; j < this->degree - 1;) + { + interpolation_matrix (0, i + (j + 4) * this->degree - j) = 1.0; + j = j + 2; + } - interpolation_matrix (1, i + 4) = -1.0; - interpolation_matrix (2, i + 3 * this->degree + 1) = -1.0; - i = i + 2; - } + interpolation_matrix (1, i + 4) = -1.0; + interpolation_matrix (2, i + 3 * this->degree + 1) = -1.0; + i = i + 2; + } interpolation_matrix (1, 0) = 0.5; interpolation_matrix (1, 1) = 0.5; @@ -1291,86 +1291,86 @@ get_subface_interpolation_matrix (const FiniteElement &x_source_fe, int factorial_l; for (int i = 2; i <= (int) this->degree; ++i) - { - double tmp = std::pow (0.5, i + 1); - interpolation_matrix (i + 2, i + 2) = tmp; - interpolation_matrix (i + 2, i + this->degree + 1) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, i + 2 * this->degree) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, i + 3 * this->degree - 1) = tmp; - tmp *= -2.0; - - for (unsigned int j = 0; j < this->degree - 1;) - { - interpolation_matrix (i + 2, j + (i + 2) * this->degree + 2 - i) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, i + (j + 4) * this->degree - 2) = tmp; - j = j + 2; - } - - tmp *= -1.0; - interpolation_matrix (i + source_fe.degree + 1, i + this->degree + 1) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, i + 3 * this->degree - 1) = tmp; - factorial_k = 1; - - for (int j = 2; j <= (int) this->degree; ++j) - { - interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j); - factorial_k *= j; - factorial_l = factorial_k; - factorial_kl = 1; - - for (int k = j + 1; k <= (int) this->degree; ++k) - { - factorial_kl *= k - j; - factorial_l *= k; - interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (k + 2) * this->degree - k) = std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl); - } - } - - factorial_i *= i; - factorial_j = factorial_i; - factorial_ij = 1; - - for (int j = i + 1; j <= (int) this->degree; ++j) - { - factorial_ij *= j - i; - factorial_j *= j; - tmp = std::pow (0.5, j + 1) * factorial_j / (factorial_i * factorial_ij); - interpolation_matrix (i + 2, j + 2) = tmp; - interpolation_matrix (i + 2, j + this->degree + 1) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, j + 2 * this->degree) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, j + 3 * this->degree - 1) = tmp; - tmp *= 2.0; - interpolation_matrix (i + source_fe.degree + 1, j + this->degree + 1) = tmp; - interpolation_matrix (i + 3 * source_fe.degree - 1, j + 3 * this->degree - 1) = tmp; - factorial_k = 1; - - for (int k = 2; k <= (int) this->degree; ++k) - { - interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k); - factorial_k *= k; - factorial_l = factorial_k; - factorial_kl = 1; - - for (int l = k + 1; l <= (int) this->degree; ++l) - { - factorial_kl *= l - k; - factorial_l *= l; - interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); - } - } - - tmp *= -1.0; - - for (unsigned int k = 0; k < this->degree - 1;) - { - interpolation_matrix (i + 2, k + (j + 2) * this->degree + 2 - j) = tmp; - interpolation_matrix (i + 2 * source_fe.degree, j + (k + 4) * this->degree - 2) = tmp; - k = k + 2; - } - } - } - } - } + { + double tmp = std::pow (0.5, i + 1); + interpolation_matrix (i + 2, i + 2) = tmp; + interpolation_matrix (i + 2, i + this->degree + 1) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, i + 2 * this->degree) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, i + 3 * this->degree - 1) = tmp; + tmp *= -2.0; + + for (unsigned int j = 0; j < this->degree - 1;) + { + interpolation_matrix (i + 2, j + (i + 2) * this->degree + 2 - i) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, i + (j + 4) * this->degree - 2) = tmp; + j = j + 2; + } + + tmp *= -1.0; + interpolation_matrix (i + source_fe.degree + 1, i + this->degree + 1) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, i + 3 * this->degree - 1) = tmp; + factorial_k = 1; + + for (int j = 2; j <= (int) this->degree; ++j) + { + interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (j + 2) * this->degree - j) = std::pow (0.5, i + j); + factorial_k *= j; + factorial_l = factorial_k; + factorial_kl = 1; + + for (int k = j + 1; k <= (int) this->degree; ++k) + { + factorial_kl *= k - j; + factorial_l *= k; + interpolation_matrix (i + (j + 2) * source_fe.degree - j, i + (k + 2) * this->degree - k) = std::pow (0.5, i + k) * factorial_l / (factorial_k * factorial_kl); + } + } + + factorial_i *= i; + factorial_j = factorial_i; + factorial_ij = 1; + + for (int j = i + 1; j <= (int) this->degree; ++j) + { + factorial_ij *= j - i; + factorial_j *= j; + tmp = std::pow (0.5, j + 1) * factorial_j / (factorial_i * factorial_ij); + interpolation_matrix (i + 2, j + 2) = tmp; + interpolation_matrix (i + 2, j + this->degree + 1) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, j + 2 * this->degree) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, j + 3 * this->degree - 1) = tmp; + tmp *= 2.0; + interpolation_matrix (i + source_fe.degree + 1, j + this->degree + 1) = tmp; + interpolation_matrix (i + 3 * source_fe.degree - 1, j + 3 * this->degree - 1) = tmp; + factorial_k = 1; + + for (int k = 2; k <= (int) this->degree; ++k) + { + interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (k + 2) * this->degree - k) = tmp * std::pow (0.5, k); + factorial_k *= k; + factorial_l = factorial_k; + factorial_kl = 1; + + for (int l = k + 1; l <= (int) this->degree; ++l) + { + factorial_kl *= l - k; + factorial_l *= l; + interpolation_matrix (i + (k + 2) * source_fe.degree - k, j + (l + 2) * this->degree - l) = tmp * std::pow (0.5, l) * factorial_l / (factorial_k * factorial_kl); + } + } + + tmp *= -1.0; + + for (unsigned int k = 0; k < this->degree - 1;) + { + interpolation_matrix (i + 2, k + (j + 2) * this->degree + 2 - j) = tmp; + interpolation_matrix (i + 2 * source_fe.degree, j + (k + 4) * this->degree - 2) = tmp; + k = k + 2; + } + } + } + } + } } } } @@ -1382,7 +1382,7 @@ void FE_Q_Hierarchical::initialize_unit_face_support_points () { const unsigned int codim = dim-1; - // number of points: (degree+1)^codim + // number of points: (degree+1)^codim unsigned int n = this->degree+1; for (unsigned int i=1; idegree+1; @@ -1395,37 +1395,37 @@ void FE_Q_Hierarchical::initialize_unit_face_support_points () for (unsigned int iz=0; iz <= ((codim>2) ? this->degree : 0) ; ++iz) for (unsigned int iy=0; iy <= ((codim>1) ? this->degree : 0) ; ++iy) for (unsigned int ix=0; ix<=this->degree; ++ix) - { - if (ix==0) - p(0) = 0.; - else if (ix==1) - p(0) = 1.; - else - p(0) = .5; - if (codim>1) - { - if (iy==0) - p(1) = 0.; - else if (iy==1) - p(1) = 1.; - else - p(1) = .5; - } - if (codim>2) - { - if (iz==0) - p(2) = 0.; - else if (iz==1) - p(2) = 1.; - else - p(2) = .5; - } - this->unit_face_support_points[face_renumber[k++]] = p; - }; + { + if (ix==0) + p(0) = 0.; + else if (ix==1) + p(0) = 1.; + else + p(0) = .5; + if (codim>1) + { + if (iy==0) + p(1) = 0.; + else if (iy==1) + p(1) = 1.; + else + p(1) = .5; + } + if (codim>2) + { + if (iz==0) + p(2) = 0.; + else if (iz==1) + p(2) = 1.; + else + p(2) = .5; + } + this->unit_face_support_points[face_renumber[k++]] = p; + }; } - // we use same dpo_vector as FE_Q + // we use same dpo_vector as FE_Q template std::vector FE_Q_Hierarchical::get_dpo_vector(const unsigned int deg) @@ -1446,167 +1446,167 @@ hierarchic_to_fe_q_hierarchical_numbering (const FiniteElementData &fe) Assert (fe.n_components() == 1, ExcInternalError()); std::vector h2l(fe.dofs_per_cell); - // polynomial degree + // polynomial degree const unsigned int degree = fe.dofs_per_line+1; - // number of grid points in each - // direction + // number of grid points in each + // direction const unsigned int n = degree+1; - // the following lines of code are - // somewhat odd, due to the way the - // hierarchic numbering is - // organized. if someone would - // really want to understand these - // lines, you better draw some - // pictures where you indicate the - // indices and orders of vertices, - // lines, etc, along with the - // numbers of the degrees of - // freedom in hierarchical and - // lexicographical order + // the following lines of code are + // somewhat odd, due to the way the + // hierarchic numbering is + // organized. if someone would + // really want to understand these + // lines, you better draw some + // pictures where you indicate the + // indices and orders of vertices, + // lines, etc, along with the + // numbers of the degrees of + // freedom in hierarchical and + // lexicographical order switch (dim) { case 1: { - for (unsigned int i=0; i fe_data(FE_Q_Hierarchical::get_dpo_vector(degree),1,degree); return invert_numbering(FE_Q_Hierarchical:: - hierarchic_to_fe_q_hierarchical_numbering (fe_data)); + hierarchic_to_fe_q_hierarchical_numbering (fe_data)); } @@ -1659,12 +1659,12 @@ FE_Q_Hierarchical<1>::has_support_on_face (const unsigned int shape_index, template bool FE_Q_Hierarchical::has_support_on_face (const unsigned int shape_index, - const unsigned int face_index) const + const unsigned int face_index) const { Assert (shape_index < this->dofs_per_cell, - ExcIndexRange (shape_index, 0, this->dofs_per_cell)); + ExcIndexRange (shape_index, 0, this->dofs_per_cell)); Assert (face_index < GeometryInfo::faces_per_cell, - ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); // first, special-case interior // shape functions, since they @@ -1675,64 +1675,64 @@ FE_Q_Hierarchical::has_support_on_face (const unsigned int shape_index, ((dim==3) && (shape_index>=this->first_hex_index))) return false; - // let's see whether this is a - // vertex + // let's see whether this is a + // vertex if (shape_index < this->first_line_index) { - // for Q elements, there is - // one dof per vertex, so - // shape_index==vertex_number. check - // whether this vertex is - // on the given face. + // for Q elements, there is + // one dof per vertex, so + // shape_index==vertex_number. check + // whether this vertex is + // on the given face. const unsigned int vertex_no = shape_index; Assert (vertex_no < GeometryInfo::vertices_per_cell, - ExcInternalError()); + ExcInternalError()); for (unsigned int i=0; i::vertices_per_face; ++i) - if (GeometryInfo::face_to_cell_vertices(face_index,i) == vertex_no) - return true; + if (GeometryInfo::face_to_cell_vertices(face_index,i) == vertex_no) + return true; return false; } else if (shape_index < this->first_quad_index) - // ok, dof is on a line + // ok, dof is on a line { const unsigned int line_index - = (shape_index - this->first_line_index) / this->dofs_per_line; + = (shape_index - this->first_line_index) / this->dofs_per_line; Assert (line_index < GeometryInfo::lines_per_cell, - ExcInternalError()); + ExcInternalError()); for (unsigned int i=0; i::lines_per_face; ++i) - if (GeometryInfo::face_to_cell_lines(face_index,i) == line_index) - return true; + if (GeometryInfo::face_to_cell_lines(face_index,i) == line_index) + return true; return false; } else if (shape_index < this->first_hex_index) - // dof is on a quad + // dof is on a quad { const unsigned int quad_index - = (shape_index - this->first_quad_index) / this->dofs_per_quad; + = (shape_index - this->first_quad_index) / this->dofs_per_quad; Assert (static_cast(quad_index) < - static_cast(GeometryInfo::quads_per_cell), - ExcInternalError()); + static_cast(GeometryInfo::quads_per_cell), + ExcInternalError()); - // in 2d, cell bubble are - // zero on all faces. but - // we have treated this - // case above already + // in 2d, cell bubble are + // zero on all faces. but + // we have treated this + // case above already Assert (dim != 2, ExcInternalError()); - // in 3d, - // quad_index=face_index + // in 3d, + // quad_index=face_index if (dim == 3) - return (quad_index == face_index); + return (quad_index == face_index); else - Assert (false, ExcNotImplemented()); + Assert (false, ExcNotImplemented()); } else - // dof on hex + // dof on hex { - // can only happen in 3d, but - // this case has already been - // covered above + // can only happen in 3d, but + // this case has already been + // covered above Assert (false, ExcNotImplemented()); return false; } @@ -1749,13 +1749,13 @@ std::vector FE_Q_Hierarchical::get_embedding_dofs (const unsigned int sub_degree) const { Assert ((sub_degree>0) && (sub_degree<=this->degree), - ExcIndexRange(sub_degree, 1, this->degree)); + ExcIndexRange(sub_degree, 1, this->degree)); if (dim==1) { std::vector embedding_dofs (sub_degree+1); for (unsigned int i=0; i<(sub_degree+1); ++i) - embedding_dofs[i] = i; + embedding_dofs[i] = i; return embedding_dofs; } @@ -1764,7 +1764,7 @@ FE_Q_Hierarchical::get_embedding_dofs (const unsigned int sub_degree) const { std::vector embedding_dofs (GeometryInfo::vertices_per_cell); for (unsigned int i=0; i::vertices_per_cell; ++i) - embedding_dofs[i] = i; + embedding_dofs[i] = i; return embedding_dofs; } @@ -1772,7 +1772,7 @@ FE_Q_Hierarchical::get_embedding_dofs (const unsigned int sub_degree) const { std::vector embedding_dofs (this->dofs_per_cell); for (unsigned int i=0; idofs_per_cell; ++i) - embedding_dofs[i] = i; + embedding_dofs[i] = i; return embedding_dofs; } @@ -1780,66 +1780,66 @@ FE_Q_Hierarchical::get_embedding_dofs (const unsigned int sub_degree) const if ((dim==2) || (dim==3)) { std::vector embedding_dofs ( (dim==2) ? - (sub_degree+1) * (sub_degree+1) : - (sub_degree+1) * (sub_degree+1) * (sub_degree+1) ); + (sub_degree+1) * (sub_degree+1) : + (sub_degree+1) * (sub_degree+1) * (sub_degree+1) ); for (unsigned int i=0; i<( (dim==2) ? - (sub_degree+1) * (sub_degree+1) : - (sub_degree+1) * (sub_degree+1) * (sub_degree+1) ); ++i) - { - // vertex - if (i::vertices_per_cell) - embedding_dofs[i] = i; - // line - else if (i<(GeometryInfo::vertices_per_cell + - GeometryInfo::lines_per_cell * (sub_degree-1))) - { - const unsigned int j = (i - GeometryInfo::vertices_per_cell) % - (sub_degree-1); - const unsigned int line = (i - GeometryInfo::vertices_per_cell - j) / (sub_degree-1); - - embedding_dofs[i] = GeometryInfo::vertices_per_cell + - line * (this->degree-1) + j; - } - // quad - else if (i<(GeometryInfo::vertices_per_cell + - GeometryInfo::lines_per_cell * (sub_degree-1)) + - GeometryInfo::quads_per_cell * (sub_degree-1) * (sub_degree-1)) - { - const unsigned int j = (i - GeometryInfo::vertices_per_cell - - GeometryInfo::lines_per_cell * (sub_degree-1)) % (sub_degree-1); - const unsigned int k = ( (i - GeometryInfo::vertices_per_cell - - GeometryInfo::lines_per_cell * (sub_degree-1) - j) / (sub_degree-1) ) % (sub_degree-1); - const unsigned int face = (i - GeometryInfo::vertices_per_cell - - GeometryInfo::lines_per_cell * (sub_degree-1) - k * (sub_degree-1) - j) / ( (sub_degree-1) * (sub_degree-1) ); - - embedding_dofs[i] = GeometryInfo::vertices_per_cell + - GeometryInfo::lines_per_cell * (this->degree-1) + - face * (this->degree-1) * (this->degree-1) + - k * (this->degree-1) + j; - } - // hex - else if (i<(GeometryInfo::vertices_per_cell + - GeometryInfo::lines_per_cell * (sub_degree-1)) + - GeometryInfo::quads_per_cell * (sub_degree-1) * (sub_degree-1) + - GeometryInfo::hexes_per_cell * (sub_degree-1) * (sub_degree-1) * (sub_degree-1)) - { - const unsigned int j = (i - GeometryInfo::vertices_per_cell - - GeometryInfo::lines_per_cell * (sub_degree-1) - - GeometryInfo::quads_per_cell * (sub_degree-1) * (sub_degree-1) ) % (sub_degree-1); - const unsigned int k = ( (i - GeometryInfo::vertices_per_cell - - GeometryInfo::lines_per_cell * (sub_degree-1) - - GeometryInfo::quads_per_cell * (sub_degree-1) * (sub_degree-1) - j) / (sub_degree-1) ) % (sub_degree-1); - const unsigned int l = (i - GeometryInfo::vertices_per_cell - - GeometryInfo::lines_per_cell * (sub_degree-1) - - GeometryInfo::quads_per_cell * (sub_degree-1) * (sub_degree-1) - j - k * (sub_degree-1)) / ( (sub_degree-1) * (sub_degree-1) ); - - embedding_dofs[i] = GeometryInfo::vertices_per_cell + - GeometryInfo::lines_per_cell * (this->degree-1) + - GeometryInfo::quads_per_cell * (this->degree-1) * (this->degree-1) + - l * (this->degree-1) * (this->degree-1) + k * (this->degree-1) + j; - } - } + (sub_degree+1) * (sub_degree+1) : + (sub_degree+1) * (sub_degree+1) * (sub_degree+1) ); ++i) + { + // vertex + if (i::vertices_per_cell) + embedding_dofs[i] = i; + // line + else if (i<(GeometryInfo::vertices_per_cell + + GeometryInfo::lines_per_cell * (sub_degree-1))) + { + const unsigned int j = (i - GeometryInfo::vertices_per_cell) % + (sub_degree-1); + const unsigned int line = (i - GeometryInfo::vertices_per_cell - j) / (sub_degree-1); + + embedding_dofs[i] = GeometryInfo::vertices_per_cell + + line * (this->degree-1) + j; + } + // quad + else if (i<(GeometryInfo::vertices_per_cell + + GeometryInfo::lines_per_cell * (sub_degree-1)) + + GeometryInfo::quads_per_cell * (sub_degree-1) * (sub_degree-1)) + { + const unsigned int j = (i - GeometryInfo::vertices_per_cell - + GeometryInfo::lines_per_cell * (sub_degree-1)) % (sub_degree-1); + const unsigned int k = ( (i - GeometryInfo::vertices_per_cell - + GeometryInfo::lines_per_cell * (sub_degree-1) - j) / (sub_degree-1) ) % (sub_degree-1); + const unsigned int face = (i - GeometryInfo::vertices_per_cell - + GeometryInfo::lines_per_cell * (sub_degree-1) - k * (sub_degree-1) - j) / ( (sub_degree-1) * (sub_degree-1) ); + + embedding_dofs[i] = GeometryInfo::vertices_per_cell + + GeometryInfo::lines_per_cell * (this->degree-1) + + face * (this->degree-1) * (this->degree-1) + + k * (this->degree-1) + j; + } + // hex + else if (i<(GeometryInfo::vertices_per_cell + + GeometryInfo::lines_per_cell * (sub_degree-1)) + + GeometryInfo::quads_per_cell * (sub_degree-1) * (sub_degree-1) + + GeometryInfo::hexes_per_cell * (sub_degree-1) * (sub_degree-1) * (sub_degree-1)) + { + const unsigned int j = (i - GeometryInfo::vertices_per_cell - + GeometryInfo::lines_per_cell * (sub_degree-1) - + GeometryInfo::quads_per_cell * (sub_degree-1) * (sub_degree-1) ) % (sub_degree-1); + const unsigned int k = ( (i - GeometryInfo::vertices_per_cell - + GeometryInfo::lines_per_cell * (sub_degree-1) - + GeometryInfo::quads_per_cell * (sub_degree-1) * (sub_degree-1) - j) / (sub_degree-1) ) % (sub_degree-1); + const unsigned int l = (i - GeometryInfo::vertices_per_cell - + GeometryInfo::lines_per_cell * (sub_degree-1) - + GeometryInfo::quads_per_cell * (sub_degree-1) * (sub_degree-1) - j - k * (sub_degree-1)) / ( (sub_degree-1) * (sub_degree-1) ); + + embedding_dofs[i] = GeometryInfo::vertices_per_cell + + GeometryInfo::lines_per_cell * (this->degree-1) + + GeometryInfo::quads_per_cell * (this->degree-1) * (this->degree-1) + + l * (this->degree-1) * (this->degree-1) + k * (this->degree-1) + j; + } + } return embedding_dofs; } diff --git a/deal.II/source/fe/fe_raviart_thomas.cc b/deal.II/source/fe/fe_raviart_thomas.cc index 310d13cded..543a2ca0a8 100644 --- a/deal.II/source/fe/fe_raviart_thomas.cc +++ b/deal.II/source/fe/fe_raviart_thomas.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -38,66 +38,66 @@ DEAL_II_NAMESPACE_OPEN template FE_RaviartThomas::FE_RaviartThomas (const unsigned int deg) - : - FE_PolyTensor, dim> ( - deg, - FiniteElementData(get_dpo_vector(deg), - dim, deg+1, FiniteElementData::Hdiv, 1), - std::vector(PolynomialsRaviartThomas::compute_n_pols(deg), true), - std::vector >(PolynomialsRaviartThomas::compute_n_pols(deg), - std::vector(dim,true))) + : + FE_PolyTensor, dim> ( + deg, + FiniteElementData(get_dpo_vector(deg), + dim, deg+1, FiniteElementData::Hdiv, 1), + std::vector(PolynomialsRaviartThomas::compute_n_pols(deg), true), + std::vector >(PolynomialsRaviartThomas::compute_n_pols(deg), + std::vector(dim,true))) { Assert (dim >= 2, ExcImpossibleInDim(dim)); const unsigned int n_dofs = this->dofs_per_cell; this->mapping_type = mapping_raviart_thomas; - // First, initialize the - // generalized support points and - // quadrature weights, since they - // are required for interpolation. + // First, initialize the + // generalized support points and + // quadrature weights, since they + // are required for interpolation. initialize_support_points(deg); - // Now compute the inverse node - //matrix, generating the correct - //basis functions from the raw - //ones. - - // We use an auxiliary matrix in - // this function. Therefore, - // inverse_node_matrix is still - // empty and shape_value_component - // returns the 'raw' shape values. + // Now compute the inverse node + //matrix, generating the correct + //basis functions from the raw + //ones. + + // We use an auxiliary matrix in + // this function. Therefore, + // inverse_node_matrix is still + // empty and shape_value_component + // returns the 'raw' shape values. FullMatrix M(n_dofs, n_dofs); FETools::compute_node_matrix(M, *this); this->inverse_node_matrix.reinit(n_dofs, n_dofs); this->inverse_node_matrix.invert(M); - // From now on, the shape functions - // will be the correct ones, not - // the raw shape functions anymore. - - // Reinit the vectors of - // restriction and prolongation - // matrices to the right sizes. - // Restriction only for isotropic - // refinement + // From now on, the shape functions + // will be the correct ones, not + // the raw shape functions anymore. + + // Reinit the vectors of + // restriction and prolongation + // matrices to the right sizes. + // Restriction only for isotropic + // refinement this->reinit_restriction_and_prolongation_matrices(true); - // Fill prolongation matrices with embedding operators + // Fill prolongation matrices with embedding operators FETools::compute_embedding_matrices (*this, this->prolongation); initialize_restriction(); - // TODO[TL]: for anisotropic refinement we will probably need a table of submatrices with an array for each refine case + // TODO[TL]: for anisotropic refinement we will probably need a table of submatrices with an array for each refine case FullMatrix face_embeddings[GeometryInfo::max_children_per_face]; for (unsigned int i=0; i::max_children_per_face; ++i) face_embeddings[i].reinit (this->dofs_per_face, this->dofs_per_face); FETools::compute_face_embedding_matrices(*this, face_embeddings, 0, 0); this->interface_constraints.reinit((1<<(dim-1)) * this->dofs_per_face, - this->dofs_per_face); + this->dofs_per_face); unsigned int target_row=0; for (unsigned int d=0;d::max_children_per_face;++d) for (unsigned int i=0;iinterface_constraints(target_row,j) = face_embeddings[d](i,j); - ++target_row; + for (unsigned int j=0;jinterface_constraints(target_row,j) = face_embeddings[d](i,j); + ++target_row; } } @@ -107,17 +107,17 @@ template std::string FE_RaviartThomas::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch - - // note that this->degree is the maximal - // polynomial degree and is thus one higher - // than the argument given to the - // constructor + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch + + // note that this->degree is the maximal + // polynomial degree and is thus one higher + // than the argument given to the + // constructor std::ostringstream namebuf; namebuf << "FE_RaviartThomas<" << dim << ">(" << this->degree-1 << ")"; @@ -147,63 +147,63 @@ FE_RaviartThomas::initialize_support_points (const unsigned int deg) = (deg>0) ? cell_quadrature.size() : 0; unsigned int n_face_points = (dim>1) ? 1 : 0; - // compute (deg+1)^(dim-1) + // compute (deg+1)^(dim-1) for (unsigned int d=1;dgeneralized_support_points.resize (GeometryInfo::faces_per_cell*n_face_points - + n_interior_points); + + n_interior_points); this->generalized_face_support_points.resize (n_face_points); - // Number of the point being entered + // Number of the point being entered unsigned int current = 0; if (dim>1) { QGauss face_points (deg+1); TensorProductPolynomials legendre - = Polynomials::Legendre::generate_complete_basis(deg); + = Polynomials::Legendre::generate_complete_basis(deg); boundary_weights.reinit(n_face_points, legendre.n()); // Assert (face_points.size() == this->dofs_per_face, -// ExcInternalError()); +// ExcInternalError()); for (unsigned int k=0;kgeneralized_face_support_points[k] = face_points.point(k); - // Compute its quadrature - // contribution for each - // moment. - for (unsigned int i=0;igeneralized_face_support_points[k] = face_points.point(k); + // Compute its quadrature + // contribution for each + // moment. + for (unsigned int i=0;i faces = QProjector::project_to_all_faces(face_points); for (;current::faces_per_cell*n_face_points; - ++current) - { - // Enter the support point - // into the vector - this->generalized_support_points[current] = faces.point(current+QProjector::DataSetDescriptor::face(0,true,false,false,n_face_points)); - } + ++current) + { + // Enter the support point + // into the vector + this->generalized_support_points[current] = faces.point(current+QProjector::DataSetDescriptor::face(0,true,false,false,n_face_points)); + } } if (deg==0) return; - // Create Legendre basis for the - // space D_xi Q_k + // Create Legendre basis for the + // space D_xi Q_k std::vector* > polynomials(dim); for (unsigned int dd=0;dd > > poly(dim); for (unsigned int d=0;d(poly); @@ -215,16 +215,16 @@ FE_RaviartThomas::initialize_support_points (const unsigned int deg) { this->generalized_support_points[current++] = cell_quadrature.point(k); for (unsigned int i=0;in();++i) - for (unsigned int d=0;dcompute_value(i,cell_quadrature.point(k)); + for (unsigned int d=0;dcompute_value(i,cell_quadrature.point(k)); } for (unsigned int d=0;dgeneralized_support_points.size(), - ExcInternalError()); + ExcInternalError()); } @@ -233,9 +233,9 @@ template <> void FE_RaviartThomas<1>::initialize_restriction() { - // there is only one refinement case in 1d, - // which is the isotropic one (first index of - // the matrix array has to be 0) + // there is only one refinement case in 1d, + // which is the isotropic one (first index of + // the matrix array has to be 0) for (unsigned int i=0;i::max_children_per_cell;++i) this->restriction[0][i].reinit(0,0); } @@ -260,81 +260,81 @@ FE_RaviartThomas::initialize_restriction() QGauss q_base (this->degree); const unsigned int n_face_points = q_base.size(); - // First, compute interpolation on - // subfaces + // First, compute interpolation on + // subfaces for (unsigned int face=0;face::faces_per_cell;++face) { - // The shape functions of the - // child cell are evaluated - // in the quadrature points - // of a full face. + // The shape functions of the + // child cell are evaluated + // in the quadrature points + // of a full face. Quadrature q_face - = QProjector::project_to_face(q_base, face); - // Store shape values, since the - // evaluation suffers if not - // ordered by point + = QProjector::project_to_face(q_base, face); + // Store shape values, since the + // evaluation suffers if not + // ordered by point Table<2,double> cached_values(this->dofs_per_cell, q_face.size()); for (unsigned int k=0;kdofs_per_cell; ++i) - cached_values(i,k) - = this->shape_value_component(i, q_face.point(k), - GeometryInfo::unit_normal_direction[face]); + for (unsigned int i = 0; i < this->dofs_per_cell; ++i) + cached_values(i,k) + = this->shape_value_component(i, q_face.point(k), + GeometryInfo::unit_normal_direction[face]); for (unsigned int sub=0;sub::max_children_per_face;++sub) - { - // The weight fuctions for - // the coarse face are - // evaluated on the subface - // only. - Quadrature q_sub - = QProjector::project_to_subface(q_base, face, sub); - const unsigned int child - = GeometryInfo::child_cell_on_face( - RefinementCase::isotropic_refinement, face, sub); - - // On a certain face, we must - // compute the moments of ALL - // fine level functions with - // the coarse level weight - // functions belonging to - // that face. Due to the - // orthogonalization process - // when building the shape - // functions, these weights - // are equal to the - // corresponding shape - // functions. - for (unsigned int k=0;kdofs_per_cell; ++i_child) - for (unsigned int i_face = 0; i_face < this->dofs_per_face; ++i_face) - { - // The quadrature - // weights on the - // subcell are NOT - // transformed, so we - // have to do it here. - this->restriction[iso][child](face*this->dofs_per_face+i_face, - i_child) - += Utilities::fixed_power(.5) * q_sub.weight(k) - * cached_values(i_child, k) - * this->shape_value_component(face*this->dofs_per_face+i_face, - q_sub.point(k), - GeometryInfo::unit_normal_direction[face]); - } - } + { + // The weight fuctions for + // the coarse face are + // evaluated on the subface + // only. + Quadrature q_sub + = QProjector::project_to_subface(q_base, face, sub); + const unsigned int child + = GeometryInfo::child_cell_on_face( + RefinementCase::isotropic_refinement, face, sub); + + // On a certain face, we must + // compute the moments of ALL + // fine level functions with + // the coarse level weight + // functions belonging to + // that face. Due to the + // orthogonalization process + // when building the shape + // functions, these weights + // are equal to the + // corresponding shape + // functions. + for (unsigned int k=0;kdofs_per_cell; ++i_child) + for (unsigned int i_face = 0; i_face < this->dofs_per_face; ++i_face) + { + // The quadrature + // weights on the + // subcell are NOT + // transformed, so we + // have to do it here. + this->restriction[iso][child](face*this->dofs_per_face+i_face, + i_child) + += Utilities::fixed_power(.5) * q_sub.weight(k) + * cached_values(i_child, k) + * this->shape_value_component(face*this->dofs_per_face+i_face, + q_sub.point(k), + GeometryInfo::unit_normal_direction[face]); + } + } } if (this->degree == 1) return; - // Create Legendre basis for the - // space D_xi Q_k. Here, we cannot - // use the shape functions + // Create Legendre basis for the + // space D_xi Q_k. Here, we cannot + // use the shape functions std::vector* > polynomials(dim); for (unsigned int dd=0;dd > > poly(dim); for (unsigned int d=0;ddegree-1); + poly[d] = Polynomials::Legendre::generate_complete_basis(this->degree-1); poly[dd] = Polynomials::Legendre::generate_complete_basis(this->degree-2); polynomials[dd] = new AnisotropicPolynomials(poly); @@ -344,30 +344,30 @@ FE_RaviartThomas::initialize_restriction() const unsigned int start_cell_dofs = GeometryInfo::faces_per_cell*this->dofs_per_face; - // Store shape values, since the - // evaluation suffers if not - // ordered by point + // Store shape values, since the + // evaluation suffers if not + // ordered by point Table<3,double> cached_values(this->dofs_per_cell, q_cell.size(), dim); for (unsigned int k=0;kdofs_per_cell; ++i) for (unsigned int d=0;dshape_value_component(i, q_cell.point(k), d); + cached_values(i,k,d) = this->shape_value_component(i, q_cell.point(k), d); for (unsigned int child=0;child::max_children_per_cell;++child) { Quadrature q_sub = QProjector::project_to_child(q_cell, child); for (unsigned int k=0;kdofs_per_cell; ++i_child) - for (unsigned int d=0;dn();++i_weight) - { - this->restriction[iso][child](start_cell_dofs+i_weight*dim+d, - i_child) - += q_sub.weight(k) - * cached_values(i_child, k, d) - * polynomials[d]->compute_value(i_weight, q_sub.point(k)); - } + for (unsigned int i_child = 0; i_child < this->dofs_per_cell; ++i_child) + for (unsigned int d=0;dn();++i_weight) + { + this->restriction[iso][child](start_cell_dofs+i_weight*dim+d, + i_child) + += q_sub.weight(k) + * cached_values(i_child, k, d) + * polynomials[d]->compute_value(i_weight, q_sub.point(k)); + } } for (unsigned int d=0;d::has_support_on_face ( const unsigned int face_index) const { Assert (shape_index < this->dofs_per_cell, - ExcIndexRange (shape_index, 0, this->dofs_per_cell)); + ExcIndexRange (shape_index, 0, this->dofs_per_cell)); Assert (face_index < GeometryInfo::faces_per_cell, - ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); - // Return computed values if we - // know them easily. Otherwise, it - // is always safe to return true. + // Return computed values if we + // know them easily. Otherwise, it + // is always safe to return true. switch (this->degree) { case 1: @@ -435,12 +435,12 @@ FE_RaviartThomas::has_support_on_face ( } default: - return true; + return true; }; }; default: // other rt_order - return true; + return true; }; return true; @@ -467,11 +467,11 @@ FE_RaviartThomas::interpolate( unsigned int offset) const { Assert (values.size() == this->generalized_support_points.size(), - ExcDimensionMismatch(values.size(), this->generalized_support_points.size())); + ExcDimensionMismatch(values.size(), this->generalized_support_points.size())); Assert (local_dofs.size() == this->dofs_per_cell, - ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); + ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); Assert (values[0].size() >= offset+this->n_components(), - ExcDimensionMismatch(values[0].size(),offset+this->n_components())); + ExcDimensionMismatch(values[0].size(),offset+this->n_components())); std::fill(local_dofs.begin(), local_dofs.end(), 0.); @@ -480,8 +480,8 @@ FE_RaviartThomas::interpolate( for (unsigned int k=0;kdofs_per_face] += boundary_weights(k,i) - * values[face*n_face_points+k](GeometryInfo::unit_normal_direction[face]+offset); + local_dofs[i+face*this->dofs_per_face] += boundary_weights(k,i) + * values[face*n_face_points+k](GeometryInfo::unit_normal_direction[face]+offset); } const unsigned start_cell_dofs = GeometryInfo::faces_per_cell*this->dofs_per_face; @@ -490,7 +490,7 @@ FE_RaviartThomas::interpolate( for (unsigned int k=0;k::interpolate( const VectorSlice > >& values) const { Assert (values.size() == this->n_components(), - ExcDimensionMismatch(values.size(), this->n_components())); + ExcDimensionMismatch(values.size(), this->n_components())); Assert (values[0].size() == this->generalized_support_points.size(), - ExcDimensionMismatch(values[0].size(), this->generalized_support_points.size())); + ExcDimensionMismatch(values[0].size(), this->generalized_support_points.size())); Assert (local_dofs.size() == this->dofs_per_cell, - ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); + ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); std::fill(local_dofs.begin(), local_dofs.end(), 0.); @@ -514,8 +514,8 @@ FE_RaviartThomas::interpolate( for (unsigned int k=0;kdofs_per_face] += boundary_weights(k,i) - * values[GeometryInfo::unit_normal_direction[face]][face*n_face_points+k]; + local_dofs[i+face*this->dofs_per_face] += boundary_weights(k,i) + * values[GeometryInfo::unit_normal_direction[face]][face*n_face_points+k]; } const unsigned start_cell_dofs = GeometryInfo::faces_per_cell*this->dofs_per_face; @@ -524,7 +524,7 @@ FE_RaviartThomas::interpolate( for (unsigned int k=0;k FE_RaviartThomasNodal::FE_RaviartThomasNodal (const unsigned int deg) - : - FE_PolyTensor, dim> ( - deg, - FiniteElementData(get_dpo_vector(deg), - dim, deg+1, FiniteElementData::Hdiv, 1), - get_ria_vector (deg), - std::vector >(PolynomialsRaviartThomas::compute_n_pols(deg), - std::vector(dim,true))) + : + FE_PolyTensor, dim> ( + deg, + FiniteElementData(get_dpo_vector(deg), + dim, deg+1, FiniteElementData::Hdiv, 1), + get_ria_vector (deg), + std::vector >(PolynomialsRaviartThomas::compute_n_pols(deg), + std::vector(dim,true))) { Assert (dim >= 2, ExcImpossibleInDim(dim)); const unsigned int n_dofs = this->dofs_per_cell; this->mapping_type = mapping_raviart_thomas; - // First, initialize the - // generalized support points and - // quadrature weights, since they - // are required for interpolation. + // First, initialize the + // generalized support points and + // quadrature weights, since they + // are required for interpolation. initialize_support_points(deg); - // Now compute the inverse node - //matrix, generating the correct - //basis functions from the raw - //ones. - - // We use an auxiliary matrix in - // this function. Therefore, - // inverse_node_matrix is still - // empty and shape_value_component - // returns the 'raw' shape values. + // Now compute the inverse node + //matrix, generating the correct + //basis functions from the raw + //ones. + + // We use an auxiliary matrix in + // this function. Therefore, + // inverse_node_matrix is still + // empty and shape_value_component + // returns the 'raw' shape values. FullMatrix M(n_dofs, n_dofs); FETools::compute_node_matrix(M, *this); this->inverse_node_matrix.reinit(n_dofs, n_dofs); this->inverse_node_matrix.invert(M); - // From now on, the shape functions - // will be the correct ones, not - // the raw shape functions anymore. - - // Reinit the vectors of - // prolongation matrices to the - // right sizes. There are no - // restriction matrices implemented + // From now on, the shape functions + // will be the correct ones, not + // the raw shape functions anymore. + + // Reinit the vectors of + // prolongation matrices to the + // right sizes. There are no + // restriction matrices implemented for (unsigned int ref_case=RefinementCase::cut_x; ref_case::isotropic_refinement+1; ++ref_case) { const unsigned int nc = GeometryInfo::n_children(RefinementCase(ref_case)); for (unsigned int i=0;iprolongation[ref_case-1][i].reinit (n_dofs, n_dofs); + this->prolongation[ref_case-1][i].reinit (n_dofs, n_dofs); } - // Fill prolongation matrices with embedding operators + // Fill prolongation matrices with embedding operators FETools::compute_embedding_matrices (*this, this->prolongation); - // TODO[TL]: for anisotropic refinement we will probably need a table of submatrices with an array for each refine case + // TODO[TL]: for anisotropic refinement we will probably need a table of submatrices with an array for each refine case FullMatrix face_embeddings[GeometryInfo::max_children_per_face]; for (unsigned int i=0; i::max_children_per_face; ++i) face_embeddings[i].reinit (this->dofs_per_face, this->dofs_per_face); FETools::compute_face_embedding_matrices(*this, face_embeddings, 0, 0); this->interface_constraints.reinit((1<<(dim-1)) * this->dofs_per_face, - this->dofs_per_face); + this->dofs_per_face); unsigned int target_row=0; for (unsigned int d=0;d::max_children_per_face;++d) for (unsigned int i=0;iinterface_constraints(target_row,j) = face_embeddings[d](i,j); - ++target_row; + for (unsigned int j=0;jinterface_constraints(target_row,j) = face_embeddings[d](i,j); + ++target_row; } } @@ -104,17 +104,17 @@ template std::string FE_RaviartThomasNodal::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch - - // note that this->degree is the maximal - // polynomial degree and is thus one higher - // than the argument given to the - // constructor + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch + + // note that this->degree is the maximal + // polynomial degree and is thus one higher + // than the argument given to the + // constructor std::ostringstream namebuf; namebuf << "FE_RaviartThomasNodal<" << dim << ">(" << this->degree-1 << ")"; @@ -143,40 +143,40 @@ FE_RaviartThomasNodal::initialize_support_points (const unsigned int deg) this->generalized_support_points.resize (this->dofs_per_cell); this->generalized_face_support_points.resize (this->dofs_per_face); - // Number of the point being entered + // Number of the point being entered unsigned int current = 0; - // On the faces, we choose as many - // Gauss points as necessary to - // determine the normal component - // uniquely. This is the deg of - // the Raviart-Thomas element plus - // one. + // On the faces, we choose as many + // Gauss points as necessary to + // determine the normal component + // uniquely. This is the deg of + // the Raviart-Thomas element plus + // one. if (dim>1) { QGauss face_points (deg+1); Assert (face_points.size() == this->dofs_per_face, - ExcInternalError()); + ExcInternalError()); for (unsigned int k=0;kdofs_per_face;++k) - this->generalized_face_support_points[k] = face_points.point(k); + this->generalized_face_support_points[k] = face_points.point(k); Quadrature faces = QProjector::project_to_all_faces(face_points); for (unsigned int k=0; - kdofs_per_face*GeometryInfo::faces_per_cell; - ++k) - this->generalized_support_points[k] = faces.point(k+QProjector - ::DataSetDescriptor::face(0, - true, - false, - false, - this->dofs_per_face)); + kdofs_per_face*GeometryInfo::faces_per_cell; + ++k) + this->generalized_support_points[k] = faces.point(k+QProjector + ::DataSetDescriptor::face(0, + true, + false, + false, + this->dofs_per_face)); current = this->dofs_per_face*GeometryInfo::faces_per_cell; } if (deg==0) return; - // In the interior, we need - // anisotropic Gauss quadratures, - // different for each direction. + // In the interior, we need + // anisotropic Gauss quadratures, + // different for each direction. QGauss<1> high(deg+1); QGauss<1> low(deg); @@ -185,14 +185,14 @@ FE_RaviartThomasNodal::initialize_support_points (const unsigned int deg) QAnisotropic* quadrature; if (dim == 1) quadrature = new QAnisotropic(high); if (dim == 2) quadrature = new QAnisotropic(((d==0) ? low : high), - ((d==1) ? low : high)); + ((d==1) ? low : high)); if (dim == 3) quadrature = new QAnisotropic(((d==0) ? low : high), - ((d==1) ? low : high), - ((d==2) ? low : high)); + ((d==1) ? low : high), + ((d==2) ? low : high)); Assert(dim<=3, ExcNotImplemented()); for (unsigned int k=0;ksize();++k) - this->generalized_support_points[current++] = quadrature->point(k); + this->generalized_support_points[current++] = quadrature->point(k); delete quadrature; } Assert (current == this->dofs_per_cell, ExcInternalError()); @@ -241,11 +241,11 @@ FE_RaviartThomasNodal::get_ria_vector (const unsigned int deg) unsigned int dofs_per_face = deg+1; for (unsigned int d=2;d ret_val(dofs_per_cell,false); for (unsigned int i=GeometryInfo::faces_per_cell*dofs_per_face; i < dofs_per_cell; ++i) @@ -262,24 +262,24 @@ FE_RaviartThomasNodal::has_support_on_face ( const unsigned int face_index) const { Assert (shape_index < this->dofs_per_cell, - ExcIndexRange (shape_index, 0, this->dofs_per_cell)); + ExcIndexRange (shape_index, 0, this->dofs_per_cell)); Assert (face_index < GeometryInfo::faces_per_cell, - ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange (face_index, 0, GeometryInfo::faces_per_cell)); - // The first degrees of freedom are - // on the faces and each face has - // degree degrees. + // The first degrees of freedom are + // on the faces and each face has + // degree degrees. const unsigned int support_face = shape_index / this->degree; - // The only thing we know for sure - // is that shape functions with - // support on one face are zero on - // the opposite face. + // The only thing we know for sure + // is that shape functions with + // support on one face are zero on + // the opposite face. if (support_face < GeometryInfo::faces_per_cell) return (face_index != GeometryInfo::opposite_face[support_face]); - // In all other cases, return true, - // which is safe + // In all other cases, return true, + // which is safe return true; } @@ -302,29 +302,29 @@ FE_RaviartThomasNodal::interpolate( unsigned int offset) const { Assert (values.size() == this->generalized_support_points.size(), - ExcDimensionMismatch(values.size(), this->generalized_support_points.size())); + ExcDimensionMismatch(values.size(), this->generalized_support_points.size())); Assert (local_dofs.size() == this->dofs_per_cell, - ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); + ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); Assert (values[0].size() >= offset+this->n_components(), - ExcDimensionMismatch(values[0].size(),offset+this->n_components())); + ExcDimensionMismatch(values[0].size(),offset+this->n_components())); - // First do interpolation on - // faces. There, the component - // evaluated depends on the face - // direction and orientation. + // First do interpolation on + // faces. There, the component + // evaluated depends on the face + // direction and orientation. unsigned int fbase = 0; unsigned int f=0; for (;f::faces_per_cell; ++f, fbase+=this->dofs_per_face) { for (unsigned int i=0;idofs_per_face;++i) - { - local_dofs[fbase+i] = values[fbase+i](offset+GeometryInfo::unit_normal_direction[f]); - } + { + local_dofs[fbase+i] = values[fbase+i](offset+GeometryInfo::unit_normal_direction[f]); + } } - // The remaining points form dim - // chunks, one for each component. + // The remaining points form dim + // chunks, one for each component. const unsigned int istep = (this->dofs_per_cell - fbase) / dim; Assert ((this->dofs_per_cell - fbase) % dim == 0, ExcInternalError()); @@ -332,9 +332,9 @@ FE_RaviartThomasNodal::interpolate( while (fbase < this->dofs_per_cell) { for (unsigned int i=0;i::interpolate( const VectorSlice > >& values) const { Assert (values.size() == this->n_components(), - ExcDimensionMismatch(values.size(), this->n_components())); + ExcDimensionMismatch(values.size(), this->n_components())); Assert (values[0].size() == this->generalized_support_points.size(), - ExcDimensionMismatch(values.size(), this->generalized_support_points.size())); + ExcDimensionMismatch(values.size(), this->generalized_support_points.size())); Assert (local_dofs.size() == this->dofs_per_cell, - ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); - // First do interpolation on - // faces. There, the component - // evaluated depends on the face - // direction and orientation. + ExcDimensionMismatch(local_dofs.size(),this->dofs_per_cell)); + // First do interpolation on + // faces. There, the component + // evaluated depends on the face + // direction and orientation. unsigned int fbase = 0; unsigned int f=0; for (;f::faces_per_cell; ++f, fbase+=this->dofs_per_face) { for (unsigned int i=0;idofs_per_face;++i) - { - local_dofs[fbase+i] = values[GeometryInfo::unit_normal_direction[f]][fbase+i]; - } + { + local_dofs[fbase+i] = values[GeometryInfo::unit_normal_direction[f]][fbase+i]; + } } - // The remaining points form dim - // chunks, one for each component. + // The remaining points form dim + // chunks, one for each component. const unsigned int istep = (this->dofs_per_cell - fbase) / dim; Assert ((this->dofs_per_cell - fbase) % dim == 0, ExcInternalError()); @@ -377,9 +377,9 @@ FE_RaviartThomasNodal::interpolate( while (fbase < this->dofs_per_cell) { for (unsigned int i=0;i > FE_RaviartThomasNodal::hp_vertex_dof_identities ( const FiniteElement &fe_other) const { - // we can presently only compute these - // identities if both FEs are - // FE_RaviartThomasNodals. in that case, no - // dofs are assigned on the vertex, so we - // shouldn't be getting here at all. + // we can presently only compute these + // identities if both FEs are + // FE_RaviartThomasNodals. in that case, no + // dofs are assigned on the vertex, so we + // shouldn't be getting here at all. if (dynamic_cast*>(&fe_other)!=0) return std::vector > (); else @@ -423,48 +423,48 @@ std::vector > FE_RaviartThomasNodal:: hp_line_dof_identities (const FiniteElement &fe_other) const { - // we can presently only compute - // these identities if both FEs are - // FE_RaviartThomasNodals + // we can presently only compute + // these identities if both FEs are + // FE_RaviartThomasNodals if (const FE_RaviartThomasNodal *fe_q_other = dynamic_cast*>(&fe_other)) { - // dofs are located on faces; these are - // only lines in 2d + // dofs are located on faces; these are + // only lines in 2d if (dim != 2) - return std::vector >(); - - // dofs are located along lines, so two - // dofs are identical only if in the - // following two cases (remember that - // the face support points are Gauss - // points): - //1. this->degree = fe_q_other->degree, - // in the case, all the dofs on - // the line are identical - //2. this->degree-1 and fe_q_other->degree-1 - // are both even, i.e. this->dof_per_line - // and fe_q_other->dof_per_line are both odd, - // there exists only one point (the middle one) - // such that dofs are identical on this point - // - // to understand this, note that - // this->degree is the *maximal* - // polynomial degree, and is thus one - // higher than the argument given to - // the constructor + return std::vector >(); + + // dofs are located along lines, so two + // dofs are identical only if in the + // following two cases (remember that + // the face support points are Gauss + // points): + //1. this->degree = fe_q_other->degree, + // in the case, all the dofs on + // the line are identical + //2. this->degree-1 and fe_q_other->degree-1 + // are both even, i.e. this->dof_per_line + // and fe_q_other->dof_per_line are both odd, + // there exists only one point (the middle one) + // such that dofs are identical on this point + // + // to understand this, note that + // this->degree is the *maximal* + // polynomial degree, and is thus one + // higher than the argument given to + // the constructor const unsigned int p = this->degree-1; const unsigned int q = fe_q_other->degree-1; std::vector > identities; if (p==q) - for (unsigned int i=0; i > FE_RaviartThomasNodal::hp_quad_dof_identities ( const FiniteElement& fe_other) const { - // we can presently only compute - // these identities if both FEs are - // FE_RaviartThomasNodals + // we can presently only compute + // these identities if both FEs are + // FE_RaviartThomasNodals if (const FE_RaviartThomasNodal *fe_q_other = dynamic_cast*>(&fe_other)) { - // dofs are located on faces; these are - // only quads in 3d + // dofs are located on faces; these are + // only quads in 3d if (dim != 3) - return std::vector >(); + return std::vector >(); - // this works exactly like the line - // case above + // this works exactly like the line + // case above const unsigned int p = this->dofs_per_quad; const unsigned int q = fe_q_other->dofs_per_quad; std::vector > identities; if (p==q) - for (unsigned int i=0; i::compare_for_face_domination ( = dynamic_cast*>(&fe_other)) { if (this->degree < fe_q_other->degree) - return FiniteElementDomination::this_element_dominates; + return FiniteElementDomination::this_element_dominates; else if (this->degree == fe_q_other->degree) - return FiniteElementDomination::either_element_can_dominate; + return FiniteElementDomination::either_element_can_dominate; else - return FiniteElementDomination::other_element_dominates; + return FiniteElementDomination::other_element_dominates; } Assert (false, ExcNotImplemented()); @@ -567,60 +567,60 @@ FE_RaviartThomasNodal::get_face_interpolation_matrix ( const FiniteElement &x_source_fe, FullMatrix &interpolation_matrix) const { - // this is only implemented, if the - // source FE is also a - // RaviartThomasNodal element + // this is only implemented, if the + // source FE is also a + // RaviartThomasNodal element AssertThrow ((x_source_fe.get_name().find ("FE_RaviartThomasNodal<") == 0) - || - (dynamic_cast*>(&x_source_fe) != 0), - typename FiniteElement:: - ExcInterpolationNotImplemented()); + || + (dynamic_cast*>(&x_source_fe) != 0), + typename FiniteElement:: + ExcInterpolationNotImplemented()); Assert (interpolation_matrix.n() == this->dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.n(), - this->dofs_per_face)); + ExcDimensionMismatch (interpolation_matrix.n(), + this->dofs_per_face)); Assert (interpolation_matrix.m() == x_source_fe.dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.m(), - x_source_fe.dofs_per_face)); + ExcDimensionMismatch (interpolation_matrix.m(), + x_source_fe.dofs_per_face)); - // ok, source is a RaviartThomasNodal element, so - // we will be able to do the work + // ok, source is a RaviartThomasNodal element, so + // we will be able to do the work const FE_RaviartThomasNodal &source_fe = dynamic_cast&>(x_source_fe); - // Make sure, that the element, - // for which the DoFs should be - // constrained is the one with - // the higher polynomial degree. - // Actually the procedure will work - // also if this assertion is not - // satisfied. But the matrices - // produced in that case might - // lead to problems in the - // hp procedures, which use this - // method. + // Make sure, that the element, + // for which the DoFs should be + // constrained is the one with + // the higher polynomial degree. + // Actually the procedure will work + // also if this assertion is not + // satisfied. But the matrices + // produced in that case might + // lead to problems in the + // hp procedures, which use this + // method. Assert (this->dofs_per_face <= source_fe.dofs_per_face, - typename FiniteElement:: - ExcInterpolationNotImplemented ()); - - // generate a quadrature - // with the generalized support points. - // This is later based as a - // basis for the QProjector, - // which returns the support - // points on the face. + typename FiniteElement:: + ExcInterpolationNotImplemented ()); + + // generate a quadrature + // with the generalized support points. + // This is later based as a + // basis for the QProjector, + // which returns the support + // points on the face. Quadrature quad_face_support (source_fe.get_generalized_face_support_points ()); - // Rule of thumb for FP accuracy, - // that can be expected for a - // given polynomial degree. - // This value is used to cut - // off values close to zero. + // Rule of thumb for FP accuracy, + // that can be expected for a + // given polynomial degree. + // This value is used to cut + // off values close to zero. double eps = 2e-13*this->degree*(dim-1); - // compute the interpolation - // matrix by simply taking the - // value at the support points. + // compute the interpolation + // matrix by simply taking the + // value at the support points. const Quadrature face_projection = QProjector::project_to_face (quad_face_support, 0); @@ -629,40 +629,40 @@ FE_RaviartThomasNodal::get_face_interpolation_matrix ( const Point &p = face_projection.point (i); for (unsigned int j=0; jdofs_per_face; ++j) - { - double matrix_entry - = this->shape_value_component (this->face_to_cell_index(j, 0), - p, 0); - - // Correct the interpolated - // value. I.e. if it is close - // to 1 or 0, make it exactly - // 1 or 0. Unfortunately, this - // is required to avoid problems - // with higher order elements. - if ( std::fabs(matrix_entry - 1.0) < eps ) - matrix_entry = 1.0; - if ( std::fabs(matrix_entry) < eps ) - matrix_entry = 0.0; - - interpolation_matrix(i,j) = matrix_entry; - } + { + double matrix_entry + = this->shape_value_component (this->face_to_cell_index(j, 0), + p, 0); + + // Correct the interpolated + // value. I.e. if it is close + // to 1 or 0, make it exactly + // 1 or 0. Unfortunately, this + // is required to avoid problems + // with higher order elements. + if ( std::fabs(matrix_entry - 1.0) < eps ) + matrix_entry = 1.0; + if ( std::fabs(matrix_entry) < eps ) + matrix_entry = 0.0; + + interpolation_matrix(i,j) = matrix_entry; + } } - // make sure that the row sum of - // each of the matrices is 1 at - // this point. this must be so - // since the shape functions sum up - // to 1 + // make sure that the row sum of + // each of the matrices is 1 at + // this point. this must be so + // since the shape functions sum up + // to 1 for (unsigned int j=0; jdofs_per_face; ++i) - sum += interpolation_matrix(j,i); + sum += interpolation_matrix(j,i); Assert (std::fabs(sum-1) < 2e-13*this->degree*(dim-1), - ExcInternalError()); + ExcInternalError()); } } @@ -674,60 +674,60 @@ FE_RaviartThomasNodal::get_subface_interpolation_matrix ( const unsigned int subface, FullMatrix &interpolation_matrix) const { - // this is only implemented, if the - // source FE is also a - // RaviartThomasNodal element + // this is only implemented, if the + // source FE is also a + // RaviartThomasNodal element AssertThrow ((x_source_fe.get_name().find ("FE_RaviartThomasNodal<") == 0) - || - (dynamic_cast*>(&x_source_fe) != 0), - typename FiniteElement:: - ExcInterpolationNotImplemented()); + || + (dynamic_cast*>(&x_source_fe) != 0), + typename FiniteElement:: + ExcInterpolationNotImplemented()); Assert (interpolation_matrix.n() == this->dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.n(), - this->dofs_per_face)); + ExcDimensionMismatch (interpolation_matrix.n(), + this->dofs_per_face)); Assert (interpolation_matrix.m() == x_source_fe.dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.m(), - x_source_fe.dofs_per_face)); + ExcDimensionMismatch (interpolation_matrix.m(), + x_source_fe.dofs_per_face)); - // ok, source is a RaviartThomasNodal element, so - // we will be able to do the work + // ok, source is a RaviartThomasNodal element, so + // we will be able to do the work const FE_RaviartThomasNodal &source_fe = dynamic_cast&>(x_source_fe); - // Make sure, that the element, - // for which the DoFs should be - // constrained is the one with - // the higher polynomial degree. - // Actually the procedure will work - // also if this assertion is not - // satisfied. But the matrices - // produced in that case might - // lead to problems in the - // hp procedures, which use this - // method. + // Make sure, that the element, + // for which the DoFs should be + // constrained is the one with + // the higher polynomial degree. + // Actually the procedure will work + // also if this assertion is not + // satisfied. But the matrices + // produced in that case might + // lead to problems in the + // hp procedures, which use this + // method. Assert (this->dofs_per_face <= source_fe.dofs_per_face, - typename FiniteElement:: - ExcInterpolationNotImplemented ()); - - // generate a quadrature - // with the generalized support points. - // This is later based as a - // basis for the QProjector, - // which returns the support - // points on the face. + typename FiniteElement:: + ExcInterpolationNotImplemented ()); + + // generate a quadrature + // with the generalized support points. + // This is later based as a + // basis for the QProjector, + // which returns the support + // points on the face. Quadrature quad_face_support (source_fe.get_generalized_face_support_points ()); - // Rule of thumb for FP accuracy, - // that can be expected for a - // given polynomial degree. - // This value is used to cut - // off values close to zero. + // Rule of thumb for FP accuracy, + // that can be expected for a + // given polynomial degree. + // This value is used to cut + // off values close to zero. double eps = 2e-13*this->degree*(dim-1); - // compute the interpolation - // matrix by simply taking the - // value at the support points. + // compute the interpolation + // matrix by simply taking the + // value at the support points. const Quadrature subface_projection = QProjector::project_to_subface (quad_face_support, 0, subface); @@ -737,39 +737,39 @@ FE_RaviartThomasNodal::get_subface_interpolation_matrix ( const Point &p = subface_projection.point (i); for (unsigned int j=0; jdofs_per_face; ++j) - { - double matrix_entry - = this->shape_value_component (this->face_to_cell_index(j, 0), p, 0); - - // Correct the interpolated - // value. I.e. if it is close - // to 1 or 0, make it exactly - // 1 or 0. Unfortunately, this - // is required to avoid problems - // with higher order elements. - if ( std::fabs(matrix_entry - 1.0) < eps ) - matrix_entry = 1.0; - if ( std::fabs(matrix_entry) < eps ) - matrix_entry = 0.0; - - interpolation_matrix(i,j) = matrix_entry; - } + { + double matrix_entry + = this->shape_value_component (this->face_to_cell_index(j, 0), p, 0); + + // Correct the interpolated + // value. I.e. if it is close + // to 1 or 0, make it exactly + // 1 or 0. Unfortunately, this + // is required to avoid problems + // with higher order elements. + if ( std::fabs(matrix_entry - 1.0) < eps ) + matrix_entry = 1.0; + if ( std::fabs(matrix_entry) < eps ) + matrix_entry = 0.0; + + interpolation_matrix(i,j) = matrix_entry; + } } - // make sure that the row sum of - // each of the matrices is 1 at - // this point. this must be so - // since the shape functions sum up - // to 1 + // make sure that the row sum of + // each of the matrices is 1 at + // this point. this must be so + // since the shape functions sum up + // to 1 for (unsigned int j=0; jdofs_per_face; ++i) - sum += interpolation_matrix(j,i); + sum += interpolation_matrix(j,i); Assert (std::fabs(sum-1) < 2e-13*this->degree*(dim-1), - ExcInternalError()); + ExcInternalError()); } } diff --git a/deal.II/source/fe/fe_system.cc b/deal.II/source/fe/fe_system.cc index 74d0e00615..9fee64915c 100644 --- a/deal.II/source/fe/fe_system.cc +++ b/deal.II/source/fe/fe_system.cc @@ -32,8 +32,8 @@ DEAL_II_NAMESPACE_OPEN template FESystem::InternalData::InternalData(const unsigned int n_base_elements): - base_fe_datas(n_base_elements), - base_fe_values_datas(n_base_elements) + base_fe_datas(n_base_elements), + base_fe_values_datas(n_base_elements) {} @@ -41,20 +41,20 @@ FESystem::InternalData::InternalData(const unsigned int n_base_ele template FESystem::InternalData::~InternalData() { - // delete pointers and set them to - // zero to avoid inadvertant use + // delete pointers and set them to + // zero to avoid inadvertant use for (unsigned int i=0; i:: InternalData::get_fe_data (const unsigned int base_no) const { Assert(base_no void FESystem:: InternalData::set_fe_data (const unsigned int base_no, - typename FiniteElement::InternalDataBase *ptr) + typename FiniteElement::InternalDataBase *ptr) { Assert(base_no:: InternalData::get_fe_values_data (const unsigned int base_no) const { Assert(base_no void FESystem:: InternalData::set_fe_values_data (const unsigned int base_no, - FEValuesData *ptr) + FEValuesData *ptr) { Assert(base_no:: InternalData::delete_fe_values_data (const unsigned int base_no) { Assert(base_no::invalid_face_number; template FESystem::FESystem (const FiniteElement &fe, - const unsigned int n_elements) : - FiniteElement (multiply_dof_numbers(fe, n_elements), - compute_restriction_is_additive_flags (fe, n_elements), - compute_nonzero_components(fe, n_elements)), + const unsigned int n_elements) : + FiniteElement (multiply_dof_numbers(fe, n_elements), + compute_restriction_is_additive_flags (fe, n_elements), + compute_nonzero_components(fe, n_elements)), base_elements(1) { this->base_to_block_indices.reinit(0, 0); @@ -165,14 +165,14 @@ FESystem::FESystem (const FiniteElement &fe, template FESystem::FESystem (const FiniteElement &fe1, - const unsigned int n1, - const FiniteElement &fe2, - const unsigned int n2) : - FiniteElement (multiply_dof_numbers(fe1, n1, fe2, n2), - compute_restriction_is_additive_flags (fe1, n1, - fe2, n2), - compute_nonzero_components(fe1, n1, - fe2, n2)), + const unsigned int n1, + const FiniteElement &fe2, + const unsigned int n2) : + FiniteElement (multiply_dof_numbers(fe1, n1, fe2, n2), + compute_restriction_is_additive_flags (fe1, n1, + fe2, n2), + compute_nonzero_components(fe1, n1, + fe2, n2)), base_elements(2) { this->base_to_block_indices.reinit(0, 0); @@ -189,20 +189,20 @@ FESystem::FESystem (const FiniteElement &fe1, template FESystem::FESystem (const FiniteElement &fe1, - const unsigned int n1, - const FiniteElement &fe2, - const unsigned int n2, - const FiniteElement &fe3, - const unsigned int n3) : + const unsigned int n1, + const FiniteElement &fe2, + const unsigned int n2, + const FiniteElement &fe3, + const unsigned int n3) : FiniteElement (multiply_dof_numbers(fe1, n1, - fe2, n2, - fe3, n3), - compute_restriction_is_additive_flags (fe1, n1, - fe2, n2, - fe3, n3), - compute_nonzero_components(fe1, n1, - fe2, n2, - fe3, n3)), + fe2, n2, + fe3, n3), + compute_restriction_is_additive_flags (fe1, n1, + fe2, n2, + fe3, n3), + compute_nonzero_components(fe1, n1, + fe2, n2, + fe3, n3)), base_elements(3) { this->base_to_block_indices.reinit(0, 0); @@ -221,25 +221,25 @@ FESystem::FESystem (const FiniteElement &fe1, template FESystem::FESystem (const FiniteElement &fe1, - const unsigned int n1, - const FiniteElement &fe2, - const unsigned int n2, - const FiniteElement &fe3, - const unsigned int n3, - const FiniteElement &fe4, - const unsigned int n4) : + const unsigned int n1, + const FiniteElement &fe2, + const unsigned int n2, + const FiniteElement &fe3, + const unsigned int n3, + const FiniteElement &fe4, + const unsigned int n4) : FiniteElement (multiply_dof_numbers(fe1, n1, - fe2, n2, - fe3, n3, - fe4, n4), - compute_restriction_is_additive_flags (fe1, n1, - fe2, n2, - fe3, n3, - fe4, n4), - compute_nonzero_components(fe1, n1, - fe2, n2, - fe3, n3, - fe4 ,n4)), + fe2, n2, + fe3, n3, + fe4, n4), + compute_restriction_is_additive_flags (fe1, n1, + fe2, n2, + fe3, n3, + fe4, n4), + compute_nonzero_components(fe1, n1, + fe2, n2, + fe3, n3, + fe4 ,n4)), base_elements(4) { this->base_to_block_indices.reinit(0, 0); @@ -260,30 +260,30 @@ FESystem::FESystem (const FiniteElement &fe1, template FESystem::FESystem (const FiniteElement &fe1, - const unsigned int n1, - const FiniteElement &fe2, - const unsigned int n2, - const FiniteElement &fe3, - const unsigned int n3, - const FiniteElement &fe4, - const unsigned int n4, - const FiniteElement &fe5, - const unsigned int n5) : + const unsigned int n1, + const FiniteElement &fe2, + const unsigned int n2, + const FiniteElement &fe3, + const unsigned int n3, + const FiniteElement &fe4, + const unsigned int n4, + const FiniteElement &fe5, + const unsigned int n5) : FiniteElement (multiply_dof_numbers(fe1, n1, - fe2, n2, - fe3, n3, - fe4, n4, - fe5, n5), - compute_restriction_is_additive_flags (fe1, n1, - fe2, n2, - fe3, n3, - fe4, n4, - fe5, n5), - compute_nonzero_components(fe1, n1, - fe2, n2, - fe3, n3, - fe4 ,n4, - fe5, n5)), + fe2, n2, + fe3, n3, + fe4, n4, + fe5, n5), + compute_restriction_is_additive_flags (fe1, n1, + fe2, n2, + fe3, n3, + fe4, n4, + fe5, n5), + compute_nonzero_components(fe1, n1, + fe2, n2, + fe3, n3, + fe4 ,n4, + fe5, n5)), base_elements(5) { this->base_to_block_indices.reinit(0, 0); @@ -312,16 +312,16 @@ template FESystem::FESystem ( const std::vector*> &fes, const std::vector &multiplicities) - : - FiniteElement (multiply_dof_numbers(fes, multiplicities), - compute_restriction_is_additive_flags (fes, multiplicities), - compute_nonzero_components(fes, multiplicities)), - base_elements(fes.size()) + : + FiniteElement (multiply_dof_numbers(fes, multiplicities), + compute_restriction_is_additive_flags (fes, multiplicities), + compute_nonzero_components(fes, multiplicities)), + base_elements(fes.size()) { Assert (fes.size() == multiplicities.size(), - ExcDimensionMismatch (fes.size(), multiplicities.size()) ); + ExcDimensionMismatch (fes.size(), multiplicities.size()) ); Assert (fes.size() > 0, - ExcMessage ("Need to pass at least one finite element.")); + ExcMessage ("Need to pass at least one finite element.")); this->base_to_block_indices.reinit(0, 0); @@ -341,8 +341,8 @@ FESystem::FESystem ( template FESystem::~FESystem () { - // delete base elements created in - // the constructor + // delete base elements created in + // the constructor for (unsigned i=0; iunsubscribe(typeid(*this).name()); @@ -357,12 +357,12 @@ template std::string FESystem::get_name () const { - // note that the - // FETools::get_fe_from_name - // function depends on the - // particular format of the string - // this function returns, so they - // have to be kept in synch + // note that the + // FETools::get_fe_from_name + // function depends on the + // particular format of the string + // this function returns, so they + // have to be kept in synch std::ostringstream namebuf; @@ -371,9 +371,9 @@ FESystem::get_name () const { namebuf << base_element(i).get_name(); if (this->element_multiplicity(i) != 1) - namebuf << '^' << this->element_multiplicity(i); + namebuf << '^' << this->element_multiplicity(i); if (i != this->n_base_elements()-1) - namebuf << '-'; + namebuf << '-'; } namebuf << ']'; @@ -390,41 +390,41 @@ FESystem::clone() const { case 1: return new FESystem(base_element(0), - this->element_multiplicity(0)); + this->element_multiplicity(0)); case 2: return new FESystem(base_element(0), - this->element_multiplicity(0), - base_element(1), - this->element_multiplicity(1)); + this->element_multiplicity(0), + base_element(1), + this->element_multiplicity(1)); case 3: return new FESystem(base_element(0), - this->element_multiplicity(0), - base_element(1), - this->element_multiplicity(1), - base_element(2), - this->element_multiplicity(2)); + this->element_multiplicity(0), + base_element(1), + this->element_multiplicity(1), + base_element(2), + this->element_multiplicity(2)); case 4: return new FESystem(base_element(0), - this->element_multiplicity(0), - base_element(1), - this->element_multiplicity(1), - base_element(2), - this->element_multiplicity(2), - base_element(3), - this->element_multiplicity(3)); + this->element_multiplicity(0), + base_element(1), + this->element_multiplicity(1), + base_element(2), + this->element_multiplicity(2), + base_element(3), + this->element_multiplicity(3)); case 5: return new FESystem(base_element(0), - this->element_multiplicity(0), - base_element(1), - this->element_multiplicity(1), - base_element(2), - this->element_multiplicity(2), - base_element(3), - this->element_multiplicity(3), - base_element(4), - this->element_multiplicity(4)); + this->element_multiplicity(0), + base_element(1), + this->element_multiplicity(1), + base_element(2), + this->element_multiplicity(2), + base_element(3), + this->element_multiplicity(3), + base_element(4), + this->element_multiplicity(4)); default: - Assert(false, ExcNotImplemented()); + Assert(false, ExcNotImplemented()); } return 0; } @@ -434,14 +434,14 @@ FESystem::clone() const template double FESystem::shape_value (const unsigned int i, - const Point &p) const + const Point &p) const { Assert (idofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell)); Assert (this->is_primitive(i), - (typename FiniteElement::ExcShapeFunctionNotPrimitive(i))); + (typename FiniteElement::ExcShapeFunctionNotPrimitive(i))); return (base_element(this->system_to_base_table[i].first.first) - .shape_value(this->system_to_base_table[i].second, p)); + .shape_value(this->system_to_base_table[i].second, p)); } @@ -449,12 +449,12 @@ FESystem::shape_value (const unsigned int i, template double FESystem::shape_value_component (const unsigned int i, - const Point &p, - const unsigned int component) const + const Point &p, + const unsigned int component) const { Assert (idofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell)); Assert (component < this->n_components(), - ExcIndexRange (component, 0, this->n_components())); + ExcIndexRange (component, 0, this->n_components())); // if this value is supposed to be // zero, then return right away... @@ -462,23 +462,23 @@ FESystem::shape_value_component (const unsigned int i, return 0; // ...otherwise: first find out to - // which of the base elements this - // desired component belongs, and - // which component within this base - // element it is + // which of the base elements this + // desired component belongs, and + // which component within this base + // element it is const unsigned int base = this->component_to_base_index(component).first; const unsigned int component_in_base = this->component_to_base_index(component).second; - // then get value from base - // element. note that that will - // throw an error should the - // respective shape function not be - // primitive; thus, there is no - // need to check this here + // then get value from base + // element. note that that will + // throw an error should the + // respective shape function not be + // primitive; thus, there is no + // need to check this here return (base_element(base). - shape_value_component(this->system_to_base_table[i].second, - p, - component_in_base)); + shape_value_component(this->system_to_base_table[i].second, + p, + component_in_base)); } @@ -486,14 +486,14 @@ FESystem::shape_value_component (const unsigned int i, template Tensor<1,dim> FESystem::shape_grad (const unsigned int i, - const Point &p) const + const Point &p) const { Assert (idofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell)); Assert (this->is_primitive(i), - (typename FiniteElement::ExcShapeFunctionNotPrimitive(i))); + (typename FiniteElement::ExcShapeFunctionNotPrimitive(i))); return (base_element(this->system_to_base_table[i].first.first) - .shape_grad(this->system_to_base_table[i].second, p)); + .shape_grad(this->system_to_base_table[i].second, p)); } @@ -501,12 +501,12 @@ FESystem::shape_grad (const unsigned int i, template Tensor<1,dim> FESystem::shape_grad_component (const unsigned int i, - const Point &p, - const unsigned int component) const + const Point &p, + const unsigned int component) const { Assert (idofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell)); Assert (component < this->n_components(), - ExcIndexRange (component, 0, this->n_components())); + ExcIndexRange (component, 0, this->n_components())); // if this value is supposed to be // zero, then return right away... @@ -514,23 +514,23 @@ FESystem::shape_grad_component (const unsigned int i, return Tensor<1,dim>(); // ...otherwise: first find out to - // which of the base elements this - // desired component belongs, and - // which component within this base - // element it is + // which of the base elements this + // desired component belongs, and + // which component within this base + // element it is const unsigned int base = this->component_to_base_index(component).first; const unsigned int component_in_base = this->component_to_base_index(component).second; - // then get value from base - // element. note that that will - // throw an error should the - // respective shape function not be - // primitive; thus, there is no - // need to check this here + // then get value from base + // element. note that that will + // throw an error should the + // respective shape function not be + // primitive; thus, there is no + // need to check this here return (base_element(base). - shape_grad_component(this->system_to_base_table[i].second, - p, - component_in_base)); + shape_grad_component(this->system_to_base_table[i].second, + p, + component_in_base)); } @@ -538,14 +538,14 @@ FESystem::shape_grad_component (const unsigned int i, template Tensor<2,dim> FESystem::shape_grad_grad (const unsigned int i, - const Point &p) const + const Point &p) const { Assert (idofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell)); Assert (this->is_primitive(i), - (typename FiniteElement::ExcShapeFunctionNotPrimitive(i))); + (typename FiniteElement::ExcShapeFunctionNotPrimitive(i))); return (base_element(this->system_to_base_table[i].first.first) - .shape_grad_grad(this->system_to_base_table[i].second, p)); + .shape_grad_grad(this->system_to_base_table[i].second, p)); } @@ -553,12 +553,12 @@ FESystem::shape_grad_grad (const unsigned int i, template Tensor<2,dim> FESystem::shape_grad_grad_component (const unsigned int i, - const Point &p, - const unsigned int component) const + const Point &p, + const unsigned int component) const { Assert (idofs_per_cell, ExcIndexRange(i, 0, this->dofs_per_cell)); Assert (component < this->n_components(), - ExcIndexRange (component, 0, this->n_components())); + ExcIndexRange (component, 0, this->n_components())); // if this value is supposed to be // zero, then return right away... @@ -566,23 +566,23 @@ FESystem::shape_grad_grad_component (const unsigned int i, return Tensor<2,dim>(); // ...otherwise: first find out to - // which of the base elements this - // desired component belongs, and - // which component within this base - // element it is + // which of the base elements this + // desired component belongs, and + // which component within this base + // element it is const unsigned int base = this->component_to_base_index(component).first; const unsigned int component_in_base = this->component_to_base_index(component).second; - // then get value from base - // element. note that that will - // throw an error should the - // respective shape function not be - // primitive; thus, there is no - // need to check this here + // then get value from base + // element. note that that will + // throw an error should the + // respective shape function not be + // primitive; thus, there is no + // need to check this here return (base_element(base). - shape_grad_grad_component(this->system_to_base_table[i].second, - p, - component_in_base)); + shape_grad_grad_component(this->system_to_base_table[i].second, + p, + component_in_base)); } @@ -594,11 +594,11 @@ FESystem::get_interpolation_matrix ( FullMatrix &interpolation_matrix) const { Assert (interpolation_matrix.m() == this->dofs_per_cell, - ExcDimensionMismatch (interpolation_matrix.m(), - this->dofs_per_cell)); + ExcDimensionMismatch (interpolation_matrix.m(), + this->dofs_per_cell)); Assert (interpolation_matrix.n() == x_source_fe.dofs_per_cell, - ExcDimensionMismatch (interpolation_matrix.m(), - x_source_fe.dofs_per_cell)); + ExcDimensionMismatch (interpolation_matrix.m(), + x_source_fe.dofs_per_cell)); // there are certain conditions // that the two elements have to @@ -614,8 +614,8 @@ FESystem::get_interpolation_matrix ( typename FEL:: ExcInterpolationNotImplemented()); - // ok, source is a system element, - // so we may be able to do the work + // ok, source is a system element, + // so we may be able to do the work const FESystem &source_fe = dynamic_cast&>(x_source_fe); @@ -684,8 +684,8 @@ UpdateFlags FESystem::update_once (const UpdateFlags flags) const { UpdateFlags out = update_default; - // generate maximal set of flags - // that are necessary + // generate maximal set of flags + // that are necessary for (unsigned int base_no=0; base_non_base_elements(); ++base_no) out |= base_element(base_no).update_once(flags); return out; @@ -698,20 +698,20 @@ UpdateFlags FESystem::update_each (const UpdateFlags flags) const { UpdateFlags out = update_default; - // generate maximal set of flags - // that are necessary + // generate maximal set of flags + // that are necessary for (unsigned int base_no=0; base_non_base_elements(); ++base_no) out |= base_element(base_no).update_each(flags); - // second derivatives are handled - // by the top-level finite element, - // rather than by the base elements - // since it is generated by finite - // differencing. if second - // derivatives are requested, we - // therefore have to set the - // respective flag since the base - // elements don't have them + // second derivatives are handled + // by the top-level finite element, + // rather than by the base elements + // since it is generated by finite + // differencing. if second + // derivatives are requested, we + // therefore have to set the + // respective flag since the base + // elements don't have them if (flags & update_hessians) out |= update_hessians | update_covariant_transformation; @@ -723,8 +723,8 @@ FESystem::update_each (const UpdateFlags flags) const template typename Mapping::InternalDataBase * FESystem::get_data (const UpdateFlags flags_, - const Mapping &mapping, - const Quadrature &quadrature) const + const Mapping &mapping, + const Quadrature &quadrature) const { UpdateFlags flags = flags_; InternalData* data = new InternalData(this->n_base_elements()); @@ -734,72 +734,72 @@ FESystem::get_data (const UpdateFlags flags_, flags = data->update_once | data->update_each; UpdateFlags sub_flags = flags; - // if second derivatives through - // finite differencing are required, - // then initialize some objects for - // that + // if second derivatives through + // finite differencing are required, + // then initialize some objects for + // that data->compute_hessians = flags & update_hessians; if (data->compute_hessians) { - // delete - // update_hessians - // from flags list + // delete + // update_hessians + // from flags list sub_flags = UpdateFlags (sub_flags ^ update_hessians); data->initialize_2nd (this, mapping, quadrature); } - // get data objects from each of - // the base elements and store them + // get data objects from each of + // the base elements and store them for (unsigned int base_no=0; base_non_base_elements(); ++base_no) { typename Mapping::InternalDataBase *base_fe_data_base = - base_element(base_no).get_data(sub_flags, mapping, quadrature); + base_element(base_no).get_data(sub_flags, mapping, quadrature); typename FiniteElement::InternalDataBase *base_fe_data = - dynamic_cast::InternalDataBase *> - (base_fe_data_base); + dynamic_cast::InternalDataBase *> + (base_fe_data_base); Assert (base_fe_data != 0, ExcInternalError()); data->set_fe_data(base_no, base_fe_data); - // make sure that *we* compute - // second derivatives, base - // elements should not do it + // make sure that *we* compute + // second derivatives, base + // elements should not do it Assert (!(base_fe_data->update_each & update_hessians), - ExcInternalError()); + ExcInternalError()); Assert (!(base_fe_data->update_once & update_hessians), - ExcInternalError()); - - // The FEValuesData @p{data} - // given to the - // @p{fill_fe_values} function - // includes the FEValuesDatas - // of the FESystem. Here the - // FEValuesDatas @p{*base_data} - // needs to be created that - // later will be given to the - // @p{fill_fe_values} functions - // of the base - // elements. @p{base_data->initialize} - // cannot be called earlier as - // in the @p{fill_fe_values} - // function called for the - // first cell. This is because - // the initialize function - // needs the update flags as - // argument. - // - // The pointers @p{base_data} - // are stored into the - // FESystem::InternalData - // @p{data}, similar to the - // storing of the - // @p{base_fe_data}s. + ExcInternalError()); + + // The FEValuesData @p{data} + // given to the + // @p{fill_fe_values} function + // includes the FEValuesDatas + // of the FESystem. Here the + // FEValuesDatas @p{*base_data} + // needs to be created that + // later will be given to the + // @p{fill_fe_values} functions + // of the base + // elements. @p{base_data->initialize} + // cannot be called earlier as + // in the @p{fill_fe_values} + // function called for the + // first cell. This is because + // the initialize function + // needs the update flags as + // argument. + // + // The pointers @p{base_data} + // are stored into the + // FESystem::InternalData + // @p{data}, similar to the + // storing of the + // @p{base_fe_data}s. FEValuesData *base_data = new FEValuesData(); data->set_fe_values_data(base_no, base_data); } data->update_flags = data->update_once | - data->update_each; + data->update_each; return data; } @@ -831,25 +831,25 @@ FESystem::get_face_data ( for (unsigned int base_no=0; base_non_base_elements(); ++base_no) { typename Mapping::InternalDataBase *base_fe_data_base = - base_element(base_no).get_face_data(sub_flags, mapping, quadrature); + base_element(base_no).get_face_data(sub_flags, mapping, quadrature); typename FiniteElement::InternalDataBase *base_fe_data = - dynamic_cast::InternalDataBase *> - (base_fe_data_base); + dynamic_cast::InternalDataBase *> + (base_fe_data_base); Assert (base_fe_data != 0, ExcInternalError()); data->set_fe_data(base_no, base_fe_data); Assert (!(base_fe_data->update_each & update_hessians), - ExcInternalError()); + ExcInternalError()); Assert (!(base_fe_data->update_once & update_hessians), - ExcInternalError()); + ExcInternalError()); FEValuesData *base_data = new FEValuesData(); data->set_fe_values_data(base_no, base_data); } data->update_flags = data->update_once | - data->update_each; + data->update_each; return data; } @@ -883,25 +883,25 @@ FESystem::get_subface_data ( for (unsigned int base_no=0; base_non_base_elements(); ++base_no) { typename Mapping::InternalDataBase *base_fe_data_base = - base_element(base_no).get_subface_data(sub_flags, mapping, quadrature); + base_element(base_no).get_subface_data(sub_flags, mapping, quadrature); typename FiniteElement::InternalDataBase *base_fe_data = - dynamic_cast::InternalDataBase *> - (base_fe_data_base); + dynamic_cast::InternalDataBase *> + (base_fe_data_base); Assert (base_fe_data != 0, ExcInternalError()); data->set_fe_data(base_no, base_fe_data); Assert (!(base_fe_data->update_each & update_hessians), - ExcInternalError()); + ExcInternalError()); Assert (!(base_fe_data->update_once & update_hessians), - ExcInternalError()); + ExcInternalError()); FEValuesData *base_data = new FEValuesData(); data->set_fe_values_data(base_no, base_data); } data->update_flags = data->update_once | - data->update_each; + data->update_each; return data; } @@ -919,7 +919,7 @@ FESystem::fill_fe_values ( CellSimilarity::Similarity &cell_similarity) const { compute_fill(mapping, cell, invalid_face_number, invalid_face_number, - quadrature, cell_similarity, mapping_data, fe_data, data); + quadrature, cell_similarity, mapping_data, fe_data, data); } @@ -976,134 +976,134 @@ FESystem::compute_fill ( { const unsigned int n_q_points = quadrature.size(); - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&fedata) != 0, ExcInternalError()); InternalData & fe_data = static_cast (fedata); - // Either dim_1==dim - // (fill_fe_values) or dim_1==dim-1 - // (fill_fe_(sub)face_values) + // Either dim_1==dim + // (fill_fe_values) or dim_1==dim-1 + // (fill_fe_(sub)face_values) Assert(dim_1==dim || dim_1==dim-1, ExcInternalError()); const UpdateFlags flags(dim_1==dim ? - fe_data.current_update_flags() : - fe_data.update_flags); + fe_data.current_update_flags() : + fe_data.update_flags); if (flags & (update_values | update_gradients)) { if (fe_data.is_first_cell()) - { - // Initialize the - // FEValuesDatas for the - // base elements. - // Originally this was the - // task of - // FEValues::FEValues() but - // the latter initializes - // the FEValuesDatas only - // of the FESystem, not of - // the FEValuesDatas needed - // by the base elements - // (and: how should it know - // of their existence, - // after all). - for (unsigned int base_no=0; base_non_base_elements(); ++base_no) - { - // Pointer needed to get - // the update flags of the - // base element - typename Mapping::InternalDataBase & - base_fe_data = fe_data.get_fe_data(base_no); - - // compute update flags ... - const UpdateFlags base_update_flags + { + // Initialize the + // FEValuesDatas for the + // base elements. + // Originally this was the + // task of + // FEValues::FEValues() but + // the latter initializes + // the FEValuesDatas only + // of the FESystem, not of + // the FEValuesDatas needed + // by the base elements + // (and: how should it know + // of their existence, + // after all). + for (unsigned int base_no=0; base_non_base_elements(); ++base_no) + { + // Pointer needed to get + // the update flags of the + // base element + typename Mapping::InternalDataBase & + base_fe_data = fe_data.get_fe_data(base_no); + + // compute update flags ... + const UpdateFlags base_update_flags = mapping_data.update_flags | base_fe_data.update_flags; - // Initialize the FEValuesDatas - // for the base elements. - FEValuesData &base_data=fe_data.get_fe_values_data(base_no); - const FiniteElement &base_fe=base_element(base_no); - base_data.initialize (n_q_points, base_fe, base_update_flags); - } - } - - // fill_fe_face_values needs - // argument Quadrature - // for both cases - // dim_1==dim-1 and - // dim_1=dim. Hence the - // following workaround + // Initialize the FEValuesDatas + // for the base elements. + FEValuesData &base_data=fe_data.get_fe_values_data(base_no); + const FiniteElement &base_fe=base_element(base_no); + base_data.initialize (n_q_points, base_fe, base_update_flags); + } + } + + // fill_fe_face_values needs + // argument Quadrature + // for both cases + // dim_1==dim-1 and + // dim_1=dim. Hence the + // following workaround const Quadrature *cell_quadrature = 0; const Quadrature *face_quadrature = 0; - // static cast to the - // common base class of - // quadrature being either - // Quadrature or - // Quadrature: + // static cast to the + // common base class of + // quadrature being either + // Quadrature or + // Quadrature: const Subscriptor* quadrature_base_pointer = &quadrature; if (face_no==invalid_face_number) - { - Assert(dim_1==dim, ExcDimensionMismatch(dim_1,dim)); - - // Some Mac OS X versions - // have a bug that makes - // the following assertion - // fail spuriously. In that - // case, just disable the - // Assert, as this is not - // something that depends - // on input parameters - // provided by users; the - // validity of the - // assertion is still - // checked on all systems - // that don't have this bug + { + Assert(dim_1==dim, ExcDimensionMismatch(dim_1,dim)); + + // Some Mac OS X versions + // have a bug that makes + // the following assertion + // fail spuriously. In that + // case, just disable the + // Assert, as this is not + // something that depends + // on input parameters + // provided by users; the + // validity of the + // assertion is still + // checked on all systems + // that don't have this bug #ifndef DEAL_II_HAVE_DARWIN_DYNACAST_BUG - Assert (dynamic_cast *>(quadrature_base_pointer) != 0, - ExcInternalError()); + Assert (dynamic_cast *>(quadrature_base_pointer) != 0, + ExcInternalError()); #endif - cell_quadrature + cell_quadrature = static_cast *>(quadrature_base_pointer); - } + } else - { - Assert(dim_1==dim-1, ExcDimensionMismatch(dim_1,dim-1)); + { + Assert(dim_1==dim-1, ExcDimensionMismatch(dim_1,dim-1)); #ifndef DEAL_II_HAVE_DARWIN_DYNACAST_BUG - Assert (dynamic_cast *>(quadrature_base_pointer) != 0, - ExcInternalError()); + Assert (dynamic_cast *>(quadrature_base_pointer) != 0, + ExcInternalError()); #endif - face_quadrature + face_quadrature = static_cast *>(quadrature_base_pointer); - } + } // let base elements update the // necessary data for (unsigned int base_no=0; base_non_base_elements(); ++base_no) - { - const FiniteElement & + { + const FiniteElement & base_fe = base_element(base_no); - typename FiniteElement::InternalDataBase & - base_fe_data = fe_data.get_fe_data(base_no); - FEValuesData & + typename FiniteElement::InternalDataBase & + base_fe_data = fe_data.get_fe_data(base_no); + FEValuesData & base_data = fe_data.get_fe_values_data(base_no); - //TODO: Think about a smarter alternative - // Copy quadrature points. These - // are required for computing the - // determinant in the FEPolyTensor - // class. The determinant is - // one ingredient of the Piola - // transformation, which is applied - // to correctly map the RT space from - // the reference element to the global - // coordinate system. - if (cell_similarity != CellSimilarity::translation) - base_data.JxW_values = data.JxW_values; + //TODO: Think about a smarter alternative + // Copy quadrature points. These + // are required for computing the + // determinant in the FEPolyTensor + // class. The determinant is + // one ingredient of the Piola + // transformation, which is applied + // to correctly map the RT space from + // the reference element to the global + // coordinate system. + if (cell_similarity != CellSimilarity::translation) + base_data.JxW_values = data.JxW_values; // Make sure that in the @@ -1121,15 +1121,15 @@ FESystem::compute_fill ( // data on each face, // therefore use // base_fe_data.update_flags. - if (face_no==invalid_face_number) - base_fe.fill_fe_values(mapping, cell, *cell_quadrature, mapping_data, - base_fe_data, base_data, cell_similarity); - else if (sub_no==invalid_face_number) - base_fe.fill_fe_face_values(mapping, cell, face_no, - *face_quadrature, mapping_data, base_fe_data, base_data); - else - base_fe.fill_fe_subface_values(mapping, cell, face_no, sub_no, - *face_quadrature, mapping_data, base_fe_data, base_data); + if (face_no==invalid_face_number) + base_fe.fill_fe_values(mapping, cell, *cell_quadrature, mapping_data, + base_fe_data, base_data, cell_similarity); + else if (sub_no==invalid_face_number) + base_fe.fill_fe_face_values(mapping, cell, face_no, + *face_quadrature, mapping_data, base_fe_data, base_data); + else + base_fe.fill_fe_subface_values(mapping, cell, face_no, sub_no, + *face_quadrature, mapping_data, base_fe_data, base_data); // now data has been // generated, so copy @@ -1165,19 +1165,19 @@ FESystem::compute_fill ( base_fe_data.current_update_flags() : base_fe_data.update_flags); - // if the current cell is just a - // translation of the previous - // one, the underlying data has - // not changed, and we don't even - // need to enter this section - if (cell_similarity != CellSimilarity::translation) - for (unsigned int system_index=0; system_indexdofs_per_cell; - ++system_index) - if (this->system_to_base_table[system_index].first.first == base_no) - { - const unsigned int - base_index = this->system_to_base_table[system_index].second; - Assert (base_indexdofs_per_cell; + ++system_index) + if (this->system_to_base_table[system_index].first.first == base_no) + { + const unsigned int + base_index = this->system_to_base_table[system_index].second; + Assert (base_index::compute_fill ( // this one value, and // to which index to // put - unsigned int out_index = 0; - for (unsigned int i=0; in_nonzero_components(i); - unsigned int in_index = 0; - for (unsigned int i=0; in_nonzero_components(i); + unsigned int in_index = 0; + for (unsigned int i=0; in_nonzero_components(system_index) == - base_fe.n_nonzero_components(base_index), - ExcInternalError()); - for (unsigned int s=0; sn_nonzero_components(system_index); ++s) - { - if (base_flags & update_values) - for (unsigned int q=0; qn_nonzero_components(system_index) == + base_fe.n_nonzero_components(base_index), + ExcInternalError()); + for (unsigned int s=0; sn_nonzero_components(system_index); ++s) + { + if (base_flags & update_values) + for (unsigned int q=0; q::compute_fill ( // should not // have computed // them! - Assert (!(base_flags & update_hessians), - ExcInternalError()); - }; - }; + Assert (!(base_flags & update_hessians), + ExcInternalError()); + }; + }; }; } @@ -1240,23 +1240,23 @@ FESystem::compute_fill ( { unsigned int offset = 0; if (face_no != invalid_face_number) - { - if (sub_no == invalid_face_number) - offset=QProjector::DataSetDescriptor - ::face(face_no, - cell->face_orientation(face_no), - cell->face_flip(face_no), - cell->face_rotation(face_no), - n_q_points); - else - offset=QProjector::DataSetDescriptor - ::subface(face_no, sub_no, - cell->face_orientation(face_no), - cell->face_flip(face_no), - cell->face_rotation(face_no), - n_q_points, - cell->subface_case(face_no)); - } + { + if (sub_no == invalid_face_number) + offset=QProjector::DataSetDescriptor + ::face(face_no, + cell->face_orientation(face_no), + cell->face_flip(face_no), + cell->face_rotation(face_no), + n_q_points); + else + offset=QProjector::DataSetDescriptor + ::subface(face_no, sub_no, + cell->face_orientation(face_no), + cell->face_flip(face_no), + cell->face_rotation(face_no), + n_q_points, + cell->subface_case(face_no)); + } this->compute_2nd (mapping, cell, offset, mapping_data, fe_data, data); } @@ -1268,9 +1268,9 @@ template void FESystem::build_cell_tables() { - // If the system is not primitive, - // these have not been initialized - // by FiniteElement + // If the system is not primitive, + // these have not been initialized + // by FiniteElement this->system_to_component_table.resize(this->dofs_per_cell); this->face_system_to_component_table.resize(this->dofs_per_face); @@ -1280,28 +1280,28 @@ FESystem::build_cell_tables() for (unsigned int base=0; base < this->n_base_elements(); ++base) for (unsigned int m = 0; m < this->element_multiplicity(base); ++m) { - this->block_indices_data.push_back(base_element(base).dofs_per_cell); - for (unsigned int k=0; kcomponent_to_base_table[total_index++] - = std::make_pair(std::make_pair(base,k), m); + this->block_indices_data.push_back(base_element(base).dofs_per_cell); + for (unsigned int k=0; kcomponent_to_base_table[total_index++] + = std::make_pair(std::make_pair(base,k), m); } Assert (total_index == this->component_to_base_table.size(), - ExcInternalError()); + ExcInternalError()); - // Initialize index tables. - // Multi-component base elements - // have to be thought of. For - // non-primitive shape functions, - // have a special invalid index. + // Initialize index tables. + // Multi-component base elements + // have to be thought of. For + // non-primitive shape functions, + // have a special invalid index. const std::pair non_primitive_index (numbers::invalid_unsigned_int, - numbers::invalid_unsigned_int); + numbers::invalid_unsigned_int); - // First enumerate vertex indices, - // where we first enumerate all - // indices on the first vertex in - // the order of the base elements, - // then of the second vertex, etc + // First enumerate vertex indices, + // where we first enumerate all + // indices on the first vertex in + // the order of the base elements, + // then of the second vertex, etc total_index = 0; for (unsigned int vertex_number=0; vertex_number::vertices_per_cell; @@ -1309,147 +1309,147 @@ FESystem::build_cell_tables() { unsigned comp_start = 0; for(unsigned int base=0; basen_base_elements(); ++base) - for (unsigned int m=0; melement_multiplicity(base); - ++m, comp_start+=base_element(base).n_components()) - for (unsigned int local_index = 0; - local_index < base_element(base).dofs_per_vertex; - ++local_index, ++total_index) - { - const unsigned int index_in_base - = (base_element(base).dofs_per_vertex*vertex_number + - local_index); - - this->system_to_base_table[total_index] - = std::make_pair (std::make_pair(base, m), index_in_base); - - if (base_element(base).is_primitive(index_in_base)) - { - const unsigned int comp_in_base - = base_element(base).system_to_component_index(index_in_base).first; - const unsigned int comp - = comp_start + comp_in_base; - const unsigned int index_in_comp - = base_element(base).system_to_component_index(index_in_base).second; - this->system_to_component_table[total_index] - = std::make_pair (comp, index_in_comp); - } - else - this->system_to_component_table[total_index] = non_primitive_index; - } + for (unsigned int m=0; melement_multiplicity(base); + ++m, comp_start+=base_element(base).n_components()) + for (unsigned int local_index = 0; + local_index < base_element(base).dofs_per_vertex; + ++local_index, ++total_index) + { + const unsigned int index_in_base + = (base_element(base).dofs_per_vertex*vertex_number + + local_index); + + this->system_to_base_table[total_index] + = std::make_pair (std::make_pair(base, m), index_in_base); + + if (base_element(base).is_primitive(index_in_base)) + { + const unsigned int comp_in_base + = base_element(base).system_to_component_index(index_in_base).first; + const unsigned int comp + = comp_start + comp_in_base; + const unsigned int index_in_comp + = base_element(base).system_to_component_index(index_in_base).second; + this->system_to_component_table[total_index] + = std::make_pair (comp, index_in_comp); + } + else + this->system_to_component_table[total_index] = non_primitive_index; + } } - // 2. Lines + // 2. Lines if (GeometryInfo::lines_per_cell > 0) for (unsigned int line_number= 0; - line_number != GeometryInfo::lines_per_cell; - ++line_number) + line_number != GeometryInfo::lines_per_cell; + ++line_number) { - unsigned comp_start = 0; - for (unsigned int base=0; basen_base_elements(); ++base) - for (unsigned int m=0; melement_multiplicity(base); - ++m, comp_start+=base_element(base).n_components()) - for (unsigned int local_index = 0; - local_index < base_element(base).dofs_per_line; - ++local_index, ++total_index) - { - const unsigned int index_in_base - = (base_element(base).dofs_per_line*line_number + - local_index + - base_element(base).first_line_index); - - this->system_to_base_table[total_index] - = std::make_pair (std::make_pair(base,m), index_in_base); - - if (base_element(base).is_primitive(index_in_base)) - { - const unsigned int comp_in_base - = base_element(base).system_to_component_index(index_in_base).first; - const unsigned int comp - = comp_start + comp_in_base; - const unsigned int index_in_comp - = base_element(base).system_to_component_index(index_in_base).second; - this->system_to_component_table[total_index] - = std::make_pair (comp, index_in_comp); - } - else - this->system_to_component_table[total_index] = non_primitive_index; - } + unsigned comp_start = 0; + for (unsigned int base=0; basen_base_elements(); ++base) + for (unsigned int m=0; melement_multiplicity(base); + ++m, comp_start+=base_element(base).n_components()) + for (unsigned int local_index = 0; + local_index < base_element(base).dofs_per_line; + ++local_index, ++total_index) + { + const unsigned int index_in_base + = (base_element(base).dofs_per_line*line_number + + local_index + + base_element(base).first_line_index); + + this->system_to_base_table[total_index] + = std::make_pair (std::make_pair(base,m), index_in_base); + + if (base_element(base).is_primitive(index_in_base)) + { + const unsigned int comp_in_base + = base_element(base).system_to_component_index(index_in_base).first; + const unsigned int comp + = comp_start + comp_in_base; + const unsigned int index_in_comp + = base_element(base).system_to_component_index(index_in_base).second; + this->system_to_component_table[total_index] + = std::make_pair (comp, index_in_comp); + } + else + this->system_to_component_table[total_index] = non_primitive_index; + } } - // 3. Quads + // 3. Quads if (GeometryInfo::quads_per_cell > 0) for (unsigned int quad_number= 0; - quad_number != GeometryInfo::quads_per_cell; - ++quad_number) + quad_number != GeometryInfo::quads_per_cell; + ++quad_number) { - unsigned int comp_start = 0; - for (unsigned int base=0; basen_base_elements(); ++base) - for (unsigned int m=0; melement_multiplicity(base); - ++m, comp_start += base_element(base).n_components()) - for (unsigned int local_index = 0; - local_index < base_element(base).dofs_per_quad; - ++local_index, ++total_index) - { - const unsigned int index_in_base - = (base_element(base).dofs_per_quad*quad_number + - local_index + - base_element(base).first_quad_index); - - this->system_to_base_table[total_index] - = std::make_pair (std::make_pair(base,m), index_in_base); - - if (base_element(base).is_primitive(index_in_base)) - { - const unsigned int comp_in_base - = base_element(base).system_to_component_index(index_in_base).first; - const unsigned int comp - = comp_start + comp_in_base; - const unsigned int index_in_comp - = base_element(base).system_to_component_index(index_in_base).second; - this->system_to_component_table[total_index] - = std::make_pair (comp, index_in_comp); - } - else - this->system_to_component_table[total_index] = non_primitive_index; - } + unsigned int comp_start = 0; + for (unsigned int base=0; basen_base_elements(); ++base) + for (unsigned int m=0; melement_multiplicity(base); + ++m, comp_start += base_element(base).n_components()) + for (unsigned int local_index = 0; + local_index < base_element(base).dofs_per_quad; + ++local_index, ++total_index) + { + const unsigned int index_in_base + = (base_element(base).dofs_per_quad*quad_number + + local_index + + base_element(base).first_quad_index); + + this->system_to_base_table[total_index] + = std::make_pair (std::make_pair(base,m), index_in_base); + + if (base_element(base).is_primitive(index_in_base)) + { + const unsigned int comp_in_base + = base_element(base).system_to_component_index(index_in_base).first; + const unsigned int comp + = comp_start + comp_in_base; + const unsigned int index_in_comp + = base_element(base).system_to_component_index(index_in_base).second; + this->system_to_component_table[total_index] + = std::make_pair (comp, index_in_comp); + } + else + this->system_to_component_table[total_index] = non_primitive_index; + } } - // 4. Hexes + // 4. Hexes if (GeometryInfo::hexes_per_cell > 0) for (unsigned int hex_number= 0; - hex_number != GeometryInfo::hexes_per_cell; - ++hex_number) + hex_number != GeometryInfo::hexes_per_cell; + ++hex_number) { - unsigned int comp_start = 0; - for(unsigned int base=0; basen_base_elements(); ++base) - for (unsigned int m=0; melement_multiplicity(base); - ++m, comp_start+=base_element(base).n_components()) - for (unsigned int local_index = 0; - local_index < base_element(base).dofs_per_hex; - ++local_index, ++total_index) - { - const unsigned int index_in_base - = (base_element(base).dofs_per_hex*hex_number + - local_index + - base_element(base).first_hex_index); - - this->system_to_base_table[total_index] - = std::make_pair (std::make_pair(base,m), index_in_base); - - if (base_element(base).is_primitive(index_in_base)) - { - const unsigned int comp_in_base - = base_element(base).system_to_component_index(index_in_base).first; - const unsigned int comp - = comp_start + comp_in_base; - const unsigned int index_in_comp - = base_element(base).system_to_component_index(index_in_base).second; - this->system_to_component_table[total_index] - = std::make_pair (comp, index_in_comp); - } - else - this->system_to_component_table[total_index] = non_primitive_index; - } + unsigned int comp_start = 0; + for(unsigned int base=0; basen_base_elements(); ++base) + for (unsigned int m=0; melement_multiplicity(base); + ++m, comp_start+=base_element(base).n_components()) + for (unsigned int local_index = 0; + local_index < base_element(base).dofs_per_hex; + ++local_index, ++total_index) + { + const unsigned int index_in_base + = (base_element(base).dofs_per_hex*hex_number + + local_index + + base_element(base).first_hex_index); + + this->system_to_base_table[total_index] + = std::make_pair (std::make_pair(base,m), index_in_base); + + if (base_element(base).is_primitive(index_in_base)) + { + const unsigned int comp_in_base + = base_element(base).system_to_component_index(index_in_base).first; + const unsigned int comp + = comp_start + comp_in_base; + const unsigned int index_in_comp + = base_element(base).system_to_component_index(index_in_base).second; + this->system_to_component_table[total_index] + = std::make_pair (comp, index_in_comp); + } + else + this->system_to_component_table[total_index] = non_primitive_index; + } } } @@ -1459,19 +1459,19 @@ template void FESystem::build_face_tables() { - // Initialize index tables. do this - // in the same way as done for the - // cell tables, except that we now - // loop over the objects of faces + // Initialize index tables. do this + // in the same way as done for the + // cell tables, except that we now + // loop over the objects of faces - // For non-primitive shape - // functions, have a special - // invalid index + // For non-primitive shape + // functions, have a special + // invalid index const std::pair non_primitive_index (numbers::invalid_unsigned_int, - numbers::invalid_unsigned_int); + numbers::invalid_unsigned_int); - // 1. Vertices + // 1. Vertices unsigned int total_index = 0; for (unsigned int vertex_number=0; vertex_number::vertices_per_face; @@ -1479,160 +1479,160 @@ FESystem::build_face_tables() { unsigned int comp_start = 0; for(unsigned int base=0; basen_base_elements(); ++base) - for (unsigned int m=0; melement_multiplicity(base); - ++m, comp_start += base_element(base).n_components()) - for (unsigned int local_index = 0; - local_index < base_element(base).dofs_per_vertex; - ++local_index, ++total_index) - { - // get (cell) index of - // this shape function - // inside the base - // element to see - // whether the shape - // function is - // primitive (assume - // that all shape - // functions on - // vertices share the - // same primitivity - // property; assume - // likewise for all - // shape functions - // located on lines, - // quads, etc. this - // way, we can ask for - // primitivity of only - // _one_ shape - // function, which is - // taken as - // representative for - // all others located - // on the same type of - // object): - const unsigned int index_in_base - = (base_element(base).dofs_per_vertex*vertex_number + - local_index); - - const unsigned int face_index_in_base - = (base_element(base).dofs_per_vertex*vertex_number + - local_index); - - this->face_system_to_base_table[total_index] - = std::make_pair (std::make_pair(base,m), face_index_in_base); - - if (base_element(base).is_primitive(index_in_base)) - { - const unsigned int comp_in_base - = base_element(base).face_system_to_component_index(face_index_in_base).first; - const unsigned int comp - = comp_start + comp_in_base; - const unsigned int face_index_in_comp - = base_element(base).face_system_to_component_index(face_index_in_base).second; - this->face_system_to_component_table[total_index] - = std::make_pair (comp, face_index_in_comp); - } - else - this->face_system_to_component_table[total_index] = non_primitive_index; - } + for (unsigned int m=0; melement_multiplicity(base); + ++m, comp_start += base_element(base).n_components()) + for (unsigned int local_index = 0; + local_index < base_element(base).dofs_per_vertex; + ++local_index, ++total_index) + { + // get (cell) index of + // this shape function + // inside the base + // element to see + // whether the shape + // function is + // primitive (assume + // that all shape + // functions on + // vertices share the + // same primitivity + // property; assume + // likewise for all + // shape functions + // located on lines, + // quads, etc. this + // way, we can ask for + // primitivity of only + // _one_ shape + // function, which is + // taken as + // representative for + // all others located + // on the same type of + // object): + const unsigned int index_in_base + = (base_element(base).dofs_per_vertex*vertex_number + + local_index); + + const unsigned int face_index_in_base + = (base_element(base).dofs_per_vertex*vertex_number + + local_index); + + this->face_system_to_base_table[total_index] + = std::make_pair (std::make_pair(base,m), face_index_in_base); + + if (base_element(base).is_primitive(index_in_base)) + { + const unsigned int comp_in_base + = base_element(base).face_system_to_component_index(face_index_in_base).first; + const unsigned int comp + = comp_start + comp_in_base; + const unsigned int face_index_in_comp + = base_element(base).face_system_to_component_index(face_index_in_base).second; + this->face_system_to_component_table[total_index] + = std::make_pair (comp, face_index_in_comp); + } + else + this->face_system_to_component_table[total_index] = non_primitive_index; + } } - // 2. Lines + // 2. Lines if (GeometryInfo::lines_per_face > 0) for (unsigned line_number= 0; - line_number != GeometryInfo::lines_per_face; - ++line_number) + line_number != GeometryInfo::lines_per_face; + ++line_number) { - unsigned comp_start = 0; - for(unsigned base = 0; base < this->n_base_elements(); ++base) - for (unsigned m=0; melement_multiplicity(base); - ++m, comp_start += base_element(base).n_components()) - for (unsigned local_index = 0; - local_index < base_element(base).dofs_per_line; - ++local_index, ++total_index) - { - // do everything - // alike for this - // type of object - const unsigned int index_in_base - = (base_element(base).dofs_per_line*line_number + - local_index + - base_element(base).first_line_index); - - const unsigned int face_index_in_base - = (base_element(base).first_face_line_index + - base_element(base).dofs_per_line * line_number + - local_index); - - this->face_system_to_base_table[total_index] - = std::make_pair (std::make_pair(base,m), face_index_in_base); - - if (base_element(base).is_primitive(index_in_base)) - { - const unsigned int comp_in_base - = base_element(base).face_system_to_component_index(face_index_in_base).first; - const unsigned int comp - = comp_start + comp_in_base; - const unsigned int face_index_in_comp - = base_element(base).face_system_to_component_index(face_index_in_base).second; - this->face_system_to_component_table[total_index] - = std::make_pair (comp, face_index_in_comp); - } - else - this->face_system_to_component_table[total_index] = non_primitive_index; - } + unsigned comp_start = 0; + for(unsigned base = 0; base < this->n_base_elements(); ++base) + for (unsigned m=0; melement_multiplicity(base); + ++m, comp_start += base_element(base).n_components()) + for (unsigned local_index = 0; + local_index < base_element(base).dofs_per_line; + ++local_index, ++total_index) + { + // do everything + // alike for this + // type of object + const unsigned int index_in_base + = (base_element(base).dofs_per_line*line_number + + local_index + + base_element(base).first_line_index); + + const unsigned int face_index_in_base + = (base_element(base).first_face_line_index + + base_element(base).dofs_per_line * line_number + + local_index); + + this->face_system_to_base_table[total_index] + = std::make_pair (std::make_pair(base,m), face_index_in_base); + + if (base_element(base).is_primitive(index_in_base)) + { + const unsigned int comp_in_base + = base_element(base).face_system_to_component_index(face_index_in_base).first; + const unsigned int comp + = comp_start + comp_in_base; + const unsigned int face_index_in_comp + = base_element(base).face_system_to_component_index(face_index_in_base).second; + this->face_system_to_component_table[total_index] + = std::make_pair (comp, face_index_in_comp); + } + else + this->face_system_to_component_table[total_index] = non_primitive_index; + } } - // 3. Quads + // 3. Quads if (GeometryInfo::quads_per_face > 0) for (unsigned quad_number= 0; - quad_number != GeometryInfo::quads_per_face; - ++quad_number) + quad_number != GeometryInfo::quads_per_face; + ++quad_number) { - unsigned comp_start = 0; - for(unsigned base=0; basen_base_elements(); ++base) - for (unsigned m=0; melement_multiplicity(base); - ++m, comp_start += base_element(base).n_components()) - for (unsigned local_index = 0; - local_index < base_element(base).dofs_per_quad; - ++local_index, ++total_index) - { - // do everything - // alike for this - // type of object - const unsigned int index_in_base - = (base_element(base).dofs_per_quad*quad_number + - local_index + - base_element(base).first_quad_index); - - const unsigned int face_index_in_base - = (base_element(base).first_face_quad_index + - base_element(base).dofs_per_quad * quad_number + - local_index); - - this->face_system_to_base_table[total_index] - = std::make_pair (std::make_pair(base,m), face_index_in_base); - - if (base_element(base).is_primitive(index_in_base)) - { - const unsigned int comp_in_base - = base_element(base).face_system_to_component_index(face_index_in_base).first; - const unsigned int comp - = comp_start + comp_in_base; - const unsigned int face_index_in_comp - = base_element(base).face_system_to_component_index(face_index_in_base).second; - this->face_system_to_component_table[total_index] - = std::make_pair (comp, face_index_in_comp); - } - else - this->face_system_to_component_table[total_index] = non_primitive_index; - } + unsigned comp_start = 0; + for(unsigned base=0; basen_base_elements(); ++base) + for (unsigned m=0; melement_multiplicity(base); + ++m, comp_start += base_element(base).n_components()) + for (unsigned local_index = 0; + local_index < base_element(base).dofs_per_quad; + ++local_index, ++total_index) + { + // do everything + // alike for this + // type of object + const unsigned int index_in_base + = (base_element(base).dofs_per_quad*quad_number + + local_index + + base_element(base).first_quad_index); + + const unsigned int face_index_in_base + = (base_element(base).first_face_quad_index + + base_element(base).dofs_per_quad * quad_number + + local_index); + + this->face_system_to_base_table[total_index] + = std::make_pair (std::make_pair(base,m), face_index_in_base); + + if (base_element(base).is_primitive(index_in_base)) + { + const unsigned int comp_in_base + = base_element(base).face_system_to_component_index(face_index_in_base).first; + const unsigned int comp + = comp_start + comp_in_base; + const unsigned int face_index_in_comp + = base_element(base).face_system_to_component_index(face_index_in_base).second; + this->face_system_to_component_table[total_index] + = std::make_pair (comp, face_index_in_comp); + } + else + this->face_system_to_component_table[total_index] = non_primitive_index; + } } Assert (total_index == this->dofs_per_face, ExcInternalError()); Assert (total_index == this->face_system_to_component_table.size(), - ExcInternalError()); + ExcInternalError()); Assert (total_index == this->face_system_to_base_table.size(), - ExcInternalError()); + ExcInternalError()); } @@ -1655,55 +1655,55 @@ void FESystem::build_interface_constraints () this->interface_constraints. TableBase<2,double>::reinit (this->interface_constraints_size()); - // the layout of the constraints - // matrix is described in the - // FiniteElement class. you may - // want to look there first before - // trying to understand the - // following, especially the - // mapping of the @p{m} index. - // - // in order to map it to the - // fe-system class, we have to know - // which base element a degree of - // freedom within a vertex, line, - // etc belongs to. this can be - // accomplished by the - // system_to_component_index - // function in conjunction with the - // numbers - // first_{line,quad,...}_index + // the layout of the constraints + // matrix is described in the + // FiniteElement class. you may + // want to look there first before + // trying to understand the + // following, especially the + // mapping of the @p{m} index. + // + // in order to map it to the + // fe-system class, we have to know + // which base element a degree of + // freedom within a vertex, line, + // etc belongs to. this can be + // accomplished by the + // system_to_component_index + // function in conjunction with the + // numbers + // first_{line,quad,...}_index for (unsigned int n=0; ninterface_constraints.n(); ++n) for (unsigned int m=0; minterface_constraints.m(); ++m) { - // for the pair (n,m) find - // out which base element - // they belong to and the - // number therein - // - // first for the n - // index. this is simple - // since the n indices are in - // the same order as they are - // usually on a face. note - // that for the data type, - // first value in pair is - // (base element,instance of - // base element), second is - // index within this instance - const std::pair, unsigned int> n_index - = this->face_system_to_base_table[n]; - - // likewise for the m - // index. this is more - // complicated due to the - // strange ordering we have - // for the dofs on the - // refined faces. - std::pair, unsigned int> m_index; - switch (dim) - { - case 1: + // for the pair (n,m) find + // out which base element + // they belong to and the + // number therein + // + // first for the n + // index. this is simple + // since the n indices are in + // the same order as they are + // usually on a face. note + // that for the data type, + // first value in pair is + // (base element,instance of + // base element), second is + // index within this instance + const std::pair, unsigned int> n_index + = this->face_system_to_base_table[n]; + + // likewise for the m + // index. this is more + // complicated due to the + // strange ordering we have + // for the dofs on the + // refined faces. + std::pair, unsigned int> m_index; + switch (dim) + { + case 1: { // we should never get here! // (in 1d, the constraints matrix @@ -1712,7 +1712,7 @@ void FESystem::build_interface_constraints () break; }; - case 2: + case 2: { // the indices m=0..d_v-1 are // from the center vertex. @@ -1793,7 +1793,7 @@ void FESystem::build_interface_constraints () break; }; - case 3: + case 3: { // same way as above, // although a little @@ -1882,22 +1882,22 @@ void FESystem::build_interface_constraints () break; }; - default: + default: Assert (false, ExcNotImplemented()); - }; - - // now that we gathered all - // information: use it to - // build the matrix. note - // that if n and m belong to - // different base elements or - // instances, then there - // definitely will be no - // coupling - if (n_index.first == m_index.first) - this->interface_constraints(m,n) - = (base_element(n_index.first.first).constraints()(m_index.second, - n_index.second)); + }; + + // now that we gathered all + // information: use it to + // build the matrix. note + // that if n and m belong to + // different base elements or + // instances, then there + // definitely will be no + // coupling + if (n_index.first == m_index.first) + this->interface_constraints(m,n) + = (base_element(n_index.first.first).constraints()(m_index.second, + n_index.second)); }; } @@ -1913,102 +1913,102 @@ void FESystem::initialize () ref_case::isotropic_refinement+1; ++ref_case) { - // Check if some of the matrices of - // the base elements are void. - // repeat this check for each RefineCase + // Check if some of the matrices of + // the base elements are void. + // repeat this check for each RefineCase bool do_restriction = true; bool do_prolongation = true; for (unsigned int i=0; in_base_elements(); ++i) - { - if (base_element(i).restriction[ref_case-1][0].n() != base_element(i).dofs_per_cell) - do_restriction = false; - if (base_element(i).prolongation[ref_case-1][0].n() != base_element(i).dofs_per_cell) - do_prolongation = false; - } - - // if we did not encounter void - // matrices, initialize the - // respective matrix sizes + { + if (base_element(i).restriction[ref_case-1][0].n() != base_element(i).dofs_per_cell) + do_restriction = false; + if (base_element(i).prolongation[ref_case-1][0].n() != base_element(i).dofs_per_cell) + do_prolongation = false; + } + + // if we did not encounter void + // matrices, initialize the + // respective matrix sizes if (do_restriction) - for (unsigned int i=0;i::n_children(RefinementCase(ref_case));++i) - this->restriction[ref_case-1][i].reinit(this->dofs_per_cell, - this->dofs_per_cell); + for (unsigned int i=0;i::n_children(RefinementCase(ref_case));++i) + this->restriction[ref_case-1][i].reinit(this->dofs_per_cell, + this->dofs_per_cell); if (do_prolongation) - for (unsigned int i=0;i::n_children(RefinementCase(ref_case));++i) - this->prolongation[ref_case-1][i].reinit(this->dofs_per_cell, - this->dofs_per_cell); - - // distribute the matrices of the - // base finite elements to the - // matrices of this object. for - // this, loop over all degrees of - // freedom and take the respective - // entry of the underlying base - // element. - // - // note that we by definition of a - // base element, they are - // independent, i.e. do not - // couple. only DoFs that belong to - // the same instance of a base - // element may couple + for (unsigned int i=0;i::n_children(RefinementCase(ref_case));++i) + this->prolongation[ref_case-1][i].reinit(this->dofs_per_cell, + this->dofs_per_cell); + + // distribute the matrices of the + // base finite elements to the + // matrices of this object. for + // this, loop over all degrees of + // freedom and take the respective + // entry of the underlying base + // element. + // + // note that we by definition of a + // base element, they are + // independent, i.e. do not + // couple. only DoFs that belong to + // the same instance of a base + // element may couple for (unsigned int i=0; idofs_per_cell; ++i) - for (unsigned int j=0; jdofs_per_cell; ++j) - { - // first find out to which - // base element indices i and - // j belong, and which - // instance thereof in case - // the base element has a - // multiplicity greater than - // one. if they should not - // happen to belong to the - // same instance of a base - // element, then they cannot - // couple, so go on with the - // next index - if (this->system_to_base_table[i].first != - this->system_to_base_table[j].first) - continue; - - // so get the common base - // element and the indices - // therein: - const unsigned int - base = this->system_to_base_table[i].first.first; - - const unsigned int - base_index_i = this->system_to_base_table[i].second, - base_index_j = this->system_to_base_table[j].second; - - // if we are sure that DoFs i - // and j may couple, then - // copy entries of the - // matrices: - for (unsigned int child=0; child::n_children(RefinementCase(ref_case)); ++child) - { - if (do_restriction) - this->restriction[ref_case-1][child] (i,j) - = (base_element(base) - .get_restriction_matrix(child, RefinementCase(ref_case))( - base_index_i,base_index_j)); - - if (do_prolongation) - this->prolongation[ref_case-1][child] (i,j) - = (base_element(base) - .get_prolongation_matrix(child, RefinementCase(ref_case))( - base_index_i,base_index_j)); - }; - }; + for (unsigned int j=0; jdofs_per_cell; ++j) + { + // first find out to which + // base element indices i and + // j belong, and which + // instance thereof in case + // the base element has a + // multiplicity greater than + // one. if they should not + // happen to belong to the + // same instance of a base + // element, then they cannot + // couple, so go on with the + // next index + if (this->system_to_base_table[i].first != + this->system_to_base_table[j].first) + continue; + + // so get the common base + // element and the indices + // therein: + const unsigned int + base = this->system_to_base_table[i].first.first; + + const unsigned int + base_index_i = this->system_to_base_table[i].second, + base_index_j = this->system_to_base_table[j].second; + + // if we are sure that DoFs i + // and j may couple, then + // copy entries of the + // matrices: + for (unsigned int child=0; child::n_children(RefinementCase(ref_case)); ++child) + { + if (do_restriction) + this->restriction[ref_case-1][child] (i,j) + = (base_element(base) + .get_restriction_matrix(child, RefinementCase(ref_case))( + base_index_i,base_index_j)); + + if (do_prolongation) + this->prolongation[ref_case-1][child] (i,j) + = (base_element(base) + .get_prolongation_matrix(child, RefinementCase(ref_case))( + base_index_i,base_index_j)); + }; + }; } - // now set up the interface constraints. - // this is kind'o hairy, so don't try - // to do it dimension independent + // now set up the interface constraints. + // this is kind'o hairy, so don't try + // to do it dimension independent build_interface_constraints (); - // finally fill in support points - // on cell and face + // finally fill in support points + // on cell and face initialize_unit_support_points (); initialize_unit_face_support_points (); @@ -2020,7 +2020,7 @@ void FESystem::initialize () template FiniteElementData FESystem::multiply_dof_numbers (const FiniteElementData &fe_data, - const unsigned int N) + const unsigned int N) { std::vector dpo; dpo.push_back(fe_data.dofs_per_vertex * N); @@ -2029,10 +2029,10 @@ FESystem::multiply_dof_numbers (const FiniteElementData &fe_d if (dim>2) dpo.push_back(fe_data.dofs_per_hex * N); return FiniteElementData (dpo, - fe_data.n_components() * N, - fe_data.tensor_degree(), - fe_data.conforming_space, - N); + fe_data.n_components() * N, + fe_data.tensor_degree(), + fe_data.conforming_space, + N); } @@ -2043,34 +2043,34 @@ void FESystem:: initialize_unit_support_points () { - // if one of the base elements - // has no support points, then - // it makes no sense to define - // support points for the - // composed element, so return - // an empty array to - // demonstrate that - // fact + // if one of the base elements + // has no support points, then + // it makes no sense to define + // support points for the + // composed element, so return + // an empty array to + // demonstrate that + // fact for (unsigned int base_el=0; base_eln_base_elements(); ++base_el) if (!base_element(base_el).has_support_points()) { - this->unit_support_points.resize(0); - return; + this->unit_support_points.resize(0); + return; }; - // generate unit support points - // from unit support points of sub - // elements + // generate unit support points + // from unit support points of sub + // elements this->unit_support_points.resize(this->dofs_per_cell); for (unsigned int i=0; idofs_per_cell; ++i) { const unsigned int - base = this->system_to_base_table[i].first.first, - base_index = this->system_to_base_table[i].second; + base = this->system_to_base_table[i].first.first, + base_index = this->system_to_base_table[i].second; Assert (basen_base_elements(), ExcInternalError()); Assert (base_indexunit_support_points[i] = base_element(base).unit_support_points[base_index]; }; } @@ -2082,39 +2082,39 @@ void FESystem:: initialize_unit_face_support_points () { - // Nothing to do in 1D + // Nothing to do in 1D if (dim == 1) return; - // if one of the base elements has no - // support points, then it makes no sense - // to define support points for the - // composed element. In that case, return - // an empty array to demonstrate that fact - // (note that we ask whether the base - // element has no support points at all, - // not only none on the face!) - // - // on the other hand, if there is an - // element that simply has no degrees of - // freedom on the face at all, then we - // don't care whether it has support points - // or not. this is, for example, the case - // for the stable Stokes element Q(p)^dim - // \times DGP(p-1). + // if one of the base elements has no + // support points, then it makes no sense + // to define support points for the + // composed element. In that case, return + // an empty array to demonstrate that fact + // (note that we ask whether the base + // element has no support points at all, + // not only none on the face!) + // + // on the other hand, if there is an + // element that simply has no degrees of + // freedom on the face at all, then we + // don't care whether it has support points + // or not. this is, for example, the case + // for the stable Stokes element Q(p)^dim + // \times DGP(p-1). for (unsigned int base_el=0; base_eln_base_elements(); ++base_el) if (!base_element(base_el).has_support_points() - && - (base_element(base_el).dofs_per_face > 0)) + && + (base_element(base_el).dofs_per_face > 0)) { - this->unit_face_support_points.resize(0); - return; + this->unit_face_support_points.resize(0); + return; } - // generate unit face support points - // from unit support points of sub - // elements + // generate unit face support points + // from unit support points of sub + // elements this->unit_face_support_points.resize(this->dofs_per_face); for (unsigned int i=0; idofs_per_face; ++i) @@ -2123,10 +2123,10 @@ initialize_unit_face_support_points () const unsigned int index_in_base = this->face_system_to_base_table[i].second; Assert (index_in_base < base_element(base_i).unit_face_support_points.size(), - ExcInternalError()); + ExcInternalError()); this->unit_face_support_points[i] - = base_element(base_i).unit_face_support_points[index_in_base]; + = base_element(base_i).unit_face_support_points[index_in_base]; } } @@ -2136,54 +2136,54 @@ template void FESystem::initialize_quad_dof_index_permutation () { - // nothing to do in other dimensions than 3 + // nothing to do in other dimensions than 3 if (dim < 3) return; - // the array into which we want to write - // should have the correct size already. + // the array into which we want to write + // should have the correct size already. Assert (this->adjust_quad_dof_index_for_face_orientation_table.n_elements()== - 8*this->dofs_per_quad, ExcInternalError()); + 8*this->dofs_per_quad, ExcInternalError()); - // to obtain the shifts for this composed - // element, copy the shift information of - // the base elements + // to obtain the shifts for this composed + // element, copy the shift information of + // the base elements unsigned int index = 0; for (unsigned int b=0; bn_base_elements();++b) { const Table<2,int> &temp - = this->base_element(b).adjust_quad_dof_index_for_face_orientation_table; + = this->base_element(b).adjust_quad_dof_index_for_face_orientation_table; for (unsigned int c=0; celement_multiplicity(b); ++c) - { - for (unsigned int i=0; iadjust_quad_dof_index_for_face_orientation_table(index+i,j)= - temp(i,j); - index += temp.size(0); - } + { + for (unsigned int i=0; iadjust_quad_dof_index_for_face_orientation_table(index+i,j)= + temp(i,j); + index += temp.size(0); + } } Assert (index == this->dofs_per_quad, - ExcInternalError()); + ExcInternalError()); - // aditionally compose the permutation - // information for lines + // aditionally compose the permutation + // information for lines Assert (this->adjust_line_dof_index_for_line_orientation_table.size()== - this->dofs_per_line, ExcInternalError()); + this->dofs_per_line, ExcInternalError()); index = 0; for (unsigned int b=0; bn_base_elements();++b) { const std::vector &temp2 - = this->base_element(b).adjust_line_dof_index_for_line_orientation_table; + = this->base_element(b).adjust_line_dof_index_for_line_orientation_table; for (unsigned int c=0; celement_multiplicity(b); ++c) - { - std::copy(temp2.begin(), temp2.end(), - this->adjust_line_dof_index_for_line_orientation_table.begin() - +index); - index += temp2.size(); - } + { + std::copy(temp2.begin(), temp2.end(), + this->adjust_line_dof_index_for_line_orientation_table.begin() + +index); + index += temp2.size(); + } } Assert (index == this->dofs_per_line, - ExcInternalError()); + ExcInternalError()); } @@ -2206,124 +2206,124 @@ template void FESystem:: get_face_interpolation_matrix (const FiniteElement &x_source_fe, - FullMatrix &interpolation_matrix) const + FullMatrix &interpolation_matrix) const { typedef FiniteElement FEL; AssertThrow ((x_source_fe.get_name().find ("FE_System<") == 0) - || - (dynamic_cast*>(&x_source_fe) != 0), - typename FEL:: - ExcInterpolationNotImplemented()); + || + (dynamic_cast*>(&x_source_fe) != 0), + typename FEL:: + ExcInterpolationNotImplemented()); Assert (interpolation_matrix.n() == this->dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.n(), - this->dofs_per_face)); + ExcDimensionMismatch (interpolation_matrix.n(), + this->dofs_per_face)); Assert (interpolation_matrix.m() == x_source_fe.dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.m(), - x_source_fe.dofs_per_face)); - - // since dofs for each base are - // independent, we only have to stack - // things up from base element to base - // element - // - // the problem is that we have to work with - // two FEs (this and fe_other). only deal - // with the case that both are FESystems - // and that they both have the same number - // of bases (counting multiplicity) each of - // which match in their number of - // components. this covers - // FESystem(FE_Q(p),1,FE_Q(q),2) vs - // FESystem(FE_Q(r),2,FE_Q(s),1), but not - // FESystem(FE_Q(p),1,FE_Q(q),2) vs - // FESystem(FESystem(FE_Q(r),2),1,FE_Q(s),1) + ExcDimensionMismatch (interpolation_matrix.m(), + x_source_fe.dofs_per_face)); + + // since dofs for each base are + // independent, we only have to stack + // things up from base element to base + // element + // + // the problem is that we have to work with + // two FEs (this and fe_other). only deal + // with the case that both are FESystems + // and that they both have the same number + // of bases (counting multiplicity) each of + // which match in their number of + // components. this covers + // FESystem(FE_Q(p),1,FE_Q(q),2) vs + // FESystem(FE_Q(r),2,FE_Q(s),1), but not + // FESystem(FE_Q(p),1,FE_Q(q),2) vs + // FESystem(FESystem(FE_Q(r),2),1,FE_Q(s),1) const FESystem *fe_other_system = dynamic_cast*>(&x_source_fe); - // clear matrix, since we will not get to - // set all elements + // clear matrix, since we will not get to + // set all elements interpolation_matrix = 0; - // loop over all the base elements of - // this and the other element, counting - // their multiplicities + // loop over all the base elements of + // this and the other element, counting + // their multiplicities unsigned int base_index = 0, - base_index_other = 0; + base_index_other = 0; unsigned int multiplicity = 0, - multiplicity_other = 0; + multiplicity_other = 0; FullMatrix base_to_base_interpolation; while (true) { const FiniteElement - &base = base_element(base_index), - &base_other = fe_other_system->base_element(base_index_other); + &base = base_element(base_index), + &base_other = fe_other_system->base_element(base_index_other); Assert (base.n_components() == base_other.n_components(), - ExcNotImplemented()); + ExcNotImplemented()); - // get the interpolation from the bases + // get the interpolation from the bases base_to_base_interpolation.reinit (base_other.dofs_per_face, - base.dofs_per_face); + base.dofs_per_face); base.get_face_interpolation_matrix (base_other, - base_to_base_interpolation); + base_to_base_interpolation); - // now translate entries. we'd like to - // have something like - // face_base_to_system_index, but that - // doesn't exist. rather, all we have - // is the reverse. well, use that then + // now translate entries. we'd like to + // have something like + // face_base_to_system_index, but that + // doesn't exist. rather, all we have + // is the reverse. well, use that then for (unsigned int i=0; idofs_per_face; ++i) - if (this->face_system_to_base_index(i).first - == - std::make_pair (base_index, multiplicity)) - for (unsigned int j=0; jdofs_per_face; ++j) - if (fe_other_system->face_system_to_base_index(j).first - == - std::make_pair (base_index_other, multiplicity_other)) - interpolation_matrix(j, i) - = base_to_base_interpolation(fe_other_system->face_system_to_base_index(j).second, - this->face_system_to_base_index(i).second); - - // advance to the next base element - // for this and the other - // fe_system; see if we can simply - // advance the multiplicity by one, - // or if have to move on to the - // next base element + if (this->face_system_to_base_index(i).first + == + std::make_pair (base_index, multiplicity)) + for (unsigned int j=0; jdofs_per_face; ++j) + if (fe_other_system->face_system_to_base_index(j).first + == + std::make_pair (base_index_other, multiplicity_other)) + interpolation_matrix(j, i) + = base_to_base_interpolation(fe_other_system->face_system_to_base_index(j).second, + this->face_system_to_base_index(i).second); + + // advance to the next base element + // for this and the other + // fe_system; see if we can simply + // advance the multiplicity by one, + // or if have to move on to the + // next base element ++multiplicity; if (multiplicity == this->element_multiplicity(base_index)) - { - multiplicity = 0; - ++base_index; - } + { + multiplicity = 0; + ++base_index; + } ++multiplicity_other; if (multiplicity_other == - fe_other_system->element_multiplicity(base_index_other)) - { - multiplicity_other = 0; - ++base_index_other; - } - - // see if we have reached the end - // of the present element. if so, - // we should have reached the end - // of the other one as well + fe_other_system->element_multiplicity(base_index_other)) + { + multiplicity_other = 0; + ++base_index_other; + } + + // see if we have reached the end + // of the present element. if so, + // we should have reached the end + // of the other one as well if (base_index == this->n_base_elements()) - { - Assert (base_index_other == fe_other_system->n_base_elements(), - ExcInternalError()); - break; - } - - // if we haven't reached the end of - // this element, we shouldn't have - // reached the end of the other one - // either + { + Assert (base_index_other == fe_other_system->n_base_elements(), + ExcInternalError()); + break; + } + + // if we haven't reached the end of + // this element, we shouldn't have + // reached the end of the other one + // either Assert (base_index_other != fe_other_system->n_base_elements(), - ExcInternalError()); + ExcInternalError()); } } @@ -2333,126 +2333,126 @@ template void FESystem:: get_subface_interpolation_matrix (const FiniteElement &x_source_fe, - const unsigned int subface, - FullMatrix &interpolation_matrix) const + const unsigned int subface, + FullMatrix &interpolation_matrix) const { typedef FiniteElement FEL; AssertThrow ((x_source_fe.get_name().find ("FE_System<") == 0) - || - (dynamic_cast*>(&x_source_fe) != 0), - typename FEL:: - ExcInterpolationNotImplemented()); + || + (dynamic_cast*>(&x_source_fe) != 0), + typename FEL:: + ExcInterpolationNotImplemented()); Assert (interpolation_matrix.n() == this->dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.n(), - this->dofs_per_face)); + ExcDimensionMismatch (interpolation_matrix.n(), + this->dofs_per_face)); Assert (interpolation_matrix.m() == x_source_fe.dofs_per_face, - ExcDimensionMismatch (interpolation_matrix.m(), - x_source_fe.dofs_per_face)); - - // since dofs for each base are - // independent, we only have to stack - // things up from base element to base - // element - // - // the problem is that we have to work with - // two FEs (this and fe_other). only deal - // with the case that both are FESystems - // and that they both have the same number - // of bases (counting multiplicity) each of - // which match in their number of - // components. this covers - // FESystem(FE_Q(p),1,FE_Q(q),2) vs - // FESystem(FE_Q(r),2,FE_Q(s),1), but not - // FESystem(FE_Q(p),1,FE_Q(q),2) vs - // FESystem(FESystem(FE_Q(r),2),1,FE_Q(s),1) + ExcDimensionMismatch (interpolation_matrix.m(), + x_source_fe.dofs_per_face)); + + // since dofs for each base are + // independent, we only have to stack + // things up from base element to base + // element + // + // the problem is that we have to work with + // two FEs (this and fe_other). only deal + // with the case that both are FESystems + // and that they both have the same number + // of bases (counting multiplicity) each of + // which match in their number of + // components. this covers + // FESystem(FE_Q(p),1,FE_Q(q),2) vs + // FESystem(FE_Q(r),2,FE_Q(s),1), but not + // FESystem(FE_Q(p),1,FE_Q(q),2) vs + // FESystem(FESystem(FE_Q(r),2),1,FE_Q(s),1) const FESystem *fe_other_system = dynamic_cast*>(&x_source_fe); - // clear matrix, since we will not get to - // set all elements + // clear matrix, since we will not get to + // set all elements interpolation_matrix = 0; - // loop over all the base elements of - // this and the other element, counting - // their multiplicities + // loop over all the base elements of + // this and the other element, counting + // their multiplicities unsigned int base_index = 0, - base_index_other = 0; + base_index_other = 0; unsigned int multiplicity = 0, - multiplicity_other = 0; + multiplicity_other = 0; FullMatrix base_to_base_interpolation; while (true) { const FiniteElement - &base = base_element(base_index), - &base_other = fe_other_system->base_element(base_index_other); + &base = base_element(base_index), + &base_other = fe_other_system->base_element(base_index_other); Assert (base.n_components() == base_other.n_components(), - ExcNotImplemented()); + ExcNotImplemented()); - // get the interpolation from the bases + // get the interpolation from the bases base_to_base_interpolation.reinit (base_other.dofs_per_face, - base.dofs_per_face); + base.dofs_per_face); base.get_subface_interpolation_matrix (base_other, - subface, - base_to_base_interpolation); - - // now translate entries. we'd like to - // have something like - // face_base_to_system_index, but that - // doesn't exist. rather, all we have - // is the reverse. well, use that then + subface, + base_to_base_interpolation); + + // now translate entries. we'd like to + // have something like + // face_base_to_system_index, but that + // doesn't exist. rather, all we have + // is the reverse. well, use that then for (unsigned int i=0; idofs_per_face; ++i) - if (this->face_system_to_base_index(i).first - == - std::make_pair (base_index, multiplicity)) - for (unsigned int j=0; jdofs_per_face; ++j) - if (fe_other_system->face_system_to_base_index(j).first - == - std::make_pair (base_index_other, multiplicity_other)) - interpolation_matrix(j, i) - = base_to_base_interpolation(fe_other_system->face_system_to_base_index(j).second, - this->face_system_to_base_index(i).second); - - // advance to the next base element - // for this and the other - // fe_system; see if we can simply - // advance the multiplicity by one, - // or if have to move on to the - // next base element + if (this->face_system_to_base_index(i).first + == + std::make_pair (base_index, multiplicity)) + for (unsigned int j=0; jdofs_per_face; ++j) + if (fe_other_system->face_system_to_base_index(j).first + == + std::make_pair (base_index_other, multiplicity_other)) + interpolation_matrix(j, i) + = base_to_base_interpolation(fe_other_system->face_system_to_base_index(j).second, + this->face_system_to_base_index(i).second); + + // advance to the next base element + // for this and the other + // fe_system; see if we can simply + // advance the multiplicity by one, + // or if have to move on to the + // next base element ++multiplicity; if (multiplicity == this->element_multiplicity(base_index)) - { - multiplicity = 0; - ++base_index; - } + { + multiplicity = 0; + ++base_index; + } ++multiplicity_other; if (multiplicity_other == - fe_other_system->element_multiplicity(base_index_other)) - { - multiplicity_other = 0; - ++base_index_other; - } - - // see if we have reached the end - // of the present element. if so, - // we should have reached the end - // of the other one as well + fe_other_system->element_multiplicity(base_index_other)) + { + multiplicity_other = 0; + ++base_index_other; + } + + // see if we have reached the end + // of the present element. if so, + // we should have reached the end + // of the other one as well if (base_index == this->n_base_elements()) - { - Assert (base_index_other == fe_other_system->n_base_elements(), - ExcInternalError()); - break; - } - - // if we haven't reached the end of - // this element, we shouldn't have - // reached the end of the other one - // either + { + Assert (base_index_other == fe_other_system->n_base_elements(), + ExcInternalError()); + break; + } + + // if we haven't reached the end of + // this element, we shouldn't have + // reached the end of the other one + // either Assert (base_index_other != fe_other_system->n_base_elements(), - ExcInternalError()); + ExcInternalError()); } } @@ -2463,121 +2463,121 @@ template std::vector > FESystem::hp_object_dof_identities (const FiniteElement &fe_other) const { - // since dofs on each subobject (vertex, - // line, ...) are ordered such that first - // come all from the first base element all - // multiplicities, then second base element - // all multiplicities, etc., we simply have - // to stack all the identities after each - // other - // - // the problem is that we have to work with - // two FEs (this and fe_other). only deal - // with the case that both are FESystems - // and that they both have the same number - // of bases (counting multiplicity) each of - // which match in their number of - // components. this covers - // FESystem(FE_Q(p),1,FE_Q(q),2) vs - // FESystem(FE_Q(r),2,FE_Q(s),1), but not - // FESystem(FE_Q(p),1,FE_Q(q),2) vs - // FESystem(FESystem(FE_Q(r),2),1,FE_Q(s),1) + // since dofs on each subobject (vertex, + // line, ...) are ordered such that first + // come all from the first base element all + // multiplicities, then second base element + // all multiplicities, etc., we simply have + // to stack all the identities after each + // other + // + // the problem is that we have to work with + // two FEs (this and fe_other). only deal + // with the case that both are FESystems + // and that they both have the same number + // of bases (counting multiplicity) each of + // which match in their number of + // components. this covers + // FESystem(FE_Q(p),1,FE_Q(q),2) vs + // FESystem(FE_Q(r),2,FE_Q(s),1), but not + // FESystem(FE_Q(p),1,FE_Q(q),2) vs + // FESystem(FESystem(FE_Q(r),2),1,FE_Q(s),1) if (const FESystem *fe_other_system = dynamic_cast*>(&fe_other)) { - // loop over all the base elements of - // this and the other element, counting - // their multiplicities + // loop over all the base elements of + // this and the other element, counting + // their multiplicities unsigned int base_index = 0, - base_index_other = 0; + base_index_other = 0; unsigned int multiplicity = 0, - multiplicity_other = 0; + multiplicity_other = 0; - // we also need to keep track of the - // number of dofs already treated for - // each of the elements + // we also need to keep track of the + // number of dofs already treated for + // each of the elements unsigned int dof_offset = 0, - dof_offset_other = 0; + dof_offset_other = 0; std::vector > identities; while (true) - { - const FiniteElement - &base = base_element(base_index), - &base_other = fe_other_system->base_element(base_index_other); - - Assert (base.n_components() == base_other.n_components(), - ExcNotImplemented()); - - // now translate the identities - // returned by the base elements to - // the indices of this system - // element - std::vector > base_identities; - switch (structdim) - { - case 0: - base_identities = base.hp_vertex_dof_identities (base_other); - break; - case 1: - base_identities = base.hp_line_dof_identities (base_other); - break; - case 2: - base_identities = base.hp_quad_dof_identities (base_other); - break; - default: - Assert (false, ExcNotImplemented()); - } - - for (unsigned int i=0; i(); - dof_offset_other += base_other.template n_dofs_per_object(); - - // advance to the next base element - // for this and the other - // fe_system; see if we can simply - // advance the multiplicity by one, - // or if have to move on to the - // next base element - ++multiplicity; - if (multiplicity == this->element_multiplicity(base_index)) - { - multiplicity = 0; - ++base_index; - } - ++multiplicity_other; - if (multiplicity_other == - fe_other_system->element_multiplicity(base_index_other)) - { - multiplicity_other = 0; - ++base_index_other; - } - - // see if we have reached the end - // of the present element. if so, - // we should have reached the end - // of the other one as well - if (base_index == this->n_base_elements()) - { - Assert (base_index_other == fe_other_system->n_base_elements(), - ExcInternalError()); - break; - } - - // if we haven't reached the end of - // this element, we shouldn't have - // reached the end of the other one - // either - Assert (base_index_other != fe_other_system->n_base_elements(), - ExcInternalError()); - } + { + const FiniteElement + &base = base_element(base_index), + &base_other = fe_other_system->base_element(base_index_other); + + Assert (base.n_components() == base_other.n_components(), + ExcNotImplemented()); + + // now translate the identities + // returned by the base elements to + // the indices of this system + // element + std::vector > base_identities; + switch (structdim) + { + case 0: + base_identities = base.hp_vertex_dof_identities (base_other); + break; + case 1: + base_identities = base.hp_line_dof_identities (base_other); + break; + case 2: + base_identities = base.hp_quad_dof_identities (base_other); + break; + default: + Assert (false, ExcNotImplemented()); + } + + for (unsigned int i=0; i(); + dof_offset_other += base_other.template n_dofs_per_object(); + + // advance to the next base element + // for this and the other + // fe_system; see if we can simply + // advance the multiplicity by one, + // or if have to move on to the + // next base element + ++multiplicity; + if (multiplicity == this->element_multiplicity(base_index)) + { + multiplicity = 0; + ++base_index; + } + ++multiplicity_other; + if (multiplicity_other == + fe_other_system->element_multiplicity(base_index_other)) + { + multiplicity_other = 0; + ++base_index_other; + } + + // see if we have reached the end + // of the present element. if so, + // we should have reached the end + // of the other one as well + if (base_index == this->n_base_elements()) + { + Assert (base_index_other == fe_other_system->n_base_elements(), + ExcInternalError()); + break; + } + + // if we haven't reached the end of + // this element, we shouldn't have + // reached the end of the other one + // either + Assert (base_index_other != fe_other_system->n_base_elements(), + ExcInternalError()); + } return identities; } @@ -2620,46 +2620,46 @@ FiniteElementDomination::Domination FESystem:: compare_for_face_domination (const FiniteElement &fe_other) const { - // at present all we can do is to compare - // with other FESystems that have the same - // number of components and bases + // at present all we can do is to compare + // with other FESystems that have the same + // number of components and bases if (const FESystem *fe_sys_other = dynamic_cast*>(&fe_other)) { Assert (this->n_components() == fe_sys_other->n_components(), - ExcNotImplemented()); + ExcNotImplemented()); Assert (this->n_base_elements() == fe_sys_other->n_base_elements(), - ExcNotImplemented()); + ExcNotImplemented()); FiniteElementDomination::Domination - domination = FiniteElementDomination::no_requirements; + domination = FiniteElementDomination::no_requirements; - // loop over all base elements and do - // some sanity checks + // loop over all base elements and do + // some sanity checks for (unsigned int b=0; bn_base_elements(); ++b) - { - Assert (this->base_element(b).n_components() == - fe_sys_other->base_element(b).n_components(), - ExcNotImplemented()); - Assert (this->element_multiplicity(b) == - fe_sys_other->element_multiplicity(b), - ExcNotImplemented()); - - // for this pair of base elements, - // check who dominates and combine - // with previous result - const FiniteElementDomination::Domination - base_domination = (this->base_element(b) - .compare_for_face_domination (fe_sys_other->base_element(b))); - domination = domination & base_domination; - } - - // if we've gotten here, then we've - // either found a winner or either - // element is fine being dominated + { + Assert (this->base_element(b).n_components() == + fe_sys_other->base_element(b).n_components(), + ExcNotImplemented()); + Assert (this->element_multiplicity(b) == + fe_sys_other->element_multiplicity(b), + ExcNotImplemented()); + + // for this pair of base elements, + // check who dominates and combine + // with previous result + const FiniteElementDomination::Domination + base_domination = (this->base_element(b) + .compare_for_face_domination (fe_sys_other->base_element(b))); + domination = domination & base_domination; + } + + // if we've gotten here, then we've + // either found a winner or either + // element is fine being dominated Assert (domination != - FiniteElementDomination::neither_element_dominates, - ExcInternalError()); + FiniteElementDomination::neither_element_dominates, + ExcInternalError()); return domination; } @@ -2673,9 +2673,9 @@ compare_for_face_domination (const FiniteElement &fe_other) const template FiniteElementData FESystem::multiply_dof_numbers (const FiniteElementData &fe1, - const unsigned int N1, - const FiniteElementData &fe2, - const unsigned int N2) + const unsigned int N1, + const FiniteElementData &fe2, + const unsigned int N2) { std::vector dpo; dpo.push_back(fe1.dofs_per_vertex * N1 + fe2.dofs_per_vertex * N2); @@ -2683,18 +2683,18 @@ FESystem::multiply_dof_numbers (const FiniteElementData &fe1, if (dim>1) dpo.push_back(fe1.dofs_per_quad * N1 + fe2.dofs_per_quad * N2); if (dim>2) dpo.push_back(fe1.dofs_per_hex * N1 + fe2.dofs_per_hex * N2); - // degree is the maximal degree of - // the components. max also makes - // sure that one unknown degree - // makes the degree of the system - // unknown. + // degree is the maximal degree of + // the components. max also makes + // sure that one unknown degree + // makes the degree of the system + // unknown. unsigned int degree = std::max(fe1.tensor_degree(), fe2.tensor_degree()); return FiniteElementData ( dpo, fe1.n_components() * N1 + fe2.n_components() * N2, degree, typename FiniteElementData::Conformity(fe1.conforming_space - & fe2.conforming_space), + & fe2.conforming_space), N1 + N2); } @@ -2703,37 +2703,37 @@ FESystem::multiply_dof_numbers (const FiniteElementData &fe1, template FiniteElementData FESystem::multiply_dof_numbers (const FiniteElementData &fe1, - const unsigned int N1, - const FiniteElementData &fe2, - const unsigned int N2, - const FiniteElementData &fe3, - const unsigned int N3) + const unsigned int N1, + const FiniteElementData &fe2, + const unsigned int N2, + const FiniteElementData &fe3, + const unsigned int N3) { std::vector dpo; dpo.push_back(fe1.dofs_per_vertex * N1 + - fe2.dofs_per_vertex * N2 + - fe3.dofs_per_vertex * N3); + fe2.dofs_per_vertex * N2 + + fe3.dofs_per_vertex * N3); dpo.push_back(fe1.dofs_per_line * N1 + - fe2.dofs_per_line * N2 + - fe3.dofs_per_line * N3); + fe2.dofs_per_line * N2 + + fe3.dofs_per_line * N3); if (dim>1) dpo.push_back(fe1.dofs_per_quad * N1 + - fe2.dofs_per_quad * N2 + - fe3.dofs_per_quad * N3); + fe2.dofs_per_quad * N2 + + fe3.dofs_per_quad * N3); if (dim>2) dpo.push_back(fe1.dofs_per_hex * N1 + - fe2.dofs_per_hex * N2 + - fe3.dofs_per_hex * N3); - // degree is the maximal degree of the components + fe2.dofs_per_hex * N2 + + fe3.dofs_per_hex * N3); + // degree is the maximal degree of the components const unsigned int degree = std::max (std::max(fe1.tensor_degree(), - fe2.tensor_degree()), - fe3.tensor_degree()); + fe2.tensor_degree()), + fe3.tensor_degree()); return FiniteElementData ( dpo, fe1.n_components() * N1 + fe2.n_components() * N2 + fe3.n_components() * N3, degree, typename FiniteElementData::Conformity(fe1.conforming_space - & fe2.conforming_space - & fe3.conforming_space), + & fe2.conforming_space + & fe3.conforming_space), N1 + N2 + N3); } @@ -2742,32 +2742,32 @@ FESystem::multiply_dof_numbers (const FiniteElementData &fe1, template FiniteElementData FESystem::multiply_dof_numbers (const FiniteElementData &fe1, - const unsigned int N1, - const FiniteElementData &fe2, - const unsigned int N2, - const FiniteElementData &fe3, - const unsigned int N3, - const FiniteElementData &fe4, - const unsigned int N4) + const unsigned int N1, + const FiniteElementData &fe2, + const unsigned int N2, + const FiniteElementData &fe3, + const unsigned int N3, + const FiniteElementData &fe4, + const unsigned int N4) { std::vector dpo; dpo.push_back(fe1.dofs_per_vertex * N1 + - fe2.dofs_per_vertex * N2 + - fe3.dofs_per_vertex * N3 + - fe4.dofs_per_vertex * N4); + fe2.dofs_per_vertex * N2 + + fe3.dofs_per_vertex * N3 + + fe4.dofs_per_vertex * N4); dpo.push_back(fe1.dofs_per_line * N1 + - fe2.dofs_per_line * N2 + - fe3.dofs_per_line * N3 + - fe4.dofs_per_line * N4); + fe2.dofs_per_line * N2 + + fe3.dofs_per_line * N3 + + fe4.dofs_per_line * N4); if (dim>1) dpo.push_back(fe1.dofs_per_quad * N1 + - fe2.dofs_per_quad * N2 + - fe3.dofs_per_quad * N3 + - fe4.dofs_per_quad * N4); + fe2.dofs_per_quad * N2 + + fe3.dofs_per_quad * N3 + + fe4.dofs_per_quad * N4); if (dim>2) dpo.push_back(fe1.dofs_per_hex * N1 + - fe2.dofs_per_hex * N2 + - fe3.dofs_per_hex * N3 + - fe4.dofs_per_hex * N4); - // degree is the maximal degree of the components + fe2.dofs_per_hex * N2 + + fe3.dofs_per_hex * N3 + + fe4.dofs_per_hex * N4); + // degree is the maximal degree of the components const unsigned int degree = std::max(std::max (std::max(fe1.tensor_degree(),fe2.tensor_degree()),fe3.tensor_degree()), fe4.tensor_degree()); @@ -2777,9 +2777,9 @@ FESystem::multiply_dof_numbers (const FiniteElementData &fe1, fe4.n_components() * N4, degree, typename FiniteElementData::Conformity(fe1.conforming_space - & fe2.conforming_space - & fe3.conforming_space - & fe4.conforming_space), + & fe2.conforming_space + & fe3.conforming_space + & fe4.conforming_space), N1 + N2 + N3 + N4); } @@ -2787,38 +2787,38 @@ FESystem::multiply_dof_numbers (const FiniteElementData &fe1, template FiniteElementData FESystem::multiply_dof_numbers (const FiniteElementData &fe1, - const unsigned int N1, - const FiniteElementData &fe2, - const unsigned int N2, - const FiniteElementData &fe3, - const unsigned int N3, - const FiniteElementData &fe4, - const unsigned int N4, - const FiniteElementData &fe5, - const unsigned int N5) + const unsigned int N1, + const FiniteElementData &fe2, + const unsigned int N2, + const FiniteElementData &fe3, + const unsigned int N3, + const FiniteElementData &fe4, + const unsigned int N4, + const FiniteElementData &fe5, + const unsigned int N5) { std::vector dpo; dpo.push_back(fe1.dofs_per_vertex * N1 + - fe2.dofs_per_vertex * N2 + - fe3.dofs_per_vertex * N3 + - fe4.dofs_per_vertex * N4 + - fe5.dofs_per_vertex * N5); + fe2.dofs_per_vertex * N2 + + fe3.dofs_per_vertex * N3 + + fe4.dofs_per_vertex * N4 + + fe5.dofs_per_vertex * N5); dpo.push_back(fe1.dofs_per_line * N1 + - fe2.dofs_per_line * N2 + - fe3.dofs_per_line * N3 + - fe4.dofs_per_line * N4 + - fe5.dofs_per_line * N5); + fe2.dofs_per_line * N2 + + fe3.dofs_per_line * N3 + + fe4.dofs_per_line * N4 + + fe5.dofs_per_line * N5); if (dim>1) dpo.push_back(fe1.dofs_per_quad * N1 + - fe2.dofs_per_quad * N2 + - fe3.dofs_per_quad * N3 + - fe4.dofs_per_quad * N4 + - fe5.dofs_per_quad * N5); + fe2.dofs_per_quad * N2 + + fe3.dofs_per_quad * N3 + + fe4.dofs_per_quad * N4 + + fe5.dofs_per_quad * N5); if (dim>2) dpo.push_back(fe1.dofs_per_hex * N1 + - fe2.dofs_per_hex * N2 + - fe3.dofs_per_hex * N3 + - fe4.dofs_per_hex * N4 + - fe5.dofs_per_hex * N5); - // degree is the maximal degree of the components + fe2.dofs_per_hex * N2 + + fe3.dofs_per_hex * N3 + + fe4.dofs_per_hex * N4 + + fe5.dofs_per_hex * N5); + // degree is the maximal degree of the components const unsigned int degree = std::max(std::max(std::max (std::max(fe1.tensor_degree(),fe2.tensor_degree()),fe3.tensor_degree()), fe4.tensor_degree()), fe5.tensor_degree()); @@ -2828,10 +2828,10 @@ FESystem::multiply_dof_numbers (const FiniteElementData &fe1, fe4.n_components() * N4 + fe5.n_components() * N5, degree, typename FiniteElementData::Conformity(fe1.conforming_space - & fe2.conforming_space - & fe3.conforming_space - & fe4.conforming_space - & fe5.conforming_space), + & fe2.conforming_space + & fe3.conforming_space + & fe4.conforming_space + & fe5.conforming_space), N1 + N2 + N3 + N4 + N5); } @@ -2895,7 +2895,7 @@ FESystem::multiply_dof_numbers ( template std::vector FESystem::compute_restriction_is_additive_flags (const FiniteElement &fe, - const unsigned int n_elements) + const unsigned int n_elements) { std::vector*> fe_list; std::vector multiplicities; @@ -2911,9 +2911,9 @@ FESystem::compute_restriction_is_additive_flags (const FiniteEleme template std::vector FESystem::compute_restriction_is_additive_flags (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2) + const unsigned int N1, + const FiniteElement &fe2, + const unsigned int N2) { std::vector*> fe_list; std::vector multiplicities; @@ -2932,11 +2932,11 @@ FESystem::compute_restriction_is_additive_flags (const FiniteEleme template std::vector FESystem::compute_restriction_is_additive_flags (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2, - const FiniteElement &fe3, - const unsigned int N3) + const unsigned int N1, + const FiniteElement &fe2, + const unsigned int N2, + const FiniteElement &fe3, + const unsigned int N3) { std::vector*> fe_list; std::vector multiplicities; @@ -2957,13 +2957,13 @@ FESystem::compute_restriction_is_additive_flags (const FiniteEleme template std::vector FESystem::compute_restriction_is_additive_flags (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2, - const FiniteElement &fe3, - const unsigned int N3, - const FiniteElement &fe4, - const unsigned int N4) + const unsigned int N1, + const FiniteElement &fe2, + const unsigned int N2, + const FiniteElement &fe3, + const unsigned int N3, + const FiniteElement &fe4, + const unsigned int N4) { std::vector*> fe_list; std::vector multiplicities; @@ -2987,15 +2987,15 @@ FESystem::compute_restriction_is_additive_flags (const FiniteEleme template std::vector FESystem::compute_restriction_is_additive_flags (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2, - const FiniteElement &fe3, - const unsigned int N3, - const FiniteElement &fe4, - const unsigned int N4, - const FiniteElement &fe5, - const unsigned int N5) + const unsigned int N1, + const FiniteElement &fe2, + const unsigned int N2, + const FiniteElement &fe3, + const unsigned int N3, + const FiniteElement &fe4, + const unsigned int N4, + const FiniteElement &fe5, + const unsigned int N5) { std::vector*> fe_list; std::vector multiplicities; @@ -3026,121 +3026,121 @@ compute_restriction_is_additive_flags (const std::vectordofs_per_cell * multiplicities[i]; - // generate the array that will - // hold the output + // generate the array that will + // hold the output std::vector retval (n_shape_functions, false); - // finally go through all the shape - // functions of the base elements, - // and copy their flags. this - // somehow copies the code in - // build_cell_table, which is not - // nice as it uses too much - // implicit knowledge about the - // layout of the individual bases - // in the composed FE, but there - // seems no way around... - // - // for each shape function, copy - // the flags from the base element - // to this one, taking into account - // multiplicities, and other - // complications + // finally go through all the shape + // functions of the base elements, + // and copy their flags. this + // somehow copies the code in + // build_cell_table, which is not + // nice as it uses too much + // implicit knowledge about the + // layout of the individual bases + // in the composed FE, but there + // seems no way around... + // + // for each shape function, copy + // the flags from the base element + // to this one, taking into account + // multiplicities, and other + // complications unsigned int total_index = 0; for (unsigned int vertex_number=0; vertex_number::vertices_per_cell; ++vertex_number) { for(unsigned int base=0; basedofs_per_vertex; - ++local_index, ++total_index) - { - const unsigned int index_in_base - = (fes[base]->dofs_per_vertex*vertex_number + - local_index); + for (unsigned int m=0; mdofs_per_vertex; + ++local_index, ++total_index) + { + const unsigned int index_in_base + = (fes[base]->dofs_per_vertex*vertex_number + + local_index); Assert (index_in_base < fes[base]->dofs_per_cell, ExcInternalError()); retval[total_index] = fes[base]->restriction_is_additive(index_in_base); - } + } } - // 2. Lines + // 2. Lines if (GeometryInfo::lines_per_cell > 0) for (unsigned int line_number= 0; - line_number != GeometryInfo::lines_per_cell; - ++line_number) + line_number != GeometryInfo::lines_per_cell; + ++line_number) { - for (unsigned int base=0; basedofs_per_line; - ++local_index, ++total_index) - { - const unsigned int index_in_base - = (fes[base]->dofs_per_line*line_number + - local_index + - fes[base]->first_line_index); + for (unsigned int base=0; basedofs_per_line; + ++local_index, ++total_index) + { + const unsigned int index_in_base + = (fes[base]->dofs_per_line*line_number + + local_index + + fes[base]->first_line_index); Assert (index_in_base < fes[base]->dofs_per_cell, ExcInternalError()); retval[total_index] = fes[base]->restriction_is_additive(index_in_base); - } + } } - // 3. Quads + // 3. Quads if (GeometryInfo::quads_per_cell > 0) for (unsigned int quad_number= 0; - quad_number != GeometryInfo::quads_per_cell; - ++quad_number) + quad_number != GeometryInfo::quads_per_cell; + ++quad_number) { - for (unsigned int base=0; basedofs_per_quad; - ++local_index, ++total_index) - { - const unsigned int index_in_base - = (fes[base]->dofs_per_quad*quad_number + - local_index + - fes[base]->first_quad_index); + for (unsigned int base=0; basedofs_per_quad; + ++local_index, ++total_index) + { + const unsigned int index_in_base + = (fes[base]->dofs_per_quad*quad_number + + local_index + + fes[base]->first_quad_index); Assert (index_in_base < fes[base]->dofs_per_cell, ExcInternalError()); retval[total_index] = fes[base]->restriction_is_additive(index_in_base); - } + } } - // 4. Hexes + // 4. Hexes if (GeometryInfo::hexes_per_cell > 0) for (unsigned int hex_number= 0; - hex_number != GeometryInfo::hexes_per_cell; - ++hex_number) + hex_number != GeometryInfo::hexes_per_cell; + ++hex_number) { - for(unsigned int base=0; basedofs_per_hex; - ++local_index, ++total_index) - { - const unsigned int index_in_base - = (fes[base]->dofs_per_hex*hex_number + - local_index + - fes[base]->first_hex_index); + for(unsigned int base=0; basedofs_per_hex; + ++local_index, ++total_index) + { + const unsigned int index_in_base + = (fes[base]->dofs_per_hex*hex_number + + local_index + + fes[base]->first_hex_index); Assert (index_in_base < fes[base]->dofs_per_cell, ExcInternalError()); retval[total_index] = fes[base]->restriction_is_additive(index_in_base); - } + } } Assert (total_index == n_shape_functions, ExcInternalError()); @@ -3153,7 +3153,7 @@ compute_restriction_is_additive_flags (const std::vector std::vector > FESystem::compute_nonzero_components (const FiniteElement &fe1, - const unsigned int N1) + const unsigned int N1) { std::vector*> fe_list; std::vector multiplicities; @@ -3169,9 +3169,9 @@ FESystem::compute_nonzero_components (const FiniteElement std::vector > FESystem::compute_nonzero_components (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2) + const unsigned int N1, + const FiniteElement &fe2, + const unsigned int N2) { std::vector*> fe_list; std::vector multiplicities; @@ -3190,11 +3190,11 @@ FESystem::compute_nonzero_components (const FiniteElement std::vector > FESystem::compute_nonzero_components (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2, - const FiniteElement &fe3, - const unsigned int N3) + const unsigned int N1, + const FiniteElement &fe2, + const unsigned int N2, + const FiniteElement &fe3, + const unsigned int N3) { std::vector*> fe_list; std::vector multiplicities; @@ -3216,13 +3216,13 @@ FESystem::compute_nonzero_components (const FiniteElement std::vector > FESystem::compute_nonzero_components (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2, - const FiniteElement &fe3, - const unsigned int N3, - const FiniteElement &fe4, - const unsigned int N4) + const unsigned int N1, + const FiniteElement &fe2, + const unsigned int N2, + const FiniteElement &fe3, + const unsigned int N3, + const FiniteElement &fe4, + const unsigned int N4) { std::vector*> fe_list; std::vector multiplicities; @@ -3247,15 +3247,15 @@ FESystem::compute_nonzero_components (const FiniteElement std::vector > FESystem::compute_nonzero_components (const FiniteElement &fe1, - const unsigned int N1, - const FiniteElement &fe2, - const unsigned int N2, - const FiniteElement &fe3, - const unsigned int N3, - const FiniteElement &fe4, - const unsigned int N4, - const FiniteElement &fe5, - const unsigned int N5) + const unsigned int N1, + const FiniteElement &fe2, + const unsigned int N2, + const FiniteElement &fe3, + const unsigned int N3, + const FiniteElement &fe4, + const unsigned int N4, + const FiniteElement &fe5, + const unsigned int N5) { std::vector*> fe_list; std::vector multiplicities; @@ -3284,13 +3284,13 @@ template std::vector > FESystem:: compute_nonzero_components (const std::vector*> &fes, - const std::vector &multiplicities) + const std::vector &multiplicities) { Assert (fes.size() == multiplicities.size(), ExcInternalError()); - // first count the number of dofs - // and components that will emerge - // from the given FEs + // first count the number of dofs + // and components that will emerge + // from the given FEs unsigned int n_shape_functions = 0; for (unsigned int i=0; idofs_per_cell * multiplicities[i]; @@ -3299,28 +3299,28 @@ compute_nonzero_components (const std::vector* for (unsigned int i=0; in_components() * multiplicities[i]; - // generate the array that will - // hold the output + // generate the array that will + // hold the output std::vector > retval (n_shape_functions, std::vector (n_components, false)); - // finally go through all the shape - // functions of the base elements, - // and copy their flags. this - // somehow copies the code in - // build_cell_table, which is not - // nice as it uses too much - // implicit knowledge about the - // layout of the individual bases - // in the composed FE, but there - // seems no way around... - // - // for each shape function, copy - // the non-zero flags from the base - // element to this one, taking into - // account multiplicities, multiple - // components in base elements, and - // other complications + // finally go through all the shape + // functions of the base elements, + // and copy their flags. this + // somehow copies the code in + // build_cell_table, which is not + // nice as it uses too much + // implicit knowledge about the + // layout of the individual bases + // in the composed FE, but there + // seems no way around... + // + // for each shape function, copy + // the non-zero flags from the base + // element to this one, taking into + // account multiplicities, multiple + // components in base elements, and + // other complications unsigned int total_index = 0; for (unsigned int vertex_number=0; vertex_number::vertices_per_cell; @@ -3328,131 +3328,131 @@ compute_nonzero_components (const std::vector* { unsigned comp_start = 0; for(unsigned int base=0; basen_components()) - for (unsigned int local_index = 0; - local_index < fes[base]->dofs_per_vertex; - ++local_index, ++total_index) - { - const unsigned int index_in_base - = (fes[base]->dofs_per_vertex*vertex_number + - local_index); - - Assert (comp_start+fes[base]->n_components() <= - retval[total_index].size(), - ExcInternalError()); - for (unsigned int c=0; cn_components(); ++c) - { - Assert (index_in_base < fes[base]->nonzero_components.size(), - ExcInternalError()); - Assert (c < fes[base]->nonzero_components[index_in_base].size(), - ExcInternalError()); - retval[total_index][comp_start+c] - = fes[base]->nonzero_components[index_in_base][c]; - }; - } + for (unsigned int m=0; mn_components()) + for (unsigned int local_index = 0; + local_index < fes[base]->dofs_per_vertex; + ++local_index, ++total_index) + { + const unsigned int index_in_base + = (fes[base]->dofs_per_vertex*vertex_number + + local_index); + + Assert (comp_start+fes[base]->n_components() <= + retval[total_index].size(), + ExcInternalError()); + for (unsigned int c=0; cn_components(); ++c) + { + Assert (index_in_base < fes[base]->nonzero_components.size(), + ExcInternalError()); + Assert (c < fes[base]->nonzero_components[index_in_base].size(), + ExcInternalError()); + retval[total_index][comp_start+c] + = fes[base]->nonzero_components[index_in_base][c]; + }; + } } - // 2. Lines + // 2. Lines if (GeometryInfo::lines_per_cell > 0) for (unsigned int line_number= 0; - line_number != GeometryInfo::lines_per_cell; - ++line_number) + line_number != GeometryInfo::lines_per_cell; + ++line_number) { - unsigned comp_start = 0; - for (unsigned int base=0; basen_components()) - for (unsigned int local_index = 0; - local_index < fes[base]->dofs_per_line; - ++local_index, ++total_index) - { - const unsigned int index_in_base - = (fes[base]->dofs_per_line*line_number + - local_index + - fes[base]->first_line_index); - - Assert (comp_start+fes[base]->n_components() <= - retval[total_index].size(), - ExcInternalError()); - for (unsigned int c=0; cn_components(); ++c) - { - Assert (index_in_base < fes[base]->nonzero_components.size(), - ExcInternalError()); - Assert (c < fes[base]->nonzero_components[index_in_base].size(), - ExcInternalError()); - retval[total_index][comp_start+c] - = fes[base]->nonzero_components[index_in_base][c]; - }; - } + unsigned comp_start = 0; + for (unsigned int base=0; basen_components()) + for (unsigned int local_index = 0; + local_index < fes[base]->dofs_per_line; + ++local_index, ++total_index) + { + const unsigned int index_in_base + = (fes[base]->dofs_per_line*line_number + + local_index + + fes[base]->first_line_index); + + Assert (comp_start+fes[base]->n_components() <= + retval[total_index].size(), + ExcInternalError()); + for (unsigned int c=0; cn_components(); ++c) + { + Assert (index_in_base < fes[base]->nonzero_components.size(), + ExcInternalError()); + Assert (c < fes[base]->nonzero_components[index_in_base].size(), + ExcInternalError()); + retval[total_index][comp_start+c] + = fes[base]->nonzero_components[index_in_base][c]; + }; + } } - // 3. Quads + // 3. Quads if (GeometryInfo::quads_per_cell > 0) for (unsigned int quad_number= 0; - quad_number != GeometryInfo::quads_per_cell; - ++quad_number) + quad_number != GeometryInfo::quads_per_cell; + ++quad_number) { - unsigned int comp_start = 0; - for (unsigned int base=0; basen_components()) - for (unsigned int local_index = 0; - local_index < fes[base]->dofs_per_quad; - ++local_index, ++total_index) - { - const unsigned int index_in_base - = (fes[base]->dofs_per_quad*quad_number + - local_index + - fes[base]->first_quad_index); - - Assert (comp_start+fes[base]->n_components() <= - retval[total_index].size(), - ExcInternalError()); - for (unsigned int c=0; cn_components(); ++c) - { - Assert (index_in_base < fes[base]->nonzero_components.size(), - ExcInternalError()); - Assert (c < fes[base]->nonzero_components[index_in_base].size(), - ExcInternalError()); - retval[total_index][comp_start+c] - = fes[base]->nonzero_components[index_in_base][c]; - }; - } + unsigned int comp_start = 0; + for (unsigned int base=0; basen_components()) + for (unsigned int local_index = 0; + local_index < fes[base]->dofs_per_quad; + ++local_index, ++total_index) + { + const unsigned int index_in_base + = (fes[base]->dofs_per_quad*quad_number + + local_index + + fes[base]->first_quad_index); + + Assert (comp_start+fes[base]->n_components() <= + retval[total_index].size(), + ExcInternalError()); + for (unsigned int c=0; cn_components(); ++c) + { + Assert (index_in_base < fes[base]->nonzero_components.size(), + ExcInternalError()); + Assert (c < fes[base]->nonzero_components[index_in_base].size(), + ExcInternalError()); + retval[total_index][comp_start+c] + = fes[base]->nonzero_components[index_in_base][c]; + }; + } } - // 4. Hexes + // 4. Hexes if (GeometryInfo::hexes_per_cell > 0) for (unsigned int hex_number= 0; - hex_number != GeometryInfo::hexes_per_cell; - ++hex_number) + hex_number != GeometryInfo::hexes_per_cell; + ++hex_number) { - unsigned int comp_start = 0; - for(unsigned int base=0; basen_components()) - for (unsigned int local_index = 0; - local_index < fes[base]->dofs_per_hex; - ++local_index, ++total_index) - { - const unsigned int index_in_base - = (fes[base]->dofs_per_hex*hex_number + - local_index + - fes[base]->first_hex_index); - - Assert (comp_start+fes[base]->n_components() <= - retval[total_index].size(), - ExcInternalError()); - for (unsigned int c=0; cn_components(); ++c) - { - Assert (index_in_base < fes[base]->nonzero_components.size(), - ExcInternalError()); - Assert (c < fes[base]->nonzero_components[index_in_base].size(), - ExcInternalError()); - retval[total_index][comp_start+c] - = fes[base]->nonzero_components[index_in_base][c]; - }; - } + unsigned int comp_start = 0; + for(unsigned int base=0; basen_components()) + for (unsigned int local_index = 0; + local_index < fes[base]->dofs_per_hex; + ++local_index, ++total_index) + { + const unsigned int index_in_base + = (fes[base]->dofs_per_hex*hex_number + + local_index + + fes[base]->first_hex_index); + + Assert (comp_start+fes[base]->n_components() <= + retval[total_index].size(), + ExcInternalError()); + for (unsigned int c=0; cn_components(); ++c) + { + Assert (index_in_base < fes[base]->nonzero_components.size(), + ExcInternalError()); + Assert (c < fes[base]->nonzero_components[index_in_base].size(), + ExcInternalError()); + retval[total_index][comp_start+c] + = fes[base]->nonzero_components[index_in_base][c]; + }; + } } Assert (total_index == n_shape_functions, ExcInternalError()); @@ -3468,7 +3468,7 @@ const FiniteElement & FESystem::base_element (const unsigned int index) const { Assert (index < base_elements.size(), - ExcIndexRange(index, 0, base_elements.size())); + ExcIndexRange(index, 0, base_elements.size())); return *base_elements[index].first; } @@ -3477,7 +3477,7 @@ FESystem::base_element (const unsigned int index) const template bool FESystem::has_support_on_face (const unsigned int shape_index, - const unsigned int face_index) const + const unsigned int face_index) const { return (base_element(this->system_to_base_index(shape_index).first.first) .has_support_on_face(this->system_to_base_index(shape_index).second, @@ -3540,14 +3540,14 @@ template std::size_t FESystem::memory_consumption () const { - // neglect size of data stored in - // @p{base_elements} due to some - // problems with teh - // compiler. should be neglectable - // after all, considering the size - // of the data of the subelements + // neglect size of data stored in + // @p{base_elements} due to some + // problems with teh + // compiler. should be neglectable + // after all, considering the size + // of the data of the subelements std::size_t mem = (FiniteElement::memory_consumption () + - sizeof (base_elements)); + sizeof (base_elements)); for (unsigned int i=0; i FiniteElement* FEFactory::get (const Quadrature<1> &) const @@ -65,7 +65,7 @@ namespace FETools return 0; } - // Specializations for FE_Q. + // Specializations for FE_Q. template <> FiniteElement<1, 1>* FEFactory >::get (const Quadrature<1> &quad) const @@ -86,7 +86,7 @@ namespace FETools } - // Specializations for FE_DGQArbitraryNodes. + // Specializations for FE_DGQArbitraryNodes. template <> FiniteElement<1, 1>* FEFactory >::get (const Quadrature<1> &quad) const @@ -168,15 +168,15 @@ namespace // and accessing the fe_name_map // variable. make this lock local // to this file. - // - // this and the next variable are - // declared static (even though - // they're in an anonymous - // namespace) in order to make icc - // happy (which otherwise reports a - // multiply defined symbol when - // linking libraries for more than - // one space dimension together + // + // this and the next variable are + // declared static (even though + // they're in an anonymous + // namespace) in order to make icc + // happy (which otherwise reports a + // multiply defined symbol when + // linking libraries for more than + // one space dimension together static Threads::ThreadMutex fe_name_map_lock; @@ -203,17 +203,17 @@ namespace // separate between them further down static std::map > > + std_cxx1x::shared_ptr > > fe_name_map_1d = get_default_fe_names<1> (); static std::map > > + std_cxx1x::shared_ptr > > fe_name_map_2d = get_default_fe_names<2> (); static std::map > > + std_cxx1x::shared_ptr > > fe_name_map_3d = get_default_fe_names<3> (); } @@ -262,48 +262,48 @@ namespace - // return how many characters - // starting at the given position - // of the string match either the - // generic string "" or the - // specialized string with "dim" - // replaced with the numeric value - // of the template argument + // return how many characters + // starting at the given position + // of the string match either the + // generic string "" or the + // specialized string with "dim" + // replaced with the numeric value + // of the template argument template inline unsigned int match_dimension (const std::string &name, - const unsigned int position) + const unsigned int position) { if (position >= name.size()) return 0; if ((position+5 < name.size()) - && - (name[position] == '<') - && - (name[position+1] == 'd') - && - (name[position+2] == 'i') - && - (name[position+3] == 'm') - && - (name[position+4] == '>')) + && + (name[position] == '<') + && + (name[position+1] == 'd') + && + (name[position+2] == 'i') + && + (name[position+3] == 'm') + && + (name[position+4] == '>')) return 5; Assert (dim<10, ExcNotImplemented()); const char dim_char = '0'+dim; if ((position+3 < name.size()) - && - (name[position] == '<') - && - (name[position+1] == dim_char) - && - (name[position+2] == '>')) + && + (name[position] == '<') + && + (name[position+1] == dim_char) + && + (name[position+2] == '>')) return 3; - // some other string that doesn't - // match + // some other string that doesn't + // match return 0; } } @@ -323,36 +323,36 @@ namespace FETools std::vector >& comp_start) { Assert(renumbering.size() == element.dofs_per_cell, - ExcDimensionMismatch(renumbering.size(), - element.dofs_per_cell)); + ExcDimensionMismatch(renumbering.size(), + element.dofs_per_cell)); comp_start.resize(element.n_base_elements()); unsigned int k=0; for (unsigned int i=0;i, unsigned int> - indices = element.system_to_base_index(i); - renumbering[i] = comp_start[indices.first.first][indices.first.second] - +indices.second; + std::pair, unsigned int> + indices = element.system_to_base_index(i); + renumbering[i] = comp_start[indices.first.first][indices.first.second] + +indices.second; } } @@ -366,42 +366,42 @@ namespace FETools bool return_start_indices) { Assert(renumbering.size() == element.dofs_per_cell, - ExcDimensionMismatch(renumbering.size(), - element.dofs_per_cell)); + ExcDimensionMismatch(renumbering.size(), + element.dofs_per_cell)); Assert(block_data.size() == element.n_blocks(), - ExcDimensionMismatch(block_data.size(), - element.n_blocks())); + ExcDimensionMismatch(block_data.size(), + element.n_blocks())); unsigned int k=0; unsigned int i=0; for (unsigned int b=0;b start_indices(block_data.size()); k = 0; for (unsigned int i=0;i - indices = element.system_to_block_index(i); - renumbering[i] = start_indices[indices.first] - +indices.second; + std::pair + indices = element.system_to_block_index(i); + renumbering[i] = start_indices[indices.first] + +indices.second; } } @@ -409,63 +409,63 @@ namespace FETools template void get_interpolation_matrix (const FiniteElement &fe1, - const FiniteElement &fe2, - FullMatrix &interpolation_matrix) + const FiniteElement &fe2, + FullMatrix &interpolation_matrix) { Assert (fe1.n_components() == fe2.n_components(), - ExcDimensionMismatch(fe1.n_components(), fe2.n_components())); + ExcDimensionMismatch(fe1.n_components(), fe2.n_components())); Assert(interpolation_matrix.m()==fe2.dofs_per_cell && - interpolation_matrix.n()==fe1.dofs_per_cell, - ExcMatrixDimensionMismatch(interpolation_matrix.m(), - interpolation_matrix.n(), - fe2.dofs_per_cell, - fe1.dofs_per_cell)); - - // first try the easy way: maybe - // the FE wants to implement things - // itself: + interpolation_matrix.n()==fe1.dofs_per_cell, + ExcMatrixDimensionMismatch(interpolation_matrix.m(), + interpolation_matrix.n(), + fe2.dofs_per_cell, + fe1.dofs_per_cell)); + + // first try the easy way: maybe + // the FE wants to implement things + // itself: bool fe_implements_interpolation = true; try { - gim_forwarder (fe1, fe2, interpolation_matrix); + gim_forwarder (fe1, fe2, interpolation_matrix); } catch (typename FiniteElement::ExcInterpolationNotImplemented &) { - // too bad.... - fe_implements_interpolation = false; + // too bad.... + fe_implements_interpolation = false; } if (fe_implements_interpolation == true) return; - // uh, so this was not the - // case. hm. then do it the hard - // way. note that this will only - // work if the element is - // primitive, so check this first + // uh, so this was not the + // case. hm. then do it the hard + // way. note that this will only + // work if the element is + // primitive, so check this first Assert (fe1.is_primitive() == true, ExcFENotPrimitive()); Assert (fe2.is_primitive() == true, ExcFENotPrimitive()); - // Initialize FEValues for fe1 at - // the unit support points of the - // fe2 element. + // Initialize FEValues for fe1 at + // the unit support points of the + // fe2 element. const std::vector > & fe2_support_points = fe2.get_unit_support_points (); typedef FiniteElement FEL; Assert(fe2_support_points.size()==fe2.dofs_per_cell, - typename FEL::ExcFEHasNoSupportPoints()); + typename FEL::ExcFEHasNoSupportPoints()); for (unsigned int i=0; i void get_back_interpolation_matrix(const FiniteElement &fe1, - const FiniteElement &fe2, - FullMatrix &interpolation_matrix) + const FiniteElement &fe2, + FullMatrix &interpolation_matrix) { Assert (fe1.n_components() == fe2.n_components(), - ExcDimensionMismatch(fe1.n_components(), fe2.n_components())); + ExcDimensionMismatch(fe1.n_components(), fe2.n_components())); Assert(interpolation_matrix.m()==fe1.dofs_per_cell && - interpolation_matrix.n()==fe1.dofs_per_cell, - ExcMatrixDimensionMismatch(interpolation_matrix.m(), - interpolation_matrix.n(), - fe1.dofs_per_cell, - fe1.dofs_per_cell)); + interpolation_matrix.n()==fe1.dofs_per_cell, + ExcMatrixDimensionMismatch(interpolation_matrix.m(), + interpolation_matrix.n(), + fe1.dofs_per_cell, + fe1.dofs_per_cell)); FullMatrix first_matrix (fe2.dofs_per_cell, fe1.dofs_per_cell); FullMatrix second_matrix(fe1.dofs_per_cell, fe2.dofs_per_cell); @@ -491,7 +491,7 @@ namespace FETools get_interpolation_matrix(fe1, fe2, first_matrix); get_interpolation_matrix(fe2, fe1, second_matrix); - // int_matrix=second_matrix*first_matrix + // int_matrix=second_matrix*first_matrix second_matrix.mmult(interpolation_matrix, first_matrix); } @@ -499,17 +499,17 @@ namespace FETools template void get_interpolation_difference_matrix (const FiniteElement &fe1, - const FiniteElement &fe2, - FullMatrix &difference_matrix) + const FiniteElement &fe2, + FullMatrix &difference_matrix) { Assert (fe1.n_components() == fe2.n_components(), - ExcDimensionMismatch(fe1.n_components(), fe2.n_components())); + ExcDimensionMismatch(fe1.n_components(), fe2.n_components())); Assert(difference_matrix.m()==fe1.dofs_per_cell && - difference_matrix.n()==fe1.dofs_per_cell, - ExcMatrixDimensionMismatch(difference_matrix.m(), - difference_matrix.n(), - fe1.dofs_per_cell, - fe1.dofs_per_cell)); + difference_matrix.n()==fe1.dofs_per_cell, + ExcMatrixDimensionMismatch(difference_matrix.m(), + difference_matrix.n(), + fe1.dofs_per_cell, + fe1.dofs_per_cell)); FullMatrix interpolation_matrix(fe1.dofs_per_cell); get_back_interpolation_matrix(fe1, fe2, interpolation_matrix); @@ -517,7 +517,7 @@ namespace FETools for (unsigned int i=0; i void get_projection_matrix (const FiniteElement &fe1, - const FiniteElement &fe2, - FullMatrix &matrix) + const FiniteElement &fe2, + FullMatrix &matrix) { Assert (fe1.n_components() == 1, ExcNotImplemented()); Assert (fe1.n_components() == fe2.n_components(), - ExcDimensionMismatch(fe1.n_components(), fe2.n_components())); + ExcDimensionMismatch(fe1.n_components(), fe2.n_components())); Assert(matrix.m()==fe2.dofs_per_cell && matrix.n()==fe1.dofs_per_cell, - ExcMatrixDimensionMismatch(matrix.m(), matrix.n(), - fe2.dofs_per_cell, - fe1.dofs_per_cell)); + ExcMatrixDimensionMismatch(matrix.m(), matrix.n(), + fe2.dofs_per_cell, + fe1.dofs_per_cell)); matrix = 0; unsigned int n1 = fe1.dofs_per_cell; unsigned int n2 = fe2.dofs_per_cell; - // First, create a local mass matrix for - // the unit cell + // First, create a local mass matrix for + // the unit cell Triangulation tr; GridGenerator::hyper_cube(tr); - // Choose a quadrature rule - // Gauss is exact up to degree 2n-1 + // Choose a quadrature rule + // Gauss is exact up to degree 2n-1 const unsigned int degree = std::max(fe1.tensor_degree(), fe2.tensor_degree()); Assert (degree != numbers::invalid_unsigned_int, - ExcNotImplemented()); + ExcNotImplemented()); QGauss quadrature(degree+1); - // Set up FEValues. + // Set up FEValues. const UpdateFlags flags = update_values | update_quadrature_points | update_JxW_values; FEValues val1 (fe1, quadrature, update_values); val1.reinit (tr.begin_active()); FEValues val2 (fe2, quadrature, flags); val2.reinit (tr.begin_active()); - // Integrate and invert mass matrix - // This happens in the target space + // Integrate and invert mass matrix + // This happens in the target space FullMatrix mass (n2, n2); for (unsigned int k=0;k b(n2); Vector x(n2); for (unsigned int j=0;j >& points = fe.get_generalized_support_points(); - // We need the values of the - // polynomials in all generalized - // support points. + // We need the values of the + // polynomials in all generalized + // support points. std::vector > values (dim, std::vector(points.size())); - // In this vector, we store the - // result of the interpolation + // In this vector, we store the + // result of the interpolation std::vector local_dofs(n_dofs); - // One row per shape - // function. Remember that these - // are the 'raw' shape functions - // where the inverse node matrix is - // empty. Otherwise, this would - // yield identity. + // One row per shape + // function. Remember that these + // are the 'raw' shape functions + // where the inverse node matrix is + // empty. Otherwise, this would + // yield identity. for (unsigned int i=0;i void compute_embedding_matrices(const FiniteElement<1,2> &, - std::vector > > &, - const bool) + std::vector > > &, + const bool) { Assert(false, ExcNotImplemented()); } - + template<> void compute_embedding_matrices(const FiniteElement<1,3> &, - std::vector > > &, - const bool) + std::vector > > &, + const bool) { Assert(false, ExcNotImplemented()); } - + template<> void compute_embedding_matrices(const FiniteElement<2,3>&, - std::vector > >&, - const bool) + std::vector > >&, + const bool) { Assert(false, ExcNotImplemented()); } @@ -699,40 +699,40 @@ namespace FETools Vector v_coarse(nq*nd); Vector v_fine(n); - // The right hand side of - // the least squares - // problem consists of the - // function values of the - // coarse grid function in - // each quadrature point. + // The right hand side of + // the least squares + // problem consists of the + // function values of the + // coarse grid function in + // each quadrature point. if (fe.is_primitive ()) - { - const unsigned int - d = fe.system_to_component_index (i).first; - const double* phi_i = &coarse.shape_value (i, 0); + { + const unsigned int + d = fe.system_to_component_index (i).first; + const double* phi_i = &coarse.shape_value (i, 0); - for (unsigned int k = 0; k < nq; ++k) - v_coarse (k * nd + d) = phi_i[k]; - } + for (unsigned int k = 0; k < nq; ++k) + v_coarse (k * nd + d) = phi_i[k]; + } else - for (unsigned int d = 0; d < nd; ++d) - for (unsigned int k = 0; k < nq; ++k) - v_coarse (k * nd + d) = coarse.shape_value_component (i, k, d); + for (unsigned int d = 0; d < nd; ++d) + for (unsigned int k = 0; k < nq; ++k) + v_coarse (k * nd + d) = coarse.shape_value_component (i, k, d); - // solve the least squares - // problem. + // solve the least squares + // problem. const double result = H.least_squares (v_fine, v_coarse); Assert (result < 1.e-12, ExcLeastSquaresError (result)); - // Copy into the result - // matrix. Since the matrix - // maps a coarse grid - // function to a fine grid - // function, the columns - // are fine grid. + // Copy into the result + // matrix. Since the matrix + // maps a coarse grid + // function to a fine grid + // function, the columns + // are fine grid. for (unsigned int j = 0; j < n; ++j) - this_matrix(j, i) = v_fine(j); + this_matrix(j, i) = v_fine(j); } @@ -746,13 +746,13 @@ namespace FETools const unsigned int n = fe.dofs_per_cell; const unsigned int nc = GeometryInfo::n_children(RefinementCase(ref_case)); for (unsigned int i = 0; i < nc; ++i) - { - Assert(matrices[i].n() == n, ExcDimensionMismatch(matrices[i].n (), n)); - Assert(matrices[i].m() == n, ExcDimensionMismatch(matrices[i].m (), n)); - } + { + Assert(matrices[i].n() == n, ExcDimensionMismatch(matrices[i].n (), n)); + Assert(matrices[i].m() == n, ExcDimensionMismatch(matrices[i].m (), n)); + } - // Set up meshes, one with a single - // reference cell and refine it once + // Set up meshes, one with a single + // reference cell and refine it once Triangulation tria; GridGenerator::hyper_cube (tria, 0, 1); tria.begin_active()->set_refine_flag (RefinementCase(ref_case)); @@ -764,31 +764,31 @@ namespace FETools const unsigned int nq = q_fine.size(); FEValues fine (mapping, fe, q_fine, - update_quadrature_points | - update_JxW_values | - update_values); - - // We search for the polynomial on - // the small cell, being equal to - // the coarse polynomial in all - // quadrature points. - - // First build the matrix for this - // least squares problem. This - // contains the values of the fine - // cell polynomials in the fine - // cell grid points. - - // This matrix is the same for all - // children. + update_quadrature_points | + update_JxW_values | + update_values); + + // We search for the polynomial on + // the small cell, being equal to + // the coarse polynomial in all + // quadrature points. + + // First build the matrix for this + // least squares problem. This + // contains the values of the fine + // cell polynomials in the fine + // cell grid points. + + // This matrix is the same for all + // children. fine.reinit (tria.begin_active ()); const unsigned int nd = fe.n_components (); FullMatrix A (nq*nd, n); for (unsigned int j = 0; j < n; ++j) - for (unsigned int d = 0; d < nd; ++d) - for (unsigned int k = 0; k < nq; ++k) - A (k * nd + d, j) = fine.shape_value_component (j, k, d); + for (unsigned int d = 0; d < nd; ++d) + for (unsigned int k = 0; k < nq; ++k) + A (k * nd + d, j) = fine.shape_value_component (j, k, d); Householder H (A); unsigned int cell_number = 0; @@ -796,60 +796,60 @@ namespace FETools Threads::TaskGroup task_group; for (typename Triangulation::active_cell_iterator - fine_cell = tria.begin_active (); fine_cell != tria.end (); - ++fine_cell, ++cell_number) - { - fine.reinit (fine_cell); - - // evaluate on the coarse cell (which - // is the first -- inactive -- cell on - // the lowest level of the - // triangulation we have created) - const Quadrature q_coarse (fine.get_quadrature_points (), - fine.get_JxW_values ()); - FEValues coarse (mapping, fe, q_coarse, update_values); - - coarse.reinit (tria.begin (0)); - - FullMatrix &this_matrix = matrices[cell_number]; - - // Compute this once for each - // coarse grid basis function. can - // spawn subtasks if n is - // sufficiently large so that there - // are more than about 5000 - // operations in the inner loop - // (which is basically const * n^2 - // operations). - if (n > 30) - { - for (unsigned int i = 0; i < n; ++i) - { - task_group += - Threads::new_task (&compute_embedding_for_shape_function, - i, fe, coarse, H, this_matrix); - } - task_group.join_all(); - } - else - { - for (unsigned int i = 0; i < n; ++i) - { - compute_embedding_for_shape_function - (i, fe, coarse, H, this_matrix); - } - } - - // Remove small entries from - // the matrix - for (unsigned int i = 0; i < this_matrix.m (); ++i) - for (unsigned int j = 0; j < this_matrix.n (); ++j) - if (std::fabs (this_matrix (i, j)) < 1e-12) - this_matrix (i, j) = 0.; - } + fine_cell = tria.begin_active (); fine_cell != tria.end (); + ++fine_cell, ++cell_number) + { + fine.reinit (fine_cell); + + // evaluate on the coarse cell (which + // is the first -- inactive -- cell on + // the lowest level of the + // triangulation we have created) + const Quadrature q_coarse (fine.get_quadrature_points (), + fine.get_JxW_values ()); + FEValues coarse (mapping, fe, q_coarse, update_values); + + coarse.reinit (tria.begin (0)); + + FullMatrix &this_matrix = matrices[cell_number]; + + // Compute this once for each + // coarse grid basis function. can + // spawn subtasks if n is + // sufficiently large so that there + // are more than about 5000 + // operations in the inner loop + // (which is basically const * n^2 + // operations). + if (n > 30) + { + for (unsigned int i = 0; i < n; ++i) + { + task_group += + Threads::new_task (&compute_embedding_for_shape_function, + i, fe, coarse, H, this_matrix); + } + task_group.join_all(); + } + else + { + for (unsigned int i = 0; i < n; ++i) + { + compute_embedding_for_shape_function + (i, fe, coarse, H, this_matrix); + } + } + + // Remove small entries from + // the matrix + for (unsigned int i = 0; i < this_matrix.m (); ++i) + for (unsigned int j = 0; j < this_matrix.n (); ++j) + if (std::fabs (this_matrix (i, j)) < 1e-12) + this_matrix (i, j) = 0.; + } Assert (cell_number == GeometryInfo::n_children (RefinementCase (ref_case)), - ExcInternalError ()); + ExcInternalError ()); } } @@ -857,19 +857,19 @@ namespace FETools template void compute_embedding_matrices(const FiniteElement& fe, - std::vector > >& matrices, - const bool isotropic_only) + std::vector > >& matrices, + const bool isotropic_only) { Threads::TaskGroup task_group; - // loop over all possible refinement cases + // loop over all possible refinement cases unsigned int ref_case = (isotropic_only) - ? RefinementCase::isotropic_refinement - : RefinementCase::cut_x; + ? RefinementCase::isotropic_refinement + : RefinementCase::cut_x; for (;ref_case <= RefinementCase::isotropic_refinement; ++ref_case) task_group += Threads::new_task (&compute_embedding_matrices_for_refinement_case, - fe, matrices[ref_case-1], ref_case); + fe, matrices[ref_case-1], ref_case); task_group.join_all (); } @@ -879,9 +879,9 @@ namespace FETools template void compute_face_embedding_matrices(const FiniteElement& fe, - FullMatrix (&matrices)[GeometryInfo::max_children_per_face], - const unsigned int face_coarse, - const unsigned int face_fine) + FullMatrix (&matrices)[GeometryInfo::max_children_per_face], + const unsigned int face_coarse, + const unsigned int face_fine) { Assert(face_coarse==0, ExcNotImplemented()); Assert(face_fine==0, ExcNotImplemented()); @@ -896,113 +896,113 @@ namespace FETools for (unsigned int i=0;i face_c_dofs(n); std::vector face_f_dofs(n); unsigned int k=0; for (unsigned int i=0;i::vertices_per_face;++i) { - const unsigned int offset_c = GeometryInfo::face_to_cell_vertices(face_coarse, i) - *fe.dofs_per_vertex; - const unsigned int offset_f = GeometryInfo::face_to_cell_vertices(face_fine, i) - *fe.dofs_per_vertex; - for (unsigned int j=0;j::face_to_cell_vertices(face_coarse, i) + *fe.dofs_per_vertex; + const unsigned int offset_f = GeometryInfo::face_to_cell_vertices(face_fine, i) + *fe.dofs_per_vertex; + for (unsigned int j=0;j::lines_per_face;++i) { - const unsigned int offset_c = fe.first_line_index - + GeometryInfo::face_to_cell_lines(face_coarse, i-1) - *fe.dofs_per_line; - const unsigned int offset_f = fe.first_line_index - + GeometryInfo::face_to_cell_lines(face_fine, i-1) - *fe.dofs_per_line; - for (unsigned int j=0;j::face_to_cell_lines(face_coarse, i-1) + *fe.dofs_per_line; + const unsigned int offset_f = fe.first_line_index + + GeometryInfo::face_to_cell_lines(face_fine, i-1) + *fe.dofs_per_line; + for (unsigned int j=0;j::quads_per_face;++i) { - const unsigned int offset_c = fe.first_quad_index - + face_coarse - *fe.dofs_per_quad; - const unsigned int offset_f = fe.first_quad_index - + face_fine - *fe.dofs_per_quad; - for (unsigned int j=0;j tria; GridGenerator::hyper_cube (tria, 0, 1); tria.refine_global(1); MappingCartesian mapping; - // Setup quadrature and FEValues - // for a face. We cannot use - // FEFaceValues and - // FESubfaceValues because of - // some nifty handling of - // refinement cases. Guido stops - // disliking and instead starts - // hating the anisotropic implementation + // Setup quadrature and FEValues + // for a face. We cannot use + // FEFaceValues and + // FESubfaceValues because of + // some nifty handling of + // refinement cases. Guido stops + // disliking and instead starts + // hating the anisotropic implementation QGauss q_gauss(degree+1); const Quadrature q_fine = QProjector::project_to_face(q_gauss, face_fine); const unsigned int nq = q_fine.size(); FEValues fine (mapping, fe, q_fine, - update_quadrature_points | update_JxW_values | update_values); + update_quadrature_points | update_JxW_values | update_values); - // We search for the polynomial on - // the small cell, being equal to - // the coarse polynomial in all - // quadrature points. + // We search for the polynomial on + // the small cell, being equal to + // the coarse polynomial in all + // quadrature points. - // First build the matrix for this - // least squares problem. This - // contains the values of the fine - // cell polynomials in the fine - // cell grid points. + // First build the matrix for this + // least squares problem. This + // contains the values of the fine + // cell polynomials in the fine + // cell grid points. - // This matrix is the same for all - // children. + // This matrix is the same for all + // children. fine.reinit(tria.begin_active()); FullMatrix A(nq*nd, n); for (unsigned int j=0;j H(A); @@ -1012,62 +1012,62 @@ namespace FETools for (unsigned int cell_number = 0; cell_number < GeometryInfo::max_children_per_face; - ++cell_number) + ++cell_number) { - const Quadrature q_coarse - = QProjector::project_to_subface(q_gauss, face_coarse, cell_number); - FEValues coarse (mapping, fe, q_coarse, update_values); - - typename Triangulation::active_cell_iterator fine_cell - = tria.begin(0)->child(GeometryInfo::child_cell_on_face( - tria.begin(0)->refinement_case(), face_coarse, cell_number)); - fine.reinit(fine_cell); - coarse.reinit(tria.begin(0)); - - FullMatrix &this_matrix = matrices[cell_number]; - - // Compute this once for each - // coarse grid basis function - for (unsigned int i=0;i q_coarse + = QProjector::project_to_subface(q_gauss, face_coarse, cell_number); + FEValues coarse (mapping, fe, q_coarse, update_values); + + typename Triangulation::active_cell_iterator fine_cell + = tria.begin(0)->child(GeometryInfo::child_cell_on_face( + tria.begin(0)->refinement_case(), face_coarse, cell_number)); + fine.reinit(fine_cell); + coarse.reinit(tria.begin(0)); + + FullMatrix &this_matrix = matrices[cell_number]; + + // Compute this once for each + // coarse grid basis function + for (unsigned int i=0;i void compute_projection_matrices(const FiniteElement<1,2>&, - std::vector > >&, bool) + std::vector > >&, bool) { Assert(false, ExcNotImplemented()); } - + template <> void compute_projection_matrices(const FiniteElement<1,3>&, - std::vector > >&, bool) + std::vector > >&, bool) { Assert(false, ExcNotImplemented()); } @@ -1093,7 +1093,7 @@ namespace FETools template <> void compute_projection_matrices(const FiniteElement<2,3>&, - std::vector > >&, bool) + std::vector > >&, bool) { Assert(false, ExcNotImplemented()); } @@ -1103,172 +1103,172 @@ namespace FETools template void compute_projection_matrices(const FiniteElement& fe, - std::vector > >& matrices, - const bool isotropic_only) + std::vector > >& matrices, + const bool isotropic_only) { const unsigned int n = fe.dofs_per_cell; const unsigned int nd = fe.n_components(); const unsigned int degree = fe.degree; - // prepare FEValues, quadrature etc on - // coarse cell + // prepare FEValues, quadrature etc on + // coarse cell MappingCartesian mapping; QGauss q_fine(degree+1); const unsigned int nq = q_fine.size(); - // create mass matrix on coarse cell. + // create mass matrix on coarse cell. FullMatrix mass(n, n); { - // set up a triangulation for coarse cell + // set up a triangulation for coarse cell Triangulation tr; GridGenerator::hyper_cube (tr, 0, 1); FEValues coarse (mapping, fe, q_fine, - update_JxW_values | update_values); + update_JxW_values | update_values); typename Triangulation::cell_iterator coarse_cell - = tr.begin(0); + = tr.begin(0); coarse.reinit (coarse_cell); const std::vector & JxW = coarse.get_JxW_values(); for (unsigned int i=0;i::isotropic_refinement - : RefinementCase::cut_x; + ? RefinementCase::isotropic_refinement + : RefinementCase::cut_x; for (;ref_case <= RefinementCase::isotropic_refinement; ++ref_case) { - const unsigned int - nc = GeometryInfo::n_children(RefinementCase(ref_case)); - - for (unsigned int i=0;i tr; - GridGenerator::hyper_cube (tr, 0, 1); - tr.begin_active()->set_refine_flag(RefinementCase(ref_case)); - tr.execute_coarsening_and_refinement(); - - FEValues fine (mapping, fe, q_fine, - update_quadrature_points | update_JxW_values | - update_values); - - typename Triangulation::cell_iterator coarse_cell - = tr.begin(0); - - Vector v_coarse(n); - Vector v_fine(n); - - for (unsigned int cell_number=0;cell_number &this_matrix = matrices[ref_case-1][cell_number]; - - // Compute right hand side, - // which is a fine level basis - // function tested with the - // coarse level functions. - fine.reinit(coarse_cell->child(cell_number)); - Quadrature q_coarse (fine.get_quadrature_points(), - fine.get_JxW_values()); - FEValues coarse (mapping, fe, q_coarse, update_values); - coarse.reinit(coarse_cell); - - // Build RHS - - const std::vector & JxW = fine.get_JxW_values(); - - // Outer loop over all fine - // grid shape functions phi_j - for (unsigned int j=0;j::n_children(RefinementCase(ref_case)); + + for (unsigned int i=0;i tr; + GridGenerator::hyper_cube (tr, 0, 1); + tr.begin_active()->set_refine_flag(RefinementCase(ref_case)); + tr.execute_coarsening_and_refinement(); + + FEValues fine (mapping, fe, q_fine, + update_quadrature_points | update_JxW_values | + update_values); + + typename Triangulation::cell_iterator coarse_cell + = tr.begin(0); + + Vector v_coarse(n); + Vector v_fine(n); + + for (unsigned int cell_number=0;cell_number &this_matrix = matrices[ref_case-1][cell_number]; + + // Compute right hand side, + // which is a fine level basis + // function tested with the + // coarse level functions. + fine.reinit(coarse_cell->child(cell_number)); + Quadrature q_coarse (fine.get_quadrature_points(), + fine.get_JxW_values()); + FEValues coarse (mapping, fe, q_coarse, update_values); + coarse.reinit(coarse_cell); + + // Build RHS + + const std::vector & JxW = fine.get_JxW_values(); + + // Outer loop over all fine + // grid shape functions phi_j + for (unsigned int j=0;j class DH1, - template class DH2, - class InVector, class OutVector> + template class DH1, + template class DH2, + class InVector, class OutVector> void interpolate(const DH1 &dof1, - const InVector &u1, - const DH2 &dof2, - OutVector &u2) - { - ConstraintMatrix dummy; - dummy.close(); - interpolate(dof1, u1, dof2, dummy, u2); - } + const InVector &u1, + const DH2 &dof2, + OutVector &u2) + { + ConstraintMatrix dummy; + dummy.close(); + interpolate(dof1, u1, dof2, dummy, u2); + } @@ -1278,10 +1278,10 @@ namespace FETools class InVector, class OutVector> void interpolate (const DH1 &dof1, - const InVector &u1, - const DH2 &dof2, - const ConstraintMatrix &constraints, - OutVector &u2) + const InVector &u1, + const DH2 &dof2, + const ConstraintMatrix &constraints, + OutVector &u2) { Assert(&dof1.get_tria()==&dof2.get_tria(), ExcTriangulationMismatch()); @@ -1339,7 +1339,7 @@ namespace FETools // for distributed triangulations, // we can only interpolate u1 on // a cell, which this processor owns, - // so we have to know the subdomain_id + // so we have to know the subdomain_id const types::subdomain_id_t subdomain_id = dof1.get_tria().locally_owned_subdomain(); @@ -1364,10 +1364,10 @@ namespace FETools (constraints.n_constraints() == 0)); if (hanging_nodes_not_allowed) - for (unsigned int face=0; face::faces_per_cell; ++face) - Assert (cell1->at_boundary(face) || - cell1->neighbor(face)->level() == cell1->level(), - ExcHangingNodesNotAllowed(0)); + for (unsigned int face=0; face::faces_per_cell; ++face) + Assert (cell1->at_boundary(face) || + cell1->neighbor(face)->level() == cell1->level(), + ExcHangingNodesNotAllowed(0)); const unsigned int dofs_per_cell1 = cell1->get_fe().dofs_per_cell; @@ -1388,8 +1388,8 @@ namespace FETools = interpolation_matrix; get_interpolation_matrix(cell1->get_fe(), - cell2->get_fe(), - *interpolation_matrix); + cell2->get_fe(), + *interpolation_matrix); } cell1->get_dof_values(u1, u1_local); @@ -1417,12 +1417,12 @@ namespace FETools // work on dofs this processor owns. IndexSet locally_owned_dofs = dof2.locally_owned_dofs(); - // when a discontinuous element is - // interpolated to a continuous - // one, we take the mean values. - // for parallel vectors check, - // if this component is owned by - // this processor. + // when a discontinuous element is + // interpolated to a continuous + // one, we take the mean values. + // for parallel vectors check, + // if this component is owned by + // this processor. for (unsigned int i=0; i void back_interpolate(const DoFHandler &dof1, - const InVector &u1, - const FiniteElement &fe2, - OutVector &u1_interpolated) + const InVector &u1, + const FiniteElement &fe2, + OutVector &u1_interpolated) { Assert(dof1.get_fe().n_components() == fe2.n_components(), - ExcDimensionMismatch(dof1.get_fe().n_components(), fe2.n_components())); + ExcDimensionMismatch(dof1.get_fe().n_components(), fe2.n_components())); Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs())); Assert(u1_interpolated.size()==dof1.n_dofs(), - ExcDimensionMismatch(u1_interpolated.size(), dof1.n_dofs())); + ExcDimensionMismatch(u1_interpolated.size(), dof1.n_dofs())); #ifdef DEAL_II_USE_PETSC if (dynamic_cast(&u1) != 0) @@ -1473,13 +1473,13 @@ namespace FETools }; #endif - // For continuous elements on grids - // with hanging nodes we need - // hanging node - // constraints. Consequently, when - // the elements are continuous no - // hanging node constraints are - // allowed. + // For continuous elements on grids + // with hanging nodes we need + // hanging node + // constraints. Consequently, when + // the elements are continuous no + // hanging node constraints are + // allowed. const bool hanging_nodes_not_allowed= (dof1.get_fe().dofs_per_vertex != 0) || (fe2.dofs_per_vertex != 0); @@ -1492,30 +1492,30 @@ namespace FETools dof1.get_tria().locally_owned_subdomain(); typename DoFHandler::active_cell_iterator cell = dof1.begin_active(), - endc = dof1.end(); + endc = dof1.end(); FullMatrix interpolation_matrix(dofs_per_cell1, dofs_per_cell1); get_back_interpolation_matrix(dof1.get_fe(), fe2, - interpolation_matrix); + interpolation_matrix); for (; cell!=endc; ++cell) if ((cell->subdomain_id() == subdomain_id) || (subdomain_id == types::invalid_subdomain_id)) { - if (hanging_nodes_not_allowed) - for (unsigned int face=0; face::faces_per_cell; ++face) - Assert (cell->at_boundary(face) || - cell->neighbor(face)->level() == cell->level(), - ExcHangingNodesNotAllowed(0)); - - cell->get_dof_values(u1, u1_local); - interpolation_matrix.vmult(u1_int_local, u1_local); - cell->set_dof_values(u1_int_local, u1_interpolated); + if (hanging_nodes_not_allowed) + for (unsigned int face=0; face::faces_per_cell; ++face) + Assert (cell->at_boundary(face) || + cell->neighbor(face)->level() == cell->level(), + ExcHangingNodesNotAllowed(0)); + + cell->get_dof_values(u1, u1_local); + interpolation_matrix.vmult(u1_int_local, u1_local); + cell->set_dof_values(u1_int_local, u1_interpolated); } - // if we work on a parallel PETSc vector - // we have to finish the work and - // update ghost values + // if we work on a parallel PETSc vector + // we have to finish the work and + // update ghost values u1_interpolated.compress(); u1_interpolated.update_ghost_values(); } @@ -1523,13 +1523,13 @@ namespace FETools template class DH, - class InVector, class OutVector, int spacedim> + template class DH, + class InVector, class OutVector, int spacedim> void back_interpolate(const DH &dof1, - const InVector &u1, - const FiniteElement &fe2, - OutVector &u1_interpolated) + const InVector &u1, + const FiniteElement &fe2, + OutVector &u1_interpolated) { Assert(u1.size() == dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs())); @@ -1564,9 +1564,9 @@ namespace FETools typename DH::active_cell_iterator cell = dof1.begin_active(), endc = dof1.end(); - // map from possible fe objects in - // dof1 to the back_interpolation - // matrices + // map from possible fe objects in + // dof1 to the back_interpolation + // matrices std::map *, std_cxx1x::shared_ptr > > interpolation_matrices; @@ -1579,13 +1579,13 @@ namespace FETools ExcDimensionMismatch(cell->get_fe().n_components(), fe2.n_components())); - // For continuous elements on - // grids with hanging nodes we - // need hanging node - // constraints. Consequently, - // when the elements are - // continuous no hanging node - // constraints are allowed. + // For continuous elements on + // grids with hanging nodes we + // need hanging node + // constraints. Consequently, + // when the elements are + // continuous no hanging node + // constraints are allowed. const bool hanging_nodes_not_allowed= (cell->get_fe().dofs_per_vertex != 0) || (fe2.dofs_per_vertex != 0); @@ -1597,8 +1597,8 @@ namespace FETools const unsigned int dofs_per_cell1 = cell->get_fe().dofs_per_cell; - // make sure back_interpolation - // matrix is available + // make sure back_interpolation + // matrix is available if (interpolation_matrices[&cell->get_fe()] != 0) { interpolation_matrices[&cell->get_fe()] = @@ -1616,9 +1616,9 @@ namespace FETools cell->set_dof_values(u1_int_local, u1_interpolated); }; - // if we work on a parallel PETSc vector - // we have to finish the work and - // update ghost values + // if we work on a parallel PETSc vector + // we have to finish the work and + // update ghost values u1_interpolated.compress(); u1_interpolated.update_ghost_values(); } @@ -1627,44 +1627,44 @@ namespace FETools template void back_interpolate(const DoFHandler &dof1, - const ConstraintMatrix &constraints1, - const InVector &u1, - const DoFHandler &dof2, - const ConstraintMatrix &constraints2, - OutVector &u1_interpolated) + const ConstraintMatrix &constraints1, + const InVector &u1, + const DoFHandler &dof2, + const ConstraintMatrix &constraints2, + OutVector &u1_interpolated) { - // For discontinuous elements - // without constraints take the - // simpler version of the - // back_interpolate function. + // For discontinuous elements + // without constraints take the + // simpler version of the + // back_interpolate function. if (dof1.get_fe().dofs_per_vertex==0 && dof2.get_fe().dofs_per_vertex==0 - && constraints1.n_constraints()==0 && constraints2.n_constraints()==0) + && constraints1.n_constraints()==0 && constraints2.n_constraints()==0) back_interpolate(dof1, u1, dof2.get_fe(), u1_interpolated); else { - Assert(dof1.get_fe().n_components() == dof2.get_fe().n_components(), - ExcDimensionMismatch(dof1.get_fe().n_components(), dof2.get_fe().n_components())); - Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs())); - Assert(u1_interpolated.size()==dof1.n_dofs(), - ExcDimensionMismatch(u1_interpolated.size(), dof1.n_dofs())); - - // For continuous elements - // first interpolate to dof2, - // taking into account - // constraints2, and then - // interpolate back to dof1 - // taking into account - // constraints1 + Assert(dof1.get_fe().n_components() == dof2.get_fe().n_components(), + ExcDimensionMismatch(dof1.get_fe().n_components(), dof2.get_fe().n_components())); + Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs())); + Assert(u1_interpolated.size()==dof1.n_dofs(), + ExcDimensionMismatch(u1_interpolated.size(), dof1.n_dofs())); + + // For continuous elements + // first interpolate to dof2, + // taking into account + // constraints2, and then + // interpolate back to dof1 + // taking into account + // constraints1 #ifdef DEAL_II_USE_PETSC if (dynamic_cast(&u1) != 0) { AssertThrow (dynamic_cast(&u1_interpolated) != 0, ExcMessage("Interpolation can only be done between vectors of same type!")); - // if u1 is a parallel distributed - // PETSc vector, we create a vector u2 - // with based on the sets of locally owned - // and relevant dofs of dof2 + // if u1 is a parallel distributed + // PETSc vector, we create a vector u2 + // with based on the sets of locally owned + // and relevant dofs of dof2 IndexSet dof2_locally_owned_dofs = dof2.locally_owned_dofs(); IndexSet dof2_locally_relevant_dofs; DoFTools::extract_locally_relevant_dofs (dof2, @@ -1690,15 +1690,15 @@ namespace FETools template void interpolation_difference (const DoFHandler &dof1, - const InVector &u1, - const FiniteElement &fe2, - OutVector &u1_difference) + const InVector &u1, + const FiniteElement &fe2, + OutVector &u1_difference) { Assert(dof1.get_fe().n_components() == fe2.n_components(), - ExcDimensionMismatch(dof1.get_fe().n_components(), fe2.n_components())); + ExcDimensionMismatch(dof1.get_fe().n_components(), fe2.n_components())); Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs())); Assert(u1_difference.size()==dof1.n_dofs(), - ExcDimensionMismatch(u1_difference.size(), dof1.n_dofs())); + ExcDimensionMismatch(u1_difference.size(), dof1.n_dofs())); #ifdef DEAL_II_USE_PETSC if (dynamic_cast(&u1) != 0) @@ -1719,13 +1719,13 @@ namespace FETools }; #endif - // For continuous elements on grids - // with hanging nodes we need - // hanging node - // constraints. Consequently, when - // the elements are continuous no - // hanging node constraints are - // allowed. + // For continuous elements on grids + // with hanging nodes we need + // hanging node + // constraints. Consequently, when + // the elements are continuous no + // hanging node constraints are + // allowed. const bool hanging_nodes_not_allowed= (dof1.get_fe().dofs_per_vertex != 0) || (fe2.dofs_per_vertex != 0); @@ -1739,30 +1739,30 @@ namespace FETools FullMatrix difference_matrix(dofs_per_cell, dofs_per_cell); get_interpolation_difference_matrix(dof1.get_fe(), fe2, - difference_matrix); + difference_matrix); typename DoFHandler::active_cell_iterator cell = dof1.begin_active(), - endc = dof1.end(); + endc = dof1.end(); for (; cell!=endc; ++cell) if ((cell->subdomain_id() == subdomain_id) || (subdomain_id == types::invalid_subdomain_id)) { - if (hanging_nodes_not_allowed) - for (unsigned int face=0; face::faces_per_cell; ++face) - Assert (cell->at_boundary(face) || - cell->neighbor(face)->level() == cell->level(), - ExcHangingNodesNotAllowed(0)); - - cell->get_dof_values(u1, u1_local); - difference_matrix.vmult(u1_diff_local, u1_local); - cell->set_dof_values(u1_diff_local, u1_difference); + if (hanging_nodes_not_allowed) + for (unsigned int face=0; face::faces_per_cell; ++face) + Assert (cell->at_boundary(face) || + cell->neighbor(face)->level() == cell->level(), + ExcHangingNodesNotAllowed(0)); + + cell->get_dof_values(u1, u1_local); + difference_matrix.vmult(u1_diff_local, u1_local); + cell->set_dof_values(u1_diff_local, u1_difference); } - // if we work on a parallel PETSc vector - // we have to finish the work and - // update ghost values + // if we work on a parallel PETSc vector + // we have to finish the work and + // update ghost values u1_difference.compress(); u1_difference.update_ghost_values(); } @@ -1771,27 +1771,27 @@ namespace FETools template void interpolation_difference(const DoFHandler &dof1, - const ConstraintMatrix &constraints1, - const InVector &u1, - const DoFHandler &dof2, - const ConstraintMatrix &constraints2, - OutVector &u1_difference) + const ConstraintMatrix &constraints1, + const InVector &u1, + const DoFHandler &dof2, + const ConstraintMatrix &constraints2, + OutVector &u1_difference) { - // For discontinuous elements - // without constraints take the - // cheaper version of the - // interpolation_difference function. + // For discontinuous elements + // without constraints take the + // cheaper version of the + // interpolation_difference function. if (dof1.get_fe().dofs_per_vertex==0 && dof2.get_fe().dofs_per_vertex==0 - && constraints1.n_constraints()==0 && constraints2.n_constraints()==0) + && constraints1.n_constraints()==0 && constraints2.n_constraints()==0) interpolation_difference(dof1, u1, dof2.get_fe(), u1_difference); else { - back_interpolate(dof1, constraints1, u1, dof2, constraints2, u1_difference); - u1_difference.sadd(-1, u1); + back_interpolate(dof1, constraints1, u1, dof2, constraints2, u1_difference); + u1_difference.sadd(-1, u1); - // if we work on a parallel PETSc vector - // we have to finish the work and - // update ghost values + // if we work on a parallel PETSc vector + // we have to finish the work and + // update ghost values u1_difference.compress(); u1_difference.update_ghost_values(); } @@ -1801,13 +1801,13 @@ namespace FETools template void project_dg(const DoFHandler &dof1, - const InVector &u1, - const DoFHandler &dof2, - OutVector &u2) + const InVector &u1, + const DoFHandler &dof2, + OutVector &u2) { Assert(&dof1.get_tria()==&dof2.get_tria(), ExcTriangulationMismatch()); Assert(dof1.get_fe().n_components() == dof2.get_fe().n_components(), - ExcDimensionMismatch(dof1.get_fe().n_components(), dof2.get_fe().n_components())); + ExcDimensionMismatch(dof1.get_fe().n_components(), dof2.get_fe().n_components())); Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs())); Assert(u2.size()==dof2.n_dofs(), ExcDimensionMismatch(u2.size(), dof2.n_dofs())); @@ -1827,25 +1827,25 @@ namespace FETools while (cell2 != end) { - cell1->get_dof_values(u1, u1_local); - matrix.vmult(u2_local, u1_local); - cell2->get_dof_indices(dofs); - for (unsigned int i=0; iget_dof_values(u1, u1_local); + matrix.vmult(u2_local, u1_local); + cell2->get_dof_indices(dofs); + for (unsigned int i=0; i void extrapolate(const DoFHandler &dof1, - const InVector &u1, - const DoFHandler &dof2, - OutVector &u2) + const InVector &u1, + const DoFHandler &dof2, + OutVector &u2) { ConstraintMatrix dummy; dummy.close(); @@ -1856,13 +1856,13 @@ namespace FETools template void extrapolate(const DoFHandler &dof1, - const InVector &u1, - const DoFHandler &dof2, - const ConstraintMatrix &constraints, - OutVector &u2) + const InVector &u1, + const DoFHandler &dof2, + const ConstraintMatrix &constraints, + OutVector &u2) { Assert(dof1.get_fe().n_components() == dof2.get_fe().n_components(), - ExcDimensionMismatch(dof1.get_fe().n_components(), dof2.get_fe().n_components())); + ExcDimensionMismatch(dof1.get_fe().n_components(), dof2.get_fe().n_components())); Assert(&dof1.get_tria()==&dof2.get_tria(), ExcTriangulationMismatch()); Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs())); Assert(u2.size()==dof2.n_dofs(), ExcDimensionMismatch(u2.size(), dof2.n_dofs())); @@ -1874,54 +1874,54 @@ namespace FETools const unsigned int dofs_per_cell = dof2.get_fe().dofs_per_cell; Vector dof_values(dofs_per_cell); - // make sure that each cell on the - // coarsest level is at least once - // refined. otherwise, we can't - // treat these cells and would - // generate a bogus result + // make sure that each cell on the + // coarsest level is at least once + // refined. otherwise, we can't + // treat these cells and would + // generate a bogus result { typename DoFHandler::cell_iterator cell = dof2.begin(0), - endc = dof2.end(0); + endc = dof2.end(0); for (; cell!=endc; ++cell) - Assert (cell->has_children(), ExcGridNotRefinedAtLeastOnce()); + Assert (cell->has_children(), ExcGridNotRefinedAtLeastOnce()); } - // then traverse grid bottom up + // then traverse grid bottom up for (unsigned int level=0; level::cell_iterator cell=dof2.begin(level), - endc=dof2.end(level); - - for (; cell!=endc; ++cell) - if (!cell->active()) - { - // check whether this - // cell has active - // children - bool active_children=false; - for (unsigned int child_n=0; child_nn_children(); ++child_n) - if (cell->child(child_n)->active()) - { - active_children=true; - break; - } - - // if there are active - // children, the we have - // to work on this - // cell. get the data - // from the one vector - // and set it on the - // other - if (active_children) - { - cell->get_interpolated_dof_values(u3, dof_values); - cell->set_dof_values_by_interpolation(dof_values, u2); - } - } + typename DoFHandler::cell_iterator cell=dof2.begin(level), + endc=dof2.end(level); + + for (; cell!=endc; ++cell) + if (!cell->active()) + { + // check whether this + // cell has active + // children + bool active_children=false; + for (unsigned int child_n=0; child_nn_children(); ++child_n) + if (cell->child(child_n)->active()) + { + active_children=true; + break; + } + + // if there are active + // children, the we have + // to work on this + // cell. get the data + // from the one vector + // and set it on the + // other + if (active_children) + { + cell->get_interpolated_dof_values(u3, dof_values); + cell->set_dof_values_by_interpolation(dof_values, u2); + } + } } - // Apply hanging node constraints. + // Apply hanging node constraints. constraints.distribute(u2); } @@ -1929,27 +1929,27 @@ namespace FETools template <> void add_fe_name(const std::string& parameter_name, - const FEFactoryBase<1,1>* factory) + const FEFactoryBase<1,1>* factory) { - // Erase everything after the - // actual class name + // Erase everything after the + // actual class name std::string name = parameter_name; unsigned int name_end = name.find_first_not_of(std::string("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_")); if (name_end < name.size()) name.erase(name_end); - // first make sure that no other - // thread intercepts the - // operation of this function; - // for this, acquire the lock - // until we quit this function + // first make sure that no other + // thread intercepts the + // operation of this function; + // for this, acquire the lock + // until we quit this function Threads::ThreadMutex::ScopedLock lock(fe_name_map_lock); Assert(fe_name_map_1d.find(name) == fe_name_map_1d.end(), - ExcMessage("Cannot change existing element in finite element name list")); + ExcMessage("Cannot change existing element in finite element name list")); - // Insert the normalized name into - // the map + // Insert the normalized name into + // the map fe_name_map_1d[name] = std_cxx1x::shared_ptr > (factory); } @@ -1959,27 +1959,27 @@ namespace FETools template <> void add_fe_name(const std::string& parameter_name, - const FEFactoryBase<2,2>* factory) + const FEFactoryBase<2,2>* factory) { - // Erase everything after the - // actual class name + // Erase everything after the + // actual class name std::string name = parameter_name; unsigned int name_end = name.find_first_not_of(std::string("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_")); if (name_end < name.size()) name.erase(name_end); - // first make sure that no other - // thread intercepts the - // operation of this function; - // for this, acquire the lock - // until we quit this function + // first make sure that no other + // thread intercepts the + // operation of this function; + // for this, acquire the lock + // until we quit this function Threads::ThreadMutex::ScopedLock lock(fe_name_map_lock); Assert(fe_name_map_2d.find(name) == fe_name_map_2d.end(), - ExcMessage("Cannot change existing element in finite element name list")); + ExcMessage("Cannot change existing element in finite element name list")); - // Insert the normalized name into - // the map + // Insert the normalized name into + // the map fe_name_map_2d[name] = std_cxx1x::shared_ptr > (factory); } @@ -1988,27 +1988,27 @@ namespace FETools template <> void add_fe_name(const std::string& parameter_name, - const FEFactoryBase<3,3>* factory) + const FEFactoryBase<3,3>* factory) { - // Erase everything after the - // actual class name + // Erase everything after the + // actual class name std::string name = parameter_name; unsigned int name_end = name.find_first_not_of(std::string("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_")); if (name_end < name.size()) name.erase(name_end); - // first make sure that no other - // thread intercepts the - // operation of this function; - // for this, acquire the lock - // until we quit this function + // first make sure that no other + // thread intercepts the + // operation of this function; + // for this, acquire the lock + // until we quit this function Threads::ThreadMutex::ScopedLock lock(fe_name_map_lock); Assert(fe_name_map_3d.find(name) == fe_name_map_3d.end(), - ExcMessage("Cannot change existing element in finite element name list")); + ExcMessage("Cannot change existing element in finite element name list")); - // Insert the normalized name into - // the map + // Insert the normalized name into + // the map fe_name_map_3d[name] = std_cxx1x::shared_ptr > (factory); } @@ -2018,121 +2018,121 @@ namespace FETools { namespace { - // TODO: this encapsulates the call to the - // dimension-dependent fe_name_map so that we - // have a unique interface. could be done - // smarter? + // TODO: this encapsulates the call to the + // dimension-dependent fe_name_map so that we + // have a unique interface. could be done + // smarter? template FiniteElement* get_fe_from_name_ext (std::string &name, - const std::map > > - &fe_name_map) + const std::map > > + &fe_name_map) { - // Extract the name of the - // finite element class, which only - // contains characters, numbers and - // underscores. - unsigned int name_end = - name.find_first_not_of(std::string("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_")); - const std::string name_part(name, 0, name_end); - name.erase(0, name_part.size()); - - // now things get a little more - // complicated: FESystem. it's - // more complicated, since we - // have to figure out what the - // base elements are. this can - // only be done recursively - - - - - if (name_part == "FESystem") - { - // next we have to get at the - // base elements. start with - // the first. wrap the whole - // block into try-catch to - // make sure we destroy the - // pointers we got from - // recursive calls if one of - // these calls should throw - // an exception - std::vector*> base_fes; - std::vector base_multiplicities; - try - { - // Now, just the [...] - // part should be left. - if (name.size() == 0 || name[0] != '[') - throw (std::string("Invalid first character in ") + name); - do - { - // Erase the - // leading '[' or '-' - name.erase(0,1); - // Now, the name of the - // first base element is - // first... Let's get it - base_fes.push_back (get_fe_from_name_ext (name, - fe_name_map)); - // next check whether - // FESystem placed a - // multiplicity after - // the element name - if (name[0] == '^') - { - // yes. Delete the '^' - // and read this - // multiplicity - name.erase(0,1); - - const std::pair tmp - = Utilities::get_integer_at_position (name, 0); - name.erase(0, tmp.second); - // add to length, - // including the '^' - base_multiplicities.push_back (tmp.first); - } - else - // no, so - // multiplicity is - // 1 - base_multiplicities.push_back (1); - - // so that's it for - // this base - // element. base - // elements are - // separated by '-', - // and the list is - // terminated by ']', - // so loop while the - // next character is - // '-' - } - while (name[0] == '-'); - - // so we got to the end - // of the '-' separated - // list. make sure that - // we actually had a ']' - // there - if (name.size() == 0 || name[0] != ']') - throw (std::string("Invalid first character in ") + name); - name.erase(0,1); - // just one more sanity check - Assert ((base_fes.size() == base_multiplicities.size()) - && - (base_fes.size() > 0), - ExcInternalError()); - - // ok, apparently - // everything went ok. so - // generate the composed - // element - FiniteElement *system_element = 0; + // Extract the name of the + // finite element class, which only + // contains characters, numbers and + // underscores. + unsigned int name_end = + name.find_first_not_of(std::string("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_")); + const std::string name_part(name, 0, name_end); + name.erase(0, name_part.size()); + + // now things get a little more + // complicated: FESystem. it's + // more complicated, since we + // have to figure out what the + // base elements are. this can + // only be done recursively + + + + + if (name_part == "FESystem") + { + // next we have to get at the + // base elements. start with + // the first. wrap the whole + // block into try-catch to + // make sure we destroy the + // pointers we got from + // recursive calls if one of + // these calls should throw + // an exception + std::vector*> base_fes; + std::vector base_multiplicities; + try + { + // Now, just the [...] + // part should be left. + if (name.size() == 0 || name[0] != '[') + throw (std::string("Invalid first character in ") + name); + do + { + // Erase the + // leading '[' or '-' + name.erase(0,1); + // Now, the name of the + // first base element is + // first... Let's get it + base_fes.push_back (get_fe_from_name_ext (name, + fe_name_map)); + // next check whether + // FESystem placed a + // multiplicity after + // the element name + if (name[0] == '^') + { + // yes. Delete the '^' + // and read this + // multiplicity + name.erase(0,1); + + const std::pair tmp + = Utilities::get_integer_at_position (name, 0); + name.erase(0, tmp.second); + // add to length, + // including the '^' + base_multiplicities.push_back (tmp.first); + } + else + // no, so + // multiplicity is + // 1 + base_multiplicities.push_back (1); + + // so that's it for + // this base + // element. base + // elements are + // separated by '-', + // and the list is + // terminated by ']', + // so loop while the + // next character is + // '-' + } + while (name[0] == '-'); + + // so we got to the end + // of the '-' separated + // list. make sure that + // we actually had a ']' + // there + if (name.size() == 0 || name[0] != ']') + throw (std::string("Invalid first character in ") + name); + name.erase(0,1); + // just one more sanity check + Assert ((base_fes.size() == base_multiplicities.size()) + && + (base_fes.size() > 0), + ExcInternalError()); + + // ok, apparently + // everything went ok. so + // generate the composed + // element + FiniteElement *system_element = 0; // uses new FESystem constructor // which is independent of @@ -2140,113 +2140,113 @@ namespace FETools system_element = new FESystem(base_fes, base_multiplicities); - // now we don't need the - // list of base elements - // any more - for (unsigned int i=0; isecond->get(1); - } - else - { - // Make sure no other thread - // is just adding an element - Threads::ThreadMutex::ScopedLock lock (fe_name_map_lock); - - AssertThrow (fe_name_map.find(name_part) != fe_name_map.end(), - ExcInvalidFEName(name)); - // Now, just the (degree) - // or (Quadrature<1>(degree+1)) - // part should be left. - if (name.size() == 0 || name[0] != '(') - throw (std::string("Invalid first character in ") + name); - name.erase(0,1); - if (name[0] != 'Q') - { - const std::pair tmp - = Utilities::get_integer_at_position (name, 0); - name.erase(0, tmp.second+1); - return fe_name_map.find(name_part)->second->get(tmp.first); - } - else - { - unsigned int position = name.find('('); - const std::string quadrature_name(name, 0, position); - name.erase(0,position+1); - if (quadrature_name.compare("QGaussLobatto") == 0) - { - const std::pair tmp - = Utilities::get_integer_at_position (name, 0); - // delete "))" - name.erase(0, tmp.second+2); - return fe_name_map.find(name_part)->second->get(QGaussLobatto<1>(tmp.first)); - } - else - { - AssertThrow (false,ExcNotImplemented()); - } - } - } - - - // hm, if we have come thus far, we - // didn't know what to do with the - // string we got. so do as the docs - // say: raise an exception - AssertThrow (false, ExcInvalidFEName(name)); - - // make some compilers happy that - // do not realize that we can't get - // here after throwing - return 0; + // now we don't need the + // list of base elements + // any more + for (unsigned int i=0; isecond->get(1); + } + else + { + // Make sure no other thread + // is just adding an element + Threads::ThreadMutex::ScopedLock lock (fe_name_map_lock); + + AssertThrow (fe_name_map.find(name_part) != fe_name_map.end(), + ExcInvalidFEName(name)); + // Now, just the (degree) + // or (Quadrature<1>(degree+1)) + // part should be left. + if (name.size() == 0 || name[0] != '(') + throw (std::string("Invalid first character in ") + name); + name.erase(0,1); + if (name[0] != 'Q') + { + const std::pair tmp + = Utilities::get_integer_at_position (name, 0); + name.erase(0, tmp.second+1); + return fe_name_map.find(name_part)->second->get(tmp.first); + } + else + { + unsigned int position = name.find('('); + const std::string quadrature_name(name, 0, position); + name.erase(0,position+1); + if (quadrature_name.compare("QGaussLobatto") == 0) + { + const std::pair tmp + = Utilities::get_integer_at_position (name, 0); + // delete "))" + name.erase(0, tmp.second+2); + return fe_name_map.find(name_part)->second->get(QGaussLobatto<1>(tmp.first)); + } + else + { + AssertThrow (false,ExcNotImplemented()); + } + } + } + + + // hm, if we have come thus far, we + // didn't know what to do with the + // string we got. so do as the docs + // say: raise an exception + AssertThrow (false, ExcInvalidFEName(name)); + + // make some compilers happy that + // do not realize that we can't get + // here after throwing + return 0; } - // need to work around problem with different - // name map names for different dimensions - // TODO: should be possible to do nicer! + // need to work around problem with different + // name map names for different dimensions + // TODO: should be possible to do nicer! template FiniteElement* get_fe_from_name (std::string &name); @@ -2254,21 +2254,21 @@ namespace FETools FiniteElement<1,1>* get_fe_from_name<1> (std::string &name) { - return get_fe_from_name_ext<1,1> (name, fe_name_map_1d); + return get_fe_from_name_ext<1,1> (name, fe_name_map_1d); } template <> FiniteElement<2,2>* get_fe_from_name<2> (std::string &name) { - return get_fe_from_name_ext<2,2> (name, fe_name_map_2d); + return get_fe_from_name_ext<2,2> (name, fe_name_map_2d); } template <> FiniteElement<3,3>* get_fe_from_name<3> (std::string &name) { - return get_fe_from_name_ext<3,3> (name, fe_name_map_3d); + return get_fe_from_name_ext<3,3> (name, fe_name_map_3d); } } } @@ -2281,69 +2281,69 @@ namespace FETools FiniteElement * get_fe_from_name (const std::string ¶meter_name) { - // Create a version of the name - // string where all template - // parameters are eliminated. + // Create a version of the name + // string where all template + // parameters are eliminated. std::string name = parameter_name; for (unsigned int pos1 = name.find('<'); - pos1 < name.size(); - pos1 = name.find('<')) + pos1 < name.size(); + pos1 = name.find('<')) { - const unsigned int pos2 = name.find('>'); - // If there is only a single - // character between those two, - // it should be 'd' or the number - // representing the dimension. - if (pos2-pos1 == 2) - { - const char dimchar = '0' + dim; - if (name.at(pos1+1) != 'd') - Assert (name.at(pos1+1) == dimchar, - ExcInvalidFEDimension(name.at(pos1+1), dim)); - } - else - Assert(pos2-pos1 == 4, ExcInvalidFEName(name)); - - // If pos1==pos2, then we are - // probably at the end of the - // string - if (pos2 != pos1) - name.erase(pos1, pos2-pos1+1); + const unsigned int pos2 = name.find('>'); + // If there is only a single + // character between those two, + // it should be 'd' or the number + // representing the dimension. + if (pos2-pos1 == 2) + { + const char dimchar = '0' + dim; + if (name.at(pos1+1) != 'd') + Assert (name.at(pos1+1) == dimchar, + ExcInvalidFEDimension(name.at(pos1+1), dim)); + } + else + Assert(pos2-pos1 == 4, ExcInvalidFEName(name)); + + // If pos1==pos2, then we are + // probably at the end of the + // string + if (pos2 != pos1) + name.erase(pos1, pos2-pos1+1); } - // Replace all occurences of "^dim" - // by "^d" to be handled by the - // next loop + // Replace all occurences of "^dim" + // by "^d" to be handled by the + // next loop for (unsigned int pos = name.find("^dim"); - pos < name.size(); - pos = name.find("^dim")) + pos < name.size(); + pos = name.find("^dim")) name.erase(pos+2, 2); - // Replace all occurences of "^d" - // by using the actual dimension + // Replace all occurences of "^d" + // by using the actual dimension for (unsigned int pos = name.find("^d"); - pos < name.size(); - pos = name.find("^d")) + pos < name.size(); + pos = name.find("^d")) name.at(pos+1) = '0' + dim; try { - FiniteElement *fe = internal::get_fe_from_name (name); - - // Make sure the auxiliary function - // ate up all characters of the name. - AssertThrow (name.size() == 0, - ExcInvalidFEName(parameter_name - + std::string(" extra characters after " - "end of name"))); - return fe; + FiniteElement *fe = internal::get_fe_from_name (name); + + // Make sure the auxiliary function + // ate up all characters of the name. + AssertThrow (name.size() == 0, + ExcInvalidFEName(parameter_name + + std::string(" extra characters after " + "end of name"))); + return fe; } catch (const std::string &errline) { - AssertThrow(false, ExcInvalidFEName(parameter_name - + std::string(" at ") - + errline)); - return 0; + AssertThrow(false, ExcInvalidFEName(parameter_name + + std::string(" at ") + + errline)); + return 0; } } @@ -2360,34 +2360,34 @@ namespace FETools void compute_projection_from_quadrature_points_matrix (const FiniteElement &fe, - const Quadrature &lhs_quadrature, - const Quadrature &rhs_quadrature, - FullMatrix &X) + const Quadrature &lhs_quadrature, + const Quadrature &rhs_quadrature, + FullMatrix &X) { Assert (fe.n_components() == 1, ExcNotImplemented()); - // first build the matrices M and Q - // described in the documentation + // first build the matrices M and Q + // described in the documentation FullMatrix M (fe.dofs_per_cell, fe.dofs_per_cell); FullMatrix Q (fe.dofs_per_cell, rhs_quadrature.size()); for (unsigned int i=0; i M_inverse (fe.dofs_per_cell, fe.dofs_per_cell); M_inverse.invert (M); - // finally compute the result + // finally compute the result X.reinit (fe.dofs_per_cell, rhs_quadrature.size()); M_inverse.mmult (X, Q); @@ -2400,17 +2400,17 @@ namespace FETools template void compute_interpolation_to_quadrature_points_matrix (const FiniteElement &fe, - const Quadrature &quadrature, - FullMatrix &I_q) + const Quadrature &quadrature, + FullMatrix &I_q) { Assert (fe.n_components() == 1, ExcNotImplemented()); Assert (I_q.m() == quadrature.size(), - ExcMessage ("Wrong matrix size")); + ExcMessage ("Wrong matrix size")); Assert (I_q.n() == fe.dofs_per_cell, ExcMessage ("Wrong matrix size")); for (unsigned int q=0; q > &vector_of_tensors_at_nodes) { - // check that the number columns of the projection_matrix - // matches the size of the vector_of_tensors_at_qp + // check that the number columns of the projection_matrix + // matches the size of the vector_of_tensors_at_qp Assert(projection_matrix.n_cols() == vector_of_tensors_at_qp.size(), - ExcDimensionMismatch(projection_matrix.n_cols(), - vector_of_tensors_at_qp.size())); + ExcDimensionMismatch(projection_matrix.n_cols(), + vector_of_tensors_at_qp.size())); - // check that the number rows of the projection_matrix - // matches the size of the vector_of_tensors_at_nodes + // check that the number rows of the projection_matrix + // matches the size of the vector_of_tensors_at_nodes Assert(projection_matrix.n_rows() == vector_of_tensors_at_nodes.size(), - ExcDimensionMismatch(projection_matrix.n_rows(), - vector_of_tensors_at_nodes.size())); + ExcDimensionMismatch(projection_matrix.n_rows(), + vector_of_tensors_at_nodes.size())); - // number of support points (nodes) to project to + // number of support points (nodes) to project to const unsigned int n_support_points = projection_matrix.n_rows(); - // number of quadrature points to project from + // number of quadrature points to project from const unsigned int n_quad_points = projection_matrix.n_cols(); - // component projected to the nodes + // component projected to the nodes Vector component_at_node(n_support_points); - // component at the quadrature point + // component at the quadrature point Vector component_at_qp(n_quad_points); for (unsigned int ii = 0; ii < dim; ++ii) { component_at_qp = 0; - // populate the vector of components at the qps - // from vector_of_tensors_at_qp - // vector_of_tensors_at_qp data is in form: - // columns: 0, 1, ..., dim - // rows: 0,1,...., n_quad_points - // so extract the ii'th column of vector_of_tensors_at_qp + // populate the vector of components at the qps + // from vector_of_tensors_at_qp + // vector_of_tensors_at_qp data is in form: + // columns: 0, 1, ..., dim + // rows: 0,1,...., n_quad_points + // so extract the ii'th column of vector_of_tensors_at_qp for (unsigned int q = 0; q < n_quad_points; ++q) { - component_at_qp(q) = vector_of_tensors_at_qp[q][ii]; + component_at_qp(q) = vector_of_tensors_at_qp[q][ii]; } - // project from the qps -> nodes - // component_at_node = projection_matrix_u * component_at_qp + // project from the qps -> nodes + // component_at_node = projection_matrix_u * component_at_qp projection_matrix.vmult(component_at_node, component_at_qp); - // rewrite the projection of the components - // back into the vector of tensors + // rewrite the projection of the components + // back into the vector of tensors for (unsigned int nn =0; nn > &vector_of_tensors_at_nodes) { - // check that the number columns of the projection_matrix - // matches the size of the vector_of_tensors_at_qp + // check that the number columns of the projection_matrix + // matches the size of the vector_of_tensors_at_qp Assert(projection_matrix.n_cols() == vector_of_tensors_at_qp.size(), - ExcDimensionMismatch(projection_matrix.n_cols(), - vector_of_tensors_at_qp.size())); + ExcDimensionMismatch(projection_matrix.n_cols(), + vector_of_tensors_at_qp.size())); - // check that the number rows of the projection_matrix - // matches the size of the vector_of_tensors_at_nodes + // check that the number rows of the projection_matrix + // matches the size of the vector_of_tensors_at_nodes Assert(projection_matrix.n_rows() == vector_of_tensors_at_nodes.size(), - ExcDimensionMismatch(projection_matrix.n_rows(), - vector_of_tensors_at_nodes.size())); + ExcDimensionMismatch(projection_matrix.n_rows(), + vector_of_tensors_at_nodes.size())); - // number of support points (nodes) + // number of support points (nodes) const unsigned int n_support_points = projection_matrix.n_rows(); - // number of quadrature points to project from + // number of quadrature points to project from const unsigned int n_quad_points = projection_matrix.n_cols(); - // number of unique entries in a symmetric second-order tensor + // number of unique entries in a symmetric second-order tensor const unsigned int n_independent_components = SymmetricTensor<2, dim >::n_independent_components; - // component projected to the nodes + // component projected to the nodes Vector component_at_node(n_support_points); - // component at the quadrature point + // component at the quadrature point Vector component_at_qp(n_quad_points); - // loop over the number of unique dimensions of the tensor + // loop over the number of unique dimensions of the tensor for (unsigned int ii = 0; ii < n_independent_components; ++ii) { component_at_qp = 0; - // row-column entry of tensor corresponding the unrolled index + // row-column entry of tensor corresponding the unrolled index TableIndices<2> row_column_index = SymmetricTensor< 2, dim >::unrolled_to_component_indices(ii); const unsigned int row = row_column_index[0]; const unsigned int column = row_column_index[1]; - // populate the vector of components at the qps - // from vector_of_tensors_at_qp - // vector_of_tensors_at_qp is in form: - // columns: 0, 1, ..., n_independent_components - // rows: 0,1,...., n_quad_points - // so extract the ii'th column of vector_of_tensors_at_qp + // populate the vector of components at the qps + // from vector_of_tensors_at_qp + // vector_of_tensors_at_qp is in form: + // columns: 0, 1, ..., n_independent_components + // rows: 0,1,...., n_quad_points + // so extract the ii'th column of vector_of_tensors_at_qp for (unsigned int q = 0; q < n_quad_points; ++q) { - component_at_qp(q) = (vector_of_tensors_at_qp[q])[row][column]; + component_at_qp(q) = (vector_of_tensors_at_qp[q])[row][column]; } - // project from the qps -> nodes - // component_at_node = projection_matrix_u * component_at_qp + // project from the qps -> nodes + // component_at_node = projection_matrix_u * component_at_qp projection_matrix.vmult(component_at_node, component_at_qp); - // rewrite the projection of the components back into the vector of tensors + // rewrite the projection of the components back into the vector of tensors for (unsigned int nn =0; nn void compute_projection_from_face_quadrature_points_matrix (const FiniteElement &fe, - const Quadrature &lhs_quadrature, - const Quadrature &rhs_quadrature, - const typename DoFHandler::active_cell_iterator & cell, - unsigned int face, - FullMatrix &X) + const Quadrature &lhs_quadrature, + const Quadrature &rhs_quadrature, + const typename DoFHandler::active_cell_iterator & cell, + unsigned int face, + FullMatrix &X) { Assert (fe.n_components() == 1, ExcNotImplemented()); Assert (lhs_quadrature.size () > fe.degree, ExcNotGreaterThan (lhs_quadrature.size (), fe.degree)); - // build the matrices M and Q - // described in the documentation + // build the matrices M and Q + // described in the documentation FullMatrix M (fe.dofs_per_cell, fe.dofs_per_cell); FullMatrix Q (fe.dofs_per_cell, rhs_quadrature.size()); { - // need an FEFaceValues object to evaluate shape function - // values on the specified face. + // need an FEFaceValues object to evaluate shape function + // values on the specified face. FEFaceValues fe_face_values (fe, lhs_quadrature, update_values); fe_face_values.reinit (cell, face); // setup shape_value on this face. for (unsigned int i=0; i M_inverse (fe.dofs_per_cell, fe.dofs_per_cell); M_inverse.invert (M); - // finally compute the result + // finally compute the result X.reinit (fe.dofs_per_cell, rhs_quadrature.size()); M_inverse.mmult (X, Q); @@ -2603,10 +2603,10 @@ namespace FETools template void hierarchic_to_lexicographic_numbering (const FiniteElementData &fe, - std::vector &h2l) + std::vector &h2l) { Assert (h2l.size() == fe.dofs_per_cell, - ExcDimensionMismatch (h2l.size(), fe.dofs_per_cell)); + ExcDimensionMismatch (h2l.size(), fe.dofs_per_cell)); h2l = hierarchic_to_lexicographic_numbering (fe); } @@ -2621,169 +2621,169 @@ namespace FETools std::vector h2l (fe.dofs_per_cell); const unsigned int dofs_per_cell = fe.dofs_per_cell; - // polynomial degree + // polynomial degree const unsigned int degree = fe.dofs_per_line+1; - // number of grid points in each - // direction + // number of grid points in each + // direction const unsigned int n = degree+1; - // the following lines of code are - // somewhat odd, due to the way the - // hierarchic numbering is - // organized. if someone would - // really want to understand these - // lines, you better draw some - // pictures where you indicate the - // indices and orders of vertices, - // lines, etc, along with the - // numbers of the degrees of - // freedom in hierarchical and - // lexicographical order + // the following lines of code are + // somewhat odd, due to the way the + // hierarchic numbering is + // organized. if someone would + // really want to understand these + // lines, you better draw some + // pictures where you indicate the + // indices and orders of vertices, + // lines, etc, along with the + // numbers of the degrees of + // freedom in hierarchical and + // lexicographical order switch (dim) { - case 1: - { - h2l[0] = 0; - h2l[1] = dofs_per_cell-1; - for (unsigned int i=2; i void lexicographic_to_hierarchic_numbering (const FiniteElementData &fe, - std::vector &l2h) + std::vector &l2h) { l2h = lexicographic_to_hierarchic_numbering (fe); } diff --git a/deal.II/source/fe/fe_values.cc b/deal.II/source/fe/fe_values.cc index 71ed640d73..0dafb49d89 100644 --- a/deal.II/source/fe/fe_values.cc +++ b/deal.II/source/fe/fe_values.cc @@ -40,7 +40,7 @@ namespace template double get_vector_element (const VectorType &vector, - const unsigned int cell_number) + const unsigned int cell_number) { return vector[cell_number]; } @@ -48,7 +48,7 @@ namespace double get_vector_element (const IndexSet &is, - const unsigned int cell_number) + const unsigned int cell_number) { return (is.is_element(cell_number) ? 1 : 0); } @@ -81,8 +81,8 @@ namespace unsigned int row = 0; for (unsigned int i=0; i Scalar::Scalar (const FEValuesBase &fe_values, - const unsigned int component) - : - fe_values (fe_values), - component (component), - shape_function_data (fe_values.fe->dofs_per_cell) + const unsigned int component) + : + fe_values (fe_values), + component (component), + shape_function_data (fe_values.fe->dofs_per_cell) { Assert (component < fe_values.fe->n_components(), - ExcIndexRange(component, 0, fe_values.fe->n_components())); + ExcIndexRange(component, 0, fe_values.fe->n_components())); const std::vector shape_function_to_row_table = make_shape_function_to_row_table (*fe_values.fe); for (unsigned int i=0; idofs_per_cell; ++i) { - const bool is_primitive = (fe_values.fe->is_primitive() || - fe_values.fe->is_primitive(i)); - - if (is_primitive == true) - shape_function_data[i].is_nonzero_shape_function_component - = (component == - fe_values.fe->system_to_component_index(i).first); - else - shape_function_data[i].is_nonzero_shape_function_component - = (fe_values.fe->get_nonzero_components(i)[component] - == true); - - if (shape_function_data[i].is_nonzero_shape_function_component == true) - { - if (is_primitive == true) - shape_function_data[i].row_index = shape_function_to_row_table[i]; - else - shape_function_data[i].row_index - = (shape_function_to_row_table[i] - + - std::count (fe_values.fe->get_nonzero_components(i).begin(), - fe_values.fe->get_nonzero_components(i).begin()+ - component, - true)); - } - else - shape_function_data[i].row_index = numbers::invalid_unsigned_int; + const bool is_primitive = (fe_values.fe->is_primitive() || + fe_values.fe->is_primitive(i)); + + if (is_primitive == true) + shape_function_data[i].is_nonzero_shape_function_component + = (component == + fe_values.fe->system_to_component_index(i).first); + else + shape_function_data[i].is_nonzero_shape_function_component + = (fe_values.fe->get_nonzero_components(i)[component] + == true); + + if (shape_function_data[i].is_nonzero_shape_function_component == true) + { + if (is_primitive == true) + shape_function_data[i].row_index = shape_function_to_row_table[i]; + else + shape_function_data[i].row_index + = (shape_function_to_row_table[i] + + + std::count (fe_values.fe->get_nonzero_components(i).begin(), + fe_values.fe->get_nonzero_components(i).begin()+ + component, + true)); + } + else + shape_function_data[i].row_index = numbers::invalid_unsigned_int; } } @@ -143,9 +143,9 @@ namespace FEValuesViews template Scalar::Scalar () - : - fe_values (*static_cast*>(0)), - component (numbers::invalid_unsigned_int) + : + fe_values (*static_cast*>(0)), + component (numbers::invalid_unsigned_int) {} @@ -153,7 +153,7 @@ namespace FEValuesViews Scalar & Scalar::operator= (const Scalar &) { - // we shouldn't be copying these objects + // we shouldn't be copying these objects Assert (false, ExcInternalError()); return *this; } @@ -162,92 +162,92 @@ namespace FEValuesViews template Vector::Vector (const FEValuesBase &fe_values, - const unsigned int first_vector_component) - : - fe_values (fe_values), - first_vector_component (first_vector_component), - shape_function_data (fe_values.fe->dofs_per_cell) + const unsigned int first_vector_component) + : + fe_values (fe_values), + first_vector_component (first_vector_component), + shape_function_data (fe_values.fe->dofs_per_cell) { Assert (first_vector_component+spacedim-1 < fe_values.fe->n_components(), - ExcIndexRange(first_vector_component+spacedim-1, 0, - fe_values.fe->n_components())); + ExcIndexRange(first_vector_component+spacedim-1, 0, + fe_values.fe->n_components())); const std::vector shape_function_to_row_table = make_shape_function_to_row_table (*fe_values.fe); for (unsigned int d=0; ddofs_per_cell; ++i) - { - const bool is_primitive = (fe_values.fe->is_primitive() || - fe_values.fe->is_primitive(i)); - - if (is_primitive == true) - shape_function_data[i].is_nonzero_shape_function_component[d] - = (component == - fe_values.fe->system_to_component_index(i).first); - else - shape_function_data[i].is_nonzero_shape_function_component[d] - = (fe_values.fe->get_nonzero_components(i)[component] - == true); - - if (shape_function_data[i].is_nonzero_shape_function_component[d] - == true) - { - if (is_primitive == true) - shape_function_data[i].row_index[d] - = shape_function_to_row_table[i]; - else - shape_function_data[i].row_index[d] - = (shape_function_to_row_table[i] - + - std::count (fe_values.fe->get_nonzero_components(i).begin(), - fe_values.fe->get_nonzero_components(i).begin()+ - component, - true)); - } - else - shape_function_data[i].row_index[d] - = numbers::invalid_unsigned_int; - } + const unsigned int component = first_vector_component + d; + + for (unsigned int i=0; idofs_per_cell; ++i) + { + const bool is_primitive = (fe_values.fe->is_primitive() || + fe_values.fe->is_primitive(i)); + + if (is_primitive == true) + shape_function_data[i].is_nonzero_shape_function_component[d] + = (component == + fe_values.fe->system_to_component_index(i).first); + else + shape_function_data[i].is_nonzero_shape_function_component[d] + = (fe_values.fe->get_nonzero_components(i)[component] + == true); + + if (shape_function_data[i].is_nonzero_shape_function_component[d] + == true) + { + if (is_primitive == true) + shape_function_data[i].row_index[d] + = shape_function_to_row_table[i]; + else + shape_function_data[i].row_index[d] + = (shape_function_to_row_table[i] + + + std::count (fe_values.fe->get_nonzero_components(i).begin(), + fe_values.fe->get_nonzero_components(i).begin()+ + component, + true)); + } + else + shape_function_data[i].row_index[d] + = numbers::invalid_unsigned_int; + } } for (unsigned int i=0; idofs_per_cell; ++i) { - unsigned int n_nonzero_components = 0; - for (unsigned int d=0; d 1) - shape_function_data[i].single_nonzero_component = -1; - else - { - for (unsigned int d=0; d 1) + shape_function_data[i].single_nonzero_component = -1; + else + { + for (unsigned int d=0; d Vector::Vector () - : - fe_values (*static_cast*>(0)), - first_vector_component (numbers::invalid_unsigned_int) + : + fe_values (*static_cast*>(0)), + first_vector_component (numbers::invalid_unsigned_int) {} @@ -256,7 +256,7 @@ namespace FEValuesViews Vector & Vector::operator= (const Vector &) { - // we shouldn't be copying these objects + // we shouldn't be copying these objects Assert (false, ExcInternalError()); return *this; } @@ -265,87 +265,87 @@ namespace FEValuesViews template SymmetricTensor<2, dim, spacedim>:: SymmetricTensor(const FEValuesBase &fe_values, - const unsigned int first_tensor_component) - : - fe_values(fe_values), - first_tensor_component(first_tensor_component), - shape_function_data(fe_values.fe->dofs_per_cell) + const unsigned int first_tensor_component) + : + fe_values(fe_values), + first_tensor_component(first_tensor_component), + shape_function_data(fe_values.fe->dofs_per_cell) { Assert(first_tensor_component + (dim*dim+dim)/2 - 1 - < - fe_values.fe->n_components(), - ExcIndexRange(first_tensor_component + - dealii::SymmetricTensor<2,dim>::n_independent_components - 1, - 0, - fe_values.fe->n_components())); + < + fe_values.fe->n_components(), + ExcIndexRange(first_tensor_component + + dealii::SymmetricTensor<2,dim>::n_independent_components - 1, + 0, + fe_values.fe->n_components())); const std::vector shape_function_to_row_table = make_shape_function_to_row_table(*fe_values.fe); for (unsigned int d = 0; d < dealii::SymmetricTensor<2,dim>::n_independent_components; ++d) { - const unsigned int component = first_tensor_component + d; - - for (unsigned int i = 0; i < fe_values.fe->dofs_per_cell; ++i) - { - const bool is_primitive = (fe_values.fe->is_primitive() || - fe_values.fe->is_primitive(i)); - - if (is_primitive == true) - shape_function_data[i].is_nonzero_shape_function_component[d] - = (component == - fe_values.fe->system_to_component_index(i).first); - else - shape_function_data[i].is_nonzero_shape_function_component[d] - = (fe_values.fe->get_nonzero_components(i)[component] - == true); - - if (shape_function_data[i].is_nonzero_shape_function_component[d] - == true) - { - if (is_primitive == true) - shape_function_data[i].row_index[d] - = shape_function_to_row_table[i]; - else - shape_function_data[i].row_index[d] - = (shape_function_to_row_table[i] - + - std::count(fe_values.fe->get_nonzero_components(i).begin(), - fe_values.fe->get_nonzero_components(i).begin() + - component, - true)); - } - else - shape_function_data[i].row_index[d] - = numbers::invalid_unsigned_int; - } + const unsigned int component = first_tensor_component + d; + + for (unsigned int i = 0; i < fe_values.fe->dofs_per_cell; ++i) + { + const bool is_primitive = (fe_values.fe->is_primitive() || + fe_values.fe->is_primitive(i)); + + if (is_primitive == true) + shape_function_data[i].is_nonzero_shape_function_component[d] + = (component == + fe_values.fe->system_to_component_index(i).first); + else + shape_function_data[i].is_nonzero_shape_function_component[d] + = (fe_values.fe->get_nonzero_components(i)[component] + == true); + + if (shape_function_data[i].is_nonzero_shape_function_component[d] + == true) + { + if (is_primitive == true) + shape_function_data[i].row_index[d] + = shape_function_to_row_table[i]; + else + shape_function_data[i].row_index[d] + = (shape_function_to_row_table[i] + + + std::count(fe_values.fe->get_nonzero_components(i).begin(), + fe_values.fe->get_nonzero_components(i).begin() + + component, + true)); + } + else + shape_function_data[i].row_index[d] + = numbers::invalid_unsigned_int; + } } for (unsigned int i = 0; i < fe_values.fe->dofs_per_cell; ++i) { - unsigned int n_nonzero_components = 0; - for (unsigned int d = 0; d < dealii::SymmetricTensor<2,dim>::n_independent_components; ++d) - if (shape_function_data[i].is_nonzero_shape_function_component[d] - == true) - ++n_nonzero_components; - - if (n_nonzero_components == 0) - shape_function_data[i].single_nonzero_component = -2; - else if (n_nonzero_components > 1) - shape_function_data[i].single_nonzero_component = -1; - else - { - for (unsigned int d = 0; d < dealii::SymmetricTensor<2,dim>::n_independent_components; ++d) - if (shape_function_data[i].is_nonzero_shape_function_component[d] - == true) - { - shape_function_data[i].single_nonzero_component - = shape_function_data[i].row_index[d]; - shape_function_data[i].single_nonzero_component_index - = d; - break; - } - } + unsigned int n_nonzero_components = 0; + for (unsigned int d = 0; d < dealii::SymmetricTensor<2,dim>::n_independent_components; ++d) + if (shape_function_data[i].is_nonzero_shape_function_component[d] + == true) + ++n_nonzero_components; + + if (n_nonzero_components == 0) + shape_function_data[i].single_nonzero_component = -2; + else if (n_nonzero_components > 1) + shape_function_data[i].single_nonzero_component = -1; + else + { + for (unsigned int d = 0; d < dealii::SymmetricTensor<2,dim>::n_independent_components; ++d) + if (shape_function_data[i].is_nonzero_shape_function_component[d] + == true) + { + shape_function_data[i].single_nonzero_component + = shape_function_data[i].row_index[d]; + shape_function_data[i].single_nonzero_component_index + = d; + break; + } + } } } @@ -353,9 +353,9 @@ namespace FEValuesViews template SymmetricTensor<2, dim, spacedim>::SymmetricTensor() - : - fe_values(*static_cast*> (0)), - first_tensor_component(numbers::invalid_unsigned_int) + : + fe_values(*static_cast*> (0)), + first_tensor_component(numbers::invalid_unsigned_int) {} @@ -364,7 +364,7 @@ namespace FEValuesViews SymmetricTensor<2, dim, spacedim> & SymmetricTensor<2, dim, spacedim>::operator=(const SymmetricTensor<2, dim, spacedim> &) { - // we shouldn't be copying these objects + // we shouldn't be copying these objects Assert(false, ExcInternalError()); return *this; } @@ -376,39 +376,39 @@ namespace FEValuesViews void Scalar:: get_function_values (const InputVector &fe_function, - std::vector &values) const + std::vector &values) const { typedef FEValuesBase FVB; Assert (fe_values.update_flags & update_values, - typename FVB::ExcAccessToUninitializedField()); + typename FVB::ExcAccessToUninitializedField()); Assert (values.size() == fe_values.n_quadrature_points, - ExcDimensionMismatch(values.size(), fe_values.n_quadrature_points)); + ExcDimensionMismatch(values.size(), fe_values.n_quadrature_points)); Assert (fe_values.present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == fe_values.present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - fe_values.present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + fe_values.present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (values.begin(), values.end(), value_type()); for (unsigned int shape_function=0; - shape_functiondofs_per_cell; ++shape_function) + shape_functiondofs_per_cell; ++shape_function) if (shape_function_data[shape_function].is_nonzero_shape_function_component) - { - const double value = dof_values(shape_function); - if (value == 0.) - continue; - - const double * shape_value_ptr = - &fe_values.shape_values(shape_function_data[shape_function].row_index, 0); - for (unsigned int q_point=0; q_point:: get_function_gradients (const InputVector &fe_function, - std::vector &gradients) const + std::vector &gradients) const { typedef FEValuesBase FVB; Assert (fe_values.update_flags & update_gradients, - typename FVB::ExcAccessToUninitializedField()); + typename FVB::ExcAccessToUninitializedField()); Assert (gradients.size() == fe_values.n_quadrature_points, - ExcDimensionMismatch(gradients.size(), fe_values.n_quadrature_points)); + ExcDimensionMismatch(gradients.size(), fe_values.n_quadrature_points)); Assert (fe_values.present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == fe_values.present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - fe_values.present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + fe_values.present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (gradients.begin(), gradients.end(), gradient_type()); for (unsigned int shape_function=0; - shape_functiondofs_per_cell; ++shape_function) + shape_functiondofs_per_cell; ++shape_function) if (shape_function_data[shape_function].is_nonzero_shape_function_component) - { - const double value = dof_values(shape_function); - if (value == 0.) - continue; - - const Tensor<1,spacedim> * shape_gradient_ptr = - &fe_values.shape_gradients[shape_function_data[shape_function]. - row_index][0]; - for (unsigned int q_point=0; q_point * shape_gradient_ptr = + &fe_values.shape_gradients[shape_function_data[shape_function]. + row_index][0]; + for (unsigned int q_point=0; q_point:: get_function_hessians (const InputVector &fe_function, - std::vector &hessians) const + std::vector &hessians) const { typedef FEValuesBase FVB; Assert (fe_values.update_flags & update_hessians, - typename FVB::ExcAccessToUninitializedField()); + typename FVB::ExcAccessToUninitializedField()); Assert (hessians.size() == fe_values.n_quadrature_points, - ExcDimensionMismatch(hessians.size(), fe_values.n_quadrature_points)); + ExcDimensionMismatch(hessians.size(), fe_values.n_quadrature_points)); Assert (fe_values.present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == fe_values.present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - fe_values.present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + fe_values.present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (hessians.begin(), hessians.end(), hessian_type()); for (unsigned int shape_function=0; - shape_functiondofs_per_cell; ++shape_function) + shape_functiondofs_per_cell; ++shape_function) if (shape_function_data[shape_function].is_nonzero_shape_function_component) - { - const double value = dof_values(shape_function); - if (value == 0.) - continue; - - const Tensor<2,spacedim> * shape_hessian_ptr = - &fe_values.shape_hessians[shape_function_data[shape_function]. - row_index][0]; - for (unsigned int q_point=0; q_point * shape_hessian_ptr = + &fe_values.shape_hessians[shape_function_data[shape_function]. + row_index][0]; + for (unsigned int q_point=0; q_point:: get_function_laplacians (const InputVector &fe_function, - std::vector &laplacians) const + std::vector &laplacians) const { typedef FEValuesBase FVB; Assert (fe_values.update_flags & update_hessians, - typename FVB::ExcAccessToUninitializedField()); + typename FVB::ExcAccessToUninitializedField()); Assert (laplacians.size() == fe_values.n_quadrature_points, - ExcDimensionMismatch(laplacians.size(), fe_values.n_quadrature_points)); + ExcDimensionMismatch(laplacians.size(), fe_values.n_quadrature_points)); Assert (fe_values.present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == fe_values.present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - fe_values.present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + fe_values.present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (laplacians.begin(), laplacians.end(), value_type()); for (unsigned int shape_function=0; - shape_functiondofs_per_cell; ++shape_function) + shape_functiondofs_per_cell; ++shape_function) if (shape_function_data[shape_function].is_nonzero_shape_function_component) - { - const double value = dof_values(shape_function); - if (value == 0.) - continue; - - const unsigned int row_index = shape_function_data[shape_function].row_index; - for (unsigned int q_point=0; q_point:: get_function_values (const InputVector &fe_function, - std::vector &values) const + std::vector &values) const { typedef FEValuesBase FVB; Assert (fe_values.update_flags & update_values, - typename FVB::ExcAccessToUninitializedField()); + typename FVB::ExcAccessToUninitializedField()); Assert (values.size() == fe_values.n_quadrature_points, - ExcDimensionMismatch(values.size(), fe_values.n_quadrature_points)); + ExcDimensionMismatch(values.size(), fe_values.n_quadrature_points)); Assert (fe_values.present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == fe_values.present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - fe_values.present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + fe_values.present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (values.begin(), values.end(), value_type()); for (unsigned int shape_function=0; - shape_functiondofs_per_cell; ++shape_function) + shape_functiondofs_per_cell; ++shape_function) { - const int snc = shape_function_data[shape_function].single_nonzero_component; - - if (snc == -2) - // shape function is zero for the - // selected components - continue; - - const double value = dof_values(shape_function); - if (value == 0.) - continue; - - if (snc != -1) - { - const unsigned int comp = - shape_function_data[shape_function].single_nonzero_component_index; - const double * shape_value_ptr = &fe_values.shape_values(snc,0); - for (unsigned int q_point=0; q_point:: get_function_gradients (const InputVector &fe_function, - std::vector &gradients) const + std::vector &gradients) const { typedef FEValuesBase FVB; Assert (fe_values.update_flags & update_gradients, - typename FVB::ExcAccessToUninitializedField()); + typename FVB::ExcAccessToUninitializedField()); Assert (gradients.size() == fe_values.n_quadrature_points, - ExcDimensionMismatch(gradients.size(), fe_values.n_quadrature_points)); + ExcDimensionMismatch(gradients.size(), fe_values.n_quadrature_points)); Assert (fe_values.present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == fe_values.present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - fe_values.present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + fe_values.present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (gradients.begin(), gradients.end(), gradient_type()); for (unsigned int shape_function=0; - shape_functiondofs_per_cell; ++shape_function) + shape_functiondofs_per_cell; ++shape_function) { - const int snc = shape_function_data[shape_function].single_nonzero_component; - - if (snc == -2) - // shape function is zero for the - // selected components - continue; - - const double value = dof_values(shape_function); - if (value == 0.) - continue; - - if (snc != -1) - { - const unsigned int comp = - shape_function_data[shape_function].single_nonzero_component_index; - const Tensor<1,spacedim> * shape_gradient_ptr = - &fe_values.shape_gradients[snc][0]; - for (unsigned int q_point=0; q_point * shape_gradient_ptr = - &fe_values.shape_gradients[shape_function_data[shape_function]. - row_index[d]][0]; - for (unsigned int q_point=0; q_point * shape_gradient_ptr = + &fe_values.shape_gradients[snc][0]; + for (unsigned int q_point=0; q_point * shape_gradient_ptr = + &fe_values.shape_gradients[shape_function_data[shape_function]. + row_index[d]][0]; + for (unsigned int q_point=0; q_point:: get_function_symmetric_gradients (const InputVector &fe_function, - std::vector &symmetric_gradients) const + std::vector &symmetric_gradients) const { typedef FEValuesBase FVB; Assert (fe_values.update_flags & update_gradients, - typename FVB::ExcAccessToUninitializedField()); + typename FVB::ExcAccessToUninitializedField()); Assert (symmetric_gradients.size() == fe_values.n_quadrature_points, - ExcDimensionMismatch(symmetric_gradients.size(), fe_values.n_quadrature_points)); + ExcDimensionMismatch(symmetric_gradients.size(), fe_values.n_quadrature_points)); Assert (fe_values.present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == fe_values.present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - fe_values.present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + fe_values.present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (symmetric_gradients.begin(), symmetric_gradients.end(), - symmetric_gradient_type()); + symmetric_gradient_type()); for (unsigned int shape_function=0; - shape_functiondofs_per_cell; ++shape_function) + shape_functiondofs_per_cell; ++shape_function) { - const int snc = shape_function_data[shape_function].single_nonzero_component; - - if (snc == -2) - // shape function is zero for the - // selected components - continue; - - const double value = dof_values(shape_function); - if (value == 0.) - continue; - - if (snc != -1) - { - const unsigned int comp = - shape_function_data[shape_function].single_nonzero_component_index; - const Tensor<1,spacedim> * shape_gradient_ptr = - &fe_values.shape_gradients[snc][0]; - for (unsigned int q_point=0; q_point * shape_gradient_ptr = + &fe_values.shape_gradients[snc][0]; + for (unsigned int q_point=0; q_point:: get_function_divergences (const InputVector &fe_function, - std::vector &divergences) const + std::vector &divergences) const { typedef FEValuesBase FVB; Assert (fe_values.update_flags & update_gradients, - typename FVB::ExcAccessToUninitializedField()); + typename FVB::ExcAccessToUninitializedField()); Assert (divergences.size() == fe_values.n_quadrature_points, - ExcDimensionMismatch(divergences.size(), fe_values.n_quadrature_points)); + ExcDimensionMismatch(divergences.size(), fe_values.n_quadrature_points)); Assert (fe_values.present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == fe_values.present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - fe_values.present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + fe_values.present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (divergences.begin(), divergences.end(), divergence_type()); for (unsigned int shape_function=0; - shape_functiondofs_per_cell; ++shape_function) + shape_functiondofs_per_cell; ++shape_function) { - const int snc = shape_function_data[shape_function].single_nonzero_component; - - if (snc == -2) - // shape function is zero for the - // selected components - continue; - - const double value = dof_values(shape_function); - if (value == 0.) - continue; - - if (snc != -1) - { - const unsigned int comp = - shape_function_data[shape_function].single_nonzero_component_index; - const Tensor<1,spacedim> * shape_gradient_ptr = - &fe_values.shape_gradients[snc][0]; - for (unsigned int q_point=0; q_point * shape_gradient_ptr = - &fe_values.shape_gradients[shape_function_data[shape_function]. - row_index[d]][0]; - for (unsigned int q_point=0; q_point * shape_gradient_ptr = + &fe_values.shape_gradients[snc][0]; + for (unsigned int q_point=0; q_point * shape_gradient_ptr = + &fe_values.shape_gradients[shape_function_data[shape_function]. + row_index[d]][0]; + for (unsigned int q_point=0; q_point:: get_function_curls (const InputVector &fe_function, - std::vector &curls) const + std::vector &curls) const { typedef FEValuesBase FVB; Assert (fe_values.update_flags & update_gradients, - typename FVB::ExcAccessToUninitializedField()); + typename FVB::ExcAccessToUninitializedField()); Assert (curls.size() == fe_values.n_quadrature_points, - ExcDimensionMismatch (curls.size(), fe_values.n_quadrature_points)); + ExcDimensionMismatch (curls.size(), fe_values.n_quadrature_points)); Assert (fe_values.present_cell.get () != 0, - ExcMessage ("FEValues object is not reinited to any cell")); + ExcMessage ("FEValues object is not reinited to any cell")); Assert (fe_function.size () == fe_values.present_cell->n_dofs_for_dof_handler (), - ExcDimensionMismatch (fe_function.size (), fe_values.present_cell->n_dofs_for_dof_handler ())); - // get function values of dofs on this cell + ExcDimensionMismatch (fe_function.size (), fe_values.present_cell->n_dofs_for_dof_handler ())); + // get function values of dofs on this cell dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values (fe_function, dof_values); @@ -817,168 +817,168 @@ namespace FEValuesViews switch (dim) { - case 1: - { - Assert (false, ExcMessage("Computing the curl in 1d is not a useful operation")); - break; - } + case 1: + { + Assert (false, ExcMessage("Computing the curl in 1d is not a useful operation")); + break; + } case 2: - { - for (unsigned int shape_function = 0; - shape_function < fe_values.fe->dofs_per_cell; ++shape_function) - { + { + for (unsigned int shape_function = 0; + shape_function < fe_values.fe->dofs_per_cell; ++shape_function) + { const int snc = shape_function_data[shape_function].single_nonzero_component; if (snc == -2) - // shape function is zero for the selected components - continue; + // shape function is zero for the selected components + continue; const double value = dof_values (shape_function); if (value == 0.) - continue; + continue; if (snc != -1) - { - const Tensor<1, spacedim> * shape_gradient_ptr = &fe_values.shape_gradients[snc][0]; - - switch (shape_function_data[shape_function].single_nonzero_component_index) - { - case 0: - { - for (unsigned int q_point = 0; - q_point < fe_values.n_quadrature_points; ++q_point) + { + const Tensor<1, spacedim> * shape_gradient_ptr = &fe_values.shape_gradients[snc][0]; + + switch (shape_function_data[shape_function].single_nonzero_component_index) + { + case 0: + { + for (unsigned int q_point = 0; + q_point < fe_values.n_quadrature_points; ++q_point) curls[q_point][0] -= value * (*shape_gradient_ptr++)[1]; - break; - } + break; + } - default: - for (unsigned int q_point = 0; - q_point < fe_values.n_quadrature_points; ++q_point) - curls[q_point][0] += value * (*shape_gradient_ptr)[0]; - } - } + default: + for (unsigned int q_point = 0; + q_point < fe_values.n_quadrature_points; ++q_point) + curls[q_point][0] += value * (*shape_gradient_ptr)[0]; + } + } else - { - if (shape_function_data[shape_function].is_nonzero_shape_function_component[0]) - { - const Tensor<1,spacedim> * shape_gradient_ptr = - &fe_values.shape_gradients[shape_function_data[shape_function].row_index[0]][0]; - - for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) - curls[q_point][0] -= value * (*shape_gradient_ptr++)[1]; - } - - if (shape_function_data[shape_function].is_nonzero_shape_function_component[1]) - { - const Tensor<1,spacedim> * shape_gradient_ptr = - &fe_values.shape_gradients[shape_function_data[shape_function].row_index[1]][0]; - - for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) - curls[q_point][0] += value * (*shape_gradient_ptr++)[0]; - } - } - } - break; + { + if (shape_function_data[shape_function].is_nonzero_shape_function_component[0]) + { + const Tensor<1,spacedim> * shape_gradient_ptr = + &fe_values.shape_gradients[shape_function_data[shape_function].row_index[0]][0]; + + for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) + curls[q_point][0] -= value * (*shape_gradient_ptr++)[1]; + } + + if (shape_function_data[shape_function].is_nonzero_shape_function_component[1]) + { + const Tensor<1,spacedim> * shape_gradient_ptr = + &fe_values.shape_gradients[shape_function_data[shape_function].row_index[1]][0]; + + for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) + curls[q_point][0] += value * (*shape_gradient_ptr++)[0]; + } + } + } + break; } case 3: - { - for (unsigned int shape_function = 0; - shape_function < fe_values.fe->dofs_per_cell; ++shape_function) - { + { + for (unsigned int shape_function = 0; + shape_function < fe_values.fe->dofs_per_cell; ++shape_function) + { const int snc = shape_function_data[shape_function].single_nonzero_component; if (snc == -2) - // shape function is zero for the selected components - continue; + // shape function is zero for the selected components + continue; const double value = dof_values (shape_function); if (value == 0.) - continue; + continue; if (snc != -1) - { - const Tensor<1, spacedim> * shape_gradient_ptr = &fe_values.shape_gradients[snc][0]; - - switch (shape_function_data[shape_function].single_nonzero_component_index) - { - case 0: - { - for (unsigned int q_point = 0; - q_point < fe_values.n_quadrature_points; ++q_point) - { - curls[q_point][1] += value * (*shape_gradient_ptr)[2]; - curls[q_point][2] -= value * (*shape_gradient_ptr++)[1]; - } - - break; - } - - case 1: - { - for (unsigned int q_point = 0; - q_point < fe_values.n_quadrature_points; ++q_point) - { - curls[q_point][0] -= value * (*shape_gradient_ptr)[2]; - curls[q_point][2] += value * (*shape_gradient_ptr++)[0]; - } - - break; - } - - default: - for (unsigned int q_point = 0; - q_point < fe_values.n_quadrature_points; ++q_point) - { - curls[q_point][0] += value * (*shape_gradient_ptr)[1]; - curls[q_point][1] -= value * (*shape_gradient_ptr++)[0]; - } - } - } + { + const Tensor<1, spacedim> * shape_gradient_ptr = &fe_values.shape_gradients[snc][0]; + + switch (shape_function_data[shape_function].single_nonzero_component_index) + { + case 0: + { + for (unsigned int q_point = 0; + q_point < fe_values.n_quadrature_points; ++q_point) + { + curls[q_point][1] += value * (*shape_gradient_ptr)[2]; + curls[q_point][2] -= value * (*shape_gradient_ptr++)[1]; + } + + break; + } + + case 1: + { + for (unsigned int q_point = 0; + q_point < fe_values.n_quadrature_points; ++q_point) + { + curls[q_point][0] -= value * (*shape_gradient_ptr)[2]; + curls[q_point][2] += value * (*shape_gradient_ptr++)[0]; + } + + break; + } + + default: + for (unsigned int q_point = 0; + q_point < fe_values.n_quadrature_points; ++q_point) + { + curls[q_point][0] += value * (*shape_gradient_ptr)[1]; + curls[q_point][1] -= value * (*shape_gradient_ptr++)[0]; + } + } + } else - { - if (shape_function_data[shape_function].is_nonzero_shape_function_component[0]) - { - const Tensor<1,spacedim> * shape_gradient_ptr = - &fe_values.shape_gradients[shape_function_data[shape_function].row_index[0]][0]; - - for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) - { - curls[q_point][1] += value * (*shape_gradient_ptr)[2]; - curls[q_point][2] -= value * (*shape_gradient_ptr++)[1]; - } - } - - if (shape_function_data[shape_function].is_nonzero_shape_function_component[1]) - { - const Tensor<1,spacedim> * shape_gradient_ptr = - &fe_values.shape_gradients[shape_function_data[shape_function].row_index[1]][0]; - - for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) - { - curls[q_point][0] -= value * (*shape_gradient_ptr)[2]; - curls[q_point][2] += value * (*shape_gradient_ptr++)[0]; - } - } - - if (shape_function_data[shape_function].is_nonzero_shape_function_component[2]) - { - const Tensor<1,spacedim> * shape_gradient_ptr = - &fe_values.shape_gradients[shape_function_data[shape_function].row_index[2]][0]; - - for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) - { - curls[q_point][0] += value * (*shape_gradient_ptr)[1]; - curls[q_point][1] -= value * (*shape_gradient_ptr++)[0]; - } - } - } - } + { + if (shape_function_data[shape_function].is_nonzero_shape_function_component[0]) + { + const Tensor<1,spacedim> * shape_gradient_ptr = + &fe_values.shape_gradients[shape_function_data[shape_function].row_index[0]][0]; + + for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) + { + curls[q_point][1] += value * (*shape_gradient_ptr)[2]; + curls[q_point][2] -= value * (*shape_gradient_ptr++)[1]; + } + } + + if (shape_function_data[shape_function].is_nonzero_shape_function_component[1]) + { + const Tensor<1,spacedim> * shape_gradient_ptr = + &fe_values.shape_gradients[shape_function_data[shape_function].row_index[1]][0]; + + for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) + { + curls[q_point][0] -= value * (*shape_gradient_ptr)[2]; + curls[q_point][2] += value * (*shape_gradient_ptr++)[0]; + } + } + + if (shape_function_data[shape_function].is_nonzero_shape_function_component[2]) + { + const Tensor<1,spacedim> * shape_gradient_ptr = + &fe_values.shape_gradients[shape_function_data[shape_function].row_index[2]][0]; + + for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) + { + curls[q_point][0] += value * (*shape_gradient_ptr)[1]; + curls[q_point][1] -= value * (*shape_gradient_ptr++)[0]; + } + } + } + } } } } @@ -989,59 +989,59 @@ namespace FEValuesViews void Vector:: get_function_hessians (const InputVector &fe_function, - std::vector &hessians) const + std::vector &hessians) const { typedef FEValuesBase FVB; Assert (fe_values.update_flags & update_hessians, - typename FVB::ExcAccessToUninitializedField()); + typename FVB::ExcAccessToUninitializedField()); Assert (hessians.size() == fe_values.n_quadrature_points, - ExcDimensionMismatch(hessians.size(), fe_values.n_quadrature_points)); + ExcDimensionMismatch(hessians.size(), fe_values.n_quadrature_points)); Assert (fe_values.present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == fe_values.present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - fe_values.present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + fe_values.present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (hessians.begin(), hessians.end(), hessian_type()); for (unsigned int shape_function=0; - shape_functiondofs_per_cell; ++shape_function) + shape_functiondofs_per_cell; ++shape_function) { - const int snc = shape_function_data[shape_function].single_nonzero_component; - - if (snc == -2) - // shape function is zero for the - // selected components - continue; - - const double value = dof_values(shape_function); - if (value == 0.) - continue; - - if (snc != -1) - { - const unsigned int comp = - shape_function_data[shape_function].single_nonzero_component_index; - const Tensor<2,spacedim> * shape_hessian_ptr = - &fe_values.shape_hessians[snc][0]; - for (unsigned int q_point=0; q_point * shape_hessian_ptr = - &fe_values.shape_hessians[shape_function_data[shape_function]. - row_index[d]][0]; - for (unsigned int q_point=0; q_point * shape_hessian_ptr = + &fe_values.shape_hessians[snc][0]; + for (unsigned int q_point=0; q_point * shape_hessian_ptr = + &fe_values.shape_hessians[shape_function_data[shape_function]. + row_index[d]][0]; + for (unsigned int q_point=0; q_point:: get_function_laplacians (const InputVector &fe_function, - std::vector &laplacians) const + std::vector &laplacians) const { typedef FEValuesBase FVB; Assert (fe_values.update_flags & update_hessians, - typename FVB::ExcAccessToUninitializedField()); + typename FVB::ExcAccessToUninitializedField()); Assert (laplacians.size() == fe_values.n_quadrature_points, - ExcDimensionMismatch(laplacians.size(), fe_values.n_quadrature_points)); + ExcDimensionMismatch(laplacians.size(), fe_values.n_quadrature_points)); Assert (fe_values.present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == fe_values.present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - fe_values.present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + fe_values.present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell dealii::Vector::type> dof_values (fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill (laplacians.begin(), laplacians.end(), value_type()); for (unsigned int shape_function=0; - shape_functiondofs_per_cell; ++shape_function) + shape_functiondofs_per_cell; ++shape_function) { - const int snc = shape_function_data[shape_function].single_nonzero_component; - - if (snc == -2) - // shape function is zero for the - // selected components - continue; - - const double value = dof_values(shape_function); - if (value == 0.) - continue; - - if (snc != -1) - { - const unsigned int comp = - shape_function_data[shape_function].single_nonzero_component_index; - const Tensor<2,spacedim> * shape_hessian_ptr = - &fe_values.shape_hessians[snc][0]; - for (unsigned int q_point=0; q_point * shape_hessian_ptr = - &fe_values.shape_hessians[shape_function_data[shape_function]. - row_index[d]][0]; - for (unsigned int q_point=0; q_point * shape_hessian_ptr = + &fe_values.shape_hessians[snc][0]; + for (unsigned int q_point=0; q_point * shape_hessian_ptr = + &fe_values.shape_hessians[shape_function_data[shape_function]. + row_index[d]][0]; + for (unsigned int q_point=0; q_point:: get_function_values(const InputVector &fe_function, - std::vector &values) const + std::vector &values) const { typedef FEValuesBase FVB; Assert(fe_values.update_flags & update_values, - typename FVB::ExcAccessToUninitializedField()); + typename FVB::ExcAccessToUninitializedField()); Assert(values.size() == fe_values.n_quadrature_points, - ExcDimensionMismatch(values.size(), fe_values.n_quadrature_points)); + ExcDimensionMismatch(values.size(), fe_values.n_quadrature_points)); Assert(fe_values.present_cell.get() != 0, - ExcMessage("FEValues object is not reinit'ed to any cell")); + ExcMessage("FEValues object is not reinit'ed to any cell")); Assert(fe_function.size() == fe_values.present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - fe_values.present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + fe_values.present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell dealii::Vector::type > dof_values(fe_values.dofs_per_cell); fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values); std::fill(values.begin(), values.end(), value_type()); for (unsigned int shape_function = 0; - shape_function < fe_values.fe->dofs_per_cell; ++shape_function) + shape_function < fe_values.fe->dofs_per_cell; ++shape_function) { - const int snc = shape_function_data[shape_function].single_nonzero_component; - - if (snc == -2) - // shape function is zero for the - // selected components - continue; - - const double value = dof_values(shape_function); - if (value == 0.) - continue; - - if (snc != -1) - { - const unsigned int comp = - shape_function_data[shape_function].single_nonzero_component_index; - const double * shape_value_ptr = &fe_values.shape_values(snc, 0); - for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) - values[q_point][value_type::unrolled_to_component_indices(comp)] - += value * *shape_value_ptr++; - } - else - { - for (unsigned int d = 0; d < value_type::n_independent_components; ++d) - if (shape_function_data[shape_function].is_nonzero_shape_function_component[d]) - { - const double * shape_value_ptr = - &fe_values.shape_values(shape_function_data[shape_function].row_index[d], 0); - for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) - values[q_point][value_type::unrolled_to_component_indices(d)] - += value * *shape_value_ptr++; - } - } + const int snc = shape_function_data[shape_function].single_nonzero_component; + + if (snc == -2) + // shape function is zero for the + // selected components + continue; + + const double value = dof_values(shape_function); + if (value == 0.) + continue; + + if (snc != -1) + { + const unsigned int comp = + shape_function_data[shape_function].single_nonzero_component_index; + const double * shape_value_ptr = &fe_values.shape_values(snc, 0); + for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) + values[q_point][value_type::unrolled_to_component_indices(comp)] + += value * *shape_value_ptr++; + } + else + { + for (unsigned int d = 0; d < value_type::n_independent_components; ++d) + if (shape_function_data[shape_function].is_nonzero_shape_function_component[d]) + { + const double * shape_value_ptr = + &fe_values.shape_values(shape_function_data[shape_function].row_index[d], 0); + for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point) + values[q_point][value_type::unrolled_to_component_indices(d)] + += value * *shape_value_ptr++; + } + } } } @@ -1233,13 +1233,13 @@ namespace FEValuesViews if (ii != jj) divergences[q_point][jj] += value * (*shape_gradient_ptr)[ii]; } - } + } else - { + { for (unsigned int d = 0; d < value_type::n_independent_components; ++d) if (shape_function_data[shape_function].is_nonzero_shape_function_component[d]) { - Assert (false, ExcNotImplemented()); + Assert (false, ExcNotImplemented()); // the following implementation needs to be looked over -- I think it // can't be right, because we are in a case where there is no single @@ -1249,22 +1249,22 @@ namespace FEValuesViews // mutliple non-zero entries in shape function and the representation // as a symmetric second-order tensor - const unsigned int comp = + const unsigned int comp = shape_function_data[shape_function].single_nonzero_component_index; - const Tensor < 1, spacedim> * shape_gradient_ptr = + const Tensor < 1, spacedim> * shape_gradient_ptr = &fe_values.shape_gradients[shape_function_data[shape_function]. row_index[d]][0]; - for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; - ++q_point, ++shape_gradient_ptr) { + for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; + ++q_point, ++shape_gradient_ptr) { for (unsigned int j = 0; j < dim; ++j) - { + { const unsigned int vector_component = value_type::component_to_unrolled_index (TableIndices<2>(comp,j)); divergences[q_point][vector_component] += value * (*shape_gradient_ptr++)[j]; - } - } + } + } } - } + } } } } @@ -1279,73 +1279,73 @@ namespace internal { const FiniteElement &fe = fe_values.get_fe(); - // create the views objects. allocate a - // bunch of default-constructed ones - // then destroy them again and do - // in-place construction of those we - // actually want to use (copying stuff - // is wasteful and we can't do that - // anyway because the class has - // reference members) + // create the views objects. allocate a + // bunch of default-constructed ones + // then destroy them again and do + // in-place construction of those we + // actually want to use (copying stuff + // is wasteful and we can't do that + // anyway because the class has + // reference members) const unsigned int n_scalars = fe.n_components(); scalars.resize (n_scalars); for (unsigned int component=0; component::~Scalar (); + scalars[component].dealii::FEValuesViews::Scalar::~Scalar (); #else - typedef dealii::FEValuesViews::Scalar ScalarView; - scalars[component].ScalarView::~ScalarView (); + typedef dealii::FEValuesViews::Scalar ScalarView; + scalars[component].ScalarView::~ScalarView (); #endif - new (&scalars[component]) - dealii::FEValuesViews::Scalar(fe_values, - component); - } - - // compute number of vectors - // that we can fit into - // this finite element. note - // that this is based on the - // dimensionality 'dim' of the - // manifold, not 'spacedim' of - // the output vector + new (&scalars[component]) + dealii::FEValuesViews::Scalar(fe_values, + component); + } + + // compute number of vectors + // that we can fit into + // this finite element. note + // that this is based on the + // dimensionality 'dim' of the + // manifold, not 'spacedim' of + // the output vector const unsigned int n_vectors = (fe.n_components() >= spacedim ? - fe.n_components()-spacedim+1 : - 0); + fe.n_components()-spacedim+1 : + 0); vectors.resize (n_vectors); for (unsigned int component=0; component::~Vector (); + vectors[component].dealii::FEValuesViews::Vector::~Vector (); #else - typedef dealii::FEValuesViews::Vector VectorView; - vectors[component].VectorView::~VectorView (); + typedef dealii::FEValuesViews::Vector VectorView; + vectors[component].VectorView::~VectorView (); #endif - new (&vectors[component]) - dealii::FEValuesViews::Vector(fe_values, - component); - } + new (&vectors[component]) + dealii::FEValuesViews::Vector(fe_values, + component); + } - // compute number of symmetric - // tensors in the same way as above + // compute number of symmetric + // tensors in the same way as above const unsigned int n_symmetric_second_order_tensors - = (fe.n_components() >= (dim*dim + dim)/2 ? - fe.n_components() - (dim*dim + dim)/2 + 1 : - 0); + = (fe.n_components() >= (dim*dim + dim)/2 ? + fe.n_components() - (dim*dim + dim)/2 + 1 : + 0); symmetric_second_order_tensors.resize(n_symmetric_second_order_tensors); for (unsigned int component = 0; component < n_symmetric_second_order_tensors; ++component) - { + { #ifndef DEAL_II_EXPLICIT_DESTRUCTOR_BUG - symmetric_second_order_tensors[component] - .dealii::FEValuesViews::SymmetricTensor<2, dim, spacedim>::~SymmetricTensor(); + symmetric_second_order_tensors[component] + .dealii::FEValuesViews::SymmetricTensor<2, dim, spacedim>::~SymmetricTensor(); #else - typedef dealii::FEValuesViews::SymmetricTensor<2, dim, spacedim> SymmetricTensorView; - symmetric_second_order_tensors[component].SymmetricTensorView::~SymmetricTensorView(); + typedef dealii::FEValuesViews::SymmetricTensor<2, dim, spacedim> SymmetricTensorView; + symmetric_second_order_tensors[component].SymmetricTensorView::~SymmetricTensorView(); #endif - new (&symmetric_second_order_tensors[component]) - dealii::FEValuesViews::SymmetricTensor<2, dim, spacedim > (fe_values, - component); - } + new (&symmetric_second_order_tensors[component]) + dealii::FEValuesViews::SymmetricTensor<2, dim, spacedim > (fe_values, + component); + } } } } @@ -1357,51 +1357,51 @@ template class FEValuesBase::CellIteratorBase { public: - /** - * Destructor. Made virtual - * since we store only - * pointers to the base - * class. - */ + /** + * Destructor. Made virtual + * since we store only + * pointers to the base + * class. + */ virtual ~CellIteratorBase (); - /** - * Conversion operator to an - * iterator for - * triangulations. This - * conversion is implicit for - * the original iterators, - * since they are derived - * classes. However, since - * here we have kind of a - * parallel class hierarchy, - * we have to have a - * conversion operator. - */ + /** + * Conversion operator to an + * iterator for + * triangulations. This + * conversion is implicit for + * the original iterators, + * since they are derived + * classes. However, since + * here we have kind of a + * parallel class hierarchy, + * we have to have a + * conversion operator. + */ virtual operator typename Triangulation::cell_iterator () const = 0; - /** - * Return the number of - * degrees of freedom the DoF - * handler object has to - * which the iterator belongs - * to. - */ + /** + * Return the number of + * degrees of freedom the DoF + * handler object has to + * which the iterator belongs + * to. + */ virtual unsigned int n_dofs_for_dof_handler () const = 0; #include "fe_values.decl.1.inst" - /// Call - /// @p get_interpolated_dof_values - /// of the iterator with the - /// given arguments. + /// Call + /// @p get_interpolated_dof_values + /// of the iterator with the + /// given arguments. virtual void get_interpolated_dof_values (const IndexSet &in, - Vector &out) const = 0; + Vector &out) const = 0; }; @@ -1412,185 +1412,185 @@ FEValuesBase::CellIteratorBase::~CellIteratorBase () /* ---------------- classes derived from FEValuesBase::CellIteratorBase --------- */ - /** - * Implementation of derived - * classes of the - * CellIteratorBase - * interface. See there for a - * description of the use of - * these classes. - * - * @author Wolfgang Bangerth, 2003 - */ + /** + * Implementation of derived + * classes of the + * CellIteratorBase + * interface. See there for a + * description of the use of + * these classes. + * + * @author Wolfgang Bangerth, 2003 + */ template template class FEValuesBase::CellIterator : public FEValuesBase::CellIteratorBase { public: - /** - * Constructor. Take an - * iterator and store it in - * this class. - */ + /** + * Constructor. Take an + * iterator and store it in + * this class. + */ CellIterator (const CI &cell); - /** - * Conversion operator to an - * iterator for - * triangulations. This - * conversion is implicit for - * the original iterators, - * since they are derived - * classes. However, since - * here we have kind of a - * parallel class hierarchy, - * we have to have a - * conversion operator. - */ + /** + * Conversion operator to an + * iterator for + * triangulations. This + * conversion is implicit for + * the original iterators, + * since they are derived + * classes. However, since + * here we have kind of a + * parallel class hierarchy, + * we have to have a + * conversion operator. + */ virtual operator typename Triangulation::cell_iterator () const; - /** - * Return the number of - * degrees of freedom the DoF - * handler object has to - * which the iterator belongs - * to. - */ + /** + * Return the number of + * degrees of freedom the DoF + * handler object has to + * which the iterator belongs + * to. + */ virtual unsigned int n_dofs_for_dof_handler () const; #include "fe_values.decl.2.inst" - /// Call - /// @p get_interpolated_dof_values - /// of the iterator with the - /// given arguments. + /// Call + /// @p get_interpolated_dof_values + /// of the iterator with the + /// given arguments. virtual void get_interpolated_dof_values (const IndexSet &in, - Vector &out) const; + Vector &out) const; private: - /** - * Copy of the iterator which - * we use in this object. - */ + /** + * Copy of the iterator which + * we use in this object. + */ const CI cell; }; - /** - * Implementation of a derived - * class of the - * CellIteratorBase - * interface. See there for a - * description of the use of - * these classes. - * - * This class is basically a - * specialization of the general - * template for iterators into - * Triangulation objects (but - * since C++ does not allow - * something like this for nested - * classes, it runs under a - * separate name). Since these do - * not implement the interface - * that we would like to call, - * the functions of this class - * cannot be implemented - * meaningfully. However, most - * functions of the FEValues - * class do not make any use of - * degrees of freedom at all, so - * it should be possible to call - * FEValues::reinit() with a tria - * iterator only; this class - * makes this possible, but - * whenever one of the functions - * of FEValues tries to call - * any of the functions of this - * class, an exception will be - * raised reminding the user that - * if she wants to use these - * features, then the - * FEValues object has to be - * reinitialized with a cell - * iterator that allows to - * extract degree of freedom - * information. - * - * @author Wolfgang Bangerth, 2003 - */ + /** + * Implementation of a derived + * class of the + * CellIteratorBase + * interface. See there for a + * description of the use of + * these classes. + * + * This class is basically a + * specialization of the general + * template for iterators into + * Triangulation objects (but + * since C++ does not allow + * something like this for nested + * classes, it runs under a + * separate name). Since these do + * not implement the interface + * that we would like to call, + * the functions of this class + * cannot be implemented + * meaningfully. However, most + * functions of the FEValues + * class do not make any use of + * degrees of freedom at all, so + * it should be possible to call + * FEValues::reinit() with a tria + * iterator only; this class + * makes this possible, but + * whenever one of the functions + * of FEValues tries to call + * any of the functions of this + * class, an exception will be + * raised reminding the user that + * if she wants to use these + * features, then the + * FEValues object has to be + * reinitialized with a cell + * iterator that allows to + * extract degree of freedom + * information. + * + * @author Wolfgang Bangerth, 2003 + */ template class FEValuesBase::TriaCellIterator : public FEValuesBase::CellIteratorBase { public: - /** - * Constructor. Take an - * iterator and store it in - * this class. - */ + /** + * Constructor. Take an + * iterator and store it in + * this class. + */ TriaCellIterator (const typename Triangulation::cell_iterator &cell); - /** - * Conversion operator to an - * iterator for - * triangulations. This - * conversion is implicit for - * the original iterators, - * since they are derived - * classes. However, since - * here we have kind of a - * parallel class hierarchy, - * we have to have a - * conversion operator. Here, - * the conversion is trivial, - * from and to the same time. - */ + /** + * Conversion operator to an + * iterator for + * triangulations. This + * conversion is implicit for + * the original iterators, + * since they are derived + * classes. However, since + * here we have kind of a + * parallel class hierarchy, + * we have to have a + * conversion operator. Here, + * the conversion is trivial, + * from and to the same time. + */ virtual operator typename Triangulation::cell_iterator () const; - /** - * Implement the respective - * function of the base - * class. Since this is not - * possible, we just raise an - * error. - */ + /** + * Implement the respective + * function of the base + * class. Since this is not + * possible, we just raise an + * error. + */ virtual unsigned int n_dofs_for_dof_handler () const; #include "fe_values.decl.2.inst" - /// Call - /// @p get_interpolated_dof_values - /// of the iterator with the - /// given arguments. + /// Call + /// @p get_interpolated_dof_values + /// of the iterator with the + /// given arguments. virtual void get_interpolated_dof_values (const IndexSet &in, - Vector &out) const; + Vector &out) const; private: - /** - * Copy of the iterator which - * we use in this object. - */ + /** + * Copy of the iterator which + * we use in this object. + */ const typename Triangulation::cell_iterator cell; - /** - * String to be displayed - * whenever one of the - * functions of this class is - * called. Make it a static - * member variable, since we - * show the same message for - * all member functions. - */ + /** + * String to be displayed + * whenever one of the + * functions of this class is + * called. Make it a static + * member variable, since we + * show the same message for + * all member functions. + */ static const char * const message_string; }; @@ -1603,8 +1603,8 @@ class FEValuesBase::TriaCellIterator : public FEValuesBase template FEValuesBase::CellIterator::CellIterator (const CI &cell) - : - cell(cell) + : + cell(cell) {} @@ -1637,7 +1637,7 @@ template void FEValuesBase::CellIterator:: get_interpolated_dof_values (const IndexSet &in, - Vector &out) const + Vector &out) const { Assert (cell->has_children() == false, ExcNotImplemented()); @@ -1666,8 +1666,8 @@ FEValuesBase::TriaCellIterator::message_string template FEValuesBase::TriaCellIterator:: TriaCellIterator (const typename Triangulation::cell_iterator &cell) - : - cell(cell) + : + cell(cell) {} @@ -1697,7 +1697,7 @@ template void FEValuesBase::TriaCellIterator:: get_interpolated_dof_values (const IndexSet &, - Vector &) const + Vector &) const { Assert (false, ExcMessage (message_string)); } @@ -1710,43 +1710,43 @@ get_interpolated_dof_values (const IndexSet &, template void FEValuesData::initialize (const unsigned int n_quadrature_points, - const FiniteElement &fe, - const UpdateFlags flags) + const FiniteElement &fe, + const UpdateFlags flags) { this->update_flags = flags; - // initialize the table mapping - // from shape function number to - // the rows in the tables denoting - // its first non-zero - // component + // initialize the table mapping + // from shape function number to + // the rows in the tables denoting + // its first non-zero + // component this->shape_function_to_row_table = make_shape_function_to_row_table (fe); - // count the total number of non-zero - // components accumulated over all shape - // functions + // count the total number of non-zero + // components accumulated over all shape + // functions unsigned int n_nonzero_shape_components = 0; for (unsigned int i=0; i= fe.dofs_per_cell, - ExcInternalError()); + ExcInternalError()); - // with the number of rows now - // known, initialize those fields - // that we will need to their - // correct size + // with the number of rows now + // known, initialize those fields + // that we will need to their + // correct size if (flags & update_values) this->shape_values.reinit(n_nonzero_shape_components, - n_quadrature_points); + n_quadrature_points); if (flags & update_gradients) this->shape_gradients.resize (n_nonzero_shape_components, - std::vector > (n_quadrature_points)); + std::vector > (n_quadrature_points)); if (flags & update_hessians) this->shape_hessians.resize (n_nonzero_shape_components, - std::vector > (n_quadrature_points)); + std::vector > (n_quadrature_points)); if (flags & update_quadrature_points) this->quadrature_points.resize(n_quadrature_points); @@ -1777,18 +1777,18 @@ FEValuesData::initialize (const unsigned int n_quadrature_p template FEValuesBase::FEValuesBase (const unsigned int n_q_points, - const unsigned int dofs_per_cell, - const UpdateFlags flags, - const Mapping &mapping, - const FiniteElement &fe) - : - n_quadrature_points (n_q_points), - dofs_per_cell (dofs_per_cell), - mapping(&mapping, typeid(*this).name()), - fe(&fe, typeid(*this).name()), - mapping_data(0, typeid(*this).name()), - fe_data(0, typeid(*this).name()), - fe_values_views_cache (*this) + const unsigned int dofs_per_cell, + const UpdateFlags flags, + const Mapping &mapping, + const FiniteElement &fe) + : + n_quadrature_points (n_q_points), + dofs_per_cell (dofs_per_cell), + mapping(&mapping, typeid(*this).name()), + fe(&fe, typeid(*this).name()), + mapping_data(0, typeid(*this).name()), + fe_data(0, typeid(*this).name()), + fe_values_views_cache (*this) { this->update_flags = flags; } @@ -1798,11 +1798,11 @@ FEValuesBase::FEValuesBase (const unsigned int n_q_points, template FEValuesBase::~FEValuesBase () { - // delete those fields that were - // created by the mapping and - // finite element objects, - // respectively, but of which we - // have assumed ownership + // delete those fields that were + // created by the mapping and + // finite element objects, + // respectively, but of which we + // have assumed ownership if (fe_data != 0) { typename Mapping::InternalDataBase *tmp1=fe_data; @@ -1830,53 +1830,53 @@ void FEValuesBase::get_function_values ( { Assert (this->update_flags & update_values, ExcAccessToUninitializedField()); Assert (fe->n_components() == 1, - ExcDimensionMismatch(fe->n_components(), 1)); + ExcDimensionMismatch(fe->n_components(), 1)); Assert (values.size() == n_quadrature_points, - ExcDimensionMismatch(values.size(), n_quadrature_points)); + ExcDimensionMismatch(values.size(), n_quadrature_points)); Assert (present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); - // initialize with zero + // initialize with zero std::fill_n (values.begin(), n_quadrature_points, 0); - // add up contributions of trial - // functions. note that here we - // deal with scalar finite - // elements, so no need to check - // for non-primitivity of shape - // functions. in order to increase - // the speed of this function, we - // directly access the data in the - // shape_values array, and - // increment pointers for accessing - // the data. this saves some lookup - // time and indexing. moreover, the - // order of the loops is such that - // we can access the shape_values - // data stored contiguously (which - // is also advantageous because - // access to dof_values is - // generally more expensive than - // access to the std::vector values - // - so we do the cheaper operation - // in the innermost loop) + // add up contributions of trial + // functions. note that here we + // deal with scalar finite + // elements, so no need to check + // for non-primitivity of shape + // functions. in order to increase + // the speed of this function, we + // directly access the data in the + // shape_values array, and + // increment pointers for accessing + // the data. this saves some lookup + // time and indexing. moreover, the + // order of the loops is such that + // we can access the shape_values + // data stored contiguously (which + // is also advantageous because + // access to dof_values is + // generally more expensive than + // access to the std::vector values + // - so we do the cheaper operation + // in the innermost loop) for (unsigned int shape_func=0; shape_funcshape_values(shape_func, 0); for (unsigned int point=0; point::get_function_values ( std::vector &values) const { Assert (this->update_flags & update_values, ExcAccessToUninitializedField()); - // This function fills a single - // component only + // This function fills a single + // component only Assert (fe->n_components() == 1, - ExcDimensionMismatch(fe->n_components(), 1)); - // One index for each dof + ExcDimensionMismatch(fe->n_components(), 1)); + // One index for each dof Assert (indices.size() == dofs_per_cell, - ExcDimensionMismatch(indices.size(), dofs_per_cell)); - // This vector has one entry for - // each quadrature point + ExcDimensionMismatch(indices.size(), dofs_per_cell)); + // This vector has one entry for + // each quadrature point Assert (values.size() == n_quadrature_points, - ExcDimensionMismatch(values.size(), n_quadrature_points)); + ExcDimensionMismatch(values.size(), n_quadrature_points)); - // initialize with zero + // initialize with zero std::fill_n (values.begin(), n_quadrature_points, 0); - // add up contributions of trial - // functions. note that here we - // deal with scalar finite - // elements, so no need to check - // for non-primitivity of shape - // functions. in order to increase - // the speed of this function, we - // directly access the data in the - // shape_values array, and - // increment pointers for accessing - // the data. this saves some lookup - // time and indexing. moreover, the - // order of the loops is such that - // we can access the shape_values - // data stored contiguously (which - // is also advantageous because - // access to the global vector - // fe_function is more expensive - // than access to the small - // std::vector values - so we do - // the cheaper operation in the - // innermost loop) + // add up contributions of trial + // functions. note that here we + // deal with scalar finite + // elements, so no need to check + // for non-primitivity of shape + // functions. in order to increase + // the speed of this function, we + // directly access the data in the + // shape_values array, and + // increment pointers for accessing + // the data. this saves some lookup + // time and indexing. moreover, the + // order of the loops is such that + // we can access the shape_values + // data stored contiguously (which + // is also advantageous because + // access to the global vector + // fe_function is more expensive + // than access to the small + // std::vector values - so we do + // the cheaper operation in the + // innermost loop) for (unsigned int shape_func=0; shape_funcshape_values(shape_func, 0); for (unsigned int point=0; point::get_function_values ( std::vector >& values) const { //TODO: Find out how to do this assertion. - // This vector must correspond to a - // complete discretization + // This vector must correspond to a + // complete discretization // Assert (fe_function.size() == present_cell->get_dof_handler().n_dofs(), -// ExcDimensionMismatch(fe_function.size(), -// present_cell->get_dof_handler().n_dofs())); - // One entry per quadrature point +// ExcDimensionMismatch(fe_function.size(), +// present_cell->get_dof_handler().n_dofs())); + // One entry per quadrature point Assert (present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (values.size() == n_quadrature_points, - ExcDimensionMismatch(values.size(), n_quadrature_points)); + ExcDimensionMismatch(values.size(), n_quadrature_points)); const unsigned int n_components = fe->n_components(); - // Assert that we can write all - // components into the result - // vectors + // Assert that we can write all + // components into the result + // vectors for (unsigned i=0;iupdate_flags & update_values, ExcAccessToUninitializedField()); Assert (fe_function.size() == present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); - // initialize with zero + // initialize with zero for (unsigned i=0;iis_primitive(shape_func)) - { - // compared to the scalar - // functions, finding the correct - // index in the shape_value table - // is more involved, since we have - // to find the row in shape_values - // that corresponds to the present - // shape_func. this is done - // manually in the same way as in - // shape_value_component() (that - // function can't be used because - // it doesn't return us a pointer - // to the data). - const unsigned int - row = fe->is_primitive() ? - shape_func : this->shape_function_to_row_table[shape_func]; - - const double *shape_value_ptr = &this->shape_values(row, 0); - const unsigned int comp = fe->system_to_component_index(shape_func).first; - for (unsigned int point=0; pointis_primitive() ? + shape_func : this->shape_function_to_row_table[shape_func]; + + const double *shape_value_ptr = &this->shape_values(row, 0); + const unsigned int comp = fe->system_to_component_index(shape_func).first; + for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) - continue; - - const unsigned int - row = (this->shape_function_to_row_table[shape_func] - + - std::count (fe->get_nonzero_components(shape_func).begin(), - fe->get_nonzero_components(shape_func).begin()+c, - true)); - - const double *shape_value_ptr = &this->shape_values(row, 0); - - for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) + continue; + + const unsigned int + row = (this->shape_function_to_row_table[shape_func] + + + std::count (fe->get_nonzero_components(shape_func).begin(), + fe->get_nonzero_components(shape_func).begin()+c, + true)); + + const double *shape_value_ptr = &this->shape_values(row, 0); + + for (unsigned int point=0; point::get_function_values ( const VectorSlice >& indices, std::vector >& values) const { - // One value per quadrature point + // One value per quadrature point Assert (n_quadrature_points == values.size(), - ExcDimensionMismatch(values.size(), n_quadrature_points)); + ExcDimensionMismatch(values.size(), n_quadrature_points)); const unsigned int n_components = fe->n_components(); - // Size of indices must be a - // multiple of dofs_per_cell such - // that an integer number of - // function values is generated in - // each point. + // Size of indices must be a + // multiple of dofs_per_cell such + // that an integer number of + // function values is generated in + // each point. Assert (indices.size() % dofs_per_cell == 0, - ExcNotMultiple(indices.size(), dofs_per_cell)); + ExcNotMultiple(indices.size(), dofs_per_cell)); - // The number of components of the - // result may be a multiple of the - // number of components of the - // finite element + // The number of components of the + // result may be a multiple of the + // number of components of the + // finite element const unsigned int result_components = indices.size() * n_components / dofs_per_cell; for (unsigned i=0;iupdate_flags & update_values, ExcAccessToUninitializedField()); - // initialize with zero + // initialize with zero for (unsigned i=0;iis_primitive(shape_func)) - { - const unsigned int - row = fe->is_primitive() ? - shape_func : this->shape_function_to_row_table[shape_func]; - - const double *shape_value_ptr = &this->shape_values(row, 0); - const unsigned int comp = fe->system_to_component_index(shape_func).first - + mc * n_components; - for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) - continue; - - const unsigned int - row = (this->shape_function_to_row_table[shape_func] - + - std::count (fe->get_nonzero_components(shape_func).begin(), - fe->get_nonzero_components(shape_func).begin()+c, - true)); - - const double *shape_value_ptr = &this->shape_values(row, 0); - const unsigned int comp = c + mc * n_components; - - for (unsigned int point=0; pointis_primitive(shape_func)) + { + const unsigned int + row = fe->is_primitive() ? + shape_func : this->shape_function_to_row_table[shape_func]; + + const double *shape_value_ptr = &this->shape_values(row, 0); + const unsigned int comp = fe->system_to_component_index(shape_func).first + + mc * n_components; + for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) + continue; + + const unsigned int + row = (this->shape_function_to_row_table[shape_func] + + + std::count (fe->get_nonzero_components(shape_func).begin(), + fe->get_nonzero_components(shape_func).begin()+c, + true)); + + const double *shape_value_ptr = &this->shape_values(row, 0); + const unsigned int comp = c + mc * n_components; + + for (unsigned int point=0; point::get_function_values ( { const unsigned int n_components = fe->n_components(); - // Size of indices must be a - // multiple of dofs_per_cell such - // that an integer number of - // function values is generated in - // each point. + // Size of indices must be a + // multiple of dofs_per_cell such + // that an integer number of + // function values is generated in + // each point. Assert (indices.size() % dofs_per_cell == 0, - ExcNotMultiple(indices.size(), dofs_per_cell)); + ExcNotMultiple(indices.size(), dofs_per_cell)); - // The number of components of the - // result may be a multiple of the - // number of components of the - // finite element + // The number of components of the + // result may be a multiple of the + // number of components of the + // finite element const unsigned int result_components = indices.size() * n_components / dofs_per_cell; - // Check if the value argument is - // initialized to the correct sizes + // Check if the value argument is + // initialized to the correct sizes if (quadrature_points_fastest) { Assert (values.size() == result_components, - ExcDimensionMismatch(values.size(), result_components)); + ExcDimensionMismatch(values.size(), result_components)); for (unsigned i=0;iupdate_flags & update_values, ExcAccessToUninitializedField()); - // initialize with zero + // initialize with zero for (unsigned i=0;iis_primitive(shape_func)) - { - const unsigned int - row = fe->is_primitive() ? - shape_func : this->shape_function_to_row_table[shape_func]; - - const double *shape_value_ptr = &this->shape_values(row, 0); - const unsigned int comp = fe->system_to_component_index(shape_func).first - + mc * n_components; - - if (quadrature_points_fastest) - for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) - continue; - - const unsigned int - row = (this->shape_function_to_row_table[shape_func] - + - std::count (fe->get_nonzero_components(shape_func).begin(), - fe->get_nonzero_components(shape_func).begin()+c, - true)); - - const double *shape_value_ptr = &this->shape_values(row, 0); - const unsigned int comp = c + mc * n_components; - - if (quadrature_points_fastest) - for (unsigned int point=0; pointis_primitive(shape_func)) + { + const unsigned int + row = fe->is_primitive() ? + shape_func : this->shape_function_to_row_table[shape_func]; + + const double *shape_value_ptr = &this->shape_values(row, 0); + const unsigned int comp = fe->system_to_component_index(shape_func).first + + mc * n_components; + + if (quadrature_points_fastest) + for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) + continue; + + const unsigned int + row = (this->shape_function_to_row_table[shape_func] + + + std::count (fe->get_nonzero_components(shape_func).begin(), + fe->get_nonzero_components(shape_func).begin()+c, + true)); + + const double *shape_value_ptr = &this->shape_values(row, 0); + const unsigned int comp = c + mc * n_components; + + if (quadrature_points_fastest) + for (unsigned int point=0; point::get_function_gradients ( Assert (this->update_flags & update_gradients, ExcAccessToUninitializedField()); Assert (fe->n_components() == 1, - ExcDimensionMismatch(fe->n_components(), 1)); + ExcDimensionMismatch(fe->n_components(), 1)); Assert (gradients.size() == n_quadrature_points, - ExcDimensionMismatch(gradients.size(), n_quadrature_points)); + ExcDimensionMismatch(gradients.size(), n_quadrature_points)); Assert (present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); - // initialize with zero + // initialize with zero std::fill_n (gradients.begin(), n_quadrature_points, Tensor<1,spacedim>()); - // add up contributions of trial - // functions. note that here we - // deal with scalar finite - // elements, so no need to check - // for non-primitivity of shape - // functions. in order to increase - // the speed of this function, we - // directly access the data in the - // shape_gradients array, and - // increment pointers for accessing - // the data. this saves some lookup - // time and indexing. moreover, the - // order of the loops is such that - // we can access the - // shape_gradients data stored - // contiguously (which is also - // advantageous because access to - // the vector dof_values is - // gerenally more expensive than - // access to the std::vector - // gradients - so we do the cheaper - // operation in the innermost loop) + // add up contributions of trial + // functions. note that here we + // deal with scalar finite + // elements, so no need to check + // for non-primitivity of shape + // functions. in order to increase + // the speed of this function, we + // directly access the data in the + // shape_gradients array, and + // increment pointers for accessing + // the data. this saves some lookup + // time and indexing. moreover, the + // order of the loops is such that + // we can access the + // shape_gradients data stored + // contiguously (which is also + // advantageous because access to + // the vector dof_values is + // gerenally more expensive than + // access to the std::vector + // gradients - so we do the cheaper + // operation in the innermost loop) for (unsigned int shape_func=0; shape_func *shape_gradient_ptr - = &this->shape_gradients[shape_func][0]; + = &this->shape_gradients[shape_func][0]; for (unsigned int point=0; point::get_function_gradients ( std::vector > &gradients) const { Assert (this->update_flags & update_gradients, ExcAccessToUninitializedField()); - // This function fills a single - // component only + // This function fills a single + // component only Assert (fe->n_components() == 1, - ExcDimensionMismatch(fe->n_components(), 1)); - // One index for each dof + ExcDimensionMismatch(fe->n_components(), 1)); + // One index for each dof Assert (indices.size() == dofs_per_cell, - ExcDimensionMismatch(indices.size(), dofs_per_cell)); - // This vector has one entry for - // each quadrature point + ExcDimensionMismatch(indices.size(), dofs_per_cell)); + // This vector has one entry for + // each quadrature point Assert (gradients.size() == n_quadrature_points, - ExcDimensionMismatch(gradients.size(), n_quadrature_points)); + ExcDimensionMismatch(gradients.size(), n_quadrature_points)); - // initialize with zero + // initialize with zero std::fill_n (gradients.begin(), n_quadrature_points, Tensor<1,spacedim>()); - // add up contributions of trial - // functions. note that here we - // deal with scalar finite - // elements, so no need to check - // for non-primitivity of shape - // functions. in order to increase - // the speed of this function, we - // directly access the data in the - // shape_gradients array, and - // increment pointers for accessing - // the data. this saves some lookup - // time and indexing. moreover, the - // order of the loops is such that - // we can access the - // shape_gradients data stored - // contiguously (which is also - // advantageous because access to - // the global vector fe_function is - // more expensive than access to - // the small std::vector gradients - // - so we do the cheaper operation - // in the innermost loop) + // add up contributions of trial + // functions. note that here we + // deal with scalar finite + // elements, so no need to check + // for non-primitivity of shape + // functions. in order to increase + // the speed of this function, we + // directly access the data in the + // shape_gradients array, and + // increment pointers for accessing + // the data. this saves some lookup + // time and indexing. moreover, the + // order of the loops is such that + // we can access the + // shape_gradients data stored + // contiguously (which is also + // advantageous because access to + // the global vector fe_function is + // more expensive than access to + // the small std::vector gradients + // - so we do the cheaper operation + // in the innermost loop) for (unsigned int shape_func=0; shape_func *shape_gradient_ptr - = &this->shape_gradients[shape_func][0]; + = &this->shape_gradients[shape_func][0]; for (unsigned int point=0; point::get_function_gradients ( std::vector > > &gradients) const { Assert (gradients.size() == n_quadrature_points, - ExcDimensionMismatch(gradients.size(), n_quadrature_points)); + ExcDimensionMismatch(gradients.size(), n_quadrature_points)); const unsigned int n_components = fe->n_components(); for (unsigned i=0; iupdate_flags & update_gradients, ExcAccessToUninitializedField()); Assert (present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); - // initialize with zero + // initialize with zero for (unsigned i=0;i()); - // add up contributions of trial - // functions. now check whether the - // shape function is primitive or - // not. if it is, then set its only - // non-zero component, otherwise - // loop over components + // add up contributions of trial + // functions. now check whether the + // shape function is primitive or + // not. if it is, then set its only + // non-zero component, otherwise + // loop over components for (unsigned int shape_func=0; shape_funcis_primitive(shape_func)) - { - const unsigned int - row = fe->is_primitive() ? - shape_func : this->shape_function_to_row_table[shape_func]; - const Tensor<1,spacedim> *shape_gradient_ptr - = &this->shape_gradients[row][0]; - const unsigned int comp = fe->system_to_component_index(shape_func).first; - for (unsigned int point=0; pointis_primitive() ? + shape_func : this->shape_function_to_row_table[shape_func]; + const Tensor<1,spacedim> *shape_gradient_ptr + = &this->shape_gradients[row][0]; + const unsigned int comp = fe->system_to_component_index(shape_func).first; + for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) - continue; - - const unsigned int - row = (this->shape_function_to_row_table[shape_func] - + - std::count (fe->get_nonzero_components(shape_func).begin(), - fe->get_nonzero_components(shape_func).begin()+c, - true)); - - const Tensor<1,spacedim> *shape_gradient_ptr - = &this->shape_gradients[row][0]; - - for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) + continue; + + const unsigned int + row = (this->shape_function_to_row_table[shape_func] + + + std::count (fe->get_nonzero_components(shape_func).begin(), + fe->get_nonzero_components(shape_func).begin()+c, + true)); + + const Tensor<1,spacedim> *shape_gradient_ptr + = &this->shape_gradients[row][0]; + + for (unsigned int point=0; point::get_function_gradients ( { const unsigned int n_components = fe->n_components(); - // Size of indices must be a - // multiple of dofs_per_cell such - // that an integer number of - // function values is generated in - // each point. + // Size of indices must be a + // multiple of dofs_per_cell such + // that an integer number of + // function values is generated in + // each point. Assert (indices.size() % dofs_per_cell == 0, - ExcNotMultiple(indices.size(), dofs_per_cell)); + ExcNotMultiple(indices.size(), dofs_per_cell)); - // The number of components of the - // result may be a multiple of the - // number of components of the - // finite element + // The number of components of the + // result may be a multiple of the + // number of components of the + // finite element const unsigned int result_components = indices.size() * n_components / dofs_per_cell; - // Check if the value argument is - // initialized to the correct sizes + // Check if the value argument is + // initialized to the correct sizes if (quadrature_points_fastest) { Assert (gradients.size() == result_components, - ExcDimensionMismatch(gradients.size(), result_components)); + ExcDimensionMismatch(gradients.size(), result_components)); for (unsigned i=0;iupdate_flags & update_gradients, ExcAccessToUninitializedField()); - // initialize with zero + // initialize with zero for (unsigned i=0;i()); - // add up contributions of trial - // functions. now check whether the - // shape function is primitive or - // not. if it is, then set its only - // non-zero component, otherwise - // loop over components + // add up contributions of trial + // functions. now check whether the + // shape function is primitive or + // not. if it is, then set its only + // non-zero component, otherwise + // loop over components for (unsigned int mc = 0; mc < component_multiple; ++mc) for (unsigned int shape_func=0; shape_funcis_primitive(shape_func)) - { - const unsigned int - row = fe->is_primitive() ? - shape_func : this->shape_function_to_row_table[shape_func]; - const Tensor<1,spacedim> *shape_gradient_ptr - = &this->shape_gradients[row][0]; - const unsigned int comp = fe->system_to_component_index(shape_func).first - + mc * n_components; - - if (quadrature_points_fastest) - for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) - continue; - - const unsigned int - row = (this->shape_function_to_row_table[shape_func] - + - std::count (fe->get_nonzero_components(shape_func).begin(), - fe->get_nonzero_components(shape_func).begin()+c, - true)); - - const Tensor<1,spacedim> *shape_gradient_ptr - = &this->shape_gradients[row][0]; - const unsigned int comp = c + mc * n_components; - - if (quadrature_points_fastest) - for (unsigned int point=0; pointis_primitive(shape_func)) + { + const unsigned int + row = fe->is_primitive() ? + shape_func : this->shape_function_to_row_table[shape_func]; + const Tensor<1,spacedim> *shape_gradient_ptr + = &this->shape_gradients[row][0]; + const unsigned int comp = fe->system_to_component_index(shape_func).first + + mc * n_components; + + if (quadrature_points_fastest) + for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) + continue; + + const unsigned int + row = (this->shape_function_to_row_table[shape_func] + + + std::count (fe->get_nonzero_components(shape_func).begin(), + fe->get_nonzero_components(shape_func).begin()+c, + true)); + + const Tensor<1,spacedim> *shape_gradient_ptr + = &this->shape_gradients[row][0]; + const unsigned int comp = c + mc * n_components; + + if (quadrature_points_fastest) + for (unsigned int point=0; point void FEValuesBase:: get_function_hessians (const InputVector &fe_function, - std::vector > &hessians) const + std::vector > &hessians) const { Assert (fe->n_components() == 1, - ExcDimensionMismatch(fe->n_components(), 1)); + ExcDimensionMismatch(fe->n_components(), 1)); Assert (hessians.size() == n_quadrature_points, - ExcDimensionMismatch(hessians.size(), n_quadrature_points)); + ExcDimensionMismatch(hessians.size(), n_quadrature_points)); Assert (this->update_flags & update_hessians, ExcAccessToUninitializedField()); Assert (present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); - // initialize with zero + // initialize with zero std::fill_n (hessians.begin(), n_quadrature_points, Tensor<2,spacedim>()); - // add up contributions of trial - // functions. note that here we - // deal with scalar finite - // elements, so no need to check - // for non-primitivity of shape - // functions + // add up contributions of trial + // functions. note that here we + // deal with scalar finite + // elements, so no need to check + // for non-primitivity of shape + // functions for (unsigned int shape_func=0; shape_func *shape_hessians_ptr - = &this->shape_hessians[shape_func][0]; + = &this->shape_hessians[shape_func][0]; for (unsigned int point=0; point::get_function_hessians ( std::vector > &hessians) const { Assert (this->update_flags & update_second_derivatives, ExcAccessToUninitializedField()); - // This function fills a single - // component only + // This function fills a single + // component only Assert (fe->n_components() == 1, - ExcDimensionMismatch(fe->n_components(), 1)); - // One index for each dof + ExcDimensionMismatch(fe->n_components(), 1)); + // One index for each dof Assert (indices.size() == dofs_per_cell, - ExcDimensionMismatch(indices.size(), dofs_per_cell)); - // This vector has one entry for - // each quadrature point + ExcDimensionMismatch(indices.size(), dofs_per_cell)); + // This vector has one entry for + // each quadrature point Assert (hessians.size() == n_quadrature_points, - ExcDimensionMismatch(hessians.size(), n_quadrature_points)); + ExcDimensionMismatch(hessians.size(), n_quadrature_points)); - // initialize with zero + // initialize with zero std::fill_n (hessians.begin(), n_quadrature_points, Tensor<2,spacedim>()); - // add up contributions of trial - // functions. note that here we - // deal with scalar finite - // elements, so no need to check - // for non-primitivity of shape - // functions + // add up contributions of trial + // functions. note that here we + // deal with scalar finite + // elements, so no need to check + // for non-primitivity of shape + // functions for (unsigned int shape_func=0; shape_func *shape_hessians_ptr - = &this->shape_hessians[shape_func][0]; + = &this->shape_hessians[shape_func][0]; for (unsigned int point=0; point void FEValuesBase:: get_function_hessians (const InputVector &fe_function, - std::vector > > &hessians, - bool quadrature_points_fastest) const + std::vector > > &hessians, + bool quadrature_points_fastest) const { Assert (n_quadrature_points == hessians.size(), - ExcDimensionMismatch(hessians.size(), n_quadrature_points)); + ExcDimensionMismatch(hessians.size(), n_quadrature_points)); const unsigned int n_components = fe->n_components(); for (unsigned i=0;iupdate_flags & update_hessians, ExcAccessToUninitializedField()); Assert (present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); - // initialize with zero + // initialize with zero for (unsigned i=0;i()); - // add up contributions of trial - // functions + // add up contributions of trial + // functions for (unsigned int shape_func=0; shape_funcis_primitive(shape_func)) - { - const unsigned int - row = fe->is_primitive() ? - shape_func : this->shape_function_to_row_table[shape_func]; - - const Tensor<2,spacedim> *shape_hessian_ptr - = &this->shape_hessians[row][0]; - const unsigned int comp = fe->system_to_component_index(shape_func).first; - - if (quadrature_points_fastest) - for (unsigned int point=0; pointis_primitive() ? + shape_func : this->shape_function_to_row_table[shape_func]; + + const Tensor<2,spacedim> *shape_hessian_ptr + = &this->shape_hessians[row][0]; + const unsigned int comp = fe->system_to_component_index(shape_func).first; + + if (quadrature_points_fastest) + for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) - continue; - - const unsigned int - row = (this->shape_function_to_row_table[shape_func] - + - std::count (fe->get_nonzero_components(shape_func).begin(), - fe->get_nonzero_components(shape_func).begin()+c, - true)); - - const Tensor<2,spacedim> *shape_hessian_ptr - = &this->shape_hessians[row][0]; - - if (quadrature_points_fastest) - for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) + continue; + + const unsigned int + row = (this->shape_function_to_row_table[shape_func] + + + std::count (fe->get_nonzero_components(shape_func).begin(), + fe->get_nonzero_components(shape_func).begin()+c, + true)); + + const Tensor<2,spacedim> *shape_hessian_ptr + = &this->shape_hessians[row][0]; + + if (quadrature_points_fastest) + for (unsigned int point=0; point::get_function_hessians ( const unsigned int n_components = fe->n_components(); - // Size of indices must be a - // multiple of dofs_per_cell such - // that an integer number of - // function values is generated in - // each point. + // Size of indices must be a + // multiple of dofs_per_cell such + // that an integer number of + // function values is generated in + // each point. Assert (indices.size() % dofs_per_cell == 0, - ExcNotMultiple(indices.size(), dofs_per_cell)); + ExcNotMultiple(indices.size(), dofs_per_cell)); - // The number of components of the - // result may be a multiple of the - // number of components of the - // finite element + // The number of components of the + // result may be a multiple of the + // number of components of the + // finite element const unsigned int result_components = indices.size() * n_components / dofs_per_cell; - // Check if the value argument is - // initialized to the correct sizes + // Check if the value argument is + // initialized to the correct sizes if (quadrature_points_fastest) { Assert (hessians.size() == result_components, - ExcDimensionMismatch(hessians.size(), result_components)); + ExcDimensionMismatch(hessians.size(), result_components)); for (unsigned i=0;i()); - // add up contributions of trial - // functions. now check whether the - // shape function is primitive or - // not. if it is, then set its only - // non-zero component, otherwise - // loop over components + // add up contributions of trial + // functions. now check whether the + // shape function is primitive or + // not. if it is, then set its only + // non-zero component, otherwise + // loop over components for (unsigned int mc = 0; mc < component_multiple; ++mc) for (unsigned int shape_func=0; shape_funcis_primitive(shape_func)) - { - const unsigned int - row = fe->is_primitive() ? - shape_func : this->shape_function_to_row_table[shape_func]; - - const Tensor<2,spacedim> *shape_hessian_ptr - = &this->shape_hessians[row][0]; - const unsigned int comp = fe->system_to_component_index(shape_func).first - + mc * n_components; - - if (quadrature_points_fastest) - for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) - continue; - - const unsigned int - row = (this->shape_function_to_row_table[shape_func] - + - std::count (fe->get_nonzero_components(shape_func).begin(), - fe->get_nonzero_components(shape_func).begin()+c, - true)); - - const Tensor<2,spacedim> *shape_hessian_ptr - = &this->shape_hessians[row][0]; - const unsigned int comp = c + mc * n_components; - - if (quadrature_points_fastest) - for (unsigned int point=0; pointis_primitive(shape_func)) + { + const unsigned int + row = fe->is_primitive() ? + shape_func : this->shape_function_to_row_table[shape_func]; + + const Tensor<2,spacedim> *shape_hessian_ptr + = &this->shape_hessians[row][0]; + const unsigned int comp = fe->system_to_component_index(shape_func).first + + mc * n_components; + + if (quadrature_points_fastest) + for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) + continue; + + const unsigned int + row = (this->shape_function_to_row_table[shape_func] + + + std::count (fe->get_nonzero_components(shape_func).begin(), + fe->get_nonzero_components(shape_func).begin()+c, + true)); + + const Tensor<2,spacedim> *shape_hessian_ptr + = &this->shape_hessians[row][0]; + const unsigned int comp = c + mc * n_components; + + if (quadrature_points_fastest) + for (unsigned int point=0; point::get_function_laplacians ( { Assert (this->update_flags & update_hessians, ExcAccessToUninitializedField()); Assert (fe->n_components() == 1, - ExcDimensionMismatch(fe->n_components(), 1)); + ExcDimensionMismatch(fe->n_components(), 1)); Assert (laplacians.size() == n_quadrature_points, - ExcDimensionMismatch(laplacians.size(), n_quadrature_points)); + ExcDimensionMismatch(laplacians.size(), n_quadrature_points)); Assert (present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (fe_function.size() == present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), - present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), + present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); - // initialize with zero + // initialize with zero std::fill_n (laplacians.begin(), n_quadrature_points, 0); - // add up contributions of trial - // functions. note that here we - // deal with scalar finite - // elements, so no need to check - // for non-primitivity of shape - // functions. note that the - // laplacian is the trace of the - // hessian, so we use a pointer to - // the hessians and get their trace + // add up contributions of trial + // functions. note that here we + // deal with scalar finite + // elements, so no need to check + // for non-primitivity of shape + // functions. note that the + // laplacian is the trace of the + // hessian, so we use a pointer to + // the hessians and get their trace for (unsigned int shape_func=0; shape_func *shape_hessian_ptr - = &this->shape_hessians[shape_func][0]; + = &this->shape_hessians[shape_func][0]; for (unsigned int point=0; point::get_function_laplacians ( std::vector &laplacians) const { Assert (this->update_flags & update_hessians, ExcAccessToUninitializedField()); - // This function fills a single - // component only + // This function fills a single + // component only Assert (fe->n_components() == 1, - ExcDimensionMismatch(fe->n_components(), 1)); - // One index for each dof + ExcDimensionMismatch(fe->n_components(), 1)); + // One index for each dof Assert (indices.size() == dofs_per_cell, - ExcDimensionMismatch(indices.size(), dofs_per_cell)); - // This vector has one entry for - // each quadrature point + ExcDimensionMismatch(indices.size(), dofs_per_cell)); + // This vector has one entry for + // each quadrature point Assert (laplacians.size() == n_quadrature_points, - ExcDimensionMismatch(laplacians.size(), n_quadrature_points)); + ExcDimensionMismatch(laplacians.size(), n_quadrature_points)); - // initialize with zero + // initialize with zero std::fill_n (laplacians.begin(), n_quadrature_points, 0); - // add up contributions of trial - // functions. note that here we - // deal with scalar finite - // elements, so no need to check - // for non-primitivity of shape - // functions. note that the - // laplacian is the trace of the - // hessian, so we use a pointer to - // the hessians and get their trace + // add up contributions of trial + // functions. note that here we + // deal with scalar finite + // elements, so no need to check + // for non-primitivity of shape + // functions. note that the + // laplacian is the trace of the + // hessian, so we use a pointer to + // the hessians and get their trace for (unsigned int shape_func=0; shape_func *shape_hessian_ptr - = &this->shape_hessians[shape_func][0]; + = &this->shape_hessians[shape_func][0]; for (unsigned int point=0; point::get_function_laplacians ( std::vector >& laplacians) const { //TODO: Find out how to do this assertion. - // This vector must correspond to a - // complete discretization + // This vector must correspond to a + // complete discretization // Assert (fe_function.size() == present_cell->get_dof_handler().n_dofs(), -// ExcDimensionMismatch(fe_function.size(), -// present_cell->get_dof_handler().n_dofs())); - // One entry per quadrature point +// ExcDimensionMismatch(fe_function.size(), +// present_cell->get_dof_handler().n_dofs())); + // One entry per quadrature point Assert (present_cell.get() != 0, - ExcMessage ("FEValues object is not reinit'ed to any cell")); + ExcMessage ("FEValues object is not reinit'ed to any cell")); Assert (laplacians.size() == n_quadrature_points, - ExcDimensionMismatch(laplacians.size(), n_quadrature_points)); + ExcDimensionMismatch(laplacians.size(), n_quadrature_points)); const unsigned int n_components = fe->n_components(); - // Assert that we can write all - // components into the result - // vectors + // Assert that we can write all + // components into the result + // vectors for (unsigned i=0;iupdate_flags & update_hessians, ExcAccessToUninitializedField()); Assert (fe_function.size() == present_cell->n_dofs_for_dof_handler(), - ExcDimensionMismatch(fe_function.size(), present_cell->n_dofs_for_dof_handler())); + ExcDimensionMismatch(fe_function.size(), present_cell->n_dofs_for_dof_handler())); - // get function values of dofs - // on this cell + // get function values of dofs + // on this cell Vector::type> dof_values (dofs_per_cell); present_cell->get_interpolated_dof_values(fe_function, dof_values); - // initialize with zero + // initialize with zero for (unsigned i=0;iis_primitive(shape_func)) - { - const unsigned int - row = fe->is_primitive() ? - shape_func : this->shape_function_to_row_table[shape_func]; - - const Tensor<2,spacedim> *shape_hessian_ptr - = &this->shape_hessians[row][0]; - const unsigned int comp = fe->system_to_component_index(shape_func).first; - for (unsigned int point=0; pointis_primitive() ? + shape_func : this->shape_function_to_row_table[shape_func]; + + const Tensor<2,spacedim> *shape_hessian_ptr + = &this->shape_hessians[row][0]; + const unsigned int comp = fe->system_to_component_index(shape_func).first; + for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) - continue; - - const unsigned int - row = (this->shape_function_to_row_table[shape_func] - + - std::count (fe->get_nonzero_components(shape_func).begin(), - fe->get_nonzero_components(shape_func).begin()+c, - true)); - - const Tensor<2,spacedim> *shape_hessian_ptr - = &this->shape_hessians[row][0]; - - for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) + continue; + + const unsigned int + row = (this->shape_function_to_row_table[shape_func] + + + std::count (fe->get_nonzero_components(shape_func).begin(), + fe->get_nonzero_components(shape_func).begin()+c, + true)); + + const Tensor<2,spacedim> *shape_hessian_ptr + = &this->shape_hessians[row][0]; + + for (unsigned int point=0; point::get_function_laplacians ( const VectorSlice >& indices, std::vector >& laplacians) const { - // One value per quadrature point + // One value per quadrature point Assert (n_quadrature_points == laplacians.size(), - ExcDimensionMismatch(laplacians.size(), n_quadrature_points)); + ExcDimensionMismatch(laplacians.size(), n_quadrature_points)); const unsigned int n_components = fe->n_components(); - // Size of indices must be a - // multiple of dofs_per_cell such - // that an integer number of - // function values is generated in - // each point. + // Size of indices must be a + // multiple of dofs_per_cell such + // that an integer number of + // function values is generated in + // each point. Assert (indices.size() % dofs_per_cell == 0, - ExcNotMultiple(indices.size(), dofs_per_cell)); + ExcNotMultiple(indices.size(), dofs_per_cell)); - // The number of components of the - // result may be a multiple of the - // number of components of the - // finite element + // The number of components of the + // result may be a multiple of the + // number of components of the + // finite element const unsigned int result_components = indices.size() * n_components / dofs_per_cell; for (unsigned i=0;iupdate_flags & update_hessians, ExcAccessToUninitializedField()); - // initialize with zero + // initialize with zero for (unsigned i=0;iis_primitive(shape_func)) - { - const unsigned int - row = fe->is_primitive() ? - shape_func : this->shape_function_to_row_table[shape_func]; - - const Tensor<2,spacedim> *shape_hessian_ptr - = &this->shape_hessians[row][0]; - const unsigned int comp = fe->system_to_component_index(shape_func).first - + mc * n_components; - for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) - continue; - - const unsigned int - row = (this->shape_function_to_row_table[shape_func] - + - std::count (fe->get_nonzero_components(shape_func).begin(), - fe->get_nonzero_components(shape_func).begin()+c, - true)); - - const Tensor<2,spacedim> *shape_hessian_ptr - = &this->shape_hessians[row][0]; - const unsigned int comp = c + mc * n_components; - - for (unsigned int point=0; pointis_primitive(shape_func)) + { + const unsigned int + row = fe->is_primitive() ? + shape_func : this->shape_function_to_row_table[shape_func]; + + const Tensor<2,spacedim> *shape_hessian_ptr + = &this->shape_hessians[row][0]; + const unsigned int comp = fe->system_to_component_index(shape_func).first + + mc * n_components; + for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) + continue; + + const unsigned int + row = (this->shape_function_to_row_table[shape_func] + + + std::count (fe->get_nonzero_components(shape_func).begin(), + fe->get_nonzero_components(shape_func).begin()+c, + true)); + + const Tensor<2,spacedim> *shape_hessian_ptr + = &this->shape_hessians[row][0]; + const unsigned int comp = c + mc * n_components; + + for (unsigned int point=0; point::get_function_laplacians ( { const unsigned int n_components = fe->n_components(); - // Size of indices must be a - // multiple of dofs_per_cell such - // that an integer number of - // function values is generated in - // each point. + // Size of indices must be a + // multiple of dofs_per_cell such + // that an integer number of + // function values is generated in + // each point. Assert (indices.size() % dofs_per_cell == 0, - ExcNotMultiple(indices.size(), dofs_per_cell)); + ExcNotMultiple(indices.size(), dofs_per_cell)); - // The number of components of the - // result may be a multiple of the - // number of components of the - // finite element + // The number of components of the + // result may be a multiple of the + // number of components of the + // finite element const unsigned int result_components = indices.size() * n_components / dofs_per_cell; - // Check if the value argument is - // initialized to the correct sizes + // Check if the value argument is + // initialized to the correct sizes if (quadrature_points_fastest) { Assert (laplacians.size() == result_components, - ExcDimensionMismatch(laplacians.size(), result_components)); + ExcDimensionMismatch(laplacians.size(), result_components)); for (unsigned i=0;iupdate_flags & update_hessians, ExcAccessToUninitializedField()); - // initialize with zero + // initialize with zero for (unsigned i=0;iis_primitive(shape_func)) - { - const unsigned int - row = fe->is_primitive() ? - shape_func : this->shape_function_to_row_table[shape_func]; - - const Tensor<2,spacedim> *shape_hessian_ptr - = &this->shape_hessians[row][0]; - const unsigned int comp = fe->system_to_component_index(shape_func).first - + mc * n_components; - if (quadrature_points_fastest) - for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) - continue; - - const unsigned int - row = (this->shape_function_to_row_table[shape_func] - + - std::count (fe->get_nonzero_components(shape_func).begin(), - fe->get_nonzero_components(shape_func).begin()+c, - true)); - - const Tensor<2,spacedim> *shape_hessian_ptr - = &this->shape_hessians[row][0]; - const unsigned int comp = c + mc * n_components; - - if (quadrature_points_fastest) - for (unsigned int point=0; pointis_primitive(shape_func)) + { + const unsigned int + row = fe->is_primitive() ? + shape_func : this->shape_function_to_row_table[shape_func]; + + const Tensor<2,spacedim> *shape_hessian_ptr + = &this->shape_hessians[row][0]; + const unsigned int comp = fe->system_to_component_index(shape_func).first + + mc * n_components; + if (quadrature_points_fastest) + for (unsigned int point=0; pointget_nonzero_components(shape_func)[c] == false) + continue; + + const unsigned int + row = (this->shape_function_to_row_table[shape_func] + + + std::count (fe->get_nonzero_components(shape_func).begin(), + fe->get_nonzero_components(shape_func).begin()+c, + true)); + + const Tensor<2,spacedim> *shape_hessian_ptr + = &this->shape_hessians[row][0]; + const unsigned int comp = c + mc * n_components; + + if (quadrature_points_fastest) + for (unsigned int point=0; point::get_normal_vectors () const { typedef FEValuesBase FEVB; Assert (this->update_flags & update_normal_vectors, - typename FEVB::ExcAccessToUninitializedField()); + typename FEVB::ExcAccessToUninitializedField()); return this->normal_vectors; } @@ -3308,25 +3308,25 @@ std::size_t FEValuesBase::memory_consumption () const { return (MemoryConsumption::memory_consumption (this->shape_values) + - MemoryConsumption::memory_consumption (this->shape_gradients) + - MemoryConsumption::memory_consumption (this->shape_hessians) + - MemoryConsumption::memory_consumption (this->JxW_values) + - MemoryConsumption::memory_consumption (this->jacobians) + - MemoryConsumption::memory_consumption (this->jacobian_grads) + - MemoryConsumption::memory_consumption (this->inverse_jacobians) + - MemoryConsumption::memory_consumption (this->quadrature_points) + - MemoryConsumption::memory_consumption (this->normal_vectors) + - MemoryConsumption::memory_consumption (this->boundary_forms) + - sizeof(this->update_flags) + - MemoryConsumption::memory_consumption (n_quadrature_points) + - MemoryConsumption::memory_consumption (dofs_per_cell) + - MemoryConsumption::memory_consumption (mapping) + - MemoryConsumption::memory_consumption (fe) + - MemoryConsumption::memory_consumption (mapping_data) + - MemoryConsumption::memory_consumption (*mapping_data) + - MemoryConsumption::memory_consumption (fe_data) + - MemoryConsumption::memory_consumption (*fe_data) + - MemoryConsumption::memory_consumption (this->shape_function_to_row_table)); + MemoryConsumption::memory_consumption (this->shape_gradients) + + MemoryConsumption::memory_consumption (this->shape_hessians) + + MemoryConsumption::memory_consumption (this->JxW_values) + + MemoryConsumption::memory_consumption (this->jacobians) + + MemoryConsumption::memory_consumption (this->jacobian_grads) + + MemoryConsumption::memory_consumption (this->inverse_jacobians) + + MemoryConsumption::memory_consumption (this->quadrature_points) + + MemoryConsumption::memory_consumption (this->normal_vectors) + + MemoryConsumption::memory_consumption (this->boundary_forms) + + sizeof(this->update_flags) + + MemoryConsumption::memory_consumption (n_quadrature_points) + + MemoryConsumption::memory_consumption (dofs_per_cell) + + MemoryConsumption::memory_consumption (mapping) + + MemoryConsumption::memory_consumption (fe) + + MemoryConsumption::memory_consumption (mapping_data) + + MemoryConsumption::memory_consumption (*mapping_data) + + MemoryConsumption::memory_consumption (fe_data) + + MemoryConsumption::memory_consumption (*fe_data) + + MemoryConsumption::memory_consumption (this->shape_function_to_row_table)); } @@ -3336,17 +3336,17 @@ UpdateFlags FEValuesBase::compute_update_flags (const UpdateFlags update_flags) const { - // first find out which objects - // need to be recomputed on each - // cell we visit. this we have to - // ask the finite element and mapping. - // elements are first since they - // might require update in mapping + // first find out which objects + // need to be recomputed on each + // cell we visit. this we have to + // ask the finite element and mapping. + // elements are first since they + // might require update in mapping UpdateFlags flags = update_flags - | fe->update_once (update_flags) - | fe->update_each (update_flags); + | fe->update_once (update_flags) + | fe->update_each (update_flags); flags |= mapping->update_once (flags) - | mapping->update_each (flags); + | mapping->update_each (flags); return flags; } @@ -3360,9 +3360,9 @@ FEValuesBase< dim, spacedim >::invalidate_present_cell () // connected via a signal to a triangulation Assert (present_cell.get() != 0, ExcInternalError()); - // so delete the present cell and - // disconnect from the signal we have with - // it + // so delete the present cell and + // disconnect from the signal we have with + // it tria_listener.disconnect (); present_cell.reset (); } @@ -3377,19 +3377,19 @@ maybe_invalidate_previous_present_cell (const typename Triangulationget_triangulation() != &present_cell->operator typename Triangulation::cell_iterator() - ->get_triangulation()) + ->get_triangulation()) { - // the triangulations for the previous cell and the current cell - // do not match. disconnect from the previous triangulation and - // connect to the current one; also invalidate the previous - // cell because we shouldn't be comparing cells from different - // triangulations - tria_listener.disconnect (); - invalidate_present_cell(); - tria_listener = - cell->get_triangulation().signals.any_change.connect - (std_cxx1x::bind (&FEValuesBase::invalidate_present_cell, - std_cxx1x::ref(static_cast&>(*this)))); + // the triangulations for the previous cell and the current cell + // do not match. disconnect from the previous triangulation and + // connect to the current one; also invalidate the previous + // cell because we shouldn't be comparing cells from different + // triangulations + tria_listener.disconnect (); + invalidate_present_cell(); + tria_listener = + cell->get_triangulation().signals.any_change.connect + (std_cxx1x::bind (&FEValuesBase::invalidate_present_cell, + std_cxx1x::ref(static_cast&>(*this)))); } } else @@ -3400,7 +3400,7 @@ maybe_invalidate_previous_present_cell (const typename Triangulationget_triangulation().signals.post_refinement.connect (std_cxx1x::bind (&FEValuesBase::invalidate_present_cell, - std_cxx1x::ref(static_cast&>(*this)))); + std_cxx1x::ref(static_cast&>(*this)))); } } @@ -3411,34 +3411,34 @@ void FEValuesBase::check_cell_similarity (const typename Triangulation::cell_iterator &cell) { - // case that there has not been any cell - // before + // case that there has not been any cell + // before if (this->present_cell.get() == 0) cell_similarity = CellSimilarity::none; else - // in MappingQ, data can have been - // modified during the last call. Then, - // we can't use that data on the new - // cell. + // in MappingQ, data can have been + // modified during the last call. Then, + // we can't use that data on the new + // cell. if (cell_similarity == CellSimilarity::invalid_next_cell) cell_similarity = CellSimilarity::none; else cell_similarity = (cell->is_translation_of - (static_cast::cell_iterator &>(*this->present_cell)) - ? - CellSimilarity::translation - : - CellSimilarity::none); + (static_cast::cell_iterator &>(*this->present_cell)) + ? + CellSimilarity::translation + : + CellSimilarity::none); if ( (dim::cell_iterator &> - (*this->present_cell)->direction_flag() - != cell->direction_flag() ) + (*this->present_cell)->direction_flag() + != cell->direction_flag() ) cell_similarity = CellSimilarity::inverted_translation; } - // TODO: here, one could implement other - // checks for similarity, e.g. for - // children of a parallelogram. + // TODO: here, one could implement other + // checks for similarity, e.g. for + // children of a parallelogram. } @@ -3468,16 +3468,16 @@ const unsigned int FEValues::integral_dimension; template FEValues::FEValues (const Mapping &mapping, - const FiniteElement &fe, - const Quadrature &q, - const UpdateFlags update_flags) - : - FEValuesBase (q.size(), - fe.dofs_per_cell, - update_default, - mapping, - fe), - quadrature (q) + const FiniteElement &fe, + const Quadrature &q, + const UpdateFlags update_flags) + : + FEValuesBase (q.size(), + fe.dofs_per_cell, + update_default, + mapping, + fe), + quadrature (q) { initialize (update_flags); } @@ -3486,15 +3486,15 @@ FEValues::FEValues (const Mapping &mapping, template FEValues::FEValues (const FiniteElement &fe, - const Quadrature &q, - const UpdateFlags update_flags) - : - FEValuesBase (q.size(), - fe.dofs_per_cell, - update_default, - StaticMappingQ1::mapping, - fe), - quadrature (q) + const Quadrature &q, + const UpdateFlags update_flags) + : + FEValuesBase (q.size(), + fe.dofs_per_cell, + update_default, + StaticMappingQ1::mapping, + fe), + quadrature (q) { Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping")); initialize (update_flags); @@ -3506,24 +3506,24 @@ template void FEValues::initialize (const UpdateFlags update_flags) { - // You can compute normal vectors - // to the cells only in the - // codimension one case. + // You can compute normal vectors + // to the cells only in the + // codimension one case. typedef FEValuesBase FEVB; if (dim != spacedim-1) Assert ((update_flags & update_normal_vectors) == false, - typename FEVB::ExcInvalidUpdateFlag()); + typename FEVB::ExcInvalidUpdateFlag()); const UpdateFlags flags = this->compute_update_flags (update_flags); - // then get objects into which the - // FE and the Mapping can store - // intermediate data used across - // calls to reinit + // then get objects into which the + // FE and the Mapping can store + // intermediate data used across + // calls to reinit this->mapping_data = this->mapping->get_data(flags, quadrature); this->fe_data = this->fe->get_data(flags, *this->mapping, quadrature); - // set up objects within this class + // set up objects within this class FEValuesData::initialize (this->n_quadrature_points, *this->fe, flags); } @@ -3533,33 +3533,33 @@ template void FEValues::reinit (const typename DoFHandler::cell_iterator &cell) { - // assert that the finite elements - // passed to the constructor and - // used by the DoFHandler used by - // this cell, are the same + // assert that the finite elements + // passed to the constructor and + // used by the DoFHandler used by + // this cell, are the same typedef FEValuesBase FEVB; Assert (static_cast&>(*this->fe) == - static_cast&>(cell->get_fe()), - typename FEVB::ExcFEDontMatch()); + static_cast&>(cell->get_fe()), + typename FEVB::ExcFEDontMatch()); this->maybe_invalidate_previous_present_cell (cell); this->check_cell_similarity(cell); - // set new cell. auto_ptr will take - // care that old object gets - // destroyed and also that this - // object gets destroyed in the - // destruction of this class + // set new cell. auto_ptr will take + // care that old object gets + // destroyed and also that this + // object gets destroyed in the + // destruction of this class this->present_cell.reset (new typename FEValuesBase::template CellIterator::cell_iterator> (cell)); - // this was the part of the work - // that is dependent on the actual - // data type of the iterator. now - // pass on to the function doing - // the real work. + // this was the part of the work + // that is dependent on the actual + // data type of the iterator. now + // pass on to the function doing + // the real work. do_reinit (); } @@ -3569,32 +3569,32 @@ template void FEValues::reinit (const typename hp::DoFHandler::cell_iterator &cell) { - // assert that the finite elements - // passed to the constructor and - // used by the DoFHandler used by - // this cell, are the same + // assert that the finite elements + // passed to the constructor and + // used by the DoFHandler used by + // this cell, are the same typedef FEValuesBase FEVB; Assert (static_cast&>(*this->fe) == - static_cast&>(cell->get_fe()), - typename FEVB::ExcFEDontMatch()); + static_cast&>(cell->get_fe()), + typename FEVB::ExcFEDontMatch()); this->maybe_invalidate_previous_present_cell (cell); this->check_cell_similarity(cell); - // set new cell. auto_ptr will take - // care that old object gets - // destroyed and also that this - // object gets destroyed in the - // destruction of this class + // set new cell. auto_ptr will take + // care that old object gets + // destroyed and also that this + // object gets destroyed in the + // destruction of this class this->present_cell.reset (new typename FEValuesBase::template CellIterator::cell_iterator> (cell)); - // this was the part of the work - // that is dependent on the actual - // data type of the iterator. now - // pass on to the function doing - // the real work. + // this was the part of the work + // that is dependent on the actual + // data type of the iterator. now + // pass on to the function doing + // the real work. do_reinit (); } @@ -3609,34 +3609,34 @@ FEValues::reinit (const typename MGDoFHandler::cell_ return; } - // assert that the finite elements - // passed to the constructor and - // used by the DoFHandler used by - // this cell, are the same + // assert that the finite elements + // passed to the constructor and + // used by the DoFHandler used by + // this cell, are the same //TODO: This was documented out ith the repository. Why? // Assert (static_cast&>(*this->fe) == -// static_cast&>(cell->get_fe()), -// typename FEValuesBase::ExcFEDontMatch()); +// static_cast&>(cell->get_fe()), +// typename FEValuesBase::ExcFEDontMatch()); this->maybe_invalidate_previous_present_cell (cell); this->check_cell_similarity(cell); - // set new cell. auto_ptr will take - // care that old object gets - // destroyed and also that this - // object gets destroyed in the - // destruction of this class + // set new cell. auto_ptr will take + // care that old object gets + // destroyed and also that this + // object gets destroyed in the + // destruction of this class this->present_cell.reset (new typename FEValuesBase::template CellIterator::cell_iterator> (cell)); - // this was the part of the work - // that is dependent on the actual - // data type of the iterator. now - // pass on to the function doing - // the real work. + // this was the part of the work + // that is dependent on the actual + // data type of the iterator. now + // pass on to the function doing + // the real work. do_reinit (); } @@ -3645,23 +3645,23 @@ FEValues::reinit (const typename MGDoFHandler::cell_ template void FEValues::reinit (const typename Triangulation::cell_iterator &cell) { - // no FE in this cell, so no assertion - // necessary here + // no FE in this cell, so no assertion + // necessary here this->maybe_invalidate_previous_present_cell (cell); this->check_cell_similarity(cell); - // set new cell. auto_ptr will take - // care that old object gets - // destroyed and also that this - // object gets destroyed in the - // destruction of this class + // set new cell. auto_ptr will take + // care that old object gets + // destroyed and also that this + // object gets destroyed in the + // destruction of this class this->present_cell.reset (new typename FEValuesBase::TriaCellIterator (cell)); - // this was the part of the work - // that is dependent on the actual - // data type of the iterator. now - // pass on to the function doing - // the real work. + // this was the part of the work + // that is dependent on the actual + // data type of the iterator. now + // pass on to the function doing + // the real work. do_reinit (); } @@ -3671,23 +3671,23 @@ template void FEValues::do_reinit () { this->get_mapping().fill_fe_values(*this->present_cell, - quadrature, - *this->mapping_data, - this->quadrature_points, - this->JxW_values, - this->jacobians, - this->jacobian_grads, - this->inverse_jacobians, - this->normal_vectors, - this->cell_similarity); + quadrature, + *this->mapping_data, + this->quadrature_points, + this->JxW_values, + this->jacobians, + this->jacobian_grads, + this->inverse_jacobians, + this->normal_vectors, + this->cell_similarity); this->get_fe().fill_fe_values(this->get_mapping(), - *this->present_cell, - quadrature, - *this->mapping_data, - *this->fe_data, - *this, - this->cell_similarity); + *this->present_cell, + quadrature, + *this->mapping_data, + *this->fe_data, + *this, + this->cell_similarity); this->fe_data->clear_first_cell (); this->mapping_data->clear_first_cell (); @@ -3700,7 +3700,7 @@ std::size_t FEValues::memory_consumption () const { return (FEValuesBase::memory_consumption () + - MemoryConsumption::memory_consumption (quadrature)); + MemoryConsumption::memory_consumption (quadrature)); } @@ -3709,18 +3709,18 @@ FEValues::memory_consumption () const template FEFaceValuesBase::FEFaceValuesBase (const unsigned int n_q_points, - const unsigned int dofs_per_cell, - const UpdateFlags, - const Mapping &mapping, - const FiniteElement &fe, - const Quadrature& quadrature) - : - FEValuesBase (n_q_points, - dofs_per_cell, - update_default, - mapping, - fe), - quadrature(quadrature) + const unsigned int dofs_per_cell, + const UpdateFlags, + const Mapping &mapping, + const FiniteElement &fe, + const Quadrature& quadrature) + : + FEValuesBase (n_q_points, + dofs_per_cell, + update_default, + mapping, + fe), + quadrature(quadrature) {} @@ -3731,7 +3731,7 @@ FEFaceValuesBase::get_boundary_forms () const { typedef FEValuesBase FEVB; Assert (this->update_flags & update_boundary_forms, - typename FEVB::ExcAccessToUninitializedField()); + typename FEVB::ExcAccessToUninitializedField()); return this->boundary_forms; } @@ -3742,7 +3742,7 @@ std::size_t FEFaceValuesBase::memory_consumption () const { return (FEValuesBase::memory_consumption () + - MemoryConsumption::memory_consumption (quadrature)); + MemoryConsumption::memory_consumption (quadrature)); } @@ -3757,15 +3757,15 @@ const unsigned int FEFaceValues::integral_dimension; template FEFaceValues::FEFaceValues (const Mapping &mapping, - const FiniteElement &fe, - const Quadrature &quadrature, - const UpdateFlags update_flags) - : - FEFaceValuesBase (quadrature.size(), - fe.dofs_per_cell, - update_flags, - mapping, - fe, quadrature) + const FiniteElement &fe, + const Quadrature &quadrature, + const UpdateFlags update_flags) + : + FEFaceValuesBase (quadrature.size(), + fe.dofs_per_cell, + update_flags, + mapping, + fe, quadrature) { initialize (update_flags); } @@ -3774,14 +3774,14 @@ FEFaceValues::FEFaceValues (const Mapping &map template FEFaceValues::FEFaceValues (const FiniteElement &fe, - const Quadrature &quadrature, - const UpdateFlags update_flags) - : - FEFaceValuesBase (quadrature.size(), - fe.dofs_per_cell, - update_flags, - StaticMappingQ1::mapping, - fe, quadrature) + const Quadrature &quadrature, + const UpdateFlags update_flags) + : + FEFaceValuesBase (quadrature.size(), + fe.dofs_per_cell, + update_flags, + StaticMappingQ1::mapping, + fe, quadrature) { Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping")); initialize (update_flags); @@ -3795,14 +3795,14 @@ FEFaceValues::initialize (const UpdateFlags update_flags) { const UpdateFlags flags = this->compute_update_flags (update_flags); - // then get objects into which the - // FE and the Mapping can store - // intermediate data used across - // calls to reinit + // then get objects into which the + // FE and the Mapping can store + // intermediate data used across + // calls to reinit this->mapping_data = this->mapping->get_face_data(flags, this->quadrature); this->fe_data = this->fe->get_face_data(flags, *this->mapping, this->quadrature); - // set up objects within this class + // set up objects within this class FEValuesData::initialize(this->n_quadrature_points, *this->fe, flags); } @@ -3810,34 +3810,34 @@ FEFaceValues::initialize (const UpdateFlags update_flags) template void FEFaceValues::reinit (const typename DoFHandler::cell_iterator &cell, - const unsigned int face_no) + const unsigned int face_no) { - // assert that the finite elements - // passed to the constructor and - // used by the DoFHandler used by - // this cell, are the same + // assert that the finite elements + // passed to the constructor and + // used by the DoFHandler used by + // this cell, are the same // Assert (static_cast&>(*this->fe) == -// static_cast&>(cell->get_dof_handler().get_fe()), -// typename FEValuesBase::ExcFEDontMatch()); +// static_cast&>(cell->get_dof_handler().get_fe()), +// typename FEValuesBase::ExcFEDontMatch()); Assert (face_no < GeometryInfo::faces_per_cell, - ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); - // set new cell. auto_ptr will take - // care that old object gets - // destroyed and also that this - // object gets destroyed in the - // destruction of this class + // set new cell. auto_ptr will take + // care that old object gets + // destroyed and also that this + // object gets destroyed in the + // destruction of this class this->maybe_invalidate_previous_present_cell (cell); this->present_cell.reset (new typename FEValuesBase::template CellIterator::cell_iterator> (cell)); - // this was the part of the work - // that is dependent on the actual - // data type of the iterator. now - // pass on to the function doing - // the real work. + // this was the part of the work + // that is dependent on the actual + // data type of the iterator. now + // pass on to the function doing + // the real work. do_reinit (face_no); } @@ -3845,36 +3845,36 @@ void FEFaceValues::reinit (const typename DoFHandler template void FEFaceValues::reinit (const typename hp::DoFHandler::cell_iterator &cell, - const unsigned int face_no) + const unsigned int face_no) { - // assert that the finite elements - // passed to the constructor and - // used by the DoFHandler used by - // this cell, are the same + // assert that the finite elements + // passed to the constructor and + // used by the DoFHandler used by + // this cell, are the same typedef FEValuesBase FEVB; Assert (static_cast&>(*this->fe) == - static_cast&>( - cell->get_dof_handler().get_fe()[cell->active_fe_index ()]), - typename FEVB::ExcFEDontMatch()); + static_cast&>( + cell->get_dof_handler().get_fe()[cell->active_fe_index ()]), + typename FEVB::ExcFEDontMatch()); Assert (face_no < GeometryInfo::faces_per_cell, - ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); - // set new cell. auto_ptr will take - // care that old object gets - // destroyed and also that this - // object gets destroyed in the - // destruction of this class + // set new cell. auto_ptr will take + // care that old object gets + // destroyed and also that this + // object gets destroyed in the + // destruction of this class this->maybe_invalidate_previous_present_cell (cell); this->present_cell.reset (new typename FEValuesBase::template CellIterator::cell_iterator> (cell)); - // this was the part of the work - // that is dependent on the actual - // data type of the iterator. now - // pass on to the function doing - // the real work. + // this was the part of the work + // that is dependent on the actual + // data type of the iterator. now + // pass on to the function doing + // the real work. do_reinit (face_no); } @@ -3882,65 +3882,65 @@ void FEFaceValues::reinit (const typename hp::DoFHandler void FEFaceValues::reinit (const typename MGDoFHandler::cell_iterator &cell, - const unsigned int face_no) + const unsigned int face_no) { if (spacedim > dim) { Assert(false,ExcNotImplemented()); return; } - // assert that the finite elements - // passed to the constructor and - // used by the DoFHandler used by - // this cell, are the same + // assert that the finite elements + // passed to the constructor and + // used by the DoFHandler used by + // this cell, are the same typedef FEValuesBase FEVB; Assert (static_cast&>(*this->fe) == - static_cast&>(cell->get_dof_handler().get_fe()), - typename FEVB::ExcFEDontMatch()); + static_cast&>(cell->get_dof_handler().get_fe()), + typename FEVB::ExcFEDontMatch()); Assert (face_no < GeometryInfo::faces_per_cell, - ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); - // set new cell. auto_ptr will take - // care that old object gets - // destroyed and also that this - // object gets destroyed in the - // destruction of this class + // set new cell. auto_ptr will take + // care that old object gets + // destroyed and also that this + // object gets destroyed in the + // destruction of this class this->maybe_invalidate_previous_present_cell (cell); this->present_cell.reset (new typename FEValuesBase::template CellIterator::cell_iterator> (cell)); - // this was the part of the work - // that is dependent on the actual - // data type of the iterator. now - // pass on to the function doing - // the real work. + // this was the part of the work + // that is dependent on the actual + // data type of the iterator. now + // pass on to the function doing + // the real work. do_reinit (face_no); } template void FEFaceValues::reinit (const typename Triangulation::cell_iterator &cell, - const unsigned int face_no) + const unsigned int face_no) { Assert (face_no < GeometryInfo::faces_per_cell, - ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); - // set new cell. auto_ptr will take - // care that old object gets - // destroyed and also that this - // object gets destroyed in the - // destruction of this class + // set new cell. auto_ptr will take + // care that old object gets + // destroyed and also that this + // object gets destroyed in the + // destruction of this class this->maybe_invalidate_previous_present_cell (cell); this->present_cell.reset (new typename FEValuesBase::TriaCellIterator (cell)); - // this was the part of the work - // that is dependent on the actual - // data type of the iterator. now - // pass on to the function doing - // the real work. + // this was the part of the work + // that is dependent on the actual + // data type of the iterator. now + // pass on to the function doing + // the real work. do_reinit (face_no); } @@ -3949,26 +3949,26 @@ void FEFaceValues::reinit (const typename Triangulation void FEFaceValues::do_reinit (const unsigned int face_no) { - // first of all, set the - // present_face_index (if - // available) + // first of all, set the + // present_face_index (if + // available) const typename Triangulation::cell_iterator cell=*this->present_cell; this->present_face_index=cell->face_index(face_no); this->get_mapping().fill_fe_face_values(*this->present_cell, face_no, - this->quadrature, - *this->mapping_data, - this->quadrature_points, - this->JxW_values, - this->boundary_forms, - this->normal_vectors); + this->quadrature, + *this->mapping_data, + this->quadrature_points, + this->JxW_values, + this->boundary_forms, + this->normal_vectors); this->get_fe().fill_fe_face_values(this->get_mapping(), - *this->present_cell, face_no, - this->quadrature, - *this->mapping_data, - *this->fe_data, - *this); + *this->present_cell, face_no, + this->quadrature, + *this->mapping_data, + *this->fe_data, + *this); this->fe_data->clear_first_cell (); this->mapping_data->clear_first_cell (); @@ -3988,15 +3988,15 @@ const unsigned int FESubfaceValues::integral_dimension; template FESubfaceValues::FESubfaceValues (const Mapping &mapping, - const FiniteElement &fe, - const Quadrature &quadrature, - const UpdateFlags update_flags) - : - FEFaceValuesBase (quadrature.size(), - fe.dofs_per_cell, - update_flags, - mapping, - fe, quadrature) + const FiniteElement &fe, + const Quadrature &quadrature, + const UpdateFlags update_flags) + : + FEFaceValuesBase (quadrature.size(), + fe.dofs_per_cell, + update_flags, + mapping, + fe, quadrature) { initialize (update_flags); } @@ -4005,14 +4005,14 @@ FESubfaceValues::FESubfaceValues (const Mapping template FESubfaceValues::FESubfaceValues (const FiniteElement &fe, - const Quadrature &quadrature, - const UpdateFlags update_flags) - : - FEFaceValuesBase (quadrature.size(), - fe.dofs_per_cell, - update_flags, - StaticMappingQ1::mapping, - fe, quadrature) + const Quadrature &quadrature, + const UpdateFlags update_flags) + : + FEFaceValuesBase (quadrature.size(), + fe.dofs_per_cell, + update_flags, + StaticMappingQ1::mapping, + fe, quadrature) { Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping")); initialize (update_flags); @@ -4026,16 +4026,16 @@ FESubfaceValues::initialize (const UpdateFlags update_flags) { const UpdateFlags flags = this->compute_update_flags (update_flags); - // then get objects into which the - // FE and the Mapping can store - // intermediate data used across - // calls to reinit + // then get objects into which the + // FE and the Mapping can store + // intermediate data used across + // calls to reinit this->mapping_data = this->mapping->get_subface_data(flags, this->quadrature); this->fe_data = this->fe->get_subface_data(flags, - *this->mapping, - this->quadrature); + *this->mapping, + this->quadrature); - // set up objects within this class + // set up objects within this class FEValuesData::initialize(this->n_quadrature_points, *this->fe, flags); } @@ -4043,53 +4043,53 @@ FESubfaceValues::initialize (const UpdateFlags update_flags) template void FESubfaceValues::reinit (const typename DoFHandler::cell_iterator &cell, - const unsigned int face_no, - const unsigned int subface_no) + const unsigned int face_no, + const unsigned int subface_no) { - // assert that the finite elements - // passed to the constructor and - // used by the DoFHandler used by - // this cell, are the same + // assert that the finite elements + // passed to the constructor and + // used by the DoFHandler used by + // this cell, are the same // Assert (static_cast&>(*this->fe) == -// static_cast&>(cell->get_dof_handler().get_fe()), -// typename FEValuesBase::ExcFEDontMatch()); +// static_cast&>(cell->get_dof_handler().get_fe()), +// typename FEValuesBase::ExcFEDontMatch()); Assert (face_no < GeometryInfo::faces_per_cell, - ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); - // We would like to check for - // subface_no < cell->face(face_no)->n_children(), - // but unfortunately the current - // function is also called for - // faces without children (see - // tests/fe/mapping.cc). Therefore, - // we must use following workaround - // of two separate assertions + ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); + // We would like to check for + // subface_no < cell->face(face_no)->n_children(), + // but unfortunately the current + // function is also called for + // faces without children (see + // tests/fe/mapping.cc). Therefore, + // we must use following workaround + // of two separate assertions Assert (cell->face(face_no)->has_children() || - subface_no < GeometryInfo::max_children_per_face, - ExcIndexRange (subface_no, 0, GeometryInfo::max_children_per_face)); + subface_no < GeometryInfo::max_children_per_face, + ExcIndexRange (subface_no, 0, GeometryInfo::max_children_per_face)); Assert (!cell->face(face_no)->has_children() || - subface_no < cell->face(face_no)->number_of_children(), - ExcIndexRange (subface_no, 0, cell->face(face_no)->number_of_children())); + subface_no < cell->face(face_no)->number_of_children(), + ExcIndexRange (subface_no, 0, cell->face(face_no)->number_of_children())); Assert (cell->has_children() == false, - ExcMessage ("You can't use subface data for cells that are " - "already refined. Iterate over their children " - "instead in these cases.")); - - // set new cell. auto_ptr will take - // care that old object gets - // destroyed and also that this - // object gets destroyed in the - // destruction of this class + ExcMessage ("You can't use subface data for cells that are " + "already refined. Iterate over their children " + "instead in these cases.")); + + // set new cell. auto_ptr will take + // care that old object gets + // destroyed and also that this + // object gets destroyed in the + // destruction of this class this->maybe_invalidate_previous_present_cell (cell); this->present_cell.reset (new typename FEValuesBase::template CellIterator::cell_iterator> (cell)); - // this was the part of the work - // that is dependent on the actual - // data type of the iterator. now - // pass on to the function doing - // the real work. + // this was the part of the work + // that is dependent on the actual + // data type of the iterator. now + // pass on to the function doing + // the real work. do_reinit (face_no, subface_no); } @@ -4097,79 +4097,79 @@ void FESubfaceValues::reinit (const typename DoFHandler void FESubfaceValues::reinit (const typename hp::DoFHandler::cell_iterator &cell, - const unsigned int face_no, - const unsigned int subface_no) + const unsigned int face_no, + const unsigned int subface_no) { - // assert that the finite elements - // passed to the constructor and - // used by the hp::DoFHandler used by - // this cell, are the same + // assert that the finite elements + // passed to the constructor and + // used by the hp::DoFHandler used by + // this cell, are the same typedef FEValuesBase FEVB; Assert (static_cast&>(*this->fe) == - static_cast&>( - cell->get_dof_handler().get_fe()[cell->active_fe_index ()]), - typename FEVB::ExcFEDontMatch()); + static_cast&>( + cell->get_dof_handler().get_fe()[cell->active_fe_index ()]), + typename FEVB::ExcFEDontMatch()); Assert (face_no < GeometryInfo::faces_per_cell, - ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); Assert (subface_no < cell->face(face_no)->number_of_children(), - ExcIndexRange (subface_no, 0, cell->face(face_no)->number_of_children())); + ExcIndexRange (subface_no, 0, cell->face(face_no)->number_of_children())); Assert (cell->has_children() == false, - ExcMessage ("You can't use subface data for cells that are " - "already refined. Iterate over their children " - "instead in these cases.")); - - // set new cell. auto_ptr will take - // care that old object gets - // destroyed and also that this - // object gets destroyed in the - // destruction of this class + ExcMessage ("You can't use subface data for cells that are " + "already refined. Iterate over their children " + "instead in these cases.")); + + // set new cell. auto_ptr will take + // care that old object gets + // destroyed and also that this + // object gets destroyed in the + // destruction of this class this->maybe_invalidate_previous_present_cell (cell); this->present_cell.reset (new typename FEValuesBase::template CellIterator::cell_iterator> (cell)); - // this was the part of the work - // that is dependent on the actual - // data type of the iterator. now - // pass on to the function doing - // the real work. + // this was the part of the work + // that is dependent on the actual + // data type of the iterator. now + // pass on to the function doing + // the real work. do_reinit (face_no, subface_no); } template void FESubfaceValues::reinit (const typename MGDoFHandler::cell_iterator &cell, - const unsigned int face_no, - const unsigned int subface_no) + const unsigned int face_no, + const unsigned int subface_no) { typedef FEValuesBase FEVB; Assert (static_cast&>(*this->fe) == - static_cast&>(cell->get_dof_handler().get_fe()), - typename FEVB::ExcFEDontMatch()); + static_cast&>(cell->get_dof_handler().get_fe()), + typename FEVB::ExcFEDontMatch()); Assert (face_no < GeometryInfo::faces_per_cell, - ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); Assert (subface_no < cell->face(face_no)->number_of_children(), - ExcIndexRange (subface_no, 0, cell->face(face_no)->number_of_children())); + ExcIndexRange (subface_no, 0, cell->face(face_no)->number_of_children())); Assert (cell->has_children() == false, - ExcMessage ("You can't use subface data for cells that are " - "already refined. Iterate over their children " - "instead in these cases.")); - - // set new cell. auto_ptr will take - // care that old object gets - // destroyed and also that this - // object gets destroyed in the - // destruction of this class + ExcMessage ("You can't use subface data for cells that are " + "already refined. Iterate over their children " + "instead in these cases.")); + + // set new cell. auto_ptr will take + // care that old object gets + // destroyed and also that this + // object gets destroyed in the + // destruction of this class this->maybe_invalidate_previous_present_cell (cell); this->present_cell.reset (new typename FEValuesBase::template CellIterator::cell_iterator> (cell)); - // this was the part of the work - // that is dependent on the actual - // data type of the iterator. now - // pass on to the function doing - // the real work. + // this was the part of the work + // that is dependent on the actual + // data type of the iterator. now + // pass on to the function doing + // the real work. do_reinit (face_no, subface_no); } @@ -4177,28 +4177,28 @@ void FESubfaceValues::reinit (const typename MGDoFHandler void FESubfaceValues::reinit (const typename Triangulation::cell_iterator &cell, - const unsigned int face_no, - const unsigned int subface_no) + const unsigned int face_no, + const unsigned int subface_no) { Assert (face_no < GeometryInfo::faces_per_cell, - ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); + ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); Assert (subface_no < cell->face(face_no)->n_children(), - ExcIndexRange (subface_no, 0, cell->face(face_no)->n_children())); + ExcIndexRange (subface_no, 0, cell->face(face_no)->n_children())); - // set new cell. auto_ptr will take - // care that old object gets - // destroyed and also that this - // object gets destroyed in the - // destruction of this class + // set new cell. auto_ptr will take + // care that old object gets + // destroyed and also that this + // object gets destroyed in the + // destruction of this class this->maybe_invalidate_previous_present_cell (cell); this->present_cell.reset (new typename FEValuesBase::TriaCellIterator (cell)); - // this was the part of the work - // that is dependent on the actual - // data type of the iterator. now - // pass on to the function doing - // the real work. + // this was the part of the work + // that is dependent on the actual + // data type of the iterator. now + // pass on to the function doing + // the real work. do_reinit (face_no, subface_no); } @@ -4206,95 +4206,95 @@ void FESubfaceValues::reinit (const typename Triangulation void FESubfaceValues::do_reinit (const unsigned int face_no, - const unsigned int subface_no) + const unsigned int subface_no) { - // first of all, set the present_face_index - // (if available) + // first of all, set the present_face_index + // (if available) const typename Triangulation::cell_iterator cell=*this->present_cell; if (!cell->face(face_no)->has_children()) - // no subfaces at all, so set - // present_face_index to this face rather - // than any subface + // no subfaces at all, so set + // present_face_index to this face rather + // than any subface this->present_face_index=cell->face_index(face_no); else if (dim!=3) this->present_face_index=cell->face(face_no)->child_index(subface_no); else { - // this is the same logic we use in - // cell->neighbor_child_on_subface(). See - // there for an explanation of the - // different cases - unsigned int subface_index=numbers::invalid_unsigned_int; - switch (cell->subface_case(face_no)) - { - case internal::SubfaceCase<3>::case_x: - case internal::SubfaceCase<3>::case_y: - case internal::SubfaceCase<3>::case_xy: - subface_index=cell->face(face_no)->child_index(subface_no); - break; - case internal::SubfaceCase<3>::case_x1y2y: - case internal::SubfaceCase<3>::case_y1x2x: - subface_index=cell->face(face_no)->child(subface_no/2)->child_index(subface_no%2); - break; - case internal::SubfaceCase<3>::case_x1y: - case internal::SubfaceCase<3>::case_y1x: - switch (subface_no) - { - case 0: - case 1: - subface_index=cell->face(face_no)->child(0)->child_index(subface_no); - break; - case 2: - subface_index=cell->face(face_no)->child_index(1); - break; - default: - Assert(false, ExcInternalError()); - } - break; - case internal::SubfaceCase<3>::case_x2y: - case internal::SubfaceCase<3>::case_y2x: - switch (subface_no) - { - case 0: - subface_index=cell->face(face_no)->child_index(0); - break; - case 1: - case 2: - subface_index=cell->face(face_no)->child(1)->child_index(subface_no-1); - break; - default: - Assert(false, ExcInternalError()); - } - break; - default: - Assert(false, ExcInternalError()); - break; - } - Assert(subface_index!=numbers::invalid_unsigned_int, - ExcInternalError()); - this->present_face_index=subface_index; + // this is the same logic we use in + // cell->neighbor_child_on_subface(). See + // there for an explanation of the + // different cases + unsigned int subface_index=numbers::invalid_unsigned_int; + switch (cell->subface_case(face_no)) + { + case internal::SubfaceCase<3>::case_x: + case internal::SubfaceCase<3>::case_y: + case internal::SubfaceCase<3>::case_xy: + subface_index=cell->face(face_no)->child_index(subface_no); + break; + case internal::SubfaceCase<3>::case_x1y2y: + case internal::SubfaceCase<3>::case_y1x2x: + subface_index=cell->face(face_no)->child(subface_no/2)->child_index(subface_no%2); + break; + case internal::SubfaceCase<3>::case_x1y: + case internal::SubfaceCase<3>::case_y1x: + switch (subface_no) + { + case 0: + case 1: + subface_index=cell->face(face_no)->child(0)->child_index(subface_no); + break; + case 2: + subface_index=cell->face(face_no)->child_index(1); + break; + default: + Assert(false, ExcInternalError()); + } + break; + case internal::SubfaceCase<3>::case_x2y: + case internal::SubfaceCase<3>::case_y2x: + switch (subface_no) + { + case 0: + subface_index=cell->face(face_no)->child_index(0); + break; + case 1: + case 2: + subface_index=cell->face(face_no)->child(1)->child_index(subface_no-1); + break; + default: + Assert(false, ExcInternalError()); + } + break; + default: + Assert(false, ExcInternalError()); + break; + } + Assert(subface_index!=numbers::invalid_unsigned_int, + ExcInternalError()); + this->present_face_index=subface_index; } - // now ask the mapping and the finite element - // to do the actual work + // now ask the mapping and the finite element + // to do the actual work this->get_mapping().fill_fe_subface_values(*this->present_cell, - face_no, subface_no, - this->quadrature, - *this->mapping_data, - this->quadrature_points, - this->JxW_values, - this->boundary_forms, - this->normal_vectors); + face_no, subface_no, + this->quadrature, + *this->mapping_data, + this->quadrature_points, + this->JxW_values, + this->boundary_forms, + this->normal_vectors); this->get_fe().fill_fe_subface_values(this->get_mapping(), - *this->present_cell, - face_no, subface_no, - this->quadrature, - *this->mapping_data, - *this->fe_data, - *this); + *this->present_cell, + face_no, subface_no, + this->quadrature, + *this->mapping_data, + *this->fe_data, + *this); this->fe_data->clear_first_cell (); this->mapping_data->clear_first_cell (); diff --git a/deal.II/source/fe/mapping.cc b/deal.II/source/fe/mapping.cc index 090e885a5d..bb856c9fa2 100644 --- a/deal.II/source/fe/mapping.cc +++ b/deal.II/source/fe/mapping.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2005, 2006, 2009, 2011 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2005, 2006, 2009, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -90,10 +90,10 @@ Mapping::transform_contravariant ( template Mapping::InternalDataBase::InternalDataBase (): - update_flags(update_default), - update_once(update_default), - update_each(update_default), - first_cell(true) + update_flags(update_default), + update_once(update_default), + update_each(update_default), + first_cell(true) {} diff --git a/deal.II/source/fe/mapping_c1.cc b/deal.II/source/fe/mapping_c1.cc index 8154bbc0d8..ce28a22e19 100644 --- a/deal.II/source/fe/mapping_c1.cc +++ b/deal.II/source/fe/mapping_c1.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2005, 2006 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2005, 2006, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -24,8 +24,8 @@ DEAL_II_NAMESPACE_OPEN template MappingC1::MappingC1 () - : - MappingQ (3) + : + MappingQ (3) { Assert (dim > 1, ExcImpossibleInDim(dim)); } @@ -35,7 +35,7 @@ MappingC1::MappingC1 () template <> void MappingC1<1>::add_line_support_points (const Triangulation<1>::cell_iterator &, - std::vector > &) const + std::vector > &) const { const unsigned int dim = 1; Assert (dim > 1, ExcImpossibleInDim(dim)); @@ -46,139 +46,139 @@ MappingC1<1>::add_line_support_points (const Triangulation<1>::cell_iterator &, template <> void MappingC1<2>::add_line_support_points (const Triangulation<2>::cell_iterator &cell, - std::vector > &a) const + std::vector > &a) const { const unsigned int dim = 2; std::vector > line_points (2); - // loop over each of the lines, - // and if it is at the - // boundary, then first get the - // boundary description and - // second compute the points on - // it. if not at the boundary, - // get the respective points - // from another function + // loop over each of the lines, + // and if it is at the + // boundary, then first get the + // boundary description and + // second compute the points on + // it. if not at the boundary, + // get the respective points + // from another function for (unsigned int line_no=0; line_no::lines_per_cell; ++line_no) { const Triangulation::line_iterator line = cell->line(line_no); if (line->at_boundary()) - { - // first get the normal - // vectors at the two - // vertices of this line - // from the boundary - // description - const Boundary &boundary - = line->get_triangulation().get_boundary(line->boundary_indicator()); - - Boundary::FaceVertexNormals face_vertex_normals; - boundary.get_normals_at_vertices (line, face_vertex_normals); - - // then transform them into - // interpolation points for - // a cubic polynomial - // - // for this, note that if - // we describe the boundary - // curve as a polynomial in - // tangential coordinate - // @p{t=0..1} (along the - // line) and @p{s} in - // normal direction, then - // the cubic mapping is - // such that @p{s = a*t**3 - // + b*t**2 + c*t + d}, and - // we want to determine the - // interpolation points at - // @p{t=1/3} and - // @p{t=2/3}. Since at - // @p{t=0,1} we want a - // vertex which is actually - // at the boundary, we know - // that @p{d=0} and - // @p{a=-b-c}. As - // side-conditions, we want - // that the derivatives at - // @p{t=0} and @p{t=1}, - // i.e. at the vertices - // match those returned by - // the boundary. We then - // have that - // @p{s(1/3)=1/27(2b+8c)} - // and - // @p{s(2/3)=4/27b+10/27c}. - // - // The task is then first - // to determine the - // coefficients from the - // tangentials. for that, - // first rotate the - // tangents of @p{s(t)} - // into the global - // coordinate system. they - // are @p{A (1,c)} and @p{A - // (1,-b-2c)} with @p{A} the - // rotation matrix, since - // the tangentials in the - // coordinate system - // relative to the line are - // @p{(1,c)} and @p{(1,-b-2c)} - // at the two vertices, - // respectively. We then - // have to make sure by - // matching @p{b,c} that - // these tangentials are - // orthogonal to the normals - // returned by the boundary - // object - const Tensor<1,2> coordinate_vector = line->vertex(1) - line->vertex(0); - const double h = std::sqrt(coordinate_vector * coordinate_vector); - Tensor<1,2> coordinate_axis = coordinate_vector; - coordinate_axis /= h; - - const double alpha = std::atan2(coordinate_axis[1], coordinate_axis[0]); - const double c = -((face_vertex_normals[0][1] * std::sin(alpha) - +face_vertex_normals[0][0] * std::cos(alpha)) / - (face_vertex_normals[0][1] * std::cos(alpha) - -face_vertex_normals[0][0] * std::sin(alpha))); - const double b = ((face_vertex_normals[1][1] * std::sin(alpha) - +face_vertex_normals[1][0] * std::cos(alpha)) / - (face_vertex_normals[1][1] * std::cos(alpha) - -face_vertex_normals[1][0] * std::sin(alpha))) - -2*c; - - - // next evaluate the so - // determined cubic - // polynomial at the points - // 1/3 and 2/3, first in - // unit coordinates - const Point<2> new_unit_points[2] = { Point<2>(1./3., 1./27.*(2*b+8*c)), - Point<2>(2./3., 4./27.*b+10./27.*c) }; - // then transform these - // points to real - // coordinates by rotating, - // scaling and shifting - for (unsigned int i=0; i<2; ++i) - { - Point<2> real_point (std::cos(alpha) * new_unit_points[i][0] - - std::sin(alpha) * new_unit_points[i][1], - std::sin(alpha) * new_unit_points[i][0] - + std::cos(alpha) * new_unit_points[i][1]); - real_point *= h; - real_point += line->vertex(0); - a.push_back (real_point); - }; - } + { + // first get the normal + // vectors at the two + // vertices of this line + // from the boundary + // description + const Boundary &boundary + = line->get_triangulation().get_boundary(line->boundary_indicator()); + + Boundary::FaceVertexNormals face_vertex_normals; + boundary.get_normals_at_vertices (line, face_vertex_normals); + + // then transform them into + // interpolation points for + // a cubic polynomial + // + // for this, note that if + // we describe the boundary + // curve as a polynomial in + // tangential coordinate + // @p{t=0..1} (along the + // line) and @p{s} in + // normal direction, then + // the cubic mapping is + // such that @p{s = a*t**3 + // + b*t**2 + c*t + d}, and + // we want to determine the + // interpolation points at + // @p{t=1/3} and + // @p{t=2/3}. Since at + // @p{t=0,1} we want a + // vertex which is actually + // at the boundary, we know + // that @p{d=0} and + // @p{a=-b-c}. As + // side-conditions, we want + // that the derivatives at + // @p{t=0} and @p{t=1}, + // i.e. at the vertices + // match those returned by + // the boundary. We then + // have that + // @p{s(1/3)=1/27(2b+8c)} + // and + // @p{s(2/3)=4/27b+10/27c}. + // + // The task is then first + // to determine the + // coefficients from the + // tangentials. for that, + // first rotate the + // tangents of @p{s(t)} + // into the global + // coordinate system. they + // are @p{A (1,c)} and @p{A + // (1,-b-2c)} with @p{A} the + // rotation matrix, since + // the tangentials in the + // coordinate system + // relative to the line are + // @p{(1,c)} and @p{(1,-b-2c)} + // at the two vertices, + // respectively. We then + // have to make sure by + // matching @p{b,c} that + // these tangentials are + // orthogonal to the normals + // returned by the boundary + // object + const Tensor<1,2> coordinate_vector = line->vertex(1) - line->vertex(0); + const double h = std::sqrt(coordinate_vector * coordinate_vector); + Tensor<1,2> coordinate_axis = coordinate_vector; + coordinate_axis /= h; + + const double alpha = std::atan2(coordinate_axis[1], coordinate_axis[0]); + const double c = -((face_vertex_normals[0][1] * std::sin(alpha) + +face_vertex_normals[0][0] * std::cos(alpha)) / + (face_vertex_normals[0][1] * std::cos(alpha) + -face_vertex_normals[0][0] * std::sin(alpha))); + const double b = ((face_vertex_normals[1][1] * std::sin(alpha) + +face_vertex_normals[1][0] * std::cos(alpha)) / + (face_vertex_normals[1][1] * std::cos(alpha) + -face_vertex_normals[1][0] * std::sin(alpha))) + -2*c; + + + // next evaluate the so + // determined cubic + // polynomial at the points + // 1/3 and 2/3, first in + // unit coordinates + const Point<2> new_unit_points[2] = { Point<2>(1./3., 1./27.*(2*b+8*c)), + Point<2>(2./3., 4./27.*b+10./27.*c) }; + // then transform these + // points to real + // coordinates by rotating, + // scaling and shifting + for (unsigned int i=0; i<2; ++i) + { + Point<2> real_point (std::cos(alpha) * new_unit_points[i][0] + - std::sin(alpha) * new_unit_points[i][1], + std::sin(alpha) * new_unit_points[i][0] + + std::cos(alpha) * new_unit_points[i][1]); + real_point *= h; + real_point += line->vertex(0); + a.push_back (real_point); + }; + } else - // not at boundary - { - static const StraightBoundary straight_boundary; - straight_boundary.get_intermediate_points_on_line (line, line_points); - a.insert (a.end(), line_points.begin(), line_points.end()); - }; + // not at boundary + { + static const StraightBoundary straight_boundary; + straight_boundary.get_intermediate_points_on_line (line, line_points); + a.insert (a.end(), line_points.begin(), line_points.end()); + }; }; } @@ -187,7 +187,7 @@ MappingC1<2>::add_line_support_points (const Triangulation<2>::cell_iterator &ce template void MappingC1::add_line_support_points (const typename Triangulation::cell_iterator &, - std::vector > &) const + std::vector > &) const { Assert (false, ExcNotImplemented()); } @@ -197,7 +197,7 @@ MappingC1::add_line_support_points (const typename Triangulation void MappingC1<1>::add_quad_support_points (const Triangulation<1>::cell_iterator &, - std::vector > &) const + std::vector > &) const { const unsigned int dim = 1; Assert (dim > 2, ExcImpossibleInDim(dim)); @@ -208,7 +208,7 @@ MappingC1<1>::add_quad_support_points (const Triangulation<1>::cell_iterator &, template <> void MappingC1<2>::add_quad_support_points (const Triangulation<2>::cell_iterator &, - std::vector > &) const + std::vector > &) const { const unsigned int dim = 2; Assert (dim > 2, ExcImpossibleInDim(dim)); @@ -219,7 +219,7 @@ MappingC1<2>::add_quad_support_points (const Triangulation<2>::cell_iterator &, template void MappingC1::add_quad_support_points (const typename Triangulation::cell_iterator &, - std::vector > &) const + std::vector > &) const { Assert (false, ExcNotImplemented()); } diff --git a/deal.II/source/fe/mapping_cartesian.cc b/deal.II/source/fe/mapping_cartesian.cc index 62e5be0e6e..5e3a1122f7 100644 --- a/deal.II/source/fe/mapping_cartesian.cc +++ b/deal.II/source/fe/mapping_cartesian.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -36,8 +36,8 @@ const unsigned int MappingCartesian::invalid_face_number; template MappingCartesian::InternalData::InternalData (const Quadrature& q) - : - quadrature_points (q.get_points ()) + : + quadrature_points (q.get_points ()) {} @@ -47,8 +47,8 @@ std::size_t MappingCartesian::InternalData::memory_consumption () const { return (Mapping::InternalDataBase::memory_consumption() + - MemoryConsumption::memory_consumption (length) + - MemoryConsumption::memory_consumption (quadrature_points)); + MemoryConsumption::memory_consumption (length) + + MemoryConsumption::memory_consumption (quadrature_points)); } @@ -79,7 +79,7 @@ MappingCartesian::update_each (const UpdateFlags in) const template typename Mapping::InternalDataBase * MappingCartesian::get_data (const UpdateFlags update_flags, - const Quadrature &q) const + const Quadrature &q) const { InternalData* data = new InternalData (q); @@ -95,7 +95,7 @@ MappingCartesian::get_data (const UpdateFlags update_flags, template typename Mapping::InternalDataBase * MappingCartesian::get_face_data (const UpdateFlags update_flags, - const Quadrature& quadrature) const + const Quadrature& quadrature) const { InternalData* data = new InternalData (QProjector::project_to_all_faces(quadrature)); @@ -112,7 +112,7 @@ MappingCartesian::get_face_data (const UpdateFlags update_flags, template typename Mapping::InternalDataBase * MappingCartesian::get_subface_data (const UpdateFlags update_flags, - const Quadrature &quadrature) const + const Quadrature &quadrature) const { InternalData* data = new InternalData (QProjector::project_to_all_subfaces(quadrature)); @@ -130,33 +130,33 @@ MappingCartesian::get_subface_data (const UpdateFlags update_flag template void MappingCartesian::compute_fill (const typename Triangulation::cell_iterator &cell, - const unsigned int face_no, - const unsigned int sub_no, - const CellSimilarity::Similarity cell_similarity, - InternalData &data, - std::vector > &quadrature_points, - std::vector > &normal_vectors) const + const unsigned int face_no, + const unsigned int sub_no, + const CellSimilarity::Similarity cell_similarity, + InternalData &data, + std::vector > &quadrature_points, + std::vector > &normal_vectors) const { const UpdateFlags update_flags(data.current_update_flags()); // some more sanity checks if (face_no != invalid_face_number) { - // Add 1 on both sides of - // assertion to avoid compiler - // warning about testing - // unsigned int < 0 in 1d. + // Add 1 on both sides of + // assertion to avoid compiler + // warning about testing + // unsigned int < 0 in 1d. Assert (face_no+1 < GeometryInfo::faces_per_cell+1, - ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); - - // We would like to check for - // sub_no < cell->face(face_no)->n_children(), - // but unfortunately the current - // function is also called for - // faces without children (see - // tests/fe/mapping.cc). Therefore, - // we must use following workaround - // of two separate assertions + ExcIndexRange (face_no, 0, GeometryInfo::faces_per_cell)); + + // We would like to check for + // sub_no < cell->face(face_no)->n_children(), + // but unfortunately the current + // function is also called for + // faces without children (see + // tests/fe/mapping.cc). Therefore, + // we must use following workaround + // of two separate assertions Assert ((sub_no == invalid_face_number) || cell->face(face_no)->has_children() || (sub_no+1 < GeometryInfo::max_children_per_face+1), @@ -168,89 +168,89 @@ MappingCartesian::compute_fill (const typename Triangulationface(face_no)->n_children())); } else - // invalid face number, so - // subface should be invalid as - // well + // invalid face number, so + // subface should be invalid as + // well Assert (sub_no == invalid_face_number, ExcInternalError()); - // let @p{start} be the origin of a - // local coordinate system. it is - // chosen as the (lower) left - // vertex + // let @p{start} be the origin of a + // local coordinate system. it is + // chosen as the (lower) left + // vertex const Point start = cell->vertex(0); - // Compute start point and sizes - // along axes. Strange vertex - // numbering makes this complicated - // again. + // Compute start point and sizes + // along axes. Strange vertex + // numbering makes this complicated + // again. if (cell_similarity != CellSimilarity::translation) { switch (dim) - { - case 1: - data.length[0] = cell->vertex(1)(0) - start(0); - break; - case 2: - data.length[0] = cell->vertex(1)(0) - start(0); - data.length[1] = cell->vertex(2)(1) - start(1); - break; - case 3: - data.length[0] = cell->vertex(1)(0) - start(0); - data.length[1] = cell->vertex(2)(1) - start(1); - data.length[2] = cell->vertex(4)(2) - start(2); - break; - default: - Assert(false, ExcNotImplemented()); - } + { + case 1: + data.length[0] = cell->vertex(1)(0) - start(0); + break; + case 2: + data.length[0] = cell->vertex(1)(0) - start(0); + data.length[1] = cell->vertex(2)(1) - start(1); + break; + case 3: + data.length[0] = cell->vertex(1)(0) - start(0); + data.length[1] = cell->vertex(2)(1) - start(1); + data.length[2] = cell->vertex(4)(2) - start(2); + break; + default: + Assert(false, ExcNotImplemented()); + } } - // transform quadrature point. this - // is obtained simply by scaling - // unit coordinates with lengths in - // each direction + // transform quadrature point. this + // is obtained simply by scaling + // unit coordinates with lengths in + // each direction if (update_flags & update_quadrature_points) { const typename QProjector::DataSetDescriptor offset - = (face_no == invalid_face_number - ? - QProjector::DataSetDescriptor::cell() - : - (sub_no == invalid_face_number - ? - // called from FEFaceValues - QProjector::DataSetDescriptor::face (face_no, - cell->face_orientation(face_no), - cell->face_flip(face_no), - cell->face_rotation(face_no), - quadrature_points.size()) - : - // called from FESubfaceValues - QProjector::DataSetDescriptor::subface (face_no, sub_no, - cell->face_orientation(face_no), - cell->face_flip(face_no), - cell->face_rotation(face_no), - quadrature_points.size(), - cell->subface_case(face_no)) - )); + = (face_no == invalid_face_number + ? + QProjector::DataSetDescriptor::cell() + : + (sub_no == invalid_face_number + ? + // called from FEFaceValues + QProjector::DataSetDescriptor::face (face_no, + cell->face_orientation(face_no), + cell->face_flip(face_no), + cell->face_rotation(face_no), + quadrature_points.size()) + : + // called from FESubfaceValues + QProjector::DataSetDescriptor::subface (face_no, sub_no, + cell->face_orientation(face_no), + cell->face_flip(face_no), + cell->face_rotation(face_no), + quadrature_points.size(), + cell->subface_case(face_no)) + )); for (unsigned int i=0; i::faces_per_cell, @@ -258,8 +258,8 @@ MappingCartesian::compute_fill (const typename Triangulation normals[GeometryInfo<1>::faces_per_cell] = { Point(-1.), @@ -269,7 +269,7 @@ MappingCartesian::compute_fill (const typename Triangulation @@ -313,73 +313,73 @@ void MappingCartesian:: fill_fe_values (const typename Triangulation::cell_iterator& cell, const Quadrature& q, - typename Mapping::InternalDataBase& mapping_data, + typename Mapping::InternalDataBase& mapping_data, std::vector >& quadrature_points, std::vector& JxW_values, - std::vector< DerivativeForm<1,dim,spacedim> > & jacobians, - std::vector > &jacobian_grads, - std::vector > &inverse_jacobians, - std::vector > &, - CellSimilarity::Similarity& cell_similarity) const + std::vector< DerivativeForm<1,dim,spacedim> > & jacobians, + std::vector > &jacobian_grads, + std::vector > &inverse_jacobians, + std::vector > &, + CellSimilarity::Similarity& cell_similarity) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); InternalData &data = static_cast (mapping_data); std::vector > dummy; compute_fill (cell, invalid_face_number, invalid_face_number, cell_similarity, - data, - quadrature_points, - dummy); - - // compute Jacobian - // determinant. all values are - // equal and are the product of the - // local lengths in each coordinate - // direction + data, + quadrature_points, + dummy); + + // compute Jacobian + // determinant. all values are + // equal and are the product of the + // local lengths in each coordinate + // direction if (data.current_update_flags() & (update_JxW_values | update_volume_elements)) if (cell_similarity != CellSimilarity::translation) { - double J = data.length[0]; - for (unsigned int d=1;d(); - for (unsigned int j=0; j(); + for (unsigned int j=0; j(); - // "compute" inverse Jacobian at the - // quadrature points, which are all - // the same + jacobian_grads[i]=DerivativeForm<2,dim,spacedim>(); + // "compute" inverse Jacobian at the + // quadrature points, which are all + // the same if (data.current_update_flags() & update_inverse_jacobians) if (cell_similarity != CellSimilarity::translation) for (unsigned int i=0; i(); - for (unsigned int j=0; j(); + for (unsigned int j=0; j::fill_fe_face_values ( std::vector > &boundary_forms, std::vector > &normal_vectors) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); InternalData &data = static_cast (mapping_data); compute_fill (cell, face_no, invalid_face_number, - CellSimilarity::none, - data, - quadrature_points, - normal_vectors); - - // first compute Jacobian - // determinant, which is simply the - // product of the local lengths - // since the jacobian is diagonal + CellSimilarity::none, + data, + quadrature_points, + normal_vectors); + + // first compute Jacobian + // determinant, which is simply the + // product of the local lengths + // since the jacobian is diagonal double J = 1.; for (unsigned int d=0; d::unit_normal_direction[face_no]) @@ -502,7 +502,7 @@ MappingCartesian::fill_fe_face_values ( { J = data.length[0]; for (unsigned int d=1;d::fill_fe_subface_values ( std::vector > &boundary_forms, std::vector > &normal_vectors) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); InternalData &data = static_cast (mapping_data); compute_fill (cell, face_no, sub_no, CellSimilarity::none, - data, - quadrature_points, - normal_vectors); - - // first compute Jacobian - // determinant, which is simply the - // product of the local lengths - // since the jacobian is diagonal + data, + quadrature_points, + normal_vectors); + + // first compute Jacobian + // determinant, which is simply the + // product of the local lengths + // since the jacobian is diagonal double J = 1.; for (unsigned int d=0; d::unit_normal_direction[face_no]) @@ -545,22 +545,22 @@ MappingCartesian::fill_fe_subface_values ( if (data.current_update_flags() & update_JxW_values) { - // Here, - // cell->face(face_no)->n_children() - // would be the right choice, - // but unfortunately the - // current function is also - // called for faces without - // children (see - // tests/fe/mapping.cc). Add - // following switch to avoid - // diffs in tests/fe/mapping.OK + // Here, + // cell->face(face_no)->n_children() + // would be the right choice, + // but unfortunately the + // current function is also + // called for faces without + // children (see + // tests/fe/mapping.cc). Add + // following switch to avoid + // diffs in tests/fe/mapping.OK const unsigned int n_subfaces= - cell->face(face_no)->has_children() ? - cell->face(face_no)->n_children() : - GeometryInfo::max_children_per_face; + cell->face(face_no)->has_children() ? + cell->face(face_no)->n_children() : + GeometryInfo::max_children_per_face; for (unsigned int i=0; i::fill_fe_subface_values ( { J = data.length[0]; for (unsigned int d=1;d::transform ( { AssertDimension (input.size(), output.size()); Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); const InternalData &data = static_cast (mapping_data); switch (mapping_type) { case mapping_covariant: { - Assert (data.update_flags & update_covariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField()); + Assert (data.update_flags & update_covariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField()); - for (unsigned int i=0; i::ExcAccessToUninitializedField()); + Assert (data.update_flags & update_contravariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField()); - for (unsigned int i=0; i::ExcAccessToUninitializedField()); - Assert (data.update_flags & update_volume_elements, - typename FEValuesBase::ExcAccessToUninitializedField()); - - for (unsigned int i=0; i::ExcAccessToUninitializedField()); + Assert (data.update_flags & update_volume_elements, + typename FEValuesBase::ExcAccessToUninitializedField()); + + for (unsigned int i=0; i::transform ( { AssertDimension (input.size(), output.size()); Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); const InternalData &data = static_cast(mapping_data); switch (mapping_type) { case mapping_covariant: { - Assert (data.update_flags & update_covariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField()); - - for (unsigned int i=0; i::ExcAccessToUninitializedField()); + + for (unsigned int i=0; i::ExcAccessToUninitializedField()); - - for (unsigned int i=0; i::ExcAccessToUninitializedField()); + + for (unsigned int i=0; i::ExcAccessToUninitializedField()); - - for (unsigned int i=0; i::ExcAccessToUninitializedField()); + + for (unsigned int i=0; i::ExcAccessToUninitializedField()); - - for (unsigned int i=0; i::ExcAccessToUninitializedField()); + + for (unsigned int i=0; i::ExcAccessToUninitializedField()); - Assert (data.update_flags & update_volume_elements, - typename FEValuesBase::ExcAccessToUninitializedField()); - - for (unsigned int i=0; i::ExcAccessToUninitializedField()); + Assert (data.update_flags & update_volume_elements, + typename FEValuesBase::ExcAccessToUninitializedField()); + + for (unsigned int i=0; i::transform ( AssertDimension (input.size(), output.size()); Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); const InternalData &data = static_cast(mapping_data); switch (mapping_type) { case mapping_piola_gradient: { - Assert (data.update_flags & update_contravariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField()); - Assert (data.update_flags & update_volume_elements, - typename FEValuesBase::ExcAccessToUninitializedField()); - - for (unsigned int i=0; i::ExcAccessToUninitializedField()); + Assert (data.update_flags & update_volume_elements, + typename FEValuesBase::ExcAccessToUninitializedField()); + + for (unsigned int i=0; i::transform_unit_to_real_cell ( switch (dim) { case 1: - length[0] = cell->vertex(1)(0) - start(0); - break; + length[0] = cell->vertex(1)(0) - start(0); + break; case 2: - length[0] = cell->vertex(1)(0) - start(0); - length[1] = cell->vertex(2)(1) - start(1); - break; + length[0] = cell->vertex(1)(0) - start(0); + length[1] = cell->vertex(2)(1) - start(1); + break; case 3: - length[0] = cell->vertex(1)(0) - start(0); - length[1] = cell->vertex(2)(1) - start(1); - length[2] = cell->vertex(4)(2) - start(2); - break; + length[0] = cell->vertex(1)(0) - start(0); + length[1] = cell->vertex(2)(1) - start(1); + length[2] = cell->vertex(4)(2) - start(2); + break; default: - Assert(false, ExcNotImplemented()); + Assert(false, ExcNotImplemented()); } Point p_real = cell->vertex(0); @@ -809,19 +809,19 @@ MappingCartesian::transform_real_to_unit_cell ( switch (dim) { case 1: - real(0) /= cell->vertex(1)(0) - start(0); - break; + real(0) /= cell->vertex(1)(0) - start(0); + break; case 2: - real(0) /= cell->vertex(1)(0) - start(0); - real(1) /= cell->vertex(2)(1) - start(1); - break; + real(0) /= cell->vertex(1)(0) - start(0); + real(1) /= cell->vertex(2)(1) - start(1); + break; case 3: - real(0) /= cell->vertex(1)(0) - start(0); - real(1) /= cell->vertex(2)(1) - start(1); - real(2) /= cell->vertex(4)(2) - start(2); - break; + real(0) /= cell->vertex(1)(0) - start(0); + real(1) /= cell->vertex(2)(1) - start(1); + real(2) /= cell->vertex(4)(2) - start(2); + break; default: - Assert(false, ExcNotImplemented()); + Assert(false, ExcNotImplemented()); } return real; } diff --git a/deal.II/source/fe/mapping_q.cc b/deal.II/source/fe/mapping_q.cc index c36b40c1b8..73817630e1 100644 --- a/deal.II/source/fe/mapping_q.cc +++ b/deal.II/source/fe/mapping_q.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -34,10 +34,10 @@ DEAL_II_NAMESPACE_OPEN template MappingQ::InternalData::InternalData (const unsigned int n_shape_functions) - : - MappingQ1::InternalData(n_shape_functions), + : + MappingQ1::InternalData(n_shape_functions), use_mapping_q1_on_current_cell(false), - mapping_q1_data(1 << dim) + mapping_q1_data(1 << dim) { this->is_mapping_q1_data=false; } @@ -49,9 +49,9 @@ std::size_t MappingQ::InternalData::memory_consumption () const { return (MappingQ1::InternalData::memory_consumption () + - MemoryConsumption::memory_consumption (unit_normals) + - MemoryConsumption::memory_consumption (use_mapping_q1_on_current_cell) + - MemoryConsumption::memory_consumption (mapping_q1_data)); + MemoryConsumption::memory_consumption (unit_normals) + + MemoryConsumption::memory_consumption (use_mapping_q1_on_current_cell) + + MemoryConsumption::memory_consumption (mapping_q1_data)); } @@ -60,30 +60,30 @@ MappingQ::InternalData::memory_consumption () const // cells are scaled linearly. Unless codimension is equal to two template<> MappingQ<1>::MappingQ (const unsigned int, - const bool /*use_mapping_q_on_all_cells*/) - : - degree(1), - n_inner(0), - n_outer(0), - tensor_pols(0), - n_shape_functions(2), - renumber(0), - use_mapping_q_on_all_cells (false), - feq(degree) + const bool /*use_mapping_q_on_all_cells*/) + : + degree(1), + n_inner(0), + n_outer(0), + tensor_pols(0), + n_shape_functions(2), + renumber(0), + use_mapping_q_on_all_cells (false), + feq(degree) {} template<> MappingQ<1>::MappingQ (const MappingQ<1> &m): - MappingQ1<1> (), - degree(1), - n_inner(0), - n_outer(0), - tensor_pols(0), - n_shape_functions(2), - renumber(0), - use_mapping_q_on_all_cells (m.use_mapping_q_on_all_cells), - feq(degree) + MappingQ1<1> (), + degree(1), + n_inner(0), + n_outer(0), + tensor_pols(0), + n_shape_functions(2), + renumber(0), + use_mapping_q_on_all_cells (m.use_mapping_q_on_all_cells), + feq(degree) {} template<> @@ -110,60 +110,60 @@ namespace template MappingQ::MappingQ (const unsigned int p, - const bool use_mapping_q_on_all_cells) + const bool use_mapping_q_on_all_cells) : - degree(p), - n_inner(Utilities::fixed_power(degree-1)), - n_outer((dim==1) ? 2 : - ((dim==2) ? - 4+4*(degree-1) : - 8+12*(degree-1)+6*(degree-1)*(degree-1))), - tensor_pols(0), - n_shape_functions(Utilities::fixed_power(degree+1)), - renumber(FETools:: - lexicographic_to_hierarchic_numbering ( - FiniteElementData (get_dpo_vector(degree), 1, - degree))), - use_mapping_q_on_all_cells (use_mapping_q_on_all_cells - || (dim != spacedim)), - feq(degree) + degree(p), + n_inner(Utilities::fixed_power(degree-1)), + n_outer((dim==1) ? 2 : + ((dim==2) ? + 4+4*(degree-1) : + 8+12*(degree-1)+6*(degree-1)*(degree-1))), + tensor_pols(0), + n_shape_functions(Utilities::fixed_power(degree+1)), + renumber(FETools:: + lexicographic_to_hierarchic_numbering ( + FiniteElementData (get_dpo_vector(degree), 1, + degree))), + use_mapping_q_on_all_cells (use_mapping_q_on_all_cells + || (dim != spacedim)), + feq(degree) { - // Construct the tensor product - // polynomials used as shape - // functions for the Qp mapping of - // cells at the boundary. + // Construct the tensor product + // polynomials used as shape + // functions for the Qp mapping of + // cells at the boundary. std::vector v; for (unsigned int i=0; i<=degree; ++i) v.push_back(Polynomials::LagrangeEquidistant(degree,i)); tensor_pols = new TensorProductPolynomials (v); Assert (n_shape_functions==tensor_pols->n(), - ExcInternalError()); + ExcInternalError()); Assert(n_inner+n_outer==n_shape_functions, ExcInternalError()); - // build laplace_on_quad_vector + // build laplace_on_quad_vector if (degree>1) { if (dim >= 2) - set_laplace_on_quad_vector(laplace_on_quad_vector); + set_laplace_on_quad_vector(laplace_on_quad_vector); if (dim >= 3) - set_laplace_on_hex_vector(laplace_on_hex_vector); + set_laplace_on_hex_vector(laplace_on_hex_vector); } } template MappingQ::MappingQ (const MappingQ &mapping) - : - MappingQ1(), - degree(mapping.degree), - n_inner(mapping.n_inner), - n_outer(mapping.n_outer), - tensor_pols(0), - n_shape_functions(mapping.n_shape_functions), - renumber(mapping.renumber), - use_mapping_q_on_all_cells (mapping.use_mapping_q_on_all_cells), - feq(degree) + : + MappingQ1(), + degree(mapping.degree), + n_inner(mapping.n_inner), + n_outer(mapping.n_outer), + tensor_pols(0), + n_shape_functions(mapping.n_shape_functions), + renumber(mapping.renumber), + use_mapping_q_on_all_cells (mapping.use_mapping_q_on_all_cells), + feq(degree) { tensor_pols=new TensorProductPolynomials (*mapping.tensor_pols); laplace_on_quad_vector=mapping.laplace_on_quad_vector; @@ -182,7 +182,7 @@ MappingQ::~MappingQ () template<> void MappingQ<1>::compute_shapes_virtual (const std::vector > &unit_points, - MappingQ1<1>::InternalData &data) const + MappingQ1<1>::InternalData &data) const { MappingQ1<1>::compute_shapes_virtual(unit_points, data); } @@ -192,7 +192,7 @@ MappingQ<1>::compute_shapes_virtual (const std::vector > &unit_points, template void MappingQ::compute_shapes_virtual (const std::vector > &unit_points, - typename MappingQ1::InternalData &data) const + typename MappingQ1::InternalData &data) const { const unsigned int n_points=unit_points.size(); std::vector values; @@ -200,22 +200,22 @@ MappingQ::compute_shapes_virtual (const std::vector > & if (data.shape_values.size()!=0) { Assert(data.shape_values.size()==n_shape_functions*n_points, - ExcInternalError()); + ExcInternalError()); values.resize(n_shape_functions); } if (data.shape_derivatives.size()!=0) { Assert(data.shape_derivatives.size()==n_shape_functions*n_points, - ExcInternalError()); + ExcInternalError()); grads.resize(n_shape_functions); } -// // dummy variable of size 0 +// // dummy variable of size 0 std::vector > grad2; if (data.shape_second_derivatives.size()!=0) { Assert(data.shape_second_derivatives.size()==n_shape_functions*n_points, - ExcInternalError()); + ExcInternalError()); grad2.resize(n_shape_functions); } @@ -223,19 +223,19 @@ MappingQ::compute_shapes_virtual (const std::vector > & if (data.shape_values.size()!=0 || data.shape_derivatives.size()!=0) for (unsigned int point=0; pointcompute(unit_points[point], values, grads, grad2); + tensor_pols->compute(unit_points[point], values, grads, grad2); - if (data.shape_values.size()!=0) - for (unsigned int i=0; i::compute_shapes_virtual (const std::vector > & template typename Mapping::InternalDataBase * MappingQ::get_data (const UpdateFlags update_flags, - const Quadrature &quadrature) const + const Quadrature &quadrature) const { InternalData *data = new InternalData(n_shape_functions); this->compute_data (update_flags, quadrature, @@ -260,7 +260,7 @@ MappingQ::get_data (const UpdateFlags update_flags, template typename Mapping::InternalDataBase * MappingQ::get_face_data (const UpdateFlags update_flags, - const Quadrature& quadrature) const + const Quadrature& quadrature) const { InternalData *data = new InternalData(n_shape_functions); const Quadrature q (QProjector::project_to_all_faces(quadrature)); @@ -278,7 +278,7 @@ MappingQ::get_face_data (const UpdateFlags update_flags, template typename Mapping::InternalDataBase * MappingQ::get_subface_data (const UpdateFlags update_flags, - const Quadrature& quadrature) const + const Quadrature& quadrature) const { InternalData *data = new InternalData(n_shape_functions); const Quadrature q (QProjector::project_to_all_subfaces(quadrature)); @@ -310,35 +310,35 @@ MappingQ::fill_fe_values ( std::vector > &normal_vectors, CellSimilarity::Similarity &cell_similarity) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); InternalData &data = static_cast (mapping_data); - // check whether this cell needs - // the full mapping or can be - // treated by a reduced Q1 mapping, - // e.g. if the cell is in the - // interior of the domain + // check whether this cell needs + // the full mapping or can be + // treated by a reduced Q1 mapping, + // e.g. if the cell is in the + // interior of the domain data.use_mapping_q1_on_current_cell = !(use_mapping_q_on_all_cells - || cell->has_boundary_lines()); - - // depending on this result, use this or - // the other data object for the - // mapping. furthermore, we need to - // ensure that the flag indicating - // whether we can use some similarity has - // to be modified - for a general - // MappingQ, the data needs to be - // recomputed anyway since then the - // mapping changes the data. this needs - // to be known also for later operations, - // so modify the variable here. this also - // affects the calculation of the next - // cell -- if we use Q1 data on the next - // cell, the data will still be invalid. + || cell->has_boundary_lines()); + + // depending on this result, use this or + // the other data object for the + // mapping. furthermore, we need to + // ensure that the flag indicating + // whether we can use some similarity has + // to be modified - for a general + // MappingQ, the data needs to be + // recomputed anyway since then the + // mapping changes the data. this needs + // to be known also for later operations, + // so modify the variable here. this also + // affects the calculation of the next + // cell -- if we use Q1 data on the next + // cell, the data will still be invalid. typename MappingQ1::InternalData *p_data=0; if (data.use_mapping_q1_on_current_cell) p_data=&data.mapping_q1_data; @@ -346,13 +346,13 @@ MappingQ::fill_fe_values ( { p_data=&data; if (get_degree() > 1) - cell_similarity = CellSimilarity::invalid_next_cell; + cell_similarity = CellSimilarity::invalid_next_cell; } MappingQ1::fill_fe_values(cell, q, *p_data, - quadrature_points, JxW_values, - jacobians, jacobian_grads, inverse_jacobians, - normal_vectors, cell_similarity); + quadrature_points, JxW_values, + jacobians, jacobian_grads, inverse_jacobians, + normal_vectors, cell_similarity); } @@ -370,34 +370,34 @@ MappingQ::fill_fe_face_values ( std::vector > &exterior_forms, std::vector > &normal_vectors) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); InternalData &data = static_cast (mapping_data); - // check whether this cell needs - // the full mapping or can be - // treated by a reduced Q1 mapping, - // e.g. if the cell is entirely in - // the interior of the domain. note - // that it is not sufficient to ask - // whether the present _face_ is in - // the interior, as the mapping on - // the face depends on the mapping - // of the cell, which in turn - // depends on the fact whether - // _any_ of the faces of this cell - // is at the boundary, not only the - // present face + // check whether this cell needs + // the full mapping or can be + // treated by a reduced Q1 mapping, + // e.g. if the cell is entirely in + // the interior of the domain. note + // that it is not sufficient to ask + // whether the present _face_ is in + // the interior, as the mapping on + // the face depends on the mapping + // of the cell, which in turn + // depends on the fact whether + // _any_ of the faces of this cell + // is at the boundary, not only the + // present face data.use_mapping_q1_on_current_cell=!(use_mapping_q_on_all_cells - || cell->has_boundary_lines()); + || cell->has_boundary_lines()); - // depending on this result, use - // this or the other data object - // for the mapping + // depending on this result, use + // this or the other data object + // for the mapping typename MappingQ1::InternalData *p_data=0; if (data.use_mapping_q1_on_current_cell) p_data=&data.mapping_q1_data; @@ -409,9 +409,9 @@ MappingQ::fill_fe_face_values ( n_q_points, QProjector::DataSetDescriptor:: face (face_no, - cell->face_orientation(face_no), - cell->face_flip(face_no), - cell->face_rotation(face_no), + cell->face_orientation(face_no), + cell->face_flip(face_no), + cell->face_rotation(face_no), n_q_points), q.get_weights(), *p_data, @@ -423,43 +423,43 @@ MappingQ::fill_fe_face_values ( template void MappingQ::fill_fe_subface_values (const typename Triangulation::cell_iterator &cell, - const unsigned int face_no, - const unsigned int sub_no, - const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, - std::vector > &quadrature_points, - std::vector &JxW_values, - std::vector > &exterior_forms, - std::vector > &normal_vectors) const + const unsigned int face_no, + const unsigned int sub_no, + const Quadrature &q, + typename Mapping::InternalDataBase &mapping_data, + std::vector > &quadrature_points, + std::vector &JxW_values, + std::vector > &exterior_forms, + std::vector > &normal_vectors) const { - // convert data object to internal - // data for this class. fails with - // an exception if that is not - // possible + // convert data object to internal + // data for this class. fails with + // an exception if that is not + // possible Assert (dynamic_cast (&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); InternalData &data = static_cast (mapping_data); - // check whether this cell needs - // the full mapping or can be - // treated by a reduced Q1 mapping, - // e.g. if the cell is entirely in - // the interior of the domain. note - // that it is not sufficient to ask - // whether the present _face_ is in - // the interior, as the mapping on - // the face depends on the mapping - // of the cell, which in turn - // depends on the fact whether - // _any_ of the faces of this cell - // is at the boundary, not only the - // present face + // check whether this cell needs + // the full mapping or can be + // treated by a reduced Q1 mapping, + // e.g. if the cell is entirely in + // the interior of the domain. note + // that it is not sufficient to ask + // whether the present _face_ is in + // the interior, as the mapping on + // the face depends on the mapping + // of the cell, which in turn + // depends on the fact whether + // _any_ of the faces of this cell + // is at the boundary, not only the + // present face data.use_mapping_q1_on_current_cell=!(use_mapping_q_on_all_cells - || cell->has_boundary_lines()); + || cell->has_boundary_lines()); - // depending on this result, use - // this or the other data object - // for the mapping + // depending on this result, use + // this or the other data object + // for the mapping typename MappingQ1::InternalData *p_data=0; if (data.use_mapping_q1_on_current_cell) p_data=&data.mapping_q1_data; @@ -471,11 +471,11 @@ MappingQ::fill_fe_subface_values (const typename Triangulation::DataSetDescriptor:: subface (face_no, sub_no, - cell->face_orientation(face_no), - cell->face_flip(face_no), - cell->face_rotation(face_no), - n_q_points, - cell->subface_case(face_no)), + cell->face_orientation(face_no), + cell->face_flip(face_no), + cell->face_rotation(face_no), + n_q_points, + cell->subface_case(face_no)), q.get_weights(), *p_data, quadrature_points, JxW_values, @@ -501,10 +501,10 @@ MappingQ::set_laplace_on_quad_vector(Table<2,double> &loqvs) const const unsigned int n_inner_2d=(degree-1)*(degree-1); const unsigned int n_outer_2d=4+4*(degree-1); - // first check whether we have precomputed - // the values for some polynomial degree; - // the sizes of arrays is - // n_inner_2d*n_outer_2d + // first check whether we have precomputed + // the values for some polynomial degree; + // the sizes of arrays is + // n_inner_2d*n_outer_2d double const *loqv_ptr=0; switch (degree) { @@ -520,181 +520,181 @@ MappingQ::set_laplace_on_quad_vector(Table<2,double> &loqvs) const // right -- just in case someone // wonders where they come from -- // WB) - static const double loqv2[1*8] - ={1/16., 1/16., 1/16., 1/16., 3/16., 3/16., 3/16., 3/16.}; - loqv_ptr=&loqv2[0]; + static const double loqv2[1*8] + ={1/16., 1/16., 1/16., 1/16., 3/16., 3/16., 3/16., 3/16.}; + loqv_ptr=&loqv2[0]; Assert (sizeof(loqv2)/sizeof(loqv2[0]) == n_inner_2d * n_outer_2d, ExcInternalError()); - break; + break; } case 3: { // (same as above) - static const double loqv3[4*12] - ={80/1053., 1/81., 1/81., 11/1053., 25/117., 44/351., - 7/117., 16/351., 25/117., 44/351., 7/117., 16/351., - 1/81., 80/1053., 11/1053., 1/81., 7/117., 16/351., - 25/117., 44/351., 44/351., 25/117., 16/351., 7/117., - 1/81., 11/1053., 80/1053., 1/81., 44/351., 25/117., - 16/351., 7/117., 7/117., 16/351., 25/117., 44/351., - 11/1053., 1/81., 1/81., 80/1053., 16/351., 7/117., - 44/351., 25/117., 16/351., 7/117., 44/351., 25/117.}; + static const double loqv3[4*12] + ={80/1053., 1/81., 1/81., 11/1053., 25/117., 44/351., + 7/117., 16/351., 25/117., 44/351., 7/117., 16/351., + 1/81., 80/1053., 11/1053., 1/81., 7/117., 16/351., + 25/117., 44/351., 44/351., 25/117., 16/351., 7/117., + 1/81., 11/1053., 80/1053., 1/81., 44/351., 25/117., + 16/351., 7/117., 7/117., 16/351., 25/117., 44/351., + 11/1053., 1/81., 1/81., 80/1053., 16/351., 7/117., + 44/351., 25/117., 16/351., 7/117., 44/351., 25/117.}; Assert (sizeof(loqv3)/sizeof(loqv3[0]) == n_inner_2d * n_outer_2d, ExcInternalError()); - loqv_ptr=&loqv3[0]; + loqv_ptr=&loqv3[0]; - break; + break; } case 4: { - static const double loqv4[9*16] - ={0.07405921850311571, -0.001075744628905992, - -0.001075744628906007, 0.001914292239071463, - 0.2231273865431892, 0.1346851306015187, - 0.03812914216116724, 0.02913160002633252, - 0.02200737428129396, 0.01600835564431224, - 0.2231273865431891, 0.1346851306015187, - 0.03812914216116723, 0.02913160002633253, - 0.02200737428129391, 0.01600835564431222, - - 0.00664803151334206, 0.006648031513342719, - 0.002873452861657458, 0.002873452861657626, - 0.07903572682584378, 0.05969238281250031, - 0.03619864817415824, 0.07903572682584187, - 0.0596923828124999, 0.03619864817415815, - 0.1527716818820237, 0.2348152760709273, - 0.152771681882024, 0.02496269311797778, - 0.04081948955407129, 0.02496269311797789, - - -0.001075744628906923, 0.07405921850311589, - 0.001914292239071339, -0.001075744628905884, - 0.02913160002633509, 0.02200737428129395, - 0.01600835564431229, 0.2231273865431878, - 0.1346851306015183, 0.0381291421611672, - 0.03812914216116729, 0.1346851306015185, - 0.2231273865431898, 0.01600835564431217, - 0.02200737428129394, 0.02913160002633262, - - 0.006648031513342073, 0.002873452861657473, - 0.006648031513342726, 0.002873452861657636, - 0.1527716818820238, 0.2348152760709273, - 0.152771681882024, 0.02496269311797779, - 0.04081948955407131, 0.0249626931179779, - 0.07903572682584376, 0.05969238281250026, - 0.03619864817415824, 0.07903572682584187, - 0.0596923828124998, 0.0361986481741581, - - 0.01106770833333302, 0.01106770833333336, - 0.01106770833333337, 0.01106770833333374, - 0.06770833333333424, 0.1035156250000011, - 0.0677083333333344, 0.06770833333333376, - 0.103515624999999, 0.06770833333333399, - 0.06770833333333422, 0.1035156250000009, - 0.06770833333333436, 0.0677083333333337, - 0.1035156249999988, 0.0677083333333339, - - 0.002873452861657185, 0.006648031513342362, - 0.002873452861657334, 0.006648031513343038, - 0.02496269311797779, 0.04081948955407401, - 0.02496269311797788, 0.1527716818820234, - 0.234815276070926, 0.1527716818820237, - 0.03619864817415819, 0.05969238281250028, - 0.07903572682584407, 0.03619864817415804, - 0.05969238281249986, 0.0790357268258422, - - -0.001075744628906913, 0.00191429223907134, - 0.07405921850311592, -0.001075744628905865, - 0.03812914216116729, 0.1346851306015185, - 0.2231273865431899, 0.01600835564431217, - 0.02200737428129396, 0.02913160002633264, - 0.02913160002633509, 0.02200737428129391, - 0.01600835564431228, 0.2231273865431878, - 0.1346851306015183, 0.03812914216116718, - - 0.002873452861657176, 0.002873452861657321, - 0.006648031513342374, 0.006648031513343037, - 0.03619864817415817, 0.05969238281250032, - 0.07903572682584409, 0.03619864817415805, - 0.05969238281249992, 0.07903572682584221, - 0.02496269311797776, 0.04081948955407392, - 0.02496269311797785, 0.1527716818820233, - 0.2348152760709258, 0.1527716818820236, - - 0.001914292239071237, -0.001075744628906803, - -0.001075744628906778, 0.07405921850311617, - 0.01600835564431228, 0.02200737428129401, - 0.02913160002633524, 0.03812914216116726, - 0.1346851306015182, 0.2231273865431886, - 0.01600835564431228, 0.02200737428129397, - 0.02913160002633523, 0.03812914216116726, - 0.1346851306015181, 0.2231273865431886, + static const double loqv4[9*16] + ={0.07405921850311571, -0.001075744628905992, + -0.001075744628906007, 0.001914292239071463, + 0.2231273865431892, 0.1346851306015187, + 0.03812914216116724, 0.02913160002633252, + 0.02200737428129396, 0.01600835564431224, + 0.2231273865431891, 0.1346851306015187, + 0.03812914216116723, 0.02913160002633253, + 0.02200737428129391, 0.01600835564431222, + + 0.00664803151334206, 0.006648031513342719, + 0.002873452861657458, 0.002873452861657626, + 0.07903572682584378, 0.05969238281250031, + 0.03619864817415824, 0.07903572682584187, + 0.0596923828124999, 0.03619864817415815, + 0.1527716818820237, 0.2348152760709273, + 0.152771681882024, 0.02496269311797778, + 0.04081948955407129, 0.02496269311797789, + + -0.001075744628906923, 0.07405921850311589, + 0.001914292239071339, -0.001075744628905884, + 0.02913160002633509, 0.02200737428129395, + 0.01600835564431229, 0.2231273865431878, + 0.1346851306015183, 0.0381291421611672, + 0.03812914216116729, 0.1346851306015185, + 0.2231273865431898, 0.01600835564431217, + 0.02200737428129394, 0.02913160002633262, + + 0.006648031513342073, 0.002873452861657473, + 0.006648031513342726, 0.002873452861657636, + 0.1527716818820238, 0.2348152760709273, + 0.152771681882024, 0.02496269311797779, + 0.04081948955407131, 0.0249626931179779, + 0.07903572682584376, 0.05969238281250026, + 0.03619864817415824, 0.07903572682584187, + 0.0596923828124998, 0.0361986481741581, + + 0.01106770833333302, 0.01106770833333336, + 0.01106770833333337, 0.01106770833333374, + 0.06770833333333424, 0.1035156250000011, + 0.0677083333333344, 0.06770833333333376, + 0.103515624999999, 0.06770833333333399, + 0.06770833333333422, 0.1035156250000009, + 0.06770833333333436, 0.0677083333333337, + 0.1035156249999988, 0.0677083333333339, + + 0.002873452861657185, 0.006648031513342362, + 0.002873452861657334, 0.006648031513343038, + 0.02496269311797779, 0.04081948955407401, + 0.02496269311797788, 0.1527716818820234, + 0.234815276070926, 0.1527716818820237, + 0.03619864817415819, 0.05969238281250028, + 0.07903572682584407, 0.03619864817415804, + 0.05969238281249986, 0.0790357268258422, + + -0.001075744628906913, 0.00191429223907134, + 0.07405921850311592, -0.001075744628905865, + 0.03812914216116729, 0.1346851306015185, + 0.2231273865431899, 0.01600835564431217, + 0.02200737428129396, 0.02913160002633264, + 0.02913160002633509, 0.02200737428129391, + 0.01600835564431228, 0.2231273865431878, + 0.1346851306015183, 0.03812914216116718, + + 0.002873452861657176, 0.002873452861657321, + 0.006648031513342374, 0.006648031513343037, + 0.03619864817415817, 0.05969238281250032, + 0.07903572682584409, 0.03619864817415805, + 0.05969238281249992, 0.07903572682584221, + 0.02496269311797776, 0.04081948955407392, + 0.02496269311797785, 0.1527716818820233, + 0.2348152760709258, 0.1527716818820236, + + 0.001914292239071237, -0.001075744628906803, + -0.001075744628906778, 0.07405921850311617, + 0.01600835564431228, 0.02200737428129401, + 0.02913160002633524, 0.03812914216116726, + 0.1346851306015182, 0.2231273865431886, + 0.01600835564431228, 0.02200737428129397, + 0.02913160002633523, 0.03812914216116726, + 0.1346851306015181, 0.2231273865431886, }; Assert (sizeof(loqv4)/sizeof(loqv4[0]) == n_inner_2d * n_outer_2d, ExcInternalError()); - loqv_ptr=&loqv4[0]; + loqv_ptr=&loqv4[0]; - break; + break; } - // no other cases implemented, - // so simply fall through + // no other cases implemented, + // so simply fall through default: break; } if (loqv_ptr!=0) { - // precomputed. copy values to - // the loqvs array + // precomputed. copy values to + // the loqvs array loqvs.reinit(n_inner_2d, n_outer_2d); for (unsigned int unit_point=0; unit_point::set_laplace_on_hex_vector(Table<2,double> &lohvs) const { Assert(degree>1, ExcInternalError()); - // first check whether we have - // precomputed the values for some - // polynomial degree + // first check whether we have + // precomputed the values for some + // polynomial degree double const *lohv_ptr=0; if (degree==2) { static const double loqv2[26] - ={1/128., 1/128., 1/128., 1/128., 1/128., 1/128., 1/128., 1/128., - 7/192., 7/192., 7/192., 7/192., 7/192., 7/192., 7/192., 7/192., - 7/192., 7/192., 7/192., 7/192., - 1/12., 1/12., 1/12., 1/12., 1/12., 1/12.}; + ={1/128., 1/128., 1/128., 1/128., 1/128., 1/128., 1/128., 1/128., + 7/192., 7/192., 7/192., 7/192., 7/192., 7/192., 7/192., 7/192., + 7/192., 7/192., 7/192., 7/192., + 1/12., 1/12., 1/12., 1/12., 1/12., 1/12.}; lohv_ptr=&loqv2[0]; } if (lohv_ptr!=0) { - // precomputed. copy values to - // the lohvs array + // precomputed. copy values to + // the lohvs array lohvs.reinit(n_inner, n_outer); for (unsigned int unit_point=0; unit_point::compute_laplace_vector(Table<2,double> &lvs) const // them are on the vertices Assert(degree>1, ExcInternalError()); - // compute the shape - // gradients at the quadrature - // points on the unit cell + // compute the shape + // gradients at the quadrature + // points on the unit cell const QGauss quadrature(degree+1); const unsigned int n_q_points=quadrature.size(); @@ -784,37 +784,37 @@ MappingQ::compute_laplace_vector(Table<2,double> &lvs) const quadrature_data.shape_derivatives.resize(n_shape_functions * n_q_points); this->compute_shapes(quadrature.get_points(), quadrature_data); - // Compute the stiffness matrix of - // the inner dofs + // Compute the stiffness matrix of + // the inner dofs FullMatrix S(n_inner); for (unsigned int point=0; point T(n_inner, n_outer); for (unsigned int point=0; point S_1(n_inner); S_1.invert(S); FullMatrix S_1_T(n_inner, n_outer); - // S:=S_1*T + // S:=S_1*T S_1.mmult(S_1_T,T); - // Resize and initialize the - // lvs + // Resize and initialize the + // lvs lvs.reinit (n_inner, n_outer); for (unsigned int i=0; i::compute_laplace_vector(Table<2,double> &lvs) const template void MappingQ::apply_laplace_vector(const Table<2,double> &lvs, - std::vector > &a) const + std::vector > &a) const { // check whether the data we need // is really available. if you fail @@ -843,23 +843,23 @@ MappingQ::apply_laplace_vector(const Table<2,double> &lvs, const unsigned int n_inner_apply=lvs.n_rows(); Assert(n_inner_apply==n_inner || n_inner_apply==(degree-1)*(degree-1), - ExcInternalError()); + ExcInternalError()); const unsigned int n_outer_apply=lvs.n_cols(); Assert(a.size()==n_outer_apply, - ExcDimensionMismatch(a.size(), n_outer_apply)); - - // compute each inner point as - // linear combination of the outer - // points. the weights are given by - // the lvs entries, the outer - // points are the first (existing) - // elements of a + ExcDimensionMismatch(a.size(), n_outer_apply)); + + // compute each inner point as + // linear combination of the outer + // points. the weights are given by + // the lvs entries, the outer + // points are the first (existing) + // elements of a for (unsigned int unit_point=0; unit_point p; for (unsigned int k=0; k::compute_mapping_support_points( const typename Triangulation::cell_iterator &cell, std::vector > &a) const { - // if this is a cell for which we - // want to compute the full - // mapping, then get them from the - // following function + // if this is a cell for which we + // want to compute the full + // mapping, then get them from the + // following function if (use_mapping_q_on_all_cells || cell->has_boundary_lines()) compute_support_points_laplace(cell, a); else - // otherwise: use a Q1 mapping - // for which the mapping shape - // function support points are - // simply the vertices of the - // cell + // otherwise: use a Q1 mapping + // for which the mapping shape + // function support points are + // simply the vertices of the + // cell { a.resize(GeometryInfo::vertices_per_cell); for (unsigned int i=0; i::vertices_per_cell; ++i) - a[i] = cell->vertex(i); + a[i] = cell->vertex(i); } } @@ -896,10 +896,10 @@ MappingQ::compute_mapping_support_points( template void MappingQ::compute_support_points_laplace(const typename Triangulation::cell_iterator &cell, - std::vector > &a) const + std::vector > &a) const { - // in any case, we need the - // vertices first + // in any case, we need the + // vertices first a.resize(GeometryInfo::vertices_per_cell); for (unsigned int i=0; i::vertices_per_cell; ++i) a[i] = cell->vertex(i); @@ -907,36 +907,36 @@ MappingQ::compute_support_points_laplace(const typename Triangulat if (degree>1) switch (dim) { - case 1: - Assert(spacedim == 2, ExcInternalError()); - add_line_support_points(cell, a); - break; - case 2: - // in 2d, add the - // points on the four - // bounding lines to - // the exterior (outer) - // points - add_line_support_points (cell, a); - if(dim != spacedim) - add_quad_support_points(cell, a); - else - apply_laplace_vector (laplace_on_quad_vector,a); - break; - - case 3: - { - // in 3d also add the - // points located on - // the boundary faces - add_line_support_points (cell, a); - add_quad_support_points (cell, a); - apply_laplace_vector (laplace_on_hex_vector, a); - break; - } - default: - Assert(false, ExcNotImplemented()); - break; + case 1: + Assert(spacedim == 2, ExcInternalError()); + add_line_support_points(cell, a); + break; + case 2: + // in 2d, add the + // points on the four + // bounding lines to + // the exterior (outer) + // points + add_line_support_points (cell, a); + if(dim != spacedim) + add_quad_support_points(cell, a); + else + apply_laplace_vector (laplace_on_quad_vector,a); + break; + + case 3: + { + // in 3d also add the + // points located on + // the boundary faces + add_line_support_points (cell, a); + add_quad_support_points (cell, a); + apply_laplace_vector (laplace_on_hex_vector, a); + break; + } + default: + Assert(false, ExcNotImplemented()); + break; }; } @@ -945,10 +945,10 @@ MappingQ::compute_support_points_laplace(const typename Triangulat template <> void MappingQ<1>::add_line_support_points (const Triangulation<1>::cell_iterator &, - std::vector > &) const + std::vector > &) const { - // there are no points on bounding - // lines which are to be added + // there are no points on bounding + // lines which are to be added const unsigned int dim=1; Assert (dim > 1, ExcImpossibleInDim(dim)); } @@ -958,30 +958,30 @@ MappingQ<1>::add_line_support_points (const Triangulation<1>::cell_iterator &, template <> void MappingQ<1,2>::add_line_support_points (const Triangulation<1,2>::cell_iterator &cell, - std::vector > &a) const + std::vector > &a) const { const unsigned int dim=1, spacedim=2; - // Ask for the mid point, if that's - // the only thing we need. + // Ask for the mid point, if that's + // the only thing we need. if (degree==2) { const Boundary * const boundary - = &(cell->get_triangulation().get_boundary(cell->material_id())); + = &(cell->get_triangulation().get_boundary(cell->material_id())); a.push_back(boundary->get_new_point_on_line(cell)); } else - // otherwise call the more - // complicated functions and ask - // for inner points from the - // boundary description + // otherwise call the more + // complicated functions and ask + // for inner points from the + // boundary description { std::vector > line_points (degree-1); const Boundary * const boundary - = &(cell->get_triangulation().get_boundary(cell->material_id())); + = &(cell->get_triangulation().get_boundary(cell->material_id())); boundary->get_intermediate_points_on_line (cell, line_points); - // Append all points + // Append all points a.insert (a.end(), line_points.begin(), line_points.end()); } } @@ -991,69 +991,69 @@ MappingQ<1,2>::add_line_support_points (const Triangulation<1,2>::cell_iterator template void MappingQ::add_line_support_points (const typename Triangulation::cell_iterator &cell, - std::vector > &a) const + std::vector > &a) const { static const StraightBoundary straight_boundary; - // if we only need the midpoint, - // then ask for it. + // if we only need the midpoint, + // then ask for it. if (degree==2) { for (unsigned int line_no=0; line_no::lines_per_cell; ++line_no) - { - const typename Triangulation::line_iterator line = cell->line(line_no); - const Boundary * const boundary - = (line->at_boundary()? - &line->get_triangulation().get_boundary(line->boundary_indicator()): - (dim != spacedim) ? - &line->get_triangulation().get_boundary(cell->material_id()): - &straight_boundary); - - a.push_back(boundary->get_new_point_on_line(line)); - }; + { + const typename Triangulation::line_iterator line = cell->line(line_no); + const Boundary * const boundary + = (line->at_boundary()? + &line->get_triangulation().get_boundary(line->boundary_indicator()): + (dim != spacedim) ? + &line->get_triangulation().get_boundary(cell->material_id()): + &straight_boundary); + + a.push_back(boundary->get_new_point_on_line(line)); + }; } else - // otherwise call the more - // complicated functions and ask - // for inner points from the - // boundary description + // otherwise call the more + // complicated functions and ask + // for inner points from the + // boundary description { std::vector > line_points (degree-1); - // loop over each of the lines, - // and if it is at the - // boundary, then first get the - // boundary description and - // second compute the points on - // it + // loop over each of the lines, + // and if it is at the + // boundary, then first get the + // boundary description and + // second compute the points on + // it for (unsigned int line_no=0; line_no::lines_per_cell; ++line_no) - { - const typename Triangulation::line_iterator line = cell->line(line_no); - - const Boundary * const boundary - = (line->at_boundary()? - &line->get_triangulation().get_boundary(line->boundary_indicator()) : - (dim != spacedim) ? - &line->get_triangulation().get_boundary(cell->material_id()) : - &straight_boundary); - - boundary->get_intermediate_points_on_line (line, line_points); - if (dim==3) - { - // in 3D, lines might be in wrong - // orientation. if so, reverse - // the vector - if (cell->line_orientation(line_no)) - a.insert (a.end(), line_points.begin(), line_points.end()); - else - a.insert (a.end(), line_points.rbegin(), line_points.rend()); - } - else - // in 2D, lines always have the - // correct orientation. simply - // append all points - a.insert (a.end(), line_points.begin(), line_points.end()); - - } + { + const typename Triangulation::line_iterator line = cell->line(line_no); + + const Boundary * const boundary + = (line->at_boundary()? + &line->get_triangulation().get_boundary(line->boundary_indicator()) : + (dim != spacedim) ? + &line->get_triangulation().get_boundary(cell->material_id()) : + &straight_boundary); + + boundary->get_intermediate_points_on_line (line, line_points); + if (dim==3) + { + // in 3D, lines might be in wrong + // orientation. if so, reverse + // the vector + if (cell->line_orientation(line_no)) + a.insert (a.end(), line_points.begin(), line_points.end()); + else + a.insert (a.end(), line_points.rbegin(), line_points.rend()); + } + else + // in 2D, lines always have the + // correct orientation. simply + // append all points + a.insert (a.end(), line_points.begin(), line_points.end()); + + } } } @@ -1066,22 +1066,22 @@ add_quad_support_points(const Triangulation<3>::cell_iterator &cell, std::vector > &a) const { const unsigned int faces_per_cell = GeometryInfo<3>::faces_per_cell, - vertices_per_face = GeometryInfo<3>::vertices_per_face, - lines_per_face = GeometryInfo<3>::lines_per_face, - vertices_per_cell = GeometryInfo<3>::vertices_per_cell; + vertices_per_face = GeometryInfo<3>::vertices_per_face, + lines_per_face = GeometryInfo<3>::lines_per_face, + vertices_per_cell = GeometryInfo<3>::vertices_per_cell; static const StraightBoundary<3> straight_boundary; - // used if face quad at boundary or - // entirely in the interior of the - // domain + // used if face quad at boundary or + // entirely in the interior of the + // domain std::vector > quad_points ((degree-1)*(degree-1)); - // used if only one line of face - // quad is at boundary + // used if only one line of face + // quad is at boundary std::vector > b(4*degree); - // loop over all faces and collect - // points on them + // loop over all faces and collect + // points on them for (unsigned int face_no=0; face_no::face_iterator face = cell->face(face_no); @@ -1089,95 +1089,95 @@ add_quad_support_points(const Triangulation<3>::cell_iterator &cell, // select the correct mappings // for the present face const bool face_orientation = cell->face_orientation(face_no), - face_flip = cell->face_flip (face_no), - face_rotation = cell->face_rotation (face_no); + face_flip = cell->face_flip (face_no), + face_rotation = cell->face_rotation (face_no); #ifdef DEBUG // some sanity checks up front for (unsigned int i=0; ivertex_index(i)==cell->vertex_index( - GeometryInfo<3>::face_to_cell_vertices(face_no, i, - face_orientation, - face_flip, - face_rotation)), - ExcInternalError()); - - // indices of the lines that - // bound a face are given by - // GeometryInfo<3>:: - // face_to_cell_lines + GeometryInfo<3>::face_to_cell_vertices(face_no, i, + face_orientation, + face_flip, + face_rotation)), + ExcInternalError()); + + // indices of the lines that + // bound a face are given by + // GeometryInfo<3>:: + // face_to_cell_lines for (unsigned int i=0; iline(i)==cell->line(GeometryInfo<3>::face_to_cell_lines( - face_no, i, face_orientation, face_flip, face_rotation)), - ExcInternalError()); + face_no, i, face_orientation, face_flip, face_rotation)), + ExcInternalError()); #endif - // if face at boundary, then - // ask boundary object to - // return intermediate points - // on it + // if face at boundary, then + // ask boundary object to + // return intermediate points + // on it if (face->at_boundary()) - { - face->get_triangulation().get_boundary(face->boundary_indicator()) - .get_intermediate_points_on_quad (face, quad_points); - // in 3D, the orientation, flip and - // rotation of the face might not - // match what we expect here, namely - // the standard orientation. thus - // reorder points accordingly. since - // a Mapping uses the same shape - // function as an FEQ, we can ask a - // FEQ to do the reordering for us. - for (unsigned int i=0; iget_triangulation().get_boundary(face->boundary_indicator()) + .get_intermediate_points_on_quad (face, quad_points); + // in 3D, the orientation, flip and + // rotation of the face might not + // match what we expect here, namely + // the standard orientation. thus + // reorder points accordingly. since + // a Mapping uses the same shape + // function as an FEQ, we can ask a + // FEQ to do the reordering for us. + for (unsigned int i=0; iline(i)->at_boundary()) - ++lines_at_boundary; - - Assert(lines_at_boundary<=lines_per_face, ExcInternalError()); - - // if at least one of the - // lines bounding this quad - // is at the boundary, then - // collect points - // separately - if (lines_at_boundary>0) - { - // call of function - // apply_laplace_vector - // increases size of b - // about 1. There - // resize b for the - // case the mentioned - // function was already - // called. - b.resize(4*degree); - - // b is of size - // 4*degree, make sure - // that this is the - // right size - Assert(b.size()==vertices_per_face+lines_per_face*(degree-1), - ExcDimensionMismatch(b.size(), + { + // face is not at boundary, + // but maybe some of its + // lines are. count them + unsigned int lines_at_boundary=0; + for (unsigned int i=0; iline(i)->at_boundary()) + ++lines_at_boundary; + + Assert(lines_at_boundary<=lines_per_face, ExcInternalError()); + + // if at least one of the + // lines bounding this quad + // is at the boundary, then + // collect points + // separately + if (lines_at_boundary>0) + { + // call of function + // apply_laplace_vector + // increases size of b + // about 1. There + // resize b for the + // case the mentioned + // function was already + // called. + b.resize(4*degree); + + // b is of size + // 4*degree, make sure + // that this is the + // right size + Assert(b.size()==vertices_per_face+lines_per_face*(degree-1), + ExcDimensionMismatch(b.size(), vertices_per_face+lines_per_face*(degree-1))); - // sort the points into b. We - // used access from the cell (not - // from the face) to fill b, so - // we can assume a standard face - // orientation. Doing so, the - // calculated points will be in - // standard orientation as well. + // sort the points into b. We + // used access from the cell (not + // from the face) to fill b, so + // we can assume a standard face + // orientation. Doing so, the + // calculated points will be in + // standard orientation as well. for (unsigned int i=0; i::face_to_cell_vertices(face_no, i)]; @@ -1185,43 +1185,43 @@ add_quad_support_points(const Triangulation<3>::cell_iterator &cell, for (unsigned int j=0; j::face_to_cell_lines( - face_no, i)*(degree-1)+j]; - - // Now b includes the support - // points on the quad and we can - // apply the laplace vector - apply_laplace_vector(laplace_on_quad_vector, b); - Assert(b.size()==4*degree+(degree-1)*(degree-1), - ExcDimensionMismatch(b.size(), 4*degree+(degree-1)*(degree-1))); - - for (unsigned int i=0; i<(degree-1)*(degree-1); ++i) - a.push_back(b[4*degree+i]); - } - else - { - // face is entirely in - // the interior. get - // intermediate points - // from a straight - // boundary object - straight_boundary.get_intermediate_points_on_quad (face, quad_points); - // in 3D, the orientation, flip - // and rotation of the face might - // not match what we expect here, - // namely the standard - // orientation. thus reorder - // points accordingly. since a - // Mapping uses the same shape - // function as an FEQ, we can ask - // a FEQ to do the reordering for - // us. - for (unsigned int i=0; i::transform ( const MappingType mapping_type) const { AssertDimension (input.size(), output.size()); - // The data object may be jsut a - // MappingQ1::InternalData, so we - // have to test for this first. + // The data object may be jsut a + // MappingQ1::InternalData, so we + // have to test for this first. const typename MappingQ1::InternalData *q1_data = dynamic_cast::InternalData *> (&mapping_data); Assert(q1_data!=0, ExcInternalError()); - // If it is a genuine - // MappingQ::InternalData, we have - // to test further + // If it is a genuine + // MappingQ::InternalData, we have + // to test further if (!q1_data->is_mapping_q1_data) { Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); const InternalData &data = static_cast(mapping_data); - // If we only use the - // Q1-portion, we have to - // extract that data object + // If we only use the + // Q1-portion, we have to + // extract that data object if (data.use_mapping_q1_on_current_cell) - q1_data = &data.mapping_q1_data; + q1_data = &data.mapping_q1_data; } - // Now, q1_data should have the - // right tensors in it and we call - // the base classes transform - // function + // Now, q1_data should have the + // right tensors in it and we call + // the base classes transform + // function MappingQ1::transform(input, output, *q1_data, mapping_type); } @@ -1302,31 +1302,31 @@ MappingQ::transform ( const MappingType mapping_type) const { AssertDimension (input.size(), output.size()); - // The data object may be jsut a - // MappingQ1::InternalData, so we - // have to test for this first. + // The data object may be jsut a + // MappingQ1::InternalData, so we + // have to test for this first. const typename MappingQ1::InternalData *q1_data = dynamic_cast::InternalData *> (&mapping_data); Assert(q1_data!=0, ExcInternalError()); - // If it is a genuine - // MappingQ::InternalData, we have - // to test further + // If it is a genuine + // MappingQ::InternalData, we have + // to test further if (!q1_data->is_mapping_q1_data) { Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); const InternalData &data = static_cast(mapping_data); - // If we only use the - // Q1-portion, we have to - // extract that data object + // If we only use the + // Q1-portion, we have to + // extract that data object if (data.use_mapping_q1_on_current_cell) - q1_data = &data.mapping_q1_data; + q1_data = &data.mapping_q1_data; } - // Now, q1_data should have the - // right tensors in it and we call - // the base classes transform - // function + // Now, q1_data should have the + // right tensors in it and we call + // the base classes transform + // function MappingQ1::transform(input, output, *q1_data, mapping_type); } @@ -1339,31 +1339,31 @@ void MappingQ::transform const MappingType mapping_type) const { AssertDimension (input.size(), output.size()); - // The data object may be jsut a - // MappingQ1::InternalData, so we - // have to test for this first. + // The data object may be jsut a + // MappingQ1::InternalData, so we + // have to test for this first. const typename MappingQ1::InternalData *q1_data = dynamic_cast::InternalData *> (&mapping_data); Assert(q1_data!=0, ExcInternalError()); - // If it is a genuine - // MappingQ::InternalData, we have - // to test further + // If it is a genuine + // MappingQ::InternalData, we have + // to test further if (!q1_data->is_mapping_q1_data) { Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); const InternalData &data = static_cast(mapping_data); - // If we only use the - // Q1-portion, we have to - // extract that data object + // If we only use the + // Q1-portion, we have to + // extract that data object if (data.use_mapping_q1_on_current_cell) - q1_data = &data.mapping_q1_data; + q1_data = &data.mapping_q1_data; } - // Now, q1_data should have the - // right tensors in it and we call - // the base classes transform - // function + // Now, q1_data should have the + // right tensors in it and we call + // the base classes transform + // function MappingQ1::transform(input, output, *q1_data, mapping_type); } @@ -1374,18 +1374,18 @@ MappingQ:: transform_unit_to_real_cell (const typename Triangulation::cell_iterator &cell, const Point &p) const { - // Use the get_data function to - // create an InternalData with data - // vectors of the right size and - // transformation shape values - // already computed at point p. + // Use the get_data function to + // create an InternalData with data + // vectors of the right size and + // transformation shape values + // already computed at point p. const Quadrature point_quadrature(p); std::auto_ptr mdata (dynamic_cast ( get_data(update_transformation_values, point_quadrature))); mdata->use_mapping_q1_on_current_cell = !(use_mapping_q_on_all_cells || - cell->has_boundary_lines()); + cell->has_boundary_lines()); typename MappingQ1::InternalData *p_data = (mdata->use_mapping_q1_on_current_cell ? @@ -1393,8 +1393,8 @@ transform_unit_to_real_cell (const typename Triangulation::cell_it &*mdata); compute_mapping_support_points(cell, p_data->mapping_support_points); - // If this should be Q1, ignore all - // other support points. + // If this should be Q1, ignore all + // other support points. if(p_data->shape_values.size()mapping_support_points.size()) p_data->mapping_support_points.resize (GeometryInfo::vertices_per_cell); @@ -1411,8 +1411,8 @@ MappingQ:: transform_real_to_unit_cell (const typename Triangulation::cell_iterator &cell, const Point &p) const { - // first a Newton iteration based - // on a Q1 mapping + // first a Newton iteration based + // on a Q1 mapping Point p_unit = MappingQ1::transform_real_to_unit_cell(cell, p); // then a Newton iteration based on the @@ -1425,12 +1425,12 @@ transform_real_to_unit_cell (const typename Triangulation::cell_it use_mapping_q_on_all_cells || (dim!=spacedim) ) { - + const Quadrature point_quadrature(p_unit); UpdateFlags update_flags = update_transformation_values|update_transformation_gradients; if (spacedim>dim) - update_flags |= update_jacobian_grads; + update_flags |= update_jacobian_grads; std::auto_ptr mdata (dynamic_cast ( get_data(update_flags,point_quadrature))); @@ -1439,11 +1439,11 @@ transform_real_to_unit_cell (const typename Triangulation::cell_it compute_mapping_support_points (cell, mdata->mapping_support_points); - // If this is a q1 mapping, - // then only use the support - // points on the vertices. + // If this is a q1 mapping, + // then only use the support + // points on the vertices. if (mdata->shape_values.size() < mdata->mapping_support_points.size()) - mdata->mapping_support_points.resize(GeometryInfo::vertices_per_cell); + mdata->mapping_support_points.resize(GeometryInfo::vertices_per_cell); this->transform_real_to_unit_cell_internal(cell, p, *mdata, p_unit); diff --git a/deal.II/source/fe/mapping_q1.cc b/deal.II/source/fe/mapping_q1.cc index 3d323eac58..b3d683b0b5 100644 --- a/deal.II/source/fe/mapping_q1.cc +++ b/deal.II/source/fe/mapping_q1.cc @@ -41,9 +41,9 @@ const unsigned int MappingQ1::n_shape_functions; template MappingQ1::InternalData::InternalData (const unsigned int n_shape_functions) - : - is_mapping_q1_data(true), - n_shape_functions (n_shape_functions) + : + is_mapping_q1_data(true), + n_shape_functions (n_shape_functions) {} @@ -53,16 +53,16 @@ std::size_t MappingQ1::InternalData::memory_consumption () const { return (Mapping::InternalDataBase::memory_consumption() + - MemoryConsumption::memory_consumption (shape_values) + - MemoryConsumption::memory_consumption (shape_derivatives) + - MemoryConsumption::memory_consumption (covariant) + - MemoryConsumption::memory_consumption (contravariant) + - MemoryConsumption::memory_consumption (unit_tangentials) + - MemoryConsumption::memory_consumption (aux) + - MemoryConsumption::memory_consumption (mapping_support_points) + - MemoryConsumption::memory_consumption (cell_of_current_support_points) + - MemoryConsumption::memory_consumption (is_mapping_q1_data) + - MemoryConsumption::memory_consumption (n_shape_functions)); + MemoryConsumption::memory_consumption (shape_values) + + MemoryConsumption::memory_consumption (shape_derivatives) + + MemoryConsumption::memory_consumption (covariant) + + MemoryConsumption::memory_consumption (contravariant) + + MemoryConsumption::memory_consumption (unit_tangentials) + + MemoryConsumption::memory_consumption (aux) + + MemoryConsumption::memory_consumption (mapping_support_points) + + MemoryConsumption::memory_consumption (cell_of_current_support_points) + + MemoryConsumption::memory_consumption (is_mapping_q1_data) + + MemoryConsumption::memory_consumption (n_shape_functions)); } @@ -76,11 +76,11 @@ MappingQ1::MappingQ1 () template void MappingQ1::compute_shapes (const std::vector > &unit_points, - InternalData &data) const + InternalData &data) const { - // choose either the function implemented - // in this class, or whatever a virtual - // function call resolves to + // choose either the function implemented + // in this class, or whatever a virtual + // function call resolves to if (data.is_mapping_q1_data) MappingQ1::compute_shapes_virtual(unit_points, data); else @@ -95,99 +95,99 @@ namespace internal template void compute_shapes_virtual (const unsigned int n_shape_functions, - const std::vector > &unit_points, - typename dealii::MappingQ1<1,spacedim>::InternalData& data) + const std::vector > &unit_points, + typename dealii::MappingQ1<1,spacedim>::InternalData& data) { const unsigned int n_points=unit_points.size(); for (unsigned int k = 0 ; k < n_points ; ++k) - { - double x = unit_points[k](0); - - if (data.shape_values.size()!=0) - { - Assert(data.shape_values.size()==n_shape_functions*n_points, - ExcInternalError()); - data.shape(k,0) = 1.-x; - data.shape(k,1) = x; - } - if (data.shape_derivatives.size()!=0) - { - Assert(data.shape_derivatives.size()==n_shape_functions*n_points, - ExcInternalError()); - data.derivative(k,0)[0] = -1.; - data.derivative(k,1)[0] = 1.; - } - if (data.shape_second_derivatives.size()!=0) - { - // the following may or may not - // work if dim != spacedim - Assert (spacedim == 1, ExcNotImplemented()); - - Assert(data.shape_second_derivatives.size()==n_shape_functions*n_points, - ExcInternalError()); - data.second_derivative(k,0)[0][0] = 0; - data.second_derivative(k,1)[0][0] = 0; - } - } + { + double x = unit_points[k](0); + + if (data.shape_values.size()!=0) + { + Assert(data.shape_values.size()==n_shape_functions*n_points, + ExcInternalError()); + data.shape(k,0) = 1.-x; + data.shape(k,1) = x; + } + if (data.shape_derivatives.size()!=0) + { + Assert(data.shape_derivatives.size()==n_shape_functions*n_points, + ExcInternalError()); + data.derivative(k,0)[0] = -1.; + data.derivative(k,1)[0] = 1.; + } + if (data.shape_second_derivatives.size()!=0) + { + // the following may or may not + // work if dim != spacedim + Assert (spacedim == 1, ExcNotImplemented()); + + Assert(data.shape_second_derivatives.size()==n_shape_functions*n_points, + ExcInternalError()); + data.second_derivative(k,0)[0][0] = 0; + data.second_derivative(k,1)[0][0] = 0; + } + } } template void compute_shapes_virtual (const unsigned int n_shape_functions, - const std::vector > &unit_points, - typename dealii::MappingQ1<2,spacedim>::InternalData& data) + const std::vector > &unit_points, + typename dealii::MappingQ1<2,spacedim>::InternalData& data) { const unsigned int n_points=unit_points.size(); for (unsigned int k = 0 ; k < n_points ; ++k) - { - double x = unit_points[k](0); - double y = unit_points[k](1); - - if (data.shape_values.size()!=0) - { - Assert(data.shape_values.size()==n_shape_functions*n_points, - ExcInternalError()); - data.shape(k,0) = (1.-x)*(1.-y); - data.shape(k,1) = x*(1.-y); - data.shape(k,2) = (1.-x)*y; - data.shape(k,3) = x*y; - } - if (data.shape_derivatives.size()!=0) - { - Assert(data.shape_derivatives.size()==n_shape_functions*n_points, - ExcInternalError()); - data.derivative(k,0)[0] = (y-1.); - data.derivative(k,1)[0] = (1.-y); - data.derivative(k,2)[0] = -y; - data.derivative(k,3)[0] = y; - data.derivative(k,0)[1] = (x-1.); - data.derivative(k,1)[1] = -x; - data.derivative(k,2)[1] = (1.-x); - data.derivative(k,3)[1] = x; - } - if (data.shape_second_derivatives.size()!=0) - { - Assert(data.shape_second_derivatives.size()==n_shape_functions*n_points, - ExcInternalError()); - data.second_derivative(k,0)[0][0] = 0; - data.second_derivative(k,1)[0][0] = 0; - data.second_derivative(k,2)[0][0] = 0; - data.second_derivative(k,3)[0][0] = 0; - data.second_derivative(k,0)[0][1] = 1.; - data.second_derivative(k,1)[0][1] = -1.; - data.second_derivative(k,2)[0][1] = -1.; - data.second_derivative(k,3)[0][1] = 1.; - data.second_derivative(k,0)[1][0] = 1.; - data.second_derivative(k,1)[1][0] = -1.; - data.second_derivative(k,2)[1][0] = -1.; - data.second_derivative(k,3)[1][0] = 1.; - data.second_derivative(k,0)[1][1] = 0; - data.second_derivative(k,1)[1][1] = 0; - data.second_derivative(k,2)[1][1] = 0; - data.second_derivative(k,3)[1][1] = 0; - } - } + { + double x = unit_points[k](0); + double y = unit_points[k](1); + + if (data.shape_values.size()!=0) + { + Assert(data.shape_values.size()==n_shape_functions*n_points, + ExcInternalError()); + data.shape(k,0) = (1.-x)*(1.-y); + data.shape(k,1) = x*(1.-y); + data.shape(k,2) = (1.-x)*y; + data.shape(k,3) = x*y; + } + if (data.shape_derivatives.size()!=0) + { + Assert(data.shape_derivatives.size()==n_shape_functions*n_points, + ExcInternalError()); + data.derivative(k,0)[0] = (y-1.); + data.derivative(k,1)[0] = (1.-y); + data.derivative(k,2)[0] = -y; + data.derivative(k,3)[0] = y; + data.derivative(k,0)[1] = (x-1.); + data.derivative(k,1)[1] = -x; + data.derivative(k,2)[1] = (1.-x); + data.derivative(k,3)[1] = x; + } + if (data.shape_second_derivatives.size()!=0) + { + Assert(data.shape_second_derivatives.size()==n_shape_functions*n_points, + ExcInternalError()); + data.second_derivative(k,0)[0][0] = 0; + data.second_derivative(k,1)[0][0] = 0; + data.second_derivative(k,2)[0][0] = 0; + data.second_derivative(k,3)[0][0] = 0; + data.second_derivative(k,0)[0][1] = 1.; + data.second_derivative(k,1)[0][1] = -1.; + data.second_derivative(k,2)[0][1] = -1.; + data.second_derivative(k,3)[0][1] = 1.; + data.second_derivative(k,0)[1][0] = 1.; + data.second_derivative(k,1)[1][0] = -1.; + data.second_derivative(k,2)[1][0] = -1.; + data.second_derivative(k,3)[1][0] = 1.; + data.second_derivative(k,0)[1][1] = 0; + data.second_derivative(k,1)[1][1] = 0; + data.second_derivative(k,2)[1][1] = 0; + data.second_derivative(k,3)[1][1] = 0; + } + } } @@ -195,143 +195,143 @@ namespace internal template void compute_shapes_virtual (const unsigned int n_shape_functions, - const std::vector > &unit_points, - typename dealii::MappingQ1<3,spacedim>::InternalData& data) + const std::vector > &unit_points, + typename dealii::MappingQ1<3,spacedim>::InternalData& data) { const unsigned int n_points=unit_points.size(); for (unsigned int k = 0 ; k < n_points ; ++k) - { - double x = unit_points[k](0); - double y = unit_points[k](1); - double z = unit_points[k](2); - - if (data.shape_values.size()!=0) - { - Assert(data.shape_values.size()==n_shape_functions*n_points, - ExcInternalError()); - data.shape(k,0) = (1.-x)*(1.-y)*(1.-z); - data.shape(k,1) = x*(1.-y)*(1.-z); - data.shape(k,2) = (1.-x)*y*(1.-z); - data.shape(k,3) = x*y*(1.-z); - data.shape(k,4) = (1.-x)*(1.-y)*z; - data.shape(k,5) = x*(1.-y)*z; - data.shape(k,6) = (1.-x)*y*z; - data.shape(k,7) = x*y*z; - } - if (data.shape_derivatives.size()!=0) - { - Assert(data.shape_derivatives.size()==n_shape_functions*n_points, - ExcInternalError()); - data.derivative(k,0)[0] = (y-1.)*(1.-z); - data.derivative(k,1)[0] = (1.-y)*(1.-z); - data.derivative(k,2)[0] = -y*(1.-z); - data.derivative(k,3)[0] = y*(1.-z); - data.derivative(k,4)[0] = (y-1.)*z; - data.derivative(k,5)[0] = (1.-y)*z; - data.derivative(k,6)[0] = -y*z; - data.derivative(k,7)[0] = y*z; - data.derivative(k,0)[1] = (x-1.)*(1.-z); - data.derivative(k,1)[1] = -x*(1.-z); - data.derivative(k,2)[1] = (1.-x)*(1.-z); - data.derivative(k,3)[1] = x*(1.-z); - data.derivative(k,4)[1] = (x-1.)*z; - data.derivative(k,5)[1] = -x*z; - data.derivative(k,6)[1] = (1.-x)*z; - data.derivative(k,7)[1] = x*z; - data.derivative(k,0)[2] = (x-1)*(1.-y); - data.derivative(k,1)[2] = x*(y-1.); - data.derivative(k,2)[2] = (x-1.)*y; - data.derivative(k,3)[2] = -x*y; - data.derivative(k,4)[2] = (1.-x)*(1.-y); - data.derivative(k,5)[2] = x*(1.-y); - data.derivative(k,6)[2] = (1.-x)*y; - data.derivative(k,7)[2] = x*y; - } - if (data.shape_second_derivatives.size()!=0) - { - // the following may or may not - // work if dim != spacedim - Assert (spacedim == 3, ExcNotImplemented()); - - Assert(data.shape_second_derivatives.size()==n_shape_functions*n_points, - ExcInternalError()); - data.second_derivative(k,0)[0][0] = 0; - data.second_derivative(k,1)[0][0] = 0; - data.second_derivative(k,2)[0][0] = 0; - data.second_derivative(k,3)[0][0] = 0; - data.second_derivative(k,4)[0][0] = 0; - data.second_derivative(k,5)[0][0] = 0; - data.second_derivative(k,6)[0][0] = 0; - data.second_derivative(k,7)[0][0] = 0; - data.second_derivative(k,0)[1][1] = 0; - data.second_derivative(k,1)[1][1] = 0; - data.second_derivative(k,2)[1][1] = 0; - data.second_derivative(k,3)[1][1] = 0; - data.second_derivative(k,4)[1][1] = 0; - data.second_derivative(k,5)[1][1] = 0; - data.second_derivative(k,6)[1][1] = 0; - data.second_derivative(k,7)[1][1] = 0; - data.second_derivative(k,0)[2][2] = 0; - data.second_derivative(k,1)[2][2] = 0; - data.second_derivative(k,2)[2][2] = 0; - data.second_derivative(k,3)[2][2] = 0; - data.second_derivative(k,4)[2][2] = 0; - data.second_derivative(k,5)[2][2] = 0; - data.second_derivative(k,6)[2][2] = 0; - data.second_derivative(k,7)[2][2] = 0; - - data.second_derivative(k,0)[0][1] = (1.-z); - data.second_derivative(k,1)[0][1] = -(1.-z); - data.second_derivative(k,2)[0][1] = -(1.-z); - data.second_derivative(k,3)[0][1] = (1.-z); - data.second_derivative(k,4)[0][1] = z; - data.second_derivative(k,5)[0][1] = -z; - data.second_derivative(k,6)[0][1] = -z; - data.second_derivative(k,7)[0][1] = z; - data.second_derivative(k,0)[1][0] = (1.-z); - data.second_derivative(k,1)[1][0] = -(1.-z); - data.second_derivative(k,2)[1][0] = -(1.-z); - data.second_derivative(k,3)[1][0] = (1.-z); - data.second_derivative(k,4)[1][0] = z; - data.second_derivative(k,5)[1][0] = -z; - data.second_derivative(k,6)[1][0] = -z; - data.second_derivative(k,7)[1][0] = z; - - data.second_derivative(k,0)[0][2] = (1.-y); - data.second_derivative(k,1)[0][2] = -(1.-y); - data.second_derivative(k,2)[0][2] = y; - data.second_derivative(k,3)[0][2] = -y; - data.second_derivative(k,4)[0][2] = -(1.-y); - data.second_derivative(k,5)[0][2] = (1.-y); - data.second_derivative(k,6)[0][2] = -y; - data.second_derivative(k,7)[0][2] = y; - data.second_derivative(k,0)[2][0] = (1.-y); - data.second_derivative(k,1)[2][0] = -(1.-y); - data.second_derivative(k,2)[2][0] = y; - data.second_derivative(k,3)[2][0] = -y; - data.second_derivative(k,4)[2][0] = -(1.-y); - data.second_derivative(k,5)[2][0] = (1.-y); - data.second_derivative(k,6)[2][0] = -y; - data.second_derivative(k,7)[2][0] = y; - - data.second_derivative(k,0)[1][2] = (1.-x); - data.second_derivative(k,1)[1][2] = x; - data.second_derivative(k,2)[1][2] = -(1.-x); - data.second_derivative(k,3)[1][2] = -x; - data.second_derivative(k,4)[1][2] = -(1.-x); - data.second_derivative(k,5)[1][2] = -x; - data.second_derivative(k,6)[1][2] = (1.-x); - data.second_derivative(k,7)[1][2] = x; - data.second_derivative(k,0)[2][1] = (1.-x); - data.second_derivative(k,1)[2][1] = x; - data.second_derivative(k,2)[2][1] = -(1.-x); - data.second_derivative(k,3)[2][1] = -x; - data.second_derivative(k,4)[2][1] = -(1.-x); - data.second_derivative(k,5)[2][1] = -x; - data.second_derivative(k,6)[2][1] = (1.-x); - data.second_derivative(k,7)[2][1] = x; - } - } + { + double x = unit_points[k](0); + double y = unit_points[k](1); + double z = unit_points[k](2); + + if (data.shape_values.size()!=0) + { + Assert(data.shape_values.size()==n_shape_functions*n_points, + ExcInternalError()); + data.shape(k,0) = (1.-x)*(1.-y)*(1.-z); + data.shape(k,1) = x*(1.-y)*(1.-z); + data.shape(k,2) = (1.-x)*y*(1.-z); + data.shape(k,3) = x*y*(1.-z); + data.shape(k,4) = (1.-x)*(1.-y)*z; + data.shape(k,5) = x*(1.-y)*z; + data.shape(k,6) = (1.-x)*y*z; + data.shape(k,7) = x*y*z; + } + if (data.shape_derivatives.size()!=0) + { + Assert(data.shape_derivatives.size()==n_shape_functions*n_points, + ExcInternalError()); + data.derivative(k,0)[0] = (y-1.)*(1.-z); + data.derivative(k,1)[0] = (1.-y)*(1.-z); + data.derivative(k,2)[0] = -y*(1.-z); + data.derivative(k,3)[0] = y*(1.-z); + data.derivative(k,4)[0] = (y-1.)*z; + data.derivative(k,5)[0] = (1.-y)*z; + data.derivative(k,6)[0] = -y*z; + data.derivative(k,7)[0] = y*z; + data.derivative(k,0)[1] = (x-1.)*(1.-z); + data.derivative(k,1)[1] = -x*(1.-z); + data.derivative(k,2)[1] = (1.-x)*(1.-z); + data.derivative(k,3)[1] = x*(1.-z); + data.derivative(k,4)[1] = (x-1.)*z; + data.derivative(k,5)[1] = -x*z; + data.derivative(k,6)[1] = (1.-x)*z; + data.derivative(k,7)[1] = x*z; + data.derivative(k,0)[2] = (x-1)*(1.-y); + data.derivative(k,1)[2] = x*(y-1.); + data.derivative(k,2)[2] = (x-1.)*y; + data.derivative(k,3)[2] = -x*y; + data.derivative(k,4)[2] = (1.-x)*(1.-y); + data.derivative(k,5)[2] = x*(1.-y); + data.derivative(k,6)[2] = (1.-x)*y; + data.derivative(k,7)[2] = x*y; + } + if (data.shape_second_derivatives.size()!=0) + { + // the following may or may not + // work if dim != spacedim + Assert (spacedim == 3, ExcNotImplemented()); + + Assert(data.shape_second_derivatives.size()==n_shape_functions*n_points, + ExcInternalError()); + data.second_derivative(k,0)[0][0] = 0; + data.second_derivative(k,1)[0][0] = 0; + data.second_derivative(k,2)[0][0] = 0; + data.second_derivative(k,3)[0][0] = 0; + data.second_derivative(k,4)[0][0] = 0; + data.second_derivative(k,5)[0][0] = 0; + data.second_derivative(k,6)[0][0] = 0; + data.second_derivative(k,7)[0][0] = 0; + data.second_derivative(k,0)[1][1] = 0; + data.second_derivative(k,1)[1][1] = 0; + data.second_derivative(k,2)[1][1] = 0; + data.second_derivative(k,3)[1][1] = 0; + data.second_derivative(k,4)[1][1] = 0; + data.second_derivative(k,5)[1][1] = 0; + data.second_derivative(k,6)[1][1] = 0; + data.second_derivative(k,7)[1][1] = 0; + data.second_derivative(k,0)[2][2] = 0; + data.second_derivative(k,1)[2][2] = 0; + data.second_derivative(k,2)[2][2] = 0; + data.second_derivative(k,3)[2][2] = 0; + data.second_derivative(k,4)[2][2] = 0; + data.second_derivative(k,5)[2][2] = 0; + data.second_derivative(k,6)[2][2] = 0; + data.second_derivative(k,7)[2][2] = 0; + + data.second_derivative(k,0)[0][1] = (1.-z); + data.second_derivative(k,1)[0][1] = -(1.-z); + data.second_derivative(k,2)[0][1] = -(1.-z); + data.second_derivative(k,3)[0][1] = (1.-z); + data.second_derivative(k,4)[0][1] = z; + data.second_derivative(k,5)[0][1] = -z; + data.second_derivative(k,6)[0][1] = -z; + data.second_derivative(k,7)[0][1] = z; + data.second_derivative(k,0)[1][0] = (1.-z); + data.second_derivative(k,1)[1][0] = -(1.-z); + data.second_derivative(k,2)[1][0] = -(1.-z); + data.second_derivative(k,3)[1][0] = (1.-z); + data.second_derivative(k,4)[1][0] = z; + data.second_derivative(k,5)[1][0] = -z; + data.second_derivative(k,6)[1][0] = -z; + data.second_derivative(k,7)[1][0] = z; + + data.second_derivative(k,0)[0][2] = (1.-y); + data.second_derivative(k,1)[0][2] = -(1.-y); + data.second_derivative(k,2)[0][2] = y; + data.second_derivative(k,3)[0][2] = -y; + data.second_derivative(k,4)[0][2] = -(1.-y); + data.second_derivative(k,5)[0][2] = (1.-y); + data.second_derivative(k,6)[0][2] = -y; + data.second_derivative(k,7)[0][2] = y; + data.second_derivative(k,0)[2][0] = (1.-y); + data.second_derivative(k,1)[2][0] = -(1.-y); + data.second_derivative(k,2)[2][0] = y; + data.second_derivative(k,3)[2][0] = -y; + data.second_derivative(k,4)[2][0] = -(1.-y); + data.second_derivative(k,5)[2][0] = (1.-y); + data.second_derivative(k,6)[2][0] = -y; + data.second_derivative(k,7)[2][0] = y; + + data.second_derivative(k,0)[1][2] = (1.-x); + data.second_derivative(k,1)[1][2] = x; + data.second_derivative(k,2)[1][2] = -(1.-x); + data.second_derivative(k,3)[1][2] = -x; + data.second_derivative(k,4)[1][2] = -(1.-x); + data.second_derivative(k,5)[1][2] = -x; + data.second_derivative(k,6)[1][2] = (1.-x); + data.second_derivative(k,7)[1][2] = x; + data.second_derivative(k,0)[2][1] = (1.-x); + data.second_derivative(k,1)[2][1] = x; + data.second_derivative(k,2)[2][1] = -(1.-x); + data.second_derivative(k,3)[2][1] = -x; + data.second_derivative(k,4)[2][1] = -(1.-x); + data.second_derivative(k,5)[2][1] = -x; + data.second_derivative(k,6)[2][1] = (1.-x); + data.second_derivative(k,7)[2][1] = x; + } + } } } } @@ -341,11 +341,11 @@ template void MappingQ1:: compute_shapes_virtual (const std::vector > &unit_points, - InternalData& data) const + InternalData& data) const { internal::MappingQ1:: compute_shapes_virtual (n_shape_functions, - unit_points, data); + unit_points, data); } @@ -355,21 +355,21 @@ UpdateFlags MappingQ1::update_once (const UpdateFlags in) const { UpdateFlags out = UpdateFlags(in & (update_transformation_values - | update_transformation_gradients)); + | update_transformation_gradients)); - // Shape function values + // Shape function values if (in & update_quadrature_points) out |= update_transformation_values; - // Shape function gradients + // Shape function gradients if (in & (update_covariant_transformation - | update_contravariant_transformation - | update_JxW_values - | update_boundary_forms - | update_normal_vectors - | update_jacobians - | update_jacobian_grads - | update_inverse_jacobians)) + | update_contravariant_transformation + | update_JxW_values + | update_boundary_forms + | update_normal_vectors + | update_jacobians + | update_jacobian_grads + | update_inverse_jacobians)) out |= update_transformation_gradients; return out; @@ -381,68 +381,68 @@ template UpdateFlags MappingQ1::update_each (const UpdateFlags in) const { - // Select flags of concern for the - // transformation. + // Select flags of concern for the + // transformation. UpdateFlags out = UpdateFlags(in & (update_quadrature_points - | update_covariant_transformation - | update_contravariant_transformation - | update_JxW_values - | update_boundary_forms - | update_normal_vectors - | update_volume_elements - | update_jacobians - | update_jacobian_grads - | update_inverse_jacobians)); - - // add flags if the respective - // quantities are necessary to - // compute what we need. note that - // some flags appear in both - // conditions and in subsequents - // set operations. this leads to - // some circular logic. the only - // way to treat this is to - // iterate. since there are 4 - // if-clauses in the loop, it will - // take at most 3 iterations to - // converge. do them: + | update_covariant_transformation + | update_contravariant_transformation + | update_JxW_values + | update_boundary_forms + | update_normal_vectors + | update_volume_elements + | update_jacobians + | update_jacobian_grads + | update_inverse_jacobians)); + + // add flags if the respective + // quantities are necessary to + // compute what we need. note that + // some flags appear in both + // conditions and in subsequents + // set operations. this leads to + // some circular logic. the only + // way to treat this is to + // iterate. since there are 4 + // if-clauses in the loop, it will + // take at most 3 iterations to + // converge. do them: for (unsigned int i=0; i<4; ++i) { - // The following is a little incorrect: - // If not applied on a face, - // update_boundary_forms does not - // make sense. On the other hand, - // it is necessary on a - // face. Currently, - // update_boundary_forms is simply - // ignored for the interior of a - // cell. + // The following is a little incorrect: + // If not applied on a face, + // update_boundary_forms does not + // make sense. On the other hand, + // it is necessary on a + // face. Currently, + // update_boundary_forms is simply + // ignored for the interior of a + // cell. if (out & (update_JxW_values - | update_normal_vectors)) - out |= update_boundary_forms; + | update_normal_vectors)) + out |= update_boundary_forms; if (out & (update_covariant_transformation - | update_JxW_values - | update_jacobians - | update_jacobian_grads - | update_boundary_forms - | update_normal_vectors)) - out |= update_contravariant_transformation; + | update_JxW_values + | update_jacobians + | update_jacobian_grads + | update_boundary_forms + | update_normal_vectors)) + out |= update_contravariant_transformation; if (out & (update_inverse_jacobians)) - out |= update_covariant_transformation; - - // The contravariant transformation - // is a Piola transformation, which - // requires the determinant of the - // Jacobi matrix of the transformation. - // Therefore these values have to be - // updated for each cell. + out |= update_covariant_transformation; + + // The contravariant transformation + // is a Piola transformation, which + // requires the determinant of the + // Jacobi matrix of the transformation. + // Therefore these values have to be + // updated for each cell. if (out & update_contravariant_transformation) - out |= update_JxW_values; + out |= update_JxW_values; if (out & update_normal_vectors) - out |= update_JxW_values; + out |= update_JxW_values; } return out; @@ -452,9 +452,9 @@ MappingQ1::update_each (const UpdateFlags in) const template void MappingQ1::compute_data (const UpdateFlags update_flags, - const Quadrature &q, - const unsigned int n_original_q_points, - InternalData &data) const + const Quadrature &q, + const unsigned int n_original_q_points, + InternalData &data) const { const unsigned int n_q_points = q.size(); @@ -490,7 +490,7 @@ MappingQ1::compute_data (const UpdateFlags update_flags, template typename Mapping::InternalDataBase * MappingQ1::get_data (const UpdateFlags update_flags, - const Quadrature& q) const + const Quadrature& q) const { InternalData* data = new InternalData(n_shape_functions); compute_data (update_flags, q, q.size(), *data); @@ -502,66 +502,66 @@ MappingQ1::get_data (const UpdateFlags update_flags, template void MappingQ1::compute_face_data (const UpdateFlags update_flags, - const Quadrature& q, - const unsigned int n_original_q_points, - InternalData& data) const + const Quadrature& q, + const unsigned int n_original_q_points, + InternalData& data) const { compute_data (update_flags, q, n_original_q_points, data); if (dim > 1) { if (data.update_flags & update_boundary_forms) - { - data.aux.resize (dim-1, std::vector > (n_original_q_points)); - - // Compute tangentials to the - // unit cell. - const unsigned int nfaces = GeometryInfo::faces_per_cell; - data.unit_tangentials.resize (nfaces*(dim-1), - std::vector > (n_original_q_points)); - if (dim==2) - { - // ensure a counterclock wise - // orientation of tangentials - static const int tangential_orientation[4]={-1,1,1,-1}; - for (unsigned int i=0; i tang; - tang[1-i/2]=tangential_orientation[i]; - std::fill (data.unit_tangentials[i].begin(), - data.unit_tangentials[i].end(), tang); - } - } - else if (dim==3) - { - for (unsigned int i=0; i tang1, tang2; - - const unsigned int nd= - GeometryInfo::unit_normal_direction[i]; - - // first tangential - // vector in direction - // of the (nd+1)%3 axis - // and inverted in case - // of unit inward normal - tang1[(nd+1)%dim]=GeometryInfo::unit_normal_orientation[i]; - // second tangential - // vector in direction - // of the (nd+2)%3 axis - tang2[(nd+2)%dim]=1.; - - // same unit tangents - // for all quadrature - // points on this face - std::fill (data.unit_tangentials[i].begin(), - data.unit_tangentials[i].end(), tang1); - std::fill (data.unit_tangentials[nfaces+i].begin(), - data.unit_tangentials[nfaces+i].end(), tang2); - } - } - } + { + data.aux.resize (dim-1, std::vector > (n_original_q_points)); + + // Compute tangentials to the + // unit cell. + const unsigned int nfaces = GeometryInfo::faces_per_cell; + data.unit_tangentials.resize (nfaces*(dim-1), + std::vector > (n_original_q_points)); + if (dim==2) + { + // ensure a counterclock wise + // orientation of tangentials + static const int tangential_orientation[4]={-1,1,1,-1}; + for (unsigned int i=0; i tang; + tang[1-i/2]=tangential_orientation[i]; + std::fill (data.unit_tangentials[i].begin(), + data.unit_tangentials[i].end(), tang); + } + } + else if (dim==3) + { + for (unsigned int i=0; i tang1, tang2; + + const unsigned int nd= + GeometryInfo::unit_normal_direction[i]; + + // first tangential + // vector in direction + // of the (nd+1)%3 axis + // and inverted in case + // of unit inward normal + tang1[(nd+1)%dim]=GeometryInfo::unit_normal_orientation[i]; + // second tangential + // vector in direction + // of the (nd+2)%3 axis + tang2[(nd+2)%dim]=1.; + + // same unit tangents + // for all quadrature + // points on this face + std::fill (data.unit_tangentials[i].begin(), + data.unit_tangentials[i].end(), tang1); + std::fill (data.unit_tangentials[nfaces+i].begin(), + data.unit_tangentials[nfaces+i].end(), tang2); + } + } + } } } @@ -570,13 +570,13 @@ MappingQ1::compute_face_data (const UpdateFlags update_flags, template typename Mapping::InternalDataBase * MappingQ1::get_face_data (const UpdateFlags update_flags, - const Quadrature &quadrature) const + const Quadrature &quadrature) const { InternalData* data = new InternalData(n_shape_functions); compute_face_data (update_flags, - QProjector::project_to_all_faces(quadrature), - quadrature.size(), - *data); + QProjector::project_to_all_faces(quadrature), + quadrature.size(), + *data); return data; } @@ -586,13 +586,13 @@ MappingQ1::get_face_data (const UpdateFlags update_flags, template typename Mapping::InternalDataBase * MappingQ1::get_subface_data (const UpdateFlags update_flags, - const Quadrature& quadrature) const + const Quadrature& quadrature) const { InternalData* data = new InternalData(n_shape_functions); compute_face_data (update_flags, - QProjector::project_to_all_subfaces(quadrature), - quadrature.size(), - *data); + QProjector::project_to_all_subfaces(quadrature), + quadrature.size(), + *data); return data; } @@ -602,23 +602,23 @@ MappingQ1::get_subface_data (const UpdateFlags update_flags, template void MappingQ1::compute_fill (const typename Triangulation::cell_iterator &cell, - const unsigned int n_q_points, - const DataSetDescriptor data_set, - const CellSimilarity::Similarity cell_similarity, - InternalData &data, - std::vector > &quadrature_points) const + const unsigned int n_q_points, + const DataSetDescriptor data_set, + const CellSimilarity::Similarity cell_similarity, + InternalData &data, + std::vector > &quadrature_points) const { const UpdateFlags update_flags(data.current_update_flags()); - // if necessary, recompute the - // support points of the - // transformation of this cell - // (note that we need to first - // check the triangulation pointer, - // since otherwise the second test - // might trigger an exception if - // the triangulations are not the - // same) + // if necessary, recompute the + // support points of the + // transformation of this cell + // (note that we need to first + // check the triangulation pointer, + // since otherwise the second test + // might trigger an exception if + // the triangulations are not the + // same) if ((data.mapping_support_points.size() == 0) || (&cell->get_triangulation() != @@ -636,15 +636,15 @@ MappingQ1::compute_fill (const typename Triangulation result = (shape[0] * - data.mapping_support_points[0]); - for (unsigned int k=1; k result = (shape[0] * + data.mapping_support_points[0]); + for (unsigned int k=1; k::compute_fill (const typename Triangulation()); - - Assert (data.n_shape_functions > 0, ExcInternalError()); - const Tensor<1,spacedim> *supp_pts = - &data.mapping_support_points[0]; - - for (unsigned int point=0; point * data_derv = - &data.derivative(point+data_set, 0); - - double result [spacedim][dim]; - - // peel away part of sum to avoid zeroing the - // entries and adding for the first time - for (unsigned int i=0; i()); + + Assert (data.n_shape_functions > 0, ExcInternalError()); + const Tensor<1,spacedim> *supp_pts = + &data.mapping_support_points[0]; + + for (unsigned int point=0; point * data_derv = + &data.derivative(point+data_set, 0); + + double result [spacedim][dim]; + + // peel away part of sum to avoid zeroing the + // entries and adding for the first time + for (unsigned int i=0; i::fill_fe_values ( std::vector > &normal_vectors, CellSimilarity::Similarity &cell_similarity) const { - // ensure that the following cast - // is really correct: + // ensure that the following cast + // is really correct: Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); InternalData &data = static_cast(mapping_data); const unsigned int n_q_points=q.size(); @@ -757,153 +757,153 @@ MappingQ1::fill_fe_values ( const UpdateFlags update_flags(data.current_update_flags()); const std::vector &weights=q.get_weights(); - // Multiply quadrature weights by - // Jacobian determinants or the area - // element g=sqrt(DX^t DX) in case of - // codim > 0 + // Multiply quadrature weights by + // Jacobian determinants or the area + // element g=sqrt(DX^t DX) in case of + // codim > 0 if (update_flags & (update_normal_vectors - | update_JxW_values)) + | update_JxW_values)) { AssertDimension (JxW_values.size(), n_q_points); Assert( !(update_flags & update_normal_vectors ) || - (normal_vectors.size() == n_q_points), - ExcDimensionMismatch(normal_vectors.size(), n_q_points)); + (normal_vectors.size() == n_q_points), + ExcDimensionMismatch(normal_vectors.size(), n_q_points)); if (cell_similarity != CellSimilarity::translation) - for (unsigned int point=0; point0 case - { - Tensor<1, spacedim> DX_t [dim]; - for (unsigned int i=0; i G; //First fundamental form - for (unsigned int i=0; idirection_flag() == false) - normal_vectors[point] *= -1.; - } - - } - } //codim>0 case - - } + for (unsigned int point=0; point0 case + { + Tensor<1, spacedim> DX_t [dim]; + for (unsigned int i=0; i G; //First fundamental form + for (unsigned int i=0; idirection_flag() == false) + normal_vectors[point] *= -1.; + } + + } + } //codim>0 case + + } } - // copy values from InternalData to - // vector given by reference + // copy values from InternalData to + // vector given by reference if (update_flags & update_jacobians) { AssertDimension (jacobians.size(), n_q_points); if (cell_similarity != CellSimilarity::translation) - for (unsigned int point=0; point()); - - - const unsigned int data_set = DataSetDescriptor::cell(); - - for (unsigned int point=0; point * second = - &data.second_derivative(point+data_set, 0); - double result [spacedim][dim][dim]; - for (unsigned int i=0; i()); + + + const unsigned int data_set = DataSetDescriptor::cell(); + + for (unsigned int point=0; point * second = + &data.second_derivative(point+data_set, 0); + double result [spacedim][dim][dim]; + for (unsigned int i=0; i void compute_fill_face (const dealii::MappingQ1 &mapping, - const typename dealii::Triangulation::cell_iterator &cell, - const unsigned int face_no, - const unsigned int subface_no, - const unsigned int n_q_points, - const std::vector &weights, - typename dealii::MappingQ1::InternalData &data, - std::vector &JxW_values, - std::vector > &boundary_forms, - std::vector > &normal_vectors) + const typename dealii::Triangulation::cell_iterator &cell, + const unsigned int face_no, + const unsigned int subface_no, + const unsigned int n_q_points, + const std::vector &weights, + typename dealii::MappingQ1::InternalData &data, + std::vector &JxW_values, + std::vector > &boundary_forms, + std::vector > &normal_vectors) { const UpdateFlags update_flags(data.current_update_flags()); if (update_flags & update_boundary_forms) - { - AssertDimension (boundary_forms.size(), n_q_points); - if (update_flags & update_normal_vectors) - AssertDimension (normal_vectors.size(), n_q_points); - if (update_flags & update_JxW_values) - AssertDimension (JxW_values.size(), n_q_points); - - // map the unit tangentials to the - // real cell. checking for d!=dim-1 - // eliminates compiler warnings - // regarding unsigned expressions < - // 0. - for (unsigned int d=0; d!=dim-1; ++d) - { - Assert (face_no+GeometryInfo::faces_per_cell*d < - data.unit_tangentials.size(), - ExcInternalError()); - Assert (data.aux[d].size() <= - data.unit_tangentials[face_no+GeometryInfo::faces_per_cell*d].size(), - ExcInternalError()); - - mapping.transform (data.unit_tangentials[face_no+GeometryInfo::faces_per_cell*d], - data.aux[d], - data, - mapping_contravariant); - } - - // if dim==spacedim, we can use the - // unit tangentials to compute the - // boundary form by simply taking - // the cross product - if (dim == spacedim) - { - for (unsigned int i=0; i cell_normal; - const DerivativeForm<1,spacedim,dim> DX_t = - data.contravariant[point].transpose(); - cross_product(cell_normal,DX_t[0],DX_t[1]); - cell_normal /= cell_normal.norm(); - - // then compute the face - // normal from the face - // tangent and the cell - // normal: - cross_product (boundary_forms[point], - data.aux[0][point], cell_normal); - - } - - } - } - - - - if (update_flags & (update_normal_vectors - | update_JxW_values)) - for (unsigned int i=0;i::subface_ratio( - cell->subface_case(face_no), subface_no); - JxW_values[i] *= area_ratio; - } - } - - if (update_flags & update_normal_vectors) - normal_vectors[i] = boundary_forms[i] / boundary_forms[i].norm(); - } - } + { + AssertDimension (boundary_forms.size(), n_q_points); + if (update_flags & update_normal_vectors) + AssertDimension (normal_vectors.size(), n_q_points); + if (update_flags & update_JxW_values) + AssertDimension (JxW_values.size(), n_q_points); + + // map the unit tangentials to the + // real cell. checking for d!=dim-1 + // eliminates compiler warnings + // regarding unsigned expressions < + // 0. + for (unsigned int d=0; d!=dim-1; ++d) + { + Assert (face_no+GeometryInfo::faces_per_cell*d < + data.unit_tangentials.size(), + ExcInternalError()); + Assert (data.aux[d].size() <= + data.unit_tangentials[face_no+GeometryInfo::faces_per_cell*d].size(), + ExcInternalError()); + + mapping.transform (data.unit_tangentials[face_no+GeometryInfo::faces_per_cell*d], + data.aux[d], + data, + mapping_contravariant); + } + + // if dim==spacedim, we can use the + // unit tangentials to compute the + // boundary form by simply taking + // the cross product + if (dim == spacedim) + { + for (unsigned int i=0; i cell_normal; + const DerivativeForm<1,spacedim,dim> DX_t = + data.contravariant[point].transpose(); + cross_product(cell_normal,DX_t[0],DX_t[1]); + cell_normal /= cell_normal.norm(); + + // then compute the face + // normal from the face + // tangent and the cell + // normal: + cross_product (boundary_forms[point], + data.aux[0][point], cell_normal); + + } + + } + } + + + + if (update_flags & (update_normal_vectors + | update_JxW_values)) + for (unsigned int i=0;i::subface_ratio( + cell->subface_case(face_no), subface_no); + JxW_values[i] *= area_ratio; + } + } + + if (update_flags & update_normal_vectors) + normal_vectors[i] = boundary_forms[i] / boundary_forms[i].norm(); + } + } } } } @@ -1087,11 +1087,11 @@ MappingQ1::compute_fill_face ( std::vector > &normal_vectors) const { compute_fill (cell, n_q_points, data_set, CellSimilarity::none, - data, quadrature_points); + data, quadrature_points); internal::compute_fill_face (*this, - cell, face_no, subface_no, n_q_points, - weights, data, - JxW_values, boundary_forms, normal_vectors); + cell, face_no, subface_no, n_q_points, + weights, data, + JxW_values, boundary_forms, normal_vectors); } @@ -1099,35 +1099,35 @@ template void MappingQ1:: fill_fe_face_values (const typename Triangulation::cell_iterator &cell, - const unsigned int face_no, - const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, - std::vector > &quadrature_points, - std::vector &JxW_values, - std::vector > &boundary_forms, - std::vector > &normal_vectors) const + const unsigned int face_no, + const Quadrature &q, + typename Mapping::InternalDataBase &mapping_data, + std::vector > &quadrature_points, + std::vector &JxW_values, + std::vector > &boundary_forms, + std::vector > &normal_vectors) const { - // ensure that the following cast - // is really correct: + // ensure that the following cast + // is really correct: Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); InternalData &data = static_cast(mapping_data); const unsigned int n_q_points = q.size(); compute_fill_face (cell, face_no, deal_II_numbers::invalid_unsigned_int, - n_q_points, - DataSetDescriptor::face (face_no, + n_q_points, + DataSetDescriptor::face (face_no, cell->face_orientation(face_no), cell->face_flip(face_no), cell->face_rotation(face_no), n_q_points), - q.get_weights(), - data, - quadrature_points, - JxW_values, - boundary_forms, - normal_vectors); + q.get_weights(), + data, + quadrature_points, + JxW_values, + boundary_forms, + normal_vectors); } @@ -1136,37 +1136,37 @@ template void MappingQ1:: fill_fe_subface_values (const typename Triangulation::cell_iterator &cell, - const unsigned int face_no, - const unsigned int sub_no, - const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, - std::vector > &quadrature_points, - std::vector &JxW_values, - std::vector > &boundary_forms, - std::vector > &normal_vectors) const + const unsigned int face_no, + const unsigned int sub_no, + const Quadrature &q, + typename Mapping::InternalDataBase &mapping_data, + std::vector > &quadrature_points, + std::vector &JxW_values, + std::vector > &boundary_forms, + std::vector > &normal_vectors) const { - // ensure that the following cast - // is really correct: + // ensure that the following cast + // is really correct: Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); InternalData &data = static_cast(mapping_data); const unsigned int n_q_points = q.size(); compute_fill_face (cell, face_no, sub_no, - n_q_points, - DataSetDescriptor::subface (face_no, sub_no, - cell->face_orientation(face_no), - cell->face_flip(face_no), - cell->face_rotation(face_no), - n_q_points, - cell->subface_case(face_no)), - q.get_weights(), - data, - quadrature_points, - JxW_values, - boundary_forms, - normal_vectors); + n_q_points, + DataSetDescriptor::subface (face_no, sub_no, + cell->face_orientation(face_no), + cell->face_flip(face_no), + cell->face_rotation(face_no), + n_q_points, + cell->subface_case(face_no)), + q.get_weights(), + data, + quadrature_points, + JxW_values, + boundary_forms, + normal_vectors); } @@ -1215,16 +1215,16 @@ MappingQ1::transform ( switch (mapping_type) { case mapping_contravariant: - transform_fields(input, output, mapping_data, mapping_type); - return; + transform_fields(input, output, mapping_data, mapping_type); + return; case mapping_piola_gradient: case mapping_contravariant_gradient: case mapping_covariant_gradient: - transform_gradients(input, output, mapping_data, mapping_type); - return; + transform_gradients(input, output, mapping_data, mapping_type); + return; default: - Assert(false, ExcNotImplemented()); + Assert(false, ExcNotImplemented()); } } @@ -1240,54 +1240,54 @@ void MappingQ1::transform_fields( { AssertDimension (input.size(), output.size()); Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); const InternalData &data = static_cast(mapping_data); switch (mapping_type) { case mapping_contravariant: { - Assert (data.update_flags & update_contravariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField()); + Assert (data.update_flags & update_contravariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField()); - for (unsigned int i=0; i::ExcAccessToUninitializedField()); - Assert (data.update_flags & update_volume_elements, - typename FEValuesBase::ExcAccessToUninitializedField()); - Assert (rank==1, ExcMessage("Only for rank 1")); - for (unsigned int i=0; i::ExcAccessToUninitializedField()); + Assert (data.update_flags & update_volume_elements, + typename FEValuesBase::ExcAccessToUninitializedField()); + Assert (rank==1, ExcMessage("Only for rank 1")); + for (unsigned int i=0; i::ExcAccessToUninitializedField()); + Assert (data.update_flags & update_contravariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField()); - for (unsigned int i=0; i::transform_gradients( { AssertDimension (input.size(), output.size()); Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); const InternalData &data = static_cast(mapping_data); switch (mapping_type) { case mapping_contravariant_gradient: { - Assert (data.update_flags & update_covariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField()); - Assert (data.update_flags & update_contravariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField()); - Assert (rank==2, ExcMessage("Only for rank 2")); - - for (unsigned int i=0; i A = - apply_transformation(data.contravariant[i], transpose(input[i]) ); - output[i] = apply_transformation(data.covariant[i], A.transpose() ); - } - - return; + Assert (data.update_flags & update_covariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField()); + Assert (data.update_flags & update_contravariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField()); + Assert (rank==2, ExcMessage("Only for rank 2")); + + for (unsigned int i=0; i A = + apply_transformation(data.contravariant[i], transpose(input[i]) ); + output[i] = apply_transformation(data.covariant[i], A.transpose() ); + } + + return; } case mapping_covariant_gradient: { - Assert (data.update_flags & update_covariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField()); - Assert (data.update_flags & update_contravariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField()); - Assert (rank==2, ExcMessage("Only for rank 2")); + Assert (data.update_flags & update_covariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField()); + Assert (data.update_flags & update_contravariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField()); + Assert (rank==2, ExcMessage("Only for rank 2")); - for (unsigned int i=0; i A = - apply_transformation(data.covariant[i], transpose(input[i]) ); - output[i] = apply_transformation(data.covariant[i], A.transpose() ); + for (unsigned int i=0; i A = + apply_transformation(data.covariant[i], transpose(input[i]) ); + output[i] = apply_transformation(data.covariant[i], A.transpose() ); - } + } - return; + return; } @@ -1349,30 +1349,30 @@ void MappingQ1::transform_gradients( case mapping_piola_gradient: { - Assert (data.update_flags & update_covariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField()); - Assert (data.update_flags & update_contravariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField()); - Assert (data.update_flags & update_volume_elements, - typename FEValuesBase::ExcAccessToUninitializedField()); - Assert (rank==2, ExcMessage("Only for rank 2")); - - for (unsigned int i=0; i A = - apply_transformation(data.covariant[i], input[i] ); - Tensor<2,spacedim> T = - apply_transformation(data.contravariant[i], A.transpose() ); - - output[i] = transpose(T); - output[i] /= data.volume_elements[i]; - } - - return; + Assert (data.update_flags & update_covariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField()); + Assert (data.update_flags & update_contravariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField()); + Assert (data.update_flags & update_volume_elements, + typename FEValuesBase::ExcAccessToUninitializedField()); + Assert (rank==2, ExcMessage("Only for rank 2")); + + for (unsigned int i=0; i A = + apply_transformation(data.covariant[i], input[i] ); + Tensor<2,spacedim> T = + apply_transformation(data.contravariant[i], A.transpose() ); + + output[i] = transpose(T); + output[i] /= data.volume_elements[i]; + } + + return; } default: - Assert(false, ExcNotImplemented()); + Assert(false, ExcNotImplemented()); } } @@ -1390,23 +1390,23 @@ void MappingQ1::transform_differential_forms( AssertDimension (input.size(), output.size()); Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); + ExcInternalError()); const InternalData &data = static_cast(mapping_data); switch (mapping_type) { case mapping_covariant: { - Assert (data.update_flags & update_contravariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField()); + Assert (data.update_flags & update_contravariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField()); - for (unsigned int i=0; i::transform_unit_to_real_cell ( const typename Triangulation::cell_iterator& cell, const Point& p) const { - // Use the get_data function to - // create an InternalData with data - // vectors of the right size and - // transformation shape values - // already computed at point p. + // Use the get_data function to + // create an InternalData with data + // vectors of the right size and + // transformation shape values + // already computed at point p. const Quadrature point_quadrature(p); std::auto_ptr mdata (dynamic_cast ( get_data(update_transformation_values, point_quadrature))); - // compute the mapping support - // points + // compute the mapping support + // points compute_mapping_support_points(cell, mdata->mapping_support_points); - // Mapping support points can be - // bigger than necessary. If this - // is the case, force them to be - // Q1. + // Mapping support points can be + // bigger than necessary. If this + // is the case, force them to be + // Q1. if(mdata->mapping_support_points.size() > mdata->shape_values.size()) mdata->mapping_support_points.resize (GeometryInfo::vertices_per_cell); @@ -1459,8 +1459,8 @@ transform_unit_to_real_cell_internal (const InternalData &data) const const unsigned int n_mapping_points=data.mapping_support_points.size(); AssertDimension (data.shape_values.size(), n_mapping_points); - // use now the InternalData to - // compute the point in real space. + // use now the InternalData to + // compute the point in real space. Point p_real; for (unsigned int i=0; i @@ -1494,8 +1494,8 @@ namespace TransformR2UInitialGuess<1>:: KA[GeometryInfo<1>::vertices_per_cell][1] = { - {-1.000000}, - {1.000000} + {-1.000000}, + {1.000000} }; template <> @@ -1564,7 +1564,7 @@ template Point MappingQ1:: transform_real_to_unit_cell_initial_guess (const std::vector > &vertex, - const Point &p) const + const Point &p) const { Point p_unit; @@ -1617,47 +1617,47 @@ transform_real_to_unit_cell (const typename Triangulation::cell_it { - // Find the initial value for the - // Newton iteration by a normal projection - // to the least square plane determined by - // the vertices of the cell + // Find the initial value for the + // Newton iteration by a normal projection + // to the least square plane determined by + // the vertices of the cell std::vector > a; compute_mapping_support_points (cell,a); Point p_unit = transform_real_to_unit_cell_initial_guess(a,p); - // if dim==1 there is nothing - // else to do the initial value is the answer. + // if dim==1 there is nothing + // else to do the initial value is the answer. if (dim>1) { - // Use the get_data function to - // create an InternalData with data - // vectors of the right size and - // transformation shape values and - // derivatives already computed at - // point p_unit. + // Use the get_data function to + // create an InternalData with data + // vectors of the right size and + // transformation shape values and + // derivatives already computed at + // point p_unit. const Quadrature point_quadrature(p_unit); UpdateFlags update_flags = update_transformation_values| update_transformation_gradients; if (spacedim>dim) - update_flags |= update_jacobian_grads; + update_flags |= update_jacobian_grads; std::auto_ptr - mdata(dynamic_cast ( - MappingQ1::get_data(update_flags, point_quadrature))); + mdata(dynamic_cast ( + MappingQ1::get_data(update_flags, point_quadrature))); compute_mapping_support_points (cell, mdata->mapping_support_points); - // The support points have to be at - // least as many as there are - // vertices. + // The support points have to be at + // least as many as there are + // vertices. Assert(mdata->mapping_support_points.size() >= - GeometryInfo::vertices_per_cell, - ExcInternalError()); - // Ignore non vertex support points. + GeometryInfo::vertices_per_cell, + ExcInternalError()); + // Ignore non vertex support points. mdata->mapping_support_points.resize(GeometryInfo::vertices_per_cell); - // perform the newton iteration. + // perform the newton iteration. transform_real_to_unit_cell_internal(cell, p, *mdata, p_unit); } @@ -1683,21 +1683,21 @@ transform_real_to_unit_cell_internal AssertDimension (points.size(), n_shapes); - // Newton iteration to solve - // f(x)=p(x)-p=0 - // x_{n+1}=x_n-[f'(x)]^{-1}f(x) + // Newton iteration to solve + // f(x)=p(x)-p=0 + // x_{n+1}=x_n-[f'(x)]^{-1}f(x) - // The start value was set to be the - // linear approximation to the cell + // The start value was set to be the + // linear approximation to the cell - // The shape values and derivatives - // of the mapping at this point are - // previously computed. + // The shape values and derivatives + // of the mapping at this point are + // previously computed. - // For the <2,3> case there is a - // template specialization. + // For the <2,3> case there is a + // template specialization. - // f(x) + // f(x) compute_shapes(std::vector > (1, p_unit), mdata); Point p_real(transform_unit_to_real_cell_internal(mdata)); @@ -1709,55 +1709,55 @@ transform_real_to_unit_cell_internal unsigned int loop=0; while (f.square()>eps*eps && loop++ df; for (unsigned int k=0; k &grad_transform=mdata.derivative(0,k); - const Point &point=points[k]; + { + const Tensor<1,dim> &grad_transform=mdata.derivative(0,k); + const Point &point=points[k]; - for (unsigned int i=0; i d; Tensor<2,spacedim> df_1; df_1 = invert(df); contract (d, df_1, static_cast&>(f)); - // update of p_unit. The - // spacedimth component of - // transformed point is simply - // ignored in codimension one - // case. When this component is - // not zero, then we are - // projecting the point to the - // surface or curve identified - // by the cell. + // update of p_unit. The + // spacedimth component of + // transformed point is simply + // ignored in codimension one + // case. When this component is + // not zero, then we are + // projecting the point to the + // surface or curve identified + // by the cell. for(unsigned int i=0;i > (1, p_unit), mdata); - // f(x) + // f(x) p_real = transform_unit_to_real_cell_internal(mdata); f = p_real-p; } - // Here we check that in the last - // execution of while the first - // condition was already wrong, - // meaning the residual was below - // eps. Only if the first condition - // failed, loop will have been - // increased and tested, and thus - // havereached the limit. + // Here we check that in the last + // execution of while the first + // condition was already wrong, + // meaning the residual was below + // eps. Only if the first condition + // failed, loop will have been + // increased and tested, and thus + // havereached the limit. AssertThrow(loop void MappingQ1<2,3>:: transform_real_to_unit_cell_internal (const Triangulation<2,3>::cell_iterator &cell, - const Point<3> &p, - InternalData &mdata, - Point<2> &p_unit) const + const Point<3> &p, + InternalData &mdata, + Point<2> &p_unit) const { transform_real_to_unit_cell_internal_codim1(cell,p, mdata, p_unit); } @@ -1795,9 +1795,9 @@ transform_real_to_unit_cell_internal (const Triangulation<2,3>::cell_iterator &c template<> void MappingQ1<1,2>:: transform_real_to_unit_cell_internal (const Triangulation<1,2>::cell_iterator &cell, - const Point<2> &p, - InternalData &mdata, - Point<1> &p_unit) const + const Point<2> &p, + InternalData &mdata, + Point<1> &p_unit) const { transform_real_to_unit_cell_internal_codim1(cell,p, mdata, p_unit); } @@ -1805,9 +1805,9 @@ transform_real_to_unit_cell_internal (const Triangulation<1,2>::cell_iterator &c template<> void MappingQ1<1,3>:: transform_real_to_unit_cell_internal (const Triangulation<1,3>::cell_iterator &/*cell*/, - const Point<3> &/*p*/, - InternalData &/*mdata*/, - Point<1> &/*p_unit*/) const + const Point<3> &/*p*/, + InternalData &/*mdata*/, + Point<1> &/*p_unit*/) const { Assert(false, ExcNotImplemented()); } @@ -1845,7 +1845,7 @@ transform_real_to_unit_cell_internal_codim1 Point f; Tensor<2,dim1> df; - //Evaluate first and second derivatives + //Evaluate first and second derivatives compute_shapes(std::vector > (1, p_unit), mdata); for (unsigned int k=0; k &point_k = points[k]; for (unsigned int j=0; jeps && loop++ d; Tensor<2,dim1> df_1; @@ -1892,48 +1892,48 @@ transform_real_to_unit_cell_internal_codim1 p_unit -= d; for (unsigned int j=0; j > (1, p_unit), mdata); for (unsigned int k=0; k &grad_phi_k = mdata.derivative(0,k); - const Tensor<2,dim1> &hessian_k = mdata.second_derivative(0,k); - const Point &point_k = points[k]; - - for (unsigned int j=0; j &grad_phi_k = mdata.derivative(0,k); + const Tensor<2,dim1> &hessian_k = mdata.second_derivative(0,k); + const Point &point_k = points[k]; + + for (unsigned int j=0; j MappingQ1Eulerian:: MappingQ1Eulerian (const EulerVectorType &euler_transform_vectors, - const DoFHandler &shiftmap_dof_handler) + const DoFHandler &shiftmap_dof_handler) : - euler_transform_vectors(&euler_transform_vectors), - shiftmap_dof_handler(&shiftmap_dof_handler) + euler_transform_vectors(&euler_transform_vectors), + shiftmap_dof_handler(&shiftmap_dof_handler) {} @@ -38,16 +38,16 @@ template void MappingQ1Eulerian:: compute_mapping_support_points(const typename Triangulation::cell_iterator &cell, - std::vector > &a) const + std::vector > &a) const { - // The assertions can not be in the - // constructor, since this would - // require to call - // dof_handler.distribute_dofs(fe) - // *before* the mapping object is - // constructed, which is not - // necessarily what we want. + // The assertions can not be in the + // constructor, since this would + // require to call + // dof_handler.distribute_dofs(fe) + // *before* the mapping object is + // constructed, which is not + // necessarily what we want. //TODO: Only one of these two assertions should be relevant AssertDimension (spacedim, shiftmap_dof_handler->get_fe().n_dofs_per_vertex()); @@ -55,30 +55,30 @@ compute_mapping_support_points(const typename Triangulation::cell_ AssertDimension (shiftmap_dof_handler->n_dofs(), euler_transform_vectors->size()); - // cast the - // Triangulation::cell_iterator - // into a - // DoFHandler::cell_iterator - // which is necessary for access to - // DoFCellAccessor::get_dof_values() + // cast the + // Triangulation::cell_iterator + // into a + // DoFHandler::cell_iterator + // which is necessary for access to + // DoFCellAccessor::get_dof_values() typename DoFHandler::cell_iterator dof_cell (const_cast *> (&(cell->get_triangulation())), - cell->level(), - cell->index(), - shiftmap_dof_handler); + cell->level(), + cell->index(), + shiftmap_dof_handler); - // We require the cell to be active - // since we can only then get nodal - // values for the shifts + // We require the cell to be active + // since we can only then get nodal + // values for the shifts Assert (dof_cell->active() == true, ExcInactiveCell()); - // for Q1 elements, the number of - // support points should equal the - // number of vertices + // for Q1 elements, the number of + // support points should equal the + // number of vertices a.resize(GeometryInfo::vertices_per_cell); - // now get the values of the shift - // vectors at the vertices + // now get the values of the shift + // vectors at the vertices Vector mapping_values (shiftmap_dof_handler->get_fe().dofs_per_cell); dof_cell->get_dof_values (*euler_transform_vectors, mapping_values); @@ -87,17 +87,17 @@ compute_mapping_support_points(const typename Triangulation::cell_ { Point shift_vector; - // pick out the value of the - // shift vector at the present - // vertex. since vertex dofs - // are always numbered first, - // we can access them easily + // pick out the value of the + // shift vector at the present + // vertex. since vertex dofs + // are always numbered first, + // we can access them easily for (unsigned int j=0; jvertex(i) + shift_vector; } } @@ -127,14 +127,14 @@ MappingQ1Eulerian::fill_fe_values ( std::vector > &normal_vectors, CellSimilarity::Similarity &cell_similarity) const { - // disable any previously detected - // similarity and then enter the - // respective function of the base class. + // disable any previously detected + // similarity and then enter the + // respective function of the base class. cell_similarity = CellSimilarity::invalid_next_cell; MappingQ1::fill_fe_values (cell, q, mapping_data, - quadrature_points, JxW_values, jacobians, - jacobian_grads, inverse_jacobians, - normal_vectors, cell_similarity); + quadrature_points, JxW_values, jacobians, + jacobian_grads, inverse_jacobians, + normal_vectors, cell_similarity); } diff --git a/deal.II/source/fe/mapping_q_eulerian.cc b/deal.II/source/fe/mapping_q_eulerian.cc index ed5625b50f..9fbbfc3a97 100644 --- a/deal.II/source/fe/mapping_q_eulerian.cc +++ b/deal.II/source/fe/mapping_q_eulerian.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -32,16 +32,16 @@ DEAL_II_NAMESPACE_OPEN template MappingQEulerian:: MappingQEulerian (const unsigned int degree, - const EulerVectorType &euler_vector, - const DoFHandler &euler_dof_handler) - : - MappingQ(degree, true), - euler_vector(&euler_vector), - euler_dof_handler(&euler_dof_handler), - support_quadrature(degree), - fe_values(euler_dof_handler.get_fe(), - support_quadrature, - update_values | update_q_points) + const EulerVectorType &euler_vector, + const DoFHandler &euler_dof_handler) + : + MappingQ(degree, true), + euler_vector(&euler_vector), + euler_dof_handler(&euler_dof_handler), + support_quadrature(degree), + fe_values(euler_dof_handler.get_fe(), + support_quadrature, + update_values | update_q_points) { } @@ -51,8 +51,8 @@ Mapping * MappingQEulerian::clone () const { return new MappingQEulerian(this->get_degree(), - *euler_vector, - *euler_dof_handler); + *euler_vector, + *euler_dof_handler); } @@ -63,22 +63,22 @@ template MappingQEulerian:: SupportQuadrature:: SupportQuadrature (const unsigned int map_degree) - : - Quadrature(Utilities::fixed_power(map_degree+1)) + : + Quadrature(Utilities::fixed_power(map_degree+1)) { - // first we determine the support points - // on the unit cell in lexicographic order. - // for this purpose we can use an interated - // trapezoidal quadrature rule. + // first we determine the support points + // on the unit cell in lexicographic order. + // for this purpose we can use an interated + // trapezoidal quadrature rule. const QTrapez<1> q1d; const QIterated q_iterated(q1d,map_degree); const unsigned int n_q_points = q_iterated.size(); - // we then need to define a renumbering - // vector that allows us to go from a - // lexicographic numbering scheme to a hierarchic - // one. this fragment is taking almost verbatim - // from the MappingQ class. + // we then need to define a renumbering + // vector that allows us to go from a + // lexicographic numbering scheme to a hierarchic + // one. this fragment is taking almost verbatim + // from the MappingQ class. std::vector renumber(n_q_points); std::vector dpo(dim+1, 1U); @@ -88,8 +88,8 @@ SupportQuadrature (const unsigned int map_degree) FETools::lexicographic_to_hierarchic_numbering ( FiniteElementData (dpo, 1, map_degree), renumber); - // finally we assign the quadrature points in the - // required order. + // finally we assign the quadrature points in the + // required order. for(unsigned int q=0; qquadrature_points[renumber[q]] = q_iterated.point(q); @@ -107,18 +107,18 @@ compute_mapping_support_points std::vector > &a) const { - // first, basic assertion - // with respect to vector size, + // first, basic assertion + // with respect to vector size, const unsigned int n_dofs = euler_dof_handler->n_dofs(); const unsigned int vector_size = euler_vector->size(); AssertDimension(vector_size,n_dofs); - // we then transform our tria iterator - // into a dof iterator so we can - // access data not associated with - // triangulations + // we then transform our tria iterator + // into a dof iterator so we can + // access data not associated with + // triangulations typename DoFHandler::cell_iterator dof_cell (const_cast *> (&(cell->get_triangulation())), @@ -128,27 +128,27 @@ compute_mapping_support_points Assert (dof_cell->active() == true, ExcInactiveCell()); - // our quadrature rule is chosen - // so that each quadrature point - // corresponds to a support point - // in the undeformed configuration. - // we can then query the given - // displacement field at these points - // to determine the shift vector that - // maps the support points to the - // deformed configuration. - - // we assume that the given field contains - // dim displacement components, but - // that there may be other solution - // components as well (e.g. pressures). - // this class therefore assumes that the - // first dim components represent the - // actual shift vector we need, and simply - // ignores any components after that. - // this implies that the user should order - // components appropriately, or create a - // separate dof handler for the displacements. + // our quadrature rule is chosen + // so that each quadrature point + // corresponds to a support point + // in the undeformed configuration. + // we can then query the given + // displacement field at these points + // to determine the shift vector that + // maps the support points to the + // deformed configuration. + + // we assume that the given field contains + // dim displacement components, but + // that there may be other solution + // components as well (e.g. pressures). + // this class therefore assumes that the + // first dim components represent the + // actual shift vector we need, and simply + // ignores any components after that. + // this implies that the user should order + // components appropriately, or create a + // separate dof handler for the displacements. const unsigned int n_support_pts = support_quadrature.size(); const unsigned int n_components = euler_dof_handler->get_fe().n_components(); @@ -157,26 +157,26 @@ compute_mapping_support_points std::vector > shift_vector(n_support_pts,Vector(n_components)); - // fill shift vector for each - // support point using an fe_values - // object. make sure that the - // fe_values variable isn't used - // simulatenously from different - // threads + // fill shift vector for each + // support point using an fe_values + // object. make sure that the + // fe_values variable isn't used + // simulatenously from different + // threads Threads::ThreadMutex::ScopedLock lock(fe_values_mutex); fe_values.reinit(dof_cell); fe_values.get_function_values(*euler_vector, shift_vector); - // and finally compute the positions of the - // support points in the deformed - // configuration. + // and finally compute the positions of the + // support points in the deformed + // configuration. a.resize(n_support_pts); for(unsigned int q=0; q::fill_fe_values ( std::vector > &normal_vectors, CellSimilarity::Similarity &cell_similarity) const { - // disable any previously detected - // similarity and hand on to the respective - // function of the base class. + // disable any previously detected + // similarity and hand on to the respective + // function of the base class. cell_similarity = CellSimilarity::invalid_next_cell; MappingQ::fill_fe_values (cell, q, mapping_data, - quadrature_points, JxW_values, jacobians, - jacobian_grads, inverse_jacobians, - normal_vectors, cell_similarity); + quadrature_points, JxW_values, jacobians, + jacobian_grads, inverse_jacobians, + normal_vectors, cell_similarity); } diff --git a/deal.II/source/grid/grid_generator.cc b/deal.II/source/grid/grid_generator.cc index 669c1ea4a2..88be275e47 100644 --- a/deal.II/source/grid/grid_generator.cc +++ b/deal.II/source/grid/grid_generator.cc @@ -45,29 +45,29 @@ DEAL_II_NAMESPACE_OPEN namespace { - // Corner points of the cube [-1,1]^3 + // Corner points of the cube [-1,1]^3 const Point<3> hexahedron[8] = { - Point<3>(-1,-1,-1), - Point<3>(+1,-1,-1), - Point<3>(-1,+1,-1), - Point<3>(+1,+1,-1), - Point<3>(-1,-1,+1), - Point<3>(+1,-1,+1), - Point<3>(-1,+1,+1), - Point<3>(+1,+1,+1) + Point<3>(-1,-1,-1), + Point<3>(+1,-1,-1), + Point<3>(-1,+1,-1), + Point<3>(+1,+1,-1), + Point<3>(-1,-1,+1), + Point<3>(+1,-1,+1), + Point<3>(-1,+1,+1), + Point<3>(+1,+1,+1) }; - // Octahedron inscribed in the cube - // [-1,1]^3 + // Octahedron inscribed in the cube + // [-1,1]^3 const Point<3> octahedron[6] = { - Point<3>(-1, 0, 0), - Point<3>( 1, 0, 0), - Point<3>( 0,-1, 0), - Point<3>( 0, 1, 0), - Point<3>( 0, 0,-1), - Point<3>( 0, 0, 1) + Point<3>(-1, 0, 0), + Point<3>( 1, 0, 0), + Point<3>( 0,-1, 0), + Point<3>( 0, 1, 0), + Point<3>( 0, 0,-1), + Point<3>( 0, 0, 1) }; } @@ -75,12 +75,12 @@ namespace template void GridGenerator::hyper_rectangle (Triangulation &tria, - const Point &p_1, - const Point &p_2, - const bool colorize) + const Point &p_1, + const Point &p_2, + const bool colorize) { - // First, normalize input such that - // p1 is lower in all coordinate directions. + // First, normalize input such that + // p1 is lower in all coordinate directions. Point p1(p_1); Point p2(p_2); @@ -92,36 +92,36 @@ GridGenerator::hyper_rectangle (Triangulation &tria, switch (dim) { case 1: - vertices[0] = p1; - vertices[1] = p2; - break; + vertices[0] = p1; + vertices[1] = p2; + break; case 2: - vertices[0] = vertices[1] = p1; - vertices[2] = vertices[3] = p2; + vertices[0] = vertices[1] = p1; + vertices[2] = vertices[3] = p2; - vertices[1](0) = p2(0); - vertices[2](0) = p1(0); - break; + vertices[1](0) = p2(0); + vertices[2](0) = p1(0); + break; case 3: - vertices[0] = vertices[1] = vertices[2] = vertices[3] = p1; - vertices[4] = vertices[5] = vertices[6] = vertices[7] = p2; + vertices[0] = vertices[1] = vertices[2] = vertices[3] = p1; + vertices[4] = vertices[5] = vertices[6] = vertices[7] = p2; - vertices[1](0) = p2(0); - vertices[2](1) = p2(1); - vertices[3](0) = p2(0); - vertices[3](1) = p2(1); + vertices[1](0) = p2(0); + vertices[2](1) = p2(1); + vertices[3](0) = p2(0); + vertices[3](1) = p2(1); - vertices[4](0) = p1(0); - vertices[4](1) = p1(1); - vertices[5](1) = p1(1); - vertices[6](0) = p1(0); + vertices[4](0) = p1(0); + vertices[4](1) = p1(1); + vertices[5](1) = p1(1); + vertices[6](0) = p1(0); - break; + break; default: - Assert (false, ExcNotImplemented ()); + Assert (false, ExcNotImplemented ()); } - // Prepare cell data + // Prepare cell data std::vector > cells (1); for (unsigned int i=0;i::vertices_per_cell;++i) cells[0].vertices[i] = i; @@ -129,7 +129,7 @@ GridGenerator::hyper_rectangle (Triangulation &tria, tria.create_triangulation (vertices, cells, SubCellData()); - // Assign boundary indicators + // Assign boundary indicators if (colorize) colorize_hyper_rectangle (tria); } @@ -140,15 +140,15 @@ template void GridGenerator::colorize_hyper_rectangle (Triangulation &tria) { - // there is nothing to do in 1d + // there is nothing to do in 1d if (dim > 1) { - // there is only one cell, so - // simple task + // there is only one cell, so + // simple task const typename Triangulation::cell_iterator - cell = tria.begin(); + cell = tria.begin(); for (unsigned int f=0; f::faces_per_cell; ++f) - cell->face(f)->set_boundary_indicator (f); + cell->face(f)->set_boundary_indicator (f); } } @@ -156,11 +156,11 @@ GridGenerator::colorize_hyper_rectangle (Triangulation &tria) template void GridGenerator::hyper_cube (Triangulation &tria, - const double left, - const double right) + const double left, + const double right) { Assert (left < right, - ExcMessage ("Invalid left-to-right bounds of hypercube")); + ExcMessage ("Invalid left-to-right bounds of hypercube")); Point p1; Point p2; @@ -199,9 +199,9 @@ GridGenerator::moebius ( for (unsigned int i=0; i& tria, - const double R, - const double r) + const double R, + const double r) { Assert (R>r, ExcMessage("Outer radius must be greater than inner radius.")); @@ -261,7 +261,7 @@ GridGenerator::torus (Triangulation<2,3>& tria, vertices[15]=Point(0,r,-R); std::vector > cells (16); - //Right Hand Orientation + //Right Hand Orientation cells[0].vertices[0] = 0; cells[0].vertices[1] = 4; cells[0].vertices[2] = 7; @@ -358,9 +358,9 @@ GridGenerator::torus (Triangulation<2,3>& tria, cells[15].vertices[3] = 14; cells[15].material_id = 0; - // Must call this to be able to create a - // correct triangulation in dealii, read - // GridReordering<> doc + // Must call this to be able to create a + // correct triangulation in dealii, read + // GridReordering<> doc GridReordering::reorder_cells (cells); tria.create_triangulation_compatibility (vertices, cells, SubCellData()); } @@ -381,7 +381,7 @@ GridGenerator::parallelogram ( vertices[1] = corners[0]; vertices[2] = corners[1]; vertices[3] = vertices[1] + vertices[2]; - // Prepare cell data + // Prepare cell data std::vector > cells (1); for (unsigned int i=0;i::vertices_per_cell;++i) cells[0].vertices[i] = i; @@ -389,7 +389,7 @@ GridGenerator::parallelogram ( tria.create_triangulation (vertices, cells, SubCellData()); - // Assign boundary indicators + // Assign boundary indicators if (colorize) colorize_hyper_rectangle (tria); } @@ -405,7 +405,7 @@ GridGenerator::subdivided_hyper_cube (Triangulation &tria, { Assert (repetitions >= 1, ExcInvalidRepetitions(repetitions)); Assert (left < right, - ExcMessage ("Invalid left-to-right bounds of hypercube")); + ExcMessage ("Invalid left-to-right bounds of hypercube")); // first generate the necessary // points @@ -439,59 +439,59 @@ GridGenerator::subdivided_hyper_cube (Triangulation &tria, } // next create the cells - // Prepare cell data + // Prepare cell data std::vector > cells; - // Define these as abbreviations - // for the step sizes below. The - // number of points in a single - // direction is repetitions+1 + // Define these as abbreviations + // for the step sizes below. The + // number of points in a single + // direction is repetitions+1 const unsigned int dy = repetitions+1; const unsigned int dz = dy*dy; switch (dim) { case 1: - cells.resize (repetitions); - for (unsigned int x=0; x &p_2, const bool colorize) { - // contributed by Joerg R. Weimar - // (j.weimar@jweimar.de) 2003 + // contributed by Joerg R. Weimar + // (j.weimar@jweimar.de) 2003 Assert(repetitions.size() == dim, - ExcInvalidRepetitionsDimension(dim)); - // First, normalize input such that - // p1 is lower in all coordinate - // directions. + ExcInvalidRepetitionsDimension(dim)); + // First, normalize input such that + // p1 is lower in all coordinate + // directions. Point p1(p_1); Point p2(p_2); @@ -532,10 +532,10 @@ GridGenerator::subdivided_hyper_rectangle ( if (p1(i) > p2(i)) std::swap (p1(i), p2(i)); - // then check that all repetitions - // are >= 1, and calculate deltas - // convert repetitions from double - // to int by taking the ceiling. + // then check that all repetitions + // are >= 1, and calculate deltas + // convert repetitions from double + // to int by taking the ceiling. Point delta; for (unsigned int i=0; i > cells; switch (dim) { @@ -642,18 +642,18 @@ GridGenerator::subdivided_hyper_rectangle ( if (colorize) { - // to colorize, run through all - // faces of all cells and set - // boundary indicator to the - // correct value if it was 0. - - // use a large epsilon to - // compare numbers to avoid - // roundoff problems. + // to colorize, run through all + // faces of all cells and set + // boundary indicator to the + // correct value if it was 0. + + // use a large epsilon to + // compare numbers to avoid + // roundoff problems. const double epsilon = 0.01 * *std::min_element (&delta[0], &delta[0]+dim); Assert (epsilon > 0, - ExcMessage ("The distance between corner points must be positive.")) + ExcMessage ("The distance between corner points must be positive.")) // actual code is external since // 1-D is different from 2/3D. @@ -672,16 +672,16 @@ GridGenerator::subdivided_hyper_rectangle( const Point &p_2, const bool colorize) { - // contributed by Joerg R. Weimar - // (j.weimar@jweimar.de) 2003 - // modified by Yaqi Wang 2006 + // contributed by Joerg R. Weimar + // (j.weimar@jweimar.de) 2003 + // modified by Yaqi Wang 2006 Assert(step_sz.size() == dim, - ExcInvalidRepetitionsDimension(dim)); + ExcInvalidRepetitionsDimension(dim)); - // First, normalize input such that - // p1 is lower in all coordinate - // directions. + // First, normalize input such that + // p1 is lower in all coordinate + // directions. // and check the consistency of // step sizes, i.e. that they all @@ -694,16 +694,16 @@ GridGenerator::subdivided_hyper_rectangle( for (unsigned int i=0;i p2(i)) - { - std::swap (p1(i), p2(i)); - std::reverse (step_sizes[i].begin(), step_sizes[i].end()); - } + { + std::swap (p1(i), p2(i)); + std::reverse (step_sizes[i].begin(), step_sizes[i].end()); + } double x = 0; for (unsigned int j=0; j (p1[0]+x)); - - // form partial sums. in - // the last run through - // avoid accessing - // non-existent values - // and exit early instead - if (i == step_sizes[0].size()) - break; - - x += step_sizes[0][i]; - } - break; + double x=0; + for (unsigned int i=0; ; ++i) + { + points.push_back (Point (p1[0]+x)); + + // form partial sums. in + // the last run through + // avoid accessing + // non-existent values + // and exit early instead + if (i == step_sizes[0].size()) + break; + + x += step_sizes[0][i]; + } + break; } case 2: { - double y=0; - for (unsigned int j=0; ; ++j) - { - double x=0; - for (unsigned int i=0; ; ++i) - { - points.push_back (Point (p1[0]+x, - p1[1]+y)); - if (i == step_sizes[0].size()) - break; - - x += step_sizes[0][i]; - } - - if (j == step_sizes[1].size()) - break; - - y += step_sizes[1][j]; - } - break; + double y=0; + for (unsigned int j=0; ; ++j) + { + double x=0; + for (unsigned int i=0; ; ++i) + { + points.push_back (Point (p1[0]+x, + p1[1]+y)); + if (i == step_sizes[0].size()) + break; + + x += step_sizes[0][i]; + } + + if (j == step_sizes[1].size()) + break; + + y += step_sizes[1][j]; + } + break; } case 3: { - double z=0; - for (unsigned int k=0; ; ++k) - { - double y=0; - for (unsigned int j=0; ; ++j) - { - double x=0; - for (unsigned int i=0; ; ++i) - { - points.push_back (Point (p1[0]+x, - p1[1]+y, - p1[2]+z)); - if (i == step_sizes[0].size()) - break; - - x += step_sizes[0][i]; - } - - if (j == step_sizes[1].size()) - break; - - y += step_sizes[1][j]; - } - - if (k == step_sizes[2].size()) - break; - - z += step_sizes[2][k]; - } - break; + double z=0; + for (unsigned int k=0; ; ++k) + { + double y=0; + for (unsigned int j=0; ; ++j) + { + double x=0; + for (unsigned int i=0; ; ++i) + { + points.push_back (Point (p1[0]+x, + p1[1]+y, + p1[2]+z)); + if (i == step_sizes[0].size()) + break; + + x += step_sizes[0][i]; + } + + if (j == step_sizes[1].size()) + break; + + y += step_sizes[1][j]; + } + + if (k == step_sizes[2].size()) + break; + + z += step_sizes[2][k]; + } + break; } default: @@ -795,7 +795,7 @@ GridGenerator::subdivided_hyper_rectangle( } // next create the cells - // Prepare cell data + // Prepare cell data std::vector > cells; switch (dim) { @@ -861,20 +861,20 @@ GridGenerator::subdivided_hyper_rectangle( if (colorize) { - // to colorize, run through all - // faces of all cells and set - // boundary indicator to the - // correct value if it was 0. - - // use a large epsilon to - // compare numbers to avoid - // roundoff problems. + // to colorize, run through all + // faces of all cells and set + // boundary indicator to the + // correct value if it was 0. + + // use a large epsilon to + // compare numbers to avoid + // roundoff problems. double min_size = *std::min_element (step_sizes[0].begin(), - step_sizes[0].end()); + step_sizes[0].end()); for (unsigned int i=1; i& material_id, const bool colorize) { - // contributed by Yaqi Wang 2006 + // contributed by Yaqi Wang 2006 Assert(spacing.size() == 1, - ExcInvalidRepetitionsDimension(1)); + ExcInvalidRepetitionsDimension(1)); const unsigned int n_cells = material_id.size(0); Assert(spacing[0].size() == n_cells, - ExcInvalidRepetitionsDimension(1)); + ExcInvalidRepetitionsDimension(1)); double delta = std::numeric_limits::max(); for (unsigned int i=0; i& material_id, const bool colorize) { - // contributed by Yaqi Wang 2006 + // contributed by Yaqi Wang 2006 Assert(spacing.size() == 2, - ExcInvalidRepetitionsDimension(2)); + ExcInvalidRepetitionsDimension(2)); std::vector repetitions(2); unsigned int n_cells = 1; @@ -965,12 +965,12 @@ GridGenerator::subdivided_hyper_rectangle ( repetitions[i] = spacing[i].size(); n_cells *= repetitions[i]; for (unsigned int j=0; j= 0, ExcInvalidRepetitions(-1)); - delta = std::min (delta, spacing[i][j]); - } + { + Assert (spacing[i][j] >= 0, ExcInvalidRepetitions(-1)); + delta = std::min (delta, spacing[i][j]); + } Assert(material_id.size(i) == repetitions[i], - ExcInvalidRepetitionsDimension(i)); + ExcInvalidRepetitionsDimension(i)); } // generate the necessary points @@ -980,13 +980,13 @@ GridGenerator::subdivided_hyper_rectangle ( { double ax = p[0]; for (unsigned int x=0; x<=repetitions[0]; ++x) - { - points.push_back (Point<2> (ax,ay)); - if (x (ax,ay)); + if (x > cells(n_val_cells); unsigned int id = 0; for (unsigned int y=0; y::cell_iterator cell = tria.begin_raw(), - endc = tria.end(); + endc = tria.end(); for (; cell !=endc; ++cell) - { - Point<2> cell_center = cell->center(); - for(unsigned int f=0; f::faces_per_cell; ++f) - if (cell->face(f)->boundary_indicator() == 0) - { - Point<2> face_center = cell->face(f)->center(); - for (unsigned int i=0; i<2; ++i) - { - if (face_center[i]face(f)->set_boundary_indicator(i*2); - if (face_center[i]>cell_center[i]+eps) - cell->face(f)->set_boundary_indicator(i*2+1); - } - } - } + { + Point<2> cell_center = cell->center(); + for(unsigned int f=0; f::faces_per_cell; ++f) + if (cell->face(f)->boundary_indicator() == 0) + { + Point<2> face_center = cell->face(f)->center(); + for (unsigned int i=0; i<2; ++i) + { + if (face_center[i]face(f)->set_boundary_indicator(i*2); + if (face_center[i]>cell_center[i]+eps) + cell->face(f)->set_boundary_indicator(i*2+1); + } + } + } } } @@ -1051,11 +1051,11 @@ GridGenerator::subdivided_hyper_rectangle ( const Table<3,types::material_id_t>& material_id, const bool colorize) { - // contributed by Yaqi Wang 2006 + // contributed by Yaqi Wang 2006 const unsigned int dim = 3; Assert(spacing.size() == dim, - ExcInvalidRepetitionsDimension(dim)); + ExcInvalidRepetitionsDimension(dim)); std::vector repetitions(dim); unsigned int n_cells = 1; @@ -1065,12 +1065,12 @@ GridGenerator::subdivided_hyper_rectangle ( repetitions[i] = spacing[i].size(); n_cells *= repetitions[i]; for (unsigned int j=0; j= 0, ExcInvalidRepetitions(-1)); - delta = std::min (delta, spacing[i][j]); - } + { + Assert (spacing[i][j] >= 0, ExcInvalidRepetitions(-1)); + delta = std::min (delta, spacing[i][j]); + } Assert(material_id.size(i) == repetitions[i], - ExcInvalidRepetitionsDimension(i)); + ExcInvalidRepetitionsDimension(i)); } // generate the necessary points @@ -1080,19 +1080,19 @@ GridGenerator::subdivided_hyper_rectangle ( { double ay = p[1]; for (unsigned int y=0; y<=repetitions[1]; ++y) - { - double ax = p[0]; - for (unsigned int x=0; x<=repetitions[0]; ++x) - { - points.push_back (Point (ax,ay,az)); - if (x (ax,ay,az)); + if (x > cells(n_val_cells); unsigned int id = 0; @@ -1110,21 +1110,21 @@ GridGenerator::subdivided_hyper_rectangle ( for (unsigned int z=0; z::cell_iterator cell = tria.begin_raw(), - endc = tria.end(); + endc = tria.end(); for (; cell !=endc; ++cell) - { - Point cell_center = cell->center(); - for(unsigned int f=0; f::faces_per_cell; ++f) - if (cell->face(f)->boundary_indicator() == 0) - { - Point face_center = cell->face(f)->center(); - for (unsigned int i=0; iface(f)->set_boundary_indicator(i*2); - if (face_center[i]>cell_center[i]+eps) - cell->face(f)->set_boundary_indicator(i*2+1); - } - } - } + { + Point cell_center = cell->center(); + for(unsigned int f=0; f::faces_per_cell; ++f) + if (cell->face(f)->boundary_indicator() == 0) + { + Point face_center = cell->face(f)->center(); + for (unsigned int i=0; iface(f)->set_boundary_indicator(i*2); + if (face_center[i]>cell_center[i]+eps) + cell->face(f)->set_boundary_indicator(i*2+1); + } + } + } } } @@ -1169,8 +1169,8 @@ GridGenerator::colorize_subdivided_hyper_rectangle ( cell != tria.end(); ++cell) if (cell->center()(0) > 0) cell->set_material_id(1); - // boundary indicators are set to - // 0 (left) and 1 (right) by default. + // boundary indicators are set to + // 0 (left) and 1 (right) by default. } @@ -1178,52 +1178,52 @@ GridGenerator::colorize_subdivided_hyper_rectangle ( template void GridGenerator::colorize_subdivided_hyper_rectangle (Triangulation &tria, - const Point &p1, - const Point &p2, - const double epsilon) + const Point &p1, + const Point &p2, + const double epsilon) { - // run through all faces and check - // if one of their center coordinates matches - // one of the corner points. Comparisons - // are made using an epsilon which - // should be smaller than the smallest cell - // diameter. + // run through all faces and check + // if one of their center coordinates matches + // one of the corner points. Comparisons + // are made using an epsilon which + // should be smaller than the smallest cell + // diameter. typename Triangulation::raw_face_iterator face = tria.begin_raw_face(), - endface = tria.end_face(); + endface = tria.end_face(); for (; face!=endface; ++face) { if (face->boundary_indicator() == 0) - { - const Point center (face->center()); - if (std::abs(center(0)-p1[0]) < epsilon) - face->set_boundary_indicator(0); - else if (std::abs(center(0) - p2[0]) < epsilon) - face->set_boundary_indicator(1); - else if (dim > 1 && std::abs(center(1) - p1[1]) < epsilon) - face->set_boundary_indicator(2); - else if (dim > 1 && std::abs(center(1) - p2[1]) < epsilon) - face->set_boundary_indicator(3); - else if (dim > 2 && std::abs(center(2) - p1[2]) < epsilon) - face->set_boundary_indicator(4); - else if (dim > 2 && std::abs(center(2) - p2[2]) < epsilon) - face->set_boundary_indicator(5); - else - // triangulation says it - // is on the boundary, - // but we could not find - // on which boundary. - Assert (false, ExcInternalError()); - - } + { + const Point center (face->center()); + if (std::abs(center(0)-p1[0]) < epsilon) + face->set_boundary_indicator(0); + else if (std::abs(center(0) - p2[0]) < epsilon) + face->set_boundary_indicator(1); + else if (dim > 1 && std::abs(center(1) - p1[1]) < epsilon) + face->set_boundary_indicator(2); + else if (dim > 1 && std::abs(center(1) - p2[1]) < epsilon) + face->set_boundary_indicator(3); + else if (dim > 2 && std::abs(center(2) - p1[2]) < epsilon) + face->set_boundary_indicator(4); + else if (dim > 2 && std::abs(center(2) - p2[2]) < epsilon) + face->set_boundary_indicator(5); + else + // triangulation says it + // is on the boundary, + // but we could not find + // on which boundary. + Assert (false, ExcInternalError()); + + } } for (typename Triangulation::cell_iterator cell = tria.begin(); cell != tria.end(); ++cell) { char id = 0; for (unsigned int d=0;dcenter()(d) > 0) id += 1 << d; + if (cell->center()(d) > 0) id += 1 << d; cell->set_material_id(id); } } @@ -1231,9 +1231,9 @@ GridGenerator::colorize_subdivided_hyper_rectangle (Triangulation &tria, template <> void GridGenerator::hyper_cube_slit (Triangulation<1> &, - const double, - const double, - const bool) + const double, + const double, + const bool) { Assert (false, ExcNotImplemented()); } @@ -1242,10 +1242,10 @@ void GridGenerator::hyper_cube_slit (Triangulation<1> &, template <> void GridGenerator::enclosed_hyper_cube (Triangulation<1>&, - const double, - const double, - const double, - const bool) + const double, + const double, + const double, + const bool) { Assert (false, ExcNotImplemented()); } @@ -1254,8 +1254,8 @@ void GridGenerator::enclosed_hyper_cube (Triangulation<1>&, template <> void GridGenerator::hyper_L (Triangulation<1> &, - const double, - const double) + const double, + const double) { Assert (false, ExcNotImplemented()); } @@ -1264,8 +1264,8 @@ void GridGenerator::hyper_L (Triangulation<1> &, template <> void GridGenerator::hyper_ball (Triangulation<1> &, - const Point<1> &, - const double) + const Point<1> &, + const double) { Assert (false, ExcNotImplemented()); } @@ -1274,8 +1274,8 @@ void GridGenerator::hyper_ball (Triangulation<1> &, template <> void GridGenerator::cylinder (Triangulation<1> &, - const double, - const double) + const double, + const double) { Assert (false, ExcNotImplemented()); } @@ -1284,9 +1284,9 @@ void GridGenerator::cylinder (Triangulation<1> &, template <> void GridGenerator::truncated_cone (Triangulation<1> &, - const double, - const double, - const double) + const double, + const double, + const double) { Assert (false, ExcNotImplemented()); } @@ -1295,11 +1295,11 @@ void GridGenerator::truncated_cone (Triangulation<1> &, template <> void GridGenerator::hyper_shell (Triangulation<1> &, - const Point<1> &, - const double, - const double, - const unsigned int, - const bool) + const Point<1> &, + const double, + const double, + const unsigned int, + const bool) { Assert (false, ExcNotImplemented()); } @@ -1307,9 +1307,9 @@ void GridGenerator::hyper_shell (Triangulation<1> &, template <> void GridGenerator::colorize_hyper_shell (Triangulation<1> &, - const Point<1> &, - const double, - const double) + const Point<1> &, + const double, + const double) { Assert (false, ExcNotImplemented()); } @@ -1330,8 +1330,8 @@ void GridGenerator::cylinder_shell (Triangulation<1>&, template <> void GridGenerator::half_hyper_ball (Triangulation<1>&, - const Point<1>&, - const double) + const Point<1>&, + const double) { Assert (false, ExcNotImplemented()); } @@ -1340,35 +1340,35 @@ GridGenerator::half_hyper_ball (Triangulation<1>&, template <> void GridGenerator::half_hyper_shell (Triangulation<1>&, - const Point<1>&, - const double, - const double, - const unsigned int, - const bool) + const Point<1>&, + const double, + const double, + const unsigned int, + const bool) { Assert (false, ExcNotImplemented()); } template <> void GridGenerator::quarter_hyper_shell (Triangulation<1>&, - const Point<1>&, - const double, - const double, - const unsigned int, - const bool) + const Point<1>&, + const double, + const double, + const unsigned int, + const bool) { Assert (false, ExcNotImplemented()); } template <> void GridGenerator::enclosed_hyper_cube (Triangulation<2> &tria, - const double left, - const double right, - const double thickness, - const bool colorize) + const double left, + const double right, + const double thickness, + const bool colorize) { Assert(left > vertices(16); double coords[4]; @@ -1383,8 +1383,8 @@ void GridGenerator::enclosed_hyper_cube (Triangulation<2> &tria, vertices[k++] = Point<2>(coords[i1], coords[i0]); const types::material_id_t materials[9] = { 5, 4, 6, - 1, 0, 2, - 9, 8,10 + 1, 0, 2, + 9, 8,10 }; std::vector > cells(9); @@ -1392,17 +1392,17 @@ void GridGenerator::enclosed_hyper_cube (Triangulation<2> &tria, for (unsigned int i0=0;i0<3;++i0) for (unsigned int i1=0;i1<3;++i1) { - cells[k].vertices[0] = i1+4*i0; - cells[k].vertices[1] = i1+4*i0+1; - cells[k].vertices[2] = i1+4*i0+4; - cells[k].vertices[3] = i1+4*i0+5; - if (colorize) - cells[k].material_id = materials[k]; - ++k; + cells[k].vertices[0] = i1+4*i0; + cells[k].vertices[1] = i1+4*i0+1; + cells[k].vertices[2] = i1+4*i0+4; + cells[k].vertices[3] = i1+4*i0+5; + if (colorize) + cells[k].material_id = materials[k]; + ++k; } tria.create_triangulation (vertices, - cells, - SubCellData()); // no boundary information + cells, + SubCellData()); // no boundary information } @@ -1411,30 +1411,30 @@ void GridGenerator::enclosed_hyper_cube (Triangulation<2> &tria, template <> void GridGenerator::hyper_cube_slit (Triangulation<2> &tria, - const double left, - const double right, - const bool colorize) + const double left, + const double right, + const bool colorize) { const double rl2=(right+left)/2; const Point<2> vertices[10] = { Point<2>(left, left ), - Point<2>(rl2, left ), - Point<2>(rl2, rl2 ), - Point<2>(left, rl2 ), - Point<2>(right,left ), - Point<2>(right,rl2 ), - Point<2>(rl2, right), - Point<2>(left, right), - Point<2>(right,right), - Point<2>(rl2, left ) }; + Point<2>(rl2, left ), + Point<2>(rl2, rl2 ), + Point<2>(left, rl2 ), + Point<2>(right,left ), + Point<2>(right,rl2 ), + Point<2>(rl2, right), + Point<2>(left, right), + Point<2>(right,right), + Point<2>(rl2, left ) }; const int cell_vertices[4][4] = { { 0,1,3,2 }, - { 9,4,2,5 }, - { 3,2,7,6 }, - { 2,5,6,8 } }; + { 9,4,2,5 }, + { 3,2,7,6 }, + { 2,5,6,8 } }; std::vector > cells (4, CellData<2>()); for (unsigned int i=0; i<4; ++i) { for (unsigned int j=0; j<4; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].vertices[j] = cell_vertices[i][j]; cells[i].material_id = 0; }; tria.create_triangulation ( @@ -1455,9 +1455,9 @@ GridGenerator::hyper_cube_slit (Triangulation<2> &tria, template <> void GridGenerator::truncated_cone (Triangulation<2> &triangulation, - const double radius_0, - const double radius_1, - const double half_length) + const double radius_0, + const double radius_1, + const double half_length) { Point<2> vertices_tmp[4]; @@ -1496,27 +1496,27 @@ void GridGenerator::truncated_cone (Triangulation<2> &triangulation, template <> void GridGenerator::hyper_L (Triangulation<2> &tria, - const double a, - const double b) + const double a, + const double b) { const Point<2> vertices[8] = { Point<2> (a,a), - Point<2> ((a+b)/2,a), - Point<2> (b,a), - Point<2> (a,(a+b)/2), - Point<2> ((a+b)/2,(a+b)/2), - Point<2> (b,(a+b)/2), - Point<2> (a,b), - Point<2> ((a+b)/2,b) }; + Point<2> ((a+b)/2,a), + Point<2> (b,a), + Point<2> (a,(a+b)/2), + Point<2> ((a+b)/2,(a+b)/2), + Point<2> (b,(a+b)/2), + Point<2> (a,b), + Point<2> ((a+b)/2,b) }; const int cell_vertices[3][4] = {{0, 1, 3, 4}, - {1, 2, 4, 5}, - {3, 4, 6, 7}}; + {1, 2, 4, 5}, + {3, 4, 6, 7}}; std::vector > cells (3, CellData<2>()); for (unsigned int i=0; i<3; ++i) { for (unsigned int j=0; j<4; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].vertices[j] = cell_vertices[i][j]; cells[i].material_id = 0; }; @@ -1532,34 +1532,34 @@ GridGenerator::hyper_L (Triangulation<2> &tria, template <> void GridGenerator::hyper_ball (Triangulation<2> &tria, - const Point<2> &p, - const double radius) + const Point<2> &p, + const double radius) { - // equilibrate cell sizes at - // transition from the inner part - // to the radial cells + // equilibrate cell sizes at + // transition from the inner part + // to the radial cells const double a = 1./(1+std::sqrt(2.0)); const Point<2> vertices[8] = { p+Point<2>(-1,-1)*(radius/std::sqrt(2.0)), - p+Point<2>(+1,-1)*(radius/std::sqrt(2.0)), - p+Point<2>(-1,-1)*(radius/std::sqrt(2.0)*a), - p+Point<2>(+1,-1)*(radius/std::sqrt(2.0)*a), - p+Point<2>(-1,+1)*(radius/std::sqrt(2.0)*a), - p+Point<2>(+1,+1)*(radius/std::sqrt(2.0)*a), - p+Point<2>(-1,+1)*(radius/std::sqrt(2.0)), - p+Point<2>(+1,+1)*(radius/std::sqrt(2.0)) }; + p+Point<2>(+1,-1)*(radius/std::sqrt(2.0)), + p+Point<2>(-1,-1)*(radius/std::sqrt(2.0)*a), + p+Point<2>(+1,-1)*(radius/std::sqrt(2.0)*a), + p+Point<2>(-1,+1)*(radius/std::sqrt(2.0)*a), + p+Point<2>(+1,+1)*(radius/std::sqrt(2.0)*a), + p+Point<2>(-1,+1)*(radius/std::sqrt(2.0)), + p+Point<2>(+1,+1)*(radius/std::sqrt(2.0)) }; const int cell_vertices[5][4] = {{0, 1, 2, 3}, - {0, 2, 6, 4}, - {2, 3, 4, 5}, - {1, 7, 3, 5}, - {6, 4, 7, 5}}; + {0, 2, 6, 4}, + {2, 3, 4, 5}, + {1, 7, 3, 5}, + {6, 4, 7, 5}}; std::vector > cells (5, CellData<2>()); for (unsigned int i=0; i<5; ++i) { for (unsigned int j=0; j<4; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].vertices[j] = cell_vertices[i][j]; cells[i].material_id = 0; }; @@ -1578,12 +1578,12 @@ GridGenerator::colorize_hyper_shell ( Triangulation<2>& tria, const Point<2>&, const double, const double) { - // Inspite of receiving geometrical - // data, we do this only based on - // topology. + // Inspite of receiving geometrical + // data, we do this only based on + // topology. - // For the mesh based on cube, - // this is highly irregular + // For the mesh based on cube, + // this is highly irregular for (Triangulation<2>::cell_iterator cell = tria.begin(); cell != tria.end(); ++cell) { @@ -1595,43 +1595,43 @@ GridGenerator::colorize_hyper_shell ( template <> void GridGenerator::hyper_shell (Triangulation<2> &tria, - const Point<2> ¢er, - const double inner_radius, - const double outer_radius, - const unsigned int n_cells, - const bool colorize) + const Point<2> ¢er, + const double inner_radius, + const double outer_radius, + const unsigned int n_cells, + const bool colorize) { Assert ((inner_radius > 0) && (inner_radius < outer_radius), - ExcInvalidRadii ()); + ExcInvalidRadii ()); const double pi = numbers::PI; - // determine the number of cells - // for the grid. if not provided by - // the user determine it such that - // the length of each cell on the - // median (in the middle between - // the two circles) is equal to its - // radial extent (which is the - // difference between the two - // radii) + // determine the number of cells + // for the grid. if not provided by + // the user determine it such that + // the length of each cell on the + // median (in the middle between + // the two circles) is equal to its + // radial extent (which is the + // difference between the two + // radii) const unsigned int N = (n_cells == 0 ? - static_cast - (std::ceil((2*pi* (outer_radius + inner_radius)/2) / - (outer_radius - inner_radius))) : - n_cells); - - // set up N vertices on the - // outer and N vertices on - // the inner circle. the - // first N ones are on the - // outer one, and all are - // numbered counter-clockwise + static_cast + (std::ceil((2*pi* (outer_radius + inner_radius)/2) / + (outer_radius - inner_radius))) : + n_cells); + + // set up N vertices on the + // outer and N vertices on + // the inner circle. the + // first N ones are on the + // outer one, and all are + // numbered counter-clockwise std::vector > vertices(2*N); for (unsigned int i=0; i( std::cos(2*pi * i/N), - std::sin(2*pi * i/N)) * outer_radius; + std::sin(2*pi * i/N)) * outer_radius; vertices[i+N] = vertices[i] * (inner_radius/outer_radius); vertices[i] += center; @@ -1662,8 +1662,8 @@ void GridGenerator::hyper_shell (Triangulation<2> &tria, template <> void GridGenerator::cylinder (Triangulation<2> &tria, - const double radius, - const double half_length) + const double radius, + const double half_length) { Point<2> p1 (-half_length, -radius); Point<2> p2 (half_length, radius); @@ -1675,17 +1675,17 @@ GridGenerator::cylinder (Triangulation<2> &tria, while (f != end) { switch (f->boundary_indicator()) - { - case 0: - f->set_boundary_indicator(1); - break; - case 1: - f->set_boundary_indicator(2); - break; - default: - f->set_boundary_indicator(0); - break; - } + { + case 0: + f->set_boundary_indicator(1); + break; + case 1: + f->set_boundary_indicator(2); + break; + default: + f->set_boundary_indicator(0); + break; + } ++f; } } @@ -1708,33 +1708,33 @@ void GridGenerator::cylinder_shell (Triangulation<2>&, template <> void GridGenerator::half_hyper_ball (Triangulation<2> &tria, - const Point<2> &p, - const double radius) + const Point<2> &p, + const double radius) { - // equilibrate cell sizes at - // transition from the inner part - // to the radial cells + // equilibrate cell sizes at + // transition from the inner part + // to the radial cells const double a = 1./(1+std::sqrt(2.0)); const Point<2> vertices[8] = { p+Point<2>(0,-1)*radius, - p+Point<2>(+1,-1)*(radius/std::sqrt(2.0)), - p+Point<2>(0,-1)*(radius/std::sqrt(2.0)*a), - p+Point<2>(+1,-1)*(radius/std::sqrt(2.0)*a), - p+Point<2>(0,+1)*(radius/std::sqrt(2.0)*a), - p+Point<2>(+1,+1)*(radius/std::sqrt(2.0)*a), - p+Point<2>(0,+1)*radius, - p+Point<2>(+1,+1)*(radius/std::sqrt(2.0)) }; + p+Point<2>(+1,-1)*(radius/std::sqrt(2.0)), + p+Point<2>(0,-1)*(radius/std::sqrt(2.0)*a), + p+Point<2>(+1,-1)*(radius/std::sqrt(2.0)*a), + p+Point<2>(0,+1)*(radius/std::sqrt(2.0)*a), + p+Point<2>(+1,+1)*(radius/std::sqrt(2.0)*a), + p+Point<2>(0,+1)*radius, + p+Point<2>(+1,+1)*(radius/std::sqrt(2.0)) }; const int cell_vertices[5][4] = {{0, 1, 2, 3}, - {2, 3, 4, 5}, - {1, 7, 3, 5}, - {6, 4, 7, 5}}; + {2, 3, 4, 5}, + {1, 7, 3, 5}, + {6, 4, 7, 5}}; std::vector > cells (4, CellData<2>()); for (unsigned int i=0; i<4; ++i) { for (unsigned int j=0; j<4; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].vertices[j] = cell_vertices[i][j]; cells[i].material_id = 0; }; @@ -1749,16 +1749,16 @@ GridGenerator::half_hyper_ball (Triangulation<2> &tria, while (cell != end) { - for (unsigned int i=0;i::faces_per_cell;++i) - { - if (cell->face(i)->boundary_indicator() == types::internal_face_boundary_id) - continue; - - // If x is zero, then this is part of the plane - if (cell->face(i)->center()(0) < p(0)+1.e-5) - cell->face(i)->set_boundary_indicator(1); - } - ++cell; + for (unsigned int i=0;i::faces_per_cell;++i) + { + if (cell->face(i)->boundary_indicator() == types::internal_face_boundary_id) + continue; + + // If x is zero, then this is part of the plane + if (cell->face(i)->center()(0) < p(0)+1.e-5) + cell->face(i)->set_boundary_indicator(1); + } + ++cell; } } @@ -1768,50 +1768,50 @@ GridGenerator::half_hyper_ball (Triangulation<2> &tria, template <> void GridGenerator::half_hyper_shell (Triangulation<2> &tria, - const Point<2> ¢er, - const double inner_radius, - const double outer_radius, - const unsigned int n_cells, - const bool colorize) + const Point<2> ¢er, + const double inner_radius, + const double outer_radius, + const unsigned int n_cells, + const bool colorize) { Assert ((inner_radius > 0) && (inner_radius < outer_radius), - ExcInvalidRadii ()); + ExcInvalidRadii ()); const double pi = numbers::PI; - // determine the number of cells - // for the grid. if not provided by - // the user determine it such that - // the length of each cell on the - // median (in the middle between - // the two circles) is equal to its - // radial extent (which is the - // difference between the two - // radii) + // determine the number of cells + // for the grid. if not provided by + // the user determine it such that + // the length of each cell on the + // median (in the middle between + // the two circles) is equal to its + // radial extent (which is the + // difference between the two + // radii) const unsigned int N = (n_cells == 0 ? - static_cast - (std::ceil((pi* (outer_radius + inner_radius)/2) / - (outer_radius - inner_radius))) : - n_cells); - - // set up N+1 vertices on the - // outer and N+1 vertices on - // the inner circle. the - // first N+1 ones are on the - // outer one, and all are - // numbered counter-clockwise + static_cast + (std::ceil((pi* (outer_radius + inner_radius)/2) / + (outer_radius - inner_radius))) : + n_cells); + + // set up N+1 vertices on the + // outer and N+1 vertices on + // the inner circle. the + // first N+1 ones are on the + // outer one, and all are + // numbered counter-clockwise std::vector > vertices(2*(N+1)); for (unsigned int i=0; i<=N; ++i) { - // enforce that the x-coordinates - // of the first and last point of - // each half-circle are exactly - // zero (contrary to what we may - // compute using the imprecise - // value of pi) + // enforce that the x-coordinates + // of the first and last point of + // each half-circle are exactly + // zero (contrary to what we may + // compute using the imprecise + // value of pi) vertices[i] = Point<2>( ( (i==0) || (i==N) ? - 0 : - std::cos(pi * i/N - pi/2) ), - std::sin(pi * i/N - pi/2)) * outer_radius; + 0 : + std::cos(pi * i/N - pi/2) ), + std::sin(pi * i/N - pi/2)) * outer_radius; vertices[i+N+1] = vertices[i] * (inner_radius/outer_radius); vertices[i] += center; @@ -1838,7 +1838,7 @@ GridGenerator::half_hyper_shell (Triangulation<2> &tria, Triangulation<2>::cell_iterator cell = tria.begin(); for (;cell!=tria.end();++cell) { - cell->face(2)->set_boundary_indicator(1); + cell->face(2)->set_boundary_indicator(1); } tria.begin()->face(0)->set_boundary_indicator(3); @@ -1849,49 +1849,49 @@ GridGenerator::half_hyper_shell (Triangulation<2> &tria, template <> void GridGenerator::quarter_hyper_shell (Triangulation<2> &tria, - const Point<2> ¢er, - const double inner_radius, - const double outer_radius, - const unsigned int n_cells, - const bool colorize) + const Point<2> ¢er, + const double inner_radius, + const double outer_radius, + const unsigned int n_cells, + const bool colorize) { Assert ((inner_radius > 0) && (inner_radius < outer_radius), - ExcInvalidRadii ()); + ExcInvalidRadii ()); const double pi = numbers::PI; - // determine the number of cells - // for the grid. if not provided by - // the user determine it such that - // the length of each cell on the - // median (in the middle between - // the two circles) is equal to its - // radial extent (which is the - // difference between the two - // radii) + // determine the number of cells + // for the grid. if not provided by + // the user determine it such that + // the length of each cell on the + // median (in the middle between + // the two circles) is equal to its + // radial extent (which is the + // difference between the two + // radii) const unsigned int N = (n_cells == 0 ? - static_cast - (std::ceil((pi* (outer_radius + inner_radius)/4) / - (outer_radius - inner_radius))) : - n_cells); - - // set up N+1 vertices on the - // outer and N+1 vertices on - // the inner circle. the - // first N+1 ones are on the - // outer one, and all are - // numbered counter-clockwise + static_cast + (std::ceil((pi* (outer_radius + inner_radius)/4) / + (outer_radius - inner_radius))) : + n_cells); + + // set up N+1 vertices on the + // outer and N+1 vertices on + // the inner circle. the + // first N+1 ones are on the + // outer one, and all are + // numbered counter-clockwise std::vector > vertices(2*(N+1)); for (unsigned int i=0; i<=N; ++i) { - // enforce that the x-coordinates - // of the last point is exactly - // zero (contrary to what we may - // compute using the imprecise - // value of pi) + // enforce that the x-coordinates + // of the last point is exactly + // zero (contrary to what we may + // compute using the imprecise + // value of pi) vertices[i] = Point<2>( ( (i==N) ? - 0 : - std::cos(pi * i/N/2) ), - std::sin(pi * i/N/2)) * outer_radius; + 0 : + std::cos(pi * i/N/2) ), + std::sin(pi * i/N/2)) * outer_radius; vertices[i+N+1] = vertices[i] * (inner_radius/outer_radius); vertices[i] += center; @@ -1918,7 +1918,7 @@ void GridGenerator::quarter_hyper_shell (Triangulation<2> &tria, Triangulation<2>::cell_iterator cell = tria.begin(); for (;cell!=tria.end();++cell) { - cell->face(2)->set_boundary_indicator(1); + cell->face(2)->set_boundary_indicator(1); } tria.begin()->face(0)->set_boundary_indicator(3); @@ -1931,44 +1931,44 @@ void GridGenerator::quarter_hyper_shell (Triangulation<2> &tria, // Implementation for 3D only template <> void GridGenerator::hyper_cube_slit (Triangulation<3>& tria, - const double left, - const double right, - const bool colorize) + const double left, + const double right, + const bool colorize) { const double rl2=(right+left)/2; const double len = (right-left)/2.; const Point<3> vertices[20] = { - Point<3>(left, left , -len/2.), - Point<3>(rl2, left , -len/2.), - Point<3>(rl2, rl2 , -len/2.), - Point<3>(left, rl2 , -len/2.), - Point<3>(right,left , -len/2.), - Point<3>(right,rl2 , -len/2.), - Point<3>(rl2, right, -len/2.), - Point<3>(left, right, -len/2.), - Point<3>(right,right, -len/2.), - Point<3>(rl2, left , -len/2.), - Point<3>(left, left , len/2.), - Point<3>(rl2, left , len/2.), - Point<3>(rl2, rl2 , len/2.), - Point<3>(left, rl2 , len/2.), - Point<3>(right,left , len/2.), - Point<3>(right,rl2 , len/2.), - Point<3>(rl2, right, len/2.), - Point<3>(left, right, len/2.), - Point<3>(right,right, len/2.), - Point<3>(rl2, left , len/2.) + Point<3>(left, left , -len/2.), + Point<3>(rl2, left , -len/2.), + Point<3>(rl2, rl2 , -len/2.), + Point<3>(left, rl2 , -len/2.), + Point<3>(right,left , -len/2.), + Point<3>(right,rl2 , -len/2.), + Point<3>(rl2, right, -len/2.), + Point<3>(left, right, -len/2.), + Point<3>(right,right, -len/2.), + Point<3>(rl2, left , -len/2.), + Point<3>(left, left , len/2.), + Point<3>(rl2, left , len/2.), + Point<3>(rl2, rl2 , len/2.), + Point<3>(left, rl2 , len/2.), + Point<3>(right,left , len/2.), + Point<3>(right,rl2 , len/2.), + Point<3>(rl2, right, len/2.), + Point<3>(left, right, len/2.), + Point<3>(right,right, len/2.), + Point<3>(rl2, left , len/2.) }; const int cell_vertices[4][8] = { { 0,1,3,2, 10, 11, 13, 12 }, - { 9,4,2,5, 19,14, 12, 15 }, - { 3,2,7,6,13,12,17,16 }, - { 2,5,6,8,12,15,16,18 } }; + { 9,4,2,5, 19,14, 12, 15 }, + { 3,2,7,6,13,12,17,16 }, + { 2,5,6,8,12,15,16,18 } }; std::vector > cells (4, CellData<3>()); for (unsigned int i=0; i<4; ++i) { for (unsigned int j=0; j<8; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].vertices[j] = cell_vertices[i][j]; cells[i].material_id = 0; }; tria.create_triangulation ( @@ -1991,13 +1991,13 @@ void GridGenerator::hyper_cube_slit (Triangulation<3>& tria, // Implementation for 3D only template <> void GridGenerator::enclosed_hyper_cube (Triangulation<3> &tria, - const double left, - const double right, - const double thickness, - const bool colorize) + const double left, + const double right, + const double thickness, + const bool colorize) { Assert(left > vertices(64); double coords[4]; @@ -2010,18 +2010,18 @@ void GridGenerator::enclosed_hyper_cube (Triangulation<3> &tria, for (unsigned int z=0;z<4;++z) for (unsigned int y=0;y<4;++y) for (unsigned int x=0;x<4;++x) - vertices[k++] = Point<3>(coords[x], coords[y], coords[z]); + vertices[k++] = Point<3>(coords[x], coords[y], coords[z]); const types::material_id_t materials[27] = { - 21,20,22, - 17,16,18, - 25,24,26, - 5 , 4, 6, - 1 , 0, 2, - 9 , 8,10, - 37,36,38, - 33,32,34, - 41,40,42 + 21,20,22, + 17,16,18, + 25,24,26, + 5 , 4, 6, + 1 , 0, 2, + 9 , 8,10, + 37,36,38, + 33,32,34, + 41,40,42 }; std::vector > cells(27); @@ -2029,19 +2029,19 @@ void GridGenerator::enclosed_hyper_cube (Triangulation<3> &tria, for (unsigned int z=0;z<3;++z) for (unsigned int y=0;y<3;++y) for (unsigned int x=0;x<3;++x) - { - cells[k].vertices[0] = x+4*y+16*z; - cells[k].vertices[1] = x+4*y+16*z+1; - cells[k].vertices[2] = x+4*y+16*z+4; - cells[k].vertices[3] = x+4*y+16*z+5; - cells[k].vertices[4] = x+4*y+16*z+16; - cells[k].vertices[5] = x+4*y+16*z+17; - cells[k].vertices[6] = x+4*y+16*z+20; - cells[k].vertices[7] = x+4*y+16*z+21; - if (colorize) - cells[k].material_id = materials[k]; - ++k; - } + { + cells[k].vertices[0] = x+4*y+16*z; + cells[k].vertices[1] = x+4*y+16*z+1; + cells[k].vertices[2] = x+4*y+16*z+4; + cells[k].vertices[3] = x+4*y+16*z+5; + cells[k].vertices[4] = x+4*y+16*z+16; + cells[k].vertices[5] = x+4*y+16*z+17; + cells[k].vertices[6] = x+4*y+16*z+20; + cells[k].vertices[7] = x+4*y+16*z+21; + if (colorize) + cells[k].material_id = materials[k]; + ++k; + } tria.create_triangulation ( vertices, cells, @@ -2052,16 +2052,16 @@ void GridGenerator::enclosed_hyper_cube (Triangulation<3> &tria, template <> void GridGenerator::truncated_cone (Triangulation<3> &triangulation, - const double radius_0, - const double radius_1, - const double half_length) + const double radius_0, + const double radius_1, + const double half_length) { - // Determine number of cells and vertices + // Determine number of cells and vertices const unsigned int n_cells = static_cast(std::floor (half_length / - std::max (radius_0, - radius_1) + - 0.5)); + std::max (radius_0, + radius_1) + + 0.5)); const unsigned int n_vertices = 4 * (n_cells + 1); std::vector > vertices_tmp(n_vertices); @@ -2088,7 +2088,7 @@ void GridGenerator::truncated_cone (Triangulation<3> &triangulation, } const std::vector > vertices (vertices_tmp.begin(), - vertices_tmp.end()); + vertices_tmp.end()); Table<2,unsigned int> cell_vertices(n_cells,GeometryInfo<3>::vertices_per_cell); for (unsigned int i = 0; i < n_cells; ++i) @@ -2112,14 +2112,14 @@ void GridGenerator::truncated_cone (Triangulation<3> &triangulation, cell->face (4)->set_boundary_indicator (1); for (unsigned int i = 0; i < 4; ++i) - cell->line (i)->set_boundary_indicator (0); + cell->line (i)->set_boundary_indicator (0); } if (cell->vertex (4) (0) == half_length) { cell->face (5)->set_boundary_indicator (2); for (unsigned int i = 4; i < 8; ++i) - cell->line (i)->set_boundary_indicator (0); + cell->line (i)->set_boundary_indicator (0); } for (unsigned int i = 0; i < 4; ++i) @@ -2132,58 +2132,58 @@ void GridGenerator::truncated_cone (Triangulation<3> &triangulation, template <> void GridGenerator::hyper_L (Triangulation<3> &tria, - const double a, - const double b) + const double a, + const double b) { - // we slice out the top back right - // part of the cube + // we slice out the top back right + // part of the cube const Point<3> vertices[26] = { - // front face of the big cube - Point<3> (a, a,a), - Point<3> ((a+b)/2,a,a), - Point<3> (b, a,a), - Point<3> (a, a,(a+b)/2), - Point<3> ((a+b)/2,a,(a+b)/2), - Point<3> (b, a,(a+b)/2), - Point<3> (a, a,b), - Point<3> ((a+b)/2,a,b), - Point<3> (b, a,b), - // middle face of the big cube - Point<3> (a, (a+b)/2,a), - Point<3> ((a+b)/2,(a+b)/2,a), - Point<3> (b, (a+b)/2,a), - Point<3> (a, (a+b)/2,(a+b)/2), - Point<3> ((a+b)/2,(a+b)/2,(a+b)/2), - Point<3> (b, (a+b)/2,(a+b)/2), - Point<3> (a, (a+b)/2,b), - Point<3> ((a+b)/2,(a+b)/2,b), - Point<3> (b, (a+b)/2,b), - // back face of the big cube - // last (top right) point is missing - Point<3> (a, b,a), - Point<3> ((a+b)/2,b,a), - Point<3> (b, b,a), - Point<3> (a, b,(a+b)/2), - Point<3> ((a+b)/2,b,(a+b)/2), - Point<3> (b, b,(a+b)/2), - Point<3> (a, b,b), - Point<3> ((a+b)/2,b,b) + // front face of the big cube + Point<3> (a, a,a), + Point<3> ((a+b)/2,a,a), + Point<3> (b, a,a), + Point<3> (a, a,(a+b)/2), + Point<3> ((a+b)/2,a,(a+b)/2), + Point<3> (b, a,(a+b)/2), + Point<3> (a, a,b), + Point<3> ((a+b)/2,a,b), + Point<3> (b, a,b), + // middle face of the big cube + Point<3> (a, (a+b)/2,a), + Point<3> ((a+b)/2,(a+b)/2,a), + Point<3> (b, (a+b)/2,a), + Point<3> (a, (a+b)/2,(a+b)/2), + Point<3> ((a+b)/2,(a+b)/2,(a+b)/2), + Point<3> (b, (a+b)/2,(a+b)/2), + Point<3> (a, (a+b)/2,b), + Point<3> ((a+b)/2,(a+b)/2,b), + Point<3> (b, (a+b)/2,b), + // back face of the big cube + // last (top right) point is missing + Point<3> (a, b,a), + Point<3> ((a+b)/2,b,a), + Point<3> (b, b,a), + Point<3> (a, b,(a+b)/2), + Point<3> ((a+b)/2,b,(a+b)/2), + Point<3> (b, b,(a+b)/2), + Point<3> (a, b,b), + Point<3> ((a+b)/2,b,b) }; const int cell_vertices[7][8] = {{0, 1, 9, 10, 3, 4, 12, 13}, - {1, 2, 10, 11, 4, 5, 13, 14}, - {3, 4, 12, 13, 6, 7, 15, 16}, - {4, 5, 13, 14, 7, 8, 16, 17}, - {9, 10, 18, 19, 12, 13, 21, 22}, - {10, 11, 19, 20, 13, 14, 22, 23}, - {12, 13, 21, 22, 15, 16, 24, 25}}; + {1, 2, 10, 11, 4, 5, 13, 14}, + {3, 4, 12, 13, 6, 7, 15, 16}, + {4, 5, 13, 14, 7, 8, 16, 17}, + {9, 10, 18, 19, 12, 13, 21, 22}, + {10, 11, 19, 20, 13, 14, 22, 23}, + {12, 13, 21, 22, 15, 16, 24, 25}}; std::vector > cells (7, CellData<3>()); for (unsigned int i=0; i<7; ++i) { for (unsigned int j=0; j<8; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].vertices[j] = cell_vertices[i][j]; cells[i].material_id = 0; }; @@ -2199,54 +2199,54 @@ GridGenerator::hyper_L (Triangulation<3> &tria, template <> void GridGenerator::hyper_ball (Triangulation<3> &tria, - const Point<3> &p, - const double radius) + const Point<3> &p, + const double radius) { const double a = 1./(1+std::sqrt(3.0)); // equilibrate cell sizes at transition - // from the inner part to the radial - // cells + // from the inner part to the radial + // cells const unsigned int n_vertices = 16; const Point<3> vertices[n_vertices] = { - // first the vertices of the inner - // cell - p+Point<3>(-1,-1,-1)*(radius/std::sqrt(3.0)*a), - p+Point<3>(+1,-1,-1)*(radius/std::sqrt(3.0)*a), - p+Point<3>(+1,-1,+1)*(radius/std::sqrt(3.0)*a), - p+Point<3>(-1,-1,+1)*(radius/std::sqrt(3.0)*a), - p+Point<3>(-1,+1,-1)*(radius/std::sqrt(3.0)*a), - p+Point<3>(+1,+1,-1)*(radius/std::sqrt(3.0)*a), - p+Point<3>(+1,+1,+1)*(radius/std::sqrt(3.0)*a), - p+Point<3>(-1,+1,+1)*(radius/std::sqrt(3.0)*a), - // now the eight vertices at - // the outer sphere - p+Point<3>(-1,-1,-1)*(radius/std::sqrt(3.0)), - p+Point<3>(+1,-1,-1)*(radius/std::sqrt(3.0)), - p+Point<3>(+1,-1,+1)*(radius/std::sqrt(3.0)), - p+Point<3>(-1,-1,+1)*(radius/std::sqrt(3.0)), - p+Point<3>(-1,+1,-1)*(radius/std::sqrt(3.0)), - p+Point<3>(+1,+1,-1)*(radius/std::sqrt(3.0)), - p+Point<3>(+1,+1,+1)*(radius/std::sqrt(3.0)), - p+Point<3>(-1,+1,+1)*(radius/std::sqrt(3.0)), + // first the vertices of the inner + // cell + p+Point<3>(-1,-1,-1)*(radius/std::sqrt(3.0)*a), + p+Point<3>(+1,-1,-1)*(radius/std::sqrt(3.0)*a), + p+Point<3>(+1,-1,+1)*(radius/std::sqrt(3.0)*a), + p+Point<3>(-1,-1,+1)*(radius/std::sqrt(3.0)*a), + p+Point<3>(-1,+1,-1)*(radius/std::sqrt(3.0)*a), + p+Point<3>(+1,+1,-1)*(radius/std::sqrt(3.0)*a), + p+Point<3>(+1,+1,+1)*(radius/std::sqrt(3.0)*a), + p+Point<3>(-1,+1,+1)*(radius/std::sqrt(3.0)*a), + // now the eight vertices at + // the outer sphere + p+Point<3>(-1,-1,-1)*(radius/std::sqrt(3.0)), + p+Point<3>(+1,-1,-1)*(radius/std::sqrt(3.0)), + p+Point<3>(+1,-1,+1)*(radius/std::sqrt(3.0)), + p+Point<3>(-1,-1,+1)*(radius/std::sqrt(3.0)), + p+Point<3>(-1,+1,-1)*(radius/std::sqrt(3.0)), + p+Point<3>(+1,+1,-1)*(radius/std::sqrt(3.0)), + p+Point<3>(+1,+1,+1)*(radius/std::sqrt(3.0)), + p+Point<3>(-1,+1,+1)*(radius/std::sqrt(3.0)), }; - // one needs to draw the seven cubes to - // understand what's going on here + // one needs to draw the seven cubes to + // understand what's going on here const unsigned int n_cells = 7; const int cell_vertices[n_cells][8] = {{0, 1, 4, 5, 3, 2, 7, 6}, // center - {8, 9, 12, 13, 0, 1, 4, 5}, // bottom - {9, 13, 1, 5, 10, 14, 2, 6}, // right - {11, 10, 3, 2, 15, 14, 7, 6}, // top - {8, 0, 12, 4, 11, 3, 15, 7}, // left - {8, 9, 0, 1, 11, 10, 3, 2}, // front - {12, 4, 13, 5, 15, 7, 14, 6}}; // back + {8, 9, 12, 13, 0, 1, 4, 5}, // bottom + {9, 13, 1, 5, 10, 14, 2, 6}, // right + {11, 10, 3, 2, 15, 14, 7, 6}, // top + {8, 0, 12, 4, 11, 3, 15, 7}, // left + {8, 9, 0, 1, 11, 10, 3, 2}, // front + {12, 4, 13, 5, 15, 7, 14, 6}}; // back std::vector > cells (n_cells, CellData<3>()); for (unsigned int i=0; i::vertices_per_cell; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].vertices[j] = cell_vertices[i][j]; cells[i].material_id = 0; }; @@ -2262,40 +2262,40 @@ GridGenerator::hyper_ball (Triangulation<3> &tria, template <> void GridGenerator::cylinder (Triangulation<3> &tria, - const double radius, - const double half_length) + const double radius, + const double half_length) { - // Copy the base from hyper_ball<3> - // and transform it to yz + // Copy the base from hyper_ball<3> + // and transform it to yz const double d = radius/std::sqrt(2.0); const double a = d/(1+std::sqrt(2.0)); Point<3> vertices[24] = { - Point<3>(-d, -half_length,-d), - Point<3>( d, -half_length,-d), - Point<3>(-a, -half_length,-a), - Point<3>( a, -half_length,-a), - Point<3>(-a, -half_length, a), - Point<3>( a, -half_length, a), - Point<3>(-d, -half_length, d), - Point<3>( d, -half_length, d), - Point<3>(-d, 0,-d), - Point<3>( d, 0,-d), - Point<3>(-a, 0,-a), - Point<3>( a, 0,-a), - Point<3>(-a, 0, a), - Point<3>( a, 0, a), - Point<3>(-d, 0, d), - Point<3>( d, 0, d), - Point<3>(-d, half_length,-d), - Point<3>( d, half_length,-d), - Point<3>(-a, half_length,-a), - Point<3>( a, half_length,-a), - Point<3>(-a, half_length, a), - Point<3>( a, half_length, a), - Point<3>(-d, half_length, d), - Point<3>( d, half_length, d), + Point<3>(-d, -half_length,-d), + Point<3>( d, -half_length,-d), + Point<3>(-a, -half_length,-a), + Point<3>( a, -half_length,-a), + Point<3>(-a, -half_length, a), + Point<3>( a, -half_length, a), + Point<3>(-d, -half_length, d), + Point<3>( d, -half_length, d), + Point<3>(-d, 0,-d), + Point<3>( d, 0,-d), + Point<3>(-a, 0,-a), + Point<3>( a, 0,-a), + Point<3>(-a, 0, a), + Point<3>( a, 0, a), + Point<3>(-d, 0, d), + Point<3>( d, 0, d), + Point<3>(-d, half_length,-d), + Point<3>( d, half_length,-d), + Point<3>(-a, half_length,-a), + Point<3>( a, half_length,-a), + Point<3>(-a, half_length, a), + Point<3>( a, half_length, a), + Point<3>(-d, half_length, d), + Point<3>( d, half_length, d), }; - // Turn cylinder such that y->x + // Turn cylinder such that y->x for (unsigned int i=0;i<24;++i) { const double h = vertices[i](1); @@ -2304,11 +2304,11 @@ GridGenerator::cylinder (Triangulation<3> &tria, } int cell_vertices[10][8] = { - {0, 1, 8, 9, 2, 3, 10, 11}, - {0, 2, 8, 10, 6, 4, 14, 12}, - {2, 3, 10, 11, 4, 5, 12, 13}, - {1, 7, 9, 15, 3, 5, 11, 13}, - {6, 4, 14, 12, 7, 5, 15, 13} + {0, 1, 8, 9, 2, 3, 10, 11}, + {0, 2, 8, 10, 6, 4, 14, 12}, + {2, 3, 10, 11, 4, 5, 12, 13}, + {1, 7, 9, 15, 3, 5, 11, 13}, + {6, 4, 14, 12, 7, 5, 15, 13} }; for (unsigned int i=0;i<5;++i) for (unsigned int j=0;j<8;++j) @@ -2319,7 +2319,7 @@ GridGenerator::cylinder (Triangulation<3> &tria, for (unsigned int i=0; i<10; ++i) { for (unsigned int j=0; j<8; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].vertices[j] = cell_vertices[i][j]; cells[i].material_id = 0; }; @@ -2328,46 +2328,46 @@ GridGenerator::cylinder (Triangulation<3> &tria, cells, SubCellData()); // no boundary information - // set boundary indicators for the - // faces at the ends to 1 and 2, - // respectively. note that we also - // have to deal with those lines - // that are purely in the interior - // of the ends. we determine wether - // an edge is purely in the - // interior if one of its vertices - // is at coordinates '+-a' as set - // above + // set boundary indicators for the + // faces at the ends to 1 and 2, + // respectively. note that we also + // have to deal with those lines + // that are purely in the interior + // of the ends. we determine wether + // an edge is purely in the + // interior if one of its vertices + // is at coordinates '+-a' as set + // above Triangulation<3>::cell_iterator cell = tria.begin(); Triangulation<3>::cell_iterator end = tria.end(); for (; cell != end; ++cell) for (unsigned int i=0; i::faces_per_cell; ++i) if (cell->at_boundary(i)) - { - if (cell->face(i)->center()(0) > half_length-1.e-5) - { - cell->face(i)->set_boundary_indicator(2); - - for (unsigned int e=0; e::lines_per_face; ++e) - if ((std::fabs(cell->face(i)->line(e)->vertex(0)[1]) == a) || - (std::fabs(cell->face(i)->line(e)->vertex(0)[2]) == a) || - (std::fabs(cell->face(i)->line(e)->vertex(1)[1]) == a) || - (std::fabs(cell->face(i)->line(e)->vertex(1)[2]) == a)) - cell->face(i)->line(e)->set_boundary_indicator(2); - } - else if (cell->face(i)->center()(0) < -half_length+1.e-5) - { - cell->face(i)->set_boundary_indicator(1); - - for (unsigned int e=0; e::lines_per_face; ++e) - if ((std::fabs(cell->face(i)->line(e)->vertex(0)[1]) == a) || - (std::fabs(cell->face(i)->line(e)->vertex(0)[2]) == a) || - (std::fabs(cell->face(i)->line(e)->vertex(1)[1]) == a) || - (std::fabs(cell->face(i)->line(e)->vertex(1)[2]) == a)) - cell->face(i)->line(e)->set_boundary_indicator(1); - } - } + { + if (cell->face(i)->center()(0) > half_length-1.e-5) + { + cell->face(i)->set_boundary_indicator(2); + + for (unsigned int e=0; e::lines_per_face; ++e) + if ((std::fabs(cell->face(i)->line(e)->vertex(0)[1]) == a) || + (std::fabs(cell->face(i)->line(e)->vertex(0)[2]) == a) || + (std::fabs(cell->face(i)->line(e)->vertex(1)[1]) == a) || + (std::fabs(cell->face(i)->line(e)->vertex(1)[2]) == a)) + cell->face(i)->line(e)->set_boundary_indicator(2); + } + else if (cell->face(i)->center()(0) < -half_length+1.e-5) + { + cell->face(i)->set_boundary_indicator(1); + + for (unsigned int e=0; e::lines_per_face; ++e) + if ((std::fabs(cell->face(i)->line(e)->vertex(0)[1]) == a) || + (std::fabs(cell->face(i)->line(e)->vertex(0)[2]) == a) || + (std::fabs(cell->face(i)->line(e)->vertex(1)[1]) == a) || + (std::fabs(cell->face(i)->line(e)->vertex(1)[2]) == a)) + cell->face(i)->line(e)->set_boundary_indicator(1); + } + } } @@ -2376,8 +2376,8 @@ GridGenerator::cylinder (Triangulation<3> &tria, template <> void GridGenerator::half_hyper_ball (Triangulation<3>& tria, - const Point<3>& center, - const double radius) + const Point<3>& center, + const double radius) { // These are for the two lower squares const double d = radius/std::sqrt(2.0); @@ -2390,80 +2390,80 @@ GridGenerator::half_hyper_ball (Triangulation<3>& tria, const double hc = radius*std::sqrt(3.0)/2.0; Point<3> vertices[16] = { - center+Point<3>( 0, d, -d), - center+Point<3>( 0, -d, -d), - center+Point<3>( 0, a, -a), - center+Point<3>( 0, -a, -a), - center+Point<3>( 0, a, a), - center+Point<3>( 0, -a, a), - center+Point<3>( 0, d, d), - center+Point<3>( 0, -d, d), - - center+Point<3>(hc, c, -c), - center+Point<3>(hc, -c, -c), - center+Point<3>(hb, b, -b), - center+Point<3>(hb, -b, -b), - center+Point<3>(hb, b, b), - center+Point<3>(hb, -b, b), - center+Point<3>(hc, c, c), - center+Point<3>(hc, -c, c), + center+Point<3>( 0, d, -d), + center+Point<3>( 0, -d, -d), + center+Point<3>( 0, a, -a), + center+Point<3>( 0, -a, -a), + center+Point<3>( 0, a, a), + center+Point<3>( 0, -a, a), + center+Point<3>( 0, d, d), + center+Point<3>( 0, -d, d), + + center+Point<3>(hc, c, -c), + center+Point<3>(hc, -c, -c), + center+Point<3>(hb, b, -b), + center+Point<3>(hb, -b, -b), + center+Point<3>(hb, b, b), + center+Point<3>(hb, -b, b), + center+Point<3>(hc, c, c), + center+Point<3>(hc, -c, c), }; int cell_vertices[6][8] = { - {0, 1, 8, 9, 2, 3, 10, 11}, - {0, 2, 8, 10, 6, 4, 14, 12}, - {2, 3, 10, 11, 4, 5, 12, 13}, - {1, 7, 9, 15, 3, 5, 11, 13}, - {6, 4, 14, 12, 7, 5, 15, 13}, - {8, 10, 9, 11, 14, 12, 15, 13} + {0, 1, 8, 9, 2, 3, 10, 11}, + {0, 2, 8, 10, 6, 4, 14, 12}, + {2, 3, 10, 11, 4, 5, 12, 13}, + {1, 7, 9, 15, 3, 5, 11, 13}, + {6, 4, 14, 12, 7, 5, 15, 13}, + {8, 10, 9, 11, 14, 12, 15, 13} }; std::vector > cells (6, CellData<3>()); for (unsigned int i=0; i<6; ++i) { - for (unsigned int j=0; j<8; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; - cells[i].material_id = 0; + for (unsigned int j=0; j<8; ++j) + cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].material_id = 0; }; tria.create_triangulation ( - std::vector >(&vertices[0], &vertices[16]), - cells, - SubCellData()); // no boundary information + std::vector >(&vertices[0], &vertices[16]), + cells, + SubCellData()); // no boundary information Triangulation<3>::cell_iterator cell = tria.begin(); Triangulation<3>::cell_iterator end = tria.end(); while (cell != end) { - for (unsigned int i=0;i::faces_per_cell;++i) - { - if (!cell->at_boundary(i)) - continue; - - // If the center is on the plane x=0, this is a planar - // element - if (cell->face(i)->center()(0) < center(0)+1.e-5) { - cell->face(i)->set_boundary_indicator(1); - for (unsigned int j=0;j::lines_per_face;++j) - cell->face(i)->line(j)->set_boundary_indicator(1); - } - } - // With this loop we restore back the indicator of the outer lines - for (unsigned int i=0;i::faces_per_cell;++i) - { - if (!cell->at_boundary(i)) - continue; - - // If the center is not on the plane x=0, this is a curvilinear - // element - if (cell->face(i)->center()(0) > center(0)+1.e-5) { - for (unsigned int j=0;j::lines_per_face;++j) - cell->face(i)->line(j)->set_boundary_indicator(0); - } - } - ++cell; + for (unsigned int i=0;i::faces_per_cell;++i) + { + if (!cell->at_boundary(i)) + continue; + + // If the center is on the plane x=0, this is a planar + // element + if (cell->face(i)->center()(0) < center(0)+1.e-5) { + cell->face(i)->set_boundary_indicator(1); + for (unsigned int j=0;j::lines_per_face;++j) + cell->face(i)->line(j)->set_boundary_indicator(1); + } + } + // With this loop we restore back the indicator of the outer lines + for (unsigned int i=0;i::faces_per_cell;++i) + { + if (!cell->at_boundary(i)) + continue; + + // If the center is not on the plane x=0, this is a curvilinear + // element + if (cell->face(i)->center()(0) > center(0)+1.e-5) { + for (unsigned int j=0;j::lines_per_face;++j) + cell->face(i)->line(j)->set_boundary_indicator(0); + } + } + ++cell; } } @@ -2472,14 +2472,14 @@ template<> void GridGenerator:: colorize_hyper_shell (Triangulation<3>& tria, - const Point<3>&, - const double, - const double) + const Point<3>&, + const double, + const double) { - // the following uses a good amount - // of knowledge about the - // orientation of cells. this is - // probably not good style... + // the following uses a good amount + // of knowledge about the + // orientation of cells. this is + // probably not good style... if (tria.n_cells() == 6) { Triangulation<3>::cell_iterator cell = tria.begin(); @@ -2504,36 +2504,36 @@ colorize_hyper_shell (Triangulation<3>& tria, } else if (tria.n_cells() == 12) { - // again use some internal - // knowledge + // again use some internal + // knowledge for (Triangulation<3>::cell_iterator cell = tria.begin(); - cell != tria.end(); ++cell) - { - Assert (cell->face(5)->at_boundary(), ExcInternalError()); - cell->face(5)->set_boundary_indicator(1); - } + cell != tria.end(); ++cell) + { + Assert (cell->face(5)->at_boundary(), ExcInternalError()); + cell->face(5)->set_boundary_indicator(1); + } } else if (tria.n_cells() == 96) { - // the 96-cell hypershell is - // based on a once refined - // 12-cell mesh. consequently, - // since the outer faces all - // are face_no==5 above, so - // they are here (unless they - // are in the interior). Use - // this to assign boundary - // indicators, but also make - // sure that we encounter - // exactly 48 such faces + // the 96-cell hypershell is + // based on a once refined + // 12-cell mesh. consequently, + // since the outer faces all + // are face_no==5 above, so + // they are here (unless they + // are in the interior). Use + // this to assign boundary + // indicators, but also make + // sure that we encounter + // exactly 48 such faces unsigned int count = 0; for (Triangulation<3>::cell_iterator cell = tria.begin(); - cell != tria.end(); ++cell) - if (cell->face(5)->at_boundary()) - { - cell->face(5)->set_boundary_indicator(1); - ++count; - } + cell != tria.end(); ++cell) + if (cell->face(5)->at_boundary()) + { + cell->face(5)->set_boundary_indicator(1); + ++count; + } Assert (count == 48, ExcInternalError()); } else @@ -2545,99 +2545,99 @@ colorize_hyper_shell (Triangulation<3>& tria, template <> void GridGenerator::hyper_shell (Triangulation<3>& tria, - const Point<3>& p, - const double inner_radius, - const double outer_radius, - const unsigned int n, - const bool colorize) + const Point<3>& p, + const double inner_radius, + const double outer_radius, + const unsigned int n, + const bool colorize) { Assert ((inner_radius > 0) && (inner_radius < outer_radius), - ExcInvalidRadii ()); + ExcInvalidRadii ()); const double irad = inner_radius/std::sqrt(3.0); const double orad = outer_radius/std::sqrt(3.0); std::vector > vertices; std::vector > cells; - // Start with the shell bounded by - // two nested cubes + // Start with the shell bounded by + // two nested cubes if (n == 6) { for (unsigned int i=0;i<8;++i) - vertices.push_back(p+hexahedron[i]*irad); + vertices.push_back(p+hexahedron[i]*irad); for (unsigned int i=0;i<8;++i) - vertices.push_back(p+hexahedron[i]*orad); + vertices.push_back(p+hexahedron[i]*orad); const unsigned int n_cells = 6; const int cell_vertices[n_cells][8] = - {{8, 9, 10, 11, 0, 1, 2, 3}, // bottom - {9, 11, 1, 3, 13, 15, 5, 7}, // right - {12, 13, 4, 5, 14, 15, 6, 7}, // top - {8, 0, 10, 2, 12, 4, 14, 6}, // left - {8, 9, 0, 1, 12, 13, 4, 5}, // front - {10, 2, 11, 3, 14, 6, 15, 7}}; // back + {{8, 9, 10, 11, 0, 1, 2, 3}, // bottom + {9, 11, 1, 3, 13, 15, 5, 7}, // right + {12, 13, 4, 5, 14, 15, 6, 7}, // top + {8, 0, 10, 2, 12, 4, 14, 6}, // left + {8, 9, 0, 1, 12, 13, 4, 5}, // front + {10, 2, 11, 3, 14, 6, 15, 7}}; // back cells.resize(n_cells, CellData<3>()); for (unsigned int i=0; i::vertices_per_cell; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; - cells[i].material_id = 0; - } + { + for (unsigned int j=0; j::vertices_per_cell; ++j) + cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].material_id = 0; + } tria.create_triangulation (vertices, cells, SubCellData()); } - // A more regular subdivision can - // be obtained by two nested - // rhombic dodecahedra + // A more regular subdivision can + // be obtained by two nested + // rhombic dodecahedra else if (n == 12) { for (unsigned int i=0;i<8;++i) - vertices.push_back(p+hexahedron[i]*irad); + vertices.push_back(p+hexahedron[i]*irad); for (unsigned int i=0;i<6;++i) - vertices.push_back(p+octahedron[i]*inner_radius); + vertices.push_back(p+octahedron[i]*inner_radius); for (unsigned int i=0;i<8;++i) - vertices.push_back(p+hexahedron[i]*orad); + vertices.push_back(p+hexahedron[i]*orad); for (unsigned int i=0;i<6;++i) - vertices.push_back(p+octahedron[i]*outer_radius); + vertices.push_back(p+octahedron[i]*outer_radius); const unsigned int n_cells = 12; const unsigned int rhombi[n_cells][4] = - {{ 10, 4, 0, 8}, - { 4, 13, 8, 6}, - { 10, 5, 4, 13}, - { 1, 9, 10, 5}, - { 9, 7, 5, 13}, - { 7, 11, 13, 6}, - { 9, 3, 7, 11}, - { 1, 12, 9, 3}, - { 12, 2, 3, 11}, - { 2, 8, 11, 6}, - { 12, 0, 2, 8}, - { 1, 10, 12, 0}}; + {{ 10, 4, 0, 8}, + { 4, 13, 8, 6}, + { 10, 5, 4, 13}, + { 1, 9, 10, 5}, + { 9, 7, 5, 13}, + { 7, 11, 13, 6}, + { 9, 3, 7, 11}, + { 1, 12, 9, 3}, + { 12, 2, 3, 11}, + { 2, 8, 11, 6}, + { 12, 0, 2, 8}, + { 1, 10, 12, 0}}; cells.resize(n_cells, CellData<3>()); for (unsigned int i=0; i boundary (p); Triangulation<3> tmp; GridGenerator::hyper_shell (tmp, p, inner_radius, outer_radius, 12); @@ -2645,112 +2645,112 @@ GridGenerator::hyper_shell (Triangulation<3>& tria, tmp.set_boundary(1, boundary); tmp.refine_global (1); - // let's determine the distance at - // which the interior nodes should be - // from the center. let's say we - // measure distances in multiples of - // outer_radius and call - // r=inner_radius. - // - // then note - // that we now have 48 faces on the - // inner and 48 on the outer sphere, - // each with an area of approximately - // 4*pi/48*r^2 and 4*pi/48, for - // a face edge length of approximately - // sqrt(pi/12)*r and sqrt(pi/12) - // - // let's say we put the interior nodes - // at a distance rho, then a measure of - // deformation for the inner cells - // would be - // di=max(sqrt(pi/12)*r/(rho-r), - // (rho-r)/sqrt(pi/12)/r) - // and for the outer cells - // do=max(sqrt(pi/12)/(1-rho), - // (1-rho)/sqrt(pi/12)) - // - // we now seek a rho so that the - // deformation of cells on the inside - // and outside is equal. there are in - // principle four possibilities for one - // of the branches of do== one of the - // branches of di, though not all of - // them satisfy do==di, of - // course. however, we are not - // interested in cases where the inner - // cell is long and skinny and the - // outer one tall -- yes, they have the - // same aspect ratio, but in different - // space directions. - // - // so it only boils down to the - // following two possibilities: the - // first branch of each max(.,.) - // functions are equal, or the second - // one are. on the other hand, since - // they two branches are reciprocals of - // each other, if one pair of branches - // is equal, so is the other - // - // this yields the following equation - // for rho: - // sqrt(pi/12)*r/(rho-r) - // == sqrt(pi/12)/(1-rho) - // with solution rho=2r/(1+r) + // let's determine the distance at + // which the interior nodes should be + // from the center. let's say we + // measure distances in multiples of + // outer_radius and call + // r=inner_radius. + // + // then note + // that we now have 48 faces on the + // inner and 48 on the outer sphere, + // each with an area of approximately + // 4*pi/48*r^2 and 4*pi/48, for + // a face edge length of approximately + // sqrt(pi/12)*r and sqrt(pi/12) + // + // let's say we put the interior nodes + // at a distance rho, then a measure of + // deformation for the inner cells + // would be + // di=max(sqrt(pi/12)*r/(rho-r), + // (rho-r)/sqrt(pi/12)/r) + // and for the outer cells + // do=max(sqrt(pi/12)/(1-rho), + // (1-rho)/sqrt(pi/12)) + // + // we now seek a rho so that the + // deformation of cells on the inside + // and outside is equal. there are in + // principle four possibilities for one + // of the branches of do== one of the + // branches of di, though not all of + // them satisfy do==di, of + // course. however, we are not + // interested in cases where the inner + // cell is long and skinny and the + // outer one tall -- yes, they have the + // same aspect ratio, but in different + // space directions. + // + // so it only boils down to the + // following two possibilities: the + // first branch of each max(.,.) + // functions are equal, or the second + // one are. on the other hand, since + // they two branches are reciprocals of + // each other, if one pair of branches + // is equal, so is the other + // + // this yields the following equation + // for rho: + // sqrt(pi/12)*r/(rho-r) + // == sqrt(pi/12)/(1-rho) + // with solution rho=2r/(1+r) const double r = inner_radius / outer_radius; const double rho = 2*r/(1+r); - // then this is the distance of the - // interior nodes from the center: + // then this is the distance of the + // interior nodes from the center: const double middle_radius = rho * outer_radius; - // mark vertices we've already moved or - // that we want to ignore: we don't - // want to move vertices at the inner - // or outer boundaries + // mark vertices we've already moved or + // that we want to ignore: we don't + // want to move vertices at the inner + // or outer boundaries std::vector vertex_already_treated (tmp.n_vertices(), false); for (Triangulation<3>::active_cell_iterator cell = tmp.begin_active(); - cell != tmp.end(); ++cell) - for (unsigned int f=0; f::faces_per_cell; ++f) - if (cell->at_boundary(f)) - for (unsigned int v=0; v::vertices_per_face; ++v) - vertex_already_treated[cell->face(f)->vertex_index(v)] = true; + cell != tmp.end(); ++cell) + for (unsigned int f=0; f::faces_per_cell; ++f) + if (cell->at_boundary(f)) + for (unsigned int v=0; v::vertices_per_face; ++v) + vertex_already_treated[cell->face(f)->vertex_index(v)] = true; - // now move the remaining vertices + // now move the remaining vertices for (Triangulation<3>::active_cell_iterator cell = tmp.begin_active(); - cell != tmp.end(); ++cell) - for (unsigned int v=0; v::vertices_per_cell; ++v) - if (vertex_already_treated[cell->vertex_index(v)] == false) - { - // this is a new interior - // vertex. mesh refinement may - // have placed it at a number - // of places in radial - // direction and oftentimes not - // in a particularly good - // one. move it to halfway - // between inner and outer - // sphere - const Point<3> old_distance = cell->vertex(v) - p; - const double old_radius = cell->vertex(v).distance(p); - cell->vertex(v) = p + old_distance * (middle_radius / old_radius); - - vertex_already_treated[cell->vertex_index(v)] = true; - } - - // now copy the resulting level 1 cells - // into the new triangulation, + cell != tmp.end(); ++cell) + for (unsigned int v=0; v::vertices_per_cell; ++v) + if (vertex_already_treated[cell->vertex_index(v)] == false) + { + // this is a new interior + // vertex. mesh refinement may + // have placed it at a number + // of places in radial + // direction and oftentimes not + // in a particularly good + // one. move it to halfway + // between inner and outer + // sphere + const Point<3> old_distance = cell->vertex(v) - p; + const double old_radius = cell->vertex(v).distance(p); + cell->vertex(v) = p + old_distance * (middle_radius / old_radius); + + vertex_already_treated[cell->vertex_index(v)] = true; + } + + // now copy the resulting level 1 cells + // into the new triangulation, cells.resize(tmp.n_active_cells(), CellData<3>()); unsigned int index = 0; for (Triangulation<3>::active_cell_iterator cell = tmp.begin_active(); - cell != tmp.end(); ++cell, ++index) - { - for (unsigned int v=0; v::vertices_per_cell; ++v) - cells[index].vertices[v] = cell->vertex_index(v); - cells[index].material_id = 0; - } + cell != tmp.end(); ++cell, ++index) + { + for (unsigned int v=0; v::vertices_per_cell; ++v) + cells[index].vertices[v] = cell->vertex_index(v); + cells[index].material_id = 0; + } tria.create_triangulation (tmp.get_vertices(), cells, SubCellData()); } @@ -2770,14 +2770,14 @@ GridGenerator::hyper_shell (Triangulation<3>& tria, template <> void GridGenerator::half_hyper_shell (Triangulation<3>& tria, - const Point<3>& center, - const double inner_radius, - const double outer_radius, - const unsigned int n, - const bool colorize) + const Point<3>& center, + const double inner_radius, + const double outer_radius, + const unsigned int n, + const bool colorize) { Assert ((inner_radius > 0) && (inner_radius < outer_radius), - ExcInvalidRadii ()); + ExcInvalidRadii ()); Assert(colorize == false, ExcNotImplemented()); if (n <= 5) @@ -2793,46 +2793,46 @@ GridGenerator::half_hyper_shell (Triangulation<3>& tria, const double hc = outer_radius*std::sqrt(3.0)/2.0; Point<3> vertices[16] = { - center+Point<3>( 0, d, -d), - center+Point<3>( 0, -d, -d), - center+Point<3>( 0, a, -a), - center+Point<3>( 0, -a, -a), - center+Point<3>( 0, a, a), - center+Point<3>( 0, -a, a), - center+Point<3>( 0, d, d), - center+Point<3>( 0, -d, d), - - center+Point<3>(hc, c, -c), - center+Point<3>(hc, -c, -c), - center+Point<3>(hb, b, -b), - center+Point<3>(hb, -b, -b), - center+Point<3>(hb, b, b), - center+Point<3>(hb, -b, b), - center+Point<3>(hc, c, c), - center+Point<3>(hc, -c, c), + center+Point<3>( 0, d, -d), + center+Point<3>( 0, -d, -d), + center+Point<3>( 0, a, -a), + center+Point<3>( 0, -a, -a), + center+Point<3>( 0, a, a), + center+Point<3>( 0, -a, a), + center+Point<3>( 0, d, d), + center+Point<3>( 0, -d, d), + + center+Point<3>(hc, c, -c), + center+Point<3>(hc, -c, -c), + center+Point<3>(hb, b, -b), + center+Point<3>(hb, -b, -b), + center+Point<3>(hb, b, b), + center+Point<3>(hb, -b, b), + center+Point<3>(hc, c, c), + center+Point<3>(hc, -c, c), }; int cell_vertices[5][8] = { - {0, 1, 8, 9, 2, 3, 10, 11}, - {0, 2, 8, 10, 6, 4, 14, 12}, - {1, 7, 9, 15, 3, 5, 11, 13}, - {6, 4, 14, 12, 7, 5, 15, 13}, - {8, 10, 9, 11, 14, 12, 15, 13} + {0, 1, 8, 9, 2, 3, 10, 11}, + {0, 2, 8, 10, 6, 4, 14, 12}, + {1, 7, 9, 15, 3, 5, 11, 13}, + {6, 4, 14, 12, 7, 5, 15, 13}, + {8, 10, 9, 11, 14, 12, 15, 13} }; std::vector > cells (5, CellData<3>()); for (unsigned int i=0; i<5; ++i) - { - for (unsigned int j=0; j<8; ++j) - cells[i].vertices[j] = cell_vertices[i][j]; - cells[i].material_id = 0; - }; + { + for (unsigned int j=0; j<8; ++j) + cells[i].vertices[j] = cell_vertices[i][j]; + cells[i].material_id = 0; + }; tria.create_triangulation ( - std::vector >(&vertices[0], &vertices[16]), - cells, - SubCellData()); // no boundary information + std::vector >(&vertices[0], &vertices[16]), + cells, + SubCellData()); // no boundary information } else { @@ -2935,19 +2935,19 @@ void GridGenerator::quarter_hyper_shell (Triangulation<3> & tria, std::vector > vertices; vertices.push_back (center+Point<3>( 0, inner_radius, 0)); //0 - vertices.push_back (center+Point<3>( a, a, 0)); //1 - vertices.push_back (center+Point<3>( b, b, 0)); //2 - vertices.push_back (center+Point<3>( 0, outer_radius, 0)); //3 - vertices.push_back (center+Point<3>( 0, a , a)); //4 - vertices.push_back (center+Point<3>( c, c , h)); //5 - vertices.push_back (center+Point<3>( d, d , e)); //6 - vertices.push_back (center+Point<3>( 0, b , b)); //7 - vertices.push_back (center+Point<3>( inner_radius, 0 , 0)); //8 - vertices.push_back (center+Point<3>( outer_radius, 0 , 0)); //9 - vertices.push_back (center+Point<3>( a, 0 , a)); //10 - vertices.push_back (center+Point<3>( b, 0 , b)); //11 - vertices.push_back (center+Point<3>( 0, 0 , inner_radius)); //12 - vertices.push_back (center+Point<3>( 0, 0 , outer_radius)); //13 + vertices.push_back (center+Point<3>( a, a, 0)); //1 + vertices.push_back (center+Point<3>( b, b, 0)); //2 + vertices.push_back (center+Point<3>( 0, outer_radius, 0)); //3 + vertices.push_back (center+Point<3>( 0, a , a)); //4 + vertices.push_back (center+Point<3>( c, c , h)); //5 + vertices.push_back (center+Point<3>( d, d , e)); //6 + vertices.push_back (center+Point<3>( 0, b , b)); //7 + vertices.push_back (center+Point<3>( inner_radius, 0 , 0)); //8 + vertices.push_back (center+Point<3>( outer_radius, 0 , 0)); //9 + vertices.push_back (center+Point<3>( a, 0 , a)); //10 + vertices.push_back (center+Point<3>( b, 0 , b)); //11 + vertices.push_back (center+Point<3>( 0, 0 , inner_radius)); //12 + vertices.push_back (center+Point<3>( 0, 0 , outer_radius)); //13 const int cell_vertices[3][8] = { {0, 1, 3, 2, 4, 5, 7, 6}, @@ -2985,19 +2985,19 @@ void GridGenerator::cylinder_shell (Triangulation<3> &tria, const unsigned int n_axial_cells) { Assert ((inner_radius > 0) && (inner_radius < outer_radius), - ExcInvalidRadii ()); + ExcInvalidRadii ()); const double pi = numbers::PI; - // determine the number of cells - // for the grid. if not provided by - // the user determine it such that - // the length of each cell on the - // median (in the middle between - // the two circles) is equal to its - // radial extent (which is the - // difference between the two - // radii) + // determine the number of cells + // for the grid. if not provided by + // the user determine it such that + // the length of each cell on the + // median (in the middle between + // the two circles) is equal to its + // radial extent (which is the + // difference between the two + // radii) const unsigned int N_r = (n_radial_cells == 0 ? static_cast (std::ceil((2*pi* (outer_radius + inner_radius)/2) / @@ -3009,12 +3009,12 @@ void GridGenerator::cylinder_shell (Triangulation<3> &tria, (2*pi*(outer_radius + inner_radius)/2/N_r))) : n_axial_cells); - // set up N vertices on the - // outer and N vertices on - // the inner circle. the - // first N ones are on the - // outer one, and all are - // numbered counter-clockwise + // set up N vertices on the + // outer and N vertices on + // the inner circle. the + // first N ones are on the + // outer one, and all are + // numbered counter-clockwise std::vector > vertices_2d(2*N_r); for (unsigned int i=0; i void GridGenerator:: merge_triangulations (const Triangulation &triangulation_1, - const Triangulation &triangulation_2, - Triangulation &result) + const Triangulation &triangulation_2, + Triangulation &result) { Assert (triangulation_1.n_levels() == 1, - ExcMessage ("The input triangulations must be coarse meshes.")); + ExcMessage ("The input triangulations must be coarse meshes.")); Assert (triangulation_2.n_levels() == 1, - ExcMessage ("The input triangulations must be coarse meshes.")); + ExcMessage ("The input triangulations must be coarse meshes.")); // get the union of the set of vertices std::vector > vertices = triangulation_1.get_vertices(); vertices.insert (vertices.end(), - triangulation_2.get_vertices().begin(), - triangulation_2.get_vertices().end()); + triangulation_2.get_vertices().begin(), + triangulation_2.get_vertices().end()); // now form the union of the set of cells std::vector > cells; @@ -3119,8 +3119,8 @@ merge_triangulations (const Triangulation &triangulation_1, // this is not necessary here as this is an internal only function. inline void GridGenerator::laplace_solve (const SparseMatrix &S, - const std::map &m, - Vector &u) + const std::map &m, + Vector &u) { const unsigned int n_dofs=S.n(); FilteredMatrix > SF (S); @@ -3143,7 +3143,7 @@ void GridGenerator::laplace_solve (const SparseMatrix &S, // Implementation for 1D only template <> void GridGenerator::laplace_transformation (Triangulation<1> &, - const std::map > &) + const std::map > &) { Assert(false, ExcNotImplemented()); } @@ -3152,18 +3152,18 @@ void GridGenerator::laplace_transformation (Triangulation<1> &, // Implementation for dimensions except 1 template void GridGenerator::laplace_transformation (Triangulation &tria, - const std::map > &new_points) + const std::map > &new_points) { - // first provide everything that is - // needed for solving a Laplace - // equation. + // first provide everything that is + // needed for solving a Laplace + // equation. MappingQ1 mapping_q1; FE_Q q1(1); DoFHandler dof_handler(tria); dof_handler.distribute_dofs(q1); SparsityPattern sparsity_pattern (dof_handler.n_dofs (), dof_handler.n_dofs (), - dof_handler.max_couplings_between_dofs()); + dof_handler.max_couplings_between_dofs()); DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern); sparsity_pattern.compress (); @@ -3173,62 +3173,62 @@ void GridGenerator::laplace_transformation (Triangulation &tria, MatrixCreator::create_laplace_matrix(mapping_q1, dof_handler, quadrature, S); - // set up the boundary values for - // the laplace problem + // set up the boundary values for + // the laplace problem std::vector > m(dim); typename std::map >::const_iterator map_iter; typename std::map >::const_iterator map_end=new_points.end(); - // fill these maps using the data - // given by new_points + // fill these maps using the data + // given by new_points typename DoFHandler::cell_iterator cell=dof_handler.begin_active(), - endc=dof_handler.end(); + endc=dof_handler.end(); typename DoFHandler::face_iterator face; for (; cell!=endc; ++cell) { if (cell->at_boundary()) - for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) - { - face=cell->face(face_no); - if (face->at_boundary()) - for (unsigned int vertex_no=0; - vertex_no::vertices_per_face; ++vertex_no) - { - const unsigned int vertex_index=face->vertex_index(vertex_no); - map_iter=new_points.find(vertex_index); - - if (map_iter!=map_end) - for (unsigned int i=0; i ( - face->vertex_dof_index(vertex_no, 0), map_iter->second(i))); - } - } + for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) + { + face=cell->face(face_no); + if (face->at_boundary()) + for (unsigned int vertex_no=0; + vertex_no::vertices_per_face; ++vertex_no) + { + const unsigned int vertex_index=face->vertex_index(vertex_no); + map_iter=new_points.find(vertex_index); + + if (map_iter!=map_end) + for (unsigned int i=0; i ( + face->vertex_dof_index(vertex_no, 0), map_iter->second(i))); + } + } } - // solve the dim problems with - // different right hand sides. + // solve the dim problems with + // different right hand sides. Vector us[dim]; for (unsigned int i=0; i tasks; for (unsigned int i=0; i::vertices_per_cell; ++vertex_no) + vertex_no::vertices_per_cell; ++vertex_no) { - Point &v=cell->vertex(vertex_no); - const unsigned int dof_index=cell->vertex_dof_index(vertex_no, 0); - for (unsigned int i=0; i &v=cell->vertex(vertex_no); + const unsigned int dof_index=cell->vertex_dof_index(vertex_no, 0); + for (unsigned int i=0; i &tria, template <> void GridGenerator::hyper_cube_with_cylindrical_hole (Triangulation<1> &, - const double, - const double, - const double, - const unsigned int, - bool){ + const double, + const double, + const double, + const unsigned int, + bool){ Assert(false, ExcNotImplemented()); } @@ -3249,21 +3249,21 @@ void GridGenerator::hyper_cube_with_cylindrical_hole (Triangulation<1> &, template <> void GridGenerator::hyper_cube_with_cylindrical_hole (Triangulation<2> &triangulation, - const double inner_radius, - const double outer_radius, - const double, // width, - const unsigned int, // width_repetition, - bool colorize) + const double inner_radius, + const double outer_radius, + const double, // width, + const unsigned int, // width_repetition, + bool colorize) { const int dim = 2; Assert(inner_radius < outer_radius, - ExcMessage("outer_radius has to be bigger than inner_radius.")); + ExcMessage("outer_radius has to be bigger than inner_radius.")); Point center; // We create an hyper_shell in two dimensions, and then we modify it. GridGenerator::hyper_shell (triangulation, - center, inner_radius, outer_radius, + center, inner_radius, outer_radius, 8); Triangulation::active_cell_iterator cell = triangulation.begin_active(), @@ -3272,27 +3272,27 @@ GridGenerator::hyper_cube_with_cylindrical_hole (Triangulation<2> &triangulation for(; cell != endc; ++cell) { for(unsigned int f=0; f::faces_per_cell; ++f) if(cell->face(f)->at_boundary()) { - for(unsigned int v=0; v < GeometryInfo::vertices_per_face; ++v) { - unsigned int vv = cell->face(f)->vertex_index(v); - if(treated_vertices[vv] == false) { - treated_vertices[vv] = true; - switch(vv) { - case 1: - cell->face(f)->vertex(v) = center+Point(outer_radius,outer_radius); - break; - case 3: - cell->face(f)->vertex(v) = center+Point(-outer_radius,outer_radius); - break; - case 5: - cell->face(f)->vertex(v) = center+Point(-outer_radius,-outer_radius); - break; - case 7: - cell->face(f)->vertex(v) = center+Point(outer_radius,-outer_radius); - default: - break; - } - } - } + for(unsigned int v=0; v < GeometryInfo::vertices_per_face; ++v) { + unsigned int vv = cell->face(f)->vertex_index(v); + if(treated_vertices[vv] == false) { + treated_vertices[vv] = true; + switch(vv) { + case 1: + cell->face(f)->vertex(v) = center+Point(outer_radius,outer_radius); + break; + case 3: + cell->face(f)->vertex(v) = center+Point(-outer_radius,outer_radius); + break; + case 5: + cell->face(f)->vertex(v) = center+Point(-outer_radius,-outer_radius); + break; + case 7: + cell->face(f)->vertex(v) = center+Point(outer_radius,-outer_radius); + default: + break; + } + } + } } } double eps = 1e-3 * outer_radius; @@ -3300,50 +3300,50 @@ GridGenerator::hyper_cube_with_cylindrical_hole (Triangulation<2> &triangulation for(; cell != endc; ++cell) { for(unsigned int f=0; f::faces_per_cell; ++f) if(cell->face(f)->at_boundary()) { - double dx = cell->face(f)->center()(0) - center(0); - double dy = cell->face(f)->center()(1) - center(1); - if(colorize) { - if(std::abs(dx + outer_radius) < eps) - cell->face(f)->set_boundary_indicator(0); - else if(std::abs(dx - outer_radius) < eps) - cell->face(f)->set_boundary_indicator(1); - else if(std::abs(dy + outer_radius) < eps) - cell->face(f)->set_boundary_indicator(2); - else if(std::abs(dy - outer_radius) < eps) - cell->face(f)->set_boundary_indicator(3); - else - cell->face(f)->set_boundary_indicator(4); - } else { - double d = (cell->face(f)->center() - center).norm(); - if(d-inner_radius < 0) - cell->face(f)->set_boundary_indicator(1); - else - cell->face(f)->set_boundary_indicator(0); - } + double dx = cell->face(f)->center()(0) - center(0); + double dy = cell->face(f)->center()(1) - center(1); + if(colorize) { + if(std::abs(dx + outer_radius) < eps) + cell->face(f)->set_boundary_indicator(0); + else if(std::abs(dx - outer_radius) < eps) + cell->face(f)->set_boundary_indicator(1); + else if(std::abs(dy + outer_radius) < eps) + cell->face(f)->set_boundary_indicator(2); + else if(std::abs(dy - outer_radius) < eps) + cell->face(f)->set_boundary_indicator(3); + else + cell->face(f)->set_boundary_indicator(4); + } else { + double d = (cell->face(f)->center() - center).norm(); + if(d-inner_radius < 0) + cell->face(f)->set_boundary_indicator(1); + else + cell->face(f)->set_boundary_indicator(0); + } } } } template <> void GridGenerator::hyper_cube_with_cylindrical_hole(Triangulation<3> &triangulation, - const double inner_radius, - const double outer_radius, - const double L, - const unsigned int Nz, - bool colorize) + const double inner_radius, + const double outer_radius, + const double L, + const unsigned int Nz, + bool colorize) { const int dim = 3; Assert(inner_radius < outer_radius, - ExcMessage("outer_radius has to be bigger than inner_radius.")); + ExcMessage("outer_radius has to be bigger than inner_radius.")); Assert(L > 0, - ExcMessage("Must give positive extension L")); + ExcMessage("Must give positive extension L")); Assert(Nz >= 1, ExcLowerRange(1, Nz)); GridGenerator::cylinder_shell (triangulation, - L, inner_radius, outer_radius, - 8, - Nz); + L, inner_radius, outer_radius, + 8, + Nz); Triangulation::active_cell_iterator cell = triangulation.begin_active(), @@ -3352,31 +3352,31 @@ void GridGenerator::hyper_cube_with_cylindrical_hole(Triangulation<3> &triangula for(; cell != endc; ++cell) { for(unsigned int f=0; f::faces_per_cell; ++f) if(cell->face(f)->at_boundary()) { - for(unsigned int v=0; v < GeometryInfo::vertices_per_face; ++v) { - unsigned int vv = cell->face(f)->vertex_index(v); - if(treated_vertices[vv] == false) { - treated_vertices[vv] = true; - for(unsigned int i=0; i<=Nz; ++i) { - double d = ((double) i)*L/((double) Nz); - switch(vv-i*16) { - case 1: - cell->face(f)->vertex(v) = Point(outer_radius,outer_radius,d); - break; - case 3: - cell->face(f)->vertex(v) = Point(-outer_radius,outer_radius,d); - break; - case 5: - cell->face(f)->vertex(v) = Point(-outer_radius,-outer_radius,d); - break; - case 7: - cell->face(f)->vertex(v) = Point(outer_radius,-outer_radius,d); - break; - default: - break; - } - } - } - } + for(unsigned int v=0; v < GeometryInfo::vertices_per_face; ++v) { + unsigned int vv = cell->face(f)->vertex_index(v); + if(treated_vertices[vv] == false) { + treated_vertices[vv] = true; + for(unsigned int i=0; i<=Nz; ++i) { + double d = ((double) i)*L/((double) Nz); + switch(vv-i*16) { + case 1: + cell->face(f)->vertex(v) = Point(outer_radius,outer_radius,d); + break; + case 3: + cell->face(f)->vertex(v) = Point(-outer_radius,outer_radius,d); + break; + case 5: + cell->face(f)->vertex(v) = Point(-outer_radius,-outer_radius,d); + break; + case 7: + cell->face(f)->vertex(v) = Point(outer_radius,-outer_radius,d); + break; + default: + break; + } + } + } + } } } double eps = 1e-3 * outer_radius; @@ -3384,46 +3384,46 @@ void GridGenerator::hyper_cube_with_cylindrical_hole(Triangulation<3> &triangula for(; cell != endc; ++cell) { for(unsigned int f=0; f::faces_per_cell; ++f) if(cell->face(f)->at_boundary()) { - double dx = cell->face(f)->center()(0); - double dy = cell->face(f)->center()(1); - double dz = cell->face(f)->center()(2); - - if(colorize) { - if(std::abs(dx + outer_radius) < eps) - cell->face(f)->set_boundary_indicator(0); - - else if(std::abs(dx - outer_radius) < eps) - cell->face(f)->set_boundary_indicator(1); - - else if(std::abs(dy + outer_radius) < eps) - cell->face(f)->set_boundary_indicator(2); - - else if(std::abs(dy - outer_radius) < eps) - cell->face(f)->set_boundary_indicator(3); - - else if(std::abs(dz) < eps) - cell->face(f)->set_boundary_indicator(4); - - else if(std::abs(dz - L) < eps) - cell->face(f)->set_boundary_indicator(5); - - else { - cell->face(f)->set_boundary_indicator(6); - for(unsigned int l=0; l::lines_per_face; ++l) - cell->face(f)->line(l)->set_boundary_indicator(6); - } - - } else { - Point c = cell->face(f)->center(); - c(2) = 0; - double d = c.norm(); - if(d-inner_radius < 0) { - cell->face(f)->set_boundary_indicator(1); - for(unsigned int l=0; l::lines_per_face; ++l) - cell->face(f)->line(l)->set_boundary_indicator(1); - } else - cell->face(f)->set_boundary_indicator(0); - } + double dx = cell->face(f)->center()(0); + double dy = cell->face(f)->center()(1); + double dz = cell->face(f)->center()(2); + + if(colorize) { + if(std::abs(dx + outer_radius) < eps) + cell->face(f)->set_boundary_indicator(0); + + else if(std::abs(dx - outer_radius) < eps) + cell->face(f)->set_boundary_indicator(1); + + else if(std::abs(dy + outer_radius) < eps) + cell->face(f)->set_boundary_indicator(2); + + else if(std::abs(dy - outer_radius) < eps) + cell->face(f)->set_boundary_indicator(3); + + else if(std::abs(dz) < eps) + cell->face(f)->set_boundary_indicator(4); + + else if(std::abs(dz - L) < eps) + cell->face(f)->set_boundary_indicator(5); + + else { + cell->face(f)->set_boundary_indicator(6); + for(unsigned int l=0; l::lines_per_face; ++l) + cell->face(f)->line(l)->set_boundary_indicator(6); + } + + } else { + Point c = cell->face(f)->center(); + c(2) = 0; + double d = c.norm(); + if(d-inner_radius < 0) { + cell->face(f)->set_boundary_indicator(1); + for(unsigned int l=0; l::lines_per_face; ++l) + cell->face(f)->line(l)->set_boundary_indicator(1); + } else + cell->face(f)->set_boundary_indicator(0); + } } } } diff --git a/deal.II/source/grid/grid_in.cc b/deal.II/source/grid/grid_in.cc index 97dba60d06..2a075f091d 100644 --- a/deal.II/source/grid/grid_in.cc +++ b/deal.II/source/grid/grid_in.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -35,7 +35,7 @@ DEAL_II_NAMESPACE_OPEN template GridIn::GridIn () : - tria(0, typeid(*this).name()), default_format(ucd) + tria(0, typeid(*this).name()), default_format(ucd) {} @@ -52,7 +52,7 @@ void GridIn::read_ucd (std::istream &in) Assert (tria != 0, ExcNoTriangulationSelected()); AssertThrow (in, ExcIO()); - // skip comments at start of file + // skip comments at start of file skip_comment_lines (in, '#'); @@ -67,11 +67,11 @@ void GridIn::read_ucd (std::istream &in) >> dummy; // model data AssertThrow (in, ExcIO()); - // set up array of vertices + // set up array of vertices std::vector > vertices (n_vertices); - // set up mapping between numbering - // in ucd-file (key) and in the - // vertices vector + // set up mapping between numbering + // in ucd-file (key) and in the + // vertices vector std::map vertex_indices; for (unsigned int vertex=0; vertex::read_ucd (std::istream &in) int vertex_number; double x[3]; - // read vertex + // read vertex AssertThrow (in, ExcIO()); in >> vertex_number - >> x[0] >> x[1] >> x[2]; + >> x[0] >> x[1] >> x[2]; - // store vertex + // store vertex for (unsigned int d=0; d > cells; SubCellData subcelldata; for (unsigned int cell=0; cell::read_ucd (std::istream &in) unsigned int material_id; in >> dummy // cell number - >> material_id; + >> material_id; in >> cell_type; if (((cell_type == "line") && (dim == 1)) || - ((cell_type == "quad") && (dim == 2)) || - ((cell_type == "hex" ) && (dim == 3))) - // found a cell - { - // allocate and read indices - cells.push_back (CellData()); - for (unsigned int i=0; i::vertices_per_cell; ++i) - in >> cells.back().vertices[i]; - - // to make sure that the cast wont fail + ((cell_type == "quad") && (dim == 2)) || + ((cell_type == "hex" ) && (dim == 3))) + // found a cell + { + // allocate and read indices + cells.push_back (CellData()); + for (unsigned int i=0; i::vertices_per_cell; ++i) + in >> cells.back().vertices[i]; + + // to make sure that the cast wont fail Assert(material_id<= std::numeric_limits::max(), ExcIndexRange(material_id,0,std::numeric_limits::max())); // we use only material_ids in the range from 0 to types::invalid_material_id-1 Assert(material_id < types::invalid_material_id, ExcIndexRange(material_id,0,types::invalid_material_id)); - cells.back().material_id = static_cast(material_id); - - // transform from ucd to - // consecutive numbering - for (unsigned int i=0; i::vertices_per_cell; ++i) - if (vertex_indices.find (cells.back().vertices[i]) != vertex_indices.end()) - // vertex with this index exists - cells.back().vertices[i] = vertex_indices[cells.back().vertices[i]]; - else - { - // no such vertex index - AssertThrow (false, ExcInvalidVertexIndex(cell, cells.back().vertices[i])); - cells.back().vertices[i] = numbers::invalid_unsigned_int; - }; - } + cells.back().material_id = static_cast(material_id); + + // transform from ucd to + // consecutive numbering + for (unsigned int i=0; i::vertices_per_cell; ++i) + if (vertex_indices.find (cells.back().vertices[i]) != vertex_indices.end()) + // vertex with this index exists + cells.back().vertices[i] = vertex_indices[cells.back().vertices[i]]; + else + { + // no such vertex index + AssertThrow (false, ExcInvalidVertexIndex(cell, cells.back().vertices[i])); + cells.back().vertices[i] = numbers::invalid_unsigned_int; + }; + } else - if ((cell_type == "line") && ((dim == 2) || (dim == 3))) - // boundary info - { - subcelldata.boundary_lines.push_back (CellData<1>()); - in >> subcelldata.boundary_lines.back().vertices[0] - >> subcelldata.boundary_lines.back().vertices[1]; - - // to make sure that the cast wont fail - Assert(material_id<= std::numeric_limits::max(), - ExcIndexRange(material_id,0,std::numeric_limits::max())); - // we use only boundary_ids in the range from 0 to types::internal_face_boundary_id-1 - Assert(material_id < types::internal_face_boundary_id, - ExcIndexRange(material_id,0,types::internal_face_boundary_id)); - - subcelldata.boundary_lines.back().boundary_id - = static_cast(material_id); - - // transform from ucd to - // consecutive numbering - for (unsigned int i=0; i<2; ++i) - if (vertex_indices.find (subcelldata.boundary_lines.back().vertices[i]) != - vertex_indices.end()) - // vertex with this index exists - subcelldata.boundary_lines.back().vertices[i] - = vertex_indices[subcelldata.boundary_lines.back().vertices[i]]; - else - { - // no such vertex index - AssertThrow (false, - ExcInvalidVertexIndex(cell, - subcelldata.boundary_lines.back().vertices[i])); - subcelldata.boundary_lines.back().vertices[i] - = numbers::invalid_unsigned_int; - }; - } - else - if ((cell_type == "quad") && (dim == 3)) - // boundary info - { - subcelldata.boundary_quads.push_back (CellData<2>()); - in >> subcelldata.boundary_quads.back().vertices[0] - >> subcelldata.boundary_quads.back().vertices[1] - >> subcelldata.boundary_quads.back().vertices[2] - >> subcelldata.boundary_quads.back().vertices[3]; - - // to make sure that the cast wont fail - Assert(material_id<= std::numeric_limits::max(), - ExcIndexRange(material_id,0,std::numeric_limits::max())); - // we use only boundary_ids in the range from 0 to types::internal_face_boundary_id-1 - Assert(material_id < types::internal_face_boundary_id, - ExcIndexRange(material_id,0,types::internal_face_boundary_id)); - - subcelldata.boundary_quads.back().boundary_id - = static_cast(material_id); - - // transform from ucd to - // consecutive numbering - for (unsigned int i=0; i<4; ++i) - if (vertex_indices.find (subcelldata.boundary_quads.back().vertices[i]) != - vertex_indices.end()) - // vertex with this index exists - subcelldata.boundary_quads.back().vertices[i] - = vertex_indices[subcelldata.boundary_quads.back().vertices[i]]; - else - { - // no such vertex index - Assert (false, - ExcInvalidVertexIndex(cell, - subcelldata.boundary_quads.back().vertices[i])); - subcelldata.boundary_quads.back().vertices[i] = - numbers::invalid_unsigned_int; - }; - - } - else - // cannot read this - AssertThrow (false, ExcUnknownIdentifier(cell_type)); + if ((cell_type == "line") && ((dim == 2) || (dim == 3))) + // boundary info + { + subcelldata.boundary_lines.push_back (CellData<1>()); + in >> subcelldata.boundary_lines.back().vertices[0] + >> subcelldata.boundary_lines.back().vertices[1]; + + // to make sure that the cast wont fail + Assert(material_id<= std::numeric_limits::max(), + ExcIndexRange(material_id,0,std::numeric_limits::max())); + // we use only boundary_ids in the range from 0 to types::internal_face_boundary_id-1 + Assert(material_id < types::internal_face_boundary_id, + ExcIndexRange(material_id,0,types::internal_face_boundary_id)); + + subcelldata.boundary_lines.back().boundary_id + = static_cast(material_id); + + // transform from ucd to + // consecutive numbering + for (unsigned int i=0; i<2; ++i) + if (vertex_indices.find (subcelldata.boundary_lines.back().vertices[i]) != + vertex_indices.end()) + // vertex with this index exists + subcelldata.boundary_lines.back().vertices[i] + = vertex_indices[subcelldata.boundary_lines.back().vertices[i]]; + else + { + // no such vertex index + AssertThrow (false, + ExcInvalidVertexIndex(cell, + subcelldata.boundary_lines.back().vertices[i])); + subcelldata.boundary_lines.back().vertices[i] + = numbers::invalid_unsigned_int; + }; + } + else + if ((cell_type == "quad") && (dim == 3)) + // boundary info + { + subcelldata.boundary_quads.push_back (CellData<2>()); + in >> subcelldata.boundary_quads.back().vertices[0] + >> subcelldata.boundary_quads.back().vertices[1] + >> subcelldata.boundary_quads.back().vertices[2] + >> subcelldata.boundary_quads.back().vertices[3]; + + // to make sure that the cast wont fail + Assert(material_id<= std::numeric_limits::max(), + ExcIndexRange(material_id,0,std::numeric_limits::max())); + // we use only boundary_ids in the range from 0 to types::internal_face_boundary_id-1 + Assert(material_id < types::internal_face_boundary_id, + ExcIndexRange(material_id,0,types::internal_face_boundary_id)); + + subcelldata.boundary_quads.back().boundary_id + = static_cast(material_id); + + // transform from ucd to + // consecutive numbering + for (unsigned int i=0; i<4; ++i) + if (vertex_indices.find (subcelldata.boundary_quads.back().vertices[i]) != + vertex_indices.end()) + // vertex with this index exists + subcelldata.boundary_quads.back().vertices[i] + = vertex_indices[subcelldata.boundary_quads.back().vertices[i]]; + else + { + // no such vertex index + Assert (false, + ExcInvalidVertexIndex(cell, + subcelldata.boundary_quads.back().vertices[i])); + subcelldata.boundary_quads.back().vertices[i] = + numbers::invalid_unsigned_int; + }; + + } + else + // cannot read this + AssertThrow (false, ExcUnknownIdentifier(cell_type)); }; - // check that no forbidden arrays are used + // check that no forbidden arrays are used Assert (subcelldata.check_consistency(dim), ExcInternalError()); AssertThrow (in, ExcIO()); - // do some clean-up on vertices... + // do some clean-up on vertices... GridTools::delete_unused_vertices (vertices, cells, subcelldata); - // ... and cells + // ... and cells if(dim==spacedim) GridReordering::invert_all_cells_of_negative_grid (vertices, cells); GridReordering::reorder_cells (cells); @@ -253,20 +253,20 @@ void GridIn::read_dbmesh (std::istream &in) AssertThrow (in, ExcIO()); - // skip comments at start of file + // skip comments at start of file skip_comment_lines (in, '#'); - // first read in identifier string + // first read in identifier string std::string line; getline (in, line); AssertThrow (line=="MeshVersionFormatted 0", - ExcInvalidDBMESHInput(line)); + ExcInvalidDBMESHInput(line)); skip_empty_lines (in); - // next read dimension + // next read dimension getline (in, line); AssertThrow (line=="Dimension", ExcInvalidDBMESHInput(line)); unsigned int dimension; @@ -274,23 +274,23 @@ void GridIn::read_dbmesh (std::istream &in) AssertThrow (dimension == dim, ExcDBMESHWrongDimension(dimension)); skip_empty_lines (in); - // now there are a lot of fields of - // which we don't know the exact - // meaning and which are far from - // being properly documented in the - // manual. we skip everything until - // we find a comment line with the - // string "# END". at some point in - // the future, someone may have the - // knowledge to parse and interpret - // the other fields in between as - // well... + // now there are a lot of fields of + // which we don't know the exact + // meaning and which are far from + // being properly documented in the + // manual. we skip everything until + // we find a comment line with the + // string "# END". at some point in + // the future, someone may have the + // knowledge to parse and interpret + // the other fields in between as + // well... while (getline(in,line), line.find("# END")==std::string::npos) ; skip_empty_lines (in); - // now read vertices + // now read vertices getline (in, line); AssertThrow (line=="Vertices", ExcInvalidDBMESHInput(line)); @@ -301,19 +301,19 @@ void GridIn::read_dbmesh (std::istream &in) std::vector > vertices (n_vertices); for (unsigned int vertex=0; vertex> vertices[vertex][d]; - // read Ref phi_i, whatever that may be + in >> vertices[vertex][d]; + // read Ref phi_i, whatever that may be in >> dummy; }; AssertThrow (in, ExcInvalidDBMeshFormat()); skip_empty_lines(in); - // read edges. we ignore them at - // present, so just read them and - // discard the input + // read edges. we ignore them at + // present, so just read them and + // discard the input getline (in, line); AssertThrow (line=="Edges", ExcInvalidDBMESHInput(line)); @@ -321,9 +321,9 @@ void GridIn::read_dbmesh (std::istream &in) in >> n_edges; for (unsigned int edge=0; edge> dummy >> dummy; - // read Ref phi_i, whatever that may be + // read Ref phi_i, whatever that may be in >> dummy; }; AssertThrow (in, ExcInvalidDBMeshFormat()); @@ -332,19 +332,19 @@ void GridIn::read_dbmesh (std::istream &in) - // read cracked edges (whatever - // that may be). we ignore them at - // present, so just read them and - // discard the input + // read cracked edges (whatever + // that may be). we ignore them at + // present, so just read them and + // discard the input getline (in, line); AssertThrow (line=="CrackedEdges", ExcInvalidDBMESHInput(line)); in >> n_edges; for (unsigned int edge=0; edge> dummy >> dummy; - // read Ref phi_i, whatever that may be + // read Ref phi_i, whatever that may be in >> dummy; }; AssertThrow (in, ExcInvalidDBMeshFormat()); @@ -352,8 +352,8 @@ void GridIn::read_dbmesh (std::istream &in) skip_empty_lines(in); - // now read cells. - // set up array of cells + // now read cells. + // set up array of cells getline (in, line); AssertThrow (line=="Quadrilaterals", ExcInvalidDBMESHInput(line)); @@ -363,22 +363,22 @@ void GridIn::read_dbmesh (std::istream &in) in >> n_cells; for (unsigned int cell=0; cell()); for (unsigned int i=0; i::vertices_per_cell; ++i) - { - in >> cells.back().vertices[i]; + { + in >> cells.back().vertices[i]; - AssertThrow ((cells.back().vertices[i] >= 1) - && - (static_cast(cells.back().vertices[i]) <= vertices.size()), - ExcInvalidVertexIndex(cell, cells.back().vertices[i])); + AssertThrow ((cells.back().vertices[i] >= 1) + && + (static_cast(cells.back().vertices[i]) <= vertices.size()), + ExcInvalidVertexIndex(cell, cells.back().vertices[i])); - --cells.back().vertices[i]; - }; + --cells.back().vertices[i]; + }; - // read and discard Ref phi_i + // read and discard Ref phi_i in >> dummy; }; AssertThrow (in, ExcInvalidDBMeshFormat()); @@ -386,25 +386,25 @@ void GridIn::read_dbmesh (std::istream &in) skip_empty_lines(in); - // then there are again a whole lot - // of fields of which I have no - // clue what they mean. skip them - // all and leave the interpretation - // to other implementors... + // then there are again a whole lot + // of fields of which I have no + // clue what they mean. skip them + // all and leave the interpretation + // to other implementors... while (getline(in,line), ((line.find("End")==std::string::npos) && (in))) ; - // ok, so we are not at the end of - // the file, that's it, mostly + // ok, so we are not at the end of + // the file, that's it, mostly - // check that no forbidden arrays are used + // check that no forbidden arrays are used Assert (subcelldata.check_consistency(dim), ExcInternalError()); AssertThrow (in, ExcIO()); - // do some clean-up on vertices... + // do some clean-up on vertices... GridTools::delete_unused_vertices (vertices, cells, subcelldata); - // ...and cells + // ...and cells GridReordering::invert_all_cells_of_negative_grid (vertices, cells); GridReordering::reorder_cells (cells); tria->create_triangulation_compatibility (vertices, cells, subcelldata); @@ -427,63 +427,63 @@ void GridIn<2>::read_xda (std::istream &in) AssertThrow (in, ExcIO()); std::string line; - // skip comments at start of file + // skip comments at start of file getline (in, line); unsigned int n_vertices; unsigned int n_cells; - // read cells, throw away rest of line + // read cells, throw away rest of line in >> n_cells; getline (in, line); in >> n_vertices; getline (in, line); - // ignore following 8 lines + // ignore following 8 lines for (unsigned int i=0; i<8; ++i) getline (in, line); - // set up array of cells + // set up array of cells std::vector > cells (n_cells); SubCellData subcelldata; for (unsigned int cell=0; cell::vertices_per_cell == 4, - ExcInternalError()); + ExcInternalError()); for (unsigned int i=0; i<4; ++i) - in >> cells[cell].vertices[i]; + in >> cells[cell].vertices[i]; }; - // set up array of vertices + // set up array of vertices std::vector > vertices (n_vertices); for (unsigned int vertex=0; vertex> x[0] >> x[1] >> x[2]; - // store vertex + // store vertex for (unsigned int d=0; d<2; ++d) - vertices[vertex](d) = x[d]; + vertices[vertex](d) = x[d]; }; AssertThrow (in, ExcIO()); - // do some clean-up on vertices... + // do some clean-up on vertices... GridTools::delete_unused_vertices (vertices, cells, subcelldata); - // ... and cells + // ... and cells GridReordering<2>::invert_all_cells_of_negative_grid (vertices, cells); GridReordering<2>::reorder_cells (cells); tria->create_triangulation_compatibility (vertices, cells, subcelldata); @@ -500,68 +500,68 @@ void GridIn<3>::read_xda (std::istream &in) static const unsigned int xda_to_dealII_map[] = {0,1,5,4,3,2,6,7}; std::string line; - // skip comments at start of file + // skip comments at start of file getline (in, line); unsigned int n_vertices; unsigned int n_cells; - // read cells, throw away rest of line + // read cells, throw away rest of line in >> n_cells; getline (in, line); in >> n_vertices; getline (in, line); - // ignore following 8 lines + // ignore following 8 lines for (unsigned int i=0; i<8; ++i) getline (in, line); - // set up array of cells + // set up array of cells std::vector > cells (n_cells); SubCellData subcelldata; for (unsigned int cell=0; cell::vertices_per_cell == 8, - ExcInternalError()); + ExcInternalError()); unsigned int xda_ordered_nodes[8]; for (unsigned int i=0; i<8; ++i) - in >> xda_ordered_nodes[i]; + in >> xda_ordered_nodes[i]; for (unsigned int i=0; i<8; i++) - cells[cell].vertices[i] = xda_ordered_nodes[xda_to_dealII_map[i]]; + cells[cell].vertices[i] = xda_ordered_nodes[xda_to_dealII_map[i]]; }; - // set up array of vertices + // set up array of vertices std::vector > vertices (n_vertices); for (unsigned int vertex=0; vertex> x[0] >> x[1] >> x[2]; - // store vertex + // store vertex for (unsigned int d=0; d<3; ++d) - vertices[vertex](d) = x[d]; + vertices[vertex](d) = x[d]; }; AssertThrow (in, ExcIO()); - // do some clean-up on vertices... + // do some clean-up on vertices... GridTools::delete_unused_vertices (vertices, cells, subcelldata); - // ... and cells + // ... and cells GridReordering<3>::invert_all_cells_of_negative_grid (vertices, cells); GridReordering<3>::reorder_cells (cells); tria->create_triangulation_compatibility (vertices, cells, subcelldata); @@ -583,7 +583,7 @@ void GridIn::read_msh (std::istream &in) in >> line; - // first determine file format + // first determine file format unsigned int gmsh_file_format = 0; if (line == "$NOD") gmsh_file_format = 1; @@ -592,9 +592,9 @@ void GridIn::read_msh (std::istream &in) else AssertThrow (false, ExcInvalidGMSHInput(line)); - // if file format is 2 or greater - // then we also have to read the - // rest of the header + // if file format is 2 or greater + // then we also have to read the + // rest of the header if (gmsh_file_format == 2) { double version; @@ -603,45 +603,45 @@ void GridIn::read_msh (std::istream &in) in >> version >> file_type >> data_size; Assert ( (version >= 2.0) && - (version <= 2.2), ExcNotImplemented()); + (version <= 2.2), ExcNotImplemented()); Assert (file_type == 0, ExcNotImplemented()); Assert (data_size == sizeof(double), ExcNotImplemented()); - // read the end of the header - // and the first line of the - // nodes description to synch - // ourselves with the format 1 - // handling above + // read the end of the header + // and the first line of the + // nodes description to synch + // ourselves with the format 1 + // handling above in >> line; AssertThrow (line == "$EndMeshFormat", - ExcInvalidGMSHInput(line)); + ExcInvalidGMSHInput(line)); in >> line; - // if the next block is of kind - // $PhysicalNames, ignore it + // if the next block is of kind + // $PhysicalNames, ignore it if (line == "$PhysicalNames") - { - do - { - in >> line; - } - while (line != "$EndPhysicalNames"); - in >> line; - } - - // but the next thing should, - // in any case, be the list of - // nodes: + { + do + { + in >> line; + } + while (line != "$EndPhysicalNames"); + in >> line; + } + + // but the next thing should, + // in any case, be the list of + // nodes: AssertThrow (line == "$Nodes", - ExcInvalidGMSHInput(line)); + ExcInvalidGMSHInput(line)); } - // now read the nodes list + // now read the nodes list in >> n_vertices; std::vector > vertices (n_vertices); - // set up mapping between numbering - // in msh-file (nod) and in the - // vertices vector + // set up mapping between numbering + // in msh-file (nod) and in the + // vertices vector std::map vertex_indices; for (unsigned int vertex=0; vertex::read_msh (std::istream &in) int vertex_number; double x[3]; - // read vertex + // read vertex in >> vertex_number - >> x[0] >> x[1] >> x[2]; + >> x[0] >> x[1] >> x[2]; for (unsigned int d=0; d> line; static const std::string end_nodes_marker[] = {"$ENDNOD", "$EndNodes" }; AssertThrow (line==end_nodes_marker[gmsh_file_format-1], - ExcInvalidGMSHInput(line)); + ExcInvalidGMSHInput(line)); - // Now read in next bit + // Now read in next bit in >> line; static const std::string begin_elements_marker[] = {"$ELM", "$Elements" }; AssertThrow (line==begin_elements_marker[gmsh_file_format-1], - ExcInvalidGMSHInput(line)); + ExcInvalidGMSHInput(line)); in >> n_cells; - // set up array of cells + // set up array of cells std::vector > cells; SubCellData subcelldata; for (unsigned int cell=0; cell::read_msh (std::istream &in) */ in >> dummy // ELM-NUMBER - >> cell_type; // ELM-TYPE + >> cell_type; // ELM-TYPE switch (gmsh_file_format) - { - case 1: - { - in >> material_id // REG-PHYS - >> dummy // reg_elm - >> nod_num; - break; - } - - case 2: - { - // read the tags; ignore - // all but the first one - unsigned int n_tags; - in >> n_tags; - if (n_tags > 0) - in >> material_id; - else - material_id = 0; - - for (unsigned int i=1; i> dummy; - - nod_num = GeometryInfo::vertices_per_cell; - - break; - } - - default: - AssertThrow (false, ExcNotImplemented()); - } + { + case 1: + { + in >> material_id // REG-PHYS + >> dummy // reg_elm + >> nod_num; + break; + } + + case 2: + { + // read the tags; ignore + // all but the first one + unsigned int n_tags; + in >> n_tags; + if (n_tags > 0) + in >> material_id; + else + material_id = 0; + + for (unsigned int i=1; i> dummy; + + nod_num = GeometryInfo::vertices_per_cell; + + break; + } + + default: + AssertThrow (false, ExcNotImplemented()); + } /* `ELM-TYPE' - defines the geometrical type of the N-th element: - `1' - Line (2 nodes, 1 edge). + defines the geometrical type of the N-th element: + `1' + Line (2 nodes, 1 edge). - `3' - Quadrangle (4 nodes, 4 edges). + `3' + Quadrangle (4 nodes, 4 edges). - `5' - Hexahedron (8 nodes, 12 edges, 6 faces). + `5' + Hexahedron (8 nodes, 12 edges, 6 faces). - `15' - Point (1 node). + `15' + Point (1 node). */ if (((cell_type == 1) && (dim == 1)) || - ((cell_type == 3) && (dim == 2)) || - ((cell_type == 5) && (dim == 3))) - // found a cell - { - AssertThrow (nod_num == GeometryInfo::vertices_per_cell, - ExcMessage ("Number of nodes does not coincide with the " - "number required for this object")); - - // allocate and read indices - cells.push_back (CellData()); - for (unsigned int i=0; i::vertices_per_cell; ++i) - in >> cells.back().vertices[i]; + ((cell_type == 3) && (dim == 2)) || + ((cell_type == 5) && (dim == 3))) + // found a cell + { + AssertThrow (nod_num == GeometryInfo::vertices_per_cell, + ExcMessage ("Number of nodes does not coincide with the " + "number required for this object")); + + // allocate and read indices + cells.push_back (CellData()); + for (unsigned int i=0; i::vertices_per_cell; ++i) + in >> cells.back().vertices[i]; // to make sure that the cast wont fail Assert(material_id<= std::numeric_limits::max(), @@ -776,27 +776,27 @@ void GridIn::read_msh (std::istream &in) Assert(material_id < types::invalid_material_id, ExcIndexRange(material_id,0,types::invalid_material_id)); - cells.back().material_id = static_cast(material_id); + cells.back().material_id = static_cast(material_id); - // transform from ucd to - // consecutive numbering - for (unsigned int i=0; i::vertices_per_cell; ++i) - { - AssertThrow (vertex_indices.find (cells.back().vertices[i]) != - vertex_indices.end(), - ExcInvalidVertexIndex(cell, cells.back().vertices[i])); + // transform from ucd to + // consecutive numbering + for (unsigned int i=0; i::vertices_per_cell; ++i) + { + AssertThrow (vertex_indices.find (cells.back().vertices[i]) != + vertex_indices.end(), + ExcInvalidVertexIndex(cell, cells.back().vertices[i])); - // vertex with this index exists - cells.back().vertices[i] = vertex_indices[cells.back().vertices[i]]; - } - } + // vertex with this index exists + cells.back().vertices[i] = vertex_indices[cells.back().vertices[i]]; + } + } else - if ((cell_type == 1) && ((dim == 2) || (dim == 3))) - // boundary info - { - subcelldata.boundary_lines.push_back (CellData<1>()); - in >> subcelldata.boundary_lines.back().vertices[0] - >> subcelldata.boundary_lines.back().vertices[1]; + if ((cell_type == 1) && ((dim == 2) || (dim == 3))) + // boundary info + { + subcelldata.boundary_lines.push_back (CellData<1>()); + in >> subcelldata.boundary_lines.back().vertices[0] + >> subcelldata.boundary_lines.back().vertices[1]; // to make sure that the cast wont fail Assert(material_id<= std::numeric_limits::max(), @@ -805,112 +805,112 @@ void GridIn::read_msh (std::istream &in) Assert(material_id < types::internal_face_boundary_id, ExcIndexRange(material_id,0,types::internal_face_boundary_id)); - subcelldata.boundary_lines.back().boundary_id - = static_cast(material_id); - - // transform from ucd to - // consecutive numbering - for (unsigned int i=0; i<2; ++i) - if (vertex_indices.find (subcelldata.boundary_lines.back().vertices[i]) != - vertex_indices.end()) - // vertex with this index exists - subcelldata.boundary_lines.back().vertices[i] - = vertex_indices[subcelldata.boundary_lines.back().vertices[i]]; - else - { - // no such vertex index - AssertThrow (false, - ExcInvalidVertexIndex(cell, - subcelldata.boundary_lines.back().vertices[i])); - subcelldata.boundary_lines.back().vertices[i] = - numbers::invalid_unsigned_int; - }; - } - else - if ((cell_type == 3) && (dim == 3)) - // boundary info - { - subcelldata.boundary_quads.push_back (CellData<2>()); - in >> subcelldata.boundary_quads.back().vertices[0] - >> subcelldata.boundary_quads.back().vertices[1] - >> subcelldata.boundary_quads.back().vertices[2] - >> subcelldata.boundary_quads.back().vertices[3]; - - // to make sure that the cast wont fail - Assert(material_id<= std::numeric_limits::max(), - ExcIndexRange(material_id,0,std::numeric_limits::max())); - // we use only boundary_ids in the range from 0 to types::internal_face_boundary_id-1 - Assert(material_id < types::internal_face_boundary_id, - ExcIndexRange(material_id,0,types::internal_face_boundary_id)); - - subcelldata.boundary_quads.back().boundary_id - = static_cast(material_id); - - // transform from gmsh to - // consecutive numbering - for (unsigned int i=0; i<4; ++i) - if (vertex_indices.find (subcelldata.boundary_quads.back().vertices[i]) != - vertex_indices.end()) - // vertex with this index exists - subcelldata.boundary_quads.back().vertices[i] - = vertex_indices[subcelldata.boundary_quads.back().vertices[i]]; - else - { - // no such vertex index - Assert (false, - ExcInvalidVertexIndex(cell, - subcelldata.boundary_quads.back().vertices[i])); - subcelldata.boundary_quads.back().vertices[i] = - numbers::invalid_unsigned_int; - }; - - } - else - if (cell_type == 15) - { - // Ignore vertices - // but read the - // number of nodes - // given - switch (gmsh_file_format) - { - case 1: - { - for (unsigned int i=0; i> dummy; - break; - } - case 2: - { - in >> dummy; - break; - } - } - } - else - // cannot read this - AssertThrow (false, ExcGmshUnsupportedGeometry(cell_type)); + subcelldata.boundary_lines.back().boundary_id + = static_cast(material_id); + + // transform from ucd to + // consecutive numbering + for (unsigned int i=0; i<2; ++i) + if (vertex_indices.find (subcelldata.boundary_lines.back().vertices[i]) != + vertex_indices.end()) + // vertex with this index exists + subcelldata.boundary_lines.back().vertices[i] + = vertex_indices[subcelldata.boundary_lines.back().vertices[i]]; + else + { + // no such vertex index + AssertThrow (false, + ExcInvalidVertexIndex(cell, + subcelldata.boundary_lines.back().vertices[i])); + subcelldata.boundary_lines.back().vertices[i] = + numbers::invalid_unsigned_int; + }; + } + else + if ((cell_type == 3) && (dim == 3)) + // boundary info + { + subcelldata.boundary_quads.push_back (CellData<2>()); + in >> subcelldata.boundary_quads.back().vertices[0] + >> subcelldata.boundary_quads.back().vertices[1] + >> subcelldata.boundary_quads.back().vertices[2] + >> subcelldata.boundary_quads.back().vertices[3]; + + // to make sure that the cast wont fail + Assert(material_id<= std::numeric_limits::max(), + ExcIndexRange(material_id,0,std::numeric_limits::max())); + // we use only boundary_ids in the range from 0 to types::internal_face_boundary_id-1 + Assert(material_id < types::internal_face_boundary_id, + ExcIndexRange(material_id,0,types::internal_face_boundary_id)); + + subcelldata.boundary_quads.back().boundary_id + = static_cast(material_id); + + // transform from gmsh to + // consecutive numbering + for (unsigned int i=0; i<4; ++i) + if (vertex_indices.find (subcelldata.boundary_quads.back().vertices[i]) != + vertex_indices.end()) + // vertex with this index exists + subcelldata.boundary_quads.back().vertices[i] + = vertex_indices[subcelldata.boundary_quads.back().vertices[i]]; + else + { + // no such vertex index + Assert (false, + ExcInvalidVertexIndex(cell, + subcelldata.boundary_quads.back().vertices[i])); + subcelldata.boundary_quads.back().vertices[i] = + numbers::invalid_unsigned_int; + }; + + } + else + if (cell_type == 15) + { + // Ignore vertices + // but read the + // number of nodes + // given + switch (gmsh_file_format) + { + case 1: + { + for (unsigned int i=0; i> dummy; + break; + } + case 2: + { + in >> dummy; + break; + } + } + } + else + // cannot read this + AssertThrow (false, ExcGmshUnsupportedGeometry(cell_type)); }; - // Assert we reached the end of the block + // Assert we reached the end of the block in >> line; static const std::string end_elements_marker[] = {"$ENDELM", "$EndElements" }; AssertThrow (line==end_elements_marker[gmsh_file_format-1], - ExcInvalidGMSHInput(line)); + ExcInvalidGMSHInput(line)); - // check that no forbidden arrays are used + // check that no forbidden arrays are used Assert (subcelldata.check_consistency(dim), ExcInternalError()); AssertThrow (in, ExcIO()); - // check that we actually read some - // cells. + // check that we actually read some + // cells. AssertThrow(cells.size() > 0, ExcGmshNoCellInformation()); - // do some clean-up on - // vertices... + // do some clean-up on + // vertices... GridTools::delete_unused_vertices (vertices, cells, subcelldata); - // ... and cells + // ... and cells if(dim==spacedim) GridReordering::invert_all_cells_of_negative_grid (vertices, cells); GridReordering::reorder_cells (cells); @@ -940,8 +940,8 @@ template <> void GridIn<2>::read_netcdf (const std::string &filename) { #ifndef HAVE_LIBNETCDF - // do something with unused - // filename + // do something with unused + // filename filename.c_str(); AssertThrow(false, ExcNeedsNetCDF()); #else @@ -949,54 +949,54 @@ void GridIn<2>::read_netcdf (const std::string &filename) const unsigned int spacedim=2; const bool output=false; Assert (tria != 0, ExcNoTriangulationSelected()); - // this function assumes the TAU - // grid format. - // - // This format stores 2d grids as - // 3d grids. In particular, a 2d - // grid of n_cells quadrilaterals - // in the y=0 plane is duplicated - // to y=1 to build n_cells - // hexaeders. The surface - // quadrilaterals of this 3d grid - // are marked with boundary - // marker. In the following we read - // in all data required, find the - // boundary marker associated with - // the plane y=0, and extract the - // corresponding 2d data to build a - // Triangulation<2>. - - // In the following, we assume that - // the 2d grid lies in the x-z - // plane (y=0). I.e. we choose: - // point[coord]=0, with coord=1 + // this function assumes the TAU + // grid format. + // + // This format stores 2d grids as + // 3d grids. In particular, a 2d + // grid of n_cells quadrilaterals + // in the y=0 plane is duplicated + // to y=1 to build n_cells + // hexaeders. The surface + // quadrilaterals of this 3d grid + // are marked with boundary + // marker. In the following we read + // in all data required, find the + // boundary marker associated with + // the plane y=0, and extract the + // corresponding 2d data to build a + // Triangulation<2>. + + // In the following, we assume that + // the 2d grid lies in the x-z + // plane (y=0). I.e. we choose: + // point[coord]=0, with coord=1 const unsigned int coord=1; - // Also x-y-z (0-1-2) point - // coordinates will be transformed - // to x-y (x2d-y2d) coordinates. - // With coord=1 as above, we have - // x-z (0-2) -> (x2d-y2d) + // Also x-y-z (0-1-2) point + // coordinates will be transformed + // to x-y (x2d-y2d) coordinates. + // With coord=1 as above, we have + // x-z (0-2) -> (x2d-y2d) const unsigned int x2d=0; const unsigned int y2d=2; - // For the case, the 2d grid lies - // in x-y or y-z plane instead, the - // following code must be extended - // to find the right value for - // coord, and setting x2d and y2d - // accordingly. - - // First, open the file + // For the case, the 2d grid lies + // in x-y or y-z plane instead, the + // following code must be extended + // to find the right value for + // coord, and setting x2d and y2d + // accordingly. + + // First, open the file NcFile nc (filename.c_str()); AssertThrow(nc.is_valid(), ExcIO()); - // then read n_cells + // then read n_cells NcDim *elements_dim=nc.get_dim("no_of_elements"); AssertThrow(elements_dim->is_valid(), ExcIO()); const unsigned int n_cells=elements_dim->size(); - // then we read - // int marker(no_of_markers) + // then we read + // int marker(no_of_markers) NcDim *marker_dim=nc.get_dim("no_of_markers"); AssertThrow(marker_dim->is_valid(), ExcIO()); const unsigned int n_markers=marker_dim->size(); @@ -1008,8 +1008,8 @@ void GridIn<2>::read_netcdf (const std::string &filename) marker_var->get_dim(0)->size())==n_markers, ExcIO()); std::vector marker(n_markers); - // use &* to convert - // vector::iterator to int * + // use &* to convert + // vector::iterator to int * marker_var->get(&*marker.begin(), n_markers); if (output) @@ -1017,13 +1017,13 @@ void GridIn<2>::read_netcdf (const std::string &filename) std::cout << "n_cell=" << n_cells << std::endl; std::cout << "marker: "; for (unsigned int i=0; iis_valid(), ExcIO()); const unsigned int n_bquads=bquads_dim->size(); @@ -1037,46 +1037,46 @@ void GridIn<2>::read_netcdf (const std::string &filename) std::vector bmarker(n_bquads); bmarker_var->get(&*bmarker.begin(), n_bquads); - // for each marker count the - // number of boundary quads - // which carry this marker + // for each marker count the + // number of boundary quads + // which carry this marker std::map n_bquads_per_bmarker; for (unsigned int i=0; i::const_iterator - iter=n_bquads_per_bmarker.begin(); + iter=n_bquads_per_bmarker.begin(); for (; iter!=n_bquads_per_bmarker.end(); ++iter) - std::cout << " n_bquads_per_bmarker[" << iter->first - << "]=" << iter->second << std::endl; + std::cout << " n_bquads_per_bmarker[" << iter->first + << "]=" << iter->second << std::endl; } - // next we read - // int points_of_surfacequadrilaterals( - // no_of_surfacequadrilaterals, - // points_per_surfacequadrilateral) + // next we read + // int points_of_surfacequadrilaterals( + // no_of_surfacequadrilaterals, + // points_per_surfacequadrilateral) NcDim *quad_vertices_dim=nc.get_dim("points_per_surfacequadrilateral"); AssertThrow(quad_vertices_dim->is_valid(), ExcIO()); const unsigned int vertices_per_quad=quad_vertices_dim->size(); @@ -1100,17 +1100,17 @@ void GridIn<2>::read_netcdf (const std::string &filename) { std::cout << "vertex_indices:" << std::endl; for (unsigned int i=0, v=0; iis_valid(), ExcIO()); const unsigned int n_vertices=vertices_dim->size(); @@ -1127,18 +1127,18 @@ void GridIn<2>::read_netcdf (const std::string &filename) AssertThrow(points_yc->num_dims()==1, ExcIO()); AssertThrow(points_zc->num_dims()==1, ExcIO()); AssertThrow(points_yc->get_dim(0)->size()== - static_cast(n_vertices), ExcIO()); + static_cast(n_vertices), ExcIO()); AssertThrow(points_zc->get_dim(0)->size()== - static_cast(n_vertices), ExcIO()); + static_cast(n_vertices), ExcIO()); AssertThrow(points_xc->get_dim(0)->size()== - static_cast(n_vertices), ExcIO()); + static_cast(n_vertices), ExcIO()); std::vector > point_values( 3, std::vector (n_vertices)); points_xc->get(&*point_values[0].begin(), n_vertices); points_yc->get(&*point_values[1].begin(), n_vertices); points_zc->get(&*point_values[2].begin(), n_vertices); - // and fill the vertices + // and fill the vertices std::vector > vertices (n_vertices); for (unsigned int i=0; i::read_netcdf (const std::string &filename) vertices[i](1)=point_values[y2d][i]; } - // For all boundary quads in the - // point[coord]=0 plane add the - // bmarker to zero_plane_markers + // For all boundary quads in the + // point[coord]=0 plane add the + // bmarker to zero_plane_markers std::map zero_plane_markers; for (unsigned int quad=0; quad::const_iterator iter=zero_plane_markers.begin(); @@ -1169,35 +1169,35 @@ void GridIn<2>::read_netcdf (const std::string &filename) { sum_of_zero_plane_cells+=n_bquads_per_bmarker[iter->first]; if (output) - std::cout << "bmarker=" << iter->first << std::endl; + std::cout << "bmarker=" << iter->first << std::endl; } AssertThrow(sum_of_zero_plane_cells==n_cells, ExcIO()); - // fill cells with all quads - // associated with - // zero_plane_markers + // fill cells with all quads + // associated with + // zero_plane_markers std::vector > cells(n_cells); for (unsigned int quad=0, cell=0; quad::const_iterator iter=zero_plane_markers.begin(); - iter != zero_plane_markers.end(); ++iter) - if (bmarker[quad]==iter->first) - { - zero_plane=true; - break; - } + iter != zero_plane_markers.end(); ++iter) + if (bmarker[quad]==iter->first) + { + zero_plane=true; + break; + } if (zero_plane) - { - for (unsigned int i=0; i::read_netcdf (const std::string &filename) const unsigned int spacedim=3; const bool output=false; Assert (tria != 0, ExcNoTriangulationSelected()); - // this function assumes the TAU - // grid format. + // this function assumes the TAU + // grid format. - // First, open the file + // First, open the file NcFile nc (filename.c_str()); AssertThrow(nc.is_valid(), ExcIO()); - // then read n_cells + // then read n_cells NcDim *elements_dim=nc.get_dim("no_of_elements"); AssertThrow(elements_dim->is_valid(), ExcIO()); const unsigned int n_cells=elements_dim->size(); if (output) std::cout << "n_cell=" << n_cells << std::endl; - // and n_hexes + // and n_hexes NcDim *hexes_dim=nc.get_dim("no_of_hexaeders"); AssertThrow(hexes_dim->is_valid(), ExcIO()); const unsigned int n_hexes=hexes_dim->size(); AssertThrow(n_hexes==n_cells, - ExcMessage("deal.II can handle purely hexaedral grids, only.")); + ExcMessage("deal.II can handle purely hexaedral grids, only.")); - // next we read - // int points_of_hexaeders( - // no_of_hexaeders, - // points_per_hexaeder) + // next we read + // int points_of_hexaeders( + // no_of_hexaeders, + // points_per_hexaeder) NcDim *hex_vertices_dim=nc.get_dim("points_per_hexaeder"); AssertThrow(hex_vertices_dim->is_valid(), ExcIO()); const unsigned int vertices_per_hex=hex_vertices_dim->size(); @@ -1260,8 +1260,8 @@ void GridIn<3>::read_netcdf (const std::string &filename) vertex_indices_var->get_dim(1)->size())==vertices_per_hex, ExcIO()); std::vector vertex_indices(n_cells*vertices_per_hex); - // use &* to convert - // vector::iterator to int * + // use &* to convert + // vector::iterator to int * vertex_indices_var->get(&*vertex_indices.begin(), n_cells, vertices_per_hex); for (unsigned int i=0; i::read_netcdf (const std::string &filename) { std::cout << "vertex_indices:" << std::endl; for (unsigned int cell=0, v=0; cellis_valid(), ExcIO()); const unsigned int n_vertices=vertices_dim->size(); @@ -1298,14 +1298,14 @@ void GridIn<3>::read_netcdf (const std::string &filename) AssertThrow(points_yc->num_dims()==1, ExcIO()); AssertThrow(points_zc->num_dims()==1, ExcIO()); AssertThrow(points_yc->get_dim(0)->size()== - static_cast(n_vertices), ExcIO()); + static_cast(n_vertices), ExcIO()); AssertThrow(points_zc->get_dim(0)->size()== - static_cast(n_vertices), ExcIO()); + static_cast(n_vertices), ExcIO()); AssertThrow(points_xc->get_dim(0)->size()== - static_cast(n_vertices), ExcIO()); + static_cast(n_vertices), ExcIO()); std::vector > point_values( 3, std::vector (n_vertices)); - // we switch y and z + // we switch y and z const bool switch_y_z=false; points_xc->get(&*point_values[0].begin(), n_vertices); if (switch_y_z) @@ -1319,7 +1319,7 @@ void GridIn<3>::read_netcdf (const std::string &filename) points_zc->get(&*point_values[2].begin(), n_vertices); } - // and fill the vertices + // and fill the vertices std::vector > vertices (n_vertices); for (unsigned int i=0; i::read_netcdf (const std::string &filename) vertices[i](2)=point_values[2][i]; } - // and cells + // and cells std::vector > cells(n_cells); for (unsigned int cell=0; cellis_valid(), ExcIO()); const unsigned int vertices_per_quad=quad_vertices_dim->size(); @@ -1353,8 +1353,8 @@ void GridIn<3>::read_netcdf (const std::string &filename) AssertThrow(bvertex_indices_var->num_dims()==2, ExcIO()); const unsigned int n_bquads=bvertex_indices_var->get_dim(0)->size(); AssertThrow(static_cast( - bvertex_indices_var->get_dim(1)->size())== - GeometryInfo::vertices_per_face, ExcIO()); + bvertex_indices_var->get_dim(1)->size())== + GeometryInfo::vertices_per_face, ExcIO()); std::vector bvertex_indices(n_bquads*vertices_per_quad); bvertex_indices_var->get(&*bvertex_indices.begin(), n_bquads, vertices_per_quad); @@ -1363,21 +1363,21 @@ void GridIn<3>::read_netcdf (const std::string &filename) { std::cout << "bquads: "; for (unsigned int i=0; i::vertices_per_face; ++v) - std::cout << bvertex_indices[ - i*GeometryInfo::vertices_per_face+v] << " "; - std::cout << std::endl; - } + { + for (unsigned int v=0; v::vertices_per_face; ++v) + std::cout << bvertex_indices[ + i*GeometryInfo::vertices_per_face+v] << " "; + std::cout << std::endl; + } } - // next we read - // int boundarymarker_of_surfaces( - // no_of_surfaceelements) + // next we read + // int boundarymarker_of_surfaces( + // no_of_surfaceelements) NcDim *bquads_dim=nc.get_dim("no_of_surfacequadrilaterals"); AssertThrow(bquads_dim->is_valid(), ExcIO()); AssertThrow(static_cast( - bquads_dim->size())==n_bquads, ExcIO()); + bquads_dim->size())==n_bquads, ExcIO()); NcVar *bmarker_var=nc.get_var("boundarymarker_of_surfaces"); AssertThrow(bmarker_var->is_valid(), ExcIO()); @@ -1387,23 +1387,23 @@ void GridIn<3>::read_netcdf (const std::string &filename) std::vector bmarker(n_bquads); bmarker_var->get(&*bmarker.begin(), n_bquads); - // we only handle boundary - // indicators that fit into an - // types::boundary_id_t. Also, we don't - // take types::internal_face_boundary_id + // we only handle boundary + // indicators that fit into an + // types::boundary_id_t. Also, we don't + // take types::internal_face_boundary_id // as it denotes an internal face for (unsigned int i=0; i::vertices_per_face; ++v) - subcelldata.boundary_quads[i].vertices[v]=bvertex_indices[ - i*GeometryInfo::vertices_per_face+v]; + subcelldata.boundary_quads[i].vertices[v]=bvertex_indices[ + i*GeometryInfo::vertices_per_face+v]; subcelldata.boundary_quads[i].boundary_id = static_cast(bmarker[i]); } @@ -1418,43 +1418,43 @@ void GridIn<3>::read_netcdf (const std::string &filename) template void GridIn::parse_tecplot_header(std::string &header, - std::vector &tecplot2deal, - unsigned int &n_vars, - unsigned int &n_vertices, - unsigned int &n_cells, - std::vector &IJK, - bool &structured, - bool &blocked) + std::vector &tecplot2deal, + unsigned int &n_vars, + unsigned int &n_vertices, + unsigned int &n_cells, + std::vector &IJK, + bool &structured, + bool &blocked) { Assert(tecplot2deal.size()==dim, ExcInternalError()); Assert(IJK.size()==dim, ExcInternalError()); - // initialize the output variables + // initialize the output variables n_vars=0; n_vertices=0; n_cells=0; switch(dim) { case 3: - IJK[2]=0; + IJK[2]=0; case 2: - IJK[1]=0; + IJK[1]=0; case 1: - IJK[0]=0; + IJK[0]=0; } structured=true; blocked=false; - // convert the string to upper case + // convert the string to upper case std::transform(header.begin(),header.end(),header.begin(),::toupper); - // replace all tabs, commas, newlines by - // whitespaces + // replace all tabs, commas, newlines by + // whitespaces std::replace(header.begin(),header.end(),'\t',' '); std::replace(header.begin(),header.end(),',',' '); std::replace(header.begin(),header.end(),'\n',' '); - // now remove whitespace in front of and - // after '=' + // now remove whitespace in front of and + // after '=' std::string::size_type pos=header.find("="); while(pos!=static_cast(std::string::npos)) @@ -1462,154 +1462,154 @@ void GridIn::parse_tecplot_header(std::string &header, header.erase(pos+1,1); else if (header[pos-1]==' ') { - header.erase(pos-1,1); - --pos; + header.erase(pos-1,1); + --pos; } else pos=header.find("=",++pos); - // split the string into individual entries + // split the string into individual entries std::vector entries=Utilities::break_text_into_lines(header,1,' '); - // now go through the list and try to extract + // now go through the list and try to extract for (unsigned int i=0; i1) - tecplot2deal[1]=n_vars; - } - else if (entries[i]=="\"Z\"") - { - // we assume, that z contains - // zero data in 1d and 2d, so - // do nothing - if (dim>2) - tecplot2deal[2]=n_vars; - } - ++n_vars; - ++i; - } - // set i back, so that the next - // string is treated correctly - --i; - - AssertThrow(n_vars>=dim, - ExcMessage("Tecplot file must contain at least one variable for each dimension")); - for (unsigned int i=1; i0, - ExcMessage("Tecplot file must contain at least one variable for each dimension.")); - } + { + ++n_vars; + // we assume, that the first variable + // is x or no coordinate at all (not y or z) + if (Utilities::match_at_string_start(entries[i],"VARIABLES=\"X\"")) + { + tecplot2deal[0]=0; + } + ++i; + while(entries[i][0]=='"') + { + if (entries[i]=="\"X\"") + tecplot2deal[0]=n_vars; + else if (entries[i]=="\"Y\"") + { + // we assume, that y contains + // zero data in 1d, so do + // nothing + if (dim>1) + tecplot2deal[1]=n_vars; + } + else if (entries[i]=="\"Z\"") + { + // we assume, that z contains + // zero data in 1d and 2d, so + // do nothing + if (dim>2) + tecplot2deal[2]=n_vars; + } + ++n_vars; + ++i; + } + // set i back, so that the next + // string is treated correctly + --i; + + AssertThrow(n_vars>=dim, + ExcMessage("Tecplot file must contain at least one variable for each dimension")); + for (unsigned int i=1; i0, + ExcMessage("Tecplot file must contain at least one variable for each dimension.")); + } else if (Utilities::match_at_string_start(entries[i],"ZONETYPE=ORDERED")) - structured=true; + structured=true; else if (Utilities::match_at_string_start(entries[i],"ZONETYPE=FELINESEG") && dim==1) - structured=false; + structured=false; else if (Utilities::match_at_string_start(entries[i],"ZONETYPE=FEQUADRILATERAL") && dim==2) - structured=false; + structured=false; else if (Utilities::match_at_string_start(entries[i],"ZONETYPE=FEBRICK") && dim==3) - structured=false; + structured=false; else if (Utilities::match_at_string_start(entries[i],"ZONETYPE=")) - // unsupported ZONETYPE - { - AssertThrow(false,ExcMessage("The tecplot file contains an unsupported ZONETYPE.")); - } + // unsupported ZONETYPE + { + AssertThrow(false,ExcMessage("The tecplot file contains an unsupported ZONETYPE.")); + } else if (Utilities::match_at_string_start(entries[i],"DATAPACKING=POINT")) - blocked=false; + blocked=false; else if (Utilities::match_at_string_start(entries[i],"DATAPACKING=BLOCK")) - blocked=true; + blocked=true; else if (Utilities::match_at_string_start(entries[i],"F=POINT")) - { - structured=true; - blocked=false; - } + { + structured=true; + blocked=false; + } else if (Utilities::match_at_string_start(entries[i],"F=BLOCK")) - { - structured=true; - blocked=true; - } + { + structured=true; + blocked=true; + } else if (Utilities::match_at_string_start(entries[i],"F=FEPOINT")) - { - structured=false; - blocked=false; - } + { + structured=false; + blocked=false; + } else if (Utilities::match_at_string_start(entries[i],"F=FEBLOCK")) - { - structured=false; - blocked=true; - } + { + structured=false; + blocked=true; + } else if (Utilities::match_at_string_start(entries[i],"ET=QUADRILATERAL") && dim==2) - structured=false; + structured=false; else if (Utilities::match_at_string_start(entries[i],"ET=BRICK") && dim==3) - structured=false; + structured=false; else if (Utilities::match_at_string_start(entries[i],"ET=")) - // unsupported ElementType - { - AssertThrow(false,ExcMessage("The tecplot file contains an unsupported ElementType.")); - } + // unsupported ElementType + { + AssertThrow(false,ExcMessage("The tecplot file contains an unsupported ElementType.")); + } else if (Utilities::match_at_string_start(entries[i],"I=")) - IJK[0]=Utilities::get_integer_at_position(entries[i],2).first; + IJK[0]=Utilities::get_integer_at_position(entries[i],2).first; else if (Utilities::match_at_string_start(entries[i],"J=")) - { - IJK[1]=Utilities::get_integer_at_position(entries[i],2).first; - AssertThrow(dim>1 || IJK[1]==1, - ExcMessage("Parameter 'J=' found in tecplot, although this is only possible for dimensions greater than 1.")); - } + { + IJK[1]=Utilities::get_integer_at_position(entries[i],2).first; + AssertThrow(dim>1 || IJK[1]==1, + ExcMessage("Parameter 'J=' found in tecplot, although this is only possible for dimensions greater than 1.")); + } else if (Utilities::match_at_string_start(entries[i],"K=")) - { - IJK[2]=Utilities::get_integer_at_position(entries[i],2).first; - AssertThrow(dim>2 || IJK[2]==1, - ExcMessage("Parameter 'K=' found in tecplot, although this is only possible for dimensions greater than 2.")); - } + { + IJK[2]=Utilities::get_integer_at_position(entries[i],2).first; + AssertThrow(dim>2 || IJK[2]==1, + ExcMessage("Parameter 'K=' found in tecplot, although this is only possible for dimensions greater than 2.")); + } else if (Utilities::match_at_string_start(entries[i],"N=")) - n_vertices=Utilities::get_integer_at_position(entries[i],2).first; + n_vertices=Utilities::get_integer_at_position(entries[i],2).first; else if (Utilities::match_at_string_start(entries[i],"E=")) - n_cells=Utilities::get_integer_at_position(entries[i],2).first; + n_cells=Utilities::get_integer_at_position(entries[i],2).first; } - // now we have read all the fields we are - // interested in. do some checks and - // calculate the variables + // now we have read all the fields we are + // interested in. do some checks and + // calculate the variables if (structured) { n_vertices=1; n_cells=1; for (unsigned int d=0; d0, - ExcMessage("Tecplot file does not contain a complete and consistent set of parameters")); - n_vertices*=IJK[d]; - n_cells*=(IJK[d]-1); - } + { + AssertThrow(IJK[d]>0, + ExcMessage("Tecplot file does not contain a complete and consistent set of parameters")); + n_vertices*=IJK[d]; + n_cells*=(IJK[d]-1); + } } else { AssertThrow(n_vertices>0, - ExcMessage("Tecplot file does not contain a complete and consistent set of parameters")); + ExcMessage("Tecplot file does not contain a complete and consistent set of parameters")); if (n_cells==0) - // this means an error, although - // tecplot itself accepts entries like - // 'J=20' instead of 'E=20'. therefore, - // take the max of IJK - n_cells=*std::max_element(IJK.begin(),IJK.end()); + // this means an error, although + // tecplot itself accepts entries like + // 'J=20' instead of 'E=20'. therefore, + // take the max of IJK + n_cells=*std::max_element(IJK.begin(),IJK.end()); AssertThrow(n_cells>0, - ExcMessage("Tecplot file does not contain a complete and consistent set of parameters")); + ExcMessage("Tecplot file does not contain a complete and consistent set of parameters")); } } @@ -1624,17 +1624,17 @@ void GridIn<2>::read_tecplot (std::istream &in) Assert (tria != 0, ExcNoTriangulationSelected()); AssertThrow (in, ExcIO()); - // skip comments at start of file + // skip comments at start of file skip_comment_lines (in, '#'); - // some strings for parsing the header + // some strings for parsing the header std::string line, header; - // first, concatenate all header lines - // create a searchstring with almost all - // letters. exclude e and E from the letters - // to search, as they might appear in - // exponential notation + // first, concatenate all header lines + // create a searchstring with almost all + // letters. exclude e and E from the letters + // to search, as they might appear in + // exponential notation std::string letters ="abcdfghijklmnopqrstuvwxyzABCDFGHIJKLMNOPQRSTUVWXYZ"; getline(in,line); @@ -1644,9 +1644,9 @@ void GridIn<2>::read_tecplot (std::istream &in) getline(in,line); } - // now create some variables holding - // important information on the mesh, get - // this information from the header string + // now create some variables holding + // important information on the mesh, get + // this information from the header string std::vector tecplot2deal(dim); std::vector IJK(dim); unsigned int n_vars, @@ -1656,191 +1656,191 @@ void GridIn<2>::read_tecplot (std::istream &in) blocked; parse_tecplot_header(header, - tecplot2deal,n_vars,n_vertices,n_cells,IJK, - structured,blocked); - - // reserve space for vertices. note, that in - // tecplot vertices are ordered beginning - // with 1, whereas in deal all indices start - // with 0. in order not to use -1 for all the - // connectivity information, a 0th vertex - // (unused) is inserted at the origin. + tecplot2deal,n_vars,n_vertices,n_cells,IJK, + structured,blocked); + + // reserve space for vertices. note, that in + // tecplot vertices are ordered beginning + // with 1, whereas in deal all indices start + // with 0. in order not to use -1 for all the + // connectivity information, a 0th vertex + // (unused) is inserted at the origin. std::vector > vertices(n_vertices+1); vertices[0]=Point(); - // reserve space for cells + // reserve space for cells std::vector > cells(n_cells); SubCellData subcelldata; if (blocked) { - // blocked data format. first we get all - // the values of the first variable for - // all points, after that we get all - // values for the second variable and so - // on. - - // dummy variable to read in all the info - // we do not want to use + // blocked data format. first we get all + // the values of the first variable for + // all points, after that we get all + // values for the second variable and so + // on. + + // dummy variable to read in all the info + // we do not want to use double dummy; - // which is the first index to read in - // the loop (see below) + // which is the first index to read in + // the loop (see below) unsigned int next_index=0; - // note, that we have already read the - // first line containing the first variable + // note, that we have already read the + // first line containing the first variable if (tecplot2deal[0]==0) - { - // we need the information in this - // line, so extract it - std::vector first_var=Utilities::break_text_into_lines(line,1); - char *endptr; - for (unsigned int i=1; i>vertices[j](next_index); - // now we got all values of the first - // variable, so increase the counter - next_index=1; - } - - // main loop over all variables + { + // we need the information in this + // line, so extract it + std::vector first_var=Utilities::break_text_into_lines(line,1); + char *endptr; + for (unsigned int i=1; i>vertices[j](next_index); + // now we got all values of the first + // variable, so increase the counter + next_index=1; + } + + // main loop over all variables for (unsigned int i=1; i>vertices[j](next_index); - ++next_index; - } - else - { - // we do not need this line, read - // it in and discard it - for (unsigned int j=1; j>dummy; - } - } + { + // if we read all the important + // variables and do not want to + // read further, because we are + // using a structured grid, we can + // stop here (and skip, for + // example, a whole lot of solution + // variables) + if (next_index==dim && structured) + break; + + if ((next_index>vertices[j](next_index); + ++next_index; + } + else + { + // we do not need this line, read + // it in and discard it + for (unsigned int j=1; j>dummy; + } + } Assert(next_index==dim, ExcInternalError()); } else { - // the data is not blocked, so we get all - // the variables for one point, then the - // next and so on. create a vector to - // hold these components + // the data is not blocked, so we get all + // the variables for one point, then the + // next and so on. create a vector to + // hold these components std::vector vars(n_vars); - // now fill the first vertex. note, that we - // have already read the first line - // containing the first vertex + // now fill the first vertex. note, that we + // have already read the first line + // containing the first vertex std::vector first_vertex=Utilities::break_text_into_lines(line,1); char *endptr; for (unsigned int d=0; d>vars[i]; - // fill the vertex - // coordinates. respect the position - // of coordinates in the list of - // variables - for (unsigned int i=0; i>vars[i]; + // fill the vertex + // coordinates. respect the position + // of coordinates in the list of + // variables + for (unsigned int i=0; i boundary_vertices(2*I+2*J-4); unsigned int k=0; for (unsigned int i=1;i::vertices_per_cell; ++j) - in>>cells[i].vertices[j]; - } - // do some clean-up on vertices + { + // note that since in the input file + // we found the number of cells at + // the top, there should still be + // input here, so check this: + AssertThrow (in, ExcIO()); + + // get the connectivity from the + // input file. the vertices are + // ordered like in the ucd format + for (unsigned int j=0; j::vertices_per_cell; ++j) + in>>cells[i].vertices[j]; + } + // do some clean-up on vertices GridTools::delete_unused_vertices (vertices, cells, subcelldata); } - // check that no forbidden arrays are - // used. as we do not read in any - // subcelldata, nothing should happen here. + // check that no forbidden arrays are + // used. as we do not read in any + // subcelldata, nothing should happen here. Assert (subcelldata.check_consistency(dim), ExcInternalError()); AssertThrow (in, ExcIO()); - // do some cleanup on cells + // do some cleanup on cells GridReordering::invert_all_cells_of_negative_grid (vertices, cells); GridReordering::reorder_cells (cells); tria->create_triangulation_compatibility (vertices, cells, subcelldata); @@ -1861,24 +1861,24 @@ void GridIn::skip_empty_lines (std::istream &in) std::string line; while (in) { - // get line + // get line getline (in, line); - // check if this is a line that - // consists only of spaces, and - // if not put the whole thing - // back and return + // check if this is a line that + // consists only of spaces, and + // if not put the whole thing + // back and return if (std::find_if (line.begin(), line.end(), - std::bind2nd (std::not_equal_to(),' ')) - != line.end()) - { - in.putback ('\n'); - for (int i=line.length()-1; i>=0; --i) - in.putback (line[i]); - return; - } - - // else: go on with next line + std::bind2nd (std::not_equal_to(),' ')) + != line.end()) + { + in.putback ('\n'); + for (int i=line.length()-1; i>=0; --i) + in.putback (line[i]); + return; + } + + // else: go on with next line } } @@ -1886,20 +1886,20 @@ void GridIn::skip_empty_lines (std::istream &in) template void GridIn::skip_comment_lines (std::istream &in, - const char comment_start) + const char comment_start) { char c; - // loop over the following comment - // lines + // loop over the following comment + // lines while ((c=in.get()) == comment_start) - // loop over the characters after - // the comment starter + // loop over the characters after + // the comment starter while (in.get() != '\n') ; - // put back first character of - // first non-comment line + // put back first character of + // first non-comment line in.putback (c); // at last: skip additional empty lines, if present @@ -1910,8 +1910,8 @@ void GridIn::skip_comment_lines (std::istream &in, template void GridIn::debug_output_grid (const std::vector > &/*cells*/, - const std::vector > &/*vertices*/, - std::ostream &/*out*/) + const std::vector > &/*vertices*/, + std::ostream &/*out*/) { Assert (false, ExcNotImplemented()); } @@ -1921,59 +1921,59 @@ void GridIn::debug_output_grid (const std::vector > template <> void GridIn<2>::debug_output_grid (const std::vector > &cells, - const std::vector > &vertices, - std::ostream &out) + const std::vector > &vertices, + std::ostream &out) { double min_x = vertices[cells[0].vertices[0]](0), - max_x = vertices[cells[0].vertices[0]](0), - min_y = vertices[cells[0].vertices[0]](1), - max_y = vertices[cells[0].vertices[0]](1); + max_x = vertices[cells[0].vertices[0]](0), + min_y = vertices[cells[0].vertices[0]](1), + max_y = vertices[cells[0].vertices[0]](1); for (unsigned int i=0; i &p = vertices[cells[i].vertices[v]]; - - if (p(0) < min_x) - min_x = p(0); - if (p(0) > max_x) - max_x = p(0); - if (p(1) < min_y) - min_y = p(1); - if (p(1) > max_y) - max_y = p(1); - }; + { + const Point<2> &p = vertices[cells[i].vertices[v]]; + + if (p(0) < min_x) + min_x = p(0); + if (p(0) > max_x) + max_x = p(0); + if (p(1) < min_y) + min_y = p(1); + if (p(1) > max_y) + max_y = p(1); + }; out << "# cell " << i << std::endl; Point<2> center; for (unsigned int f=0; f<4; ++f) - center += vertices[cells[i].vertices[f]]; + center += vertices[cells[i].vertices[f]]; center /= 4; out << "set label \"" << i << "\" at " - << center(0) << ',' << center(1) - << " center" - << std::endl; + << center(0) << ',' << center(1) + << " center" + << std::endl; - // first two line right direction + // first two line right direction for (unsigned int f=0; f<2; ++f) - out << "set arrow from " - << vertices[cells[i].vertices[f]](0) << ',' - << vertices[cells[i].vertices[f]](1) - << " to " - << vertices[cells[i].vertices[(f+1)%4]](0) << ',' - << vertices[cells[i].vertices[(f+1)%4]](1) - << std::endl; - // other two lines reverse direction + out << "set arrow from " + << vertices[cells[i].vertices[f]](0) << ',' + << vertices[cells[i].vertices[f]](1) + << " to " + << vertices[cells[i].vertices[(f+1)%4]](0) << ',' + << vertices[cells[i].vertices[(f+1)%4]](1) + << std::endl; + // other two lines reverse direction for (unsigned int f=2; f<4; ++f) - out << "set arrow from " - << vertices[cells[i].vertices[(f+1)%4]](0) << ',' - << vertices[cells[i].vertices[(f+1)%4]](1) - << " to " - << vertices[cells[i].vertices[f]](0) << ',' - << vertices[cells[i].vertices[f]](1) - << std::endl; + out << "set arrow from " + << vertices[cells[i].vertices[(f+1)%4]](0) << ',' + << vertices[cells[i].vertices[(f+1)%4]](1) + << " to " + << vertices[cells[i].vertices[f]](0) << ',' + << vertices[cells[i].vertices[f]](1) + << std::endl; out << std::endl; }; @@ -1991,71 +1991,71 @@ GridIn<2>::debug_output_grid (const std::vector > &cells, template <> void GridIn<3>::debug_output_grid (const std::vector > &cells, - const std::vector > &vertices, - std::ostream &out) + const std::vector > &vertices, + std::ostream &out) { for (unsigned int cell=0; cell::debug_output_grid (const std::vector > &cells, template void GridIn::read (const std::string& filename, - Format format) + Format format) { - // Search file class for meshes + // Search file class for meshes PathSearch search("MESH"); std::string name; - // Open the file and remember its name + // Open the file and remember its name if (format == Default) name = search.find(filename); else @@ -2081,11 +2081,11 @@ void GridIn::read (const std::string& filename, const std::string::size_type slashpos = name.find_last_of('/'); const std::string::size_type dotpos = name.find_last_of('.'); if (dotpos < name.length() - && (dotpos > slashpos || slashpos == std::string::npos)) - { - std::string ext = name.substr(dotpos+1); - format = parse_format(ext); - } + && (dotpos > slashpos || slashpos == std::string::npos)) + { + std::string ext = name.substr(dotpos+1); + format = parse_format(ext); + } } if (format == netcdf) read_netcdf(filename); @@ -2096,7 +2096,7 @@ void GridIn::read (const std::string& filename, template void GridIn::read (std::istream& in, - Format format) + Format format) { if (format == Default) format = default_format; @@ -2104,33 +2104,33 @@ void GridIn::read (std::istream& in, switch (format) { case dbmesh: - read_dbmesh (in); - return; + read_dbmesh (in); + return; case msh: - read_msh (in); - return; + read_msh (in); + return; case ucd: - read_ucd (in); - return; + read_ucd (in); + return; case xda: - read_xda (in); - return; + read_xda (in); + return; case netcdf: - Assert(false, ExcMessage("There is no read_netcdf(istream &) function. " - "Use the read(_netcdf)(string &filename) " - "functions, instead.")); - return; + Assert(false, ExcMessage("There is no read_netcdf(istream &) function. " + "Use the read(_netcdf)(string &filename) " + "functions, instead.")); + return; case tecplot: - read_tecplot (in); - return; + read_tecplot (in); + return; case Default: - break; + break; } Assert (false, ExcInternalError()); } @@ -2146,18 +2146,18 @@ GridIn::default_suffix (const Format format) case dbmesh: return ".dbmesh"; case msh: - return ".msh"; + return ".msh"; case ucd: - return ".inp"; + return ".inp"; case xda: - return ".xda"; + return ".xda"; case netcdf: - return ".nc"; + return ".nc"; case tecplot: - return ".dat"; + return ".dat"; default: - Assert (false, ExcNotImplemented()); - return ".unknown_format"; + Assert (false, ExcNotImplemented()); + return ".unknown_format"; } } @@ -2195,19 +2195,19 @@ GridIn::parse_format (const std::string &format_name) return tecplot; if (format_name == "plt") - // Actually, this is the extension for the - // tecplot binary format, which we do not - // support right now. However, some people - // tend to create tecplot ascii files with - // the extension 'plt' instead of - // 'dat'. Thus, include this extension - // here. If it actually is a binary file, - // the read_tecplot() function will fail - // and throw an exception, anyway. + // Actually, this is the extension for the + // tecplot binary format, which we do not + // support right now. However, some people + // tend to create tecplot ascii files with + // the extension 'plt' instead of + // 'dat'. Thus, include this extension + // here. If it actually is a binary file, + // the read_tecplot() function will fail + // and throw an exception, anyway. return tecplot; AssertThrow (false, ExcInvalidState ()); - // return something weird + // return something weird return Format(Default); } diff --git a/deal.II/source/grid/grid_out.cc b/deal.II/source/grid/grid_out.cc index d1c0ce6f80..51baca980d 100644 --- a/deal.II/source/grid/grid_out.cc +++ b/deal.II/source/grid/grid_out.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2010, 2011 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -37,10 +37,10 @@ DEAL_II_NAMESPACE_OPEN namespace GridOutFlags { DX::DX (const bool write_cells, - const bool write_faces, - const bool write_diameter, - const bool write_measure, - const bool write_all_faces) : + const bool write_faces, + const bool write_diameter, + const bool write_measure, + const bool write_all_faces) : write_cells (write_cells), write_faces (write_faces), write_diameter (write_diameter), @@ -51,18 +51,18 @@ namespace GridOutFlags void DX::declare_parameters (ParameterHandler& param) { param.declare_entry("Write cells", "true", Patterns::Bool(), - "Write the mesh connectivity as DX grid cells"); + "Write the mesh connectivity as DX grid cells"); param.declare_entry("Write faces", "false", Patterns::Bool(), - "Write faces of cells. These may be boundary faces " - "or all faces between mesh cells, according to " - "\"Write all faces\""); + "Write faces of cells. These may be boundary faces " + "or all faces between mesh cells, according to " + "\"Write all faces\""); param.declare_entry("Write diameter", "false", Patterns::Bool(), - "If cells are written, additionally write their" - " diameter as data for visualization"); + "If cells are written, additionally write their" + " diameter as data for visualization"); param.declare_entry("Write measure", "false", Patterns::Bool(), - "Write the volume of each cell as data"); + "Write the volume of each cell as data"); param.declare_entry("Write all faces", "true", Patterns::Bool(), - "Write all faces, not only boundary"); + "Write all faces, not only boundary"); } void DX::parse_parameters (ParameterHandler& param) @@ -76,7 +76,7 @@ namespace GridOutFlags Msh::Msh (const bool write_faces, - const bool write_lines) : + const bool write_lines) : write_faces (write_faces), write_lines (write_lines) {} @@ -96,11 +96,11 @@ namespace GridOutFlags Ucd::Ucd (const bool write_preamble, - const bool write_faces, - const bool write_lines) : - write_preamble (write_preamble), - write_faces (write_faces), - write_lines (write_lines) + const bool write_faces, + const bool write_lines) : + write_preamble (write_preamble), + write_faces (write_faces), + write_lines (write_lines) {} @@ -122,11 +122,11 @@ namespace GridOutFlags Gnuplot::Gnuplot (const bool write_cell_numbers, - const unsigned int n_boundary_face_points, - const bool curved_inner_cells) : - write_cell_numbers (write_cell_numbers), - n_boundary_face_points(n_boundary_face_points), - curved_inner_cells(curved_inner_cells) + const unsigned int n_boundary_face_points, + const bool curved_inner_cells) : + write_cell_numbers (write_cell_numbers), + n_boundary_face_points(n_boundary_face_points), + curved_inner_cells(curved_inner_cells) {} @@ -146,38 +146,38 @@ namespace GridOutFlags EpsFlagsBase::EpsFlagsBase (const SizeType size_type, - const unsigned int size, - const double line_width, - const bool color_lines_on_user_flag, - const unsigned int n_boundary_face_points, - const bool color_lines_level) : - size_type (size_type), - size (size), - line_width (line_width), - color_lines_on_user_flag(color_lines_on_user_flag), - n_boundary_face_points(n_boundary_face_points), - color_lines_level(color_lines_level) + const unsigned int size, + const double line_width, + const bool color_lines_on_user_flag, + const unsigned int n_boundary_face_points, + const bool color_lines_level) : + size_type (size_type), + size (size), + line_width (line_width), + color_lines_on_user_flag(color_lines_on_user_flag), + n_boundary_face_points(n_boundary_face_points), + color_lines_level(color_lines_level) {} void EpsFlagsBase::declare_parameters (ParameterHandler& param) { param.declare_entry("Size by", "width", - Patterns::Selection("width|height"), - "Depending on this parameter, either the" - "width or height " - "of the eps is scaled to \"Size\""); + Patterns::Selection("width|height"), + "Depending on this parameter, either the" + "width or height " + "of the eps is scaled to \"Size\""); param.declare_entry("Size", "300", Patterns::Integer(), - "Size of the output in points"); + "Size of the output in points"); param.declare_entry("Line width", "0.5", Patterns::Double(), - "Width of the lines drawn in points"); + "Width of the lines drawn in points"); param.declare_entry("Color by flag", "false", Patterns::Bool(), - "Draw lines with user flag set in different color"); + "Draw lines with user flag set in different color"); param.declare_entry("Boundary points", "2", Patterns::Integer(), - "Number of points on boundary edges. " - "Increase this beyond 2 to see curved boundaries."); + "Number of points on boundary edges. " + "Increase this beyond 2 to see curved boundaries."); param.declare_entry("Color by level", "false", Patterns::Bool(), - "Draw different colors according to grid level."); + "Draw different colors according to grid level."); } @@ -197,14 +197,14 @@ namespace GridOutFlags Eps<1>::Eps (const SizeType size_type, - const unsigned int size, - const double line_width, - const bool color_lines_on_user_flag, - const unsigned int n_boundary_face_points) - : - EpsFlagsBase(size_type, size, line_width, - color_lines_on_user_flag, - n_boundary_face_points) + const unsigned int size, + const double line_width, + const bool color_lines_on_user_flag, + const unsigned int n_boundary_face_points) + : + EpsFlagsBase(size_type, size, line_width, + color_lines_on_user_flag, + n_boundary_face_points) {} @@ -220,36 +220,36 @@ namespace GridOutFlags Eps<2>::Eps (const SizeType size_type, - const unsigned int size, - const double line_width, - const bool color_lines_on_user_flag, - const unsigned int n_boundary_face_points, - const bool write_cell_numbers, - const bool write_cell_number_level, - const bool write_vertex_numbers, - const bool color_lines_level + const unsigned int size, + const double line_width, + const bool color_lines_on_user_flag, + const unsigned int n_boundary_face_points, + const bool write_cell_numbers, + const bool write_cell_number_level, + const bool write_vertex_numbers, + const bool color_lines_level ) - : - EpsFlagsBase(size_type, size, line_width, - color_lines_on_user_flag, - n_boundary_face_points, - color_lines_level), - write_cell_numbers (write_cell_numbers), - write_cell_number_level (write_cell_number_level), - write_vertex_numbers (write_vertex_numbers) + : + EpsFlagsBase(size_type, size, line_width, + color_lines_on_user_flag, + n_boundary_face_points, + color_lines_level), + write_cell_numbers (write_cell_numbers), + write_cell_number_level (write_cell_number_level), + write_vertex_numbers (write_vertex_numbers) {} void Eps<2>::declare_parameters (ParameterHandler& param) { param.declare_entry("Cell number", "false", Patterns::Bool(), - "(2D only) Write cell numbers" - " into the centers of cells"); + "(2D only) Write cell numbers" + " into the centers of cells"); param.declare_entry("Level number", "false", Patterns::Bool(), - "(2D only) if \"Cell number\" is true, write" - "numbers in the form level.number"); + "(2D only) if \"Cell number\" is true, write" + "numbers in the form level.number"); param.declare_entry("Vertex number", "false", Patterns::Bool(), - "Write numbers for each vertex"); + "Write numbers for each vertex"); } @@ -264,28 +264,28 @@ namespace GridOutFlags Eps<3>::Eps (const SizeType size_type, - const unsigned int size, - const double line_width, - const bool color_lines_on_user_flag, - const unsigned int n_boundary_face_points, - const double azimut_angle, - const double turn_angle) - : - EpsFlagsBase(size_type, size, line_width, - color_lines_on_user_flag, - n_boundary_face_points), - azimut_angle (azimut_angle), - turn_angle (turn_angle) + const unsigned int size, + const double line_width, + const bool color_lines_on_user_flag, + const unsigned int n_boundary_face_points, + const double azimut_angle, + const double turn_angle) + : + EpsFlagsBase(size_type, size, line_width, + color_lines_on_user_flag, + n_boundary_face_points), + azimut_angle (azimut_angle), + turn_angle (turn_angle) {} void Eps<3>::declare_parameters (ParameterHandler& param) { param.declare_entry("Azimuth", "30", Patterns::Double(), - "Azimuth of the viw point, that is, the angle " - "in the plane from the x-axis."); + "Azimuth of the viw point, that is, the angle " + "in the plane from the x-axis."); param.declare_entry("Elevation", "30", Patterns::Double(), - "Elevation of the view point above the xy-plane."); + "Elevation of the view point above the xy-plane."); } @@ -299,7 +299,7 @@ namespace GridOutFlags XFig::XFig () - : + : draw_boundary(true), level_color(false), level_depth(true), @@ -347,8 +347,8 @@ namespace GridOutFlags GridOut::GridOut () - : - default_format (none) + : + default_format (none) {} @@ -413,22 +413,22 @@ GridOut::default_suffix (const OutputFormat output_format) switch (output_format) { case none: - return ""; + return ""; case dx: return ".dx"; case gnuplot: - return ".gnuplot"; + return ".gnuplot"; case ucd: - return ".inp"; + return ".inp"; case eps: - return ".eps"; + return ".eps"; case xfig: - return ".fig"; + return ".fig"; case msh: - return ".msh"; + return ".msh"; default: - Assert (false, ExcNotImplemented()); - return ""; + Assert (false, ExcNotImplemented()); + return ""; }; } @@ -467,7 +467,7 @@ GridOut::parse_output_format (const std::string &format_name) return msh; AssertThrow (false, ExcInvalidState ()); - // return something weird + // return something weird return OutputFormat(-1); } @@ -483,7 +483,7 @@ void GridOut::declare_parameters(ParameterHandler& param) { param.declare_entry("Format", "none", - Patterns::Selection(get_output_format_names())); + Patterns::Selection(get_output_format_names())); param.enter_subsection("DX"); GridOutFlags::DX::declare_parameters(param); @@ -553,20 +553,20 @@ std::size_t GridOut::memory_consumption () const { return (sizeof(dx_flags) + - sizeof(msh_flags) + - sizeof(ucd_flags) + - sizeof(gnuplot_flags) + - sizeof(eps_flags_1) + - sizeof(eps_flags_2) + - sizeof(eps_flags_3) + - sizeof(xfig_flags)); + sizeof(msh_flags) + + sizeof(ucd_flags) + + sizeof(gnuplot_flags) + + sizeof(eps_flags_1) + + sizeof(eps_flags_2) + + sizeof(eps_flags_3) + + sizeof(xfig_flags)); } template <> void GridOut::write_dx (const Triangulation<1> &, - std::ostream &) const + std::ostream &) const { Assert (false, ExcNotImplemented()); } @@ -575,25 +575,25 @@ void GridOut::write_dx (const Triangulation<1> &, template void GridOut::write_dx (const Triangulation &tria, - std::ostream &out) const + std::ostream &out) const { //TODO:[GK] allow for boundary faces only Assert(dx_flags.write_all_faces, ExcNotImplemented()); AssertThrow (out, ExcIO()); - // Copied and adapted from write_ucd + // Copied and adapted from write_ucd const std::vector > &vertices = tria.get_vertices(); const std::vector &vertex_used = tria.get_used_vertices(); const unsigned int n_vertices = tria.n_used_vertices(); - // vertices are implicitly numbered from 0 to - // n_vertices-1. we have to renumber the - // vertices, because otherwise we would end - // up with wrong results, if there are unused - // vertices + // vertices are implicitly numbered from 0 to + // n_vertices-1. we have to renumber the + // vertices, because otherwise we would end + // up with wrong results, if there are unused + // vertices std::vector renumber(vertices.size()); - // fill this vector with new vertex numbers - // ranging from 0 to n_vertices-1 + // fill this vector with new vertex numbers + // ranging from 0 to n_vertices-1 unsigned int new_number=0; for (unsigned int i=0; i &tria, const typename Triangulation::active_cell_iterator endc=tria.end(); - // write the vertices + // write the vertices out << "object \"vertices\" class array type float rank 1 shape " << dim << " items " << n_vertices << " data follows" << '\n'; @@ -612,16 +612,16 @@ void GridOut::write_dx (const Triangulation &tria, for (unsigned int i=0; i1) ? dx_flags.write_faces : false; const unsigned int n_cells = tria.n_active_cells(); const unsigned int n_faces = tria.n_active_cells() - * GeometryInfo::faces_per_cell; + * GeometryInfo::faces_per_cell; const unsigned int n_vertices_per_cell = GeometryInfo::vertices_per_cell; const unsigned int n_vertices_per_face = GeometryInfo::vertices_per_face; @@ -629,128 +629,128 @@ void GridOut::write_dx (const Triangulation &tria, if (write_cells) { out << "object \"cells\" class array type int rank 1 shape " - << n_vertices_per_cell - << " items " << n_cells << " data follows" << '\n'; + << n_vertices_per_cell + << " items " << n_cells << " data follows" << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) - { - for (unsigned int v=0; v::vertices_per_cell; ++v) - out << '\t' << renumber[cell->vertex_index(GeometryInfo::dx_to_deal[v])]; - out << '\n'; - } + { + for (unsigned int v=0; v::vertices_per_cell; ++v) + out << '\t' << renumber[cell->vertex_index(GeometryInfo::dx_to_deal[v])]; + out << '\n'; + } out << "attribute \"element type\" string \""; if (dim==1) out << "lines"; if (dim==2) out << "quads"; if (dim==3) out << "cubes"; out << "\"" << '\n' - << "attribute \"ref\" string \"positions\"" << '\n' << '\n'; + << "attribute \"ref\" string \"positions\"" << '\n' << '\n'; - // Additional cell information + // Additional cell information out << "object \"material\" class array type int rank 0 items " - << n_cells << " data follows" << '\n'; + << n_cells << " data follows" << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) - out << ' ' << (unsigned int)cell->material_id(); + out << ' ' << (unsigned int)cell->material_id(); out << '\n' - << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; + << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; out << "object \"level\" class array type int rank 0 items " - << n_cells << " data follows" << '\n'; + << n_cells << " data follows" << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) - out << ' ' << cell->level(); + out << ' ' << cell->level(); out << '\n' - << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; + << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; if (dx_flags.write_measure) - { - out << "object \"measure\" class array type float rank 0 items " - << n_cells << " data follows" << '\n'; - for (cell = tria.begin_active(); cell != endc; ++cell) - out << '\t' << cell->measure(); - out << '\n' - << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; - } + { + out << "object \"measure\" class array type float rank 0 items " + << n_cells << " data follows" << '\n'; + for (cell = tria.begin_active(); cell != endc; ++cell) + out << '\t' << cell->measure(); + out << '\n' + << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; + } if (dx_flags.write_diameter) - { - out << "object \"diameter\" class array type float rank 0 items " - << n_cells << " data follows" << '\n'; - for (cell = tria.begin_active(); cell != endc; ++cell) - out << '\t' << cell->diameter(); - out << '\n' - << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; - } + { + out << "object \"diameter\" class array type float rank 0 items " + << n_cells << " data follows" << '\n'; + for (cell = tria.begin_active(); cell != endc; ++cell) + out << '\t' << cell->diameter(); + out << '\n' + << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; + } } if (write_faces) { out << "object \"faces\" class array type int rank 1 shape " - << n_vertices_per_face - << " items " << n_faces << " data follows" - << '\n'; + << n_vertices_per_face + << " items " << n_faces << " data follows" + << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) - { - for (unsigned int f=0;f::faces_per_cell;++f) - { - typename Triangulation::face_iterator face = cell->face(f); - - for (unsigned int v=0; v::vertices_per_face; ++v) - out << '\t' << renumber[face->vertex_index(GeometryInfo::dx_to_deal[v])]; - out << '\n'; - } - } + { + for (unsigned int f=0;f::faces_per_cell;++f) + { + typename Triangulation::face_iterator face = cell->face(f); + + for (unsigned int v=0; v::vertices_per_face; ++v) + out << '\t' << renumber[face->vertex_index(GeometryInfo::dx_to_deal[v])]; + out << '\n'; + } + } out << "attribute \"element type\" string \""; if (dim==2) out << "lines"; if (dim==3) out << "quads"; out << "\"" << '\n' - << "attribute \"ref\" string \"positions\"" << '\n' << '\n'; + << "attribute \"ref\" string \"positions\"" << '\n' << '\n'; - // Additional face information + // Additional face information out << "object \"boundary\" class array type int rank 0 items " - << n_faces << " data follows" << '\n'; + << n_faces << " data follows" << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) - { - // Little trick to get -1 - // for the interior - for (unsigned int f=0;f::faces_per_cell;++f) - out << ' ' << (int)(signed char)cell->face(f)->boundary_indicator(); - out << '\n'; - } + { + // Little trick to get -1 + // for the interior + for (unsigned int f=0;f::faces_per_cell;++f) + out << ' ' << (int)(signed char)cell->face(f)->boundary_indicator(); + out << '\n'; + } out << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; if (dx_flags.write_measure) - { - out << "object \"face measure\" class array type float rank 0 items " - << n_faces << " data follows" << '\n'; - for (cell = tria.begin_active(); cell != endc; ++cell) - { - for (unsigned int f=0;f::faces_per_cell;++f) - out << ' ' << cell->face(f)->measure(); - out << '\n'; - } - out << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; - } + { + out << "object \"face measure\" class array type float rank 0 items " + << n_faces << " data follows" << '\n'; + for (cell = tria.begin_active(); cell != endc; ++cell) + { + for (unsigned int f=0;f::faces_per_cell;++f) + out << ' ' << cell->face(f)->measure(); + out << '\n'; + } + out << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; + } if (dx_flags.write_diameter) - { - out << "object \"face diameter\" class array type float rank 0 items " - << n_faces << " data follows" << '\n'; - for (cell = tria.begin_active(); cell != endc; ++cell) - { - for (unsigned int f=0;f::faces_per_cell;++f) - out << ' ' << cell->face(f)->diameter(); - out << '\n'; - } - out << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; - } + { + out << "object \"face diameter\" class array type float rank 0 items " + << n_faces << " data follows" << '\n'; + for (cell = tria.begin_active(); cell != endc; ++cell) + { + for (unsigned int f=0;f::faces_per_cell;++f) + out << ' ' << cell->face(f)->diameter(); + out << '\n'; + } + out << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; + } } - // Write additional face information + // Write additional face information if (write_faces) { @@ -760,7 +760,7 @@ void GridOut::write_dx (const Triangulation &tria, { } - // The wrapper + // The wrapper out << "object \"deal data\" class field" << '\n' << "component \"positions\" value \"vertices\"" << '\n' << "component \"connections\" value \"cells\"" << '\n'; @@ -768,26 +768,26 @@ void GridOut::write_dx (const Triangulation &tria, if (write_cells) { out << "object \"cell data\" class field" << '\n' - << "component \"positions\" value \"vertices\"" << '\n' - << "component \"connections\" value \"cells\"" << '\n'; + << "component \"positions\" value \"vertices\"" << '\n' + << "component \"connections\" value \"cells\"" << '\n'; out << "component \"material\" value \"material\"" << '\n'; out << "component \"level\" value \"level\"" << '\n'; if (dx_flags.write_measure) - out << "component \"measure\" value \"measure\"" << '\n'; + out << "component \"measure\" value \"measure\"" << '\n'; if (dx_flags.write_diameter) - out << "component \"diameter\" value \"diameter\"" << '\n'; + out << "component \"diameter\" value \"diameter\"" << '\n'; } if (write_faces) { out << "object \"face data\" class field" << '\n' - << "component \"positions\" value \"vertices\"" << '\n' - << "component \"connections\" value \"faces\"" << '\n'; + << "component \"positions\" value \"vertices\"" << '\n' + << "component \"connections\" value \"faces\"" << '\n'; out << "component \"boundary\" value \"boundary\"" << '\n'; if (dx_flags.write_measure) - out << "component \"measure\" value \"face measure\"" << '\n'; + out << "component \"measure\" value \"face measure\"" << '\n'; if (dx_flags.write_diameter) - out << "component \"diameter\" value \"face diameter\"" << '\n'; + out << "component \"diameter\" value \"face diameter\"" << '\n'; } out << '\n' @@ -798,8 +798,8 @@ void GridOut::write_dx (const Triangulation &tria, out << "member \"faces\" value \"face data\"" << '\n'; out << "end" << '\n'; - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); AssertThrow (out, ExcIO()); @@ -810,13 +810,13 @@ void GridOut::write_dx (const Triangulation &tria, template void GridOut::write_msh (const Triangulation &tria, - std::ostream &out) const + std::ostream &out) const { AssertThrow (out, ExcIO()); - // get the positions of the - // vertices and whether they are - // used. + // get the positions of the + // vertices and whether they are + // used. const std::vector > &vertices = tria.get_vertices(); const std::vector &vertex_used = tria.get_used_vertices(); @@ -825,117 +825,117 @@ void GridOut::write_msh (const Triangulation &tria, typename Triangulation::active_cell_iterator cell=tria.begin_active(); const typename Triangulation::active_cell_iterator endc=tria.end(); - // Write Header - // The file format is: - /* - - - $NOD - number-of-nodes - node-number x-coord y-coord z-coord - ... - $ENDNOD - $ELM - number-of-elements - elm-number elm-type reg-phys reg-elem number-of-nodes node-number-list - ... - $ENDELM - */ + // Write Header + // The file format is: + /* + + + $NOD + number-of-nodes + node-number x-coord y-coord z-coord + ... + $ENDNOD + $ELM + number-of-elements + elm-number elm-type reg-phys reg-elem number-of-nodes node-number-list + ... + $ENDELM + */ out << "$NOD" << std::endl << n_vertices << std::endl; - // actually write the vertices. - // note that we shall number them - // with first index 1 instead of 0 + // actually write the vertices. + // note that we shall number them + // with first index 1 instead of 0 for (unsigned int i=0; i(cell->material_id()) << ' ' - << cell->subdomain_id() << ' ' - << GeometryInfo::vertices_per_cell << ' '; + << static_cast(cell->material_id()) << ' ' + << cell->subdomain_id() << ' ' + << GeometryInfo::vertices_per_cell << ' '; - // Vertex numbering follows UCD conventions. + // Vertex numbering follows UCD conventions. for (unsigned int vertex=0; vertex::vertices_per_cell; - ++vertex) - out << cell->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1 << ' '; + ++vertex) + out << cell->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1 << ' '; out << std::endl; }; - // write faces and lines with - // non-zero boundary indicator + // write faces and lines with + // non-zero boundary indicator if (msh_flags.write_faces) write_msh_faces (tria, cell_index, out); if (msh_flags.write_lines) @@ -943,8 +943,8 @@ void GridOut::write_msh (const Triangulation &tria, out << "$ENDELM" << std::endl; - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); AssertThrow (out, ExcIO()); @@ -953,13 +953,13 @@ void GridOut::write_msh (const Triangulation &tria, template void GridOut::write_ucd (const Triangulation &tria, - std::ostream &out) const + std::ostream &out) const { AssertThrow (out, ExcIO()); - // get the positions of the - // vertices and whether they are - // used. + // get the positions of the + // vertices and whether they are + // used. const std::vector > &vertices = tria.get_vertices(); const std::vector &vertex_used = tria.get_used_vertices(); @@ -968,100 +968,100 @@ void GridOut::write_ucd (const Triangulation &tria, typename Triangulation::active_cell_iterator cell=tria.begin_active(); const typename Triangulation::active_cell_iterator endc=tria.end(); - // write preamble + // write preamble if (ucd_flags.write_preamble) { - // block this to have local - // variables destroyed after - // use + // block this to have local + // variables destroyed after + // use std::time_t time1= std::time (0); std::tm *time = std::localtime(&time1); out << "# This file was generated by the deal.II library." << '\n' - << "# Date = " - << time->tm_year+1900 << "/" - << time->tm_mon+1 << "/" - << time->tm_mday << '\n' - << "# Time = " - << time->tm_hour << ":" - << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << '\n' - << "#" << '\n' - << "# For a description of the UCD format see the AVS Developer's guide." - << '\n' - << "#" << '\n'; + << "# Date = " + << time->tm_year+1900 << "/" + << time->tm_mon+1 << "/" + << time->tm_mday << '\n' + << "# Time = " + << time->tm_hour << ":" + << std::setw(2) << time->tm_min << ":" + << std::setw(2) << time->tm_sec << '\n' + << "#" << '\n' + << "# For a description of the UCD format see the AVS Developer's guide." + << '\n' + << "#" << '\n'; }; - // start with ucd data + // start with ucd data out << n_vertices << ' ' << tria.n_active_cells() + ( (ucd_flags.write_faces ? - n_boundary_faces(tria) : 0) + - (ucd_flags.write_lines ? - n_boundary_lines(tria) : 0) ) + n_boundary_faces(tria) : 0) + + (ucd_flags.write_lines ? + n_boundary_lines(tria) : 0) ) << " 0 0 0" // no data << '\n'; - // actually write the vertices. - // note that we shall number them - // with first index 1 instead of 0 + // actually write the vertices. + // note that we shall number them + // with first index 1 instead of 0 for (unsigned int i=0; i(cell->material_id()) - << ' '; + << static_cast(cell->material_id()) + << ' '; switch (dim) - { - case 1: out << "line "; break; - case 2: out << "quad "; break; - case 3: out << "hex "; break; - default: - Assert (false, ExcNotImplemented()); - }; - - // it follows a list of the - // vertices of each cell. in 1d - // this is simply a list of the - // two vertices, in 2d its counter - // clockwise, as usual in this - // library. in 3d, the same applies - // (special thanks to AVS for - // numbering their vertices in a - // way compatible to deal.II!) - // - // technical reference: - // AVS Developer's Guide, Release 4, - // May, 1992, p. E6 - // - // note: vertex numbers are 1-base + { + case 1: out << "line "; break; + case 2: out << "quad "; break; + case 3: out << "hex "; break; + default: + Assert (false, ExcNotImplemented()); + }; + + // it follows a list of the + // vertices of each cell. in 1d + // this is simply a list of the + // two vertices, in 2d its counter + // clockwise, as usual in this + // library. in 3d, the same applies + // (special thanks to AVS for + // numbering their vertices in a + // way compatible to deal.II!) + // + // technical reference: + // AVS Developer's Guide, Release 4, + // May, 1992, p. E6 + // + // note: vertex numbers are 1-base for (unsigned int vertex=0; vertex::vertices_per_cell; - ++vertex) - out << cell->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1 << ' '; + ++vertex) + out << cell->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1 << ' '; out << '\n'; }; - // write faces and lines with - // non-zero boundary indicator + // write faces and lines with + // non-zero boundary indicator if (ucd_flags.write_faces) write_ucd_faces (tria, cell_index, out); if (ucd_flags.write_lines) write_ucd_lines (tria, cell_index, out); - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); AssertThrow (out, ExcIO()); @@ -1093,119 +1093,119 @@ void GridOut::write_xfig ( const unsigned int nf = GeometryInfo::faces_per_cell; const unsigned int nvf = GeometryInfo::vertices_per_face; - // The following text was copied - // from an existing XFig file. + // The following text was copied + // from an existing XFig file. out << "#FIG 3.2\nLandscape\nCenter\nInches" << '\n' << "A4\n100.00\nSingle" << '\n' - // Background is transparent + // Background is transparent << "-3" << '\n' << "# generated by deal.II GridOut class" << '\n' << "# reduce first number to scale up image" << '\n' << "1200 2" << '\n'; - // We write all cells and cells on - // coarser levels are behind cells - // on finer levels. Level 0 - // corresponds to a depth of 900, - // each level subtracting 1 + // We write all cells and cells on + // coarser levels are behind cells + // on finer levels. Level 0 + // corresponds to a depth of 900, + // each level subtracting 1 Triangulation::cell_iterator cell = tria.begin(); const Triangulation::cell_iterator end = tria.end(); for (;cell != end; ++cell) { - // If depth is not encoded, write finest level only + // If depth is not encoded, write finest level only if (!xfig_flags.level_depth && !cell->active()) - continue; - // Code for polygon + continue; + // Code for polygon out << "2 3 " - << xfig_flags.line_style << ' ' - << xfig_flags.line_thickness - // with black line - << " 0 "; - // Fill color + << xfig_flags.line_style << ' ' + << xfig_flags.line_thickness + // with black line + << " 0 "; + // Fill color if (xfig_flags.level_color) - out << cell->level() + 8; + out << cell->level() + 8; else - out << cell->material_id() + 1; - // Depth, unused, fill + out << cell->material_id() + 1; + // Depth, unused, fill out << ' ' - << (xfig_flags.level_depth - ? (900-cell->level()) - : (900+cell->material_id())) - << " 0 " - << xfig_flags.fill_style << " 0.0 " - // some style parameters - << " 0 0 -1 0 0 " - // number of points - << nv+1 << '\n'; - - // For each point, write scaled - // and shifted coordinates - // multiplied by 1200 - // (dots/inch) + << (xfig_flags.level_depth + ? (900-cell->level()) + : (900+cell->material_id())) + << " 0 " + << xfig_flags.fill_style << " 0.0 " + // some style parameters + << " 0 0 -1 0 0 " + // number of points + << nv+1 << '\n'; + + // For each point, write scaled + // and shifted coordinates + // multiplied by 1200 + // (dots/inch) for (unsigned int k=0;k<=nv;++k) - { - const Point& p = cell->vertex( - GeometryInfo::ucd_to_deal[k % nv]); - for (unsigned int d=0; d(dim); ++d) - { - int val = (int)(1200 * xfig_flags.scaling(d) * - (p(d)-xfig_flags.offset(d))); - out << '\t' << val; - } - out << '\n'; - } - // Now write boundary edges + { + const Point& p = cell->vertex( + GeometryInfo::ucd_to_deal[k % nv]); + for (unsigned int d=0; d(dim); ++d) + { + int val = (int)(1200 * xfig_flags.scaling(d) * + (p(d)-xfig_flags.offset(d))); + out << '\t' << val; + } + out << '\n'; + } + // Now write boundary edges static const unsigned int face_reorder[4]={2,1,3,0}; if (xfig_flags.draw_boundary) - for (unsigned int f=0;f::face_iterator - face = cell->face(face_reorder[f]); - const types::boundary_id_t bi = face->boundary_indicator(); - if (bi != types::internal_face_boundary_id) - { - // Code for polyline - out << "2 1 " - // with line style and thickness - << xfig_flags.boundary_style << ' ' - << xfig_flags.boundary_thickness << ' ' - << (1 + (unsigned int) bi); - // Fill color - out << " -1 "; - // Depth 100 less than cells - out << (xfig_flags.level_depth - ? (800-cell->level()) - : 800+bi) - // unused, no fill - << " 0 -1 0.0 " - // some style parameters - << " 0 0 -1 0 0 " - // number of points - << nvf << '\n'; - - // For each point, write scaled - // and shifted coordinates - // multiplied by 1200 - // (dots/inch) - - for (unsigned int k=0;k& p = face->vertex(k % nv); - for (unsigned int d=0; d(dim); ++d) - { - int val = (int)(1200 * xfig_flags.scaling(d) * - (p(d)-xfig_flags.offset(d))); - out << '\t' << val; - } - out << '\n'; - } - } - } + for (unsigned int f=0;f::face_iterator + face = cell->face(face_reorder[f]); + const types::boundary_id_t bi = face->boundary_indicator(); + if (bi != types::internal_face_boundary_id) + { + // Code for polyline + out << "2 1 " + // with line style and thickness + << xfig_flags.boundary_style << ' ' + << xfig_flags.boundary_thickness << ' ' + << (1 + (unsigned int) bi); + // Fill color + out << " -1 "; + // Depth 100 less than cells + out << (xfig_flags.level_depth + ? (800-cell->level()) + : 800+bi) + // unused, no fill + << " 0 -1 0.0 " + // some style parameters + << " 0 0 -1 0 0 " + // number of points + << nvf << '\n'; + + // For each point, write scaled + // and shifted coordinates + // multiplied by 1200 + // (dots/inch) + + for (unsigned int k=0;k& p = face->vertex(k % nv); + for (unsigned int d=0; d(dim); ++d) + { + int val = (int)(1200 * xfig_flags.scaling(d) * + (p(d)-xfig_flags.offset(d))); + out << '\t' << val; + } + out << '\n'; + } + } + } } - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); AssertThrow (out, ExcIO()); @@ -1267,7 +1267,7 @@ unsigned int GridOut::n_boundary_faces (const Triangulation &tria) for (face=tria.begin_active_face(), endf=tria.end_face(); face != endf; ++face) if ((face->at_boundary()) && - (face->boundary_indicator() != 0)) + (face->boundary_indicator() != 0)) n_faces++; return n_faces; @@ -1284,7 +1284,7 @@ unsigned int GridOut::n_boundary_lines (const Triangulation &tria for (edge=tria.begin_active_line(), endedge=tria.end_line(); edge != endedge; ++edge) if ((edge->at_boundary()) && - (edge->boundary_indicator() != 0)) + (edge->boundary_indicator() != 0)) n_lines++; return n_lines; @@ -1294,61 +1294,61 @@ unsigned int GridOut::n_boundary_lines (const Triangulation &tria void GridOut::write_msh_faces (const Triangulation<1> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_msh_faces (const Triangulation<1,2> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_msh_faces (const Triangulation<1,3> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_msh_lines (const Triangulation<1> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_msh_lines (const Triangulation<1,2> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_msh_lines (const Triangulation<1,3> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_msh_lines (const Triangulation<2> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_msh_lines (const Triangulation<2,3> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } @@ -1358,8 +1358,8 @@ void GridOut::write_msh_lines (const Triangulation<2,3> &, template void GridOut::write_msh_faces (const Triangulation &tria, - const unsigned int starting_index, - std::ostream &out) const + const unsigned int starting_index, + std::ostream &out) const { typename Triangulation::active_face_iterator face, endf; unsigned int index=starting_index; @@ -1367,35 +1367,35 @@ void GridOut::write_msh_faces (const Triangulation &tria, for (face=tria.begin_active_face(), endf=tria.end_face(); face != endf; ++face) if (face->at_boundary() && - (face->boundary_indicator() != 0)) + (face->boundary_indicator() != 0)) { - out << index << ' '; - switch (dim) - { - case 2: out << 1 << ' '; break; - case 3: out << 3 << ' '; break; - default: - Assert (false, ExcNotImplemented()); - }; - out << static_cast(face->boundary_indicator()) - << ' ' - << static_cast(face->boundary_indicator()) - << ' ' << GeometryInfo::vertices_per_face; - // note: vertex numbers are 1-base - for (unsigned int vertex=0; vertex::vertices_per_face; ++vertex) - out << ' ' - << face->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1; - out << '\n'; - - ++index; + out << index << ' '; + switch (dim) + { + case 2: out << 1 << ' '; break; + case 3: out << 3 << ' '; break; + default: + Assert (false, ExcNotImplemented()); + }; + out << static_cast(face->boundary_indicator()) + << ' ' + << static_cast(face->boundary_indicator()) + << ' ' << GeometryInfo::vertices_per_face; + // note: vertex numbers are 1-base + for (unsigned int vertex=0; vertex::vertices_per_face; ++vertex) + out << ' ' + << face->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1; + out << '\n'; + + ++index; }; } template void GridOut::write_msh_lines (const Triangulation &tria, - const unsigned int starting_index, - std::ostream &out) const + const unsigned int starting_index, + std::ostream &out) const { typename Triangulation::active_line_iterator line, endl; unsigned int index=starting_index; @@ -1403,20 +1403,20 @@ void GridOut::write_msh_lines (const Triangulation &tria, for (line=tria.begin_active_line(), endl=tria.end_line(); line != endl; ++line) if (line->at_boundary() && - (line->boundary_indicator() != 0)) + (line->boundary_indicator() != 0)) { - out << index << " 1 "; - out << static_cast(line->boundary_indicator()) - << ' ' - << static_cast(line->boundary_indicator()) - << " 2 "; - // note: vertex numbers are 1-base - for (unsigned int vertex=0; vertex<2; ++vertex) - out << ' ' - << line->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1; - out << '\n'; - - ++index; + out << index << " 1 "; + out << static_cast(line->boundary_indicator()) + << ' ' + << static_cast(line->boundary_indicator()) + << " 2 "; + // note: vertex numbers are 1-base + for (unsigned int vertex=0; vertex<2; ++vertex) + out << ' ' + << line->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1; + out << '\n'; + + ++index; }; } @@ -1424,59 +1424,59 @@ void GridOut::write_msh_lines (const Triangulation &tria, void GridOut::write_ucd_faces (const Triangulation<1> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_ucd_faces (const Triangulation<1,2> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_ucd_faces (const Triangulation<1,3> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_ucd_lines (const Triangulation<1> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_ucd_lines (const Triangulation<1,2> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_ucd_lines (const Triangulation<1,3> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_ucd_lines (const Triangulation<2> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } void GridOut::write_ucd_lines (const Triangulation<2,3> &, - const unsigned int, - std::ostream &) const + const unsigned int, + std::ostream &) const { return; } @@ -1486,8 +1486,8 @@ void GridOut::write_ucd_lines (const Triangulation<2,3> &, template void GridOut::write_ucd_faces (const Triangulation &tria, - const unsigned int starting_index, - std::ostream &out) const + const unsigned int starting_index, + std::ostream &out) const { typename Triangulation::active_face_iterator face, endf; unsigned int index=starting_index; @@ -1495,24 +1495,24 @@ void GridOut::write_ucd_faces (const Triangulation &tria, for (face=tria.begin_active_face(), endf=tria.end_face(); face != endf; ++face) if (face->at_boundary() && - (face->boundary_indicator() != 0)) + (face->boundary_indicator() != 0)) { - out << index << " " - << static_cast(face->boundary_indicator()) - << " "; - switch (dim) - { - case 2: out << "line "; break; - case 3: out << "quad "; break; - default: - Assert (false, ExcNotImplemented()); - }; - // note: vertex numbers are 1-base - for (unsigned int vertex=0; vertex::vertices_per_face; ++vertex) - out << face->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1 << ' '; - out << '\n'; - - ++index; + out << index << " " + << static_cast(face->boundary_indicator()) + << " "; + switch (dim) + { + case 2: out << "line "; break; + case 3: out << "quad "; break; + default: + Assert (false, ExcNotImplemented()); + }; + // note: vertex numbers are 1-base + for (unsigned int vertex=0; vertex::vertices_per_face; ++vertex) + out << face->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1 << ' '; + out << '\n'; + + ++index; }; } @@ -1520,8 +1520,8 @@ void GridOut::write_ucd_faces (const Triangulation &tria, template void GridOut::write_ucd_lines (const Triangulation &tria, - const unsigned int starting_index, - std::ostream &out) const + const unsigned int starting_index, + std::ostream &out) const { typename Triangulation::active_line_iterator line, endl; unsigned int index=starting_index; @@ -1529,17 +1529,17 @@ void GridOut::write_ucd_lines (const Triangulation &tria, for (line=tria.begin_active_line(), endl=tria.end_line(); line != endl; ++line) if (line->at_boundary() && - (line->boundary_indicator() != 0)) + (line->boundary_indicator() != 0)) { - out << index << " " - << static_cast(line->boundary_indicator()) - << " line "; - // note: vertex numbers are 1-base - for (unsigned int vertex=0; vertex<2; ++vertex) - out << line->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1 << ' '; - out << '\n'; - - ++index; + out << index << " " + << static_cast(line->boundary_indicator()) + << " line "; + // note: vertex numbers are 1-base + for (unsigned int vertex=0; vertex<2; ++vertex) + out << line->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1 << ' '; + out << '\n'; + + ++index; }; } @@ -1550,34 +1550,34 @@ namespace internal { template void write_gnuplot (const dealii::Triangulation<1,spacedim> &tria, - std::ostream &out, - const Mapping<1,spacedim> *, - const GridOutFlags::Gnuplot &gnuplot_flags) + std::ostream &out, + const Mapping<1,spacedim> *, + const GridOutFlags::Gnuplot &gnuplot_flags) { AssertThrow (out, ExcIO()); const int dim = 1; typename dealii::Triangulation::active_cell_iterator - cell=tria.begin_active(); + cell=tria.begin_active(); const typename dealii::Triangulation::active_cell_iterator - endc=tria.end(); + endc=tria.end(); for (; cell!=endc; ++cell) - { - if (gnuplot_flags.write_cell_numbers) - out << "# cell " << cell << '\n'; - - out << cell->vertex(0) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << cell->vertex(1) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << '\n'; - } - - // make sure everything now gets to - // disk + { + if (gnuplot_flags.write_cell_numbers) + out << "# cell " << cell << '\n'; + + out << cell->vertex(0) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << cell->vertex(1) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; + } + + // make sure everything now gets to + // disk out.flush (); AssertThrow (out, ExcIO()); @@ -1587,126 +1587,126 @@ namespace internal template void write_gnuplot (const dealii::Triangulation<2,spacedim> &tria, - std::ostream &out, - const Mapping<2,spacedim> *mapping, - const GridOutFlags::Gnuplot &gnuplot_flags) + std::ostream &out, + const Mapping<2,spacedim> *mapping, + const GridOutFlags::Gnuplot &gnuplot_flags) { AssertThrow (out, ExcIO()); const int dim = 2; const unsigned int n_additional_points= - gnuplot_flags.n_boundary_face_points; + gnuplot_flags.n_boundary_face_points; const unsigned int n_points=2+n_additional_points; typename dealii::Triangulation::active_cell_iterator - cell=tria.begin_active(); + cell=tria.begin_active(); const typename dealii::Triangulation::active_cell_iterator - endc=tria.end(); + endc=tria.end(); - // if we are to treat curved - // boundaries, then generate a - // quadrature formula which will be - // used to probe boundary points at - // curved faces + // if we are to treat curved + // boundaries, then generate a + // quadrature formula which will be + // used to probe boundary points at + // curved faces Quadrature *q_projector=0; std::vector > boundary_points; if (mapping!=0) - { - boundary_points.resize(n_points); - boundary_points[0][0]=0; - boundary_points[n_points-1][0]=1; - for (unsigned int i=1; i dummy_weights(n_points, 1./n_points); - Quadrature quadrature(boundary_points, dummy_weights); + std::vector dummy_weights(n_points, 1./n_points); + Quadrature quadrature(boundary_points, dummy_weights); - q_projector = new Quadrature (QProjector::project_to_all_faces(quadrature)); - } + q_projector = new Quadrature (QProjector::project_to_all_faces(quadrature)); + } for (; cell!=endc; ++cell) - { - if (gnuplot_flags.write_cell_numbers) - out << "# cell " << cell << '\n'; - - if (mapping==0 || - (!cell->at_boundary() && !gnuplot_flags.curved_inner_cells)) - { - // write out the four sides - // of this cell by putting - // the four points (+ the - // initial point again) in - // a row and lifting the - // drawing pencil at the - // end - for (unsigned int i=0; i::vertices_per_cell; ++i) - out << cell->vertex(GeometryInfo::ucd_to_deal[i]) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n'; - out << cell->vertex(0) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << '\n' // double new line for gnuplot 3d plots - << '\n'; - } - else - // cell is at boundary and we - // are to treat curved - // boundaries. so loop over - // all faces and draw them as - // small pieces of lines - { - for (unsigned int face_no=0; - face_no::faces_per_cell; ++face_no) - { - const typename dealii::Triangulation::face_iterator - face = cell->face(face_no); - if (face->at_boundary() || gnuplot_flags.curved_inner_cells) - { - // compute offset - // of quadrature - // points within - // set of projected - // points - const unsigned int offset=face_no*n_points; - for (unsigned int i=0; itransform_unit_to_real_cell - (cell, q_projector->point(offset+i))) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) - << '\n'; - - out << '\n' - << '\n'; - } - else - { - // if, however, the - // face is not at - // the boundary, - // then draw it as - // usual - out << face->vertex(0) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) - << '\n' - << face->vertex(1) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) - << '\n' - << '\n' - << '\n'; - } - } - } - } + { + if (gnuplot_flags.write_cell_numbers) + out << "# cell " << cell << '\n'; + + if (mapping==0 || + (!cell->at_boundary() && !gnuplot_flags.curved_inner_cells)) + { + // write out the four sides + // of this cell by putting + // the four points (+ the + // initial point again) in + // a row and lifting the + // drawing pencil at the + // end + for (unsigned int i=0; i::vertices_per_cell; ++i) + out << cell->vertex(GeometryInfo::ucd_to_deal[i]) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n'; + out << cell->vertex(0) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n' // double new line for gnuplot 3d plots + << '\n'; + } + else + // cell is at boundary and we + // are to treat curved + // boundaries. so loop over + // all faces and draw them as + // small pieces of lines + { + for (unsigned int face_no=0; + face_no::faces_per_cell; ++face_no) + { + const typename dealii::Triangulation::face_iterator + face = cell->face(face_no); + if (face->at_boundary() || gnuplot_flags.curved_inner_cells) + { + // compute offset + // of quadrature + // points within + // set of projected + // points + const unsigned int offset=face_no*n_points; + for (unsigned int i=0; itransform_unit_to_real_cell + (cell, q_projector->point(offset+i))) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) + << '\n'; + + out << '\n' + << '\n'; + } + else + { + // if, however, the + // face is not at + // the boundary, + // then draw it as + // usual + out << face->vertex(0) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) + << '\n' + << face->vertex(1) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) + << '\n' + << '\n' + << '\n'; + } + } + } + } if (q_projector != 0) - delete q_projector; + delete q_projector; - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); AssertThrow (out, ExcIO()); @@ -1716,209 +1716,209 @@ namespace internal template void write_gnuplot (const dealii::Triangulation<3,spacedim> &tria, - std::ostream &out, - const Mapping<3,spacedim> *mapping, - const GridOutFlags::Gnuplot &gnuplot_flags) + std::ostream &out, + const Mapping<3,spacedim> *mapping, + const GridOutFlags::Gnuplot &gnuplot_flags) { AssertThrow (out, ExcIO()); const int dim = 3; const unsigned int n_additional_points= - gnuplot_flags.n_boundary_face_points; + gnuplot_flags.n_boundary_face_points; const unsigned int n_points=2+n_additional_points; typename dealii::Triangulation::active_cell_iterator - cell=tria.begin_active(); + cell=tria.begin_active(); const typename dealii::Triangulation::active_cell_iterator - endc=tria.end(); + endc=tria.end(); - // if we are to treat curved - // boundaries, then generate a - // quadrature formula which will be - // used to probe boundary points at - // curved faces + // if we are to treat curved + // boundaries, then generate a + // quadrature formula which will be + // used to probe boundary points at + // curved faces Quadrature *q_projector=0; std::vector > boundary_points; if (mapping!=0) - { - boundary_points.resize(n_points); - boundary_points[0][0]=0; - boundary_points[n_points-1][0]=1; - for (unsigned int i=1; i dummy_weights(n_points, 1./n_points); - Quadrature<1> quadrature1d(boundary_points, dummy_weights); - - // tensor product of points, - // only one copy - QIterated quadrature(quadrature1d, 1); - q_projector = new Quadrature (QProjector::project_to_all_faces(quadrature)); - } + { + boundary_points.resize(n_points); + boundary_points[0][0]=0; + boundary_points[n_points-1][0]=1; + for (unsigned int i=1; i dummy_weights(n_points, 1./n_points); + Quadrature<1> quadrature1d(boundary_points, dummy_weights); + + // tensor product of points, + // only one copy + QIterated quadrature(quadrature1d, 1); + q_projector = new Quadrature (QProjector::project_to_all_faces(quadrature)); + } for (; cell!=endc; ++cell) - { - if (gnuplot_flags.write_cell_numbers) - out << "# cell " << cell << '\n'; - - if (mapping==0 || n_points==2 || - (!cell->has_boundary_lines() && !gnuplot_flags.curved_inner_cells)) - { - // front face - out << cell->vertex(0) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << cell->vertex(1) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << cell->vertex(5) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << cell->vertex(4) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << cell->vertex(0) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << '\n'; - // back face - out << cell->vertex(2) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << cell->vertex(3) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << cell->vertex(7) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << cell->vertex(6) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << cell->vertex(2) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << '\n'; - - // now for the four connecting lines - out << cell->vertex(0) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << cell->vertex(2) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << '\n'; - out << cell->vertex(1) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << cell->vertex(3) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << '\n'; - out << cell->vertex(5) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << cell->vertex(7) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << '\n'; - out << cell->vertex(4) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << cell->vertex(6) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << '\n'; - } - else - { - for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) - { - const typename dealii::Triangulation::face_iterator - face = cell->face(face_no); - - if (face->at_boundary()) - { - const unsigned int offset=face_no*n_points*n_points; - for (unsigned int i=0; i p0=mapping->transform_unit_to_real_cell( - cell, q_projector->point(offset+i*n_points+j)); - out << p0 - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n'; - out << (mapping->transform_unit_to_real_cell( - cell, q_projector->point(offset+(i+1)*n_points+j))) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n'; - out << (mapping->transform_unit_to_real_cell( - cell, q_projector->point(offset+(i+1)*n_points+j+1))) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n'; - out << (mapping->transform_unit_to_real_cell( - cell, q_projector->point(offset+i*n_points+j+1))) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n'; - // and the - // first - // point - // again - out << p0 - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n'; - out << '\n' << '\n'; - } - } - else - { - for (unsigned int l=0; l::lines_per_face; ++l) - { - const typename dealii::Triangulation::line_iterator - line=face->line(l); - - const Point &v0=line->vertex(0), - &v1=line->vertex(1); - if (line->at_boundary() || gnuplot_flags.curved_inner_cells) - { - // transform_real_to_unit_cell - // could be - // replaced - // by using - // QProjector::project_to_line - // which is - // not yet - // implemented - const Point u0=mapping->transform_real_to_unit_cell(cell, v0), - u1=mapping->transform_real_to_unit_cell(cell, v1); - - for (unsigned int i=0; itransform_unit_to_real_cell - (cell, (1-boundary_points[i][0])*u0+boundary_points[i][0]*u1)) - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n'; - } - else - out << v0 - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n' - << v1 - << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << '\n'; - - out << '\n' << '\n'; - } - } - } - } - } + { + if (gnuplot_flags.write_cell_numbers) + out << "# cell " << cell << '\n'; + + if (mapping==0 || n_points==2 || + (!cell->has_boundary_lines() && !gnuplot_flags.curved_inner_cells)) + { + // front face + out << cell->vertex(0) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << cell->vertex(1) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << cell->vertex(5) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << cell->vertex(4) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << cell->vertex(0) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; + // back face + out << cell->vertex(2) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << cell->vertex(3) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << cell->vertex(7) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << cell->vertex(6) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << cell->vertex(2) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; + + // now for the four connecting lines + out << cell->vertex(0) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << cell->vertex(2) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; + out << cell->vertex(1) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << cell->vertex(3) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; + out << cell->vertex(5) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << cell->vertex(7) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; + out << cell->vertex(4) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << cell->vertex(6) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; + } + else + { + for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) + { + const typename dealii::Triangulation::face_iterator + face = cell->face(face_no); + + if (face->at_boundary()) + { + const unsigned int offset=face_no*n_points*n_points; + for (unsigned int i=0; i p0=mapping->transform_unit_to_real_cell( + cell, q_projector->point(offset+i*n_points+j)); + out << p0 + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n'; + out << (mapping->transform_unit_to_real_cell( + cell, q_projector->point(offset+(i+1)*n_points+j))) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n'; + out << (mapping->transform_unit_to_real_cell( + cell, q_projector->point(offset+(i+1)*n_points+j+1))) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n'; + out << (mapping->transform_unit_to_real_cell( + cell, q_projector->point(offset+i*n_points+j+1))) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n'; + // and the + // first + // point + // again + out << p0 + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n'; + out << '\n' << '\n'; + } + } + else + { + for (unsigned int l=0; l::lines_per_face; ++l) + { + const typename dealii::Triangulation::line_iterator + line=face->line(l); + + const Point &v0=line->vertex(0), + &v1=line->vertex(1); + if (line->at_boundary() || gnuplot_flags.curved_inner_cells) + { + // transform_real_to_unit_cell + // could be + // replaced + // by using + // QProjector::project_to_line + // which is + // not yet + // implemented + const Point u0=mapping->transform_real_to_unit_cell(cell, v0), + u1=mapping->transform_real_to_unit_cell(cell, v1); + + for (unsigned int i=0; itransform_unit_to_real_cell + (cell, (1-boundary_points[i][0])*u0+boundary_points[i][0]*u1)) + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n'; + } + else + out << v0 + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n' + << v1 + << ' ' << cell->level() + << ' ' << static_cast(cell->material_id()) << '\n'; + + out << '\n' << '\n'; + } + } + } + } + } if (q_projector != 0) - delete q_projector; + delete q_projector; - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); AssertThrow (out, ExcIO()); @@ -1945,26 +1945,26 @@ namespace internal { struct LineEntry { - Point<2> first; - Point<2> second; - bool colorize; - unsigned int level; - LineEntry (const Point<2> &f, - const Point<2> &s, - const bool c, - const unsigned int l) - : - first(f), second(s), - colorize(c), level(l) - {} + Point<2> first; + Point<2> second; + bool colorize; + unsigned int level; + LineEntry (const Point<2> &f, + const Point<2> &s, + const bool c, + const unsigned int l) + : + first(f), second(s), + colorize(c), level(l) + {} }; void write_eps (const dealii::Triangulation<1> &, - std::ostream &, - const Mapping<1> *, - const GridOutFlags::Eps<2> &, - const GridOutFlags::Eps<3> &) + std::ostream &, + const Mapping<1> *, + const GridOutFlags::Eps<2> &, + const GridOutFlags::Eps<3> &) { Assert(false, ExcNotImplemented()); } @@ -1973,251 +1973,251 @@ namespace internal template void write_eps (const dealii::Triangulation &tria, - std::ostream &out, - const Mapping *mapping, - const GridOutFlags::Eps<2> &eps_flags_2, - const GridOutFlags::Eps<3> &eps_flags_3) + std::ostream &out, + const Mapping *mapping, + const GridOutFlags::Eps<2> &eps_flags_2, + const GridOutFlags::Eps<3> &eps_flags_3) { typedef std::list LineList; - // get a pointer to the flags - // common to all dimensions, in - // order to avoid the recurring - // distinctions between - // eps_flags_1, eps_flags_2, ... + // get a pointer to the flags + // common to all dimensions, in + // order to avoid the recurring + // distinctions between + // eps_flags_1, eps_flags_2, ... const GridOutFlags::EpsFlagsBase - &eps_flags_base = (dim==2 ? - static_cast(eps_flags_2) : - (dim==3 ? - static_cast(eps_flags_3) : - *static_cast(0))); + &eps_flags_base = (dim==2 ? + static_cast(eps_flags_2) : + (dim==3 ? + static_cast(eps_flags_3) : + *static_cast(0))); AssertThrow (out, ExcIO()); const unsigned int n_points = eps_flags_base.n_boundary_face_points; - // make up a list of lines by which - // we will construct the triangulation - // - // this part unfortunately is a bit - // dimension dependent, so we have to - // treat every dimension different. - // however, by directly producing - // the lines to be printed, i.e. their - // 2d images, we can later do the - // actual output dimension independent - // again + // make up a list of lines by which + // we will construct the triangulation + // + // this part unfortunately is a bit + // dimension dependent, so we have to + // treat every dimension different. + // however, by directly producing + // the lines to be printed, i.e. their + // 2d images, we can later do the + // actual output dimension independent + // again LineList line_list; switch (dim) - { - case 1: - { - Assert(false, ExcInternalError()); - break; - }; - - case 2: - { - typename dealii::Triangulation::active_cell_iterator - cell=tria.begin_active(), - endc=tria.end(); - - for (; cell!=endc; ++cell) - for (unsigned int line_no=0; - line_no::lines_per_cell; ++line_no) - { - typename dealii::Triangulation::line_iterator - line=cell->line(line_no); - - // first treat all - // interior lines and - // make up a list of - // them. if curved - // lines shall not be - // supported (i.e. no - // mapping is - // provided), then also - // treat all other - // lines - if (!line->has_children() && - (mapping==0 || !line->at_boundary())) - // one would expect - // make_pair(line->vertex(0), - // line->vertex(1)) - // here, but that is - // not dimension - // independent, since - // vertex(i) is - // Point, but we - // want a Point<2>. - // in fact, whenever - // we're here, the - // vertex is a - // Point, but - // the compiler does - // not know - // this. hopefully, - // the compiler will - // optimize away this - // little kludge - line_list.push_back (LineEntry(Point<2>(line->vertex(0)(0), - line->vertex(0)(1)), - Point<2>(line->vertex(1)(0), - line->vertex(1)(1)), - line->user_flag_set(), - cell->level())); - } - - // next if we are to treat - // curved boundaries - // specially, then add lines - // to the list consisting of - // pieces of the boundary - // lines - if (mapping!=0) - { - // to do so, first - // generate a sequence of - // points on a face and - // project them onto the - // faces of a unit cell - std::vector > boundary_points (n_points); - - for (unsigned int i=0; i quadrature (boundary_points); - Quadrature q_projector (QProjector::project_to_all_faces(quadrature)); - - // next loop over all - // boundary faces and - // generate the info from - // them - typename dealii::Triangulation::active_cell_iterator - cell=tria.begin_active (); - const typename dealii::Triangulation::active_cell_iterator - end=tria.end (); - for (; cell!=end; ++cell) - for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) - { - const typename dealii::Triangulation::face_iterator - face = cell->face(face_no); - - if (face->at_boundary()) - { - Point p0_dim(face->vertex(0)); - Point<2> p0 (p0_dim(0), p0_dim(1)); - - // loop over - // all pieces - // of the line - // and generate - // line-lets - const unsigned int offset=face_no*n_points; - for (unsigned int i=0; i p1_dim (mapping->transform_unit_to_real_cell - (cell, q_projector.point(offset+i))); - const Point<2> p1 (p1_dim(0), p1_dim(1)); - - line_list.push_back (LineEntry(p0, p1, - face->user_flag_set(), - cell->level() )); - p0=p1; - } - - // generate last piece - const Point p1_dim (face->vertex(1)); - const Point<2> p1 (p1_dim(0), p1_dim(1)); - line_list.push_back (LineEntry(p0, p1, - face->user_flag_set(), - cell->level())); - }; - }; - }; - - break; - }; - - case 3: - { - // curved boundary output - // presently not supported - Assert (mapping == 0, ExcNotImplemented()); - - typename dealii::Triangulation::active_cell_iterator - cell=tria.begin_active(), - endc=tria.end(); - - // loop over all lines and compute their - // projection on the plane perpendicular - // to the direction of sight - - // direction of view equals the unit - // vector of the position of the - // spectator to the origin. - // - // we chose here the viewpoint as in - // gnuplot as default. - // - //TODO:[WB] Fix a potential problem with viewing angles in 3d Eps GridOut - // note: the following might be wrong - // if one of the base vectors below - // is in direction of the viewer, but - // I am too tired at present to fix - // this - const double pi = numbers::PI; - const double z_angle = eps_flags_3.azimut_angle; - const double turn_angle = eps_flags_3.turn_angle; - const Point view_direction(-std::sin(z_angle * 2.*pi / 360.) * std::sin(turn_angle * 2.*pi / 360.), - +std::sin(z_angle * 2.*pi / 360.) * std::cos(turn_angle * 2.*pi / 360.), - -std::cos(z_angle * 2.*pi / 360.)); - - // decide about the two unit vectors - // in this plane. we chose the first one - // to be the projection of the z-axis - // to this plane - const Point vector1 - = Point(0,0,1) - ((Point(0,0,1) * view_direction) * view_direction); - const Point unit_vector1 = vector1 / std::sqrt(vector1.square()); - - // now the third vector is fixed. we - // chose the projection of a more or - // less arbitrary vector to the plane - // perpendicular to the first one - const Point vector2 - = (Point(1,0,0) - - ((Point(1,0,0) * view_direction) * view_direction) - - ((Point(1,0,0) * unit_vector1) * unit_vector1)); - const Point unit_vector2 = vector2 / std::sqrt(vector2.square()); - - - for (; cell!=endc; ++cell) - for (unsigned int line_no=0; - line_no::lines_per_cell; ++line_no) - { - typename dealii::Triangulation::line_iterator - line=cell->line(line_no); - line_list.push_back (LineEntry(Point<2>(line->vertex(0) * unit_vector2, - line->vertex(0) * unit_vector1), - Point<2>(line->vertex(1) * unit_vector2, - line->vertex(1) * unit_vector1), - line->user_flag_set(), - cell->level())); - } - - break; - } - - default: - Assert (false, ExcNotImplemented()); - } - - - - // find out minimum and maximum x and - // y coordinates to compute offsets - // and scaling factors + { + case 1: + { + Assert(false, ExcInternalError()); + break; + }; + + case 2: + { + typename dealii::Triangulation::active_cell_iterator + cell=tria.begin_active(), + endc=tria.end(); + + for (; cell!=endc; ++cell) + for (unsigned int line_no=0; + line_no::lines_per_cell; ++line_no) + { + typename dealii::Triangulation::line_iterator + line=cell->line(line_no); + + // first treat all + // interior lines and + // make up a list of + // them. if curved + // lines shall not be + // supported (i.e. no + // mapping is + // provided), then also + // treat all other + // lines + if (!line->has_children() && + (mapping==0 || !line->at_boundary())) + // one would expect + // make_pair(line->vertex(0), + // line->vertex(1)) + // here, but that is + // not dimension + // independent, since + // vertex(i) is + // Point, but we + // want a Point<2>. + // in fact, whenever + // we're here, the + // vertex is a + // Point, but + // the compiler does + // not know + // this. hopefully, + // the compiler will + // optimize away this + // little kludge + line_list.push_back (LineEntry(Point<2>(line->vertex(0)(0), + line->vertex(0)(1)), + Point<2>(line->vertex(1)(0), + line->vertex(1)(1)), + line->user_flag_set(), + cell->level())); + } + + // next if we are to treat + // curved boundaries + // specially, then add lines + // to the list consisting of + // pieces of the boundary + // lines + if (mapping!=0) + { + // to do so, first + // generate a sequence of + // points on a face and + // project them onto the + // faces of a unit cell + std::vector > boundary_points (n_points); + + for (unsigned int i=0; i quadrature (boundary_points); + Quadrature q_projector (QProjector::project_to_all_faces(quadrature)); + + // next loop over all + // boundary faces and + // generate the info from + // them + typename dealii::Triangulation::active_cell_iterator + cell=tria.begin_active (); + const typename dealii::Triangulation::active_cell_iterator + end=tria.end (); + for (; cell!=end; ++cell) + for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) + { + const typename dealii::Triangulation::face_iterator + face = cell->face(face_no); + + if (face->at_boundary()) + { + Point p0_dim(face->vertex(0)); + Point<2> p0 (p0_dim(0), p0_dim(1)); + + // loop over + // all pieces + // of the line + // and generate + // line-lets + const unsigned int offset=face_no*n_points; + for (unsigned int i=0; i p1_dim (mapping->transform_unit_to_real_cell + (cell, q_projector.point(offset+i))); + const Point<2> p1 (p1_dim(0), p1_dim(1)); + + line_list.push_back (LineEntry(p0, p1, + face->user_flag_set(), + cell->level() )); + p0=p1; + } + + // generate last piece + const Point p1_dim (face->vertex(1)); + const Point<2> p1 (p1_dim(0), p1_dim(1)); + line_list.push_back (LineEntry(p0, p1, + face->user_flag_set(), + cell->level())); + }; + }; + }; + + break; + }; + + case 3: + { + // curved boundary output + // presently not supported + Assert (mapping == 0, ExcNotImplemented()); + + typename dealii::Triangulation::active_cell_iterator + cell=tria.begin_active(), + endc=tria.end(); + + // loop over all lines and compute their + // projection on the plane perpendicular + // to the direction of sight + + // direction of view equals the unit + // vector of the position of the + // spectator to the origin. + // + // we chose here the viewpoint as in + // gnuplot as default. + // + //TODO:[WB] Fix a potential problem with viewing angles in 3d Eps GridOut + // note: the following might be wrong + // if one of the base vectors below + // is in direction of the viewer, but + // I am too tired at present to fix + // this + const double pi = numbers::PI; + const double z_angle = eps_flags_3.azimut_angle; + const double turn_angle = eps_flags_3.turn_angle; + const Point view_direction(-std::sin(z_angle * 2.*pi / 360.) * std::sin(turn_angle * 2.*pi / 360.), + +std::sin(z_angle * 2.*pi / 360.) * std::cos(turn_angle * 2.*pi / 360.), + -std::cos(z_angle * 2.*pi / 360.)); + + // decide about the two unit vectors + // in this plane. we chose the first one + // to be the projection of the z-axis + // to this plane + const Point vector1 + = Point(0,0,1) - ((Point(0,0,1) * view_direction) * view_direction); + const Point unit_vector1 = vector1 / std::sqrt(vector1.square()); + + // now the third vector is fixed. we + // chose the projection of a more or + // less arbitrary vector to the plane + // perpendicular to the first one + const Point vector2 + = (Point(1,0,0) + - ((Point(1,0,0) * view_direction) * view_direction) + - ((Point(1,0,0) * unit_vector1) * unit_vector1)); + const Point unit_vector2 = vector2 / std::sqrt(vector2.square()); + + + for (; cell!=endc; ++cell) + for (unsigned int line_no=0; + line_no::lines_per_cell; ++line_no) + { + typename dealii::Triangulation::line_iterator + line=cell->line(line_no); + line_list.push_back (LineEntry(Point<2>(line->vertex(0) * unit_vector2, + line->vertex(0) * unit_vector1), + Point<2>(line->vertex(1) * unit_vector2, + line->vertex(1) * unit_vector1), + line->user_flag_set(), + cell->level())); + } + + break; + } + + default: + Assert (false, ExcNotImplemented()); + } + + + + // find out minimum and maximum x and + // y coordinates to compute offsets + // and scaling factors double x_min = tria.begin_active_line()->vertex(0)(0); double x_max = x_min; double y_min = tria.begin_active_line()->vertex(0)(1); @@ -2225,202 +2225,202 @@ namespace internal unsigned int max_level = line_list.begin()->level; for (LineList::const_iterator line=line_list.begin(); - line!=line_list.end(); ++line) - { - x_min = std::min (x_min, line->first(0)); - x_min = std::min (x_min, line->second(0)); + line!=line_list.end(); ++line) + { + x_min = std::min (x_min, line->first(0)); + x_min = std::min (x_min, line->second(0)); - x_max = std::max (x_max, line->first(0)); - x_max = std::max (x_max, line->second(0)); + x_max = std::max (x_max, line->first(0)); + x_max = std::max (x_max, line->second(0)); - y_min = std::min (y_min, line->first(1)); - y_min = std::min (y_min, line->second(1)); + y_min = std::min (y_min, line->first(1)); + y_min = std::min (y_min, line->second(1)); - y_max = std::max (y_max, line->first(1)); - y_max = std::max (y_max, line->second(1)); + y_max = std::max (y_max, line->first(1)); + y_max = std::max (y_max, line->second(1)); - max_level = std::max (max_level, line->level); - }; + max_level = std::max (max_level, line->level); + }; - // scale in x-direction such that - // in the output 0 <= x <= 300. - // don't scale in y-direction to - // preserve the shape of the - // triangulation + // scale in x-direction such that + // in the output 0 <= x <= 300. + // don't scale in y-direction to + // preserve the shape of the + // triangulation const double scale = (eps_flags_base.size / - (eps_flags_base.size_type==GridOutFlags::EpsFlagsBase::width ? - x_max - x_min : - y_min - y_max)); + (eps_flags_base.size_type==GridOutFlags::EpsFlagsBase::width ? + x_max - x_min : + y_min - y_max)); - // now write preamble + // now write preamble if (true) - { - // block this to have local - // variables destroyed after - // use - std::time_t time1= std::time (0); - std::tm *time = std::localtime(&time1); - out << "%!PS-Adobe-2.0 EPSF-1.2" << '\n' - << "%%Title: deal.II Output" << '\n' - << "%%Creator: the deal.II library" << '\n' - << "%%Creation Date: " - << time->tm_year+1900 << "/" - << time->tm_mon+1 << "/" - << time->tm_mday << " - " - << time->tm_hour << ":" - << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << '\n' - << "%%BoundingBox: " - // lower left corner - << "0 0 " - // upper right corner - << static_cast(std::floor(( (x_max-x_min) * scale )+1)) - << ' ' - << static_cast(std::floor(( (y_max-y_min) * scale )+1)) - << '\n'; - - // define some abbreviations to keep - // the output small: - // m=move turtle to - // x=execute line stroke - // b=black pen - // r=red pen - out << "/m {moveto} bind def" << '\n' - << "/x {lineto stroke} bind def" << '\n' - << "/b {0 0 0 setrgbcolor} def" << '\n' - << "/r {1 0 0 setrgbcolor} def" << '\n'; - - // calculate colors for level - // coloring; level 0 is black, - // other levels are blue - // ... red - if (eps_flags_base.color_lines_level) - out << "/l { neg " - << (max_level) - << " add " - << (0.66666/std::max(1U,(max_level-1))) - << " mul 1 0.8 sethsbcolor} def" << '\n'; - - // in 2d, we can also plot cell - // and vertex numbers, but this - // requires a somewhat more - // lengthy preamble. please - // don't ask me what most of - // this means, it is reverse - // engineered from what GNUPLOT - // uses in its output - if ((dim == 2) && (eps_flags_2.write_cell_numbers || - eps_flags_2.write_vertex_numbers)) - { - out << ("/R {rmoveto} bind def\n" - "/Symbol-Oblique /Symbol findfont [1 0 .167 1 0 0] makefont\n" - "dup length dict begin {1 index /FID eq {pop pop} {def} ifelse} forall\n" - "currentdict end definefont\n" - "/MFshow {{dup dup 0 get findfont exch 1 get scalefont setfont\n" - "[ currentpoint ] exch dup 2 get 0 exch rmoveto dup dup 5 get exch 4 get\n" - "{show} {stringwidth pop 0 rmoveto}ifelse dup 3 get\n" - "{2 get neg 0 exch rmoveto pop} {pop aload pop moveto}ifelse} forall} bind def\n" - "/MFwidth {0 exch {dup 3 get{dup dup 0 get findfont exch 1 get scalefont setfont\n" - "5 get stringwidth pop add}\n" - "{pop} ifelse} forall} bind def\n" - "/MCshow { currentpoint stroke m\n" - "exch dup MFwidth -2 div 3 -1 roll R MFshow } def\n") - << '\n'; - }; - - out << "%%EndProlog" << '\n' - << '\n'; - - // set fine lines - out << eps_flags_base.line_width << " setlinewidth" << '\n'; - }; - - // now write the lines + { + // block this to have local + // variables destroyed after + // use + std::time_t time1= std::time (0); + std::tm *time = std::localtime(&time1); + out << "%!PS-Adobe-2.0 EPSF-1.2" << '\n' + << "%%Title: deal.II Output" << '\n' + << "%%Creator: the deal.II library" << '\n' + << "%%Creation Date: " + << time->tm_year+1900 << "/" + << time->tm_mon+1 << "/" + << time->tm_mday << " - " + << time->tm_hour << ":" + << std::setw(2) << time->tm_min << ":" + << std::setw(2) << time->tm_sec << '\n' + << "%%BoundingBox: " + // lower left corner + << "0 0 " + // upper right corner + << static_cast(std::floor(( (x_max-x_min) * scale )+1)) + << ' ' + << static_cast(std::floor(( (y_max-y_min) * scale )+1)) + << '\n'; + + // define some abbreviations to keep + // the output small: + // m=move turtle to + // x=execute line stroke + // b=black pen + // r=red pen + out << "/m {moveto} bind def" << '\n' + << "/x {lineto stroke} bind def" << '\n' + << "/b {0 0 0 setrgbcolor} def" << '\n' + << "/r {1 0 0 setrgbcolor} def" << '\n'; + + // calculate colors for level + // coloring; level 0 is black, + // other levels are blue + // ... red + if (eps_flags_base.color_lines_level) + out << "/l { neg " + << (max_level) + << " add " + << (0.66666/std::max(1U,(max_level-1))) + << " mul 1 0.8 sethsbcolor} def" << '\n'; + + // in 2d, we can also plot cell + // and vertex numbers, but this + // requires a somewhat more + // lengthy preamble. please + // don't ask me what most of + // this means, it is reverse + // engineered from what GNUPLOT + // uses in its output + if ((dim == 2) && (eps_flags_2.write_cell_numbers || + eps_flags_2.write_vertex_numbers)) + { + out << ("/R {rmoveto} bind def\n" + "/Symbol-Oblique /Symbol findfont [1 0 .167 1 0 0] makefont\n" + "dup length dict begin {1 index /FID eq {pop pop} {def} ifelse} forall\n" + "currentdict end definefont\n" + "/MFshow {{dup dup 0 get findfont exch 1 get scalefont setfont\n" + "[ currentpoint ] exch dup 2 get 0 exch rmoveto dup dup 5 get exch 4 get\n" + "{show} {stringwidth pop 0 rmoveto}ifelse dup 3 get\n" + "{2 get neg 0 exch rmoveto pop} {pop aload pop moveto}ifelse} forall} bind def\n" + "/MFwidth {0 exch {dup 3 get{dup dup 0 get findfont exch 1 get scalefont setfont\n" + "5 get stringwidth pop add}\n" + "{pop} ifelse} forall} bind def\n" + "/MCshow { currentpoint stroke m\n" + "exch dup MFwidth -2 div 3 -1 roll R MFshow } def\n") + << '\n'; + }; + + out << "%%EndProlog" << '\n' + << '\n'; + + // set fine lines + out << eps_flags_base.line_width << " setlinewidth" << '\n'; + }; + + // now write the lines const Point<2> offset(x_min, y_min); for (LineList::const_iterator line=line_list.begin(); - line!=line_list.end(); ++line) - if (eps_flags_base.color_lines_level && (line->level > 0)) - // lines colored according to - // refinement level, - // contributed by J�rg - // R. Weimar - out << line->level - << " l " - << (line->first - offset) * scale << " m " - << (line->second - offset) * scale << " x" << '\n'; - else - out << ((line->colorize && eps_flags_base.color_lines_on_user_flag) ? "r " : "b ") - << (line->first - offset) * scale << " m " - << (line->second - offset) * scale << " x" << '\n'; - - // finally write the cell numbers - // in 2d, if that is desired + line!=line_list.end(); ++line) + if (eps_flags_base.color_lines_level && (line->level > 0)) + // lines colored according to + // refinement level, + // contributed by J�rg + // R. Weimar + out << line->level + << " l " + << (line->first - offset) * scale << " m " + << (line->second - offset) * scale << " x" << '\n'; + else + out << ((line->colorize && eps_flags_base.color_lines_on_user_flag) ? "r " : "b ") + << (line->first - offset) * scale << " m " + << (line->second - offset) * scale << " x" << '\n'; + + // finally write the cell numbers + // in 2d, if that is desired if ((dim == 2) && (eps_flags_2.write_cell_numbers == true)) - { - out << "(Helvetica) findfont 140 scalefont setfont" - << '\n'; - - typename dealii::Triangulation::active_cell_iterator - cell = tria.begin_active (), - endc = tria.end (); - for (; cell!=endc; ++cell) - { - out << (cell->center()(0)-offset(0))*scale << ' ' - << (cell->center()(1)-offset(1))*scale - << " m" << '\n' - << "[ [(Helvetica) 12.0 0.0 true true ("; - if (eps_flags_2.write_cell_number_level) - out << cell; - else - out << cell->index(); - - out << ")] " - << "] -6 MCshow" - << '\n'; - }; - }; - - // and the vertex numbers + { + out << "(Helvetica) findfont 140 scalefont setfont" + << '\n'; + + typename dealii::Triangulation::active_cell_iterator + cell = tria.begin_active (), + endc = tria.end (); + for (; cell!=endc; ++cell) + { + out << (cell->center()(0)-offset(0))*scale << ' ' + << (cell->center()(1)-offset(1))*scale + << " m" << '\n' + << "[ [(Helvetica) 12.0 0.0 true true ("; + if (eps_flags_2.write_cell_number_level) + out << cell; + else + out << cell->index(); + + out << ")] " + << "] -6 MCshow" + << '\n'; + }; + }; + + // and the vertex numbers if ((dim == 2) && (eps_flags_2.write_vertex_numbers == true)) - { - out << "(Helvetica) findfont 140 scalefont setfont" - << '\n'; - - // have a list of those - // vertices which we have - // already tracked, to avoid - // doing this multiply - std::set treated_vertices; - typename dealii::Triangulation::active_cell_iterator - cell = tria.begin_active (), - endc = tria.end (); - for (; cell!=endc; ++cell) - for (unsigned int vertex=0; - vertex::vertices_per_cell; - ++vertex) - if (treated_vertices.find(cell->vertex_index(vertex)) - == - treated_vertices.end()) - { - treated_vertices.insert (cell->vertex_index(vertex)); - - out << (cell->vertex(vertex)(0)-offset(0))*scale << ' ' - << (cell->vertex(vertex)(1)-offset(1))*scale - << " m" << '\n' - << "[ [(Helvetica) 10.0 0.0 true true (" - << cell->vertex_index(vertex) - << ")] " - << "] -6 MCshow" - << '\n'; - }; - }; + { + out << "(Helvetica) findfont 140 scalefont setfont" + << '\n'; + + // have a list of those + // vertices which we have + // already tracked, to avoid + // doing this multiply + std::set treated_vertices; + typename dealii::Triangulation::active_cell_iterator + cell = tria.begin_active (), + endc = tria.end (); + for (; cell!=endc; ++cell) + for (unsigned int vertex=0; + vertex::vertices_per_cell; + ++vertex) + if (treated_vertices.find(cell->vertex_index(vertex)) + == + treated_vertices.end()) + { + treated_vertices.insert (cell->vertex_index(vertex)); + + out << (cell->vertex(vertex)(0)-offset(0))*scale << ' ' + << (cell->vertex(vertex)(1)-offset(1))*scale + << " m" << '\n' + << "[ [(Helvetica) 10.0 0.0 true true (" + << cell->vertex_index(vertex) + << ")] " + << "] -6 MCshow" + << '\n'; + }; + }; out << "showpage" << '\n'; - // make sure everything now gets to - // disk + // make sure everything now gets to + // disk out.flush (); AssertThrow (out, ExcIO()); @@ -2431,48 +2431,48 @@ namespace internal template void GridOut::write_eps (const Triangulation &tria, - std::ostream &out, - const Mapping *mapping) const + std::ostream &out, + const Mapping *mapping) const { internal::write_eps (tria, out, mapping, - eps_flags_2, eps_flags_3); + eps_flags_2, eps_flags_3); } template void GridOut::write (const Triangulation &tria, - std::ostream &out, - const OutputFormat output_format, - const Mapping *mapping) const + std::ostream &out, + const OutputFormat output_format, + const Mapping *mapping) const { switch (output_format) { case none: - return; + return; case dx: - write_dx (tria, out); - return; + write_dx (tria, out); + return; case ucd: - write_ucd (tria, out); - return; + write_ucd (tria, out); + return; case gnuplot: - write_gnuplot (tria, out, mapping); - return; + write_gnuplot (tria, out, mapping); + return; case eps: - write_eps (tria, out, mapping); - return; + write_eps (tria, out, mapping); + return; case xfig: - write_xfig (tria, out, mapping); - return; + write_xfig (tria, out, mapping); + return; case msh: - write_msh (tria, out); - return; + write_msh (tria, out); + return; } Assert (false, ExcInternalError()); diff --git a/deal.II/source/grid/grid_refinement.cc b/deal.II/source/grid/grid_refinement.cc index b484d8ad7b..a6932fa814 100644 --- a/deal.II/source/grid/grid_refinement.cc +++ b/deal.II/source/grid/grid_refinement.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -61,12 +61,12 @@ namespace PetscScalar max_element (const PETScWrappers::Vector &criteria) { - // this is horribly slow (since we have - // to get the array of values from PETSc - // in every iteration), but works + // this is horribly slow (since we have + // to get the array of values from PETSc + // in every iteration), but works PetscScalar m = 0; for (unsigned int i=0; i typename constraint_and_return_value::value, - typename Vector::value_type>::type + typename Vector::value_type>::type min_element (const Vector &criteria) { return internal::min_element (criteria); @@ -117,7 +117,7 @@ namespace template typename constraint_and_return_value::value, - typename Vector::value_type>::type + typename Vector::value_type>::type max_element (const Vector &criteria) { return internal::max_element (criteria); @@ -126,7 +126,7 @@ namespace template typename constraint_and_return_value::value, - typename Vector::value_type>::type + typename Vector::value_type>::type min_element (const Vector &criteria) { typename Vector::value_type t = internal::min_element(criteria.block(0)); @@ -139,7 +139,7 @@ namespace template typename constraint_and_return_value::value, - typename Vector::value_type>::type + typename Vector::value_type>::type max_element (const Vector &criteria) { typename Vector::value_type t = internal::max_element(criteria.block(0)); @@ -154,21 +154,21 @@ namespace namespace { - /** - * Sorts the vector @p ind as an - * index vector of @p a in - * increasing order. This - * implementation of quicksort - * seems to be faster than the - * STL version and is needed in - * @p refine_and_coarsen_optimize - */ + /** + * Sorts the vector @p ind as an + * index vector of @p a in + * increasing order. This + * implementation of quicksort + * seems to be faster than the + * STL version and is needed in + * @p refine_and_coarsen_optimize + */ template void qsort_index (const Vector &a, - std::vector &ind, - int l, - int r) + std::vector &ind, + int l, + int r) { int i,j; typename Vector::value_type v; @@ -181,21 +181,21 @@ namespace j = r; do { - do - { - ++i; - } - while ((a(ind[i])>v) && (i0)); - - if (iv) && (i0)); + + if (i void GridRefinement::refine (Triangulation &tria, - const Vector &criteria, - const double threshold) + const Vector &criteria, + const double threshold) { Assert (criteria.size() == tria.n_active_cells(), - ExcDimensionMismatch(criteria.size(), tria.n_active_cells())); + ExcDimensionMismatch(criteria.size(), tria.n_active_cells())); Assert (criteria.is_non_negative (), ExcNegativeCriteria()); - // when all indicators are zero we - // do not need to refine but only - // to coarsen + // when all indicators are zero we + // do not need to refine but only + // to coarsen if (criteria.all_zero()) return; @@ -227,16 +227,16 @@ void GridRefinement::refine (Triangulation &tria, //TODO: This is undocumented, looks fishy and seems unnecessary double new_threshold=threshold; - // when threshold==0 find the - // smallest value in criteria - // greater 0 + // when threshold==0 find the + // smallest value in criteria + // greater 0 if (new_threshold==0) { new_threshold = criteria(0); for (unsigned int index=1; index0 - && (criteria(index)0 + && (criteria(index) &tria, template void GridRefinement::coarsen (Triangulation &tria, - const Vector &criteria, - const double threshold) + const Vector &criteria, + const double threshold) { Assert (criteria.size() == tria.n_active_cells(), - ExcDimensionMismatch(criteria.size(), tria.n_active_cells())); + ExcDimensionMismatch(criteria.size(), tria.n_active_cells())); Assert (criteria.is_non_negative (), ExcNegativeCriteria()); typename Triangulation::active_cell_iterator cell = tria.begin_active(); @@ -269,13 +269,13 @@ void GridRefinement::coarsen (Triangulation &tria, template void GridRefinement::refine_and_coarsen_fixed_number (Triangulation &tria, - const Vector &criteria, - const double top_fraction, - const double bottom_fraction, - const unsigned int max_n_cells) + const Vector &criteria, + const double top_fraction, + const double bottom_fraction, + const unsigned int max_n_cells) { - // correct number of cells is - // checked in @p{refine} + // correct number of cells is + // checked in @p{refine} Assert ((top_fraction>=0) && (top_fraction<=1), ExcInvalidParameterValue()); Assert ((bottom_fraction>=0) && (bottom_fraction<=1), ExcInvalidParameterValue()); Assert (top_fraction+bottom_fraction <= 1, ExcInvalidParameterValue()); @@ -284,65 +284,65 @@ GridRefinement::refine_and_coarsen_fixed_number (Triangulation &tr int refine_cells = static_cast(top_fraction*criteria.size()); int coarsen_cells = static_cast(bottom_fraction*criteria.size()); - // first we have to see whether we - // currently already exceed the target - // number of cells + // first we have to see whether we + // currently already exceed the target + // number of cells if (tria.n_active_cells() >= max_n_cells) { - // if yes, then we need to stop - // refining cells and instead try to - // only coarsen as many as it would - // take to get to the target - - // as we have no information on cells - // being refined isotropically or - // anisotropically, assume isotropic - // refinement here, though that may - // result in a worse approximation + // if yes, then we need to stop + // refining cells and instead try to + // only coarsen as many as it would + // take to get to the target + + // as we have no information on cells + // being refined isotropically or + // anisotropically, assume isotropic + // refinement here, though that may + // result in a worse approximation refine_cells = 0; coarsen_cells = (tria.n_active_cells() - max_n_cells) * - GeometryInfo::max_children_per_cell / - (GeometryInfo::max_children_per_cell - 1); + GeometryInfo::max_children_per_cell / + (GeometryInfo::max_children_per_cell - 1); } - // otherwise, see if we would exceed the - // maximum desired number of cells with the - // number of cells that are likely going to - // result from refinement. here, each cell - // to be refined is replaced by - // C=GeometryInfo::max_children_per_cell - // new cells, i.e. there will be C-1 more - // cells than before. similarly, C cells - // will be replaced by 1 - - // again, this is true for isotropically - // refined cells. we take this as an - // approximation of a mixed refinement. + // otherwise, see if we would exceed the + // maximum desired number of cells with the + // number of cells that are likely going to + // result from refinement. here, each cell + // to be refined is replaced by + // C=GeometryInfo::max_children_per_cell + // new cells, i.e. there will be C-1 more + // cells than before. similarly, C cells + // will be replaced by 1 + + // again, this is true for isotropically + // refined cells. we take this as an + // approximation of a mixed refinement. else if (static_cast - (tria.n_active_cells() - + refine_cells * (GeometryInfo::max_children_per_cell - 1) - - (coarsen_cells * - (GeometryInfo::max_children_per_cell - 1) / - GeometryInfo::max_children_per_cell)) - > - max_n_cells) + (tria.n_active_cells() + + refine_cells * (GeometryInfo::max_children_per_cell - 1) + - (coarsen_cells * + (GeometryInfo::max_children_per_cell - 1) / + GeometryInfo::max_children_per_cell)) + > + max_n_cells) { - // we have to adjust the - // fractions. assume we want - // alpha*refine_fraction and - // alpha*coarsen_fraction as new - // fractions and the resulting number - // of cells to be equal to - // max_n_cells. this leads to the - // following equation for lambda + // we have to adjust the + // fractions. assume we want + // alpha*refine_fraction and + // alpha*coarsen_fraction as new + // fractions and the resulting number + // of cells to be equal to + // max_n_cells. this leads to the + // following equation for lambda const double alpha - = - 1. * - (max_n_cells - tria.n_active_cells()) - / - (refine_cells * (GeometryInfo::max_children_per_cell - 1) - - (coarsen_cells * - (GeometryInfo::max_children_per_cell - 1) / - GeometryInfo::max_children_per_cell)); + = + 1. * + (max_n_cells - tria.n_active_cells()) + / + (refine_cells * (GeometryInfo::max_children_per_cell - 1) + - (coarsen_cells * + (GeometryInfo::max_children_per_cell - 1) / + GeometryInfo::max_children_per_cell)); refine_cells = static_cast (refine_cells * alpha); coarsen_cells = static_cast (coarsen_cells * alpha); } @@ -351,21 +351,21 @@ GridRefinement::refine_and_coarsen_fixed_number (Triangulation &tr { dealii::Vector tmp (criteria); if (refine_cells) - { - std::nth_element (tmp.begin(), tmp.begin()+refine_cells, - tmp.end(), - std::greater()); - refine (tria, criteria, *(tmp.begin() + refine_cells)); - } + { + std::nth_element (tmp.begin(), tmp.begin()+refine_cells, + tmp.end(), + std::greater()); + refine (tria, criteria, *(tmp.begin() + refine_cells)); + } if (coarsen_cells) - { - std::nth_element (tmp.begin(), tmp.begin()+tmp.size()-coarsen_cells, - tmp.end(), - std::greater()); - coarsen (tria, criteria, - *(tmp.begin() + tmp.size() - coarsen_cells)); - } + { + std::nth_element (tmp.begin(), tmp.begin()+tmp.size()-coarsen_cells, + tmp.end(), + std::greater()); + coarsen (tria, criteria, + *(tmp.begin() + tmp.size() - coarsen_cells)); + } } } @@ -374,31 +374,31 @@ GridRefinement::refine_and_coarsen_fixed_number (Triangulation &tr template void GridRefinement::refine_and_coarsen_fixed_fraction (Triangulation &tria, - const Vector &criteria, - const double top_fraction, - const double bottom_fraction, - const unsigned int max_n_cells) + const Vector &criteria, + const double top_fraction, + const double bottom_fraction, + const unsigned int max_n_cells) { - // correct number of cells is - // checked in @p{refine} + // correct number of cells is + // checked in @p{refine} Assert ((top_fraction>=0) && (top_fraction<=1), ExcInvalidParameterValue()); Assert ((bottom_fraction>=0) && (bottom_fraction<=1), ExcInvalidParameterValue()); Assert (top_fraction+bottom_fraction <= 1, ExcInvalidParameterValue()); Assert (criteria.is_non_negative (), ExcNegativeCriteria()); - // let tmp be the cellwise square of the - // error, which is what we have to sum - // up and compare with - // @p{fraction_of_error*total_error}. + // let tmp be the cellwise square of the + // error, which is what we have to sum + // up and compare with + // @p{fraction_of_error*total_error}. dealii::Vector tmp; tmp = criteria; const double total_error = tmp.l1_norm(); - // sort the largest criteria to the - // beginning of the vector + // sort the largest criteria to the + // beginning of the vector std::sort (tmp.begin(), tmp.end(), std::greater()); - // compute thresholds + // compute thresholds typename dealii::Vector::const_iterator pp=tmp.begin(); for (double sum=0; @@ -406,8 +406,8 @@ GridRefinement::refine_and_coarsen_fixed_fraction (Triangulation & ++pp) sum += *pp; double top_threshold = ( pp != tmp.begin () ? - (*pp+*(pp-1))/2 : - *pp ); + (*pp+*(pp-1))/2 : + *pp ); typename dealii::Vector::const_iterator qq=(tmp.end()-1); for (double sum=0; @@ -415,75 +415,75 @@ GridRefinement::refine_and_coarsen_fixed_fraction (Triangulation & --qq) sum += *qq; double bottom_threshold = ( qq != (tmp.end()-1) ? - (*qq + *(qq+1))/2 : - 0); - - // we now have an idea how many cells we - // are going to refine and coarsen. we use - // this information to see whether we are - // over the limit and if so use a function - // that knows how to deal with this - // situation - - // note, that at this point, we have no - // information about anisotropically refined - // cells, thus use the situation of purely - // isotropic refinement as guess for a mixed - // refinemnt as well. + (*qq + *(qq+1))/2 : + 0); + + // we now have an idea how many cells we + // are going to refine and coarsen. we use + // this information to see whether we are + // over the limit and if so use a function + // that knows how to deal with this + // situation + + // note, that at this point, we have no + // information about anisotropically refined + // cells, thus use the situation of purely + // isotropic refinement as guess for a mixed + // refinemnt as well. { const unsigned int refine_cells = pp - tmp.begin(), - coarsen_cells = tmp.end() - qq; + coarsen_cells = tmp.end() - qq; if (static_cast - (tria.n_active_cells() - + refine_cells * (GeometryInfo::max_children_per_cell - 1) - - (coarsen_cells * - (GeometryInfo::max_children_per_cell - 1) / - GeometryInfo::max_children_per_cell)) - > - max_n_cells) + (tria.n_active_cells() + + refine_cells * (GeometryInfo::max_children_per_cell - 1) + - (coarsen_cells * + (GeometryInfo::max_children_per_cell - 1) / + GeometryInfo::max_children_per_cell)) + > + max_n_cells) { - refine_and_coarsen_fixed_number (tria, - criteria, - 1.*refine_cells/criteria.size(), - 1.*coarsen_cells/criteria.size(), - max_n_cells); - return; + refine_and_coarsen_fixed_number (tria, + criteria, + 1.*refine_cells/criteria.size(), + 1.*coarsen_cells/criteria.size(), + max_n_cells); + return; } } - // in some rare cases it may happen that - // both thresholds are the same (e.g. if - // there are many cells with the same - // error indicator). That would mean that - // all cells will be flagged for - // refinement or coarsening, but some will - // be flagged for both, namely those for - // which the indicator equals the - // thresholds. This is forbidden, however. - // - // In some rare cases with very few cells - // we also could get integer round off - // errors and get problems with - // the top and bottom fractions. - // - // In these case we arbitrarily reduce the - // bottom threshold by one permille below - // the top threshold - // - // Finally, in some cases - // (especially involving symmetric - // solutions) there are many cells - // with the same error indicator - // values. if there are many with - // indicator equal to the top - // threshold, no refinement will - // take place below; to avoid this - // case, we also lower the top - // threshold if it equals the - // largest indicator and the - // top_fraction!=1 + // in some rare cases it may happen that + // both thresholds are the same (e.g. if + // there are many cells with the same + // error indicator). That would mean that + // all cells will be flagged for + // refinement or coarsening, but some will + // be flagged for both, namely those for + // which the indicator equals the + // thresholds. This is forbidden, however. + // + // In some rare cases with very few cells + // we also could get integer round off + // errors and get problems with + // the top and bottom fractions. + // + // In these case we arbitrarily reduce the + // bottom threshold by one permille below + // the top threshold + // + // Finally, in some cases + // (especially involving symmetric + // solutions) there are many cells + // with the same error indicator + // values. if there are many with + // indicator equal to the top + // threshold, no refinement will + // take place below; to avoid this + // case, we also lower the top + // threshold if it equals the + // largest indicator and the + // top_fraction!=1 if ((top_threshold == max_element(criteria)) && (top_fraction != 1)) top_threshold *= 0.999; @@ -491,7 +491,7 @@ GridRefinement::refine_and_coarsen_fixed_fraction (Triangulation & if (bottom_threshold>=top_threshold) bottom_threshold = 0.999*top_threshold; - // actually flag cells + // actually flag cells if (top_threshold < max_element(criteria)) refine (tria, criteria, top_threshold); @@ -504,15 +504,15 @@ GridRefinement::refine_and_coarsen_fixed_fraction (Triangulation & template void GridRefinement::refine_and_coarsen_optimize (Triangulation &tria, - const Vector &criteria, - const unsigned int order) + const Vector &criteria, + const unsigned int order) { Assert (criteria.size() == tria.n_active_cells(), - ExcDimensionMismatch(criteria.size(), tria.n_active_cells())); + ExcDimensionMismatch(criteria.size(), tria.n_active_cells())); Assert (criteria.is_non_negative (), ExcNegativeCriteria()); - // get an increasing order on - // the error indicator + // get an increasing order on + // the error indicator std::vector tmp(criteria.size()); for (unsigned int i=0;i &tria, unsigned int N = criteria.size(); unsigned int M = 0; - // The first M cells are refined - // to minimize the expected error - // multiplied with the expected - // number of cells to the power of - // 2 * expected order of the finite - // element space divided by the dimension - // of the discretized space. - // We assume that the error is - // decreased by (1-2^(-order)) a_K if the cell - // K with error indicator a_K is - // refined and 'order' ist the expected + // The first M cells are refined + // to minimize the expected error + // multiplied with the expected + // number of cells to the power of + // 2 * expected order of the finite + // element space divided by the dimension + // of the discretized space. + // We assume that the error is + // decreased by (1-2^(-order)) a_K if the cell + // K with error indicator a_K is + // refined and 'order' ist the expected // order of convergence. - // The expected number of cells is - // N+(2^d-1)*M (N is the current number - // of cells) + // The expected number of cells is + // N+(2^d-1)*M (N is the current number + // of cells) double min =std::pow( ((std::pow(2.,dim)-1)*(1.+M)+N),(double) order/dim) * (E-s0); unsigned int minArg = N-1; @@ -549,10 +549,10 @@ GridRefinement::refine_and_coarsen_optimize (Triangulation &tria, s0 += (1-std::pow(2.,-1.*order)) * criteria(tmp[M]); if ( std::pow(((std::pow(2.,dim)-1)*(1+M)+N), (double) order/dim) * (E-s0) <= min) - { - min = std::pow(((std::pow(2.,dim)-1)*(1+M)+N), (double) order/dim) * (E-s0); - minArg = M; - } + { + min = std::pow(((std::pow(2.,dim)-1)*(1+M)+N), (double) order/dim) * (E-s0); + minArg = M; + } } refine(tria,criteria,criteria(tmp[minArg])); } diff --git a/deal.II/source/grid/grid_reordering.cc b/deal.II/source/grid/grid_reordering.cc index c5e29b7a6c..bbda1d4f87 100644 --- a/deal.II/source/grid/grid_reordering.cc +++ b/deal.II/source/grid/grid_reordering.cc @@ -2,7 +2,7 @@ // grid_reordering.cc,v 1.27 2002/05/28 07:43:22 wolf Exp // Version: // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2011 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -29,34 +29,34 @@ template<> void GridReordering<1>::reorder_cells (std::vector > &) { - // there should not be much to do - // in 1d... + // there should not be much to do + // in 1d... } template<> void GridReordering<1>::invert_all_cells_of_negative_grid(const std::vector > &, - std::vector > &) + std::vector > &) { - // nothing to be done in 1d + // nothing to be done in 1d } template<> void GridReordering<1,2>::reorder_cells (std::vector > &) { - // there should not be much to do - // in 1d... + // there should not be much to do + // in 1d... } template<> void GridReordering<1,2>::invert_all_cells_of_negative_grid(const std::vector > &, - std::vector > &) + std::vector > &) { - // nothing to be done in 1d + // nothing to be done in 1d } @@ -107,7 +107,7 @@ namespace internal for (; c != cells.end(); ++c) { // construct the four edges - // in reverse order + // in reverse order const Edge reverse_edges[4] = { Edge (c->vertices[1], c->vertices[0]), Edge (c->vertices[2], @@ -119,21 +119,21 @@ namespace internal // for each of them, check // whether they are already // in the set - if ((edges.find (reverse_edges[0]) != edges.end()) || - (edges.find (reverse_edges[1]) != edges.end()) || - (edges.find (reverse_edges[2]) != edges.end()) || - (edges.find (reverse_edges[3]) != edges.end())) + if ((edges.find (reverse_edges[0]) != edges.end()) || + (edges.find (reverse_edges[1]) != edges.end()) || + (edges.find (reverse_edges[2]) != edges.end()) || + (edges.find (reverse_edges[3]) != edges.end())) return false; // ok, not. insert them - // in the order in which - // we want them + // in the order in which + // we want them // (std::set eliminates // duplicated by itself) for (unsigned int i = 0; i<4; ++i) - { - const Edge e(reverse_edges[i].v1, reverse_edges[i].v0); - edges.insert (e); - } + { + const Edge e(reverse_edges[i].v1, reverse_edges[i].v0); + edges.insert (e); + } // then go on with next // cell } @@ -146,47 +146,47 @@ namespace internal struct MSide::SideRectify : public std::unary_function { - void operator() (MSide &s) const - { - if (s.v0>s.v1) - std::swap (s.v0, s.v1); - } + void operator() (MSide &s) const + { + if (s.v0>s.v1) + std::swap (s.v0, s.v1); + } }; struct MSide::SideSortLess : public std::binary_function { - bool operator()(const MSide &s1, const MSide &s2) const - { - int s1vmin,s1vmax; - int s2vmin,s2vmax; - if (s1.v0s2vmin) - return false; - return s1vmaxs2vmin) + return false; + return s1vmax,int,MSide> { - MSide operator()(const CellData<2>& q, int i) const - { - return quadside(q,i); - } + MSide operator()(const CellData<2>& q, int i) const + { + return quadside(q,i); + } }; MQuad::MQuad (const unsigned int v0, - const unsigned int v1, - const unsigned int v2, - const unsigned int v3, - const unsigned int s0, - const unsigned int s1, - const unsigned int s2, - const unsigned int s3, - const CellData<2> &cd) - : - original_cell_data (cd) + const unsigned int v1, + const unsigned int v2, + const unsigned int v3, + const unsigned int s0, + const unsigned int s1, + const unsigned int s2, + const unsigned int s3, + const CellData<2> &cd) + : + original_cell_data (cd) { v[0] = v0; v[1] = v1; @@ -239,14 +239,14 @@ namespace internal MSide::MSide (const unsigned int initv0, - const unsigned int initv1) - : - v0(initv0), v1(initv1), - Q0(numbers::invalid_unsigned_int), + const unsigned int initv1) + : + v0(initv0), v1(initv1), + Q0(numbers::invalid_unsigned_int), Q1(numbers::invalid_unsigned_int), - lsn0(numbers::invalid_unsigned_int), + lsn0(numbers::invalid_unsigned_int), lsn1(numbers::invalid_unsigned_int), - Oriented(false) + Oriented(false) {} @@ -269,39 +269,39 @@ namespace internal namespace { - /** - * Create an MQuad object from the - * indices of the four vertices by - * looking up the indices of the four - * sides. - */ + /** + * Create an MQuad object from the + * indices of the four vertices by + * looking up the indices of the four + * sides. + */ MQuad build_quad_from_vertices(const CellData<2> &q, - const std::vector &elist) + const std::vector &elist) { - // compute the indices of the four - // sides that bound this quad. note - // that the incoming list elist is - // sorted with regard to the - // MSide::SideSortLess criterion - unsigned int edges[4] = { numbers::invalid_unsigned_int, - numbers::invalid_unsigned_int, - numbers::invalid_unsigned_int, - numbers::invalid_unsigned_int }; - - for (unsigned int i=0; i<4; ++i) - edges[i] = (Utilities::lower_bound (elist.begin(), - elist.end(), - quadside(q,i), - MSide::SideSortLess()) - - - elist.begin()); - - return MQuad(q.vertices[0],q.vertices[1], q.vertices[2], q.vertices[3], - edges[0], edges[1], edges[2], edges[3], - q); + // compute the indices of the four + // sides that bound this quad. note + // that the incoming list elist is + // sorted with regard to the + // MSide::SideSortLess criterion + unsigned int edges[4] = { numbers::invalid_unsigned_int, + numbers::invalid_unsigned_int, + numbers::invalid_unsigned_int, + numbers::invalid_unsigned_int }; + + for (unsigned int i=0; i<4; ++i) + edges[i] = (Utilities::lower_bound (elist.begin(), + elist.end(), + quadside(q,i), + MSide::SideSortLess()) + - + elist.begin()); + + return MQuad(q.vertices[0],q.vertices[1], q.vertices[2], q.vertices[3], + edges[0], edges[1], edges[2], edges[3], + q); } } - + void @@ -316,131 +316,131 @@ namespace internal void GridReordering::build_graph (const std::vector > &inquads) { - //Reserve some space + //Reserve some space sides.reserve(4*inquads.size()); - //Insert all the sides into the side vector + //Insert all the sides into the side vector for (int i = 0;i<4;++i) - { - std::transform(inquads.begin(),inquads.end(), - std::back_inserter(sides), std::bind2nd(QuadSide(),i)); - } + { + std::transform(inquads.begin(),inquads.end(), + std::back_inserter(sides), std::bind2nd(QuadSide(),i)); + } - //Change each edge so that v0(sides).swap(sides); - - // Now assign the correct sides to - // each quads + + // Now assign the correct sides to + // each quads mquads.reserve(inquads.size()); std::transform(inquads.begin(), - inquads.end(), - std::back_inserter(mquads), - std_cxx1x::bind(build_quad_from_vertices, - std_cxx1x::_1, - std_cxx1x::cref(sides)) ); + inquads.end(), + std::back_inserter(mquads), + std_cxx1x::bind(build_quad_from_vertices, + std_cxx1x::_1, + std_cxx1x::cref(sides)) ); - // Assign the quads to their sides also. + // Assign the quads to their sides also. int qctr = 0; for (std::vector::iterator it = mquads.begin(); it != mquads.end(); ++it) - { - for (unsigned int i = 0;i<4;++i) - { - MSide &ss = sides[(*it).side[i]]; - if (ss.Q0 == numbers::invalid_unsigned_int) - { - ss.Q0 = qctr; - ss.lsn0 = i; - } - else if (ss.Q1 == numbers::invalid_unsigned_int) - { - ss.Q1 = qctr; - ss.lsn1 = i; - } - else - AssertThrow (false, ExcInternalError()); - } - qctr++; - } + { + for (unsigned int i = 0;i<4;++i) + { + MSide &ss = sides[(*it).side[i]]; + if (ss.Q0 == numbers::invalid_unsigned_int) + { + ss.Q0 = qctr; + ss.lsn0 = i; + } + else if (ss.Q1 == numbers::invalid_unsigned_int) + { + ss.Q1 = qctr; + ss.lsn1 = i; + } + else + AssertThrow (false, ExcInternalError()); + } + qctr++; + } } void GridReordering::orient() { - // do what the comment in the - // class declaration says + // do what the comment in the + // class declaration says unsigned int qnum = 0; while (get_unoriented_quad(qnum)) - { - unsigned int lsn = 0; - while (get_unoriented_side(qnum,lsn)) - { - orient_side(qnum,lsn); - unsigned int qqnum = qnum; - while (side_hop(qqnum,lsn)) - { - // switch this face - lsn = (lsn+2)%4; - if (!is_oriented_side(qqnum,lsn)) - orient_side(qqnum,lsn); - else - //We've found a - //cycle.. and - //oriented all - //quads in it. - break; - } - } - } + { + unsigned int lsn = 0; + while (get_unoriented_side(qnum,lsn)) + { + orient_side(qnum,lsn); + unsigned int qqnum = qnum; + while (side_hop(qqnum,lsn)) + { + // switch this face + lsn = (lsn+2)%4; + if (!is_oriented_side(qqnum,lsn)) + orient_side(qqnum,lsn); + else + //We've found a + //cycle.. and + //oriented all + //quads in it. + break; + } + } + } } void GridReordering::orient_side(const unsigned int quadnum, - const unsigned int localsidenum) + const unsigned int localsidenum) { MQuad &quad = mquads[quadnum]; int op_side_l = (localsidenum+2)%4; MSide &side = sides[mquads[quadnum].side[localsidenum]]; const MSide &op_side = sides[mquads[quadnum].side[op_side_l]]; - //is the opposite side oriented? + //is the opposite side oriented? if (op_side.Oriented) - { - //YES - Make the orientations match - //Is op side in default orientation? - if (op_side.v0 == quad.v[ConnectGlobals::DefaultOrientation[op_side_l][0]]) - { - //YES - side.v0 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]]; - side.v1 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]]; - } - else - { - //NO, its reversed - side.v0 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]]; - side.v1 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]]; - } - } + { + //YES - Make the orientations match + //Is op side in default orientation? + if (op_side.v0 == quad.v[ConnectGlobals::DefaultOrientation[op_side_l][0]]) + { + //YES + side.v0 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]]; + side.v1 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]]; + } + else + { + //NO, its reversed + side.v0 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]]; + side.v1 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]]; + } + } else - { - //NO - //Just use the default orientation - side.v0 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]]; - side.v1 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]]; - } + { + //NO + //Just use the default orientation + side.v0 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]]; + side.v1 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]]; + } side.Oriented = true; } @@ -450,10 +450,10 @@ namespace internal GridReordering::is_fully_oriented_quad(const unsigned int quadnum) const { return ( - (sides[mquads[quadnum].side[0]].Oriented)&& - (sides[mquads[quadnum].side[1]].Oriented)&& - (sides[mquads[quadnum].side[2]].Oriented)&& - (sides[mquads[quadnum].side[3]].Oriented) + (sides[mquads[quadnum].side[0]].Oriented)&& + (sides[mquads[quadnum].side[1]].Oriented)&& + (sides[mquads[quadnum].side[2]].Oriented)&& + (sides[mquads[quadnum].side[3]].Oriented) ); } @@ -461,7 +461,7 @@ namespace internal bool GridReordering::is_oriented_side(const unsigned int quadnum, - const unsigned int lsn) const + const unsigned int lsn) const { return (sides[mquads[quadnum].side[lsn]].Oriented); } @@ -473,8 +473,8 @@ namespace internal GridReordering::get_unoriented_quad(unsigned int &UnOrQLoc) const { while( (UnOrQLoc q = mquads[qn].original_cell_data; - - // Are the sides oriented? - Assert (is_fully_oriented_quad(qn), ExcInternalError()); - bool s[4]; //whether side 1 ,2, 3, 4 are in the default orientation - for (int sn = 0;sn<4;sn++) - { - s[sn] = is_side_default_oriented(qn,sn); - } - // Are they oriented in the "deal way"? - Assert (s[0] == s[2], ExcInternalError()); - Assert (s[1] == s[3], ExcInternalError()); - // How much we rotate them by. - int rotn = 2*(s[0]?1:0)+ ((s[0]^s[1])?1:0); - - for (int i = 0;i<4;++i) - { - q.vertices[(i+rotn)%4] = mquads[qn].v[i]; - } - outquads.push_back(q); - } + { + // initialize CellData object with + // previous contents, and the + // overwrite all the fields that + // might have changed in the + // process of rotating things + CellData<2> q = mquads[qn].original_cell_data; + + // Are the sides oriented? + Assert (is_fully_oriented_quad(qn), ExcInternalError()); + bool s[4]; //whether side 1 ,2, 3, 4 are in the default orientation + for (int sn = 0;sn<4;sn++) + { + s[sn] = is_side_default_oriented(qn,sn); + } + // Are they oriented in the "deal way"? + Assert (s[0] == s[2], ExcInternalError()); + Assert (s[1] == s[3], ExcInternalError()); + // How much we rotate them by. + int rotn = 2*(s[0]?1:0)+ ((s[0]^s[1])?1:0); + + for (int i = 0;i<4;++i) + { + q.vertices[(i+rotn)%4] = mquads[qn].v[i]; + } + outquads.push_back(q); + } } bool GridReordering::is_side_default_oriented (const unsigned int qnum, - const unsigned int lsn) const + const unsigned int lsn) const { return (sides[mquads[qnum].side[lsn]].v0 == - mquads[qnum].v[ConnectGlobals::DefaultOrientation[lsn][0]]); + mquads[qnum].v[ConnectGlobals::DefaultOrientation[lsn][0]]); } } // namespace GridReordering2d } // namespace internal @@ -612,41 +612,41 @@ GridReordering<2,3>::reorder_cells (std::vector > &original_cells) template<> void GridReordering<2>::invert_all_cells_of_negative_grid(const std::vector > &all_vertices, - std::vector > &cells) + std::vector > &cells) { unsigned int vertices_lex[GeometryInfo<2>::vertices_per_cell]; unsigned int n_negative_cells=0; for (unsigned int cell_no=0; cell_no::vertices_per_cell; ++i) - vertices_lex[GeometryInfo<2>::ucd_to_deal[i]]=cells[cell_no].vertices[i]; + vertices_lex[GeometryInfo<2>::ucd_to_deal[i]]=cells[cell_no].vertices[i]; if (GridTools::cell_measure<2>(all_vertices, vertices_lex) < 0) - { - ++n_negative_cells; - std::swap(cells[cell_no].vertices[1], cells[cell_no].vertices[3]); - - // check whether the - // resulting cell is now ok. - // if not, then the grid is - // seriously broken and - // should be sticked into the - // bin - for (unsigned int i=0; i::vertices_per_cell; ++i) - vertices_lex[GeometryInfo<2>::ucd_to_deal[i]]=cells[cell_no].vertices[i]; - AssertThrow(GridTools::cell_measure<2>(all_vertices, vertices_lex) > 0, - ExcInternalError()); - } + { + ++n_negative_cells; + std::swap(cells[cell_no].vertices[1], cells[cell_no].vertices[3]); + + // check whether the + // resulting cell is now ok. + // if not, then the grid is + // seriously broken and + // should be sticked into the + // bin + for (unsigned int i=0; i::vertices_per_cell; ++i) + vertices_lex[GeometryInfo<2>::ucd_to_deal[i]]=cells[cell_no].vertices[i]; + AssertThrow(GridTools::cell_measure<2>(all_vertices, vertices_lex) > 0, + ExcInternalError()); + } } - // We assume that all cells of a grid have - // either positive or negative volumes but - // not both mixed. Although above reordering - // might work also on single cells, grids - // with both kind of cells are very likely to - // be broken. Check for this here. + // We assume that all cells of a grid have + // either positive or negative volumes but + // not both mixed. Although above reordering + // might work also on single cells, grids + // with both kind of cells are very likely to + // be broken. Check for this here. AssertThrow(n_negative_cells==0 || n_negative_cells==cells.size(), ExcInternalError()); } @@ -655,7 +655,7 @@ GridReordering<2>::invert_all_cells_of_negative_grid(const std::vector template<> void GridReordering<2,3>::invert_all_cells_of_negative_grid(const std::vector > &, - std::vector > &) + std::vector > &) { Assert(false, ExcNotImplemented()); } @@ -667,8 +667,8 @@ namespace internal namespace GridReordering3d { DeclException1 (ExcGridOrientError, - char *, - << "Grid Orientation Error: " << arg1); + char *, + << "Grid Orientation Error: " << arg1); const EdgeOrientation unoriented_edge = {'u'}; const EdgeOrientation forward_edge = {'f'}; @@ -681,7 +681,7 @@ namespace internal operator == (const EdgeOrientation &edge_orientation) const { Assert ((orientation == 'u') || (orientation == 'f') || (orientation == 'b'), - ExcInternalError()); + ExcInternalError()); return orientation == edge_orientation.orientation; } @@ -699,80 +699,80 @@ namespace internal namespace ElementInfo { - /** - * The numbers of the edges - * coming into node i are - * given by - * edge_to_node[i][k] where - * k=0,1,2. - */ + /** + * The numbers of the edges + * coming into node i are + * given by + * edge_to_node[i][k] where + * k=0,1,2. + */ static const unsigned int edge_to_node[8][3] = { - {0,4,8}, - {0,5,9}, - {3,5,10}, - {3,4,11}, - {1,7,8}, - {1,6,9}, - {2,6,10}, - {2,7,11} + {0,4,8}, + {0,5,9}, + {3,5,10}, + {3,4,11}, + {1,7,8}, + {1,6,9}, + {2,6,10}, + {2,7,11} }; - /** - * The orientation of edge - * coming into node i is - * given by - * edge_to_node_orient[i][k] - * where k=0,1,2. 1 means the - * given node is the start of - * the edge -1 means the end - * of the edge. - */ + /** + * The orientation of edge + * coming into node i is + * given by + * edge_to_node_orient[i][k] + * where k=0,1,2. 1 means the + * given node is the start of + * the edge -1 means the end + * of the edge. + */ static const EdgeOrientation edge_to_node_orient[8][3] = { - {forward_edge, forward_edge, forward_edge}, - {backward_edge, forward_edge, forward_edge}, - {backward_edge, backward_edge, forward_edge}, - {forward_edge, backward_edge, forward_edge}, - {forward_edge, forward_edge, backward_edge}, - {backward_edge, forward_edge, backward_edge}, - {backward_edge, backward_edge, backward_edge}, - {forward_edge, backward_edge, backward_edge} + {forward_edge, forward_edge, forward_edge}, + {backward_edge, forward_edge, forward_edge}, + {backward_edge, backward_edge, forward_edge}, + {forward_edge, backward_edge, forward_edge}, + {forward_edge, forward_edge, backward_edge}, + {backward_edge, forward_edge, backward_edge}, + {backward_edge, backward_edge, backward_edge}, + {forward_edge, backward_edge, backward_edge} }; - /** - * nodesonedge[i][0] is the - * start node for edge i. - * nodesonedge[i][1] is the - * end node for edge i. - */ + /** + * nodesonedge[i][0] is the + * start node for edge i. + * nodesonedge[i][1] is the + * end node for edge i. + */ static const unsigned int nodes_on_edge[12][2] = { - {0,1}, - {4,5}, - {7,6}, - {3,2}, - {0,3}, - {1,2}, - {5,6}, - {4,7}, - {0,4}, - {1,5}, - {2,6}, - {3,7} + {0,1}, + {4,5}, + {7,6}, + {3,2}, + {0,3}, + {1,2}, + {5,6}, + {4,7}, + {0,4}, + {1,5}, + {2,6}, + {3,7} }; } CheapEdge::CheapEdge (const unsigned int n0, - const unsigned int n1) - : + const unsigned int n1) + : // sort the // entries so // that // node0::lines_per_cell; ++i) - { - edges[i] = numbers::invalid_unsigned_int; - local_orientation_flags[i] = forward_edge; - } + { + edges[i] = numbers::invalid_unsigned_int; + local_orientation_flags[i] = forward_edge; + } for (unsigned int i=0; i::vertices_per_cell; ++i) - nodes[i] = numbers::invalid_unsigned_int; + nodes[i] = numbers::invalid_unsigned_int; waiting_to_be_processed = false; } @@ -841,8 +841,8 @@ namespace internal Mesh::sanity_check () const { for (unsigned int i=0; i edge_map; - unsigned int ctr = 0; - for (unsigned int cur_cell_id = 0; - cur_cell_id edge_map; + unsigned int ctr = 0; + for (unsigned int cur_cell_id = 0; + cur_cell_id edge_count(n_edges,0); + std::vector edge_count(n_edges,0); - // Count every time an edge - // occurs in a cube. - for (unsigned int cur_cell_id=0; cur_cell_id cur_cell_edge_list_posn(n_edges,0); - for (unsigned int cur_cell_id=0; cur_cell_id cur_cell_edge_list_posn(n_edges,0); + for (unsigned int cur_cell_id=0; cur_cell_id::reorder_cells (std::vector > &incubes) { Assert (incubes.size() != 0, - ExcMessage("List of elements to orient was of zero length")); + ExcMessage("List of elements to orient was of zero length")); - // create a backup to use if GridReordering - // was not successful + // create a backup to use if GridReordering + // was not successful std::vector > backup=incubes; - // This does the real work + // This does the real work bool success= internal::GridReordering3d::Orienter::orient_mesh (incubes); - // if reordering was not successful use - // original connectivity, otherwiese do - // nothing (i.e. use the reordered - // connectivity) + // if reordering was not successful use + // original connectivity, otherwiese do + // nothing (i.e. use the reordered + // connectivity) if (!success) incubes=backup; } @@ -1540,39 +1540,39 @@ GridReordering<3>::invert_all_cells_of_negative_grid( unsigned int n_negative_cells=0; for (unsigned int cell_no=0; cell_no::vertices_per_cell; ++i) - vertices_lex[GeometryInfo<3>::ucd_to_deal[i]]=cells[cell_no].vertices[i]; + vertices_lex[GeometryInfo<3>::ucd_to_deal[i]]=cells[cell_no].vertices[i]; if (GridTools::cell_measure<3>(all_vertices, vertices_lex) < 0) - { - ++n_negative_cells; - // reorder vertices: swap front and back face - for (unsigned int i=0; i<4; ++i) - std::swap(cells[cell_no].vertices[i], cells[cell_no].vertices[i+4]); - - // check whether the - // resulting cell is now ok. - // if not, then the grid is - // seriously broken and - // should be sticked into the - // bin - for (unsigned int i=0; i::vertices_per_cell; ++i) - vertices_lex[GeometryInfo<3>::ucd_to_deal[i]]=cells[cell_no].vertices[i]; - AssertThrow(GridTools::cell_measure<3>(all_vertices, vertices_lex) > 0, - ExcInternalError()); - } + { + ++n_negative_cells; + // reorder vertices: swap front and back face + for (unsigned int i=0; i<4; ++i) + std::swap(cells[cell_no].vertices[i], cells[cell_no].vertices[i+4]); + + // check whether the + // resulting cell is now ok. + // if not, then the grid is + // seriously broken and + // should be sticked into the + // bin + for (unsigned int i=0; i::vertices_per_cell; ++i) + vertices_lex[GeometryInfo<3>::ucd_to_deal[i]]=cells[cell_no].vertices[i]; + AssertThrow(GridTools::cell_measure<3>(all_vertices, vertices_lex) > 0, + ExcInternalError()); + } } - // We assume that all cells of a - // grid have either positive or - // negative volumes but not both - // mixed. Although above reordering - // might work also on single cells, - // grids with both kind of cells - // are very likely to be - // broken. Check for this here. + // We assume that all cells of a + // grid have either positive or + // negative volumes but not both + // mixed. Although above reordering + // might work also on single cells, + // grids with both kind of cells + // are very likely to be + // broken. Check for this here. AssertThrow(n_negative_cells==0 || n_negative_cells==cells.size(), ExcInternalError()); } diff --git a/deal.II/source/grid/grid_tools.cc b/deal.II/source/grid/grid_tools.cc index 7dad144693..5d39c1f1f7 100644 --- a/deal.II/source/grid/grid_tools.cc +++ b/deal.II/source/grid/grid_tools.cc @@ -83,36 +83,36 @@ namespace GridTools double diameter (const Triangulation &tria) { - // we can't deal with distributed meshes - // since we don't have all vertices - // locally. there is one exception, - // however: if the mesh has never been - // refined. the way to test this is not to - // ask tria.n_levels()==1, since this is - // something that can happen on one - // processor without being true on - // all. however, we can ask for the global - // number of active cells and use that + // we can't deal with distributed meshes + // since we don't have all vertices + // locally. there is one exception, + // however: if the mesh has never been + // refined. the way to test this is not to + // ask tria.n_levels()==1, since this is + // something that can happen on one + // processor without being true on + // all. however, we can ask for the global + // number of active cells and use that #ifdef DEAL_II_USE_P4EST if (const parallel::distributed::Triangulation *p_tria - = dynamic_cast*>(&tria)) + = dynamic_cast*>(&tria)) Assert (p_tria->n_global_active_cells() == tria.n_cells(0), - ExcNotImplemented()); + ExcNotImplemented()); #endif - // the algorithm used simply - // traverses all cells and picks - // out the boundary vertices. it - // may or may not be faster to - // simply get all vectors, don't - // mark boundary vertices, and - // compute the distances thereof, - // but at least as the mesh is - // refined, it seems better to - // first mark boundary nodes, as - // marking is O(N) in the number of - // cells/vertices, while computing - // the maximal distance is O(N*N) + // the algorithm used simply + // traverses all cells and picks + // out the boundary vertices. it + // may or may not be faster to + // simply get all vectors, don't + // mark boundary vertices, and + // compute the distances thereof, + // but at least as the mesh is + // refined, it seems better to + // first mark boundary nodes, as + // marking is O(N) in the number of + // cells/vertices, while computing + // the maximal distance is O(N*N) const std::vector > &vertices = tria.get_vertices (); std::vector boundary_vertices (vertices.size(), false); @@ -122,25 +122,25 @@ namespace GridTools endc = tria.end(); for (; cell!=endc; ++cell) for (unsigned int face=0; face::faces_per_cell; ++face) - if (cell->face(face)->at_boundary ()) - for (unsigned int i=0; i::vertices_per_face; ++i) - boundary_vertices[cell->face(face)->vertex_index(i)] = true; - - // now traverse the list of - // boundary vertices and check - // distances. since distances are - // symmetric, we only have to check - // one half + if (cell->face(face)->at_boundary ()) + for (unsigned int i=0; i::vertices_per_face; ++i) + boundary_vertices[cell->face(face)->vertex_index(i)] = true; + + // now traverse the list of + // boundary vertices and check + // distances. since distances are + // symmetric, we only have to check + // one half double max_distance_sqr = 0; std::vector::const_iterator pi = boundary_vertices.begin(); const unsigned int N = boundary_vertices.size(); for (unsigned int i=0; i::const_iterator pj = pi+1; - for (unsigned int j=i+1; j max_distance_sqr)) - max_distance_sqr = (vertices[i]-vertices[j]).square(); + std::vector::const_iterator pj = pi+1; + for (unsigned int j=i+1; j max_distance_sqr)) + max_distance_sqr = (vertices[i]-vertices[j]).square(); }; return std::sqrt(max_distance_sqr); @@ -151,21 +151,21 @@ namespace GridTools template double volume (const Triangulation &triangulation, - const Mapping &mapping) + const Mapping &mapping) { - // get the degree of the mapping if possible. if not, just assume 1 + // get the degree of the mapping if possible. if not, just assume 1 const unsigned int mapping_degree = (dynamic_cast*>(&mapping) != 0 ? - dynamic_cast*>(&mapping)->get_degree() : - 1); + dynamic_cast*>(&mapping)->get_degree() : + 1); - // then initialize an appropriate quadrature formula + // then initialize an appropriate quadrature formula const QGauss quadrature_formula (mapping_degree + 1); const unsigned int n_q_points = quadrature_formula.size(); FE_DGQ dummy_fe(0); FEValues fe_values (mapping, dummy_fe, quadrature_formula, - update_JxW_values); + update_JxW_values); typename Triangulation::active_cell_iterator cell = triangulation.begin_active(), @@ -173,20 +173,20 @@ namespace GridTools double local_volume = 0; - // compute the integral quantities by quadrature + // compute the integral quantities by quadrature for (; cell!=endc; ++cell) if (cell->is_locally_owned()) - { - fe_values.reinit (cell); - for (unsigned int q=0; q* p_tria - = dynamic_cast*>(&triangulation)) + = dynamic_cast*>(&triangulation)) global_volume = Utilities::MPI::sum (local_volume, p_tria->get_communicator()); else global_volume = local_volume; @@ -201,38 +201,38 @@ namespace GridTools template <> double cell_measure<3>(const std::vector > &all_vertices, - const unsigned int (&vertex_indices)[GeometryInfo<3>::vertices_per_cell]) + const unsigned int (&vertex_indices)[GeometryInfo<3>::vertices_per_cell]) { - // note that this is the - // cell_measure based on the new - // deal.II numbering. When called - // from inside GridReordering make - // sure that you reorder the - // vertex_indices before + // note that this is the + // cell_measure based on the new + // deal.II numbering. When called + // from inside GridReordering make + // sure that you reorder the + // vertex_indices before const double x[8] = { all_vertices[vertex_indices[0]](0), - all_vertices[vertex_indices[1]](0), - all_vertices[vertex_indices[2]](0), - all_vertices[vertex_indices[3]](0), - all_vertices[vertex_indices[4]](0), - all_vertices[vertex_indices[5]](0), - all_vertices[vertex_indices[6]](0), - all_vertices[vertex_indices[7]](0) }; + all_vertices[vertex_indices[1]](0), + all_vertices[vertex_indices[2]](0), + all_vertices[vertex_indices[3]](0), + all_vertices[vertex_indices[4]](0), + all_vertices[vertex_indices[5]](0), + all_vertices[vertex_indices[6]](0), + all_vertices[vertex_indices[7]](0) }; const double y[8] = { all_vertices[vertex_indices[0]](1), - all_vertices[vertex_indices[1]](1), - all_vertices[vertex_indices[2]](1), - all_vertices[vertex_indices[3]](1), - all_vertices[vertex_indices[4]](1), - all_vertices[vertex_indices[5]](1), - all_vertices[vertex_indices[6]](1), - all_vertices[vertex_indices[7]](1) }; + all_vertices[vertex_indices[1]](1), + all_vertices[vertex_indices[2]](1), + all_vertices[vertex_indices[3]](1), + all_vertices[vertex_indices[4]](1), + all_vertices[vertex_indices[5]](1), + all_vertices[vertex_indices[6]](1), + all_vertices[vertex_indices[7]](1) }; const double z[8] = { all_vertices[vertex_indices[0]](2), - all_vertices[vertex_indices[1]](2), - all_vertices[vertex_indices[2]](2), - all_vertices[vertex_indices[3]](2), - all_vertices[vertex_indices[4]](2), - all_vertices[vertex_indices[5]](2), - all_vertices[vertex_indices[6]](2), - all_vertices[vertex_indices[7]](2) }; + all_vertices[vertex_indices[1]](2), + all_vertices[vertex_indices[2]](2), + all_vertices[vertex_indices[3]](2), + all_vertices[vertex_indices[4]](2), + all_vertices[vertex_indices[5]](2), + all_vertices[vertex_indices[6]](2), + all_vertices[vertex_indices[7]](2) }; /* This is the same Maple script as in the barycenter method above @@ -321,7 +321,7 @@ namespace GridTools template <> double cell_measure(const std::vector > &all_vertices, - const unsigned int (&vertex_indices) [GeometryInfo<2>::vertices_per_cell]) + const unsigned int (&vertex_indices) [GeometryInfo<2>::vertices_per_cell]) { /* Get the computation of the measure by this little Maple script. We @@ -360,14 +360,14 @@ namespace GridTools */ const double x[4] = { all_vertices[vertex_indices[0]](0), - all_vertices[vertex_indices[1]](0), - all_vertices[vertex_indices[2]](0), - all_vertices[vertex_indices[3]](0)}; + all_vertices[vertex_indices[1]](0), + all_vertices[vertex_indices[2]](0), + all_vertices[vertex_indices[3]](0)}; const double y[4] = { all_vertices[vertex_indices[0]](1), - all_vertices[vertex_indices[1]](1), - all_vertices[vertex_indices[2]](1), - all_vertices[vertex_indices[3]](1)}; + all_vertices[vertex_indices[1]](1), + all_vertices[vertex_indices[2]](1), + all_vertices[vertex_indices[3]](1)}; return (-x[1]*y[0]+x[1]*y[3]+y[0]*x[2]+x[0]*y[1]-x[0]*y[2]-y[1]*x[3]-x[2]*y[3]+x[3]*y[2])/2; @@ -379,7 +379,7 @@ namespace GridTools template double cell_measure(const std::vector > &, - const unsigned int (&) [GeometryInfo::vertices_per_cell]) + const unsigned int (&) [GeometryInfo::vertices_per_cell]) { Assert(false, ExcNotImplemented()); return 0.; @@ -390,54 +390,54 @@ namespace GridTools template void delete_unused_vertices (std::vector > &vertices, - std::vector > &cells, - SubCellData &subcelldata) + std::vector > &cells, + SubCellData &subcelldata) { - // first check which vertices are - // actually used + // first check which vertices are + // actually used std::vector vertex_used (vertices.size(), false); for (unsigned int c=0; c::vertices_per_cell; ++v) - vertex_used[cells[c].vertices[v]] = true; + vertex_used[cells[c].vertices[v]] = true; - // then renumber the vertices that - // are actually used in the same - // order as they were beforehand + // then renumber the vertices that + // are actually used in the same + // order as they were beforehand const unsigned int invalid_vertex = numbers::invalid_unsigned_int; std::vector new_vertex_numbers (vertices.size(), invalid_vertex); unsigned int next_free_number = 0; for (unsigned int i=0; i::vertices_per_cell; ++v) - cells[c].vertices[v] = new_vertex_numbers[cells[c].vertices[v]]; + cells[c].vertices[v] = new_vertex_numbers[cells[c].vertices[v]]; - // same for boundary data + // same for boundary data for (unsigned int c=0; c::vertices_per_cell; ++v) - subcelldata.boundary_lines[c].vertices[v] - = new_vertex_numbers[subcelldata.boundary_lines[c].vertices[v]]; + subcelldata.boundary_lines[c].vertices[v] + = new_vertex_numbers[subcelldata.boundary_lines[c].vertices[v]]; for (unsigned int c=0; c::vertices_per_cell; ++v) - subcelldata.boundary_quads[c].vertices[v] - = new_vertex_numbers[subcelldata.boundary_quads[c].vertices[v]]; + subcelldata.boundary_quads[c].vertices[v] + = new_vertex_numbers[subcelldata.boundary_quads[c].vertices[v]]; - // finally copy over the vertices - // which we really need to a new - // array and replace the old one by - // the new one + // finally copy over the vertices + // which we really need to a new + // array and replace the old one by + // the new one std::vector > tmp; tmp.reserve (std::count(vertex_used.begin(), vertex_used.end(), true)); for (unsigned int v=0; v void delete_duplicated_vertices (std::vector > &vertices, - std::vector > &cells, - SubCellData &subcelldata, - std::vector &considered_vertices, - double tol) + std::vector > &cells, + SubCellData &subcelldata, + std::vector &considered_vertices, + double tol) { - // create a vector of vertex - // indices. initialize it to the identity, - // later on change that if necessary. + // create a vector of vertex + // indices. initialize it to the identity, + // later on change that if necessary. std::vector new_vertex_numbers(vertices.size()); for (unsigned int i=0; i::vertices_per_cell; ++v) - cells[c].vertices[v]=new_vertex_numbers[cells[c].vertices[v]]; + cells[c].vertices[v]=new_vertex_numbers[cells[c].vertices[v]]; delete_unused_vertices(vertices,cells,subcelldata); } @@ -521,36 +521,36 @@ namespace GridTools class ShiftPoint { public: - ShiftPoint (const Point &shift) - : - shift(shift) - {} - Point operator() (const Point p) const - { - return p+shift; - } + ShiftPoint (const Point &shift) + : + shift(shift) + {} + Point operator() (const Point p) const + { + return p+shift; + } private: - const Point shift; + const Point shift; }; - // the following class is only - // needed in 2d, so avoid trouble - // with compilers warning otherwise + // the following class is only + // needed in 2d, so avoid trouble + // with compilers warning otherwise class Rotate2d { public: - Rotate2d (const double angle) - : - angle(angle) - {} - Point<2> operator() (const Point<2> &p) const - { - return Point<2> (std::cos(angle)*p(0) - std::sin(angle) * p(1), - std::sin(angle)*p(0) + std::cos(angle) * p(1)); - } + Rotate2d (const double angle) + : + angle(angle) + {} + Point<2> operator() (const Point<2> &p) const + { + return Point<2> (std::cos(angle)*p(0) - std::sin(angle) * p(1), + std::sin(angle)*p(0) + std::cos(angle) * p(1)); + } private: - const double angle; + const double angle; }; @@ -558,16 +558,16 @@ namespace GridTools class ScalePoint { public: - ScalePoint (const double factor) - : - factor(factor) - {} - Point operator() (const Point p) const - { - return p*factor; - } + ScalePoint (const double factor) + : + factor(factor) + {} + Point operator() (const Point p) const + { + return p*factor; + } private: - const double factor; + const double factor; }; } @@ -575,7 +575,7 @@ namespace GridTools template void shift (const Point &shift_vector, - Triangulation &triangulation) + Triangulation &triangulation) { #ifdef DEAL_II_ANON_NAMESPACE_BOGUS_WARNING transform (TRANS::ShiftPoint(shift_vector), triangulation); @@ -588,7 +588,7 @@ namespace GridTools void rotate (const double angle, - Triangulation<2> &triangulation) + Triangulation<2> &triangulation) { #ifdef DEAL_II_ANON_NAMESPACE_BOGUS_WARNING transform (TRANS::Rotate2d(angle), triangulation); @@ -602,7 +602,7 @@ namespace GridTools template void scale (const double scaling_factor, - Triangulation &triangulation) + Triangulation &triangulation) { Assert (scaling_factor>0, ExcScalingFactorNotPositive (scaling_factor)); #ifdef DEAL_II_ANON_NAMESPACE_BOGUS_WARNING @@ -617,41 +617,41 @@ namespace GridTools template class Container, int spacedim> unsigned int find_closest_vertex (const Container &container, - const Point &p) + const Point &p) { - // first get the underlying - // triangulation from the - // container and determine vertices - // and used vertices + // first get the underlying + // triangulation from the + // container and determine vertices + // and used vertices const Triangulation &tria = get_tria(container); const std::vector< Point > &vertices = tria.get_vertices(); const std::vector< bool > &used = tria.get_used_vertices(); - // At the beginning, the first - // used vertex is the closest one + // At the beginning, the first + // used vertex is the closest one std::vector::const_iterator first = std::find(used.begin(), used.end(), true); - // Assert that at least one vertex - // is actually used + // Assert that at least one vertex + // is actually used Assert(first != used.end(), ExcInternalError()); unsigned int best_vertex = std::distance(used.begin(), first); double best_dist = (p - vertices[best_vertex]).square(); - // For all remaining vertices, test - // whether they are any closer + // For all remaining vertices, test + // whether they are any closer for(unsigned int j = best_vertex+1; j < vertices.size(); j++) if(used[j]) - { - double dist = (p - vertices[j]).square(); - if(dist < best_dist) - { - best_vertex = j; - best_dist = dist; - } - } + { + double dist = (p - vertices[j]).square(); + if(dist < best_dist) + { + best_vertex = j; + best_dist = dist; + } + } return best_vertex; } @@ -660,100 +660,100 @@ namespace GridTools template class Container, int spacedim> std::vector::active_cell_iterator> find_cells_adjacent_to_vertex(const Container &container, - const unsigned int vertex) + const unsigned int vertex) { - // make sure that the given vertex is - // an active vertex of the underlying - // triangulation + // make sure that the given vertex is + // an active vertex of the underlying + // triangulation Assert(vertex < get_tria(container).n_vertices(), - ExcIndexRange(0,get_tria(container).n_vertices(),vertex)); + ExcIndexRange(0,get_tria(container).n_vertices(),vertex)); Assert(get_tria(container).get_used_vertices()[vertex], - ExcVertexNotUsed(vertex)); + ExcVertexNotUsed(vertex)); - // We use a set instead of a vector - // to ensure that cells are inserted only - // once. A bug in the previous version - // prevented some cases to be - // treated correctly + // We use a set instead of a vector + // to ensure that cells are inserted only + // once. A bug in the previous version + // prevented some cases to be + // treated correctly std::set::active_cell_iterator> adj_cells_set; typename Container::active_cell_iterator cell = container.begin_active(), endc = container.end(); - // go through all active cells and look - // if the vertex is part of that cell + // go through all active cells and look + // if the vertex is part of that cell for (; cell != endc; ++cell) for (unsigned v = 0; v < GeometryInfo::vertices_per_cell; v++) - if (cell->vertex_index(v) == vertex) - { - // OK, we found a cell that contains - // the particular vertex. We add it - // to the list. - adj_cells_set.insert(cell); - - // Now we need to make sure that the - // vertex is not a locally refined - // vertex not being part of the - // neighboring cells. So we loop over - // all faces to which this vertex - // belongs, check the level of - // the neighbor, and if it is coarser, - // then check whether the vertex is - // part of that neighbor or not. - for (unsigned vface = 0; vface < dim; vface++) - { - const unsigned face = - GeometryInfo::vertex_to_face[v][vface]; - if (!cell->at_boundary(face)) - { - typename Container::cell_iterator - nb = cell->neighbor(face); - - // Here we - // check - // whether - // the - // neighbor - // is - // coarser. If - // it is, we - // search - // for the - // vertex in - // this - // coarser - // cell and - // only if - // not found - // we will - // add the - // coarser - // cell - // itself - if (nb->level() < cell->level()) - { - bool found = false; - for (unsigned v=0; v::vertices_per_cell; v++) - if (nb->vertex_index(v) == vertex) - { - found = true; - break; - } - if (!found) - adj_cells_set.insert(nb); - } - } - } - - break; - } + if (cell->vertex_index(v) == vertex) + { + // OK, we found a cell that contains + // the particular vertex. We add it + // to the list. + adj_cells_set.insert(cell); + + // Now we need to make sure that the + // vertex is not a locally refined + // vertex not being part of the + // neighboring cells. So we loop over + // all faces to which this vertex + // belongs, check the level of + // the neighbor, and if it is coarser, + // then check whether the vertex is + // part of that neighbor or not. + for (unsigned vface = 0; vface < dim; vface++) + { + const unsigned face = + GeometryInfo::vertex_to_face[v][vface]; + if (!cell->at_boundary(face)) + { + typename Container::cell_iterator + nb = cell->neighbor(face); + + // Here we + // check + // whether + // the + // neighbor + // is + // coarser. If + // it is, we + // search + // for the + // vertex in + // this + // coarser + // cell and + // only if + // not found + // we will + // add the + // coarser + // cell + // itself + if (nb->level() < cell->level()) + { + bool found = false; + for (unsigned v=0; v::vertices_per_cell; v++) + if (nb->vertex_index(v) == vertex) + { + found = true; + break; + } + if (!found) + adj_cells_set.insert(nb); + } + } + } + + break; + } std::vector::active_cell_iterator> adjacent_cells; - // We now produce the output vector - // from the set that we assembled above. + // We now produce the output vector + // from the set that we assembled above. typename std::set::active_cell_iterator>::iterator it = adj_cells_set.begin(), endit = adj_cells_set.end(); @@ -771,31 +771,31 @@ namespace GridTools template class Container, int spacedim> typename Container::active_cell_iterator find_active_cell_around_point (const Container &container, - const Point &p) + const Point &p) { return find_active_cell_around_point(StaticMappingQ1::mapping, - container, p).first; + container, p).first; } template class Container, int spacedim> std::pair::active_cell_iterator, Point > find_active_cell_around_point (const Mapping &mapping, - const Container &container, - const Point &p) + const Container &container, + const Point &p) { typedef typename Container::active_cell_iterator cell_iterator; - // The best distance is set to the - // maximum allowable distance from - // the unit cell; we assume a - // max. deviation of 1e-10 + // The best distance is set to the + // maximum allowable distance from + // the unit cell; we assume a + // max. deviation of 1e-10 double best_distance = 1e-10; int best_level = -1; std::pair > best_cell; - // Find closest vertex and determine - // all adjacent cells + // Find closest vertex and determine + // all adjacent cells unsigned int vertex = find_closest_vertex(container, p); std::vector adjacent_cells = @@ -807,35 +807,35 @@ namespace GridTools for(; cell != endc; ++cell) { - try - { - const Point p_cell = mapping.transform_real_to_unit_cell(*cell, p); - - // calculate the infinity norm of - // the distance vector to the unit cell. - const double dist = GeometryInfo::distance_to_unit_cell(p_cell); - - // We compare if the point is inside the - // unit cell (or at least not too far - // outside). If it is, it is also checked - // that the cell has a more refined state - if (dist < best_distance || - (dist == best_distance && (*cell)->level() > best_level)) - { - best_distance = dist; - best_level = (*cell)->level(); - best_cell = std::make_pair(*cell, p_cell); - } - } - catch (typename MappingQ1::ExcTransformationFailed &) - { + try + { + const Point p_cell = mapping.transform_real_to_unit_cell(*cell, p); + + // calculate the infinity norm of + // the distance vector to the unit cell. + const double dist = GeometryInfo::distance_to_unit_cell(p_cell); + + // We compare if the point is inside the + // unit cell (or at least not too far + // outside). If it is, it is also checked + // that the cell has a more refined state + if (dist < best_distance || + (dist == best_distance && (*cell)->level() > best_level)) + { + best_distance = dist; + best_level = (*cell)->level(); + best_cell = std::make_pair(*cell, p_cell); + } + } + catch (typename MappingQ1::ExcTransformationFailed &) + { //TODO: Maybe say something - } + } } Assert (best_cell.first.state() == IteratorState::valid, - ExcPointNotFound(p)); + ExcPointNotFound(p)); return best_cell; } @@ -845,37 +845,37 @@ namespace GridTools template std::pair::active_cell_iterator, Point > find_active_cell_around_point (const hp::MappingCollection &mapping, - const hp::DoFHandler &container, - const Point &p) + const hp::DoFHandler &container, + const Point &p) { Assert ((mapping.size() == 1) || - (mapping.size() == container.get_fe().size()), - ExcMessage ("Mapping collection needs to have either size 1 " - "or size equal to the number of elements in " - "the FECollection.")); + (mapping.size() == container.get_fe().size()), + ExcMessage ("Mapping collection needs to have either size 1 " + "or size equal to the number of elements in " + "the FECollection.")); typedef typename hp::DoFHandler::active_cell_iterator cell_iterator; std::pair > best_cell; - //If we have only one element in the MappingCollection, - //we use find_active_cell_around_point using only one - //mapping. + //If we have only one element in the MappingCollection, + //we use find_active_cell_around_point using only one + //mapping. if(mapping.size()==1) best_cell = find_active_cell_around_point(mapping[0], container, p); else { - // The best distance is set to the - // maximum allowable distance from - // the unit cell; we assume a - // max. deviation of 1e-10 + // The best distance is set to the + // maximum allowable distance from + // the unit cell; we assume a + // max. deviation of 1e-10 double best_distance = 1e-10; int best_level = -1; - // Find closest vertex and determine - // all adjacent cells + // Find closest vertex and determine + // all adjacent cells unsigned int vertex = find_closest_vertex(container, p); std::vector adjacent_cells = @@ -887,28 +887,28 @@ namespace GridTools for(; cell != endc; ++cell) { - const Point p_cell - = mapping[(*cell)->active_fe_index()].transform_real_to_unit_cell(*cell, p); - - // calculate the infinity norm of - // the distance vector to the unit cell. - const double dist = GeometryInfo::distance_to_unit_cell(p_cell); - - // We compare if the point is inside the - // unit cell (or at least not too far - // outside). If it is, it is also checked - // that the cell has a more refined state - if (dist < best_distance || - (dist == best_distance && (*cell)->level() > best_level)) - { - best_distance = dist; - best_level = (*cell)->level(); - best_cell = std::make_pair(*cell, p_cell); - } - } - - Assert (best_cell.first.state() == IteratorState::valid, - ExcPointNotFound(p)); + const Point p_cell + = mapping[(*cell)->active_fe_index()].transform_real_to_unit_cell(*cell, p); + + // calculate the infinity norm of + // the distance vector to the unit cell. + const double dist = GeometryInfo::distance_to_unit_cell(p_cell); + + // We compare if the point is inside the + // unit cell (or at least not too far + // outside). If it is, it is also checked + // that the cell has a more refined state + if (dist < best_distance || + (dist == best_distance && (*cell)->level() > best_level)) + { + best_distance = dist; + best_level = (*cell)->level(); + best_cell = std::make_pair(*cell, p_cell); + } + } + + Assert (best_cell.first.state() == IteratorState::valid, + ExcPointNotFound(p)); } return best_cell; } @@ -918,72 +918,72 @@ namespace GridTools template void get_face_connectivity_of_cells (const Triangulation &triangulation, - SparsityPattern &cell_connectivity) + SparsityPattern &cell_connectivity) { - // as built in this function, we - // only consider face neighbors, - // which leads to a fixed number of - // entries per row (don't forget - // that each cell couples with - // itself, and that neighbors can - // be refined) + // as built in this function, we + // only consider face neighbors, + // which leads to a fixed number of + // entries per row (don't forget + // that each cell couples with + // itself, and that neighbors can + // be refined) cell_connectivity.reinit (triangulation.n_active_cells(), - triangulation.n_active_cells(), - GeometryInfo::faces_per_cell - * GeometryInfo::max_children_per_face - + - 1); - - // next we have to build a mapping from the - // list of cells to their indices. for - // this, use the user_index field + triangulation.n_active_cells(), + GeometryInfo::faces_per_cell + * GeometryInfo::max_children_per_face + + + 1); + + // next we have to build a mapping from the + // list of cells to their indices. for + // this, use the user_index field std::vector saved_user_indices; triangulation.save_user_indices (saved_user_indices); unsigned int index = 0; for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell != triangulation.end(); ++cell, ++index) + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell, ++index) cell->set_user_index (index); - // next loop over all cells and - // their neighbors to build the - // sparsity pattern. note that it's - // a bit hard to enter all the - // connections when a neighbor has - // children since we would need to - // find out which of its children - // is adjacent to the current - // cell. this problem can be - // omitted if we only do something - // if the neighbor has no children - // -- in that case it is either on - // the same or a coarser level than - // we are. in return, we have to - // add entries in both directions - // for both cells + // next loop over all cells and + // their neighbors to build the + // sparsity pattern. note that it's + // a bit hard to enter all the + // connections when a neighbor has + // children since we would need to + // find out which of its children + // is adjacent to the current + // cell. this problem can be + // omitted if we only do something + // if the neighbor has no children + // -- in that case it is either on + // the same or a coarser level than + // we are. in return, we have to + // add entries in both directions + // for both cells index = 0; for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell != triangulation.end(); ++cell, ++index) + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell, ++index) { - cell_connectivity.add (index, index); - for (unsigned int f=0; f::faces_per_cell; ++f) - if ((cell->at_boundary(f) == false) - && - (cell->neighbor(f)->has_children() == false)) - { - cell_connectivity.add (index, - cell->neighbor(f)->user_index()); - cell_connectivity.add (cell->neighbor(f)->user_index(), - index); - } + cell_connectivity.add (index, index); + for (unsigned int f=0; f::faces_per_cell; ++f) + if ((cell->at_boundary(f) == false) + && + (cell->neighbor(f)->has_children() == false)) + { + cell_connectivity.add (index, + cell->neighbor(f)->user_index()); + cell_connectivity.add (cell->neighbor(f)->user_index(), + index); + } } - // now compress the so-built connectivity - // pattern and restore user indices. the - // const-cast is necessary since we treat - // the triangulation as constant (we here - // return it to its original state) + // now compress the so-built connectivity + // pattern and restore user indices. the + // const-cast is necessary since we treat + // the triangulation as constant (we here + // return it to its original state) cell_connectivity.compress (); const_cast&>(triangulation) .load_user_indices (saved_user_indices); @@ -994,38 +994,38 @@ namespace GridTools template void partition_triangulation (const unsigned int n_partitions, - Triangulation &triangulation) + Triangulation &triangulation) { Assert ((dynamic_cast*> - (&triangulation) - == 0), - ExcMessage ("Objects of type parallel::distributed::Triangulation " - "are already partitioned implicitly and can not be " - "partitioned again explicitly.")); + (&triangulation) + == 0), + ExcMessage ("Objects of type parallel::distributed::Triangulation " + "are already partitioned implicitly and can not be " + "partitioned again explicitly.")); Assert (n_partitions > 0, ExcInvalidNumberOfPartitions(n_partitions)); - // check for an easy return + // check for an easy return if (n_partitions == 1) { - for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell != triangulation.end(); ++cell) - cell->set_subdomain_id (0); - return; + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell) + cell->set_subdomain_id (0); + return; } - // we decompose the domain by first - // generating the connection graph of all - // cells with their neighbors, and then - // passing this graph off to METIS. - // finally defer to the other function for - // partitioning and assigning subdomain ids + // we decompose the domain by first + // generating the connection graph of all + // cells with their neighbors, and then + // passing this graph off to METIS. + // finally defer to the other function for + // partitioning and assigning subdomain ids SparsityPattern cell_connectivity; get_face_connectivity_of_cells (triangulation, cell_connectivity); partition_triangulation (n_partitions, - cell_connectivity, - triangulation); + cell_connectivity, + triangulation); } @@ -1033,45 +1033,45 @@ namespace GridTools template void partition_triangulation (const unsigned int n_partitions, - const SparsityPattern &cell_connection_graph, - Triangulation &triangulation) + const SparsityPattern &cell_connection_graph, + Triangulation &triangulation) { Assert ((dynamic_cast*> - (&triangulation) - == 0), - ExcMessage ("Objects of type parallel::distributed::Triangulation " - "are already partitioned implicitly and can not be " - "partitioned again explicitly.")); + (&triangulation) + == 0), + ExcMessage ("Objects of type parallel::distributed::Triangulation " + "are already partitioned implicitly and can not be " + "partitioned again explicitly.")); Assert (n_partitions > 0, ExcInvalidNumberOfPartitions(n_partitions)); Assert (cell_connection_graph.n_rows() == triangulation.n_active_cells(), - ExcMessage ("Connectivity graph has wrong size")); + ExcMessage ("Connectivity graph has wrong size")); Assert (cell_connection_graph.n_cols() == triangulation.n_active_cells(), - ExcMessage ("Connectivity graph has wrong size")); + ExcMessage ("Connectivity graph has wrong size")); - // check for an easy return + // check for an easy return if (n_partitions == 1) { - for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell != triangulation.end(); ++cell) - cell->set_subdomain_id (0); - return; + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell) + cell->set_subdomain_id (0); + return; } - // partition this connection graph and get - // back a vector of indices, one per degree - // of freedom (which is associated with a - // cell) + // partition this connection graph and get + // back a vector of indices, one per degree + // of freedom (which is associated with a + // cell) std::vector partition_indices (triangulation.n_active_cells()); SparsityTools::partition (cell_connection_graph, n_partitions, partition_indices); - // finally loop over all cells and set the - // subdomain ids + // finally loop over all cells and set the + // subdomain ids std::vector dof_indices(1); unsigned int index = 0; for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell != triangulation.end(); ++cell, ++index) + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell, ++index) cell->set_subdomain_id (partition_indices[index]); } @@ -1080,15 +1080,15 @@ namespace GridTools template void get_subdomain_association (const Triangulation &triangulation, - std::vector &subdomain) + std::vector &subdomain) { Assert (subdomain.size() == triangulation.n_active_cells(), - ExcDimensionMismatch (subdomain.size(), - triangulation.n_active_cells())); + ExcDimensionMismatch (subdomain.size(), + triangulation.n_active_cells())); unsigned int index = 0; for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell!=triangulation.end(); ++cell, ++index) + cell = triangulation.begin_active(); + cell!=triangulation.end(); ++cell, ++index) subdomain[index] = cell->subdomain_id(); Assert (index == subdomain.size(), ExcInternalError()); @@ -1100,14 +1100,14 @@ namespace GridTools unsigned int count_cells_with_subdomain_association (const Triangulation &triangulation, - const types::subdomain_id_t subdomain) + const types::subdomain_id_t subdomain) { unsigned int count = 0; for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); - cell!=triangulation.end(); ++cell) + cell = triangulation.begin_active(); + cell!=triangulation.end(); ++cell) if (cell->subdomain_id() == subdomain) - ++count; + ++count; return count; } @@ -1116,29 +1116,29 @@ namespace GridTools template std::list > + typename Container::cell_iterator> > get_finest_common_cells (const Container &mesh_1, - const Container &mesh_2) + const Container &mesh_2) { Assert (have_same_coarse_mesh (mesh_1, mesh_2), - ExcMessage ("The two containers must be represent triangulations that " - "have the same coarse meshes")); - - // the algorithm goes as follows: - // first, we fill a list with pairs - // of iterators common to the two - // meshes on the coarsest - // level. then we traverse the - // list; each time, we find a pair - // of iterators for which both - // correspond to non-active cells, - // we delete this item and push the - // pairs of iterators to their - // children to the back. if these - // again both correspond to - // non-active cells, we will get to - // the later on for further - // consideration + ExcMessage ("The two containers must be represent triangulations that " + "have the same coarse meshes")); + + // the algorithm goes as follows: + // first, we fill a list with pairs + // of iterators common to the two + // meshes on the coarsest + // level. then we traverse the + // list; each time, we find a pair + // of iterators for which both + // correspond to non-active cells, + // we delete this item and push the + // pairs of iterators to their + // children to the back. if these + // again both correspond to + // non-active cells, we will get to + // the later on for further + // consideration typedef std::list > @@ -1146,62 +1146,62 @@ namespace GridTools CellList cell_list; - // first push the coarse level cells + // first push the coarse level cells typename Container::cell_iterator cell_1 = mesh_1.begin(0), cell_2 = mesh_2.begin(0); for (; cell_1 != mesh_1.end(0); ++cell_1, ++cell_2) cell_list.push_back (std::make_pair (cell_1, cell_2)); - // then traverse list as described - // above + // then traverse list as described + // above typename CellList::iterator cell_pair = cell_list.begin(); while (cell_pair != cell_list.end()) { - // if both cells in this pair - // have children, then erase - // this element and push their - // children instead - if (cell_pair->first->has_children() - && - cell_pair->second->has_children()) - { - Assert(cell_pair->first->refinement_case()== - cell_pair->second->refinement_case(), ExcNotImplemented()); - for (unsigned int c=0; cfirst->n_children(); ++c) - cell_list.push_back (std::make_pair (cell_pair->first->child(c), - cell_pair->second->child(c))); - - // erasing an iterator - // keeps other iterators - // valid, so already - // advance the present - // iterator by one and then - // delete the element we've - // visited before - const typename CellList::iterator previous_cell_pair = cell_pair; - ++cell_pair; - - cell_list.erase (previous_cell_pair); - } - else - // both cells are active, do - // nothing - ++cell_pair; + // if both cells in this pair + // have children, then erase + // this element and push their + // children instead + if (cell_pair->first->has_children() + && + cell_pair->second->has_children()) + { + Assert(cell_pair->first->refinement_case()== + cell_pair->second->refinement_case(), ExcNotImplemented()); + for (unsigned int c=0; cfirst->n_children(); ++c) + cell_list.push_back (std::make_pair (cell_pair->first->child(c), + cell_pair->second->child(c))); + + // erasing an iterator + // keeps other iterators + // valid, so already + // advance the present + // iterator by one and then + // delete the element we've + // visited before + const typename CellList::iterator previous_cell_pair = cell_pair; + ++cell_pair; + + cell_list.erase (previous_cell_pair); + } + else + // both cells are active, do + // nothing + ++cell_pair; } - // just to make sure everything is ok, - // validate that all pairs have at least one - // active iterator or have different - // refinement_cases + // just to make sure everything is ok, + // validate that all pairs have at least one + // active iterator or have different + // refinement_cases for (cell_pair = cell_list.begin(); cell_pair != cell_list.end(); ++cell_pair) Assert (cell_pair->first->active() - || - cell_pair->second->active() - || - (cell_pair->first->refinement_case() - != cell_pair->second->refinement_case()), - ExcInternalError()); + || + cell_pair->second->active() + || + (cell_pair->first->refinement_case() + != cell_pair->second->refinement_case()), + ExcInternalError()); return cell_list; } @@ -1209,29 +1209,29 @@ namespace GridTools template bool have_same_coarse_mesh (const Triangulation &mesh_1, - const Triangulation &mesh_2) + const Triangulation &mesh_2) { - // make sure the two meshes have - // the same number of coarse cells + // make sure the two meshes have + // the same number of coarse cells if (mesh_1.n_cells (0) != mesh_2.n_cells (0)) return false; - // if so, also make sure they have - // the same vertices on the cells - // of the coarse mesh + // if so, also make sure they have + // the same vertices on the cells + // of the coarse mesh typename Triangulation::cell_iterator cell_1 = mesh_1.begin(0), cell_2 = mesh_2.begin(0), endc = mesh_1.end(0); for (; cell_1!=endc; ++cell_1, ++cell_2) for (unsigned int v=0; v::vertices_per_cell; ++v) - if (cell_1->vertex(v) != cell_2->vertex(v)) - return false; + if (cell_1->vertex(v) != cell_2->vertex(v)) + return false; - // if we've gotten through all - // this, then the meshes really - // seem to have a common coarse - // mesh + // if we've gotten through all + // this, then the meshes really + // seem to have a common coarse + // mesh return true; } @@ -1240,10 +1240,10 @@ namespace GridTools template bool have_same_coarse_mesh (const Container &mesh_1, - const Container &mesh_2) + const Container &mesh_2) { return have_same_coarse_mesh (mesh_1.get_tria(), - mesh_2.get_tria()); + mesh_2.get_tria()); } @@ -1254,10 +1254,10 @@ namespace GridTools { double min_diameter = triangulation.begin_active()->diameter(); for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); cell != triangulation.end(); - ++cell) + cell = triangulation.begin_active(); cell != triangulation.end(); + ++cell) min_diameter = std::min (min_diameter, - cell->diameter()); + cell->diameter()); return min_diameter; } @@ -1269,10 +1269,10 @@ namespace GridTools { double max_diameter = triangulation.begin_active()->diameter(); for (typename Triangulation::active_cell_iterator - cell = triangulation.begin_active(); cell != triangulation.end(); - ++cell) + cell = triangulation.begin_active(); cell != triangulation.end(); + ++cell) max_diameter = std::max (max_diameter, - cell->diameter()); + cell->diameter()); return max_diameter; } @@ -1281,48 +1281,48 @@ namespace GridTools template void create_union_triangulation (const Triangulation &triangulation_1, - const Triangulation &triangulation_2, - Triangulation &result) + const Triangulation &triangulation_2, + Triangulation &result) { Assert (have_same_coarse_mesh (triangulation_1, triangulation_2), - ExcMessage ("The two input triangulations are not derived from " - "the same coarse mesh as required.")); - - // first copy triangulation_1, and - // then do as many iterations as - // there are levels in - // triangulation_2 to refine - // additional cells. since this is - // the maximum number of - // refinements to get from the - // coarse grid to triangulation_2, - // it is clear that this is also - // the maximum number of - // refinements to get from any cell - // on triangulation_1 to - // triangulation_2 + ExcMessage ("The two input triangulations are not derived from " + "the same coarse mesh as required.")); + + // first copy triangulation_1, and + // then do as many iterations as + // there are levels in + // triangulation_2 to refine + // additional cells. since this is + // the maximum number of + // refinements to get from the + // coarse grid to triangulation_2, + // it is clear that this is also + // the maximum number of + // refinements to get from any cell + // on triangulation_1 to + // triangulation_2 result.clear (); result.copy_triangulation (triangulation_1); for (unsigned int iteration=0; iteration > intergrid_map; - intergrid_map.make_mapping (result, triangulation_2); - - bool any_cell_flagged = false; - for (typename Triangulation::active_cell_iterator - result_cell = result.begin_active(); - result_cell != result.end(); ++result_cell) - if (intergrid_map[result_cell]->has_children()) - { - any_cell_flagged = true; - result_cell->set_refine_flag (); - } - - if (any_cell_flagged == false) - break; - else - result.execute_coarsening_and_refinement(); + InterGridMap > intergrid_map; + intergrid_map.make_mapping (result, triangulation_2); + + bool any_cell_flagged = false; + for (typename Triangulation::active_cell_iterator + result_cell = result.begin_active(); + result_cell != result.end(); ++result_cell) + if (intergrid_map[result_cell]->has_children()) + { + any_cell_flagged = true; + result_cell->set_refine_flag (); + } + + if (any_cell_flagged == false) + break; + else + result.execute_coarsening_and_refinement(); } } @@ -1331,526 +1331,526 @@ namespace GridTools { namespace FixUpDistortedChildCells { - // compute the mean square - // deviation of the alternating - // forms of the children of the - // given object from that of - // the object itself. for - // objects with - // structdim==spacedim, the - // alternating form is the - // determinant of the jacobian, - // whereas for faces with - // structdim==spacedim-1, the - // alternating form is the - // (signed and scaled) normal - // vector - // - // this average square - // deviation is computed for an - // object where the center node - // has been replaced by the - // second argument to this - // function + // compute the mean square + // deviation of the alternating + // forms of the children of the + // given object from that of + // the object itself. for + // objects with + // structdim==spacedim, the + // alternating form is the + // determinant of the jacobian, + // whereas for faces with + // structdim==spacedim-1, the + // alternating form is the + // (signed and scaled) normal + // vector + // + // this average square + // deviation is computed for an + // object where the center node + // has been replaced by the + // second argument to this + // function template double objective_function (const Iterator &object, - const Point &object_mid_point) + const Point &object_mid_point) { - const unsigned int structdim = Iterator::AccessorType::structure_dimension; - Assert (spacedim == Iterator::AccessorType::dimension, - ExcInternalError()); - - // everything below is wrong - // if not for the following - // condition - Assert (object->refinement_case() == RefinementCase::isotropic_refinement, - ExcNotImplemented()); - // first calculate the - // average alternating form - // for the parent cell/face - Point parent_vertices - [GeometryInfo::vertices_per_cell]; - Tensor parent_alternating_forms - [GeometryInfo::vertices_per_cell]; - - for (unsigned int i=0; i::vertices_per_cell; ++i) - parent_vertices[i] = object->vertex(i); - - GeometryInfo::alternating_form_at_vertices (parent_vertices, - parent_alternating_forms); - - const Tensor - average_parent_alternating_form - = std::accumulate (&parent_alternating_forms[0], - &parent_alternating_forms[GeometryInfo::vertices_per_cell], - Tensor()); - - // now do the same - // computation for the - // children where we use the - // given location for the - // object mid point instead of - // the one the triangulation - // currently reports - Point child_vertices - [GeometryInfo::max_children_per_cell] - [GeometryInfo::vertices_per_cell]; - Tensor child_alternating_forms - [GeometryInfo::max_children_per_cell] - [GeometryInfo::vertices_per_cell]; - - for (unsigned int c=0; cn_children(); ++c) - for (unsigned int i=0; i::vertices_per_cell; ++i) - child_vertices[c][i] = object->child(c)->vertex(i); - - // replace mid-object - // vertex. note that for - // child i, the mid-object - // vertex happens to have the - // number - // max_children_per_cell-i - for (unsigned int c=0; cn_children(); ++c) - child_vertices[c][GeometryInfo::max_children_per_cell-c-1] - = object_mid_point; - - for (unsigned int c=0; cn_children(); ++c) - GeometryInfo::alternating_form_at_vertices (child_vertices[c], - child_alternating_forms[c]); - - // on a uniformly refined - // hypercube object, the child - // alternating forms should - // all be smaller by a factor - // of 2^structdim than the - // ones of the parent. as a - // consequence, we'll use the - // squared deviation from - // this ideal value as an - // objective function - double objective = 0; - for (unsigned int c=0; cn_children(); ++c) - for (unsigned int i=0; i::vertices_per_cell; ++i) - objective += (child_alternating_forms[c][i] - - average_parent_alternating_form/std::pow(2.,1.*structdim)) - .norm_square(); - - return objective; + const unsigned int structdim = Iterator::AccessorType::structure_dimension; + Assert (spacedim == Iterator::AccessorType::dimension, + ExcInternalError()); + + // everything below is wrong + // if not for the following + // condition + Assert (object->refinement_case() == RefinementCase::isotropic_refinement, + ExcNotImplemented()); + // first calculate the + // average alternating form + // for the parent cell/face + Point parent_vertices + [GeometryInfo::vertices_per_cell]; + Tensor parent_alternating_forms + [GeometryInfo::vertices_per_cell]; + + for (unsigned int i=0; i::vertices_per_cell; ++i) + parent_vertices[i] = object->vertex(i); + + GeometryInfo::alternating_form_at_vertices (parent_vertices, + parent_alternating_forms); + + const Tensor + average_parent_alternating_form + = std::accumulate (&parent_alternating_forms[0], + &parent_alternating_forms[GeometryInfo::vertices_per_cell], + Tensor()); + + // now do the same + // computation for the + // children where we use the + // given location for the + // object mid point instead of + // the one the triangulation + // currently reports + Point child_vertices + [GeometryInfo::max_children_per_cell] + [GeometryInfo::vertices_per_cell]; + Tensor child_alternating_forms + [GeometryInfo::max_children_per_cell] + [GeometryInfo::vertices_per_cell]; + + for (unsigned int c=0; cn_children(); ++c) + for (unsigned int i=0; i::vertices_per_cell; ++i) + child_vertices[c][i] = object->child(c)->vertex(i); + + // replace mid-object + // vertex. note that for + // child i, the mid-object + // vertex happens to have the + // number + // max_children_per_cell-i + for (unsigned int c=0; cn_children(); ++c) + child_vertices[c][GeometryInfo::max_children_per_cell-c-1] + = object_mid_point; + + for (unsigned int c=0; cn_children(); ++c) + GeometryInfo::alternating_form_at_vertices (child_vertices[c], + child_alternating_forms[c]); + + // on a uniformly refined + // hypercube object, the child + // alternating forms should + // all be smaller by a factor + // of 2^structdim than the + // ones of the parent. as a + // consequence, we'll use the + // squared deviation from + // this ideal value as an + // objective function + double objective = 0; + for (unsigned int c=0; cn_children(); ++c) + for (unsigned int i=0; i::vertices_per_cell; ++i) + objective += (child_alternating_forms[c][i] - + average_parent_alternating_form/std::pow(2.,1.*structdim)) + .norm_square(); + + return objective; } - /** - * Return the location of the midpoint - * of the 'f'th face (vertex) of this 1d - * object. - */ + /** + * Return the location of the midpoint + * of the 'f'th face (vertex) of this 1d + * object. + */ template Point get_face_midpoint (const Iterator &object, - const unsigned int f, - dealii::internal::int2type<1>) + const unsigned int f, + dealii::internal::int2type<1>) { - return object->vertex(f); + return object->vertex(f); } - /** - * Return the location of the midpoint - * of the 'f'th face (line) of this 2d - * object. - */ + /** + * Return the location of the midpoint + * of the 'f'th face (line) of this 2d + * object. + */ template Point get_face_midpoint (const Iterator &object, - const unsigned int f, - dealii::internal::int2type<2>) + const unsigned int f, + dealii::internal::int2type<2>) { - return object->line(f)->center(); + return object->line(f)->center(); } - /** - * Return the location of the midpoint - * of the 'f'th face (quad) of this 3d - * object. - */ + /** + * Return the location of the midpoint + * of the 'f'th face (quad) of this 3d + * object. + */ template Point get_face_midpoint (const Iterator &object, - const unsigned int f, - dealii::internal::int2type<3>) + const unsigned int f, + dealii::internal::int2type<3>) { - return object->face(f)->center(); + return object->face(f)->center(); } - /** - * Compute the minimal diameter of an - * object by looking for the minimal - * distance between the mid-points of - * its faces. This minimal diameter is - * used to determine the step length - * for our grid cell improvement - * algorithm, and it should be small - * enough that the point moves around - * within the cell even if it is highly - * elongated -- thus, the diameter of - * the object is not a good measure, - * while the minimal diameter is. Note - * that the algorithm below works for - * both cells that are long rectangles - * with parallel sides where the - * nearest distance is between opposite - * edges as well as highly slanted - * parallelograms where the shortest - * distance is between neighboring - * edges. - */ + /** + * Compute the minimal diameter of an + * object by looking for the minimal + * distance between the mid-points of + * its faces. This minimal diameter is + * used to determine the step length + * for our grid cell improvement + * algorithm, and it should be small + * enough that the point moves around + * within the cell even if it is highly + * elongated -- thus, the diameter of + * the object is not a good measure, + * while the minimal diameter is. Note + * that the algorithm below works for + * both cells that are long rectangles + * with parallel sides where the + * nearest distance is between opposite + * edges as well as highly slanted + * parallelograms where the shortest + * distance is between neighboring + * edges. + */ template double minimal_diameter (const Iterator &object) { - const unsigned int - structdim = Iterator::AccessorType::structure_dimension; - - double diameter = object->diameter(); - for (unsigned int f=0; - f::faces_per_cell; - ++f) - for (unsigned int e=f+1; - e::faces_per_cell; - ++e) - diameter = std::min (diameter, - get_face_midpoint - (object, f, - dealii::internal::int2type()) - .distance (get_face_midpoint - (object, - e, - dealii::internal::int2type()))); - - return diameter; + const unsigned int + structdim = Iterator::AccessorType::structure_dimension; + + double diameter = object->diameter(); + for (unsigned int f=0; + f::faces_per_cell; + ++f) + for (unsigned int e=f+1; + e::faces_per_cell; + ++e) + diameter = std::min (diameter, + get_face_midpoint + (object, f, + dealii::internal::int2type()) + .distance (get_face_midpoint + (object, + e, + dealii::internal::int2type()))); + + return diameter; } - /** - * Try to fix up a single cell. Return - * whether we succeeded with this. - * - * The second argument indicates - * whether we need to respect the - * manifold/boundary on which this - * object lies when moving around its - * mid-point. - */ + /** + * Try to fix up a single cell. Return + * whether we succeeded with this. + * + * The second argument indicates + * whether we need to respect the + * manifold/boundary on which this + * object lies when moving around its + * mid-point. + */ template bool fix_up_object (const Iterator &object, - const bool respect_manifold) + const bool respect_manifold) { - const Boundary - *manifold = (respect_manifold ? - &object->get_boundary() : - 0); - - const unsigned int structdim = Iterator::AccessorType::structure_dimension; - const unsigned int spacedim = Iterator::AccessorType::space_dimension; - - // right now we can only deal - // with cells that have been - // refined isotropically - // because that is the only - // case where we have a cell - // mid-point that can be moved - // around without having to - // consider boundary - // information - Assert (object->has_children(), ExcInternalError()); - Assert (object->refinement_case() == RefinementCase::isotropic_refinement, - ExcNotImplemented()); - - // get the current location of - // the object mid-vertex: - Point object_mid_point - = object->child(0)->vertex (GeometryInfo::max_children_per_cell-1); - - // now do a few steepest descent - // steps to reduce the objective - // function. compute the diameter in - // the helper function above - unsigned int iteration = 0; - const double diameter = minimal_diameter (object); - - // current value of objective - // function and initial delta - double current_value = objective_function (object, object_mid_point); - double initial_delta = 0; - - do - { - // choose a step length - // that is initially 1/4 - // of the child objects' - // diameter, and a sequence - // whose sum does not - // converge (to avoid - // premature termination of - // the iteration) - const double step_length = diameter / 4 / (iteration + 1); - - // compute the objective - // function's derivative using a - // two-sided difference formula - // with eps=step_length/10 - Tensor<1,spacedim> gradient; - for (unsigned int d=0; d h; - h[d] = eps/2; - - if (respect_manifold == false) - gradient[d] - = ((objective_function (object, object_mid_point + h) - - - objective_function (object, object_mid_point - h)) - / - eps); - else - gradient[d] - = ((objective_function (object, - manifold->project_to_surface(object, - object_mid_point + h)) - - - objective_function (object, - manifold->project_to_surface(object, - object_mid_point - h))) - / - eps); - } - - // sometimes, the - // (unprojected) gradient - // is perpendicular to - // the manifold, but we - // can't go there if - // respect_manifold==true. in - // that case, gradient=0, - // and we simply need to - // quite the loop here - if (gradient.norm() == 0) - break; - - // so we need to go in - // direction -gradient. the - // optimal value of the - // objective function is - // zero, so assuming that - // the model is quadratic - // we would have to go - // -2*val/||gradient|| in - // this direction, make - // sure we go at most - // step_length into this - // direction - object_mid_point -= std::min(2 * current_value / (gradient*gradient), - step_length / gradient.norm()) * - gradient; - - if (respect_manifold == true) - object_mid_point = manifold->project_to_surface(object, - object_mid_point); - - // compute current value of the - // objective function - const double previous_value = current_value; - current_value = objective_function (object, object_mid_point); - - if (iteration == 0) - initial_delta = (previous_value - current_value); - - // stop if we aren't moving much - // any more - if ((iteration >= 1) && - ((previous_value - current_value < 0) - || - (std::fabs (previous_value - current_value) - < - 0.001 * initial_delta))) - break; - - ++iteration; - } - while (iteration < 20); - - // verify that the new - // location is indeed better - // than the one before. check - // this by comparing whether - // the minimum value of the - // products of parent and - // child alternating forms is - // positive. for cells this - // means that the - // determinants have the same - // sign, for faces that the - // face normals of parent and - // children point in the same - // general direction - double old_min_product, new_min_product; - - Point parent_vertices - [GeometryInfo::vertices_per_cell]; - for (unsigned int i=0; i::vertices_per_cell; ++i) - parent_vertices[i] = object->vertex(i); - - Tensor parent_alternating_forms - [GeometryInfo::vertices_per_cell]; - GeometryInfo::alternating_form_at_vertices (parent_vertices, - parent_alternating_forms); - - Point child_vertices - [GeometryInfo::max_children_per_cell] - [GeometryInfo::vertices_per_cell]; - - for (unsigned int c=0; cn_children(); ++c) - for (unsigned int i=0; i::vertices_per_cell; ++i) - child_vertices[c][i] = object->child(c)->vertex(i); - - Tensor child_alternating_forms - [GeometryInfo::max_children_per_cell] - [GeometryInfo::vertices_per_cell]; - - for (unsigned int c=0; cn_children(); ++c) - GeometryInfo::alternating_form_at_vertices (child_vertices[c], - child_alternating_forms[c]); - - old_min_product = child_alternating_forms[0][0] * parent_alternating_forms[0]; - for (unsigned int c=0; cn_children(); ++c) - for (unsigned int i=0; i::vertices_per_cell; ++i) - for (unsigned int j=0; j::vertices_per_cell; ++j) - old_min_product = std::min (old_min_product, - child_alternating_forms[c][i] * - parent_alternating_forms[j]); - - // for the new minimum value, - // replace mid-object - // vertex. note that for child - // i, the mid-object vertex - // happens to have the number - // max_children_per_cell-i - for (unsigned int c=0; cn_children(); ++c) - child_vertices[c][GeometryInfo::max_children_per_cell-c-1] - = object_mid_point; - - for (unsigned int c=0; cn_children(); ++c) - GeometryInfo::alternating_form_at_vertices (child_vertices[c], - child_alternating_forms[c]); - - new_min_product = child_alternating_forms[0][0] * parent_alternating_forms[0]; - for (unsigned int c=0; cn_children(); ++c) - for (unsigned int i=0; i::vertices_per_cell; ++i) - for (unsigned int j=0; j::vertices_per_cell; ++j) - new_min_product = std::min (new_min_product, - child_alternating_forms[c][i] * - parent_alternating_forms[j]); - - // if new minimum value is - // better than before, then set the - // new mid point. otherwise - // return this object as one of - // those that can't apparently - // be fixed - if (new_min_product >= old_min_product) - object->child(0)->vertex (GeometryInfo::max_children_per_cell-1) - = object_mid_point; - - // return whether after this - // operation we have an object that - // is well oriented - return (std::max (new_min_product, old_min_product) > 0); + const Boundary + *manifold = (respect_manifold ? + &object->get_boundary() : + 0); + + const unsigned int structdim = Iterator::AccessorType::structure_dimension; + const unsigned int spacedim = Iterator::AccessorType::space_dimension; + + // right now we can only deal + // with cells that have been + // refined isotropically + // because that is the only + // case where we have a cell + // mid-point that can be moved + // around without having to + // consider boundary + // information + Assert (object->has_children(), ExcInternalError()); + Assert (object->refinement_case() == RefinementCase::isotropic_refinement, + ExcNotImplemented()); + + // get the current location of + // the object mid-vertex: + Point object_mid_point + = object->child(0)->vertex (GeometryInfo::max_children_per_cell-1); + + // now do a few steepest descent + // steps to reduce the objective + // function. compute the diameter in + // the helper function above + unsigned int iteration = 0; + const double diameter = minimal_diameter (object); + + // current value of objective + // function and initial delta + double current_value = objective_function (object, object_mid_point); + double initial_delta = 0; + + do + { + // choose a step length + // that is initially 1/4 + // of the child objects' + // diameter, and a sequence + // whose sum does not + // converge (to avoid + // premature termination of + // the iteration) + const double step_length = diameter / 4 / (iteration + 1); + + // compute the objective + // function's derivative using a + // two-sided difference formula + // with eps=step_length/10 + Tensor<1,spacedim> gradient; + for (unsigned int d=0; d h; + h[d] = eps/2; + + if (respect_manifold == false) + gradient[d] + = ((objective_function (object, object_mid_point + h) + - + objective_function (object, object_mid_point - h)) + / + eps); + else + gradient[d] + = ((objective_function (object, + manifold->project_to_surface(object, + object_mid_point + h)) + - + objective_function (object, + manifold->project_to_surface(object, + object_mid_point - h))) + / + eps); + } + + // sometimes, the + // (unprojected) gradient + // is perpendicular to + // the manifold, but we + // can't go there if + // respect_manifold==true. in + // that case, gradient=0, + // and we simply need to + // quite the loop here + if (gradient.norm() == 0) + break; + + // so we need to go in + // direction -gradient. the + // optimal value of the + // objective function is + // zero, so assuming that + // the model is quadratic + // we would have to go + // -2*val/||gradient|| in + // this direction, make + // sure we go at most + // step_length into this + // direction + object_mid_point -= std::min(2 * current_value / (gradient*gradient), + step_length / gradient.norm()) * + gradient; + + if (respect_manifold == true) + object_mid_point = manifold->project_to_surface(object, + object_mid_point); + + // compute current value of the + // objective function + const double previous_value = current_value; + current_value = objective_function (object, object_mid_point); + + if (iteration == 0) + initial_delta = (previous_value - current_value); + + // stop if we aren't moving much + // any more + if ((iteration >= 1) && + ((previous_value - current_value < 0) + || + (std::fabs (previous_value - current_value) + < + 0.001 * initial_delta))) + break; + + ++iteration; + } + while (iteration < 20); + + // verify that the new + // location is indeed better + // than the one before. check + // this by comparing whether + // the minimum value of the + // products of parent and + // child alternating forms is + // positive. for cells this + // means that the + // determinants have the same + // sign, for faces that the + // face normals of parent and + // children point in the same + // general direction + double old_min_product, new_min_product; + + Point parent_vertices + [GeometryInfo::vertices_per_cell]; + for (unsigned int i=0; i::vertices_per_cell; ++i) + parent_vertices[i] = object->vertex(i); + + Tensor parent_alternating_forms + [GeometryInfo::vertices_per_cell]; + GeometryInfo::alternating_form_at_vertices (parent_vertices, + parent_alternating_forms); + + Point child_vertices + [GeometryInfo::max_children_per_cell] + [GeometryInfo::vertices_per_cell]; + + for (unsigned int c=0; cn_children(); ++c) + for (unsigned int i=0; i::vertices_per_cell; ++i) + child_vertices[c][i] = object->child(c)->vertex(i); + + Tensor child_alternating_forms + [GeometryInfo::max_children_per_cell] + [GeometryInfo::vertices_per_cell]; + + for (unsigned int c=0; cn_children(); ++c) + GeometryInfo::alternating_form_at_vertices (child_vertices[c], + child_alternating_forms[c]); + + old_min_product = child_alternating_forms[0][0] * parent_alternating_forms[0]; + for (unsigned int c=0; cn_children(); ++c) + for (unsigned int i=0; i::vertices_per_cell; ++i) + for (unsigned int j=0; j::vertices_per_cell; ++j) + old_min_product = std::min (old_min_product, + child_alternating_forms[c][i] * + parent_alternating_forms[j]); + + // for the new minimum value, + // replace mid-object + // vertex. note that for child + // i, the mid-object vertex + // happens to have the number + // max_children_per_cell-i + for (unsigned int c=0; cn_children(); ++c) + child_vertices[c][GeometryInfo::max_children_per_cell-c-1] + = object_mid_point; + + for (unsigned int c=0; cn_children(); ++c) + GeometryInfo::alternating_form_at_vertices (child_vertices[c], + child_alternating_forms[c]); + + new_min_product = child_alternating_forms[0][0] * parent_alternating_forms[0]; + for (unsigned int c=0; cn_children(); ++c) + for (unsigned int i=0; i::vertices_per_cell; ++i) + for (unsigned int j=0; j::vertices_per_cell; ++j) + new_min_product = std::min (new_min_product, + child_alternating_forms[c][i] * + parent_alternating_forms[j]); + + // if new minimum value is + // better than before, then set the + // new mid point. otherwise + // return this object as one of + // those that can't apparently + // be fixed + if (new_min_product >= old_min_product) + object->child(0)->vertex (GeometryInfo::max_children_per_cell-1) + = object_mid_point; + + // return whether after this + // operation we have an object that + // is well oriented + return (std::max (new_min_product, old_min_product) > 0); } void fix_up_faces (const dealii::Triangulation<1,1>::cell_iterator &, - dealii::internal::int2type<1>, - dealii::internal::int2type<1>) + dealii::internal::int2type<1>, + dealii::internal::int2type<1>) { - // nothing to do for the faces of - // cells in 1d + // nothing to do for the faces of + // cells in 1d } - - - // possibly fix up the faces of - // a cell by moving around its - // mid-points + + + // possibly fix up the faces of + // a cell by moving around its + // mid-points template void fix_up_faces (const typename dealii::Triangulation::cell_iterator &cell, - dealii::internal::int2type, - dealii::internal::int2type) + dealii::internal::int2type, + dealii::internal::int2type) { - // see if we first can fix up - // some of the faces of this - // object. we can mess with - // faces if and only if it is - // not at the boundary (since - // otherwise the location of - // the face mid-point has been - // determined by the boundary - // object) and if the - // neighboring cell is not even - // more refined than we are - // (since in that case the - // sub-faces have themselves - // children that we can't move - // around any more). however, - // the latter case shouldn't - // happen anyway: if the - // current face is distorted - // but the neighbor is even - // more refined, then the face - // had been deformed before - // already, and had been - // ignored at the time; we - // should then also be able to - // ignore it this time as well - for (unsigned int f=0; f::faces_per_cell; ++f) - { - Assert (cell->face(f)->has_children(), ExcInternalError()); - Assert (cell->face(f)->refinement_case() == - RefinementCase::isotropic_refinement, - ExcInternalError()); - - bool subface_is_more_refined = false; - for (unsigned int g=0; g::max_children_per_face; ++g) - if (cell->face(f)->child(g)->has_children()) - { - subface_is_more_refined = true; - break; - } - - if (subface_is_more_refined == true) - continue; - - // so, now we finally know - // that we can do something - // about this face - fix_up_object (cell->face(f), cell->at_boundary(f)); - } + // see if we first can fix up + // some of the faces of this + // object. we can mess with + // faces if and only if it is + // not at the boundary (since + // otherwise the location of + // the face mid-point has been + // determined by the boundary + // object) and if the + // neighboring cell is not even + // more refined than we are + // (since in that case the + // sub-faces have themselves + // children that we can't move + // around any more). however, + // the latter case shouldn't + // happen anyway: if the + // current face is distorted + // but the neighbor is even + // more refined, then the face + // had been deformed before + // already, and had been + // ignored at the time; we + // should then also be able to + // ignore it this time as well + for (unsigned int f=0; f::faces_per_cell; ++f) + { + Assert (cell->face(f)->has_children(), ExcInternalError()); + Assert (cell->face(f)->refinement_case() == + RefinementCase::isotropic_refinement, + ExcInternalError()); + + bool subface_is_more_refined = false; + for (unsigned int g=0; g::max_children_per_face; ++g) + if (cell->face(f)->child(g)->has_children()) + { + subface_is_more_refined = true; + break; + } + + if (subface_is_more_refined == true) + continue; + + // so, now we finally know + // that we can do something + // about this face + fix_up_object (cell->face(f), cell->at_boundary(f)); + } } - - + + } } @@ -1861,33 +1861,33 @@ namespace GridTools typename Triangulation::DistortedCellList fix_up_distorted_child_cells (const typename Triangulation::DistortedCellList &distorted_cells, - Triangulation &/*triangulation*/) + Triangulation &/*triangulation*/) { typename Triangulation::DistortedCellList unfixable_subset; - // loop over all cells that we have - // to fix up + // loop over all cells that we have + // to fix up for (typename std::list::cell_iterator>::const_iterator - cell_ptr = distorted_cells.distorted_cells.begin(); - cell_ptr != distorted_cells.distorted_cells.end(); ++cell_ptr) + cell_ptr = distorted_cells.distorted_cells.begin(); + cell_ptr != distorted_cells.distorted_cells.end(); ++cell_ptr) { - const typename Triangulation::cell_iterator - cell = *cell_ptr; - - internal::FixUpDistortedChildCells - ::fix_up_faces (cell, - dealii::internal::int2type(), - dealii::internal::int2type()); - - // fix up the object. we need to - // respect the manifold if the cell is - // embedded in a higher dimensional - // space; otherwise, like a hex in 3d, - // every point within the cell interior - // is fair game - if (! internal::FixUpDistortedChildCells::fix_up_object (cell, - (dim < spacedim))) - unfixable_subset.distorted_cells.push_back (cell); + const typename Triangulation::cell_iterator + cell = *cell_ptr; + + internal::FixUpDistortedChildCells + ::fix_up_faces (cell, + dealii::internal::int2type(), + dealii::internal::int2type()); + + // fix up the object. we need to + // respect the manifold if the cell is + // embedded in a higher dimensional + // space; otherwise, like a hex in 3d, + // every point within the cell interior + // is fair game + if (! internal::FixUpDistortedChildCells::fix_up_object (cell, + (dim < spacedim))) + unfixable_subset.distorted_cells.push_back (cell); } return unfixable_subset; @@ -1897,10 +1897,10 @@ namespace GridTools template