reuse FEEvaluation within a cell for RHS-like calculation

12 views
Skip to first unread message

Denis Davydov

unread,
Nov 15, 2016, 8:14:46 AM11/15/16
to deal.II User Group
I wonder if it possible to re-use FEEvaluation within each cell to calculate integrals of multiple right-hand-side like vectors.
Something along these lines:

          for (unsigned int cell=0; cell<n_cells; ++cell)
           
{
                fe_eval
.reinit(cell);
               
for (unsigned int q=0; q<n_q_points; ++q)
                 
// evaluate RHS functions and store results in values[q][i]

               
for (unsigned int i = 0; i < n_rhs; ++i)
                 
{
                     
for (unsigned int q= 0; q < n_q_points; ++q)
                         fe_eval
.submit_value(values[q][i], q);

                      fe_eval
.integrate (true,false);
                      fe_eval
.distribute_local_to_global (rhs_vectors[i]);
                 
}
             
}


Essentially, the question is whether or not integrate() and/or distribute_local_to_global() will re-set the FEEvaluation object to the state right after fe_eval.reinit(cell).
If not, then i suppose my best bet is to move the reinit within the loop over RHS vectors.

p.s. n_rhs is large, more than just a few, so I would prefer not to keep a vector of shared pointers to FEEvaluation or alike.

Regards,
Denis.

Martin Kronbichler

unread,
Nov 15, 2016, 9:00:02 AM11/15/16
to dea...@googlegroups.com

Hi Denis,


I wonder if it possible to re-use FEEvaluation within each cell to calculate integrals of multiple right-hand-side like vectors.
Yes, you can re-use an FEEvaluation object. As soon as you call submit_value(), you will write into the data field that is used by integrate(), which in turn writes the data field that is read in distribute_local_to_global. Re-using the same evaluators (shape functions, scratch arrays) is the reason why we did not tie the FEEvaluation object to the vector.


Something along these lines:

          for (unsigned int cell=0; cell<n_cells; ++cell)
           
{
                fe_eval
.reinit(cell);
               
for (unsigned int q=0; q<n_q_points; ++q)
                 
// evaluate RHS functions and store results in values[q][i]

               
for (unsigned int i = 0; i < n_rhs; ++i)
                 
{
                     
for (unsigned int q= 0; q < n_q_points; ++q)
                         fe_eval
.submit_value(values[q][i], q);

                      fe_eval
.integrate (true,false);
                      fe_eval
.distribute_local_to_global (rhs_vectors[i]);
                 
}
             
}

This is exactly written as intended.

Best,
Martin

Denis Davydov

unread,
Nov 15, 2016, 9:05:28 AM11/15/16
to dea...@googlegroups.com
Hi Martin,

Cool, thanks for the prompt reply.

Kind regards,
Denis 

-- 
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 a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/VsIkogE1L40/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages