-
John Regan authoredJohn Regan authored
externalgravity.rst 6.53 KiB
External Gravity Task Example
An example of how to implement an external gravity task in SWIFT
An external gravitational field can be imposed in SWIFT to mimic self-gravity. This is done by assigning a gravitational force that falls as $1/ r^2$ (mathjax support to be included).
In order to do this we update the files as described in :ref:`NewTask`. For the specific case of adding an external graviational field the additions are as follows:
task.h
Code (snapshot Nov 2015):
/* The different task types. */
enum task_types {
task_type_none = 0,
task_type_sort,
task_type_self,
task_type_pair,
task_type_sub,
task_type_ghost,
task_type_kick1,
task_type_kick2,
task_type_send,
task_type_recv,
task_type_link,
task_type_grav_pp,
task_type_grav_mm,
task_type_grav_up,
task_type_grav_down,
**task_type_grav_external,**
task_type_psort,
task_type_split_cell,
task_type_count
};
Task of type - task_type_grav_external - added to list of tasks.
task.c
Code (snapshot Nov 2015):
/* Task type names. */
const char *taskID_names[task_type_count] = {
"none", "sort", "self", "pair", "sub",
"ghost", "kick1", "kick2", "send", "recv",
"link", "grav_pp", "grav_mm", "grav_up", "grav_down", "grav_external",
"psort", "split_cell"
};
Task added to list of task names (used only for debugging purposed).
cell.h
Code (snapshot Nov 2015):
/* The ghost task to link density to interactions. */
struct task *ghost, *kick1, *kick2, *grav_external;
Struture of type "task" declared (or pointer to a task at least).