Version 13 (modified by 12 years ago) ( diff ) | ,
---|
To illustrate the use of tracers inside of an object, this page will follow adding a tracer to the clump object.
Inside of clumps.f90, ClumpDef, there is:
INTEGER :: iTracer=0
This integer indexes the position in q of the clump tracer. When it is set to 0, there is no slot in q that holds the tracer, hence no tracer is assigned to the clump object.
To add a tracer to the clump object, one must assign a slot in q to hold the tracer. This is done by adding the following to ProblemModuleInit in problem.f90:
CALL AddTracer(MyClump%iTracer, "ClumpTracer")
First, this call passes in a non-zero integer to index the tracer in q, which is assigned in the routine AddTracer by identifying the next empty slot in q. Second, the name of the tracer is passed in, which is here called "ClumpTracer". This name is recognized by a visualization program such as Visit as a new variable.
Next, the tracer is distributed throughout the clump by the line in clumps.f90:
IF (Clump%iTracer .ne. 0) s(Clump%iTracer) = s(1)
This line says, if there is an assigned slot in q for the tracer, then assign as that tracer's value, s(1), where s(1) is defined earlier in clumps.f90 as:
s(1)=(perturb-q(1))*f !fade into clump
This source term takes the value of the clump density (perturb) and subtracts from it the density of the background density (q(1)), where background here means the ambient object "behind" the clump object. The f is a fading factor that is used within a smoothing region between clump and ambient object. If one is fully within the clump (and outside of the smoothing region), then f=1. The value of the density is then assigned by rho=q(1)+s(1)=perturb. If, on the other hand, one is fully outside of the clump, then f=0, and rho=q(1)+s(1)=q(1). Within the smoothing region, some value between 0 and 1 is used to fade the density between these two objects.
Now, assigning the tracer in this way means that the tracer is initialized with the same value of the density inside of the clump; where there is more density, there is more tracer in a 1:1 ratio. This allows one to easily calculate the amount of ambient material inside a cell by taking rho-tracer after the initial frame.