SPH
Settings.cpp
Go to the documentation of this file.
1 #include "gui/Settings.h"
3 #include "system/Settings.impl.h"
4 
6 
7 static RegisterEnum<RendererEnum> sRenderer({
8  { RendererEnum::NONE, "none", "No particle visualization" },
9  { RendererEnum::PARTICLE, "particle", "Particles are visualized as circles. No shading." },
10  /*{ RendererEnum::MESH,
11  "mesh",
12  "Surfaces of bodies are meshed using Marching cubes and drawed as triangles." },*/
14  "raymarcher",
15  "Use raymarching to find intersections with implicit surface." },
16  { RendererEnum::VOLUME, "volumetric", "Use raytracing to find total emission along the ray." },
17  //{ RendererEnum::CONTOUR, "contour", "Draws contours (iso-lines) of quantities" },
18 });
19 
20 static RegisterEnum<CameraEnum> sCamera({
21  { CameraEnum::ORTHO, "ortho", "Orthographic projection" },
22  { CameraEnum::PERSPECTIVE, "perspective", "Perspective projection" },
23  { CameraEnum::FISHEYE, "fisheye", "Fisheye equidistant projection" },
24  { CameraEnum::SPHERICAL, "spherical", "Spherical 360° projection" },
25 });
26 
27 static RegisterEnum<PlotEnum> sPlot({
28  { PlotEnum::INTERNAL_ENERGY, "internal_energy", "Plots the total internal energy." },
29  { PlotEnum::KINETIC_ENERGY, "kinetic_energy", "Plots the total kinetic energy." },
30  { PlotEnum::TOTAL_ENERGY, "total_energy", "Plots the sum of the internal and kinetic energy." },
31  { PlotEnum::TOTAL_MOMENTUM, "total_momentum", "Plots the total momentum." },
32  { PlotEnum::TOTAL_ANGULAR_MOMENTUM, "total_angular_momentum", "Plots the total angular momentum." },
33  /* { PlotEnum::PARTICLE_SFD,
34  "particle_sfd",
35  "Current cumulative size-frequency distribution of bodies in the simulation." },
36  { PlotEnum::PREDICTED_SFD,
37  "predicted_sfd",
38  "Size-frequency distribution that would be realized if we merged all particles that are currently "
39  "gravitationally bounded. It allows to roughly predict the final SFD after reaccumulation. Useful "
40  "for both NBody solvers and SPH solvers." },
41  { PlotEnum::CURRENT_SFD,
42  "current_sfd",
43  "Size-frequency distribution of particle components, i.e. groups of particles in mutual contact. "
44  "Useful for both NBody solvers and SPH solvers. Note that construcing the SFD has non-negligible "
45  "overhead, so it is recommended to specify plot period significantly larger than the time step." },*/
47  "selected_particle",
48  "Plots the current quantity of the selected particle." },
49 });
50 
51 static RegisterEnum<BrdfEnum> sBrdf({
52  { BrdfEnum::LAMBERT, "lambert", "Lambert shading" },
53  { BrdfEnum::PHONG, "phong", "Phong shading" },
54 });
55 
56 static RegisterEnum<ColorMapEnum> sColorMap({
57  { ColorMapEnum::LINEAR, "linear", "No colormapping transform" },
58  { ColorMapEnum::LOGARITHMIC, "logarithmic", "Uses logarithmic transform for color mapping" },
59  { ColorMapEnum::FILMIC, "filmic", "Uses filmic color mapping" },
60 });
61 
62 
63 // clang-format off
64 template<>
67  { GuiSettingsId::PARTICLE_RADIUS, "particle_radius", 0.5_f,
68  "Multiplier of the particle radius for drawing." },
70  "Specifies the projection of the particles to the image. Can be one of the following:\n" + EnumMap::getDesc<CameraEnum>() },
71  { GuiSettingsId::CAMERA_POSITION, "camera.position", Vector(0._f, 0._f, 1._f),
72  "Position of the camera in space." },
73  { GuiSettingsId::CAMERA_VELOCITY, "camera.velocity", Vector(0._f),
74  "Velocity of the camera in space." },
75  { GuiSettingsId::CAMERA_ORBIT, "camera.orbit", 0._f,
76  "Angular velocity of the camera orbiting arount its target." },
77  { GuiSettingsId::CAMERA_TARGET, "camera.target", Vector(0._f),
78  "Look-at point of the perspective camera. Actual distance from the camera does not matter." },
79  { GuiSettingsId::CAMERA_UP, "camera.up", Vector(0._f, 1._f, 0._f),
80  "Up-vector of the perspective camera. Does not have to be normalized." },
81  { GuiSettingsId::CAMERA_CLIP_NEAR, "camera.clip.near", EPS,
82  "Nearest distance that can be projected by the perspective camera" },
83  { GuiSettingsId::CAMERA_CLIP_FAR, "camera.clip.far", INFTY,
84  "Farthest distance that can be projected by the perspective camera" },
85  { GuiSettingsId::CAMERA_PERSPECTIVE_FOV, "camera.perspective.fov", PI / 3._f,
86  "Field of view of the perspective camera (in radians)." },
87  { GuiSettingsId::CAMERA_ORTHO_CUTOFF, "camera.ortho.cutoff", 0._f,
88  "Cut-off distance from center plane. Particles further away are not drawn. Used by particle renderer." },
89  { GuiSettingsId::CAMERA_ORTHO_FOV, "camera.ortho.fov", 1.e5_f,
90  "Field of view of the orthographic camera. Specified as distance (not an angle)."},
91  { GuiSettingsId::CAMERA_TRACK_PARTICLE, "camera.track_particle", -1,
92  "Index of the particle tracked by the camera. -1 means no tracking is used. " },
93  { GuiSettingsId::CAMERA_AUTOSETUP, "camera.autosetup", true,
94  "If true, camera parameters are automatically adjusted based on particle data. "
95  "This overrides other parameters, such as field of view, camera position, etc." },
96  { GuiSettingsId::CAMERA_TRACK_MEDIAN, "camera.track_median", false,
97  "If true, camera tracks the median position of particles. Not used if camera.track_particle is set." },
98  { GuiSettingsId::CAMERA_TRACKING_OFFSET, "camera.tracking_offset", Vector(0._f),
99  "Constant offset from the median." },
100 
103  "Selected renderer for particle visualization. Can be one of the following:\n" + EnumMap::getDesc<RendererEnum>() },
104  { GuiSettingsId::VIEW_WIDTH, "view.width", 800,
105  "Width of the rendered image (in pixels)." },
106  { GuiSettingsId::VIEW_HEIGHT, "view.height", 600,
107  "Height of the rendered image (in pixels)." },
108  { GuiSettingsId::VIEW_MAX_FRAMERATE, "view.max_framerate", 10, // ms
109  "Minimal refresh period of the drawed bitmap. Used to avoid visualization unnecessarily affecting "
110  "the performance of the simulation." },
111  { GuiSettingsId::REFRESH_ON_TIMESTEP, "view.refresh_on_timestep", true,
112  "If true, the image is automatically refreshed every timestep, otherwise manual refresh is needed." },
113  { GuiSettingsId::VIEW_GRID_SIZE, "view.grid_size", 0._f,
114  "Step of the grid drawn into the bitmap. If zero, no grid is drawn." },
115  { GuiSettingsId::SURFACE_RESOLUTION, "surface.resolution", 100._f, // m
116  "Resolution of the meshed surface (in world units). Lower values means the mesh is more detailed, "
117  "but construction takes (significantly) more time and memory." },
118  { GuiSettingsId::SURFACE_LEVEL, "surface.level", 0.13_f,
119  "Surface level for mesh renderer and raytracer. Specifies the value of the constructed/intersected "
120  "iso-surface of color field." },
121  { GuiSettingsId::SURFACE_SUN_POSITION, "surface.sun_position", Vector(0.f, 0.f, 1.f),
122  "Direction to the sun, used for shading in mesh renderer in raytracer." },
123  { GuiSettingsId::SURFACE_SUN_INTENSITY, "surface.sun_intentity", 0.7_f,
124  "Relative intensity of the sun, used for shading in mesh renderer in raytracer." },
125  { GuiSettingsId::SURFACE_AMBIENT, "surface.ambient", 0.3_f,
126  "Relative intensity of an ambient light, illuminating all shaded points." },
127  { GuiSettingsId::SURFACE_EMISSION, "surface.emission", 1._f,
128  "Emission multiplier used by raytracer. Note that emission is only enabled for Beauty quantity." },
129  { GuiSettingsId::RAYTRACE_SUBSAMPLING, "raytrace.subsampling", 1,
130  "Specifies a number of subsampled iterations of the progressive renderer. Larger values speed up the "
131  "start-up of the render at a cost of lower resolution of the render." },
132  { GuiSettingsId::RAYTRACE_ITERATION_LIMIT, "raytrace.iteration_limit", 10,
133  "Number of iterations of the render, including the subsampled iterations. " },
134  { GuiSettingsId::RAYTRACE_HDRI, "raytrace.hdri", std::string(""),
135  "Optional spherical bitmap used as an environment. Empty means the environment is black." },
137  "Surface BRDF. Applicable for raytracer. "},
138  { GuiSettingsId::RAYTRACE_SHADOWS, "raytrace.shadows", true,
139  "Take into account occlusions when computing surface illumination." },
140  { GuiSettingsId::RAYTRACE_SPHERES, "raytrace.spheres", false,
141  "If true, raytraced surface is given by spheres centered at particles, "
142  "otherwise isosurface of a colorfield is rendered." },
143  { GuiSettingsId::VOLUME_EMISSION, "volume.emission", 1.e-3_f,
144  "Volume emission per unit length. Used by volumetric renderer." },
145  { GuiSettingsId::VOLUME_ABSORPTION, "volume.absorption", 0._f,
146  "Absorption per unit length. Used by volumetric renderer." },
147  { GuiSettingsId::RENDER_GHOST_PARTICLES, "render_ghost_particles", true,
148  "If true, ghost particles will be displayed as transparent circles, otherwise they are hidden." },
149  { GuiSettingsId::BACKGROUND_COLOR, "background_color", Vector(0._f, 0._f, 0._f, 1._f),
150  "Background color of the rendered image." },
152  "Color mapping applied on the rendered image." },
153  { GuiSettingsId::COLORMAP_LOGARITHMIC_FACTOR, "colormap.logarithmic.factor", 2._f,
154  "Compression factor used by the logarithmic colormapper. Higher values imply stronger compression of "
155  "intensive pixels. Low values (~0.01) effectively produce a linear colormapping." },
156  { GuiSettingsId::SHOW_KEY, "show_key", true,
157  "Include a color pallete and a distance scale in the rendered image." },
158  { GuiSettingsId::FORCE_GRAYSCALE, "force_grayscale", false,
159  "Palette used for particle colorization is converted to grayscale. Useful for checking how the "
160  "image will look when printed on blank-and-white printer. "},
161  { GuiSettingsId::ANTIALIASED, "antialiased", false,
162  "Draw particles with antialiasing. Improves quality of the image, but may slow down the rendering." },
163  { GuiSettingsId::SMOOTH_PARTICLES, "smooth_particles", false,
164  "If true, rendered particles will be smoothed using cubic spline kernel. Useful to visualize the actual "
165  "extend of particles."},
166  { GuiSettingsId::CONTOUR_SPACING, "contour.spacing", 10._f,
167  "Different between values corresponding to subsequenct iso-lines" },
168  { GuiSettingsId::CONTOUR_GRID_SIZE, "contour.grid_size", 100,
169  "TODO" },
170  { GuiSettingsId::CONTOUR_SHOW_LABELS, "contour.show_labels", true,
171  "TODO" },
173  "Default colorizer shown when the simulation starts." },
174 
176  { GuiSettingsId::WINDOW_TITLE, "window.title", std::string("OpenSPH"),
177  "Title of the main window of the application." },
178  { GuiSettingsId::WINDOW_WIDTH, "window.width", 1110,
179  "Width of the main window." },
180  { GuiSettingsId::WINDOW_HEIGHT, "window.height", 600,
181  "Height of the main window." },
182  { GuiSettingsId::PLOT_INTEGRALS, "plot.integrals", PlotEnum::ALL,
183  "Integrals to compute and plot during the simulation. Can be one or more values of the following:\n"
184  + EnumMap::getDesc<PlotEnum>() },
185  { GuiSettingsId::PLOT_INITIAL_PERIOD, "plot.initial_period", 0.1_f,
186  "Initial period of time-dependent plots." },
187  { GuiSettingsId::PLOT_OVERPLOT_SFD, "plot.overplot_sfd", std::string(""),
188  "Path to the file containing SFD to plot over the computed one. The file must contain lines with value "
189  "N(>D) and D [km]. If empty, no SFD is drawn."},
190 
193  "Type of the renderer used when creating snapshot images. Values are the same as for 'renderer' entry." },
194  { GuiSettingsId::IMAGES_SAVE, "images.save", false,
195  "If true, snapshot images are periodically saved to disk." },
196  { GuiSettingsId::IMAGES_PATH, "images.path", std::string("imgs/"),
197  "Directory where the images are saved." },
198  { GuiSettingsId::IMAGES_NAME, "images.name", std::string("img_%e_%d.png"),
199  "File mask of the created images. Can contain wildcard %d, replaced with the counter of an image, "
200  "and %e, replaced with the name of the renderer quantity." },
201  { GuiSettingsId::IMAGES_FIRST_INDEX, "images.first_index", 0,
202  "Index of the first generated image."},
203  { GuiSettingsId::IMAGES_MAKE_MOVIE, "images.make_movie", false,
204  "If true, an animation is made from the saved images automatically at the end of the simulation. "
205  "Requires ffmpeg to be installed." },
206  { GuiSettingsId::IMAGES_MOVIE_NAME, "images.movie_name", std::string("%e.avi"),
207  "File mask of the animation." },
208  { GuiSettingsId::IMAGES_TIMESTEP, "images.time_step", 0.1_f,
209  "Period of creating the snapshot images." },
210  { GuiSettingsId::IMAGES_WIDTH, "images.width", 800,
211  "Width of the created images." },
212  { GuiSettingsId::IMAGES_HEIGHT, "images.height", 600,
213  "Height of the created images." },
214 
215 });
216 // clang-format on
217 
219 template <>
221  SPH_ASSERT(instance != nullptr);
222  return *instance;
223 }
224 
225 // Explicit instantiation
226 template class Settings<GuiSettingsId>;
227 template class SettingsIterator<GuiSettingsId>;
228 
#define SPH_ASSERT(x,...)
Definition: Assert.h:94
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Object converting quantity values of particles into colors.
@ VELOCITY
Particle velocities.
constexpr Float EPS
Definition: MathUtils.h:30
constexpr Float INFTY
Definition: MathUtils.h:38
constexpr Float PI
Mathematical constants.
Definition: MathUtils.h:361
#define NAMESPACE_SPH_END
Definition: Object.h:12
BasicVector< Float > Vector
Definition: Vector.h:539
Wrapper of pointer that deletes the resource from destructor.
Definition: AutoPtr.h:15
Iterator useful for iterating over all entries in the settings.
Definition: Settings.h:486
Generic object containing various settings and parameters of the run.
Definition: Settings.h:108
static const Settings & getDefaults()
\brief Returns a reference to object containing default values of all settings.
@ COLORMAP_LOGARITHMIC_FACTOR
@ RAYTRACE_ITERATION_LIMIT
@ IMAGES_NAME
Mask of the image names, having d where the output number will be placed.
@ PARTICLE_RADIUS
Displayed radius of particle in units of smoothing length.
@ SURFACE_RESOLUTION
Size of the grid used in MarchingCubes (in code units, not h).
@ CAMERA_ORTHO_CUTOFF
Max z-coordinate of particle to be displayed by ortho renderer.
@ WINDOW_TITLE
Title of the window appearing on taskbar.
@ IMAGES_PATH
Path of directory where the rendered images will be saved.
@ RENDERER
Selected renderer.
@ VIEW_GRID_SIZE
Size of the grid cell in simulation units (not window units); if zero, no grid is drawn.
@ SURFACE_LEVEL
Value of iso-surface being constructed; lower value means larget bodies.
@ SURFACE_SUN_INTENSITY
Intentity of the sun.
@ IMAGES_SAVE
If true, rendered images are saved to disk.
@ SURFACE_SUN_POSITION
Direction to the sun used for shading.
@ CAMERA_ORTHO_FOV
View field of view (zoom). Special value 0 means the field of view is computed from the bounding box.
@ SURFACE_AMBIENT
Ambient color for surface renderer.
@ TOTAL_MOMENTUM
Evolution of the total momentum in time.
@ INTERNAL_ENERGY
Evolution of the total internal energy in time.
@ SELECTED_PARTICLE
Evolution of the selected quantity for the selected particle in time.
@ TOTAL_ANGULAR_MOMENTUM
Evolution of the total angular momentum in time.
@ KINETIC_ENERGY
Evolution of the total kinetic energy in time.
@ PARTICLE
2D section showing particles as points
@ RAYMARCHER
Raymarcher that computes intersections with implicit surface.
@ VOLUME
Volumetric renderer.
@ NONE
No particle visualization.
Helper class for adding individual enums to the enum map.
Definition: EnumMap.h:175