underworldcode / underworld2

underworld2: A parallel, particle-in-cell, finite element code for Geodynamics.
http://www.underworldcode.org/
Other
168 stars 58 forks source link

How to avoid too much diffusion while projecting Temperature Field from swarm to mesh #418

Closed Prasanna2989 closed 4 years ago

Prasanna2989 commented 5 years ago

Hi All,

I have noticed an issue when I was projecting the temperature from Swarm to mesh variable. I use following code for this projection

I have produced the error as per the attachment.

Here, I take a mantle convection model and evaluate the temperature in the swarm coordinates. I want to deform the swarm, however I have tested this scenario without deforming the swarm to indicate the issue. When I project the swarm temperature in to mesh with the method that you mentioned above, the system diffuse the (heat)temperature faster than it should be. I was wandering this may be an issue with the projection routine. The resolution of the model is 16x16.

(I need this mechanism to change the temperature of magma intrusion in my model. I can see this method work fine in I2elvis and StagYY codes). Could you please give me some help with this.

import underworld as uw
mesh = uw.mesh.FeMesh_Cartesian()
temp_mesh = mesh.add_variable(1)
swarm = uw.swarm.Swarm(mesh)
swarm.populate_using_layout(uw.swarm.layouts.PerCellSpaceFillerLayout(swarm,20))
temp_swarm = swarm.add_variable("double",1)

# 1.
temp_swarm.data[:] = temp_mesh.evaluate(swarm.data)

# 2. 
#  advection and/or deform

# 3. 
projector = uw.utils.MeshVariable_Projection(temp_mesh,temp_swarm)  #  created this once
projector.solve()   # this for every time you need to project back to mesh again.`

Temperature of the mesh without projections (steps = 200)

temp1

Temperature of the mesh with projections (steps = 200)

Temp2

Thanks Pras

jmansour commented 5 years ago

Yep, the projection is definitely a diffusive operation. Have you tried the type=1 projector option? It should be less diffusive, but may produce spurious results where you have sharp gradients.

But why do you need to put the temperature on a swarm variable?

Prasanna2989 commented 5 years ago

Here, I am implementing mantle melt extraction process. So, when the melt marker is generated at a certain point in the mantle (Let's say at 0.7, if the model height is 1.), I create a new market at 0.9 depth with same temperature (I want to transfer some heat energy at once to increase the temperature of the surface layer). Mean time, I convert the previously existed marker in to different material based on the composition of the remaining material of melting event. Basically the idea is, I take one marker at 0.7 and break that marker in to 2 markers with equal temperature. One marker is sent to the surface while other remaining at the same location.

jmansour commented 5 years ago

Ok, definitely try the type=1 projector. I'd suggest as a simple synthetic test, you simply to the following in a loop and see how it behaves with increased repetition:

  1. Evaluate temp field onto swarm
  2. Project swarm temp variable back onto field.

Then, do the above again, but this time add your melting dynamics to see how well it is captured by the process.

Another option to consider is to leave everything on the mesh, and instead create heat sources/sink functions (possibly mesh variables) which effect the melting dynamics.