Multiple FESystem

84 views
Skip to first unread message

Karthi

unread,
Jan 14, 2021, 12:51:32 PM1/14/21
to deal.II User Group

Dear All,

I have gone through a lot of tutorials. I would like to understand the basic relation between dof_handler and FESystem. I am trying to solve two 4th order equations on the same mesh (or triangulation). And each equation is split into two second order equations.

FESystem<dim>      fe_one,  fe_two;

BlockSparseMatrix<double> system_matrix_one, system_matrix_two;

BlockVector<double> solution_one, solution_two;

BlockVector<double> old_solution_one, old_solution_two;

BlockVector<double> system_rhs_one, system_rhs_two;

Question (1) Do I need one or two dof_handler? 

DoFHandler<dim>    dof_handler;

Where,

fe_one(FE_Q<dim>(degree),1, FE_Q<dim>(degree),1)

fe_two(FE_Q<dim>(degree),1, FE_Q<dim>(degree),1)

Some additional information, both the fe_one and fe_two systems are independently solved in a semi-implicitly manner. Meaning system_matrix_one is a function of old_solution_one and old_solution_two, likewise for system_matrix_two.

Question (2) I am assuming one block spartisty_pattern is enough and use the same for both the system_matrix? 

BlockSparsityPattern      sparsity_pattern;

If there would be other multiple declarations please let me know. I look forward to your response.

Best regards,

Karthi.


Wolfgang Bangerth

unread,
Jan 16, 2021, 11:22:45 AM1/16/21
to dea...@googlegroups.com
On 1/14/21 10:51 AM, Karthi wrote:
> I have gone through a lot of tutorials. I would like to understand the basic
> relation between dof_handler and FESystem. I am trying to solve _two_ 4th
> order equations on the same mesh (or triangulation). And each equation is
> split into two second order equations.
>
> FESystem<dim>      fe_one,  fe_two;
>
> BlockSparseMatrix<double> system_matrix_one, system_matrix_two;
>
> BlockVector<double> solution_one, solution_two;
>
> BlockVector<double> old_solution_one, old_solution_two;
>
> BlockVector<double> system_rhs_one, system_rhs_two;
>
> Question (1) Do I need one or two dof_handler?
>
> DoFHandler<dim>    dof_handler;
>
> Where,
>
> fe_one(FE_Q<dim>(degree),1, FE_Q<dim>(degree),1)
>
> fe_two(FE_Q<dim>(degree),1, FE_Q<dim>(degree),1)
>
> Some additional information, both the fe_one and fe_two systems are
> _independently solved_ in a semi-implicitly manner. Meaning system_matrix_one
> is a function of old_solution_one and old_solution_two, likewise for
> system_matrix_two.

No. A DoFHandler in essence just describes a function space: The triangulation
provides the subdivision of the domain into cells, the finite element provides
information about what the polynomial space is, and the DoFHandler provides an
enumeration of degrees of freedom. As a consequence, if you want to use the
same function space for your two problems, then you can use the same
DoFHandler for both of your sub-problems.


> Question (2) I am assuming one block spartisty_pattern is enough and use the
> same for both the system_matrix?
>
> BlockSparsityPattern      sparsity_pattern;

Correct.

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

Karthikeyan Chockalingam

unread,
Jan 17, 2021, 10:48:47 AM1/17/21
to dea...@googlegroups.com

Thank you very much for your response.


Now, I understand since the fe space is the same for the sub-problems I can use the same dof_handler for both.


Question (1) Does it mean when I distribute the dofs, I should do it twice with the same dof_handler?


dof_handler.distribute_dofs(fe_one);

dof_handler.distribute_dofs(fe_two);



Question(2) Currently, both the sub-problems solves almost the same pde and in 

the future the number of subproblems can be more than two. 

So I am planning to define a vector of FESystem<dim>.


std::vector<FESystem<dim>>  fe;


In the body of the constructor I have 


   for(unsigned int i=0; i < num_index; i++)

       fe.push_back({FE_Q<dim>(degree),1,FE_Q<dim>(degree)});


The above code compiles. 


Likewise define a vector for system_matrix, solution, old_solution, system_rhs.

Is this the approach correct?


Question (3)


Can I do the same for FEValues?


std::vector<FEValues<dim>> fe_vector_values;


    for(unsigned int i=0; i < num_index; i++)

      fe_vector_values.push_back({fe_vector[i], quadrature_formula, update_values});


Strangely enough depending on where the above code is located, 

it sometimes gives me compile errors.


If there is a better approach please let me know. Thank you!!


Best,

Karthi.


--
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/TyT5br2YYnM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/0e23dcc8-d543-824a-1165-0c8bf008b350%40colostate.edu.

Karthikeyan Chockalingam

unread,
Jan 18, 2021, 10:15:30 AM1/18/21
to dea...@googlegroups.com
I realized the mistake I was making, since all my sub-problems share the same fe space.  I don't need a vector of FESystem or FEValues but just one object of each object for all my sub-problems.

Best,
Karthi. 

Wolfgang Bangerth

unread,
Jan 18, 2021, 2:04:43 PM1/18/21
to dea...@googlegroups.com

> Question (1) Does it mean when I distribute the dofs, I should do it twice
> with the same dof_handler?
>
>
> dof_handler.distribute_dofs(fe_one);
>
> dof_handler.distribute_dofs(fe_two);

The latter would overwrite the former. But because your two elements are the
same, the second operation in reality does nothing at all.


> Question(2) Currently, both the sub-problems solves almost the same pde and in
>
> the future the number of subproblems can be more than two.
>
> So I am planning to define a vector of FESystem<dim>.
>
>
> std::vector<FESystem<dim>> fe;
>
>
> In the body of the constructor I have
>
>
> for(unsignedinti=0; i < num_index; i++)
>
>        fe.push_back({FE_Q<dim>(degree),1,FE_Q<dim>(degree)});
>
>
> The above code compiles.
>
>
> Likewise define a vector for system_matrix, solution, old_solution, system_rhs.
>
> Is this the approach correct?

You can do that, but in reality all of your finite element spaces are the
same, so you might as well create only one finite element and one DoFHandler,
plus multiple matrices and vectors. I think you already figured this out in
your follow-up email.


> Question (3)
>
>
> Can I do the same for FEValues?
>
>
> std::vector<FEValues<dim>> fe_vector_values;
>
>
> for(unsignedinti=0; i < num_index; i++)
>
>       fe_vector_values.push_back({fe_vector[i], quadrature_formula,
> update_values});
>
>
> Strangely enough depending on where the above code is located,
>
> it sometimes gives me compile errors.

You can do that, but again you are using identical objects where it would be
enough to just have one. (You get the error messages because FEValues objects
cannot be copied. But std::vector<X> requires that objects of type X can be
copied. The solution is to use std::vector<std::unique_ptr<X>> in such cases.)
Reply all
Reply to author
Forward
0 new messages