normal vector of boundary faces

61 views
Skip to first unread message

Shahab Golshan

unread,
Nov 27, 2019, 4:56:30 PM11/27/19
to deal.II User Group
Dear all,
I was looking for a function to obtain the normal vectors of boundary faces. Are there any functions in dealII which returns the normal vector of a face?
Thank you in advance.
Shahab

navneet roshan

unread,
Nov 28, 2019, 12:57:43 AM11/28/19
to dea...@googlegroups.com
Hi Shahab, 

  Please look at the following piece of code, it might be useful to you.


   unsigned int n_face_q_points = face_quadrature_formula.size();
   FEFaceValues<dim> fe_face_values (fe, face_quadrature_formula,
                                      update_values |  update_normal_vectors
                                      | update_JxW_values);
 
   typename DoFHandler<dim>::active_cell_iterator
    cell = dof_handler.begin_active(),
    endc = dof_handler.end();

 // iterate over cells
    for (; cell!=endc; ++cell)
      {
      // iterate over faces
      for (unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell;
             ++face)
         // query if the faces of the cell belong to the boundary id needed
          if (cell->face(face)->at_boundary() == true
              && cell->face(face)->boundary_id() == 2)
            {
              fe_face_values.reinit(cell, face);

              for (unsigned int f_q_point = 0; f_q_point <n_face_q_points;
                   ++f_q_point)
                {
                  const Tensor<1, dim> &Nv =

                   fe_face_values.normal_vector(f_q_point);
                }
        }    
}   


Best,
Navneet


--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/1554c651-b524-4c15-b253-a6529dc2887e%40googlegroups.com.

Shahab Golshan

unread,
Dec 2, 2019, 1:58:00 PM12/2/19
to deal.II User Group
That was very helpful, thank you Navneet.
Best,
Shahab
On Thu, Nov 28, 2019 at 3:26 AM Shahab Golshan <shahab....@gmail.com> wrote:
Dear all,
I was looking for a function to obtain the normal vectors of boundary faces. Are there any functions in dealII which returns the normal vector of a face?
Thank you in advance.
Shahab

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dea...@googlegroups.com.

Shahab Golshan

unread,
Dec 2, 2019, 2:52:43 PM12/2/19
to deal.II User Group
Thank you again for your help. I have another question. I want to find the projection of a point on a face (the point on a face that has the closest distance to the query point). I think the function: project_real_point_to_unit_point_on_face should do this task, but I'm not sure. Can someone help me on this?


On Thursday, November 28, 2019 at 12:57:43 AM UTC-5, navneet roshan wrote:
On Thu, Nov 28, 2019 at 3:26 AM Shahab Golshan <shahab....@gmail.com> wrote:
Dear all,
I was looking for a function to obtain the normal vectors of boundary faces. Are there any functions in dealII which returns the normal vector of a face?
Thank you in advance.
Shahab

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dea...@googlegroups.com.

Wolfgang Bangerth

unread,
Dec 4, 2019, 1:04:19 AM12/4/19
to dea...@googlegroups.com
On 12/2/19 12:52 PM, Shahab Golshan wrote:
> Thank you again for your help. I have another question. I want to find the
> projection of a point on a face (the point on a face that has the closest
> distance to the query point). I think the function:
> project_real_point_to_unit_point_on_face should do this task, but I'm not
> sure. Can someone help me on this?

The function is going to give you a point in the reference coordinate system
of the face. If that's what you want, then that's the function you should
call. Have you tried?

As a general rule, it's often useful to start not using points in real space
and transforming them back into the coordinate systems of cells and faces
(which is very expensive), but by starting from points in the reference
coordinate systems and transforming them forward into real space (cheap). This
is, for example, how we define quadrature points. I don't know what you're
trying to do, but it might be worthwhile thinking about alternative ways to
achieve what you're looking for.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Reply all
Reply to author
Forward
0 new messages