From: Min Xu <minxu@sc...>  20050914 15:26:10

On Tuesday 13 September 2005 13:45, Roy Stogner wrote: > 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. > You are right. I could imagine though it may be desirable to allow the multiple systems defined within one equationSystem to use their individual meshes. For example, L1 psi1 = f (psi2) L2 psi2 = g(psi1) one can use different meshes for psi1 and psi2 as seen most effective. > > (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). The corresponding element number for the same spatial location may be different between the two meshes due to renumbering as you have pointed out in the earlier email. To implement such a mapping, how should I proceed? What is the index used for the solution vector? > > > (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. The required functionality conceptually belongs to MeshData. However, I do not find any way to use MeshData for this purpose such that data defined on a mesh can be casted into a new MeshData on its child or parent mesh by projection or restriction. Anyone knows a way? Thanks! Min 