From: David Knezevic <dknez@MIT.EDU>  20090420 01:03:31

OK, so I've got a simple version of this working. I've attached a patch, as well as some new files for the instantiation of FEScalar (I sent this earlier, but didn't zip it up, so it didn't make it under the 40kb limit) Some notes:  As a first cut, I used lots of hacks in dof_map.h that will only work in serial  I used Roy's idea of letting the Order of SCALAR indicate how many scalar variables we want  I guess then it would be good to make sure that we only add one SCALAR to a system, but I haven't done that yet...  I didn't (yet) make any changes to the sparsity pattern, so adding to the last row(s) and column(s) of the matrix will be slow  Plotting the SCALAR variables gives garbage at the moment, although I guess it should be easy to change GMVIO etc to plot the constant value of the SCALAR I've attached a test example (lagrange_mult.C) for this functionality, using a Lagrange multiplier to solve a pure (homogeneous) Neumann problem, and enforcing that \int_\Omega u \dx = 5.  Dave Roy Stogner wrote: > > On Sat, 18 Apr 2009, David Knezevic wrote: > >> So, I'd really like to add this system.add_variable(foo,SCALAR) >> functionality to libMesh. I've been poking around the library, but I'm >> not really sure how to get started, so I could definitely use some >> pointers... >> >> It seems to me that the important details for this are in DofMap, for >> storing and retrieving the dof index of the scalar variable, as well as >> for setting the sparsity pattern/number of nonzeros...? > > That's right. > >> Some thoughts I've had are: >> >>  Add a new enum SCALAR to FEFamily (or alternatively, a new enum SCALAR >> to Order)? > > FEFamily. The Order would then specify how many scalars to add. > > Maybe next write an FE<SCALAR> specialization? Something that acted > sort of like a discontinuous monomial element? That might help > avoiding the need to add special cases to a lot of loops in the > library later. > >>  Short circuit all the loops over elements for DOF counting in DofMap >> for SCALAR variables, > > If the FE<SCALAR> claimed to have zero dofs per element, DofMap would > basically skip right over it... but I'm not sure that's an intuitive > behavior; this might be a loop you really do want a special case on. > >> and instead store the dof index of each SCALAR variable in a vector >> in DofMap? > > Right. > >>  However, I can't see where in the code one should compute the dof >> index of a SCALAR variable in the first place? > > That's all in dof_map.C. > >>  Ben, regarding setting the nonzero count and the number of rows that >> you mentioned; where is this controlled? In SparsityPattern? > > In SparseMatrix, I believe, although the code to build the sparsity > pattern is in DofMap. >  > Roy > 