## Re: [Libmesh-users] AMR in 3D (fwd)

 Re: [Libmesh-users] AMR in 3D (fwd) From: Roy Stogner - 2007-05-07 18:14:18 ```> ---------- Forwarded message ---------- > Date: Sun, 6 May 2007 03:15:02 -0500 > From: Shun Wang > To: Roy Stogner > Subject: Re: [Libmesh-users] AMR in 3D > > I found the bug. In this special case, DofMap::build_constrain_matrix() > would go wrong. > > a----b----c-------------d > > Let's look at the case in a simple line and consider the element with nodes > b,c. > > When we call build_constrain_matrix() with elem_dofs={bc}, up to line 745 of > dof_map_constraints.C (see doc > page;), > we have > new_elem_dofs = {abcd}, because b depends on {ac}, and c depends on {ad}. > And in the constrain matrix C, the coefficients on row b are 0.5 on column a > and 0.5 on column c. > > Now build_constrain_matrix() is called recursively with elem_dofs={abcd}, > then it won't expand any more and return an empty constrain matrix Cnew. > Then, the constrain matrix C will have wrong row b. This analysis looks correct to me. Unless Ben has an explanation of something we're missing, I'd say you've found a real bug. > So, I changed the code as following to correct this bug: > 1. remove the "if" condition on lines 699 and 700 > 2. put a "if (!called_recursively)" condition for the recursive call between > lines 745 to 753. This fix doesn't look correct to me. With that if(!called_recursively) condition, you'd never get more than one level of recursion, and the code would work on level-2 mismatches but fail on level-3. > I think there is better ways to implement build_constrain_matrix() without > recursive calls. > One way is to do some pre-processing on DofConstraints to eliminate > recursive dependency (hanging nodes depend on other hanging nodes). I'm not > sure if this will make trouble for other things, but it will certainly make > the frequently called function DofMap::build_constrain_matrix() more > efficient. I like this idea, but it would be a little more tricky than a single pre-processing step. If you do the pr-eprocessing in DofMap::create_dof_constraints(), then whenever the user calls DofMap::add_constraint_row() there's a possibility that the constraint list will now have become recursive again. Fixing that by doing another set of pre-processing sweeps after every add_constraint_row() call would be too expensive, and I can't think of any other easy solutions. --- Roy ```