// Path: src/main/java/org/shaman/jmecl/OpenCLSettings.java
// public class OpenCLSettings {
// 	
// 	private final Context clContext;
// 	private final CommandQueue clCommandQueue;
// 	private final ProgramCache programCache;
// 	private final AssetManager assetManager;
// 
// 	public OpenCLSettings(Context clContext, CommandQueue clCommandQueue, 
// 			ProgramCache programCache, AssetManager assetManager) {
// 		this.clContext = clContext;
// 		this.clCommandQueue = clCommandQueue;
// 		this.programCache = programCache!=null ? programCache : new ProgramCache();
// 		this.assetManager = assetManager;
// 	}
// 
// 	public Context getClContext() {
// 		return clContext;
// 	}
// 
// 	public CommandQueue getClCommandQueue() {
// 		return clCommandQueue;
// 	}
// 
// 	public ProgramCache getProgramCache() {
// 		return programCache;
// 	}
// 
// 	public AssetManager getAssetManager() {
// 		return assetManager;
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		int hash = 3;
// 		hash = 43 * hash + Objects.hashCode(this.clContext);
// 		hash = 43 * hash + Objects.hashCode(this.clCommandQueue);
// 		return hash;
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (obj == null) {
// 			return false;
// 		}
// 		if (getClass() != obj.getClass()) {
// 			return false;
// 		}
// 		final OpenCLSettings other = (OpenCLSettings) obj;
// 		if (!Objects.equals(this.clContext, other.clContext)) {
// 			return false;
// 		}
// 		if (!Objects.equals(this.clCommandQueue, other.clCommandQueue)) {
// 			return false;
// 		}
// 		return true;
// 	}
// 
// }


import com.jme3.math.Vector3f;
import com.jme3.math.Vector4f;
import com.jme3.opencl.Buffer;
import com.jme3.opencl.CommandQueue;
import com.jme3.opencl.Kernel;
import com.jme3.opencl.Program;
import com.jme3.scene.VertexBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.shaman.jmecl.OpenCLSettings;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.shaman.jmecl.particles;


/**
 * A default advection strategy.
 * <p>
 * Particles can have:
 * <ul>
 * <li>a position</li>
 * <li>a velocity</li>
 * <li>an acceleration, or a global acceleration</li>
 * <li>a mass, or a global mass</li>
 * <li>a color</li>
 * </ul>
 * <p>
 * Deletion by (multiple can be specified):
 * <ul>
 * <li>axis aligned bounding box</li>
 * <li>bounding sphere</li>
 * <li>lower density threshold</li>
 * </ul>
 * <p>
 * Advection equation: <br>
 * <code> v = v + dt * (alpha*density*gravity - beta * temperature * gravity + velocity_field(x)/density </code> <br>
 * <code> x = x + dt * v </code>
 * <p>
 * Exponential decay: <br>
 * <code> temperature = temperature - dt * temperature * lambda </code> <br>
 * <code> density = density - dt * temperature * mu </code> <br>
 * It must hold that <code>dt * lambda < 1</code>, <code>dt * my < 1</code> for the largest possible timestep <code>dt</code>
 */
public class DefaultAdvectionStrategy implements AdvectionStrategy {

	private static final String SOURCE_FILE = "org/shaman/jmecl/particles/DefaultAdvectionStrategy.cl";
// Path: src/main/java/org/shaman/jmecl/OpenCLSettings.java
// public class OpenCLSettings {
// 	
// 	private final Context clContext;
// 	private final CommandQueue clCommandQueue;
// 	private final ProgramCache programCache;
// 	private final AssetManager assetManager;
// 
// 	public OpenCLSettings(Context clContext, CommandQueue clCommandQueue, 
// 			ProgramCache programCache, AssetManager assetManager) {
// 		this.clContext = clContext;
// 		this.clCommandQueue = clCommandQueue;
// 		this.programCache = programCache!=null ? programCache : new ProgramCache();
// 		this.assetManager = assetManager;
// 	}
// 
// 	public Context getClContext() {
// 		return clContext;
// 	}
// 
// 	public CommandQueue getClCommandQueue() {
// 		return clCommandQueue;
// 	}
// 
// 	public ProgramCache getProgramCache() {
// 		return programCache;
// 	}
// 
// 	public AssetManager getAssetManager() {
// 		return assetManager;
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		int hash = 3;
// 		hash = 43 * hash + Objects.hashCode(this.clContext);
// 		hash = 43 * hash + Objects.hashCode(this.clCommandQueue);
// 		return hash;
// 	}
// 
// 	@Override
// 	public boolean equals(Object obj) {
// 		if (obj == null) {
// 			return false;
// 		}
// 		if (getClass() != obj.getClass()) {
// 			return false;
// 		}
// 		final OpenCLSettings other = (OpenCLSettings) obj;
// 		if (!Objects.equals(this.clContext, other.clContext)) {
// 			return false;
// 		}
// 		if (!Objects.equals(this.clCommandQueue, other.clCommandQueue)) {
// 			return false;
// 		}
// 		return true;
// 	}
// 
// }


// Path: src/main/java/org/shaman/jmecl/particles/DefaultAdvectionStrategy.java
import com.jme3.math.Vector3f;
import com.jme3.math.Vector4f;
import com.jme3.opencl.Buffer;
import com.jme3.opencl.CommandQueue;
import com.jme3.opencl.Kernel;
import com.jme3.opencl.Program;
import com.jme3.scene.VertexBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.shaman.jmecl.OpenCLSettings;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.shaman.jmecl.particles;


/**
 * A default advection strategy.
 * <p>
 * Particles can have:
 * <ul>
 * <li>a position</li>
 * <li>a velocity</li>
 * <li>an acceleration, or a global acceleration</li>
 * <li>a mass, or a global mass</li>
 * <li>a color</li>
 * </ul>
 * <p>
 * Deletion by (multiple can be specified):
 * <ul>
 * <li>axis aligned bounding box</li>
 * <li>bounding sphere</li>
 * <li>lower density threshold</li>
 * </ul>
 * <p>
 * Advection equation: <br>
 * <code> v = v + dt * (alpha*density*gravity - beta * temperature * gravity + velocity_field(x)/density </code> <br>
 * <code> x = x + dt * v </code>
 * <p>
 * Exponential decay: <br>
 * <code> temperature = temperature - dt * temperature * lambda </code> <br>
 * <code> density = density - dt * temperature * mu </code> <br>
 * It must hold that <code>dt * lambda < 1</code>, <code>dt * my < 1</code> for the largest possible timestep <code>dt</code>
 */
public class DefaultAdvectionStrategy implements AdvectionStrategy {

	private static final String SOURCE_FILE = "org/shaman/jmecl/particles/DefaultAdvectionStrategy.cl";
	private static final Map<OpenCLSettings, Kernels> kernelMap = new HashMap<>();