From: Roy Stogner <roystgnr@ic...>  20050913 17:45:51

On Tue, 13 Sep 2005, Min Xu wrote: > I am thinking to attach two system to one equationsystem like: > > EquationSystems equation_systems (mesh); > > // The real system for diffusion equation > TransientLinearImplicitSystem & system = > equation_systems.add_system<TransientLinearImplicitSystem>("Diffusion"); > system.add_variable ("u", FIRST); > > // The dummy system for the coefficient alpha > LinearImplicitSystem & dummy = > equation_systems.add_system<LinearImplicitSystem>("Dummy"); > system.add_variable ("alpha", FIRST); This is one way to do things if you want both alpha and u to be defined on the same mesh, however unless you're going to be doing implicit solves for alpha you might want to make dummy an explicit system and avoid allocating an extra matrix. > The procedure follows: > (1) assign a coarse mesh and initialize the systems, mesh_psi = > mesh_alpha = mesh0. keep a copy of the mesh as mesh_coarse. You can keep a copy of the mesh, but alpha will always be defined on the mesh attached to equation_systems. If you want two different meshes for alpha and psi, there's currently no way to do so without two separate EquationSystems objects. > (1) If the two meshes are strictly that one is a refined version of the > another (maybe refined multiple times), is there a relative cheap way to use > alpha defined on the coarser mesh in the assemble routine for the equation > system? Any example for coefficients defined on a mesh? You're right that the problem is easier if one mesh is a superset of the other: if your alpha mesh is a coarser version of your psi mesh then a normal quadrature rule on psi will still be accurate when integrating terms containing alpha. However, the trick from a coding standpoint remains the same: in your assemble routine, you'll iterate through elements on the psi mesh. You'll need to integrate against data from the alpha mesh. This means you'll need to be able first to take a mesh_psi element and find the corresponding mesh_alpha element (via some map like I mentioned earlier) and second to take a mesh_psi master element point and find the corresponding mesh_alpha master element point (via inverse_map(), if you want to start with inefficient but correct and quicktoprogram code). > (2) Can project_vector work in a reverse direction, i.e., map a > vector defined on a finer mesh to a coarser mesh? If not, any > suggestion to implement such a projection? Currently the meshtomesh project_vector only works in the context of a single mesh whose elements are being refined and/or coarsened one level at a time, and so it's only meant to be called internally by the EquationSystems object. You could project all your EquationSystems vectors from a finer mesh to a much coarser mesh by repeatedly coarsening and calling EquationSystems::reinit(), but this is a one way process  you wouldn't be able to save fine mesh data. My suggestion would be to do such a projection with the same two EquationSystems objects you'd want to use for the rest of your problem. Either make alpha an implicit system and do an L2 projection, or simply do interpolation. Doing a projection would be the harder to code of the two choices, but would give you code portable to nonLagrange elements. Doing interpolation with Lagrange elements should be easy: iterate through all your mesh_alpha elements, find the corresponding mesh_phi elements, and copy over values. The mesh_phi elements will be inactive "ancestors", but they'll have the nodal data you want.  Roy Stogner 