On 9/12/21 6:15 PM, Michael Li wrote:
Thank you for your hints. I tried using *shape_value*, but it seems finite_element_output is a protected member. The error shows as follows:

error*: ‘dealii::internal::FEValuesImplementation::FiniteElementRelatedData<2, 2> dealii::FEValuesBase<2, 2>::finite_element_output’* is protected within this context

   59 |           double shape_value = fe_values.finite_element_output.shape_value(i, q_index);

^~~~~~~~~~~~~~~~~~~~~

*error: ‘class dealii::internal::FEValuesImplementation::FiniteElementRelatedData<2, 2>’ has no member named ‘shape_value’; did you mean‘shape_values’?*

Where does the reference to finite_element_output come from? You just need
  fe_values.shape_value(i,q_index);
Take a look at any of the tutorial programs -- they all use this syntax, and they're usually quite a good illustration of how things are typically done with deal.II :-)


By the way, I also want to get the *shape_grad* of the reference cell to compare with some other code implementation regarding shape function.

Based on Thong’s method, the following codes gives me the desired results for a Q1 element:

const FE_Q<2> Q_2d_element(1);

const Point<2> center(1, 1);

That's not the center of the cell :-)


for(unsignedint i=0; i<Q_2d_element.n_dofs_per_cell(); i++)

   {

     std::cout << " shape value = "<< Q_2d_element.shape_value(i, center);

    std::cout << " shape grad = " << Q_2d_element.shape_grad(i, center) << std::endl;

   }

I wonder if there are other ways to access the shape_grad on the ref cell directly. Do I need to use *fe_values.inverse_jacobian(q_index) *to convert from *shape_grad* on the real cell to the reference cell?

If you ask the finite element object, you will get the values, gradients, ... of the shape functions on the reference cell. If you ask the FEValues object, you will get the values, gradients, ... of the shape functions on a concrete cell.

Best
 W.

--
------------------------------------------------------------------------
Wolfgang Bangerth          email:                 [email protected]
                           www: http://www.math.colostate.edu/~bangerth/

--
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/f83cc022-5893-3b4c-e547-8bdfeb70f5f9%40colostate.edu.

Reply via email to