How to use cell stiffness matrix to build global stiffness matrix

52 views
Skip to first unread message

Lance Zhang

unread,
Aug 1, 2023, 5:00:10 AM8/1/23
to deal.II User Group
Hello dear group,

I have one question which is about how to build global stiffness matrix with cell stiffness matrix.

In our project,the density is a vector (actually we need a mu vector but in the code of deallii mu is a scalar)with different values,I would like to use the element of density vector to build cell matrix as written in the link below:

(starting from line 1782)

And finally the cell stiffness matrix is used to build global stiffness matrix,but I don' know how the global stiffness matrix is bulit with cell stiffness matrix.

(starting from line 1599)
//>>>>>>>>>>>>>>>>>>>>>>>>>>
     constraints.distribute_local_to_global(
        data.cell_matrix,
data.cell_rhs,
        data.local_dof_indices,
        tangent_matrix,
system_rhs);
    }


//<<<<<<<<<<<<<<<<<<<<<<<<<<<<


I have a idea that I use mu[0] to obtain the first cell_matrix and use mu[1] to get the second cell stiffness matrix ,step by step then I got final mu[m] to obtain the last cell stiffness matrix and in the end I use some function like  distribute_local_to_global to construct the global stiffness matrix,and system rhs and even the solutions.

But the hint information guides me to read the cm.templates.h file.
ewcfp I was a little confused ,I did not find the file from dealii lib. could anyone provide any information or hint? Thanks in advance!
Best regards
Lance
Could

I

Abbas Ballout

unread,
Aug 1, 2023, 5:47:12 AM8/1/23
to deal.II User Group
Lance, 

I am not sure if I understood you correctly. 
Maybe looking at the local_assemble_matrix() function in step:13 might help. 

Abbas

Lance Zhang

unread,
Aug 1, 2023, 12:53:35 PM8/1/23
to deal.II User Group
Hello Abbas,

Thanks for your reply.

I will take a look at the step13.

Howerver, I would like to know if the cell matrix transform seems like the process below:

    const Eigen::MatrixXd& cell_matrix,
    const Eigen::VectorXd& cell_youngs_modulus,
    const std::vector<int>& local_dof_indices,
    Eigen::MatrixXd& tangent_matrix,
    Eigen::VectorXd& global_youngs_modulus)

   const int N = cell_matrix.rows();
    const int M = tangent_matrix.rows();

    // Loop over the local degrees of freedom
    for (int i = 0; i < N; ++i) {
        const int global_i = local_dof_indices[i]; // Global index of the i-th local dof

        // Add the contribution of the i-th local dof to the global Young's modulus vector
        global_youngs_modulus(global_i) += cell_youngs_modulus(i);

        for (int j = 0; j < N; ++j) {
            const int global_j = local_dof_indices[j]; // Global index of the j-th local dof

            // Add the contribution of the (i,j)-th entry of the cell matrix multiplied by the i-th and j-th Young's modulus to the global tangent matrix
            tangent_matrix(global_i, global_j) += cell_matrix(i, j) * cell_youngs_modulus(i) * cell_youngs_modulus(j);
        }
    }

I am not quite sure if the assembly process for the global stiffness matrix is correct.

Best regards
Lance

Abbas Ballout

unread,
Aug 2, 2023, 7:29:19 AM8/2/23
to deal.II User Group
Not really experienced with eigen so I am not exactly sure. 
Abbas
Reply all
Reply to author
Forward
0 new messages