## [Libmesh-users] Adaptive Mesh: how to update data values?

 [Libmesh-users] Adaptive Mesh: how to update data values? From: Karen Lee - 2011-03-30 05:11:38 ```Dear Libmesh developers and users, I have this program that reads in a mesh with extra data values (in a MeshData object associated with the mesh): assert (dim == 3); Mesh mesh(dim); MeshData mesh_data(mesh); mesh_data.activate(); mesh.read (mesh_file, &mesh_data); mesh_data.read(mesh_file); I've had no probem getting the values of the data in my assemble function: DenseVector rho, eps; for ( ; el != end_el ; ++el) { num_el++; const Elem* elem = *el; Node* nn = elem->get_node(0); nn->print_info(); dof_map.dof_indices (elem, dof_indices); fe->reinit (elem); Ke.resize (dof_indices.size(), dof_indices.size()); Fe.resize (dof_indices.size()); rho.resize(qrule.n_points()); eps.resize(qrule.n_points()); for (unsigned int qp=0; qp& data = mesh_data.get_data(elem->get_node(i)); //this line gets into trouble when doing adaptive refinement, since mesh_data.has_data() returns false eps(qp) += data[1] * phi[i][qp]; rho(qp) += data[0] * phi[i][qp]; } for (unsigned int i=0; iget_node(i)) returns false fo all elems in the new mesh. I'm wondering if there's a straightforward way to interpolate these data values that I use as the RHS to solve Poisson's equations. Any help will be deeply appreciated. Thanks! Karen P.S. I wonder if "insert_node_data ()" is somehow involved, although with the new mesh having different numbers of nodes and elements as the old mesh, I'm not sure how I would do this... ```

 [Libmesh-users] Adaptive Mesh: how to update data values? From: Karen Lee - 2011-03-30 05:11:38 ```Dear Libmesh developers and users, I have this program that reads in a mesh with extra data values (in a MeshData object associated with the mesh): assert (dim == 3); Mesh mesh(dim); MeshData mesh_data(mesh); mesh_data.activate(); mesh.read (mesh_file, &mesh_data); mesh_data.read(mesh_file); I've had no probem getting the values of the data in my assemble function: DenseVector rho, eps; for ( ; el != end_el ; ++el) { num_el++; const Elem* elem = *el; Node* nn = elem->get_node(0); nn->print_info(); dof_map.dof_indices (elem, dof_indices); fe->reinit (elem); Ke.resize (dof_indices.size(), dof_indices.size()); Fe.resize (dof_indices.size()); rho.resize(qrule.n_points()); eps.resize(qrule.n_points()); for (unsigned int qp=0; qp& data = mesh_data.get_data(elem->get_node(i)); //this line gets into trouble when doing adaptive refinement, since mesh_data.has_data() returns false eps(qp) += data[1] * phi[i][qp]; rho(qp) += data[0] * phi[i][qp]; } for (unsigned int i=0; iget_node(i)) returns false fo all elems in the new mesh. I'm wondering if there's a straightforward way to interpolate these data values that I use as the RHS to solve Poisson's equations. Any help will be deeply appreciated. Thanks! Karen P.S. I wonder if "insert_node_data ()" is somehow involved, although with the new mesh having different numbers of nodes and elements as the old mesh, I'm not sure how I would do this... ```
 Re: [Libmesh-users] Adaptive Mesh: how to update data values? From: Roy Stogner - 2011-03-30 05:17:07 ```On Wed, 30 Mar 2011, Karen Lee wrote: > HOWEVER, now that I'm trying to do adaptive refinement, it doesn't > look like these data values are refined. Nope. The short answer: don't use MeshData. In this case, the primary reason is that there's no good way for the library to know how you want it interpreted and interpolated. Use a separate ExplicitSystem with a finite element data field instead, and then the data will be projected from mesh to mesh in as consistent a way as possible. --- Roy ```
 Re: [Libmesh-users] Adaptive Mesh: how to update data values? From: Karen Lee - 2011-04-07 19:40:06 ```So my code with MeshData worked fine, but is not parallelizable. So I'm trying to get some help of understanding how to use ExplicitSystem. The only example I found from the examples that contain ExplicitSystem is Example 2, and being a newbie to C++ does not help me understand how I can give values to and access the variables from ExplicitSystem. 1. What is the format of the input to void read_parallel_data (Xdr &io, const bool read_additional_data) ? I would like to put my data for all the nodes in .xdr (or is it .xda?) form. I have .xda files of meshes from previous runs where I output the .xda files, but I'm not sure what the format of .xdr is. If I have a single field of 5's (5 nodes), do I just do the following? 5 1 1 1 1 1 I have this code within a loop that goes through all the elements from my previous program that uses MeshData, which I now wanna get rid of using: for (unsigned int i=0; i& data = mesh_data.get_data(elem->get_node(i)); eps(qp) += data[1] * phi[i][qp]; rho(qp) += data[0] * phi[i][qp]; } I guess I just need a function that takes the place of mesh_data.get_data(elem->get_node(i)) and takes the "elem->get_node(i)"th item from the explicit system.(I would like to have 3 of such variables, and just be able to access the ith element of each of them.) Any help will be deeply appreciated. Thanks, Karen ---------- Forwarded message ---------- From: Roy Stogner Date: Wed, Mar 30, 2011 at 1:17 AM Subject: Re: [Libmesh-users] Adaptive Mesh: how to update data values? To: Karen Lee Cc: libmesh-users On Wed, 30 Mar 2011, Karen Lee wrote: > HOWEVER, now that I'm trying to do adaptive refinement, it doesn't > look like these data values are refined. Nope.  The short answer: don't use MeshData.  In this case, the primary reason is that there's no good way for the library to know how you want it interpreted and interpolated.  Use a separate ExplicitSystem with a finite element data field instead, and then the data will be projected from mesh to mesh in as consistent a way as possible. --- Roy ```
 Re: [Libmesh-users] Adaptive Mesh: how to update data values? From: Karen Lee - 2011-04-07 19:45:18 ```Another question I have is, is there any say to speed up the reading of a large mesh (about 55M elements)? It seemed that a lot of time was spent looking for neighbors... (when renumbering is turned off. When it's not, much time is spent renumbering stuff...) Thanks, Karen On Thu, Apr 7, 2011 at 3:39 PM, Karen Lee wrote: > So my code with MeshData worked fine, but is not parallelizable. So > I'm trying to get some help of understanding how to use > ExplicitSystem. > > The only example I found from the examples that contain ExplicitSystem > is Example 2, and being a newbie to C++ does not help me understand > how I can give values to and access the variables from ExplicitSystem. > > 1. What is the format of the input to > > void    read_parallel_data (Xdr &io, const bool read_additional_data) > > ? I would like to put my data for all the nodes in .xdr (or is it > .xda?) form. I have .xda files of meshes from previous runs where I > output the .xda files, but I'm not sure what the format of .xdr is. If > I have a single field of 5's (5 nodes), do I just do the following? > > 5 > 1 > 1 > 1 > 1 > 1 > >  I have this code within a loop that goes through all the elements > from my previous program that uses MeshData, which I now wanna get rid > of using: > > for (unsigned int i=0; i          const std::vector& data = > mesh_data.get_data(elem->get_node(i)); >          eps(qp) += data[1] * phi[i][qp]; >          rho(qp) += data[0] * phi[i][qp]; > } > > I guess I just need a function that takes the place of > mesh_data.get_data(elem->get_node(i)) and takes the > "elem->get_node(i)"th item from the explicit system.(I would like to > have 3 of such variables, and just be able to access the ith element > of each of them.) > > Any help will be deeply appreciated. > > Thanks, > Karen > > > > > > ---------- Forwarded message ---------- > From: Roy Stogner > Date: Wed, Mar 30, 2011 at 1:17 AM > Subject: Re: [Libmesh-users] Adaptive Mesh: how to update data values? > To: Karen Lee > Cc: libmesh-users > > > > On Wed, 30 Mar 2011, Karen Lee wrote: > >> HOWEVER, now that I'm trying to do adaptive refinement, it doesn't >> look like these data values are refined. > > Nope.  The short answer: don't use MeshData.  In this case, the > primary reason is that there's no good way for the library to know how > you want it interpreted and interpolated.  Use a separate > ExplicitSystem with a finite element data field instead, and then the > data will be projected from mesh to mesh in as consistent a way as > possible. > --- > Roy > ```
 Re: [Libmesh-users] Adaptive Mesh: how to update data values? From: Karen Lee - 2011-04-13 06:12:05 ```ExplicitSystem has read_header() and read_parallel_data() functions, but I'm not sure how the format is read in. 1) The functions above take "Xdr", but do they in fact take the ascii form Xda? I tried looking at the Xdr class, but didn't see Xda anywhere 2) I looked at the pdf file that explains the xda/xdr format, and they do a good job explainig what a xda file looks like for a mesh. I'm trying to read in some values of a field associated with the nodes for use as the RHS of a LinearInplicitSystem, and I'm completely lost as to how I would do that... For example, after I add some variables to my ExplicitSystem: equation_systems.add_system ("VarSystem"); equation_systems.get_system("VarSystem").add_variable("rhoV", FIRST); equation_systems.get_system("VarSystem").add_variable("epsV", FIRST); equation_systems.get_system("VarSystem").add_variable("inBrainv", FIRST); How does the program know that the fields read in (assuming I know how to do that) are associated with these variables? 3) How would I acutally put them into the RHS? When I was using MeshData, I had: DenseVector rho, eps; (fields), and for each element, I interpolate the field at quadrature points as follows: for (unsigned int qp=0; qp& data = mesh_data.get_data(elem->get_node(i\ )); eps(qp) += data[1] * phi[i][qp]; rho(qp) += data[0] * phi[i][qp]; } for (unsigned int i=0; i > On Thu, Apr 7, 2011 at 3:39 PM, Karen Lee wrote: >> So my code with MeshData worked fine, but is not parallelizable. So >> I'm trying to get some help of understanding how to use >> ExplicitSystem. >> >> The only example I found from the examples that contain ExplicitSystem >> is Example 2, and being a newbie to C++ does not help me understand >> how I can give values to and access the variables from ExplicitSystem. >> >> 1. What is the format of the input to >> >> void    read_parallel_data (Xdr &io, const bool read_additional_data) >> >> ? I would like to put my data for all the nodes in .xdr (or is it >> .xda?) form. I have .xda files of meshes from previous runs where I >> output the .xda files, but I'm not sure what the format of .xdr is. If >> I have a single field of 5's (5 nodes), do I just do the following? >> >> 5 >> 1 >> 1 >> 1 >> 1 >> 1 >> >>  I have this code within a loop that goes through all the elements >> from my previous program that uses MeshData, which I now wanna get rid >> of using: >> >> for (unsigned int i=0; i>          const std::vector& data = >> mesh_data.get_data(elem->get_node(i)); >>          eps(qp) += data[1] * phi[i][qp]; >>          rho(qp) += data[0] * phi[i][qp]; >> } >> >> I guess I just need a function that takes the place of >> mesh_data.get_data(elem->get_node(i)) and takes the >> "elem->get_node(i)"th item from the explicit system.(I would like to >> have 3 of such variables, and just be able to access the ith element >> of each of them.) >> >> Any help will be deeply appreciated. >> >> Thanks, >> Karen >> >> >> >> >> >> ---------- Forwarded message ---------- >> From: Roy Stogner >> Date: Wed, Mar 30, 2011 at 1:17 AM >> Subject: Re: [Libmesh-users] Adaptive Mesh: how to update data values? >> To: Karen Lee >> Cc: libmesh-users >> >> >> >> On Wed, 30 Mar 2011, Karen Lee wrote: >> >>> HOWEVER, now that I'm trying to do adaptive refinement, it doesn't >>> look like these data values are refined. >> >> Nope.  The short answer: don't use MeshData.  In this case, the >> primary reason is that there's no good way for the library to know how >> you want it interpreted and interpolated.  Use a separate >> ExplicitSystem with a finite element data field instead, and then the >> data will be projected from mesh to mesh in as consistent a way as >> possible. >> --- >> Roy >> > ```