Dear Zhenghuai Guo,

There are several ways. A very concise way is using interpolation functions
with expression <http://getfem.org/userdoc/interMM.html>,

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 <[email protected]>
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