In step 1) you are creating only im_data object, which doesn't contain
actual data. im_data class is a descriptor of the data. The actual data is
contained in some bgeot::base_vector (which is an alias for
std::vector<double>).
Having the base_vector alone doesn't allow you to understand what's in it,
because you don't know what the numbers correspond to. But having im_data
allows you to relate indices in im_data to the specific element and Gauss
point.
To view the actual data you should use
 bgeot::base_vector &data = model.real_variable(*"previous_cauthy_1"* );
Then you can pass this data vector reference to
*getfem::ga_interpolation_im_data*, which will update it. But the actual
vector is stored inside getfem::model.

I hope this helps,
                               Andriy

On Fri, 10 May 2019 at 13:24, Zhenghuai Guo <[email protected]>
wrote:

> 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 <[email protected]>
> *Sent:* Friday, May 10, 2019 6:21 PM
> *To:* Zhenghuai Guo <[email protected]>
> *Cc:* getfem-users <[email protected]>
> *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 <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