getfem-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Getfem-users] How_to_update_im_data_in_each_loop


From: Zhenghuai Guo
Subject: Re: [Getfem-users] How_to_update_im_data_in_each_loop
Date: Fri, 10 May 2019 11:24:53 +0000

Hi Andriy,

 

Thank you for the advice. They are very helpful. I have a question regarding the ga_interpolation_im_data as below

 

Say if I do

 

getfem::im_data previous_cauthy_1(mim_1);     (step 1)

model.add_im_data("previous_cauthy_1", previous_cauthy_1);     (step  2)

other stuff here

getfem::ga_interpolation_im_data(model, "Grad_u_1" , previous_cauthy_1, base_vector_previous_cauthy_1);    (step 3)

 

When I do the step 3, do I update the "previous_cauthy_1"  defined in (step  2) which is inside the model  or update the previous_cauthy_1 defined in the (step 1) or both ? (because they are linked)

I assume by doing the (step 3), the im_data “previous_cauthy_1” in the model is updated, right?

Thank you very much

Regards

Zhenghuai Guo

 

 

 

 

 

 

 

From: Andriy Andreykiv <address@hidden>
Sent: Friday, May 10, 2019 6:21 PM
To: Zhenghuai Guo <address@hidden>
Cc: getfem-users <address@hidden>
Subject: Re: How_to_update_im_data_in_each_loop

 

Dear Zhenghuai Guo,

 

There are several ways. A very concise way is using interpolation functions with _expression_

Interpolation on an im_data object (on the Gauss points of an integration method):

void getfem::ga_interpolation_im_data(md, expr, im_data &imd,
 base_vector &result, const mesh_region &rg=mesh_region::all_convexes());

However, if this, for some reason doesn't work for you, you can simply iterate over elements (or faces) of a region of interest and set

the data on each Gauss point in a loop:

 

  getfem::mesh mesh;

  getfem::mesh_im im(mesh);

  bgeot::multi_index matrixSize(2, 2);

  auto regionA = 1;

  ImData imDataA(im, matrixSize, regionA);

  PlainVector data(imDataA.nb_tensor_elem() * imDataA.nb_filtered_index());

  for (auto v = getfem::mr_visitor{mesh.region(regionA)}; !v.finished(); ++v)

  {

    for (size_t point = 0; point != imDataA.nb_points_of_element(v.cv()); ++point)

    {

      bgeot::base_matrix M(2, 2);

      // fill in M

      imDataA.set_matrix(data, v.cv(), point, M);

    }

  }

 

you can also set this way ImData for vectors and scalars, of course.

 

Best regards,

                           Andriy

 

On Fri, 10 May 2019 at 06:21, Zhenghuai Guo <address@hidden> wrote:

Hi, Konstantinos and Yves  and Andriy,

I add a im_data “previous_cauthy_1” to the model. Then in each step of a loop from 1 to 10, I would like to update this im_data. The code sample is as below. Could you please teach me how to update values of the im_data?

 

getfem::im_data previous_cauthy_1(mim_1);

model.add_im_data("previous_cauthy_1", previous_cauthy_1);

getfem::add_nonlinear_term(model, mim_1,"(lambda_1*Trace(Grad_u_1-previous_cauthy_1)*Id(qdim(u_1)) + mu_1*(Grad_u_1+Grad_u_1'-previous_cauthy_1-previous_cauthy_1')):Grad_Test_u_1" );

 

for i = 1 to 10:

{

 getfem::standard_solve(model, iter, solver_name, ls);

 

update im_data "previous_cauthy_1", for the next loop step

}

 

 

Thank you very much

Regards

Zhenghuai Guo


reply via email to

[Prev in Thread] Current Thread [Next in Thread]