[deal.II] Re: How to use cell stiffness matrix to build global stiffness matrix

2023-08-01 Thread Lance Zhang
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& 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

On Tuesday, August 1, 2023 at 11:47:12 AM UTC+2 abbas.b...@gmail.com wrote:

> Lance, 
>
> I am not sure if I understood you correctly. 
> Maybe looking at the local_assemble_matrix() function in step:13 might 
> help. 
>
> Abbas
>
> On Tuesday, August 1, 2023 at 11:00:10 AM UTC+2 dim...@gmail.com wrote:
>
>> 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:
>>
>>  
>> https://www.dealii.org/current/doxygen/code-gallery/Quasi_static_Finite_strain_Compressible_Elasticity/cook_membrane.cc
>> (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.
>>
>>
>> https://www.dealii.org/current/doxygen/code-gallery/Quasi_static_Finite_strain_Compressible_Elasticity/cook_membrane.cc
>> (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.
>>
>>I checked the code in 
>> AffineConstraints::distribute_local_to_global 
>> .
>>  
>> (
>> https://www.dealii.org/current/doxygen/deal.II/affine__constraints_8h_source.html
>> )
>> 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
>>
>

-- 
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 the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/0e042fbd-fab4-408e-a67e-a43f612c7490n%40googlegroups.com.


Re: [deal.II] Q: Question about extracting part of a vector

2023-08-01 Thread Abbas Ballout
Najwa, 
The files I edited are in the pull request here: 
https://github.com/dealii/dealii/pull/15805.
Let me know if I can help in a better way or of there is something I can 
do. 

Abbas. 

On Tuesday, August 1, 2023 at 5:48:41 AM UTC+2 najwaa...@gmail.com wrote:

> Hello Abbas,
>
> Thank you for your response. I have actually written something, but I need 
> to test it. It would be great to have a look at your work as well, so we 
> can compare.
>
> Best regards,
> Najwa
>
> On Mon, 31 Jul 2023 at 10:48 PM Abbas Ballout  
> wrote:
>
>> Najwaa, 
>>
>> I submitted a pull request  
>> recently about something similar 
>> . (I guess)
>> Maybe that would help. 
>>
>> Abbas 
>>  
>>
>> On Monday, July 31, 2023 at 7:37:59 PM UTC+2 najwaa...@gmail.com wrote:
>>
>>> Dear Wolfgang,
>>>
>>> Thank you for your answer. I will try to write a patch to the deal.II 
>>> sources that implement the missing function. This might require some time. 
>>> I will come back here if needed.
>>>
>>>
>>> Thank you all for your quick answers,
>>> Najwa
>>>
>>> On Wednesday, July 26, 2023 at 11:41:15 PM UTC+3 Wolfgang Bangerth wrote:
>>>
 On 7/26/23 12:17, Najwa Alshehri wrote: 
 > 
 > Regarding the function "VectorFucntionFromScalarFunctionObject," I 
 have 
 > observed that it works for computing the L2 norm of the error. 
 However, when I 
 > attempted to compute the H1_seminorm of the error, I noticed that the 
 gradient 
 > was not implemented for this function. Please let me know if my 
 understanding 
 > is incorrect, as I referred to the  for 
 this. 

 Yes, correct. Someone needs to implement 
 VectorFucntionFromScalarFunctionObject::gradient() 
 and/or 
 VectorFucntionFromScalarFunctionObject::gradient_list() 
 in exactly the same way as the value() and value_list() functions are 
 implemented. 


 > Could you kindly advise me on the simplest way to accomplish this? 

 The easiest way is to create a class derived from 
 VectorFucntionFromScalarFunctionObject in your own project that 
 implements the 
 missing function. The better way is to write a patch to the deal.II 
 sources 
 that implements the missing function because then others can use your 
 work in 
 the future as well :-) 


 > On a side note, although "VectorFucntionFromScalarFunctionObject" 
 works with 
 > the L2 norm of the error, it is quite computationally intensive. 

 It isn't VectorFucntionFromScalarFunctionObject that's expensive, but 
 the 
 FEFieldFunction. That's sort of inherently the case with this class. If 
 you 
 can, it should be avoided and you should try an evaluate the FE field 
 you have 
 at regular quadrature points, via FEValues. 

 Best 
 W. 

 -- 
  

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


 -- 
>> 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/DqH2auneWaY/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/dd5f93f8-fb58-45c6-9ab2-91ef6c5bdf56n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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 the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/bf142002-8af6-492b-a54b-d2fad4093ecen%40googlegroups.com.


[deal.II] Re: How to use cell stiffness matrix to build global stiffness matrix

2023-08-01 Thread Abbas Ballout
Lance, 

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

Abbas

On Tuesday, August 1, 2023 at 11:00:10 AM UTC+2 dim...@gmail.com wrote:

> 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:
>
>  
> https://www.dealii.org/current/doxygen/code-gallery/Quasi_static_Finite_strain_Compressible_Elasticity/cook_membrane.cc
> (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.
>
>
> https://www.dealii.org/current/doxygen/code-gallery/Quasi_static_Finite_strain_Compressible_Elasticity/cook_membrane.cc
> (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.
>
>I checked the code in 
> AffineConstraints::distribute_local_to_global 
> .
>  
> (
> https://www.dealii.org/current/doxygen/deal.II/affine__constraints_8h_source.html
> )
> 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
>

-- 
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 the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/1ab39ea3-2fbf-413e-924d-aa8c601766den%40googlegroups.com.


[deal.II] How to use cell stiffness matrix to build global stiffness matrix

2023-08-01 Thread Lance Zhang
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:

 
https://www.dealii.org/current/doxygen/code-gallery/Quasi_static_Finite_strain_Compressible_Elasticity/cook_membrane.cc
(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.

https://www.dealii.org/current/doxygen/code-gallery/Quasi_static_Finite_strain_Compressible_Elasticity/cook_membrane.cc
(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.

   I checked the code in 
AffineConstraints::distribute_local_to_global 
.
 
(
https://www.dealii.org/current/doxygen/deal.II/affine__constraints_8h_source.html
)
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

-- 
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 the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/e3f16c37-7670-40ee-b0d2-821fdcb7b307n%40googlegroups.com.