How to convert stiffness matrix in global degrees of freedom into stiffness matrix in global cells

46 views
Skip to first unread message

Lance Zhang

unread,
Oct 30, 2023, 5:54:34 PM10/30/23
to deal.II User Group
Hello team,

may I know how the stiffness matrix  in global degrees of freedom could be converted into  stiffness matrix in global cells?

I would like to use cook_memebrane.cc to get a stiffness matrix in a way of global cells.

Currently,I only got the stiffness matrix (solid_3d.tangent_matrix) in global degree of freedom.

How could I use cell matrix or stiffness matrix in global degree of freedom to reconstruct cells stiffness matrix?

Thanks in advance!

Best regards
Lance

Wolfgang Bangerth

unread,
Oct 30, 2023, 7:32:19 PM10/30/23
to dea...@googlegroups.com

On 10/30/23 15:54, Lance Zhang wrote:
>
> may I know how the stiffness matrix  in global degrees of freedom could
> be converted into  stiffness matrix in global cells?

Lance:
How do you define "stiffness matrix in global cells" mathematically?

Best
W.

Lance Zhang

unread,
Nov 13, 2023, 5:05:28 AM11/13/23
to dea...@googlegroups.com
Hello Wolfgang,

thanks for your reply.

I wonder whether the stiffness matrix could be converted to a matrix with rows = cell_numbers and columns = cell_numbers.

I tried to write the gradient with rows = degree_of_freedom into with rows = cell_numbers.

###################

for (unsigned int i = 0; i < solid_3d.solution_n.size(); ++i) {
            solver_vector(i) = solid_3d.solution_n[i];
            obj_det(i)= solid_3d.solution_n[i];
            norm2_value+=std::pow(solid_3d.solution_n[i],2);
        }

      norm2_value=std::sqrt(norm2_value);



   Eigen::VectorXd solver_gradient=-1*(obj_det/norm2_value).transpose()*inv_dense_matrix*solver_vector*solver_vector.transpose()*100;
   // the length of rows and columns in solver_gradient is respectively equal to the number of degree of freedom



 /*---------------------new update on degree of finite into cells---------------- */
  //change the length of rows and column into the number of cells//
  Eigen::VectorXd cell_gradients_solid(solid_3d.triangulation.n_active_cells());
  FE_Q<dim> fe_tmp(parameters.poly_degree);
  const QGauss<dim> qf_cell(parameters.quad_order);
  const UpdateFlags uf_cell(update_gradients | update_JxW_values);
  FEValues<dim> fe_values_ref_tmp(fe_tmp, qf_cell, uf_cell);
  unsigned int cell_index_solid = 0;
  double dof_value = 0;
  double gradient_tmp = 0;
  std::cout<<"***************************************"<<std::endl;
  for (auto cell = solid_3d.dof_handler_ref.begin_active(); cell != solid_3d.dof_handler_ref.end(); ++cell) {
    if (cell->is_locally_owned()) {
        fe_values_ref_tmp.reinit(cell);

        std::vector<dealii::types::global_dof_index> local_dof_indices(solid_3d.dofs_per_cell) ;

       cell->get_dof_indices(local_dof_indices);
 
       for (unsigned int i = 0; i < local_dof_indices.size(); ++i) {
           
           dealii::types::global_dof_index global_index = local_dof_indices[i];

         
           dof_value = solver_gradient(global_index);
           gradient_tmp += dof_value;
           dof_value=0;
 
         }
 
         cell_gradients_solid(cell_index_solid) = gradient_tmp;
         gradient_tmp=0;
         ++cell_index_solid;
     }
 }
 
 //change the length of rows and column into the number of cells
 std::cout<<cell_gradients_solid<<std::endl;

###################

If the gradient could be converted from degree of freedom into a cell_numbers, may I know if the stiffness matrix with length of degree of freedom could be converted to a stiffness  matrix with rows = cell_numbers and columns = cell_numbers.

But I am not quite sure if the idea about converting from degree of freedom into cell_numbers is mathematically correct.

If I have a wrong thought, please kindly provide hint and suggestions.

Best regards
Lance


Wolfgang Bangerth <bang...@colostate.edu> 于2023年10月31日周二 01:32写道:
--
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/1sVmdUIFY3k/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/b56b296b-14bf-46e0-bc39-da2f3b1de3b8%40colostate.edu.

Wolfgang Bangerth

unread,
Nov 13, 2023, 2:01:20 PM11/13/23
to dea...@googlegroups.com

On 11/13/23 03:05, Lance Zhang wrote:
>
> I wonder whether the stiffness matrix could be converted to a matrix
> with rows = cell_numbers and columns = cell_numbers.

Lance:
I think I mentioned this before: You can't. The entries of the stiffness
matrix are sums over contributions from different cells. So, in 2d with
Q1 elements for example, every matrix entry A_{ij} has the form

A_{ij} = a+b+c+d

where a...d are the contributions of the four cells adjacent to vertex i
(or j). Once you add these four numbers together, you can no longer
determine what the four numbers were. If you need the contributions of
individual cells, you need to store them before you add them together.

Best
W.

Lance Zhang

unread,
Nov 13, 2023, 2:19:48 PM11/13/23
to dea...@googlegroups.com
Hello Wolfgang,

thanks very much for your information.

I got the point.

Best regards
Lance

Wolfgang Bangerth <bang...@colostate.edu> 于 2023年11月13日周一 21:01写道:
--
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/1sVmdUIFY3k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages