From 986a703a5b95df94d25a3c32ea0b16610f64ac7c Mon Sep 17 00:00:00 2001 From: bangerth Date: Mon, 20 Dec 2010 02:02:03 +0000 Subject: [PATCH] Make code somewhat cleaner and dimension independent. Document better what exactly we do. git-svn-id: https://svn.dealii.org/trunk@23014 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/fe/mapping_q1.cc | 86 ++++++++++++++------------------- 1 file changed, 36 insertions(+), 50 deletions(-) diff --git a/deal.II/source/fe/mapping_q1.cc b/deal.II/source/fe/mapping_q1.cc index 3dee5dbf4e..200ed752ac 100644 --- a/deal.II/source/fe/mapping_q1.cc +++ b/deal.II/source/fe/mapping_q1.cc @@ -804,59 +804,45 @@ MappingQ1::fill_fe_values ( } else { + data.contravariant[point]=transpose(data.contravariant[point]); + + // compute the normal + // vector to this cell + // and put it into the + // last row of + // data.contravariant if ( (dim==1) && (spacedim==2) ) - { - data.contravariant[point] = transpose(data.contravariant[point]); - JxW_values[point] - = data.contravariant[point][0].norm()*weights[point]; - if (update_flags & update_normal_vectors) - { - normal_vectors[point][0] - = -(data.contravariant[point][0][1] - / - data.contravariant[point][0].norm()); - normal_vectors[point][1] - = (data.contravariant[point][0][0] - / - data.contravariant[point][0].norm()); - - if (cell->direction_flag() == false) - normal_vectors[point] *= -1.; - } - } + cross_product(data.contravariant[point][1], + -data.contravariant[point][0]); + else if ( (dim==2) && (spacedim==3) ) + cross_product(data.contravariant[point][2], + data.contravariant[point][0], + data.contravariant[point][1]); else + Assert (false, ExcNotImplemented()); + + // det(J) is now the norm + // of the cross product + // of all the mapped unit + // tangential vectors + JxW_values[point] + = data.contravariant[point][spacedim-1].norm()*weights[point]; + + // in order to compute + // the normal vector, + // normalize the cross + // product of mapped unit + // vectors + data.contravariant[point][spacedim-1] + /= data.contravariant[point][spacedim-1].norm(); + + if (update_flags & update_normal_vectors) { - if ( (dim==2) && (spacedim==3) ) - { - data.contravariant[point]=transpose(data.contravariant[point]); - cross_product(data.contravariant[point][2], - data.contravariant[point][0], - data.contravariant[point][1]); - JxW_values[point] - = data.contravariant[point][2].norm()*weights[point]; - - // the cell - // normal - // vector - // (normal - // to the - // surface) - // is - // stored - // in the - // 3d - // subtensor - // of the - // contravariant - // tensor - data.contravariant[point][2] /= data.contravariant[point][2].norm(); - if (update_flags & update_normal_vectors) - { - normal_vectors[point]=data.contravariant[point][2]; - if (cell->direction_flag() == false) - normal_vectors[point] *= -1.; - } - } + normal_vectors[point] + = data.contravariant[point][spacedim-1]; + + if (cell->direction_flag() == false) + normal_vectors[point] *= -1.; } } } -- 2.39.5