From: Wolfgang Bangerth Date: Wed, 10 Mar 2010 01:06:27 +0000 (+0000) Subject: Clarify comment. X-Git-Tag: v8.0.0~6346 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6174c8ea0946c7d22324256fe974a3b5cd95869;p=dealii.git Clarify comment. git-svn-id: https://svn.dealii.org/trunk@20782 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/numerics/vectors.templates.h b/deal.II/deal.II/include/numerics/vectors.templates.h index 4022144672..cd60005e97 100644 --- a/deal.II/deal.II/include/numerics/vectors.templates.h +++ b/deal.II/deal.II/include/numerics/vectors.templates.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name: $ // -// Copyright (C) 2005, 2006, 2007, 2008, 2009 by the deal.II authors +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -62,11 +62,11 @@ void VectorTools::interpolate (const Mapping Assert (dof.get_fe().n_components() == function.n_components, ExcDimensionMismatch(dof.get_fe().n_components(), function.n_components)); - + const hp::FECollection fe (dof.get_fe()); const unsigned int n_components = fe.n_components(); const bool fe_is_system = (n_components != 1); - + typename DH::active_cell_iterator cell = dof.begin_active(), endc = dof.end(); @@ -92,11 +92,11 @@ void VectorTools::interpolate (const Mapping Assert (unit_support_points[fe_index].size() != 0, ExcNonInterpolatingFE()); } - - // Find the support points + + // Find the support points // on a cell that - // are multiply mentioned in + // are multiply mentioned in // unit_support_points. // Mark the first representative // of each multiply mentioned @@ -108,7 +108,7 @@ void VectorTools::interpolate (const Mapping // the following vector collects all dofs i, // 0<=i std::vector > dof_to_rep_index_table(fe.size()); std::vector n_rep_points (fe.size(), 0); - + for (unsigned int fe_index=0; fe_index // support points that are placed // one after the other. for (unsigned int j=dofs_of_rep_points[fe_index].size(); j>0; --j) - if (unit_support_points[fe_index][i] + if (unit_support_points[fe_index][i] == unit_support_points[fe_index][dofs_of_rep_points[fe_index][j-1]]) { dof_to_rep_index_table[fe_index].push_back(j-1); representative=false; break; } - + if (representative) { // rep_index=dofs_of_rep_points.size() @@ -155,12 +155,12 @@ void VectorTools::interpolate (const Mapping Assert(dof_to_rep_index_table[fe_index].size()==fe[fe_index].dofs_per_cell, ExcInternalError()); } - + const unsigned int max_rep_points = *std::max_element (n_rep_points.begin(), n_rep_points.end()); std::vector dofs_on_cell (fe.max_dofs_per_cell()); std::vector > rep_points (max_rep_points); - + // get space for the values of the // function at the rep support points. // @@ -179,21 +179,21 @@ void VectorTools::interpolate (const Mapping // Transformed support points are computed by // FEValues hp::MappingCollection mapping_collection (mapping); - + hp::FEValues fe_values (mapping_collection, fe, support_quadrature, update_quadrature_points); - + for (; cell!=endc; ++cell) { const unsigned int fe_index = cell->active_fe_index(); - + // for each cell: // get location of finite element // support_points fe_values.reinit(cell); const std::vector >& support_points = fe_values.get_present_fe_values().get_quadrature_points(); - + // pick out the representative // support points rep_points.resize (dofs_of_rep_points[fe_index].size()); @@ -201,7 +201,7 @@ void VectorTools::interpolate (const Mapping rep_points[j] = support_points[dofs_of_rep_points[fe_index][j]]; // get indices of the dofs on this cell - dofs_on_cell.resize (fe[fe_index].dofs_per_cell); + dofs_on_cell.resize (fe[fe_index].dofs_per_cell); cell->get_dof_indices (dofs_on_cell); @@ -240,7 +240,7 @@ void VectorTools::interpolate (const Mapping // values to the global // vector for (unsigned int i=0; i::mapping, + interpolate(StaticMappingQ1::mapping, dof, function, vec); } @@ -273,27 +273,27 @@ VectorTools::interpolate (const DoFHandler &dof_1, std::vector touch_count (dof_2.n_dofs(), 0); std::vector local_dof_indices (dof_2.get_fe().dofs_per_cell); - + typename DoFHandler::active_cell_iterator h = dof_1.begin_active(); typename DoFHandler::active_cell_iterator l = dof_2.begin_active(); const typename DoFHandler::cell_iterator endh = dof_1.end(); - + for(; h != endh; ++h, ++l) { h->get_dof_values(data_1, cell_data_1); transfer.vmult(cell_data_2, cell_data_1); l->get_dof_indices (local_dof_indices); - + // distribute cell vector - for (unsigned int j=0; j &dof_1, { Assert (touch_count[i] != 0, ExcInternalError()); - + data_2(i) /= touch_count[i]; }; } @@ -362,7 +362,7 @@ namespace internal #else - + template void interpolate_zero_boundary_values (const dealii::DoFHandler &dof_handler, @@ -409,7 +409,7 @@ namespace internal boundary_values[face_dof_indices[i]] = 0.; } } - + #endif } } @@ -433,18 +433,18 @@ void VectorTools::project (const Mapping &mapping, Assert (vec_result.size() == dof.n_dofs(), ExcDimensionMismatch (vec_result.size(), dof.n_dofs())); - + // make up boundary values std::map boundary_values; - - if (enforce_zero_boundary == true) + + if (enforce_zero_boundary == true) // no need to project boundary // values, but enforce // homogeneous boundary values // anyway internal::VectorTools:: interpolate_zero_boundary_values (dof, boundary_values); - + else // no homogeneous boundary values if (project_to_boundary_first == true) @@ -504,7 +504,7 @@ void VectorTools::project (const Mapping &mapping, prec.initialize(mass_matrix, 1.2); // solve cg.solve (mass_matrix, vec, tmp, prec); - + // distribute solution constraints.distribute (vec); @@ -551,7 +551,7 @@ void VectorTools::create_right_hand_side (const Mapping &mappi Assert (rhs_vector.size() == dof_handler.n_dofs(), ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs())); rhs_vector = 0; - + UpdateFlags update_flags = UpdateFlags(update_values | update_quadrature_points | update_JxW_values); @@ -560,7 +560,7 @@ void VectorTools::create_right_hand_side (const Mapping &mappi const unsigned int dofs_per_cell = fe_values.dofs_per_cell, n_q_points = fe_values.n_quadrature_points, n_components = fe.n_components(); - + std::vector dofs (dofs_per_cell); Vector cell_vector (dofs_per_cell); @@ -571,42 +571,42 @@ void VectorTools::create_right_hand_side (const Mapping &mappi if (n_components==1) { std::vector rhs_values(n_q_points); - - for (; cell!=endc; ++cell) + + for (; cell!=endc; ++cell) { fe_values.reinit(cell); - + const std::vector &weights = fe_values.get_JxW_values (); rhs_function.value_list (fe_values.get_quadrature_points(), rhs_values); - + cell_vector = 0; for (unsigned int point=0; pointget_dof_indices (dofs); - + for (unsigned int i=0; i > rhs_values(n_q_points, Vector(n_components)); - - for (; cell!=endc; ++cell) + + for (; cell!=endc; ++cell) { fe_values.reinit(cell); - + const std::vector &weights = fe_values.get_JxW_values (); rhs_function.vector_value_list (fe_values.get_quadrature_points(), rhs_values); - + cell_vector = 0; // Use the faster code if the // FiniteElement is primitive @@ -617,7 +617,7 @@ void VectorTools::create_right_hand_side (const Mapping &mappi { const unsigned int component = fe.system_to_component_index(i).first; - + cell_vector(i) += rhs_values[point](component) * fe_values.shape_value(i,point) * weights[point]; @@ -638,9 +638,9 @@ void VectorTools::create_right_hand_side (const Mapping &mappi weights[point]; } } - + cell->get_dof_indices (dofs); - + for (unsigned int i=0; i x_fe_values (mapping, fe, quadrature, update_flags); const unsigned int n_components = fe.n_components(); - + std::vector dofs (fe.max_dofs_per_cell()); Vector cell_vector (fe.max_dofs_per_cell()); @@ -694,60 +694,60 @@ void VectorTools::create_right_hand_side (const hp::MappingCollection rhs_values; - - for (; cell!=endc; ++cell) + + for (; cell!=endc; ++cell) { x_fe_values.reinit(cell); const FEValues &fe_values = x_fe_values.get_present_fe_values(); - + const unsigned int dofs_per_cell = fe_values.dofs_per_cell, n_q_points = fe_values.n_quadrature_points; rhs_values.resize (n_q_points); dofs.resize (dofs_per_cell); cell_vector.reinit (dofs_per_cell); - + const std::vector &weights = fe_values.get_JxW_values (); rhs_function.value_list (fe_values.get_quadrature_points(), rhs_values); - + cell_vector = 0; for (unsigned int point=0; pointget_dof_indices (dofs); - + for (unsigned int i=0; i > rhs_values; - + for (; cell!=endc; ++cell) { x_fe_values.reinit(cell); const FEValues &fe_values = x_fe_values.get_present_fe_values(); - + const unsigned int dofs_per_cell = fe_values.dofs_per_cell, n_q_points = fe_values.n_quadrature_points; rhs_values.resize (n_q_points, Vector(n_components)); dofs.resize (dofs_per_cell); cell_vector.reinit (dofs_per_cell); - + const std::vector &weights = fe_values.get_JxW_values (); rhs_function.vector_value_list (fe_values.get_quadrature_points(), rhs_values); - + cell_vector = 0; - + // Use the faster code if the // FiniteElement is primitive if (cell->get_fe().is_primitive ()) @@ -757,7 +757,7 @@ void VectorTools::create_right_hand_side (const hp::MappingCollectionget_fe().system_to_component_index(i).first; - + cell_vector(i) += rhs_values[point](component) * fe_values.shape_value(i,point) * weights[point]; @@ -777,9 +777,9 @@ void VectorTools::create_right_hand_side (const hp::MappingCollectionget_dof_indices (dofs); - + for (unsigned int i=0; i Vector &rhs_vector) { Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping")); - create_right_hand_side(hp::StaticMappingQ1::mapping_collection, + create_right_hand_side(hp::StaticMappingQ1::mapping_collection, dof_handler, quadrature, rhs_function, rhs_vector); } @@ -813,7 +813,7 @@ void VectorTools::create_point_source_vector (const Mapping ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs())); Assert (dof_handler.get_fe().n_components() == 1, ExcMessage ("This function only works for scalar finite elements")); - + rhs_vector = 0; std::pair::active_cell_iterator, Point > @@ -858,7 +858,7 @@ void VectorTools::create_point_source_vector (const hp::MappingCollection::active_cell_iterator, Point > @@ -910,9 +910,9 @@ VectorTools::create_boundary_right_hand_side (const Mapping ExcDimensionMismatch(fe.n_components(), rhs_function.n_components)); Assert (rhs_vector.size() == dof_handler.n_dofs(), ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs())); - + rhs_vector = 0; - + UpdateFlags update_flags = UpdateFlags(update_values | update_quadrature_points | update_JxW_values); @@ -921,7 +921,7 @@ VectorTools::create_boundary_right_hand_side (const Mapping const unsigned int dofs_per_cell = fe_values.dofs_per_cell, n_q_points = fe_values.n_quadrature_points, n_components = fe.n_components(); - + std::vector dofs (dofs_per_cell); Vector cell_vector (dofs_per_cell); @@ -931,7 +931,7 @@ VectorTools::create_boundary_right_hand_side (const Mapping if (n_components==1) { std::vector rhs_values(n_q_points); - + for (; cell!=endc; ++cell) for (unsigned int face=0; face::faces_per_cell; ++face) if (cell->face(face)->at_boundary () && @@ -940,19 +940,19 @@ VectorTools::create_boundary_right_hand_side (const Mapping boundary_indicators.end())) { fe_values.reinit(cell, face); - + const std::vector &weights = fe_values.get_JxW_values (); rhs_function.value_list (fe_values.get_quadrature_points(), rhs_values); - + cell_vector = 0; for (unsigned int point=0; pointget_dof_indices (dofs); - + for (unsigned int i=0; i else { std::vector > rhs_values(n_q_points, Vector(n_components)); - - for (; cell!=endc; ++cell) + + for (; cell!=endc; ++cell) for (unsigned int face=0; face::faces_per_cell; ++face) if (cell->face(face)->at_boundary () && (boundary_indicators.find (cell->face(face)->boundary_indicator()) @@ -969,22 +969,22 @@ VectorTools::create_boundary_right_hand_side (const Mapping boundary_indicators.end())) { fe_values.reinit(cell, face); - + const std::vector &weights = fe_values.get_JxW_values (); rhs_function.vector_value_list (fe_values.get_quadrature_points(), rhs_values); - + cell_vector = 0; - + // Use the faster code if the // FiniteElement is primitive if (fe.is_primitive ()) - { + { for (unsigned int point=0; point weights[point]; } } - + cell->get_dof_indices (dofs); - + for (unsigned int i=0; i x_fe_values (mapping, fe, quadrature, update_flags); const unsigned int n_components = fe.n_components(); - + std::vector dofs (fe.max_dofs_per_cell()); Vector cell_vector (fe.max_dofs_per_cell()); @@ -1086,7 +1086,7 @@ VectorTools::create_boundary_right_hand_side (const hp::MappingCollection rhs_values; - + for (; cell!=endc; ++cell) for (unsigned int face=0; face::faces_per_cell; ++face) if (cell->face(face)->at_boundary () && @@ -1101,19 +1101,19 @@ VectorTools::create_boundary_right_hand_side (const hp::MappingCollection &weights = fe_values.get_JxW_values (); rhs_function.value_list (fe_values.get_quadrature_points(), rhs_values); - + cell_vector = 0; for (unsigned int point=0; pointget_dof_indices (dofs); - + for (unsigned int i=0; i > rhs_values; - - for (; cell!=endc; ++cell) + + for (; cell!=endc; ++cell) for (unsigned int face=0; face::faces_per_cell; ++face) if (cell->face(face)->at_boundary () && (boundary_indicators.find (cell->face(face)->boundary_indicator()) @@ -1136,22 +1136,22 @@ VectorTools::create_boundary_right_hand_side (const hp::MappingCollection(n_components)); - + const std::vector &weights = fe_values.get_JxW_values (); rhs_function.vector_value_list (fe_values.get_quadrature_points(), rhs_values); - + cell_vector = 0; - + // Use the faster code if the // FiniteElement is primitive if (cell->get_fe().is_primitive ()) - { + { for (unsigned int point=0; pointget_fe().system_to_component_index(i).first; - + cell_vector(i) += rhs_values[point](component) * fe_values.shape_value(i,point) * weights[point]; @@ -1173,9 +1173,9 @@ VectorTools::create_boundary_right_hand_side (const hp::MappingCollectionget_dof_indices (dofs); - + for (unsigned int i=0; ineighbor(direction).state() == IteratorState::valid) outermost_cell = outermost_cell->neighbor(direction); - + while (outermost_cell->has_children()) outermost_cell = outermost_cell->child(direction); @@ -1300,7 +1300,7 @@ VectorTools::interpolate_boundary_values (const Mappingvertex(direction), function_values); - + for (unsigned int i=0; ivertex_dof_index(direction,i)] @@ -1357,7 +1357,7 @@ interpolate_boundary_values (const Mapping // immediately if (function_map.size() == 0) return; - + Assert (function_map.find(255) == function_map.end(), ExcInvalidBoundaryIndicator()); @@ -1407,7 +1407,7 @@ interpolate_boundary_values (const Mapping for (unsigned int f=0; f &fe = finite_elements[f]; - + // generate a quadrature rule // on the face from the unit // support points. this will be @@ -1464,9 +1464,9 @@ interpolate_boundary_values (const Mapping if (component_mask[fe.face_system_to_component_index(i).first] == true) unit_support_points[i] = fe.unit_face_support_point(i); - + q_collection.push_back (Quadrature(unit_support_points)); - } + } } // now that we have a q_collection // object with all the right @@ -1477,7 +1477,7 @@ interpolate_boundary_values (const Mapping hp::MappingCollection mapping_collection (mapping); hp::FEFaceValues x_fe_values (mapping_collection, finite_elements, q_collection, update_quadrature_points); - + typename DH::active_cell_iterator cell = dof.begin_active(), endc = dof.end(); for (; cell!=endc; ++cell) @@ -1509,10 +1509,10 @@ interpolate_boundary_values (const Mapping "values that correspond to primitive (scalar) base " "elements")); } - + typename DH::face_iterator face = cell->face(face_no); const unsigned char boundary_component = face->boundary_indicator(); - if (function_map.find(boundary_component) != function_map.end()) + if (function_map.find(boundary_component) != function_map.end()) { // face is of the right component x_fe_values.reinit(cell, face_no); @@ -1525,7 +1525,7 @@ interpolate_boundary_values (const Mapping face->get_dof_indices (face_dofs, cell->active_fe_index()); const std::vector > &dof_locations = fe_values.get_quadrature_points (); - + if (fe_is_system) { // resize @@ -1539,10 +1539,10 @@ interpolate_boundary_values (const Mapping Vector(fe.n_components())); else dof_values_system.resize (fe.dofs_per_face); - + function_map.find(boundary_component)->second ->vector_value_list (dof_locations, dof_values_system); - + // enter those dofs // into the list that // match the @@ -1650,10 +1650,10 @@ interpolate_boundary_values (const Mapping - fe.get_nonzero_components(cell_i).begin()); } - + if (component_mask[component] == true) boundary_values[face_dofs[i]] = dof_values_system[i](component); - } + } } else // fe has only one component, @@ -1664,9 +1664,9 @@ interpolate_boundary_values (const Mapping dof_values_scalar.resize (fe.dofs_per_face); function_map.find(boundary_component)->second ->value_list (dof_locations, dof_values_scalar, 0); - + // enter into list - + for (unsigned int i=0; i void @@ -1703,7 +1703,7 @@ VectorTools::interpolate_boundary_values (const DH &dof, const std::vector &component_mask) { Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping")); - interpolate_boundary_values(StaticMappingQ1::mapping, + interpolate_boundary_values(StaticMappingQ1::mapping, dof, boundary_component, boundary_function, boundary_values, component_mask); } @@ -1718,7 +1718,7 @@ VectorTools::interpolate_boundary_values (const DH &dof, const std::vector &component_mask) { Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping")); - interpolate_boundary_values(StaticMappingQ1::mapping, + interpolate_boundary_values(StaticMappingQ1::mapping, dof, function_map, boundary_values, component_mask); } @@ -1758,7 +1758,7 @@ VectorTools::interpolate_boundary_values (const Mappingneighbor(direction).state() == IteratorState::valid) outermost_cell = outermost_cell->neighbor(direction); - + while (outermost_cell->has_children()) outermost_cell = outermost_cell->child(direction); @@ -1814,7 +1814,7 @@ VectorTools::interpolate_boundary_values (const Mappingvertex(direction), function_values); - + for (unsigned int i=0; ivertex_dof_index(direction,i); constraints.add_line (row); - constraints.set_inhomogeneity (row, + constraints.set_inhomogeneity (row, function_values(fe.face_system_to_component_index(i).first)); } } @@ -1834,7 +1834,7 @@ VectorTools::interpolate_boundary_values (const Mapping void -VectorTools::interpolate_boundary_values +VectorTools::interpolate_boundary_values (const Mapping &mapping, const DH &dof, const typename FunctionMap::type &function_map, @@ -1857,7 +1857,7 @@ VectorTools::interpolate_boundary_values template void -VectorTools::interpolate_boundary_values +VectorTools::interpolate_boundary_values (const Mapping &mapping, const DH &dof, const typename FunctionMap::type &function_map, @@ -1878,7 +1878,7 @@ VectorTools::interpolate_boundary_values // immediately if (function_map.size() == 0) return; - + Assert (function_map.find(255) == function_map.end(), ExcInvalidBoundaryIndicator()); @@ -1926,7 +1926,7 @@ VectorTools::interpolate_boundary_values for (unsigned int f=0; f &fe = finite_elements[f]; - + // generate a quadrature rule on the // face from the unit support // points. this will be used to @@ -1977,9 +1977,9 @@ VectorTools::interpolate_boundary_values if (component_mask[fe.face_system_to_component_index(i).first] == true) unit_support_points[i] = fe.unit_face_support_point(i); - + q_collection.push_back (Quadrature(unit_support_points)); - } + } } // now that we have a q_collection object // with all the right quadrature points, @@ -1989,7 +1989,7 @@ VectorTools::interpolate_boundary_values hp::MappingCollection mapping_collection (mapping); hp::FEFaceValues x_fe_values (mapping_collection, finite_elements, q_collection, update_quadrature_points); - + typename DH::active_cell_iterator cell = dof.begin_active(), endc = dof.end(); for (; cell!=endc; ++cell) @@ -2021,10 +2021,10 @@ VectorTools::interpolate_boundary_values "values that correspond to primitive (scalar) base " "elements")); } - + typename DH::face_iterator face = cell->face(face_no); const unsigned char boundary_component = face->boundary_indicator(); - if (function_map.find(boundary_component) != function_map.end()) + if (function_map.find(boundary_component) != function_map.end()) { // face is of the right // component @@ -2038,7 +2038,7 @@ VectorTools::interpolate_boundary_values face->get_dof_indices (face_dofs, cell->active_fe_index()); const std::vector > &dof_locations = fe_values.get_quadrature_points (); - + if (fe_is_system) { // resize array. avoid @@ -2050,10 +2050,10 @@ VectorTools::interpolate_boundary_values Vector(fe.n_components())); else dof_values_system.resize (fe.dofs_per_face); - + function_map.find(boundary_component)->second ->vector_value_list (dof_locations, dof_values_system); - + // enter those dofs into // the list that match the // component @@ -2140,7 +2140,7 @@ VectorTools::interpolate_boundary_values - fe.get_nonzero_components(cell_i).begin()); } - + if (component_mask[component] == true) { // TODO: check whether we should clear @@ -2149,7 +2149,7 @@ VectorTools::interpolate_boundary_values constraints.set_inhomogeneity (face_dofs[i], dof_values_system[i](component)); } - } + } } else // fe has only one component, @@ -2161,9 +2161,9 @@ VectorTools::interpolate_boundary_values dof_values_scalar.resize (fe.dofs_per_face); function_map.find(boundary_component)->second ->value_list (dof_locations, dof_values_scalar, 0); - + // enter into list - + for (unsigned int i=0; i void -VectorTools::interpolate_boundary_values +VectorTools::interpolate_boundary_values (const Mapping &mapping, const DH &dof, const unsigned char boundary_component, @@ -2196,11 +2196,11 @@ VectorTools::interpolate_boundary_values } #endif - + template void -VectorTools::interpolate_boundary_values +VectorTools::interpolate_boundary_values (const DH &dof, const unsigned char boundary_component, const Function &boundary_function, @@ -2208,7 +2208,7 @@ VectorTools::interpolate_boundary_values const std::vector &component_mask) { Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping")); - interpolate_boundary_values(StaticMappingQ1::mapping, + interpolate_boundary_values(StaticMappingQ1::mapping, dof, boundary_component, boundary_function, constraints, component_mask); } @@ -2217,14 +2217,14 @@ VectorTools::interpolate_boundary_values template void -VectorTools::interpolate_boundary_values +VectorTools::interpolate_boundary_values (const DH &dof, const typename FunctionMap::type &function_map, ConstraintMatrix &constraints, const std::vector &component_mask) { Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping")); - interpolate_boundary_values(StaticMappingQ1::mapping, + interpolate_boundary_values(StaticMappingQ1::mapping, dof, function_map, constraints, component_mask); } @@ -2283,16 +2283,16 @@ VectorTools::project_boundary_values (const Mapping &mappin } else AssertDimension (dof.get_fe().n_components(), component_mapping.size()); - + std::vector dof_to_boundary_mapping; std::set selected_boundary_components; for (typename FunctionMap::type::const_iterator i=boundary_functions.begin(); i!=boundary_functions.end(); ++i) selected_boundary_components.insert (i->first); - + DoFTools::map_dof_to_boundary_indices (dof, selected_boundary_components, dof_to_boundary_mapping); - + // Done if no degrees of freedom on // the boundary if (dof.n_boundary_dofs (boundary_functions) == 0) @@ -2322,7 +2322,7 @@ VectorTools::project_boundary_values (const Mapping &mappin if (dim>=3) { #ifdef DEBUG -// Assert that there are no hanging nodes at the boundary +// Assert that there are no hanging nodes at the boundary int level = -1; for (typename DoFHandler::active_cell_iterator cell = dof.begin_active(); cell != dof.end(); ++cell) @@ -2333,7 +2333,7 @@ VectorTools::project_boundary_values (const Mapping &mappin if (level == -1) level = cell->level(); else - { + { Assert (level == cell->level(), ExcNotImplemented()); } } @@ -2341,14 +2341,14 @@ VectorTools::project_boundary_values (const Mapping &mappin #endif } sparsity.compress(); - + // make mass matrix and right hand side SparseMatrix mass_matrix(sparsity); Vector rhs(sparsity.n_rows()); - MatrixCreator::create_boundary_mass_matrix (mapping, dof, q, + MatrixCreator::create_boundary_mass_matrix (mapping, dof, q, mass_matrix, boundary_functions, rhs, dof_to_boundary_mapping, (const Function*) 0, component_mapping); @@ -2361,7 +2361,7 @@ VectorTools::project_boundary_values (const Mapping &mappin // eliminate them here. //TODO: Maybe we should figure out if the element really needs this - + FilteredMatrix > filtered_mass_matrix(mass_matrix, true); FilteredMatrix > filtered_precondition; std::vector excluded_dofs(mass_matrix.m(), false); @@ -2370,7 +2370,7 @@ VectorTools::project_boundary_values (const Mapping &mappin for (unsigned int i=0;i max_element) max_element = mass_matrix.diag_element(i); - + for (unsigned int i=0;i &mappin mass_matrix.diag_element(i) = 1.; excluded_dofs[i] = true; } - + Vector boundary_projection (rhs.size()); // Allow for a maximum of 5*n @@ -2398,7 +2398,7 @@ VectorTools::project_boundary_values (const Mapping &mappin // solve cg.solve (filtered_mass_matrix, boundary_projection, rhs, filtered_precondition); filtered_precondition.apply_constraints(boundary_projection, true); - filtered_precondition.clear(); + filtered_precondition.clear(); // fill in boundary values for (unsigned int i=0; i::invalid_dof_index @@ -2481,16 +2481,16 @@ VectorTools::project_boundary_values (const Mapping &mappin } else AssertDimension (dof.get_fe().n_components(), component_mapping.size()); - + std::vector dof_to_boundary_mapping; std::set selected_boundary_components; for (typename FunctionMap::type::const_iterator i=boundary_functions.begin(); i!=boundary_functions.end(); ++i) selected_boundary_components.insert (i->first); - + DoFTools::map_dof_to_boundary_indices (dof, selected_boundary_components, dof_to_boundary_mapping); - + // Done if no degrees of freedom on // the boundary if (dof.n_boundary_dofs (boundary_functions) == 0) @@ -2520,7 +2520,7 @@ VectorTools::project_boundary_values (const Mapping &mappin if (dim>=3) { #ifdef DEBUG -// Assert that there are no hanging nodes at the boundary +// Assert that there are no hanging nodes at the boundary int level = -1; for (typename DoFHandler::active_cell_iterator cell = dof.begin_active(); cell != dof.end(); ++cell) @@ -2531,7 +2531,7 @@ VectorTools::project_boundary_values (const Mapping &mappin if (level == -1) level = cell->level(); else - { + { Assert (level == cell->level(), ExcNotImplemented()); } } @@ -2539,14 +2539,14 @@ VectorTools::project_boundary_values (const Mapping &mappin #endif } sparsity.compress(); - + // make mass matrix and right hand side SparseMatrix mass_matrix(sparsity); Vector rhs(sparsity.n_rows()); - MatrixCreator::create_boundary_mass_matrix (mapping, dof, q, + MatrixCreator::create_boundary_mass_matrix (mapping, dof, q, mass_matrix, boundary_functions, rhs, dof_to_boundary_mapping, (const Function*) 0, component_mapping); @@ -2559,7 +2559,7 @@ VectorTools::project_boundary_values (const Mapping &mappin // eliminate them here. //TODO: Maybe we should figure out if the element really needs this - + FilteredMatrix > filtered_mass_matrix(mass_matrix, true); FilteredMatrix > filtered_precondition; std::vector excluded_dofs(mass_matrix.m(), false); @@ -2568,7 +2568,7 @@ VectorTools::project_boundary_values (const Mapping &mappin for (unsigned int i=0;i max_element) max_element = mass_matrix.diag_element(i); - + for (unsigned int i=0;i &mappin mass_matrix.diag_element(i) = 1.; excluded_dofs[i] = true; } - + Vector boundary_projection (rhs.size()); // Allow for a maximum of 5*n @@ -2596,7 +2596,7 @@ VectorTools::project_boundary_values (const Mapping &mappin // solve cg.solve (filtered_mass_matrix, boundary_projection, rhs, filtered_precondition); filtered_precondition.apply_constraints(boundary_projection, true); - filtered_precondition.clear(); + filtered_precondition.clear(); // fill in boundary values for (unsigned int i=0; i::invalid_dof_index @@ -2654,8 +2654,8 @@ namespace internal for (unsigned int i=0; i &other) const { for (unsigned int i=0; i &dof_indices, const Tensor<1,dim> &constraining_vector, ConstraintMatrix &constraints) - { + { // choose the DoF that has the // largest component in the // constraining_vector as the @@ -2752,7 +2752,7 @@ namespace internal (std::fabs(constraining_vector[0]) >= std::fabs(constraining_vector[2]))) { constraints.add_line (dof_indices.dof_indices[0]); - + if (std::fabs (constraining_vector[1]/constraining_vector[0]) > std::numeric_limits::epsilon()) constraints.add_entry (dof_indices.dof_indices[0], @@ -2800,14 +2800,14 @@ namespace internal dof_indices.dof_indices[1], -constraining_vector[1]/constraining_vector[2]); } - + break; } default: Assert (false, ExcNotImplemented()); } - + } @@ -2823,7 +2823,7 @@ namespace internal void compute_orthonormal_vectors (const Tensor<1,dim> &vector, Tensor<1,dim> (&orthonormals)[dim-1]) - { + { switch (dim) { case 3: @@ -2910,9 +2910,9 @@ namespace internal default: Assert (false, ExcNotImplemented()); - } + } } - + } } @@ -2930,30 +2930,38 @@ VectorTools::compute_no_normal_flux_constraints (const DH ExcMessage ("This function is not useful in 1d because it amounts " "to imposing Dirichlet values on the vector-valued " "quantity.")); - + const FiniteElement &fe = dof_handler.get_fe(); std::vector face_dofs (fe.dofs_per_face); std::vector > dof_locations (fe.dofs_per_face); - // have a map that stores normal vectors - // for each vector-dof tuple we want to - // constrain. since we can get at the same - // vector dof tuple more than once (for - // example if it is located at a vertex - // that we visit from all adjacent cells), - // we will want to average later on the - // normal vectors computed on different - // cells as described in the documentation - // of this function. however, we can only - // average if the contributions came from - // different cells, whereas we want to - // constrain twice or more in case the - // contributions came from different faces - // of the same cell. consequently, we also - // have to store which cell a normal vector - // was computed on - typedef + // have a map that stores normal + // vectors for each vector-dof + // tuple we want to + // constrain. since we can get at + // the same vector dof tuple more + // than once (for example if it is + // located at a vertex that we + // visit from all adjacent cells), + // we will want to average later on + // the normal vectors computed on + // different cells as described in + // the documentation of this + // function. however, we can only + // average if the contributions + // came from different cells, + // whereas we want to constrain + // twice or more in case the + // contributions came from + // different faces of the same cell + // (i.e. constrain not just the + // *average normal direction* but + // *all normal directions* we + // find). consequently, we also + // have to store which cell a + // normal vector was computed on + typedef std::multimap, std::pair, typename DH::active_cell_iterator> > DoFToNormalsMap; @@ -2980,7 +2988,7 @@ VectorTools::compute_no_normal_flux_constraints (const DH // vectors at the locations // where they are defined: const std::vector > & - unit_support_points = fe.get_unit_face_support_points(); + unit_support_points = fe.get_unit_face_support_points(); Quadrature aux_quad (unit_support_points); FEFaceValues fe_values (mapping, fe, aux_quad, update_normal_vectors); @@ -2998,7 +3006,7 @@ VectorTools::compute_no_normal_flux_constraints (const DH // components of vector internal::VectorTools::VectorDoFTuple vector_dofs; vector_dofs.dof_indices[0] = face_dofs[i]; - + for (unsigned int k=0; k vector_dofs.dof_indices[fe.face_system_to_component_index(k).first - first_vector_component] = face_dofs[k]; - + for (unsigned int d=0; d // dofs typename DoFToNormalsMap::const_iterator p = dof_to_normals_map.begin(); - + while (p != dof_to_normals_map.end()) { // first find the range of entries in @@ -3132,7 +3140,7 @@ VectorTools::compute_no_normal_flux_constraints (const DH // average over all normal vectors case 1: { - + // compute the average // normal vector from all // the ones that have the @@ -3149,12 +3157,12 @@ VectorTools::compute_no_normal_flux_constraints (const DH x = cell_to_normals_map.begin(); x != cell_to_normals_map.end(); ++x) normal += x->second.first; - normal /= normal.norm(); - + normal /= normal.norm(); + // then construct constraints // from this: const internal::VectorTools::VectorDoFTuple & - dof_indices = same_dof_range[0]->first; + dof_indices = same_dof_range[0]->first; internal::VectorTools::add_constraint (dof_indices, normal, constraints); @@ -3219,11 +3227,11 @@ VectorTools::compute_no_normal_flux_constraints (const DH for (unsigned int i=0; isecond.first[j]; - + Assert (std::fabs(determinant (t)) > 1e-3, ExcMessage("Found a set of normal vectors that are nearly collinear.")); } - + // so all components of // this vector dof are // constrained. enter @@ -3237,7 +3245,7 @@ VectorTools::compute_no_normal_flux_constraints (const DH break; } - + // this is the case of an // edge contribution in 3d, @@ -3274,7 +3282,7 @@ VectorTools::compute_no_normal_flux_constraints (const DH q != same_dof_range[1]; ++q) cell_contributions[q->second.second].push_back (q->second.first); Assert (cell_contributions.size() >= 1, ExcInternalError()); - + // now for each cell that // has contributed // determine the number @@ -3373,7 +3381,7 @@ VectorTools::compute_no_normal_flux_constraints (const DH Assert (std::fabs (tangent.norm()-1) < 1e-12, ExcInternalError()); - + tangential_vectors.push_back (tangent); } @@ -3396,7 +3404,7 @@ VectorTools::compute_no_normal_flux_constraints (const DH if (*t * first_tangent < 0) *t *= -1; } - + // now compute the // average tangent and // normalize it @@ -3461,7 +3469,7 @@ namespace internal // necessary, so have a read-write // version of it: double exponent = exponent_1; - + const unsigned int n_components = dof.get_fe().n_components(); const bool fe_is_system = (n_components != 1); @@ -3472,7 +3480,7 @@ namespace internal } difference.reinit (dof.get_tria().n_active_cells()); - + switch (norm) { case dealii::VectorTools::L2_norm: @@ -3486,7 +3494,7 @@ namespace internal default: break; } - + UpdateFlags update_flags = UpdateFlags (update_quadrature_points | update_JxW_values); switch (norm) @@ -3504,13 +3512,13 @@ namespace internal default: update_flags |= UpdateFlags (update_values); break; - } + } dealii::hp::FECollection fe_collection (dof.get_fe()); dealii::hp::FEValues x_fe_values(mapping, fe_collection, q, update_flags); const unsigned int max_n_q_points = q.max_n_quadrature_points (); - + std::vector< dealii::Vector > function_values (max_n_q_points, dealii::Vector(n_components)); std::vector > > @@ -3533,7 +3541,7 @@ namespace internal // scalar functions std::vector tmp_values (max_n_q_points); std::vector > tmp_gradients (max_n_q_points); - + // loop over all cells typename DH::active_cell_iterator cell = dof.begin_active(), endc = dof.end(); @@ -3545,7 +3553,7 @@ namespace internal const dealii::FEValues &fe_values = x_fe_values.get_present_fe_values (); const unsigned int n_q_points = fe_values.n_quadrature_points; - + // resize all out scratch // arrays to the number of // quadrature points we use @@ -3586,8 +3594,8 @@ namespace internal for (unsigned int k=0;k &mapping, Assert(GeometryInfo::distance_to_unit_cell(cell_point.second) < 1e-10, ExcInternalError()); - + const Quadrature quadrature (GeometryInfo::project_to_unit_cell(cell_point.second)); FEValues fe_values(mapping, fe, quadrature, update_values); @@ -3926,7 +3934,7 @@ VectorTools::point_difference (const Mapping &mapping, difference(0) = exact_function.value(point); else exact_function.vector_value(point, difference); - + for (unsigned int i=0; i &mapping, Assert(GeometryInfo::distance_to_unit_cell(cell_point.second) < 1e-10, ExcInternalError()); - + const Quadrature quadrature (GeometryInfo::project_to_unit_cell(cell_point.second)); FEValues fe_values(mapping, fe, quadrature, update_values); @@ -4047,7 +4055,7 @@ VectorTools::compute_mean_value (const Mapping &mapping, ExcDimensionMismatch (v.size(), dof.n_dofs())); Assert (component < dof.get_fe().n_components(), ExcIndexRange(component, 0, dof.get_fe().n_components())); - + FEValues fe(mapping, dof.get_fe(), quadrature, UpdateFlags(update_JxW_values | update_values)); @@ -4055,7 +4063,7 @@ VectorTools::compute_mean_value (const Mapping &mapping, typename DoFHandler::active_cell_iterator c; std::vector > values(quadrature.size(), Vector (dof.get_fe().n_components())); - + double mean = 0.; double area = 0.; // Compute mean value @@ -4069,7 +4077,7 @@ VectorTools::compute_mean_value (const Mapping &mapping, area += fe.JxW(k); }; }; - + return (mean/area); }