On Mon, Feb 8, 2016 at 5:29 AM, Giacomo Rosilho de Souza < giacomo.rosilhodeso...@epfl.ch> wrote:
> Hello, > I was wondering if it is possible to change the ordering of the degrees > of freedom in a numeric vector. In my application the domain is splitted > in two parts, one containing the elements considered to be fine and the > other the coarse ones. When we integrate the equations in time I use > different coefficients for the different domains and this leads to a > code like this one: > > for(int i=0;i<coarse_dofs.size();i++) > { > dof = coarse_dofs[i]; > vj->set(dof,mu[0]*(v1->el(dof))+nu[0]*(v2->el(dof)) + /*......*/); > } > for(int i=0;i<fine_dofs.size();i++) > { > dof = fine_dofs[i]; > vj->set(dof,mu[1]*(w1->el(dof))+nu[1]*(w2->el(dof)) + /*......*/); > } > > Obviously fine_dofs and coarse_dofs are not contiguous sets of indexes > and the above loops are quite slow. So, if I can modify the dof_map so > that every processor owns a set of degrees of freedom in which the first > ones are the coarses end the others the fines I hope to get some > performance improvements. I think that modifying the dof_map would be > the easiest way because it wouldn't require any further code > modification since also the matrices will be correctly reordered. > I don't think modifying the DofMap's ordering is going to be straightforward. We currently support two different orderings (node-major and dof-major) so you could look at how DofMap::distribute_local_dofs_var_major() DofMap::distribute_local_dofs_node_major() are implemented, and see if they might be adapted to your particular application. That being said, I question whether reordering is going to buy you very much speed in your overall application. That is, have you actually profiled the code and determined that this specific part is one of the slowest parts? Also, remember that setting values in NumericVectors is already a fairly indirect operation. For example, if you are using PETSc, the values are cached and communicated only when the vector is closed. One last thing: it looks like you are calling the virtual "el()" function on NumericVectors? It's usually possible to just use the non-virtual operator() for this (in your case (*v1)(dof) should do it), unless you are using DenseVectorBase pointers for some reason... -- John ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 _______________________________________________ Libmesh-users mailing list Libmesh-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libmesh-users