Integrate the solution over a subdomain

31 views
Skip to first unread message

Yang Liu

unread,
Oct 8, 2019, 8:43:23 AM10/8/19
to deal.II User Group

Dear DEAL.II users,

The DEAL.II software provides the function VectorTools::compute_mean_value() to integrate the solution over the whole domain. 

But now I would like to integrate the solution over a subdomain. 

fCan anyone give me some suggestions? Thanks in advance!

Doug Shi-Dong

unread,
Oct 8, 2019, 7:42:28 PM10/8/19
to deal.II User Group
Hello,

I guess it's not currently part of the library since the subdomain are determined by the partitioner, so it's rather odd that you need to integrate a specific subdomain. What you can do however, is basically copy this code


and add a parameter such that

 compute_mean_value(const Mapping<dim, spacedim> &   mapping,
                     const DoFHandler<dim, spacedim> &dof,
                     const Quadrature<dim> &          quadrature,
                     const VectorType &               v,
                     const unsigned int               component,
                     const unsigned int               subdomain_to_integrate)

and change line 9062

if (cell->is_locally_owned())

to

if (cell->is_locally_owned() && cell->subdomain_id == subdomain_to_integrate)

Not sure if there is a more elegant way. 

Doug

Wolfgang Bangerth

unread,
Oct 9, 2019, 9:40:49 AM10/9/19
to dea...@googlegroups.com
On 10/8/19 6:43 AM, Yang Liu wrote:
>
> The DEAL.II software provides the function VectorTools::compute_mean_value()
> to integrate the solution over the whole domain.
>
> But now I would like to integrate the solution over a subdomain.

Doug Shi-Dong already outlined an idea. Can you elaborate what you mean by
"subdomain"? If it's just a subset of cells, then you simply have to change
the function you refer to (which you can find in
include/deal.II/numerics/vector_tools.templates.h) and in the loop over all
cells simply add another if-condition that checks whether you are inside or
outside the subdomain you care about.

Best
W.

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

Reply all
Reply to author
Forward
0 new messages